Skip to content

feat: surface Claude permission prompts as needs-decision events - #7480

Open
Azd325 wants to merge 9 commits into
kunchenguid:mainfrom
Azd325:fm/fm-7105-permission-prompt-wake
Open

Azd325 wants to merge 9 commits into
kunchenguid:mainfrom
Azd325:fm/fm-7105-permission-prompt-wake

Conversation

@Azd325

@Azd325 Azd325 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • bin/fm-spawn.sh now installs a PermissionRequest hook for Claude workers. It calls the new permission-request command in bin/fm-busy-event.sh. The command validates the payload and appends a keyed needs-decision line to state/<id>.status. It does not change busy state and does not answer the prompt. Duplicate requests share one key, derived from the incarnation, lifecycle sequence, session, tool input and transcript size.
  • Open keys are stored in a <id>.permission-keys sidecar. The next apply of the same incarnation appends one matching resolved line. arm, retire and incarnation clearing close every open key before the sidecar is removed, so a relaunch cannot leave a decision open.
  • Added tests/fm-claude-permission.test.sh and the live e2e tests/fm-claude-permission-live-e2e.test.sh. Registered both in bin/fm-test-run.sh and updated the shard doc, the adapter wiring and t3code tests, the Claude harness reference, the operational-home-layout skill, and docs/verification/runtime-backends.md.

Risk Assessment

✅ Low: The rebase keeps the PR's bounded behavior intact: a Claude PermissionRequest appends one deduplicated needs-decision line under the existing writer lock and gen check, the same incarnation's next apply closes it, and arm, retire, and teardown (via retire) close it; the conflict-resolved shard lists, timing hints, and runtime-backends doc section are consistent with no duplicates or broken anchors.

Testing

Ran the permission and busy-adapter wiring tests; both passed. Ran the opt-in live e2e with the real Claude 2.1.311 CLI, using hooks generated by fm-spawn. A real permission prompt produced a decision signal within 120s, before the 3600s busy bound, and no keys were sent. The full suite was not run.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Real Claude auto-mode permission prompt raises a decision signal through the fm-spawn-generated PermissionRequest hook, without answering the prompt ✅ pass live live-e2e.txt
Replacing a worker closes the abandoned permission decision, and a resume event closes it exactly once ✅ pass live bash tests/fm-claude-permission.test.sh (real fm-busy-event.sh against a temp state dir)
Claude hooks wiring keeps the busy open/close behavior after the rebase ✅ pass live bash tests/fm-busy-adapter-wiring.test.sh
Evidence: live e2e output

Source: live e2e output

ok - claude 2.1.311 (Claude Code): real auto-mode PermissionRequest produces a decision signal within 120s, before the 3600s busy bound; no keys sent

ok - claude 2.1.311 (Claude Code): real auto-mode PermissionRequest produces a decision signal within 120s, before the 3600s busy bound; no keys sent

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ docs/verification/runtime-backends.md - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Real Claude auto-mode permission prompt raises a decision signal through the fm-spawn-generated PermissionRequest hook, without answering the prompt ✅ pass live live-e2e.txt
Replacing a worker closes the abandoned permission decision, and a resume event closes it exactly once ✅ pass live bash tests/fm-claude-permission.test.sh (real fm-busy-event.sh against a temp state dir)
Claude hooks wiring keeps the busy open/close behavior after the rebase ✅ pass live bash tests/fm-busy-adapter-wiring.test.sh
  • bash tests/fm-claude-permission.test.sh
  • bash tests/fm-busy-adapter-wiring.test.sh
  • FM_CLAUDE_PERMISSION_LIVE=1 bash tests/fm-claude-permission-live-e2e.test.sh
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325. I read the whole PR and the diff. The hook only records the decision. It never answers the prompt, and it leaves busy state alone, which is the right shape for a security decision.

