When Claude finishes a response but hasn't written to the PHASE file,
the stop hook now injects a nudge into the tmux session instead of just
marking idle. This gives Claude another chance to complete the phase
protocol before the monitor loop times out.
Key changes:
- on-idle-stop.sh: check phase file emptiness, nudge via tmux (max 2)
- agent-session.sh: pass phase_file + session to stop hook, clean up
nudge counter on session teardown
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add session name as third arg to guard hook (passed from agent-session.sh)
- Detect formula sessions (supervisor-*, gardener-*, planner-*, predictor-*)
- Guard 6: block filesystem access to factory root from worktrees, exempt formulas
- Guard 7: restrict system commands (kill, docker, tmux) to supervisor only
- Guard 2: allow formula agents rm -rf within factory root
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Guard against overwriting terminal phases (PHASE:done, PHASE:merged)
in on-stop-failure.sh to prevent false failures from same-turn race
- Declare sf_phase_marker explicitly in StopFailure block instead of
relying on phase_marker from PostToolUse block
- Add authentication_failed test (10c) and terminal phase guard tests
(10g, 10h)
- Fix fragile nested command substitution in test 10f fail() message
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Guard 2: add /tmp/* to allowlist so normal temp file cleanup is not blocked
- Guard 1: block bare `git push --force` (no branch arg) since upstream may
point to primary branch
- Guard 4: allow flags between verb and branch (`git switch --detach main`),
escape branch name for regex safety, exclude -b/-B/-c/-C (branch creation)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
## Summary
- Claude Code v2.1.79 permanently shows `❯` in the input area even while actively thinking, causing `monitor_phase_loop` to false-positive on idle detection and kill working sessions after 90 seconds
- Replace `tmux capture-pane | grep ❯` with a Claude Code Stop hook (`lib/hooks/on-idle-stop.sh`) that writes a marker file only when Claude actually finishes responding
- Hook is installed per-worktree in `.claude/settings.json` by `create_agent_session`; marker cleaned up on inject/kill
## Test plan
- [x] Verified hook installs correctly in fresh worktree
- [x] Verified marker file appears only after Claude finishes responding (not during active thinking)
- [x] Verified live dev-agent session picks up fix and Claude works without being killed
- [x] Verified `agent_inject_into_session` clears marker before new work
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: openhands <openhands@all-hands.dev>
Reviewed-on: https://codeberg.org/johba/disinto/pulls/272