Repository navigation
fix(#8641): pin runner-owned settings in the claude --settings document - #8642
Conversation
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 (#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 #8641 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
/fs-fix-stop |
|
Fix agent disabled for this PR. Remove the |
|
🤖 Review · Commit: |
Site previewPreview: https://4f371927-site.fullsend-ai.workers.dev Commit: |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
A settings file's env block is applied inside Claude Code, after the launch clears its variables, and reaches the hook commands it starts. Set every claudeLoaderEnvUnset and claudeSettingsEnvUnset name to "" in the generated --settings document, and add CLAUDE_CODE_SUBPROCESS_ENV_SCRUB to the cleared Claude Code variables: it removes credential-named variables, FULLSEND_CANARY_TOKEN among them, from the hooks' environment. Skip the hooks-on /bin/sh case of the launch test where /bin/sh rejects `unset -f [` (bash 3.2 on macOS), and say in the docs which keys the settings document pins. Assisted-by: Claude (fix), Codex (review), Claude (review) Signed-off-by: Wayne Sun <gsun@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 1:49 AM UTC · Completed 2:05 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.91 |
|
<!-- fullsend:risk-assessment --> DetailsWell-scoped bot change matching issue requirements with zero protected paths, balanced by high recent commit churn in the Claude runtime and unflagged modification of runner settings. Previous run<!-- fullsend:risk-assessment --> DetailsWell-scoped bot change matching issue requirements with zero protected paths, balanced by high recent commit churn in the Claude runtime and unflagged modification of runner settings. |
|
Looks good to me Previous run<!-- fullsend:review-findings-v2:eyJ2ZXJzaW9uIjoyLCJhY3Rpb24iOiJyZXF1ZXN0LWNoYW5nZXMiLCJmaW5kaW5ncyI6W3sic2V2ZXJpdHkiOiJtZWRpdW0iLCJjYXRlZ29yeSI6ImluamVjdGlvbi12dWxuIiwiZmlsZSI6ImludGVybmFsL3J1bnRpbWUvY2xhdWRlLmdvIiwiaWQiOiJmXzgzZmNiODJmMmQzZTBhMGUiLCJsaW5lIjoxMDI5LCJhY3Rpb25hYmxlIjp0cnVlfSx7InNldmVyaXR5IjoibG93IiwiY2F0ZWdvcnkiOiJkb2Mtc3R5bGUiLCJmaWxlIjoiZG9jcy9yZWZlcmVuY2UvaGFybmVzcy1yZWZlcmVuY2UubWQiLCJpZCI6ImZfZDgwMTZkYjUyMTM1NTA0NCIsImxpbmUiOjIyNywiYWN0aW9uYWJsZSI6ZmFsc2V9XX0= --> ReviewFindingsMedium
Low
Next steps:
|
envDataDropNames refuses both from .env; set them to "" in the generated --settings document too, so a settings file's env block cannot hand one to the shells Claude Code starts. Rewrap the edited .env.d paragraph in the harness reference. Assisted-by: Claude (fix), Codex (review), Claude (review) Signed-off-by: Wayne Sun <gsun@redhat.com>
|
🤖 Finished Review · ✅ Success · Started 2:10 AM UTC · Completed 2:19 AM UTC Commit: Runtime: pi · Model: sonnet → claude-sonnet-5-5 · Effort: high · Cost: $2.06 |
Superseded by updated review
waynesun09
left a comment
There was a problem hiding this comment.
Validated in the fleet sandbox image with Claude Code 2.1.304: with the settings document rendered from this head, lower-priority settings files and .env no longer change the hook settings or hook activation. Go runtime suite green on Linux.
Summary
Pins the settings the runner owns in the
--settingsdocument fullsend generates for Claude Code, on every run. Before this, a lower-priority settings file ($CLAUDE_CONFIG_DIR/settings.json, or the repository's.claude/settings.jsonand.claude/settings.local.json) could override the sandbox hook settings through itsenvblock, or switch the hooks off withdisableAllHooks.--settingsonly wins for the keys it sets, so each key is now set explicitly. The launch also clears three Claude Code variables after.env, because they change how Claude Code loads settings and runs hook commands.Related Issue
Related: #8261, #8637
Changes
internal/runtime/claude.goinstallClaudeHooksnow records the hook settings (bootstrapHookEnv) before it rendershooks.json. The read still happens beforeappendHookEnv.claudeRunnerSettingsadds two things to the document:envblock holdingTIRITH_FAIL_ON,TIRITH_REQUIRED,FULLSEND_EGRESS_ALLOWLIST,FULLSEND_CANARY_TOKENandFULLSEND_TOOL_ALLOWLIST, each with the value Bootstrap recorded, or""where the runner has none"disableAllHooks": falseclaudeGatewaySettingsenvblock rather than replacing it. Both additions are covered by thehooks.jsondigest and appear in the inline gateway document.claudeSettingsEnvUnsetlistsCLAUDE_CODE_SAFE_MODE,CLAUDE_CODE_SIMPLEandCLAUDE_CODE_SHELL_PREFIX.internal/runtime/claude_integrity.go:claudeGuardedEnvunsets those three variables right afterclaudeLoaderEnvUnset, with hooks on or off. The comment that listed the config-dir and repository settings files as out of scope is updated.docs/runtimes/claude.md: the hook settings and hook activation come from the runner's settings document, and the lower-priority files cannot change them. The cleared-variables table gains a row for the new unsets.docs/reference/harness-reference.mdanddocs/guides/dev/cli-internals.md: the list of cleared variables now includes the new names.Testing
make lintpasses (stage changes first, then run).pre-commitcould not fetch its remote hook repos in the sandbox (TLS failure). I ran the local hooks directly and they pass: gofmt, go vet, lint-broken-symlinks, lint-docs-links, lychee. Whitespace and end-of-file were checked by hand, and secrets were scanned withscan-secrets.TestClaudeRunnerSettings: theenvblock (values and"") anddisableAllHooks, on non-gateway and gateway runs, including the merged gateway env, and checks the gateway settings passed in are not modified.TestInstallClaudeHooks_PinsRunnerSettings: the uploadedhooks.jsonand its recorded digest, for non-gateway, oidc gateway and api-key gateway runs. The inline--settingsdocument must match exactly.TestClaudeLaunch_ClearsSettingsVariablesSetByEnv: runs the real launch under/bin/shanddash, with hooks on and off, using a.envthat exports the three variables. claude must not see them. A control run without the unset confirms the values do reach claude, so the test is not passing because.envwas ignored.TestBuildRunCommand_HooksGuardPlacementandTestInstallClaudeHooks_RecordsDigests.disableAllHooks, merging the gateway env, and passing the runner settings ininstallClaudeHooks). Each mutation fails at least one test.go test -race ./internal/runtime/passes.claudeRunnerSettingsandclaudeGuardedEnvhave 100% coverage.Note:
FULLSEND_CANARY_TOKENis now also inhooks.json, and on gateway runs in the inline--settingsargument. The agent can already read that value in the workspace.env, so nothing new is exposed inside the sandbox.Not breaking: the pinned values are what the harness configured. A repository that sets these keys in its own
.claude/settings.jsonnow gets the runner's values.Checklist
!for breaking changes)🤖 Generated with Claude Code
Closes #8641
Post-script verification
agent/8641-pin-runner-settings)5bbf11a05f1220107ae0a6196fbc436bec15d292..HEAD)