Skip to content

feat(bin): detect Claude permission prompts on worker and main panes - #7612

Closed
johntran-mudflap wants to merge 13 commits into
kunchenguid:mainfrom
johntran-mudflap:fm/fm-permission-prompt-upstream
Closed

johntran-mudflap wants to merge 13 commits into
kunchenguid:mainfrom
johntran-mudflap:fm/fm-permission-prompt-upstream

Conversation

@johntran-mudflap

@johntran-mudflap johntran-mudflap commented Oct 21, 2026 •

Copy link
Copy Markdown

What Changed

  • fm_composer_blocking_dialog in bin/fm-composer-lib.sh now recognizes Claude tool-permission prompts through the new fm_composer_permission_prompt matcher. The matcher handles the 2.1.306 and 2.1.153 layouts and reports the prompted command as the prompt's subject. bin/fm-watch.sh raises a single check: permission prompt pending wake when the same prompt stays on an ordinary task's pane for FM_PERMISSION_PROMPT_SECS (default 90), whatever the pane's busy state. It never answers the prompt. fm_wake_queue_prune_task now also removes a task's permission-prompt-<task>-<epoch> wakes.
  • New bin/fm-main-prompt-alarm.sh runs as a tracked Claude PermissionRequest hook (.claude/settings.json, skipped under Grok). It acts only for the lock-owning primary session of a primary checkout. It writes a record of the prompt and starts a delayed check. After FM_MAIN_PROMPT_ALARM_SECS (default 300) the check alerts once, but only if the record, session lock and transcript are all unchanged and the main pane, when it can be read, still shows the prompt. A newer prompt's record is never deleted by an older check.
  • The wedge-alarm channel code moved out of bin/fm-supervise-daemon.sh into the new shared bin/fm-wedge-alarm-lib.sh, which both alarms use. Docs and skills cover the new detection and its settings. Tests were added for the composer matcher, watcher triage, the main-session alarm and wake-queue pruning, plus an opt-in live e2e test (tests/fm-permission-prompt-live-e2e.test.sh).

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The fix round changes one line: it removes the rm -f of the shared prompt record, so a delayed check can no longer delete a newer prompt's record, and each check still alerts at most once because it is keyed to its own token. The test's wait condition was relaxed to match, and the rest of the diff, reviewed in round 1, still holds.

Testing

I ran the opt-in live e2e guard against real Claude Code 2.1.308. I then drove a real Claude worker in a lab home onto a hook-ask permission prompt and pointed fm-send, the typed-submit path, and fm-watch at it. Finally I drove fm-main-prompt-alarm.sh's check through the superseded-prompt race and the transcript-changed case, and ran the four targeted test files. Everything passed. The prompt was never approved and was cancelled with Escape. Evidence is pane captures and transcripts; this change has no graphical surface, so there are no screenshots. All lab homes and tmux servers were torn down, and the worktree is clean.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A real Claude hook-ask permission prompt is recognized as a blocking dialog that names the prompted command ✅ pass live live-e2e-claude-2.1.308.log: fm_composer_permission_prompt subject = 'echo fm-live-ask-marker && echo second-line', dialog name 'Claude permission prompt: ...'
Steering a worker parked on a real prompt (fm-send and typed submit) types nothing, so the prompt is not approved ✅ pass live live-worker-scenarios.log: both refused with 'blocked on a prompt: Claude permission prompt: ...'; worker-pane-after-steer.txt still shows 'Do you want to proceed?' with no typed text and no command o…
The watcher raises one check: permission prompt pending wake for a worker that stays on a prompt past FM_PERMISSION_PROMPT_SECS, and stale reasons carry blocked-on-prompt ✅ pass live live-worker-scenarios.log: 'check: permission prompt pending: task=w1 window=fmlab:worker waiting=7s - Claude permission prompt: ...' and a durable wake-queue row permission-prompt-w1-<since>; prompt…
The main-session PermissionRequest hook alerts once through the wedge-alarm channel while the prompt waits, and decides nothing ✅ pass live live-e2e-claude-2.1.308.log: 'the PermissionRequest registration alerts on a waiting prompt and leaves it unanswered'
Adversarial: an older prompt's delayed check that fires after a newer prompt's hook does not delete the newer record or alert; the newer prompt's check still alerts ✅ pass live main-alarm-race.log: check tokA raised no alert; check tokB alerted 'for Bash: echo prompt-B'; after a matched check the record file still exists (persist section)
Adversarial: a prompt whose session transcript changed (answered or cancelled) does not alert ✅ pass live main-alarm-race.log: tokC 'resolved: the session moved on after the Bash prompt', no alert
Evidence: Live e2e guard on Claude Code 2.1.308

Source: Live e2e guard on Claude Code 2.1.308

ok - Claude Code 2.1.308 (Claude Code): the live hook-ask permission prompt matches and names the prompted command
ok - Claude Code 2.1.308 (Claude Code): the PermissionRequest registration alerts on a waiting prompt and leaves it unanswered
Evidence: Live worker scenarios transcript (steer refusal + watcher wake)

Source: Live worker scenarios transcript (steer refusal + watcher wake)

fm-send: error: blocked on a prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line stale: fmlab:worker (blocked-on-prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line) check: permission prompt pending: task=w1 window=fmlab:worker waiting=7s - Claude permission prompt: echo fm-live-ask-marker && echo second-line

=== pane on prompt saved
=== SCENARIO A: steer typed into a real prompt
fm-send rc=1
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/51/1351mbqd7jn0fjnv9l24y04c0000gn/T/fm-lab.c8a7Yl
error: blocked on a prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line
error: text not sent to fmlab:worker (tmux send failed; tried meta=/private/var/folders/51/1351mbqd7jn0fjnv9l24y04c0000gn/T/fm-lab.c8a7Yl/state/fmlab:worker.meta; metadata window/terminal lookup; backend=tmux; endpoint=verified)
fm_backend_send_text_submit rc=1
error: blocked on a prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line
A: PASS prompt still open, nothing typed, command not approved
=== SCENARIO B: watcher wake on a worker parked on the prompt
round 1 watch rc=0
--- watch stdout
signal: /private/var/folders/51/1351mbqd7jn0fjnv9l24y04c0000gn/T/fm-lab.c8a7Yl/state/w1.status
drained: 1792683865	2	signal	w1.status	signal: /private/var/folders/51/1351mbqd7jn0fjnv9l24y04c0000gn/T/fm-lab.c8a7Yl/state/w1.status wake annotation: latest wake-EVENT observed at drain, not current state: w1.status: working: running the marker command  ack=2 gen=83928.1792683865.VBzHbX
round 2 watch rc=0
--- watch stdout
stale: fmlab:worker (blocked-on-prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line)
drained: 1792683873	3	stale	fmlab:worker	stale: fmlab:worker (blocked-on-prompt: Claude permission prompt: echo fm-live-ask-marker && echo second-line)  ack=3 gen=86227.1792683873.eAmx4d
round 3 watch rc=0
--- watch stdout
check: permission prompt pending: task=w1 window=fmlab:worker waiting=7s - Claude permission prompt: echo fm-live-ask-marker && echo second-line
--- watch stderr (tail)
--- triage log (prompt lines)
--- wake queue
1792683875	4	check	permission-prompt-w1-1792683868	check: permission prompt pending: task=w1 window=fmlab:worker waiting=7s - Claude permission prompt: echo fm-live-ask-marker && echo second-line
prompt still unanswered after the watcher
=== cleared prompt with Escape
Evidence: Real worker pane on the permission prompt

Source: Real worker pane on the permission prompt

╭─── Claude Code v2.1.153 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                           │ Tips for getting started                                                                                         │
│               Welcome back!               │ Run /init to create a CLAUDE.md file with instructions for Claude                                                │
│                                           │ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────── │
│                  ▐▛███▜▌                  │ What's new                                                                                                       │
│                 ▝▜█████▛▘                 │ Bug fixes and reliability improvements                                                                           │
│                   ▘▘ ▝▝                   │ Added `/claude-api api-version` to move Claude API code to API version `2026-10-21`                              │
│                                           │ Added the `claude_code.safety_event` OpenTelemetry event for each tool call a permission rule, auto mode, a saf… │
│           Haiku 4.5 · [redacted]          │ /release-notes for more                                                                                          │
│          /…/T/fm-lab.c8a7Yl/proj          │                                                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

  ⎿  SessionStart:startup hook error                                              ⎿  Failed with non-blocking status code: /bin/sh: chrome-devtools-axi: command
                                                                                      not found
  ⎿  SessionStart:startup hook error                                              ⎿  Failed with non-blocking status code: /bin/sh: gh-axi: command not found
  ⎿  SessionStart:startup hook error                                              ⎿  Failed with non-blocking status code: /bin/sh: lavish-axi: command not
                                                                                     found

❯ Use the Bash tool to run exactly this one command and nothing else: echo fm-live-ask-marker && echo second-line

⏺ Bash(echo fm-live-ask-marker && echo second-line)
  ⎿  Waiting…

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Bash command

   echo fm-live-ask-marker && echo second-line
   Run the specified echo commands

 Hook PreToolUse:Bash requires confirmation for this command:
 live guard asks [settings]
 settings.json to update hooks

 Do you want to proceed?
 ❯ 1. Yes
   2. No

 Esc to cancel · Tab to amend · ctrl+e to explain
Evidence: Worker pane after the refused steer (prompt still open)

Source: Worker pane after the refused steer (prompt still open)

╭─── Claude Code v2.1.153 ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                           │ Tips for getting started                                                                                         │
│               Welcome back!               │ Run /init to create a CLAUDE.md file with instructions for Claude                                                │
│                                           │ ──────────────────────────────────────────────────────────────────────────────────────────────────────────────── │
│                  ▐▛███▜▌                  │ What's new                                                                                                       │
│                 ▝▜█████▛▘                 │ Bug fixes and reliability improvements                                                                           │
│                   ▘▘ ▝▝                   │ Added `/claude-api api-version` to move Claude API code to API version `2026-10-21`                              │
│                                           │ Added the `claude_code.safety_event` OpenTelemetry event for each tool call a permission rule, auto mode, a saf… │
│           Haiku 4.5 · [redacted]          │ /release-notes for more                                                                                          │
│          /…/T/fm-lab.c8a7Yl/proj          │                                                                                                                  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

  ⎿  SessionStart:startup hook error                                              ⎿  Failed with non-blocking status code: /bin/sh: chrome-devtools-axi: command
                                                                                      not found
  ⎿  SessionStart:startup hook error                                              ⎿  Failed with non-blocking status code: /bin/sh: gh-axi: command not found
  ⎿  SessionStart:startup hook error                                              ⎿  Failed with non-blocking status code: /bin/sh: lavish-axi: command not
                                                                                     found

❯ Use the Bash tool to run exactly this one command and nothing else: echo fm-live-ask-marker && echo second-line

⏺ Bash(echo fm-live-ask-marker && echo second-line)
  ⎿  Waiting…

────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Bash command

   echo fm-live-ask-marker && echo second-line
   Run the specified echo commands

 Hook PreToolUse:Bash requires confirmation for this command:
 live guard asks [settings]
 settings.json to update hooks

 Do you want to proceed?
 ❯ 1. Yes
   2. No

 Esc to cancel · Tab to amend · ctrl+e to explain
Evidence: Main-prompt alarm race and persistence transcript

Source: Main-prompt alarm race and persistence transcript

--- prompt A recorded, its check starts with a 2s delay
--- prompt B's hook replaces the record while A's check sleeps
A check exit: done
record after A's check:
A raised no alert (correct, superseded)
--- B's check runs
alerts:
command|firstmate's main session has waited 1s on a permission prompt for Bash: echo prompt-B; supervision is paused until it is answered (main pane unreadable; an approved command still running looks the same)
log:
[2026-10-22T08:45:01-0700] alert: firstmate's main session has waited 1s on a permission prompt for Bash: echo prompt-B; supervision is paused until it is answered (main pane unreadable; an approved command still running looks the same)
--- adversarial: transcript changed after prompt C -> resolved, no alert
C raised no alert
[2026-10-22T08:45:02-0700] resolved: the session moved on after the Bash prompt
/tmp/fm-live-scen/race.sh: line 48: 93130 Terminated: 15          sleep 600
after A's own matched check, record exists: yes
token=tokA
subject=echo A
a newer hook write (mv over it) replaces it, nothing in check removes it
/tmp/fm-live-scen/persist.sh: line 11: 95323 Terminated: 15          sleep 600
Evidence: Lab scripts used (run.sh, race.sh, persist.sh)

Source: Lab scripts used (run.sh, race.sh, persist.sh)

#!/usr/bin/env bash
# Live scenarios against a real Claude Code TUI parked on a permission prompt,
# on a private tmux server inside a disposable lab home.
set -u
WT=~/.no-mistakes/worktrees/2355c3b107b7/01M5J2CGV2K32PMY9E958FDZ44
EV=~/.no-mistakes/evidence/01M5J2CGV2K32PMY9E958FDZ44
cd "$WT"
LAB=$(cd "$(mktemp -d "${TMPDIR:-/tmp}/fm-lab.XXXXXX")" && pwd -P)
bin/fm-lab-home.sh create "$LAB" >/dev/null
mkdir -p "$LAB/tmux" "$LAB/proj"
export TMUX_TMPDIR="$LAB/tmux"
unset TMUX
T() { tmux "$@"; }
cleanup() { T kill-server 2>/dev/null; rm -rf "$LAB"; }
trap cleanup EXIT
git init -q "$LAB/proj"
MARKER=fm-live-ask-marker
cat > "$LAB/ask-hook" <<SH
#!/usr/bin/env bash
case "\$(cat)" in
  *$MARKER*) printf '%s\n' '{"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"ask","permissionDecisionReason":"live guard asks"}}' ;;
esac
exit 0
SH
chmod +x "$LAB/ask-hook"
jq -n --arg ask "$LAB/ask-hook" '{feedbackDrafts:"off",hooks:{PreToolUse:[{matcher:"Bash",hooks:[{type:"command",command:$ask}]}]}}' > "$LAB/settings.json"
UNSET=$(env | grep -E '^(CLAUDECODE|CLAUDE_CODE_[A-Z_]+|CLAUDE_CONFIG_DIR|NO_MISTAKES_GATE|FM_[A-Z_]+_OVERRIDE|FM_GATE_REFUSE_BYPASS)=' | cut -d= -f1 | sed 's/^/-u /' | tr '\n' ' ')
T new-session -d -s fmlab -n worker -x 160 -y 44 -c "$LAB/proj" \
  "env $UNSET CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION=false claude --model haiku --dangerously-skip-permissions --settings '$LAB/settings.json'; sleep 30"
screen() { T capture-pane -p -t fmlab:worker -S -40 2>/dev/null; }
wait_for() {
  local i=0 s
  while [ $i -lt 480 ]; do
    s=$(screen)
    case "$s" in *'Yes, I trust this folder'*)
      case "$(printf '%s\n' "$s" | grep -F '❯' | head -1)" in *'Yes, I trust'*) T send-keys -t fmlab:worker Enter ;; *) T send-keys -t fmlab:worker Down ;; esac
      sleep 0.3; i=$((i+1)); continue ;; esac
    case "$s" in *"$1"*) return 0 ;; esac
    sleep 0.25; i=$((i+1))
  done
  screen; echo "TIMEOUT waiting for $1"; return 1
}
wait_for 'bypass permissions on' || exit 1
T send-keys -t fmlab:worker -l "Use the Bash tool to run exactly this one command and nothing else: echo $MARKER && echo second-line"
sleep 0.5; T send-keys -t fmlab:worker Enter
wait_for 'Do you want to proceed?' || exit 1
sleep 1
screen > "$EV/worker-pane-on-prompt.txt"
echo "=== pane on prompt saved"

echo "=== SCENARIO A: steer typed into a real prompt"
set +e
FM_HOME="$LAB" bin/fm-send.sh fmlab:worker 'please continue' > "$LAB/send.out" 2> "$LAB/send.err"
echo "fm-send rc=$?"; cat "$LAB/send.out" "$LAB/send.err"
bash -c '. bin/fm-backend.sh; fm_backend_send_text_submit tmux fmlab:worker "please continue" 3 0 0' > "$LAB/sub.out" 2> "$LAB/sub.err"
echo "fm_backend_send_text_submit rc=$?"; cat "$LAB/sub.out" "$LAB/sub.err"
set -e; set +e
sleep 3
screen > "$EV/worker-pane-after-steer.txt"
if grep -q 'Do you want to proceed?' "$EV/worker-pane-after-steer.txt" && ! grep -q 'please continue' "$EV/worker-pane-after-steer.txt" && ! grep -qx '  ⎿  second-line\|second-line' "$EV/worker-pane-after-steer.txt"; then
  echo "A: PASS prompt still open, nothing typed, command not approved"
else echo "A: FAIL"; cat "$EV/worker-pane-after-steer.txt"; fi

echo "=== SCENARIO B: watcher wake on a worker parked on the prompt"
printf 'window=fmlab:worker\nkind=ship\nharness=claude\nbackend=tmux\n' > "$LAB/state/w1.meta"
printf 'working: running the marker command\n' > "$LAB/state/w1.status"
for round in 1 2 3 4 5; do
FM_HOME="$LAB" FM_PERMISSION_PROMPT_SECS=6 FM_POLL=2 FM_SIGNAL_GRACE=1 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 \
  FM_STALE_ESCALATE_SECS=999 FM_BUSY_TURN_MAX_SECS=9999 timeout 90 bin/fm-watch.sh > "$LAB/watch.out" 2> "$LAB/watch.err"
echo "round $round watch rc=$?"
echo "--- watch stdout"; cat "$LAB/watch.out"
grep -q 'permission prompt pending' "$LAB/watch.out" && break
FM_HOME="$LAB" bin/fm-wake-drain.sh > "$LAB/drain.out" 2> "$LAB/drain.err"
seq=$(sed -n 's/^WAKE_ACK_REQUIRED:.*--ack-through \([0-9][0-9]*\) --recovery-generation .*/\1/p' "$LAB/drain.err")
gen=$(sed -n 's/^WAKE_ACK_REQUIRED:.*--recovery-generation \([A-Za-z0-9._-]*\)$/\1/p' "$LAB/drain.err")
echo "drained: $(tr '\n' ' ' < "$LAB/drain.out") ack=$seq gen=$gen"
[ -z "$seq" ] || FM_HOME="$LAB" bin/fm-wake-drain.sh --ack-through "$seq" --recovery-generation "$gen" >/dev/null 2>&1
done
echo "--- watch stderr (tail)"; tail -5 "$LAB/watch.err"
echo "--- triage log (prompt lines)"; grep -h 'permission prompt' "$LAB/state/"*triage* 2>/dev/null | tail -5
echo "--- wake queue"; grep -h 'permission-prompt' "$LAB/state/.wake-queue" 2>/dev/null
screen | grep -q 'Do you want to proceed?' && echo "prompt still unanswered after the watcher"

T send-keys -t fmlab:worker Escape
sleep 2
screen > "$EV/worker-pane-after-escape.txt"
echo "=== cleared prompt with Escape"

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ℹ️ bin/fm-main-prompt-alarm.sh:142 - check() reads the record's token and then runs rm -f &#34;$RECORD&#34; without checking again that the record is still its own. Suppose prompt B's hook replaces the record in the short gap after prompt A's check has matched its token (A was answered long ago, and its delayed check fires just as a new prompt opens). A's check then deletes B's record. B's check later finds no matching token and exits silently, so a prompt that is really waiting never alerts. The window is a few milliseconds, so this is rare. Fix: re-read the token right before the remove, or drop the rm and let the token comparison alone decide which check is current.

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

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A real Claude hook-ask permission prompt is recognized as a blocking dialog that names the prompted command ✅ pass live live-e2e-claude-2.1.308.log: fm_composer_permission_prompt subject = 'echo fm-live-ask-marker && echo second-line', dialog name 'Claude permission prompt: ...'
Steering a worker parked on a real prompt (fm-send and typed submit) types nothing, so the prompt is not approved ✅ pass live live-worker-scenarios.log: both refused with 'blocked on a prompt: Claude permission prompt: ...'; worker-pane-after-steer.txt still shows 'Do you want to proceed?' with no typed text and no command o…
The watcher raises one check: permission prompt pending wake for a worker that stays on a prompt past FM_PERMISSION_PROMPT_SECS, and stale reasons carry blocked-on-prompt ✅ pass live live-worker-scenarios.log: 'check: permission prompt pending: task=w1 window=fmlab:worker waiting=7s - Claude permission prompt: ...' and a durable wake-queue row permission-prompt-w1-<since>; prompt…
The main-session PermissionRequest hook alerts once through the wedge-alarm channel while the prompt waits, and decides nothing ✅ pass live live-e2e-claude-2.1.308.log: 'the PermissionRequest registration alerts on a waiting prompt and leaves it unanswered'
Adversarial: an older prompt's delayed check that fires after a newer prompt's hook does not delete the newer record or alert; the newer prompt's check still alerts ✅ pass live main-alarm-race.log: check tokA raised no alert; check tokB alerted 'for Bash: echo prompt-B'; after a matched check the record file still exists (persist section)
Adversarial: a prompt whose session transcript changed (answered or cancelled) does not alert ✅ pass live main-alarm-race.log: tokC 'resolved: the session moved on after the Bash prompt', no alert
  • FM_PERMISSION_PROMPT_LIVE_E2E=1 bash tests/fm-permission-prompt-live-e2e.test.sh (real Claude Code 2.1.308, isolated tmux and FM_HOME)
  • Live lab script run.sh: real Claude worker parked on a hook-ask prompt; FM_HOME=$LAB bin/fm-send.sh fmlab:worker &#39;please continue&#39; and fm_backend_send_text_submit tmux fmlab:worker ..., then a pane capture
  • Live lab script run.sh: bin/fm-watch.sh against the lab home with FM_PERMISSION_PROMPT_SECS=6, its wakes drained and acked through bin/fm-wake-drain.sh between runs
  • race.sh: bin/fm-main-prompt-alarm.sh check tokA sleeping while a newer prompt record (tokB) replaces it, then check tokB, then a transcript-changed check (tokC)
  • persist.sh: after a check whose token matches, the prompt record still exists (HEAD commit removed the rm)
  • bash tests/fm-main-prompt-alarm.test.sh, tests/fm-composer-lib.test.sh, tests/fm-tmux-submit-busy.test.sh, tests/fm-wake-queue.test.sh (targeted; no failures)
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

A Claude permission prompt, including the one a PreToolUse hook's ask
decision opens, now matches fm_composer_permission_prompt by its bottom
structure and is named as a blocking dialog with the prompted command's
first line. Its selected '1. Yes' row read as a composer holding text, so
a typed submit would have pressed the Enter that approves the call; the
delivery guards now refuse it.
A worker parked on a Claude permission prompt is still inside its turn,
so it read busy and was only reported after FM_BUSY_TURN_MAX_SECS. The
watcher now raises one check wake, naming the task and the prompted
command's first line, once the same prompt has stayed on the pane for
FM_PERMISSION_PROMPT_SECS (default 90), and teardown prunes a task's
pending prompt wakes. Nothing answers the prompt.
The config/wedge-alarm channel layer moves unchanged from the away-mode
daemon into bin/fm-wedge-alarm-lib.sh so another alarm can use the same
channels. Callers name their alarm through WEDGE_ALARM_TITLE, which the
osascript banner now receives as an argv item.
A tracked Claude PermissionRequest hook records a prompt in the
lock-owning primary session and starts one delayed check. After
FM_MAIN_PROMPT_ALARM_SECS (default 300) it alerts once through the
config/wedge-alarm channels when the session transcript has not moved
and the main pane, when readable, still shows the prompt. The hook
prints no decision, so the prompt is never answered. An opt-in live
guard proves both prompt signals against the installed Claude Code.
Record the measured prompt shapes and hook behavior on Claude Code
2.1.306 and 2.1.153, the two new settings, the shared alarm channels,
the new state records, and how a supervisor handles a worker parked on
a permission prompt without approving it.
…entries

The tracked PermissionRequest registration carries the same Grok guard as
the other Claude-only entries, so the inventory of tracked hooks now stubs
its script and expects eight guarded entries.
…on screen

The watcher reads every worker pane on every poll, so the matcher now
returns before forking unless the screen holds its question text.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @johntran-mudflap. This is a careful piece of work, and the live labs on real Claude Code 2.1.306 are exactly the kind of evidence that helps. This is my first triage look.

I read the whole diff of head 4faa04bc against main (23 files). It covers the composer's Claude permission-prompt recognition, the new watcher permission_prompt_check and its check: permission prompt pending wake, the new bin/fm-main-prompt-alarm.sh behind a PermissionRequest hook in .claude/settings.json, the wedge-alarm channels moved into bin/fm-wedge-alarm-lib.sh, the wake-queue prune, and the tests and docs. The library move is faithful: the removed daemon block and the new library match apart from comments and the new WEDGE_ALARM_TITLE. Titles and summaries still reach osascript as argv. There are no workflow edits, no network calls and no credential handling, and nothing answers a prompt. The no-mistakes attestation binds this head, and live validation is 7 of 8 go. The Herdr main-pane capture and the real banner stay disclosed as untested.

CI: this head's first-time-contributor runs were waiting for approval. I approved them (CI 39629823970, Require no-mistakes 39629824232 and 39631151666), so they're running now.

contract-class: new-default (my own read): without any configuration, every Claude worker pane gets a new wake class after FM_PERMISSION_PROMPT_SECS (90s), and firstmate's own Claude main session gets a new PermissionRequest hook and an alert after 300s. The composer refusing to type into a permission prompt is a safety guard in its own right, but it ships together with those new default-on surfaces.

Overlap worth knowing: #7480 (@Azd325) also wakes the first mate on Claude worker permission prompts. It does that through a PermissionRequest hook in the generated worker settings, writing a needs-decision status line, rather than by reading the pane. The two would double-signal the same worker prompt. Yours also covers the main session and the delivery guard, which #7480 doesn't. If you have a view on how the two should fit together (for example, keeping the worker-pane wake only as a fallback when no hook has fired), a short note here would help Kun decide.

VISION, rule by rule: One captain aligns (a stalled prompt surfaces instead of silently blocking). Authority aligns (it detects and alerts only, never answers, and the delivery guard stops a typed steer approving a call). Scripts/judgment aligns. Restart aligns (durable per-window records and a prunable keyed wake). Delegation aligns (live 7/8 plus unit suites). On vendor, it aligns with a note: the worker-pane wake reads Claude's rendered prompt even though Claude exposes a PermissionRequest hook for workers. It's recorded with version readings in runtime-backends.md, but Kun should weigh it next to #7480. Scope aligns.

Where this stands: waiting on CI, with nothing required from you. If CI and the no-mistakes check come back green, this goes to Kun to decide whether to merge or leave it, since it changes default behavior. I won't merge it on my own.

Resolves the operational-home-layout runtime-marker list as the union of both sides: the wedge-cap markers from main and the permission-prompt markers from this branch.
@johntran-mudflap johntran-mudflap changed the title feat(bin): detect Claude permission prompts on worker panes and the main session feat(bin): detect and alert on pending Claude permission prompts Oct 21, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks for bringing this up to date with main, @johntran-mudflap.

I looked at the new head 4c60946a. The merge only resolves the runtime-marker list in operational-home-layout/SKILL.md as the union of both sides, and the rest of the diff against main 9fe25bca is the same change I reviewed before. The no-mistakes attestation binds this head, and live validation is go (6 of 8).

CI: on this head, serial 2 was cancelled at the 30-minute limit, which is a known flake. Serial 4 failed one case, post-cap churn poll 10 watcher did not stay alive, in tests/fm-watch-wedge-cap.test.sh. Since this PR touches the watcher, I ran that file on this exact head myself and every case passed, so it looks like a timing flake. I've re-run the failed jobs.

contract-class: new-default, same as before: with no configuration, worker panes get the new permission-prompt wake and the main Claude session gets the new PermissionRequest alarm. The overlap with #7480 still stands, and a short note from you on how the two should fit together would still help Kun.

Where this stands: waiting on the CI re-run, and you don't need to do anything. If it comes back green, this goes to Kun to decide whether to merge it or leave it. I won't merge it on my own.

Resolves the operational-home-layout runtime-marker list again as the union of both sides: main's current wording and markers plus this branch's permission-prompt markers.
@johntran-mudflap johntran-mudflap changed the title feat(bin): detect and alert on pending Claude permission prompts feat(bin): detect Claude permission prompts on worker and main panes Oct 22, 2026
@johntran-mudflap

Copy link
Copy Markdown
Author

Merged the latest main to clear the conflict. On the previous run, the two red jobs looked unrelated to this change: "Behavior portable serial 2" hit the 30-minute timeout, and "serial 4" failed fm-watch-wedge-cap.test.sh once; that test passes 12/12 on both this branch and main, including under heavy parallel load. Could a maintainer approve the new workflow run?

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @johntran-mudflap for merging main and for checking the two red jobs. I agree: the serial 2 timeout and the one-off fm-watch-wedge-cap failure aren't from this change.

I read the new head 3b86c3c6 against main d906d442. Apart from the main merge, your own delta is small: check() in bin/fm-main-prompt-alarm.sh no longer deletes the record up front, so it can't remove a newer prompt's record. There's also a matching test tweak and one line in the operational-home-layout skill. The attestation binds this head (MATCH), and the PR merges cleanly with current main.

The new head's fork runs (CI 39810638876, Require no-mistakes) haven't started yet: they're waiting on a maintainer's approval to run, which isn't something you need to do anything about.

Contract-class (my read, unchanged): new-default. VISION: unchanged.

Status: waiting on CI, not on you. Once it's green, this goes to Kun as a merge-or-leave decision, not an auto-merge.

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.

2 participants