Repository navigation
fix(tier3): end the rich progress table's line off a terminal, and find a case's trials by its recorded case - #668
Conversation
… stream With --progress rich and standard error not a terminal, for example redirected to a file or piped to another program, Rich's Live draws the progress table only when it stops and, unlike on a terminal, does not end the table's last line. The run's close() left the cursor after the bottom border, so the next output was printed on the same line: the caller's next log line or result, the shell prompt, or the line saying that progress stopped after a drawing error (on time, kept by the stream, or the late one written when the run ends). Live's stop now writes one line end after the table when the console is not a terminal, in the same write as the table, so a stream that keeps a refused table, as standard error's buffer does, keeps its line end too. Both the run's close() and the stop after a drawing failure use it. A terminal, a dumb terminal included, already gets its line end from Live and its output is byte-for-byte unchanged; the plain and off modes do not use Live. Tests: forced rich on a non-terminal stream ends the table with exactly one line end before the caller's next line (plain text stream, a stderr-shaped pipe, and a pipe that is full when the run ends); the stop notice on such a pipe starts its own line under the table and appears once when the changed plan line is refused, when the notice is refused too, and when the pipe is full until the run ends (late notice). All six fail on the old source on Python 3.14 and 3.13. Two guards check that a terminal and a dumb terminal still end the table with one line end. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…name
The "How to improve" list found a case's errored and judge-failed trials
by d.name.split("__")[0] == case_id. Harbor names a trial after the first
32 characters of its task directory, so this missed every trial of a
native or NeMo Gym task whose [metadata] entry_id differs from its
directory, and of a case ID longer than 32 characters. Such a case's run
error had no cause and no evidence file, and a failed judge got the
generic run error advice instead of the judge remedy. The case rows
rebuilt for a failed arm were keyed by the trial name too, so they named
the task directory instead of the case.
case_summary now reads a persisted trial's case as the token usage report
does: the entry_id the collector recorded in failure.json (from the run's
selector map or staged task map), then the entry_id in reward.json, then
the task directory that result.json or config.json names, and only then
the name. It reuses report_data's _recorded_case_id and
_harbor_task_directory, and what_to_fix groups each agent's trials by case
once instead of rescanning them for every case. The live case grid keys a
trial by the whole task directory its config.json names, so a long-named
case's attempts count in its staged row instead of a second row.
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…RACTIVE=1 With --progress rich, standard error not a terminal and TTY_INTERACTIVE=1 in the environment, Rich treats the pipe or file as interactive. Live then draws a whole table under every line printed while it runs, which includes each plan line that changes during the run. Off a terminal Rich drops the cursor moves that would erase those tables, so each copy stayed in the output with its last line open, and the next plan line or the final table started on the same line as its bottom border. The previous commit only ended the last table's line. The progress view's console is no longer interactive when its stream is not a terminal. Live then draws the table once, as it stops, the same as without TTY_INTERACTIVE, and the line end added in the previous commit follows it. A terminal keeps Rich's own setting, TTY_INTERACTIVE=0 included. Tests: with TTY_INTERACTIVE=1 on a plain text stream, a stderr-shaped pipe, and a pipe that refuses the changed plan line, the output has one table, the changed plan line on a line of its own, and the next output (or the stop notice, once) on its own line under the table. All three fail on the previous source on Python 3.14 and 3.13. A guard checks that a terminal stays interactive by default and with TTY_INTERACTIVE=1, and not with TTY_INTERACTIVE=0. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d's case The previous commit made case_summary read a persisted trial's case from the entry_id in its reward.json before the task directory or the trial name. When the collector cannot tie a reward to a case, as for a trial stopped before Harbor wrote result.json, it fails the reward with "Reward identity violates the bounded publication contract" and records the placeholder entry_id "unknown". Such a trial then moved to a case named "unknown": a failed arm's rebuilt rows and its "How to improve" entry named a case that does not exist, and a scored arm's missing attempt lost its collector cause and its reward.json evidence. case_summary now skips the reward's entry_id when the collector rejected that reward's case, so the trial keeps the case its config.json task directory or its name gives, as it did before. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Six of the new progress tests failed on the Windows CI job. They counted "╯", the bottom-right corner of the ROUNDED box the progress table uses, but Rich draws that box SQUARE on a legacy Windows console, so the table ends with "┘" there. The tests now ask Rich for the corner of the box it draws on the reporter's console. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rng1995
left a comment
There was a problem hiding this comment.
Review of #668 at 56ccbf7: three lenses (progress, case summary, tests and docs), each finding checked by three independent reviewers.
One finding holds (inline). Three were dropped: a plan line refused while Live runs is printed twice, and a refused final frame can be cut by a full stderr buffer, but both behave the same on main and this PR does not change them; the TTY_INTERACTIVE CHANGELOG entry is accurate for the case it describes.
CI on 7c9c339 is fixed at 56ccbf7: the six Windows progress test failures (Rich draws the ROUNDED box SQUARE on a legacy Windows console, so the tests now ask the console for the corner), the Python 3.12 linear-time flake (#665, merged into this branch with main) and the Bedrock invalid-region test (passes after the merge with main).
…fix call A failed condition persists no pass@k cases, so _cases rebuilds its rows from the trial files every time it is asked. what_to_fix asks for an agent's rows several times for each case (the case list, each case's diagnosis and comparability, then the baseline checks), so the trials were re-read for every case. Finding each failed trial's case from its records in this PR doubled that work: on a failed arm of 60 cases, CPU went from 8.9 s to 17.2 s. what_to_fix now keeps the rows it rebuilds for the length of the call, by agent and condition, and the next call reads the trials again. On a failed arm of 30 cases with five attempts each, CPU drops from 2.9 s to 0.4 s. Signed-off-by: Narendran Raghavan <nraghavan@nvidia.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
Fixes two problems found while reviewing #546 and #548. Both were already on main before those PRs and were not filed.
--progress richon a stream that is not a terminal leaves the table's last line open (found during fix(tier3): say progress stopped when a plan line is refused, and keep the running spinner moving #548).case_summarymatched trials byd.name.split("__")[0] == case_id, but Harbor names a trial after the first 32 characters of its task directory.[metadata] entry_iddiffers from its directory, and of a case ID longer than 32 characters.A third item from the #549 review was dropped. It said a non-UTF-8
SKILL.mdgets the embedding provider's reason, but #549's last commit already fixed that before it merged.tests/ci/test_run_tiers.pyandtests/embedding/test_registry.pypin the current behaviour.Changes
Progress (
tier3/harbor/progress.py). A new_stop_livewrites one line end after the table when the console is not a terminal, in the same write as the table.Case summary (
tier3/case_summary.py). A trial's case is read as the token usage report reads it:entry_idthe collector recorded infailure.json;entry_idinreward.json;result.jsonorconfig.jsonnames;It reuses
report_data._recorded_case_idand_harbor_task_directory, which read without following links.what_to_fixgroups each agent's trials by case once instead of rescanning them for every case.Follow-ups from independent review of the two fixes:
TTY_INTERACTIVE=1on a pipe (f875345a). Rich treated the pipe as interactive, so Live drew a whole table under every plan line that changed during the run. Off a terminal, those copies stayed in the output, each with its last line open. The progress view's console is now not interactive when its stream is not a terminal, so the table is drawn once, as the run ends. A terminal keeps Rich's own setting, includingTTY_INTERACTIVE=0.7c9c3393). For a trial stopped before Harbor wroteresult.json, the collector fails the reward as an unsafe reward identity and records the placeholderentry_idunknown. The case summary no longer reads that placeholder, so the trial keeps the case its task directory or name gives, instead of moving to a case namedunknown.result_display.py. It only decides whether a "Missing scored attempts" line is already explained by a printed trial label, so it does not map trials to cases."How to improve" rebuilds a failed condition's rows once per call (
57b56eb6, from the PR review)._casesrebuilds its rows from the trial files each time it is asked.what_to_fixasks several times for each case. Finding each failed trial's case from its records doubled that work: CPU went from 8.9 s to 17.2 s on a failed arm of 60 cases.what_to_fixnow keeps the rebuilt rows for the length of the call, keyed by agent and condition, and the next call reads the trials again.Windows CI fix (
56ccbf75). The new progress tests counted╯, the corner of the table's ROUNDED box. Rich draws that box SQUARE on a legacy Windows console, so the table ends with┘there. The tests now ask Rich for the corner of the box it draws on the reporter's console.Main merged in (
1b9889cc), with no conflicts. This brings test(tier3): time the masking linear-time checks in CPU time, in turn #665's fix for the linear-time masking flake and the change that makes the Bedrock invalid-region preflight test pass again.One CHANGELOG entry for each of the three user-visible fixes, under Unreleased → Fixed.
Testing
b201fb72), and each failure below is an assertion error:tests/test_tier3_progress.pyfail on 3.14 and 3.13, showing text such as╯Result: pass. The 2 that pass are guards that terminal output is unchanged.tests/test_tier3_case_summary.pyfail. For example, the run error reads only1 attempt(s) never produced a score, and a failed judge gets the run-error advice.TTY_INTERACTIVE=1tests (plain text stream, stderr-shaped pipe, refused plan line) fail on the first progress fix. The rejected-identity tests fail on the first case-summary fix. Both were checked on 3.14 and 3.13.tests/test_tier3_progress.py,tests/tier3/test_skip_with_skill.py,tests/test_tier3_case_summary.py,tests/test_nemo_gym_backend.py,tests/reporting/test_case_findings_report.py,tests/reporting/test_tier3_validate_cases.py,tests/validators/test_security.py,tests/tier3/test_view_results_feedback.py.test_gym_cli_probe_failure_contains_descendants[interrupt]andtest_detached_cleanup_defers_termination_until_finished[SIGHUP]. Both fail the same way on unmodified main on this Mac, and this PR does not touch NeMo Gym code.7c9c3393):57b56eb6):test_failed_condition_rows_are_rebuilt_once_per_what_to_fix_callfails without the cache on both versions.legacy_windows, the six progress tests that failed on Windows CI fail on the old tests and pass on the new ones, on 3.14 and 3.13.ruff checkandruff format --checkpass on the changed files.🤖 Generated with Claude Code