Where it stands:

  • CI: everything else is green. Behavior portable serial 4 failed in fm-remote-reply.test.sh ("the NUL-bearing line was not captured"), serial 5 failed in fm-remote-secondmate-lifecycle-e2e.test.sh ("the watcher did not exit on its auto-relaunch wake within the bound"), and serial 2 was cancelled at the 30-minute ceiling (fix(pi): keep the Pi watcher armed after a successor or arm child dies #7255). I've seen those same failures on unrelated PRs, so they look like flakes. I re-ran the failed jobs once.
  • The no-mistakes attestation matches head 18cdc9a9, and live validation is 4/4 go.
  • My contract-class verdict is new-default. Every Claude worker and secondmate launch now registers a new PermissionRequest hook, and each request writes a new needs-decision wake, without the user configuring anything. Your own risk note says the same.

Next step: we're waiting on the CI re-run. If it comes back green, this goes to Kun for a merge-or-leave call, because it adds a default-on hook and wake. That will be a captain decision. Nothing is waiting on you unless the re-run fails again in those tests.

@Azd325

Azd325 commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Two CI shards are red on head 18cdc9a9, and neither comes from this change. Could you rerun them?

  • Behavior portable serial 5 fails in tests/fm-remote-secondmate-lifecycle-e2e.test.sh with "the watcher did not exit on its auto-relaunch wake within the bound" (line 1319). I ran that test on main 1aa2a21e with a 30-minute bound, and it fails at the same assertion there. The test and bin/fm-watch.sh are identical between main and this branch, and the diff does not touch the watcher.
  • Behavior portable serial 2 was cancelled at the 30-minute job limit, so it has no verdict.

The other 17 checks pass.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325, and thanks for checking the watcher test against main.

Where it stands on head 18cdc9a9 (unchanged since my last note):

  • The re-run cleared serial 4. serial 5 failed again in fm-remote-secondmate-lifecycle-e2e.test.sh ("the watcher did not exit on its auto-relaunch wake within the bound"), and serial 2 was cancelled again at the 30-minute ceiling (fix(pi): keep the Pi watcher armed after a successor or arm child dies #7255).
  • In CI that test passes on main 1aa2a21e and on other PRs today, but it has also flaked on unrelated PRs, and your diff doesn't touch the watcher. So I'm treating it as a flake for now and have re-run the failed jobs once more (run 39110722423).
  • The no-mistakes attestation still matches 18cdc9a9, with live validation 4/4 go.

My contract-class verdict is unchanged: new-default. Every Claude worker and secondmate launch gets a new PermissionRequest hook and a new needs-decision wake without the user configuring anything.

Next step: we're waiting on CI only. Nothing is needed from you right now. If the re-run comes back green, this goes to Kun for a merge-or-leave decision (captain decision, not waiting on you). If serial 5 fails a third time on this head, I'll ask you to look at whether the new hook changes the secondmate relaunch path in that test.

@Azd325 Azd325 changed the title fix(bin): wake firstmate on Claude permission prompts fix(bin): wake firstmate on Claude worker permission prompts Oct 21, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325 for bringing this up to date with main.

I re-read the new head 0bcdcac7 against main 2c93247f (2 ahead, 0 behind). It is a merge of main into the branch, and the PR's own changes are byte-identical to the 18cdc9a9 diff I reviewed on 10-18. The no-mistakes attestation binds this head, and live validation is 4 of 4 go on Claude 2.1.304.

CI: 18 of 19 green, and the serial 5 failure from last time is gone. The only red is Behavior portable serial 2, cancelled at the 30-minute ceiling (#7255), which isn't related to this diff. I've re-run that job once (run 39601714739).

contract-class: new-default (unchanged): every Claude worker and secondmate launch gets a new PermissionRequest hook and a needs-decision wake without anything being configured.

VISION, rule by rule: One captain aligns (a stuck permission prompt reaches the first mate instead of silently stalling). Authority aligns (the hook records the decision and never answers it). Scripts/judgment aligns. Restart aligns (a keyed, deduplicated status line). Delegation aligns. Vendor aligns (it uses Claude's documented hook, not the rendered surface). Scope aligns.

Nothing is needed from you right now. If the serial 2 re-run comes back green, this goes to Kun for a merge-or-leave decision. That will be a captain decision, not waiting on you.

@Azd325 Azd325 changed the title fix(bin): wake firstmate on Claude worker permission prompts feat(bin): wake the supervisor on Claude permission prompts Oct 23, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325 for keeping this current.

Delta since my 10-21 stamp (0bcdcac7): new head a8b495bd is a merge of main plus one doc commit. That commit adds PermissionRequest to the Claude adapter's busy-hook row, and the test-family list was re-wrapped. The hook, fm-busy-event.sh permission-request and the spawn wiring are unchanged from what I reviewed. The no-mistakes attestation matches a8b495bd, and live validation is go on Claude 2.1.308 (a decision signal within 120s, no keys sent).

CI: 18 of 19 green. Behavior portable serial 3 failed in fm-remote-reply.test.sh ("the NUL-bearing line was not captured"). That's the same remote-reply flake I saw on this PR on 10-18, and the diff doesn't touch it. I re-ran the failed job (run 39949684992).

Contract-class: new-default (unchanged). Every Claude worker and secondmate launch gets a PermissionRequest hook and a needs-decision wake without anything being configured. VISION rule by rule is unchanged from 10-21: all seven rules align.

Nothing is needed from you. If the re-run is green, this goes to Kun for a merge-or-leave decision. That's a captain decision, not waiting on you.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325. The re-run came back green. All 19 checks pass on head a8b495bd, the no-mistakes attestation still binds this head, and the PR is mergeable.

Contract-class: new-default (unchanged). Every Claude worker and secondmate launch gets a PermissionRequest hook and a needs-decision wake without anything being configured. VISION.md: all rules align, same as my 10-21 read.

This goes to Kun now as a merge-or-leave decision. It's a captain decision, so it isn't waiting on you.

@Azd325
Azd325 force-pushed the fm/fm-7105-permission-prompt-wake branch from a8b495b to 4da203b Compare November 1, 2026 14:46
@Azd325 Azd325 changed the title feat(bin): wake the supervisor on Claude permission prompts fix(bin): wake firstmate on Claude permission prompts Nov 1, 2026
@greptile-apps

greptile-apps Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with the stated known limits.

Reviews (7) · Last reviewed commit: "no-mistakes(document): Document permissi..." · Reviewed by Greptile

Comment thread bin/fm-busy-event.sh Resolved
@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 1, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325 for the re-raise. On head 020260aa, the new Greptile P1 ("Answered prompts stay open") is fixed. The request now records its key, and the next busy event from the same incarnation appends the matching resolved line once, with a test for the full open-and-close flow. Greptile is 5/5 with the thread resolved. The attestation binds this head with no skipped steps, live validation is 4 of 4 go on Claude 2.1.316, and it merges cleanly with main 41a47c09.

I've added the full-ci label so the full suite runs. Contract-class: new-default (unchanged): every Claude worker and secondmate launch gets a PermissionRequest hook and a needs-decision wake without anything being configured. So if the suite is green, this goes back to Kun for the merge-or-leave call. That step waits on Kun, not on you. VISION.md: all rules align.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325. The full suite ran on head 020260aa (run 41321249948), and one lane fails on this PR's own change, so it's back with you for a small fix.

Behavior portable parallel 1, tests/fm-backend-t3code.test.sh: not ok - the env merge must keep the busy hooks, got hooks '["UserPromptSubmit","Stop","StopFailure","SessionEnd","PermissionRequest"]'. Around line 1550 the test compares the sorted hook keys in the worktree's .claude/settings.local.json with exactly SessionEnd Stop StopFailure UserPromptSubmit. Your fm-spawn.sh change now adds PermissionRequest to that set, so the assertion needs to expect it too. It reproduces for me on this head merged with main e1a7a2ff. Main passes the same test.

The other red lane, serial 6 (tests/fm-watcher-lock.test.sh, "the successor never delivered its recovery wake and exited"), isn't your code. It's a watcher-lock timing flake that has also hit another PR today, so you can ignore it.

Waiting on you: update that expected hook set and re-raise through git push no-mistakes. I've left the full-ci label on, so the full suite will run again on your new head. Contract-class: new-default (unchanged). Once it's green, it goes to Kun for the merge-or-leave call. VISION.md: unchanged, all rules align.

@Azd325
Azd325 force-pushed the fm/fm-7105-permission-prompt-wake branch from 020260a to b6769e4 Compare November 2, 2026 08:01
@Azd325 Azd325 changed the title fix(bin): wake firstmate on Claude permission prompts feat: wake firstmate on Claude permission prompts Nov 2, 2026
Comment thread bin/fm-busy-event.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @Azd325, this round fixes both things that were open. f563d3ca adds PermissionRequest to the t3code hook set, which was the parallel-1 failure. 8382b661 fixes Greptile's second P1 ("Abandoned prompts survive worker replacement"): arm and retire now close every stored key before they drop the sidecar, and there's a relaunch regression test for it. Greptile is at 5/5 on this head, both threads are resolved, the quick checks pass, and it still merges cleanly with main c61646ff.

The full suite on 8382b661 (run 41414993399) passed everything except Behavior portable serial 5. That lane failed in tests/fm-wake-queue.test.sh ("concurrent append/drain subprocess failed"), which is a known timing flake on main that your diff doesn't touch. I've rerun that lane once, so you can ignore it.

Waiting on you for one thing. The no-mistakes attestation for 8382b661 shows the Intent step as skipped. Our merge gate now requires every pipeline step to run on the head being merged, with no exceptions for skips. Could you re-raise once more through git push no-mistakes so every step runs, including Intent? The code doesn't need to change. I've left the full-ci label on, so the suite will run again on the new head.

Contract-class: new-default (unchanged). Every Claude worker and secondmate launch gets the PermissionRequest hook and a needs-decision wake without any configuration. So after a clean re-raise and a green Full suite, this goes to Kun for the merge-or-leave call. VISION.md: unchanged, all rules align.

@Azd325
Azd325 force-pushed the fm/fm-7105-permission-prompt-wake branch from 8382b66 to 96fd2b9 Compare November 2, 2026 16:08
@Azd325 Azd325 changed the title feat: wake firstmate on Claude permission prompts fix: surface Claude permission prompts as needs-decision events Nov 2, 2026
Comment thread bin/fm-busy-event.sh Resolved
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @Azd325 for the clean re-raise. On head 96fd2b9c, the no-mistakes attestation binds the head with every step run (Intent included), so the skip from last round is gone. The Full suite passed on this head (run 41478546652), every other check is green, and it merges cleanly with main 9224c902. The code is the same close-on-resume / close-on-arm-and-retire shape I reviewed this morning, now with the close loop pulled into close_permission_keys.

Waiting on you for two small things before this can go to Kun:

  1. Live validation on this head. This run's live check came back inconclusive (1 of 3) because node wasn't on PATH, so the generated PermissionRequest hook from fm-spawn.sh and a real Claude permission prompt weren't exercised. Your earlier run on 020260aa covered those 4 of 4, but the hook code has changed since. Could you re-run with node available, either as another git push no-mistakes or by posting the FM_CLAUDE_PERMISSION_LIVE=1 bash tests/fm-claude-permission-live-e2e.test.sh output and the wiring test here?
  2. Greptile's new P2 thread ("Failed writes strand permission decisions", on bin/fm-busy-event.sh) is still open. My read is that a disk-full write failure is an edge case, so a short reply on the thread saying how you want to handle it, then resolving it, is enough. A small fix is welcome too if you prefer.

I've left the full-ci label on, so the suite will run again if the head changes. Contract-class: new-default (unchanged): every Claude worker and secondmate launch gets the PermissionRequest hook and a needs-decision wake without any configuration. So once these two are done, the merge-or-leave call goes to Kun. VISION.md: unchanged, all rules align.

@Azd325

Azd325 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Live validation on head 96fd2b9c, this time with node on PATH (v24.22.2).

Ran in a temporary lab home, with no shared state or sessions touched:

  • FM_CLAUDE_PERMISSION_LIVE=1 bash tests/fm-claude-permission-live-e2e.test.sh passed (exit 0):
    ok - claude 2.1.316 (Claude Code): real auto-mode PermissionRequest produces a decision signal within 120s, before the 3600s busy bound; no keys sent
  • bash tests/fm-busy-adapter-wiring.test.sh passed (exit 0): all fm-busy-adapter-wiring tests passed.
  • bash tests/fm-claude-permission.test.sh passed (exit 0), including a resume event closes the permission decision exactly once.

The live test uses fm-spawn to generate the worker settings with the PermissionRequest hook, then a real Claude permission prompt raises the decision signal through that hook.

@Azd325
Azd325 force-pushed the fm/fm-7105-permission-prompt-wake branch from 96fd2b9 to 38cbf76 Compare November 9, 2026 18:12
@Azd325 Azd325 changed the title fix: surface Claude permission prompts as needs-decision events fix(bin): surface Claude permission prompts as needs-decision events Nov 9, 2026
@kunchenguid kunchenguid removed the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 9, 2026
@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 9, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325 for the re-raise. On 38cbf765 the no-mistakes attestation binds the head with every step completed and none skipped, the live run is 3 of 3 go, Greptile is 5/5, and all three review threads are resolved. The labelled full suite (run 42683030281) passed every behavior lane except one, and that one, like the coverage guard, fails because of this branch. So it's back with you for one small fix.

Test coverage guard (job 129382360169): coverage guard: 45 of 295 portable serial scripts have no measured duration hint (max 15%). Your two new serial scripts, tests/fm-claude-permission.test.sh and tests/fm-claude-permission-live-e2e.test.sh, are both on the no-hint list. They push the count over the cap. Main 660d2b31 passes this guard with 43 unhinted of 295, so rebasing alone won't clear it. Behavior portable parallel 2 (job 129382360775) fails only in tests/fm-test-run.test.sh, which re-runs the same guard. It has the same cause.

The fix: add provisional serial hints for both scripts in portable_serial_weight_hints in bin/fm-test-run.sh. Add a matching "provisional local measurement" line in docs/fm-test-portable-shards.md, the way recent suites such as tests/fm-stow-guard.test.sh do. Then re-raise once with git push no-mistakes so the attestation binds the new head with no skipped steps.

I'm leaving full-ci on. Contract-class (my own read): new-default. Every Claude spawn gets the PermissionRequest hook and a new needs-decision wake, with no flag. VISION.md: aligns on every rule. Once the suite is green, this goes to Kun for a decision. Right now it's waiting on you, not on Kun.

@Azd325
Azd325 force-pushed the fm/fm-7105-permission-prompt-wake branch from 38cbf76 to ecd03b8 Compare November 10, 2026 08:00
@Azd325 Azd325 changed the title fix(bin): surface Claude permission prompts as needs-decision events fix(bin): wake the supervisor on Claude permission prompts Nov 10, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @Azd325, that fixed it. On ecd03b82 both new serial scripts have provisional hints with a matching line in docs/fm-test-portable-shards.md. The test coverage guard and Behavior portable parallel 2 are green in the labelled run. The attestation binds this head with every step completed, Greptile is 5/5 on this head, all three threads are still resolved, and live validation is go (3 of 3). Apart from the hints and one reworded header comment, the code matches the head I reviewed last time.

The full suite is still red, but neither failure comes from this branch. One lane hits a test that is currently broken on main too. The other, Lint 2, was cancelled at its 30-minute limit after every file it had linted passed. We'll re-run the suite once main is fixed. There's nothing for you to change.

The next step is ours (the full-suite re-run), not yours. Contract class (my own read): new-default, because every Claude spawn gets the PermissionRequest hook and a new needs-decision wake with no flag. So once the suite is green, Kun makes the merge decision. VISION.md: every rule aligns.

Report permission requests through durable decision status without answering the security prompt. Deduplicate repeats within the armed worker incarnation and preserve the busy record.

Refs kunchenguid#7105
… a permission `needs-decision` opened by an incarnation must close when that incarnation resumes work. - `permission-request` now also records `<gen> <key>` in a new sidecar, `state/<id>.permission-keys`. It does this only when it appends a new status line, under the writer lock. - The next `apply` of the same gen appends `resolved [key=…]` once for each matching key. It then removes the sidecar. Other gens' lines are skipped. - `arm` and `retire` clear the sidecar through `clear_stream_incarnation`. - No new command, no message to the worker, and no crew-state output change. I added `test_resume_closes_the_decision` to `tests/fm-claude-permission.test.sh`. The test covers the full flow: the request opens the decision, a resume event closes it, `status_own_open_decisions` is empty, and a second event adds no second resolved line. `tests/fm-claude-permission.test.sh` passes with the fix. With the `bin/fm-busy-event.sh` change stashed, it fails with "resume left the decision open". I ran only that test file, not the wider suite. I changed nothing for ci-1 (full-ci label) and posted no PR comments
…ion` must close before its worker incarnation is discarded. I added `close_permission_keys [gen]` in `bin/fm-busy-event.sh`. `clear_stream_incarnation` calls it with no gen. That makes `arm` and `retire` append `resolved [key=…]` for every stored key before the sidecar is removed. The `apply` resume path now calls the same helper with its own gen, which replaces the inline loop. I added `test_relaunch_closes_the_abandoned_decision` to `tests/fm-claude-permission.test.sh`. With the `bin/fm-busy-event.sh` change stashed, it fails with "relaunch left the decision open". With the change, it passes. I raised two status-line counts in `test_request_identity_and_generation` from 2 to 4 and from 3 to 5. They now include the resolved lines that `arm` appends. All four tests in that file pass. I did not run the wider suite. I posted no PR comments
@Azd325
Azd325 force-pushed the fm/fm-7105-permission-prompt-wake branch from ecd03b8 to 421933d Compare November 18, 2026 18:02
@Azd325 Azd325 changed the title fix(bin): wake the supervisor on Claude permission prompts feat: surface Claude permission prompts as needs-decision events Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants