Skip to content

Put the pinned Hookdeck CLI on PATH for Codex's login shells - #115

Merged
leggetter merged 5 commits into
mainfrom
cli-on-path-for-login-shells
Nov 6, 2026
Merged

leggetter merged 5 commits into
mainfrom
cli-on-path-for-login-shells

Conversation

@leggetter

Copy link
Copy Markdown
Collaborator

Fixes #114.

What was wrong

Codex runs most commands in a login shell (/bin/bash -lc): 2,233 of its 2,456 shell commands in release run 42044644850. A login shell sources Debian's /etc/profile, which replaces PATH with /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games. That leaves out the npm prefix holding the pinned CLI (/home/node/.npm-global/bin). The PATH the harness sets on docker exec only reaches non-login shells, which is why Claude Code was unaffected, and why the few Codex attempts that ran hookdeck only through bash -c found it.

What changed

  • Dockerfile: the npm prefix goes on PATH through ENV (non-login shells, root execs) and through /etc/profile.d/npm-global.sh (login shells). I used a profile.d entry rather than symlinks into /usr/local/bin because it covers the whole prefix, including skills and anything an agent installs with npm install -g mid-run. The CLI version is unchanged (2.5.0).
  • Image tag: now includes a hash of the Dockerfile. ensureSandboxImage reuses any existing tag, so without this a machine with a cached image would keep the old one.
  • Harness fingerprint: now includes the same image-definition hash. Rows measured before and after this change carry different harness values, and export-results --merge reports carried rows as harness changed. reference/results-format.md is updated.
  • Sandbox self-check (packages/sandbox/src/toolchain-check.ts): before seeding or credentials, it probes bash -c and bash -lc for hookdeck and its --version, with ANSI colour stripped before the version is matched. A failure errors the cell through the existing errored-cell path, so no result file is written. There are two kinds:
    • Facts about the image: command -v hookdeck resolves nothing (the probe prints a sentinel and exits 3), or the version line is not the pin. These throw sandbox self-check failed.
    • Anything else: an in-container timeout, a refused docker exec, a dead container, no version line. This is retried once, then throws sandbox self-check could not complete, which errors that cell alone.
    • It uses --version rather than hookdeck version, because the subcommand creates ~/.config/hookdeck/config.toml and calls the GitHub API inside the agent's sandbox. The flag does neither.
  • CI: a broken image cancels the run. Every job builds the same image, so Run evals treats sandbox self-check failed like a provider refusal. It writes a sandbox-broken marker, uploads it, and cancels the run. publish-results refuses any run carrying a sandbox-broken-* artifact. A test fails if the workflow, the marker steps or the error string drift apart.
  • triage: two new flags, raised whether the cell passed or failed.
    • PINNED CLI NOT ON PATH means the shell said hookdeck: command not found, so the agent had to find the CLI.
    • UNPINNED CLI means a hookdeck-cli@<other> ran.
    • Only shell commands are read, so a docs page mentioning @latest doesn't trip either flag. Against run 42044644850: 69 of 76 Codex cells flagged, 2 of them also UNPINNED CLI, and none of the 38 Claude Code cells.
  • AGENTS.md: a Trap entry for the login-shell PATH reset and what CI does when the self-check fails, and the new triage signal.

Verified

  • pnpm -r build, pnpm typecheck, sandbox package typecheck: pass
  • pnpm check: framework 131/131, core 115/115, sandbox 49/49, web 71/71
  • pnpm format:check, biome check: clean
  • actionlint 1.7.12 (with shellcheck): no findings
  • New tests:
    • the probe, run for real in a local shell (directly and nested in single quotes), against no hookdeck, a stand-in printing 2.5.0 and one printing 3.1.0
    • classification of timeouts, dead containers and missing version lines as inconclusive, and of coloured or hyperlinked --version output as the version it contains
    • retry once, then a cell-only error that does not carry the cancelling string
    • the workflow's grep string, marker write, Record broken sandbox step, Cancel the run condition and publish refusal against the code
    • the profile.d snippet, taken from the Dockerfile and run under sh with Debian's login PATH: the prefix comes back first, appears once however often it is sourced, and is written before USER node
    • the image tag and the harness fingerprint both change when the image definition does
    • the triage detector and its two flags, on a row shaped like a real one

Not verified

Docker wasn't available, so the image hasn't been built. An independent review confirmed from source the /etc/profile behaviour (Debian base-files and bash skel) and the --version output (v2.5.0 source, cobra, the binary's ldflags), but nobody has run either in the image. That Codex's login shells resolve the CLI on the new image is still to be confirmed. The cancel and publish-refusal path for a broken sandbox hasn't been exercised in CI.

Proposed check: dispatch codex-gpt-5.4-mini on benchmark-localdev-001-listen-locally with runs=1 and EVALS_PUBLISH=false. Then confirm the log has no sandbox self-check, the transcript has no command not found, and triage raises neither flag.

Not in this change

No results are re-run or re-published here. The Codex cells of the v0.5.0 matrix are re-run after this merges.

🤖 Generated with Claude Code

leggetter and others added 5 commits November 5, 2026 21:06
Codex runs every command as `/bin/bash -lc`. A login shell sources
Debian's /etc/profile, which replaces PATH with a fixed list that leaves
out /home/node/.npm-global/bin, so the PATH the harness passes on
`docker exec` never reached a Codex tool call. In release run
42044644850 every Codex attempt that invoked `hookdeck` got
`command not found` (26/26, 18/22, 16/16 and 19/19 across the four
Codex arms) and worked around it by absolute path, `npx`, an unpinned
`npx -y hookdeck-cli@latest`, or the REST API. Claude Code runs
`bash -c`, inherits the PATH, and was unaffected.

- Dockerfile: put the npm prefix on PATH with `ENV` (non-login shells
  and any exec without an explicit PATH) and with an
  /etc/profile.d/npm-global.sh entry (login shells). A profile.d entry
  rather than symlinks into /usr/local/bin, so `skills` and anything an
  agent installs with `npm install -g` are covered too. The installed
  CLI version is unchanged.
- Image tag: include a hash of the Dockerfile, so a machine with a
  cached image rebuilds instead of reusing one without the fix.
- Sandbox self-check: before a cell starts, run
  `command -v hookdeck && hookdeck --version` in a non-login and a
  login shell and throw unless both resolve the pinned version. The
  throw errors the cell, so no result file is written. `--version`
  rather than `hookdeck version`, which creates a config file and
  calls GitHub inside the agent's sandbox.
- triage: flag PINNED CLI NOT USED for a cell whose shell said
  `hookdeck: command not found` or that ran a `hookdeck-cli@<version>`
  other than the pin. Against run 42044644850 it flags 69 of 76 Codex
  cells and none of the 38 Claude Code cells.
- AGENTS.md: a Trap entry for the login-shell PATH reset, and the new
  triage signal.

Not verified in a built image: Docker was not available where this was
written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The login-shell PATH fix changed only the Dockerfile, and it gave the
Codex arms the pinned Hookdeck CLI they had been missing. The harness
fingerprint covered the base prompt, the CLI pin, the skills CLI and
the skills submodule pin, so rows measured with and without the CLI on
PATH would have carried the same `harness` hash and read as measured
under one instrument.

`harnessFingerprint` now also hashes the image definition: the same
12-character Dockerfile hash the image tag uses, exported from the
sandbox package as `sandboxImageDefinition`. Every row recorded before
this change has a different `harness` from every row after it, which
is the point; `export-results --merge` will report carried-forward
rows as measured under a different harness.

reference/results-format.md and the two code comments that list the
fingerprint inputs now name the image definition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A failed sandbox self-check is systemic: every matrix job builds the
same image from the same Dockerfile, so one broken image errors every
cell. Until now each cell errored on its own and the matrix ran to the
end.

Reuse the provider-refusal path (#103):

- Run evals: when the eval exits non-zero and the log contains
  `sandbox self-check failed`, write sandbox-broken.marker (experiment,
  eval, matched string; no log lines) and exit 1.
- Record broken sandbox: upload it as
  `sandbox-broken-<experiment>__<eval>`, kept 90 days like the
  provider marker.
- Cancel the run: now fires on either marker.
- publish-results: refuses a run with any `sandbox-broken-*` artifact,
  the same way it refuses `provider-refused-*`, so a cancel that does
  not take still cannot publish.

The string is exported from toolchain-check.ts as
SANDBOX_SELF_CHECK_FAILED and starts the error the check throws. A test
fails if eval-refresh.yml stops matching it. AGENTS.md's Trap entry
says what CI does with the failure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review fixes for the sandbox self-check and the wording around it.

The self-check gave every failed probe the `sandbox self-check failed`
prefix, which CI now treats as a run-level failure. An in-container
timeout (124/137), a `docker exec` the daemon refused or a container
that had died would therefore have cancelled the whole matrix over one
cell's bad minute.

- The probe now prints a sentinel and exits 3 when `command -v
  hookdeck` resolves nothing, so a missing CLI cannot be confused with
  `docker exec` exiting 1 for a dead container.
- Only two outcomes are facts about the image and carry the cancelling
  prefix: no `hookdeck` on PATH, or a recognisable version line that
  is not the pin. Anything else, including a probe that throws, is
  retried once and then throws `sandbox self-check could not complete`,
  which errors that cell alone. A test holds the second prefix to not
  containing the first.
- Tests run the real probe in a local shell, both directly and nested
  in single quotes as the login probe is, against a PATH with no
  `hookdeck`, a stand-in printing 2.5.0 and one printing 3.1.0. The
  fixtures for a missing CLI now match what the probe returns.
- The drift test also checks that `Record broken sandbox` exists and
  uploads the marker, and that `Cancel the run` fires on
  `sandbox-broken.marker` as well as `provider-refused.marker`.
- triage: the single PINNED CLI NOT USED flag is now two.
  PINNED CLI NOT ON PATH says the agent had to find the CLI, which by
  absolute path or unversioned `npx` was still the pinned 2.5.0.
  UNPINNED CLI is raised only where a `hookdeck-cli@<other>` ran.
  Against run 42044644850: 69 of 76 Codex cells flagged, 2 of them
  also UNPINNED CLI, and none of the 38 Claude Code cells.
- Wording: Codex runs most commands in a login shell, not every one.
  In run 42044644850, 2,233 of its 2,456 shell commands were `bash -lc`.
  The four Codex attempts that invoked `hookdeck` without hitting
  `command not found` ran it only through `bash -c`. AGENTS.md, the
  Dockerfile, docker-sandbox.ts, toolchain-check.ts and pinned-cli.ts
  now say so. reference/results-format.md, provenance.ts and image.ts
  no longer claim the image change has given Codex the CLI. That is
  for the first run on the new image to confirm.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The version match in classifyToolchainProbe is a whole
whitespace-delimited token. A CLI release that coloured `--version`
would put an escape code against the number. Every cell of a working
image would then read as the wrong version, and the run would cancel.
stdout and stderr are now stripped of CSI sequences (including SGR
colour) and OSC sequences (including hyperlinks) before anything is
matched. A test covers coloured output with CRLF, an OSC 8 hyperlink
with both terminators, and a coloured 3.1.0, which must still read as
the wrong version.

The Run evals `::error::` for a broken sandbox no longer says the CLI
is not on PATH, since a wrong version raises it too: "The sandbox image
failed its self-check (pinned Hookdeck CLI missing from PATH or wrong
version)".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leggetter
leggetter merged commit 5b0644c into main Nov 6, 2026
1 check passed
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.

The pinned Hookdeck CLI was not on PATH in Codex's login shells

1 participant