Skip to content

fix(tier3): omit local Codex credential dirs from stop-on-pass merges - #276

Merged
rng1995 merged 5 commits into
mainfrom
naren/port-codex-credential-home-cleanup
Nov 3, 2026
Merged

rng1995 merged 5 commits into
mainfrom
naren/port-codex-credential-home-cleanup

Conversation

@rng1995

@rng1995 rng1995 commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

--stop-on-pass runs with local-mode Codex now finalize even when Harbor's Codex cleanup did not run. The merged per-arm job no longer contains the Codex credential.

  • _merge_attempt_jobs snapshots each attempt job with copytree_secure. That snapshot now gets an ignore callback that drops codex-home and codex-secrets in two places only:
    • directly under <trial>/agent
    • directly under <trial>/steps/<step>/agent, where Harbor 0.24's multi-step trials move agent logs after each step
  • The callback matches paths against copytree_secure's own lexical source root, so platform root aliases still work (for example macOS /tmp -> /private/tmp).
  • Everything else still goes through the existing symlink, reparse-point and hard-link checks. That includes the same names at any other depth, such as artifacts/agent/codex-home.
  • The source attempt jobs are not modified.
  • New constants LOCAL_CODEX_HOME_DIRNAME and LOCAL_CODEX_SECRETS_DIRNAME live in the dependency-free skillevaluator.tier3.harbor package. SkillEvaluatorLocalCodex builds its _REMOTE_CODEX_HOME / _REMOTE_CODEX_SECRETS_DIR from them, and so does the runner's exclusion set, so the two cannot drift apart.
  • CHANGELOG entry under Unreleased / Fixed.

Why

In local mode, SkillEvaluatorLocalCodex keeps Codex's runtime home and credential under each trial's agent log dir, not /tmp, so that concurrent trials do not share them. Harbor's Codex agent works like this:

  1. It writes codex-secrets/auth.json, which holds the OPENAI_API_KEY value or an uploaded host auth.json.
  2. It runs ln -sf to point codex-home/auth.json at that file.
  3. It removes both dirs only in a finally block that swallows every exception.

If a trial times out, is cancelled, or the cleanup command fails, both dirs stay in <trial>/agent/.

With --stop-on-pass, those per-attempt jobs are then snapshotted before the merge:

  • A leftover auth.json symlink made the secure copy fail with "symlink or reparse point". The merge failed closed and the run could not finalize.
  • A regular-file auth.json was copied into the merged job together with the API key. With --harbor-keep-jobs that copy stays on disk.

Docker and the other backends keep CODEX_HOME at /tmp/codex-home inside the container, so they are not affected. Runs without --stop-on-pass do not merge attempts, so they are not affected either.

Kept from public

  • Fail-closed secure copy. The exclusion is a narrow, depth-anchored ignore list. It does not relax copytree_secure, so links anywhere else in a trial still reject the merge. A 15-path test pins this.
  • Root-swap and overlap guards. The whole-job-root link, fingerprint, and source/aggregate overlap checks in _merge_attempt_jobs are unchanged. The second copy reads from the private snapshot, so it needs no change.
  • Judge score consistency. The same upstream change also stopped rejecting judge payloads whose score contradicts their criteria. Public already does this, and more broadly (fix(tier3): derive accuracy scores from criterion verdicts #190): it derives the score from applicable criteria, including the excluded SKILL_IDENTIFIED case. That part is not ported. The only internal-only piece is a score_mismatch diagnostic field, which is left out to keep this PR focused.

Tests

New tests in tests/test_harbor_runner_status.py, next to the existing merge tests:

  • test_merge_attempt_jobs_omits_leftover_local_codex_credential_dirs has 12 cases. It is parametrized over:

    • single-step agent/ and multi-step steps/step-1/agent/
    • auth.json as a link to codex-secrets, a link to a host file, or a regular file
    • descriptor and fallback copy backends

    Each case checks that both dirs are absent from the merged trial and that the key appears in no merged file. It also checks that trajectory, agent log, verifier reward, artifacts, and look-alike artifacts/agent/codex-* paths are kept, that the merged trial result is valid, and that the source attempt is unchanged. Without the fix, all 12 cases fail: the linked layouts raise "symlink or reparse point", and the regular-file layout copies the credential.

  • test_merge_attempt_jobs_codex_exclusions_track_local_codex_runtime_dirs checks that SkillEvaluatorLocalCodex and SkillEvaluatorLocalNvidiaBuildCodex both put their runtime dirs directly under Harbor's EnvironmentPaths.agent_dir, using the excluded names.

  • test_merge_attempt_jobs_rejects_auth_links_outside_trial_codex_dirs has 15 cases. A linked auth.json at a trial root, under steps/, under artifacts/agent/, in a nested agent/, or in look-alike dir names still rejects the merge, and a pre-existing aggregate is left untouched.

The fixture key is synthetic and below Gitleaks' generic-key entropy threshold, so no allowlist entry is needed.

Validation:

  • Rebased on current main. Ran tests/test_harbor_runner_status.py, test_harbor_runner_artifacts.py, test_harbor_secure_copy.py, test_harbor_local_mode.py, test_harbor_local_environment.py, test_harbor_local_upload.py, test_harbor_runner_environment.py, test_nvidia_build_bridge.py, test_tier3_public_runtime.py, test_oss_packaging.py, test_character_facts.py, test_harbor_runtime_skill_isolation.py, test_tier3_case_summary.py, test_tier3_progress.py, tests/tier3/ and tests/reporting/test_tier3_scoped_reports.py: 8,225 passed, 7 skipped.
  • ruff check and ruff format --check pass on the changed files.
  • OSS boundary check passes.

🤖 Generated with Claude Code

In local mode, Codex keeps its runtime home and credential under each
trial's agent log dir: codex-secrets/auth.json holds the API key (or an
uploaded host auth.json) and codex-home/auth.json links to it. Harbor
removes both only in a best-effort cleanup that swallows errors, so a
timed-out or cancelled trial can leave them behind.

With --stop-on-pass, the per-attempt jobs are snapshotted with the
secure copier before they are merged. A leftover auth.json symlink made
that copy fail closed, so the run could not finalize, and a regular-file
auth.json was copied into the merged job together with the credential.

Pass an ignore callback to the attempt snapshot that drops codex-home and
codex-secrets only directly under <trial>/agent or
<trial>/steps/<step>/agent (Harbor's multi-step layout). Paths are
matched against the copier's own lexical source root, so platform root
aliases such as macOS /tmp keep working. Every other path, including the
same names at any other depth, still goes through the existing symlink
and hard-link checks. The source attempt jobs are left unchanged.

Share the directory names between SkillEvaluatorLocalCodex and the
runner through the dependency-free tier3.harbor package, and pin them
with a test so the exclusion tracks the agent's paths.

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

@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.

Reviewed the diff in full context. No findings. The ignore callback is limited to /agent and /steps//agent, so the secure copier's symlink and hard-link checks still apply everywhere else; the new tests cover both copy backends, all three auth.json layouts, the multi-step layout and a set of look-alike paths that must still fail closed. Constants are shared with local_agents.py and a test pins them to the agent class. tests (-k merge_attempt_jobs, 54 passed) and ruff pass locally. Minor style note only: runner.py imports the private _absolute_lexical helper from secure_copy; a public alias would be cleaner but is not worth blocking on.

Reviewed with Claude Code.

@chrisknvidia
chrisknvidia force-pushed the naren/port-codex-credential-home-cleanup branch from 2b187c4 to 532f94e Compare October 30, 2026 22:24
Conflicted files: CHANGELOG.md

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

@chrisknvidia chrisknvidia left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The ignore callback is wired correctly: _merge_attempt_jobs has one snapshot copy of the source job, and the later per-trial copy and the final publish both read from that filtered snapshot, so the dirs are gone from every copy after it. The same callback runs for both secure-copy backends, and the manifest rebuild uses the same callback, so the copy-time recheck agrees. One gap: the depth match only covers a step name with a single path component.

With --harbor-keep-jobs the whole _harbor-jobs directory is kept, including the untouched source attempt dirs, so the leftover codex-secrets/auth.json is still on disk there. This PR stops the second copy and the failed merge, which is fine, but the description reads as if the key no longer reaches retained output. Worth saying that in the description, or scrubbing the two dirs from the source attempt once the snapshot is taken.

rng1995 and others added 3 commits November 3, 2026 04:27
The stop-on-pass merge only dropped leftover local Codex runtime dirs in
<trial>/agent and <trial>/steps/<one component>/agent. Step names may span
several path components, so a step such as phase/author kept the old
behavior: a linked codex-home/auth.json failed the merge, and a regular
codex-secrets/auth.json was copied into the merged job.

Read the step names the trial declares in its result.json (or in the
attempt root's trial_results entry, the merge's own fallback) without
following links, validate them as the runtime preflight does, and also
drop the dirs in those step agent dirs. Undeclared, absolute and
dot-segment step paths still go through the secure copier's link checks.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicted files: CHANGELOG.md.

Signed-off-by: Narendran Raghavan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@rng1995
rng1995 merged commit cb52c19 into main Nov 3, 2026
21 checks passed
@rng1995
rng1995 deleted the naren/port-codex-credential-home-cleanup branch November 3, 2026 20:08
rng1995 added a commit that referenced this pull request Nov 6, 2026
* docs(changelog): move entries released in 0.7.0-0.7.2 out of Unreleased

0.7.0 (#314) and 0.7.1 (#327) never cut their sections on main, and 0.7.2
(#335) added its section below the whole Unreleased block, so Unreleased
still listed work that had already shipped.

Place each Unreleased entry under the release that shipped the PR that
added it:

- 0.7.0: the published section from the 0.7.0 tag, verbatim. It already
  holds the six entries that main had filed under 0.6.0, so 0.6.0 again
  matches the v0.6.0 tag, including the original run_config.json entry.
- 0.7.1: #264 #271 #274 #281 #284 #289 #293 #299 #316 #317 #318 #323
  #324 #326 #327, plus the #320 wording of the Windows Git-root entry,
  since #320 changed that 0.7.0 fix in 0.7.1.
- 0.7.2: #263 #265 #269 #270 #276 #279 #287 #290 #296 #309 #328 #330
  merged with the existing #335 entries.

Only post-v0.7.2 entries stay under Unreleased, with one heading per
subsection. Entry text is unchanged, apart from the published tag wording
in 0.7.0 and 0.6.0.

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

* chore(release): prepare v0.8.0

Set the package, fallback, lock, citation and developer-guide versions to
0.8.0 and move every entry merged since v0.7.2 under
'## 0.8.0 - 2026-11-05', leaving Unreleased empty.

The refusal-fallback documentation test now reads the release section
that names CLAUDE_CODE_DISABLE_REFUSAL_FALLBACK, requires it to be 0.8.0,
and requires exactly one entry there to name the switch.

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

* chore(release): pin the verified 0.8.0 Tier 1 image and add its CI bundle

Pin onboarding to the Tier 1 image published by the reviewed main revision
55d2d04 in "Build and publish Tier 1 image" run 42158955180:
ghcr.io/nvidia/skillevaluator-tier1@sha256:9d5483243918937be4f2178f74cf7c622a531dee41e3176906994d52fa14950a
(config sha256:d17d6f5105ec5f1bf0cbe4dff0d693aae4ecf01e9c1c6a6ddb7830518acace33).
The workflow and publisher refs both move to 55d2d04.

ci/bundles/0.8.0 mirrors the 0.7.2 bundle. The templates, README and
release.json are the run's github-actions-onboarding artifact and match
ci/render_templates.py output for these pins byte for byte. The scanner
inventory and verification receipt come from the build's runtime-stage
version step, the five-case smoke receipt, the onboarding job's anonymous
pull, and the public manifest, whose config digest equals the smoke-tested
image ID. The ZIP uses the 0.7.2 layout (sorted members, inner checksums,
1980 timestamps, 0644, deflate level 9) and rebuilds to identical bytes.

Point the current-bundle links at 0.8.0 and list 0.7.2 as historical.

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

---------

Signed-off-by: Narendran Raghavan <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants