Repository navigation
fix(#8635): take hook settings from the runner after .env on all runtimes - #8637
Conversation
|
/fs-fix-stop |
|
Fix agent disabled for this PR. Remove the |
|
🤖 Finished Review · ✅ Success · Started 9:50 PM UTC · Completed 10:02 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $3.15 |
|
<!-- fullsend:risk-assessment --> DetailsLarge change size across runtime files with high churn is mitigated by zero protected path edits, strong test ratio, bot authorship, and close alignment with linked issue #8635. Previous run<!-- fullsend:risk-assessment --> DetailsModerate risk: large change size across runtime files with high churn is balanced by zero protected path edits, strong test ratio, bot authorship, and close alignment with linked issue #8635. |
ReviewFindingsLow
Previous run<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJjb21tZW50IiwiZmluZGluZ3MiOlt7InNldmVyaXR5IjoibWVkaXVtIiwiY2F0ZWdvcnkiOiJmYWlsLW9wZW4iLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9waV9ydW4uZ28iLCJpZCI6ImZfZDEyZTgzMGFhZGE2ODVmNSIsImxpbmUiOjYyMywiYWN0aW9uYWJsZSI6ZmFsc2V9LHsic2V2ZXJpdHkiOiJsb3ciLCJjYXRlZ29yeSI6InBhdHRlcm4taW5jb25zaXN0ZW5jeSIsImZpbGUiOiJpbnRlcm5hbC9ydW50aW1lL3BpX2Jvb3RzdHJhcC5nbyIsImlkIjoiZl8zYjdiMzgxMmY5OWY5NDA0IiwibGluZSI6NDI1LCJhY3Rpb25hYmxlIjpmYWxzZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiY29kZS1vcmdhbml6YXRpb24iLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9jb2RleF9ib290c3RyYXBfdGVzdC5nbyIsImlkIjoiZl80ODhkZWU5OTY5Y2Q0NDBiIiwibGluZSI6Njc5LCJhY3Rpb25hYmxlIjpmYWxzZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoibmFtaW5nLWNvbnZlbnRpb24iLCJmaWxlIjoiaW50ZXJuYWwvcnVudGltZS9jb2RleF9ydW5fdGVzdC5nbyIsImlkIjoiZl81ZWRhNzYyZWFlNDc4ZmRiIiwibGluZSI6NzcxLCJhY3Rpb25hYmxlIjpmYWxzZX0seyJzZXZlcml0eSI6ImxvdyIsImNhdGVnb3J5IjoiZG9jLXN0eWxlIiwiZmlsZSI6ImRvY3MvY29udHJpYnV0aW5nL3J1bnRpbWUtaW1wbGVtZW50YXRpb24ubWQiLCJpZCI6ImZfMzA2Nzg2MTMwMTcyODAzZCIsImxpbmUiOjEzOTUsImFjdGlvbmFibGUiOmZhbHNlfV19 --> ReviewFindingsMedium
Low
Labels: PR changes runtime launch/hook environment handling in the agent runner |
…imes The sandbox hook scripts read TIRITH_FAIL_ON, TIRITH_REQUIRED, FULLSEND_EGRESS_ALLOWLIST, FULLSEND_CANARY_TOKEN and FULLSEND_TOOL_ALLOWLIST from the environment, and the workspace .env that carries them is agent-writable. Codex recorded them at Bootstrap and re-exported them after the .env load. The Claude Code and pi launches did not, so iteration 1 could change what iteration 2's hooks saw. Move the codex mechanism into sandbox_hooks_env.go: - bootstrapHookEnv records the SandboxHookConfig values plus the harness pair, read back from .env before the first iteration. - hookEnvExports exports each name the runner has a value for and unsets the rest, so a value only .env carries never reaches the hooks (codex included; it used to export only names with values). Claude Code keeps the values in claudeHookDigests and pi in a runner-side map next to piManifestHashes; both re-assert them after .env. pi's childEnv copies the launch env, so the hook adapter and sub-agents inherit them. A pi launch with no Bootstrap entry emits nothing, as for its manifest guard. Tests run each runtime's .env handling under /bin/sh with a .env that changes every name. Dropping the re-export or the unset fails them. Codex goldens regenerated; docs updated. Note: pre-commit could not fetch its hook repos (TLS failure in the sandbox). The hooks that apply to these files were run directly (whitespace, EOF, gofmt, go vet, gitleaks via scan-secrets, broken symlinks, docs links, lychee) and pass. One pi JS test (SIGTERM to grandchildren) also fails on main in this sandbox; it is unrelated. Closes #8635 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With sandbox hooks on, buildPiRunCommand re-asserts the hook settings only when Bootstrap recorded them in this process; without a record the launch left them to .env. Run now refuses to start pi in that case, as Claude Code and codex refuse without their runner-held digests. Also rewrap the edited contributor-docs paragraph. Assisted-by: Claude (fix), Codex (review) Signed-off-by: Wayne Sun <gsun@redhat.com>
fc6568b to
52a2e54
Compare
|
🤖 Review · ❌ Terminated · Started 10:54 PM UTC · Ended 11:06 PM UTC Commit: |
Site previewPreview: https://d6afaef6-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Note: The following review comments could not be posted on the diff (GitHub returned 422) and are included here instead:
internal/runtime/codex_run_test.go(file-level): Line 771 ·
[low] naming-convention
TestCodexSecurityEnv_PinsWhatTheRunnerKnows keeps the runtime-specific CodexSecurityEnv prefix, but this PR renamed the function it tests from codexSecurityEnv to the runtime-neutral configHookEnv (now in sandbox_hooks_env.go). The sibling test TestCodexSecurityEnv_BeatsTheAgentsEnvFile at line 803 has the same stale prefix.
Suggested fix: Rename the test to TestConfigHookEnv_PinsWhatTheRunnerKnows (or move it to sandbox_hooks_env_test.go) to match the renamed helper.
|
🤖 Finished Review · ✅ Success · Started 10:54 PM UTC · Completed 11:05 PM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.90 |
waynesun09
left a comment
There was a problem hiding this comment.
Validated in the sandbox image as the sandbox user under dash: with a .env that changes or adds each hook setting, the hooks (ssrf_pretool.py, tool_allowlist_pretool.py) see the Bootstrap values and the names the runner did not set are unset. Go suite passes on Linux with dash as /bin/sh; JS suite passes.
…ings document Claude Code merges the --settings document fullsend generates with $CLAUDE_CONFIG_DIR/settings.json and the repository's .claude/settings.json and .claude/settings.local.json. --settings wins only for the keys it sets, so an env block in a lower-priority file was applied inside Claude Code after the launch re-exported the hook settings (fullsend-ai#8637), and a disableAllHooks there could switch the hooks off. installClaudeHooks now records the hook settings (bootstrapHookEnv) before it renders hooks.json, and claudeRunnerSettings adds to the document, on every run: - env: TIRITH_FAIL_ON, TIRITH_REQUIRED, FULLSEND_EGRESS_ALLOWLIST, FULLSEND_CANARY_TOKEN and FULLSEND_TOOL_ALLOWLIST with the values Bootstrap recorded, or "" (unset) where the runner has none. On gateway runs these are merged into the claudeGatewaySettings env block instead of replacing it. - "disableAllHooks": false. Both land in the hooks.json digest the launch guard checks and in the inline document on gateway runs. After .env the launch also unsets CLAUDE_CODE_SAFE_MODE, CLAUDE_CODE_SIMPLE and CLAUDE_CODE_SHELL_PREFIX (claudeSettingsEnvUnset), next to claudeLoaderEnvUnset. Tests cover the env block (values and "") and disableAllHooks on the non-gateway and both gateway routes, the merged gateway env, the digest, and the launch under /bin/sh and dash with a .env exporting the three variables, with a control run showing they reach claude without the unset. Each test was mutation-checked by dropping the change it covers. Note: pre-commit could not fetch remote hook repos in the sandbox (TLS failure). The local hooks (gofmt, go vet, lint-broken-symlinks, lint-docs-links, lychee) were run directly and pass; whitespace and EOF were checked by hand, and secrets were scanned with scan-secrets. Closes fullsend-ai#8641 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Renumber the ADR 0150 -> 0152 (0146-0151 are claimed by open PRs fullsend-ai#8679, fullsend-ai#8694, fullsend-ai#8698, fullsend-ai#8702; fullsend-ai#8702 was filed first for 0150). Per waynesun09's reviews (first round 14:56, second round 18:29): - restructure the Decision as rules 1-10 with the conformance table separated out (moved to docs/contributing/runtime-implementation.md so it can track the implementation as the code changes, linked from Consequences) - add the Options section back per the ADR template (fail-open with warning, per-runtime resolvers, version-floor acceptance, hash-verification as primary mechanism — each rejected) - add rules 9 (executables, not just directories) and 10 (scope: settings sources fullsend-ai#8637, hooks.json integrity fullsend-ai#8261, plugin trust ADR 0094) - gaps against the rules are tracked in issues, not the ADR: fullsend-ai#8763 (per-file trust for every executable a hook runs) and fullsend-ai#8764 (paths that let a tool call through without a hook verdict), both filed by the reviewer; rule 8's root-launch exception stays as a one-sentence stated limit - fix the pre-fullsend-ai#8605 Codex wording: the PATH was restored for itself and its hook adapter's children - fix the architecture.md sentence to state the decision for all runtimes, not Codex only - factual corrections from the first round: the shared resolver is hookPreflightInterpreter; the boundary value is FULLSEND_TRUSTED_PATH; the pre-fullsend-ai#8605 gap was image-PATH agent-writable dirs; pi included (same treatment in fullsend-ai#8589, pinned python3 not Node) Per the dual-model review round (GLM 5.3 + DeepSeek V4.1 Flash): - breaking change names the runtimes (pi has no version preflight) - forge scope before Consequences, full forge list Signed-off-by: James Tanner <jtanner@redhat.com>
Summary
Claude Code and pi launches now take the sandbox hook settings from the runner after the
.envload, as codex already did. The codex code moves into a runtime-neutral helper,internal/runtime/sandbox_hooks_env.go, and all three runtimes use it. The launch also unsets any of the five names the runner has no value for, so a value that only.envcarries never reaches the hooks.Changes
sandbox_hooks_env.gobootstrapHookEnvrecords theSandboxHookConfig-derived values and the harness pair (FULLSEND_CANARY_TOKEN,FULLSEND_TOOL_ALLOWLIST). The pair is read back from.envbefore the first iteration.hookEnvExportsrendersunset <names without a value> && export K='v' ....configHookEnvandreadHarnessHookEnvare the formercodexSecurityEnvandcodexReadHarnessSecurityEnv, renamed.''. Goldens regenerated; the only change is oneunsetline.installClaudeHooksrecords the values inclaudeHookDigests.SecurityEnv.buildRunCommandWithDigestsre-asserts them after the second hooks guard, before the gateway post-env.piHookEnvsmap, next topiManifestHashes.buildPiRunCommandre-asserts them right before the launch, after the declared-extension env and the gateway env.childEnvcopies the launch env ({...base}) and only deletes provider credentials, so the hook adapter and sub-agents inherit the values. A new JS test locks that in.docs/runtimes/{claude,codex,pi}.mdsay that hook settings come from the harness configuration at Bootstrap and that.envcannot change them.docs/contributing/runtime-implementation.mdno longer describes this as codex-only.Testing
TestHookEnv_LaunchesTakeTheRunnerValues: for each runtime, the test builds the real launch command and takes its.envload plus the hook-env statements between that load and the CLI start. It runs them under/bin/shwith a.envthat changes every managed name. The hooks must see the Bootstrap values, and no value for a name the runner did not set. A control subtest confirms that the.envalone does reach the hooks, so the check is not vacuous.unsetremoved fromhookEnvExports, every runtime subtest fails.hookEnvExports. Existing stubs answer the new Bootstrap read.go test -race ./internal/runtime/passes. Patch coverage on changed Go lines is about 92%.make lint:pre-commitcould not fetch its hook repos in the sandbox (TLS failure). The applicable hooks were run directly and pass: whitespace, EOF, gofmt, go vet, gitleaks (scan-secrets), broken symlinks, docs links and lychee.Caveats
fullsend-agent.test.mjs"a timed-out child gets SIGTERM..." fails in the agent sandbox onmaintoo. It is unrelated to this change.Checklist
!for breaking changes)🤖 Generated with Claude Code
Closes #8635
Post-script verification
agent/8635-hook-settings-runner-env)d93007f9d8c36709a6eacf42bb2d43a9d93f7042..HEAD)