Skip to content

fix(health): recheck a merged run directory from its shards - #4996

Merged
AdamRajfer merged 10 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/recheck-aggregated-shards
Oct 26, 2026
Merged

AdamRajfer merged 10 commits into
NVIDIA-NeMo:mainfrom
AdamRajfer:fix/recheck-aggregated-shards

Conversation

@AdamRajfer

@AdamRajfer AdamRajfer commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

After gym eval aggregate merges runs, a health recheck can lose shard failures and expected-task counts, then overwrite the correct report. Reused task indices from different inputs can also look like duplicates.

Aggregation records a hash-checked source-shard list. Default health checks use those shards and their task namespaces; changed or missing files stop the check before replacing the report.

flowchart LR
    A[Source shards and failures] --> B[Aggregate rows]
    B --> C[Save shard list and hashes]
    C --> D[Health check validates sources]
    D --> E[Recompute source-aware counts]
Loading

Regression tests and a real-CLI replay of saved artifacts verify aggregate/recheck counts, duplicate handling, aliases and resume summaries. Focused collection/health tests and changed-file hooks pass.

An explicit --rollouts-file checks that file alone. Unsafe file aliases are rejected; ordinary in-place aggregation remains supported. Writers invalidate stale lists; no-op resumes retain them. A stopped no-op resume preserves shard-backed counts; a full recheck reads current source failures and inventories. Generation, rewards and retries are unchanged.

`gym eval aggregate` checks the health of the shards it reads: each
shard's rows, its failure sidecar and its materialized inputs. The
merged rollouts.jsonl holds only the rows, so `gym eval health-check`
of the merged directory checked those rows alone. Every failure and
every inventory was lost, and the recheck overwrote the aggregation's
quality summary with one that counted none of them.

Aggregation now lists the shards it merged, in its order, in
rollouts_sources.json next to the merged file, with the merged file's
size. A recheck of that directory without --rollouts-file reads the
listed shards, as the aggregation did, so it counts the same rollouts.
It refuses when a shard is gone or the merged file is not the one the
aggregation wrote. An explicit --rollouts-file still checks that file
alone.

The shards are listed relative to the merged directory, so the tree can
move as a whole. The merged file is written aside and moved into place
after the list, so it never stands without one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Oct 23, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@AdamRajfer AdamRajfer self-assigned this Oct 23, 2026
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 5f039e9

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci added area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters bug Something isn't working labels Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HOLD — two RISK findings in merged-run provenance need correction before merge.

The new source manifest restores the intended accounting on the ordinary path, but its identity check can accept an interrupted replacement, and file-symlink resolution can lose the sidecars used during aggregation. The inline comments include scoped corrections and acceptance checks.

Reviewed all seven changed files and traced the affected aggregation, CLI selection, manifest loading, and health-accounting paths. Static review only; tests were not executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/rollout_health.py Resolved
Comment thread nemo_gym/rollout_health.py Resolved
Two gaps in the shard list, found in review:

- Equal sizes do not make equal contents. A second aggregation into the
  same directory that stopped before its merged file took its place
  could leave a list whose size matched the first merged file. A
  recheck would then read the second aggregation's shards for the first
  one's rows. The list now records the merged file's SHA-256 as well,
  and the recheck checks it after the size.
- A shard reached through a file link was recorded by its target. A
  recheck then looked for the sidecars beside the target, while the
  aggregation had read the ones beside the link. Only the directories
  are resolved now, and each shard keeps its file name.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 3ac53cf

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/review

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP — both prior RISK findings are resolved; no eligible follow-up findings remain.

  • Merged-content identity: the manifest now hashes the temporary merged contents before publication, and rechecks verify that digest before writing reports. The regression tests cover interrupted equal-size replacement, unchanged reports, and successful reaggregation.
  • Symlink-local artifacts: manifest writing and loading preserve each shard’s filename while resolving directories. The regression cases distinguish alias-local artifacts, target-only artifacts, and directory symlinks.

Compared the fixes with the previous reviewed tree, inspected all seven changed files, and traced the affected publication, recheck, and sidecar-accounting paths. This was a follow-up review, not a fresh broad review. Static inspection only; tests were not executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@AdamRajfer
AdamRajfer marked this pull request as ready for review October 23, 2026 17:39
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the needs-review PR is ready for code review and waiting on a reviewer label Oct 23, 2026

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP — no eligible findings remain in this same-head follow-up.

Verified that the earlier failures remain fixed:

  • Merged-content identity: the manifest writer and reader bind the manifest to the merged file’s size and SHA-256 before report generation. The interrupted-reaggregation regression checks rejection without changing either report, followed by successful reaggregation.
  • Symlink-local artifacts: directory-only resolution preserves each shard’s filename and sibling-artifact lookup. The regression cases distinguish alias-local artifacts, target-only artifacts, and directory symlinks.

Accounted for all seven changed files and traced the relevant publication, recheck, and health-accounting paths. The head equals the latest reviewed baseline, so no subsequent changes require regression review; this was not a fresh broad review. Static inspection only; tests were not executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a findings-only review. Request a full review with /review reset=true.

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HOLD — one RISK remains in the lifecycle of the new source manifest when an aggregate output is reused for fresh collection.

The earlier content-identity and symlink-local-artifact findings are fixed in the current source; the regressions cover those concrete failures.

Completed a fresh broad review of all seven changed files and traced aggregation publication, CLI selection, health accounting, and output reuse. Static inspection only; tests were not executed.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/rollout_collection.py Resolved
Review of the shard list found four gaps:

- A run that writes an output an aggregation merged into left the list
  behind: a fresh or resumed `gym eval run`, `gym eval reverify`, and
  the GDPval multistage driver. A recheck of that directory then
  refused the run's own rollouts. Each now removes the list when it
  takes over the output.
- A shard changed after the aggregation, for example by a resume, was
  read as it is now, while the merged rows and metrics hold what it
  held then. The list now records each shard's size and SHA-256 from
  the read the merge makes anyway, and a recheck refuses a changed
  shard.
- Merging onto one of several shards replaced a shard the merge had
  read and listed the merged file as that shard, so a recheck counted
  its rows twice. That is now refused before anything is written. A
  single run merged onto itself, the in-place metrics repair, still
  works and needs no list.
- The merged file replaced a symlinked output instead of writing
  through it as before. The temporary file now sits beside the link's
  target and replaces the target.

The docs and help now say that --rollouts-file checks that file alone,
so a merged file not named rollouts.jsonl is rechecked shard by shard.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/ok to test 1027768

@AdamRajfer

Copy link
Copy Markdown
Contributor Author

/review reset=true

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HOLD — one prior RISK remains: a single-shard file alias loses shard-backed accounting on recheck.

Verified both latest fixes in the current source: shard resolution now runs in a worker thread, and permission instrumentation uses portable descriptor operations, retaining the staging and final-mode assertions. Those prior findings are closed.

Completed a fresh light review of all 12 changed files and traced the directly affected aggregation, CLI selection, health-accounting, and writer paths. Static inspection only; tests and the suggested correction were not executed. Verify the suggestion before adopting it.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

Comment thread nemo_gym/rollout_collection.py Resolved
Reject in-place file aliases whose sidecars live beside another name.
Use source shards for the post-run health report and avoid replacing
shard-backed accounting with a single-file provisional report on stop.
Document the supported in-place path and cover the affected boundaries.

Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer
AdamRajfer enabled auto-merge October 26, 2026 18:16
@AdamRajfer
AdamRajfer added this pull request to the merge queue Oct 26, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40377429218

Merged via the queue into NVIDIA-NeMo:main with commit 4945282 Oct 26, 2026
53 of 56 checks passed
@AdamRajfer
AdamRajfer deleted the fix/recheck-aggregated-shards branch October 26, 2026 18:55
yuhezhang-ai added a commit that referenced this pull request Oct 26, 2026
Brings in #4996 (recheck a merged run directory from its shards) and #4921.
Integration with the run history:

- A fresh run drops a stale shard list in RolloutStore.start_or_resume, which
  owns the fresh-run cleanup here. Collection drops the list with the first
  row of any kind, since every outcome writes a row (an unpersisted result is
  saved as an omission).
- Post-collection health stays in the CLI. A merged output with a shard list
  is checked from its shards without this run's coverage, which describes
  only its own rows.
- Aggregation reads history-backed shards from their history and hashes every
  shard for the list. The merge uses main's writer, which records the list
  before the merged rows replace the output, plus an fsync. A merge never
  replaces one of its shards, so it always lists them; the refusal names that
  case in main's words.
- The reverification and gdpval writers drop the list through this branch's
  resolved output path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
yuhezhang-ai added a commit that referenced this pull request Oct 26, 2026
… rules

#4996's tests assumed main's aggregation, which merges a run onto itself and
into a directory holding a run. This branch refuses both, because merged rows
would replace rows the run's history indexes.

- Merging a run onto itself, directly or through a linked directory, is
  refused before anything is written; merge_shards=false still recomputes its
  metrics in place.
- A fresh run into an aggregated output drops its shard list; a resume finds
  no run history there and stops before writing.
- Aggregating into a run with history is refused and changes nothing.
- A file link's companions are read beside the link when they sit there,
  otherwise beside the file it resolves to, which owns them, as do a linked
  output's shard list and reports.
- A failed publication leaves the original rows and a shard list that names
  contents that never landed, so a recheck refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>
mikemikimike pushed a commit to mikemikimike/Gym that referenced this pull request Oct 31, 2026
…A-NeMo#3302)

* feat(eval): persist outcomes and resume unfinished evaluations

Rebase the final NVIDIA-NeMo#3302 implementation onto main after NVIDIA-NeMo#4029 and NVIDIA-NeMo#4178. Preserve cancellation and timing cleanup, remove retired Stirrup migration paths, forward GDPVal retry progress, and allow selected-source judge recovery into separate output. Verify saved rewards reach the live counter exactly once.

Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): preserve retry and scoring compatibility

Signed-off-by: Yuhe Zhang <[email protected]>

* test(gdpval): isolate HTTP recovery fixtures from core tests

Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): preserve managed recovery through explicit resubmission

Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): align tracing fixtures with managed recovery

Return a valid scored completion from the incoming telemetry fixture. Verify that resuming a completed run neither sends requests nor emits duplicate rollout dispatch traces.

Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): align recovery health and retry reporting

Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): mark exhausted resume chains incomplete

Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): align recovery checks with saved run policy

Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): accept the health span context in the native-failure health test

Main's NVIDIA-NeMo#5052 passes the dispatch span context to _record_rollout_health as a fourth argument. Give this test's stub the same optional parameter as main's other stubs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): accept typed judge failures and keep failure paths and legacy classes

NVIDIA-NeMo#5072 lets judge_failsafe name the observed cause as its failure_kind (for
example judge_rate_limited) while the routing class stays judge_failed, and
adds a diagnostic _ng_failure_path. Its base Environment Server also fills
in a kind such as provider_unavailable when the producer left it unset.

- _episode_record() accepts the judge markers and the path on a result whose
  class is judge_failed and whose kind is a judge kind, not only judge_failed
  itself. Such a result stays a retryable judge failure that
  --judge-failed-only re-judges, instead of a terminal
  environment_protocol_violation (or an aborted run without sidecar routing).
- _sanitize_legacy_result() and the native failure branch of _episode_record()
  keep _ng_failure_path on the saved row as a diagnostic, outside the typed
  record.
- An Environment Server failure with a kind keeps environment_server_failed as
  its legacy class, so count_failure_classes_as_zero and the other class
  selectors still match it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): reply with the dispatched episode identity in the provenance tests

Main's provenance tests answered every row with a fixed or malformed episode id. Collection validates a reply against the episode it dispatched, so answer with that identity.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): keep a legacy link's companions when checking health

Health resolved every rollout path to the file it links to, so a legacy run
reached through a file link lost the sidecar and inventory kept beside the
link. Aggregation and the shard glob keep the link's name in that case
(resolve_rollout_path), so a recheck counted less than the aggregation it
checks. Resolve health paths with the same reader rule.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): align main's aggregation tests with the run-history merge rules

NVIDIA-NeMo#4996's tests assumed main's aggregation, which merges a run onto itself and
into a directory holding a run. This branch refuses both, because merged rows
would replace rows the run's history indexes.

- Merging a run onto itself, directly or through a linked directory, is
  refused before anything is written; merge_shards=false still recomputes its
  metrics in place.
- A fresh run into an aggregated output drops its shard list; a resume finds
  no run history there and stops before writing.
- Aggregating into a run with history is refused and changes nothing.
- A file link's companions are read beside the link when they sit there,
  otherwise beside the file it resolves to, which owns them, as do a linked
  output's shard list and reports.
- A failed publication leaves the original rows and a shard list that names
  contents that never landed, so a recheck refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): format the omitted-rollout test parameters

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* fix(arena): also limit final judge-outage failures

With the run history, an outage counts as a final failure once its retries
are used up, so the not-final limit NVIDIA-NeMo#5073 set would stop catching it. Each
Arena benchmark now sets the final-failure limit to the same share.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): accept NVIDIA-NeMo#5072's judge failure report on judge_failed results

NVIDIA-NeMo#5072's judge_failsafe now attaches a failure report instead of a failure
path: `_ng_failure_events`, `_ng_failure_id` and, when events were left out,
`_ng_failure_events_omitted`. NVIDIA-NeMo#3302 rejected those as collector-owned keys,
so a judge outage either aborted collection or became a terminal
environment_protocol_violation that lost the saved answer.

A judge_failed result may now carry those three keys. They stay on the row
as diagnostics, beside the version-1 failure record and not inside it, and
legacy agents keep them too. The unused `_ng_failure_path` handling is
removed, and other collector-owned keys stay forbidden.

The judge fixtures use the row NVIDIA-NeMo#5072's code produces for a judge 429.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* refactor(eval): name the saved failure record RolloutFailureRecord

The failure-boundary design names the saved envelope RolloutFailureRecord:
a run's identity plus the failure data, apart from the runtime exceptions
that report failures. The record, its version and its fields are
unchanged. `RolloutFailure` stays importable as an alias of the same class.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): mark the judge report's event ids for the secrets detector

The event ids are random hex from NVIDIA-NeMo#5072's judge_failsafe output, which detect-secrets reads as high-entropy
strings. Name each once with the repository's allowlist pragma.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): mark incomplete CLI runs as failed in tracking

Preserve the final saved-coverage gate after merging NVIDIA-NeMo#5213, and mark its rejected completions as failed for exporters. Keep SIGTERM and retryable/exhausted exit codes unchanged. Cover both CLI paths and tolerated partial runs with a real local MLflow store.

Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): integrate main's health layering and partial-stage checks

Move collection health reporting below the CLI layer and pass shutdown state
from CLI callers. Register the recovery modules in main's import contract,
without adding dependency exceptions, and refresh the import inventory for
three private helpers intentionally replaced by the recovery implementation.

Cover accepted GDPVal partial stages followed by a still-incomplete stage,
including a no-progress resume. Accepted omissions must not be counted twice.
Align the older GDPVal test with the stage-aware partial-acceptance report.

Validation: 2,707 targeted tests and all-files pre-commit passed. The new
GDPVal regression fails under a controlled double-credit mutation.

Signed-off-by: Yuhe Zhang <[email protected]>

* fix(imports): finish recovery compatibility with package moves

Expose the existing ConfigError and ENVIRONMENT_SERVER_FAILED definitions
through the package APIs used by the conformance runner and legacy adapter.
Update the remaining recovery test and conformance import paths. No failure,
scoring, or retry policy changes.

Validation: 3,197 targeted tests and all-files pre-commit passed, including
package interfaces, import layering, recovery, legacy adapter and conformance.

Signed-off-by: Yuhe Zhang <[email protected]>

* test(eval): follow verification and runtime package moves

Signed-off-by: Yuhe Zhang <[email protected]>

* fix(eval): preserve run identity and saved recovery policy

Signed-off-by: Yuhe Zhang <[email protected]>

* test(swe-pivot): align runtime stub with public imports

Signed-off-by: Yuhe Zhang <[email protected]>

---------

Signed-off-by: Yuhe Zhang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
public — f0e45838 Deployed Oct 26, 2026 by copy-pr-bot[bot] via release / finalize / notify #7363
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:evaluation Evaluation, rollout collection, reward profiling, comparison, and exporters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer sla:review-overdue Review response is over the one-business-day SLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants