Skip to content

fix(tier3): end the rich progress table's line off a terminal, and find a case's trials by its recorded case - #668

Merged
rng1995 merged 7 commits into
mainfrom
naren/fix-progress-case-summary-utf8-followups
Nov 16, 2026
Merged

rng1995 merged 7 commits into
mainfrom
naren/fix-progress-case-summary-utf8-followups

Conversation

@rng1995

@rng1995 rng1995 commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes two problems found while reviewing #546 and #548. Both were already on main before those PRs and were not filed.

  1. --progress rich on 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).
  2. The "How to improve" list missed failed attempts whose trial name does not start with the case ID (found during fix(tier3): count token usage per case correctly and keep the terminal token notes accurate #546).
    • case_summary matched trials by d.name.split("__")[0] == case_id, but Harbor names a trial after the first 32 characters of its task directory.
    • So it 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.
    • Effect: 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.

A third item from the #549 review was dropped. It said a non-UTF-8 SKILL.md gets the embedding provider's reason, but #549's last commit already fixed that before it merged. tests/ci/test_run_tiers.py and tests/embedding/test_registry.py pin the current behaviour.

Changes

  • Progress (tier3/harbor/progress.py). A new _stop_live writes one line end after the table when the console is not a terminal, in the same write as the table.

    • A stream that keeps a refused table, as standard error's buffer does, keeps its line end too.
    • Both the normal close and the stop after a drawing failure use it.
    • Terminals, a dumb terminal included, already get their line end from Live; their output is byte-for-byte unchanged.
  • Case summary (tier3/case_summary.py). A trial's case is read as the token usage report reads it:

    • first the entry_id the collector recorded in failure.json;
    • then the entry_id in reward.json;
    • then the task directory that result.json or config.json names;
    • only then the trial name.

    It reuses report_data._recorded_case_id and _harbor_task_directory, which read without following links.

    • what_to_fix groups each agent's trials by case once instead of rescanning them for every case.
    • The case rows rebuilt for a failed arm use the same case.
    • The live case grid keys a trial by the whole task directory, so a long-named case's attempts count in its own row.
  • Follow-ups from independent review of the two fixes:

    • Progress with TTY_INTERACTIVE=1 on 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, including TTY_INTERACTIVE=0.
    • A reward whose case the collector rejected (7c9c3393). For a trial stopped before Harbor wrote result.json, the collector fails the reward as an unsafe reward identity and records the placeholder entry_id unknown. 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 named unknown.
    • Declined: a similar trial-name check in 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).

    • A failed condition persists no pass@k cases, so _cases rebuilds its rows from the trial files each time it is asked.
    • what_to_fix asks 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_fix now keeps the rebuilt rows for the length of the call, keyed by agent and condition, and the next call reads the trials again.
    • On a failed arm of 30 cases with 5 attempts each, CPU drops from 2.9 s to 0.4 s, which is also below main's 1.8 s.
  • 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

  • Tests that fail on main. Each new test was run against main's source (b201fb72), and each failure below is an assertion error:
    • Progress: 6 of 8 new tests in tests/test_tier3_progress.py fail on 3.14 and 3.13, showing text such as ╯Result: pass. The 2 that pass are guards that terminal output is unchanged.
    • Case summary: 6 new tests in tests/test_tier3_case_summary.py fail. For example, the run error reads only 1 attempt(s) never produced a score, and a failed judge gets the run-error advice.
    • Follow-ups: the TTY_INTERACTIVE=1 tests (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.
  • Affected modules (first two fixes), together with every module that uses the reused helpers:
    • 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.
    • Results: 2,183 passed on Python 3.14 and 2,182 on 3.13.
    • The failures were 1 on 3.14 and 2 on 3.13, all in the NeMo Gym signal tests test_gym_cli_probe_failure_contains_descendants[interrupt] and test_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.
  • After the follow-ups (head 7c9c3393):
    • The progress, skip-with-skill, case-summary, result-display, next-steps, case-findings, validate-cases and view-results-feedback modules: 697 passed on Python 3.14 and 697 on 3.13.
    • The CHANGELOG-reading tests also pass.
  • After the review fix and the merge (head 57b56eb6):
    • The progress, case-summary, result-display, next-steps, case-findings, validate-cases and view-results-feedback modules: 709 passed on Python 3.14 and 709 on 3.13.
    • test_failed_condition_rows_are_rebuilt_once_per_what_to_fix_call fails without the cache on both versions.
    • With Rich forced to 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.
  • CHANGELOG-reading tests (first two fixes): 8 passed on 3.14 and 3.13.
  • Lint: ruff check and ruff format --check pass on the changed files.

🤖 Generated with Claude Code

rng1995 and others added 2 commits November 16, 2026 04:55
… 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>
rng1995 and others added 4 commits November 16, 2026 06:19
…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 rng1995 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@rng1995
rng1995 merged commit c06b5fa into main Nov 16, 2026
27 checks passed
@rng1995
rng1995 deleted the naren/fix-progress-case-summary-utf8-followups branch November 16, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant