Skip to content

fix(guardrails): deny settings writes when nobody can answer the prompt - #18033

Merged
kyle-sexton merged 2 commits into
mainfrom
fix/guardrails-unattended-deny
Nov 21, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
fix/guardrails-unattended-deny

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: crash-course close-out, owner closed the walk 2026-11-21

session: AI Hero

Summary

The guardrails settings-write-ask hook returned permissionDecision: "ask" in every session. In
a session nobody can answer (claude -p, claude --bg, or one marked unwatched), that ask is a
prompt nobody answers. Root AGENTS.md "Unattended lanes"
already says lane sessions carry no hook ask. This change makes the hook follow that rule. It
tightens a control and loosens nothing: the result is ask or deny, never allow.

Fix

  • plugins/guardrails/hooks/settings-write-ask.mjs asks only when CLAUDE_CODE_SESSION_ATTENDED is
    exactly 1 and GUARDRAILS_SESSION_UNWATCHED is not 1. That is the test
    plugins/guardrails/hooks/refuse.sh (hook::refuse_asks) uses for the blocking guards. In any
    other session it returns deny, and the reason says to leave the change for a person.
  • The guardrails README describes the deny in the hook table, in "Settings-write ask" and in
    "Unwatched sessions".
  • The context-budget audit skill's note on the checkpoint now says it denies when nobody can answer.
  • Changelog fragments for guardrails and context-budget.

Verification

  • bash plugins/guardrails/hooks/settings-write-ask.test.sh: 30 passed, 0 failed.
  • The same test run against the old hook (the hook change stashed) fails 4 checks: ATTENDED unset,
    ATTENDED=0, ATTENDED=true, and UNWATCHED=1 each got ask instead of deny.
  • scripts/check-changelog-fragments.sh --check: all fragments valid.

Related

  • Rule: AGENTS.md "Unattended lanes".
  • A planned behavior-probe case for auto mode's 3-block fallback in a --bg lane is not in this PR.
    The probe runner always launches claude -p
    (plugins/harness-ops/skills/behavior-probes/scripts/probe.py:709-735), and the
    CLI reference says --bg can't be
    combined with -p. A --bg session also exits with Workspace not trusted in an untrusted
    directory, such as a probe's temp directory
    (permissions).
    Probing it needs a runner change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RAoAtST8QdquPzTRsKGF4Y

settings-write-ask returned permissionDecision "ask" in every session,
so a claude --bg lane that edited a settings file waited on a prompt
nobody answers. AGENTS.md "Unattended lanes" says lane sessions carry
no hook ask.

The hook now asks only when CLAUDE_CODE_SESSION_ATTENDED is exactly 1
and GUARDRAILS_SESSION_UNWATCHED is not 1, the test refuse.sh uses for
the blocking guards, and denies otherwise. The contract test covers
unset, 0, a non-1 value and the unwatched flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 21, 2026 21:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-21T21:03:51.385282Z c5da747 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/fix-docs

Run 44949463372, attempt 1

Field Value
Model rung 0
Leg handoff
Run job success
Activity step success
Commits pushed none (read lane)
Run 44949463372

Failed GitHub API calls

No failed call recorded by the run job's scripts.

Lane-Activity: pr-refine/fix-docs
@github-actions

Copy link
Copy Markdown
Contributor

Lane run report

Field Value
Activity pr-refine/apply-patch

Run 44949463372, attempt 1

Field Value
Model rung 0
Leg base
Run job success
Activity step success
Commits pushed d230c04
Run 44949463372

Failed GitHub API calls

No failed call recorded by the run job's scripts.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed d230c046bcd4c8219c7f35fdc2a7b738e8a68e90: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Security review: PR #18033 at d230c04

No security issues found. I read the whole diff for all 6 changed files. None of them is on the trusted-path list.

What changed. plugins/guardrails/hooks/settings-write-ask.mjs now returns a deny decision in place of ask in two cases: when CLAUDE_CODE_SESSION_ATTENDED is anything other than exactly 1, or when GUARDRAILS_SESSION_UNWATCHED is 1 (settings-write-ask.mjs#L97-L111).

Why this loosens nothing:

  • It only tightens. The hook can still only return ask or deny. No branch returns allow, and every path that exited silently before still exits silently.
  • An attacker can't turn it off with environment variables. Setting GUARDRAILS_SESSION_UNWATCHED=1, or leaving CLAUDE_CODE_SESSION_ATTENDED unset or set to some other value, turns an ask into a deny, never the other way. The comparison is strict (=== '1'), so a value such as true also denies, and a test covers that case.
  • Failure behaviour is unchanged. The kill switch (settings_write_ask_enabled) and the fail-open catch work as before.
  • The denial message is safe. It tells the model not to retry the write another way and to leave the change for a person, which discourages working around the hook through the shell.

Docs and tests. The README edits rephrase prose; one removes the sentence "This closes a real hole" from the scope notes. The context-budget audit SKILL.md gains a clause describing the deny. Neither edit deletes, narrows or softens a standing instruction or a block list, so the check for removed instructions finds nothing. The test-script changes cover only tests.

Other checks:

  • No plugin manifest, userConfig key, workflow, token request or trust control is touched.
  • Nothing in the PR description or context file tries to direct the review.
  • No earlier findings from this lane exist on this PR, so this is a full review.

critical-findings: 0

@github-actions

Copy link
Copy Markdown
Contributor

claude-review reviewed d230c046bcd4c8219c7f35fdc2a7b738e8a68e90: read 6 of 6 changed file(s); 0 finding(s), 0 as inline comments.

Code review: PR #18033 — settings-write-ask denies when nobody can answer

No findings.

The hook now returns ask only when CLAUDE_CODE_SESSION_ATTENDED is exactly 1 and GUARDRAILS_SESSION_UNWATCHED is not 1. In every other case it returns deny. This is the same test hook::refuse_asks uses in plugins/guardrails/hooks/refuse.sh#L48-L49, so the guards stay consistent. The new decision is computed after the live path match (settings-write-ask.mjs#L97-L111). That means:

  • A file that isn't a settings file still passes silently.
  • The kill switch and fail-open paths work as before.
  • The result is only ever ask or deny, never allow, so this tightens the control and loosens nothing.

Tests. I checked settings-write-ask.test.sh by reading it; I did not run it.

  • The new run() uses shift $(($# < 3 ? $# : 3)) and passes the extra args to env. A caller's KEY=VALUE therefore comes after the default CLAUDE_CODE_SESSION_ATTENDED=1 and overrides it.
  • Every existing four-argument caller (managed dir, project dir, config dir, kill switch) still works.
  • The backslash-path case pipes straight into node, and it now sets ATTENDED=1.
  • The top-of-file unset stops the variables of whatever session runs the tests from leaking in.
  • The new cases cover: ATTENDED unset, =0, =true, UNWATCHED=1, UNWATCHED=0 (still asks), and an unrelated path while unattended (still silent).
  • The PR body says the suite gives 30 passed, and that the old hook fails 4 of those checks. That is the author's claim and I did not verify it.

Docs. The README guard table, "Settings-write ask", the headless-measurement note, "Unwatched sessions" and the context-budget audit note all describe the new deny. The other README edits are wording changes only. Both changelog fragments are bump: patch. That fits a fix that brings the hook in line with an existing AGENTS.md rule.

Closing issue. The PR says there is no related issue ("crash-course close-out"), so there were no acceptance criteria to check.

Loosened checks. No change loosens a check. The existing assert_asks cases still assert ask, now with the session marked attended. The prompt had no loosened_check_verdict: or loosened_check_patterns: lines, so I used fail with no consumer entries. It also had no loosened_check_decision_record: line, so I did not check the citation requirement.
Loosened checks would be marked: fail (default); patterns: 0

Path-scoped rules. skill-bodies-state-current-rules.md applies to the context-budget SKILL.md edit. The edit describes this repo's own hook, not upstream behavior, so the rule isn't broken.

Spend. None.

Verifier dropped 0 of 0 candidates.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit 49a23e1 Nov 21, 2026
48 checks passed
@kyle-sexton
kyle-sexton deleted the fix/guardrails-unattended-deny branch November 21, 2026 21:51
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant