Skip to content

fix: block primary-session delegation outside the fleet - #854

Merged
kunchenguid merged 5 commits into
kunchenguid:mainfrom
ItsFlow:fm/fm-agent-guard
Jul 22, 2026
Merged

kunchenguid merged 5 commits into
kunchenguid:mainfrom
ItsFlow:fm/fm-agent-guard

Conversation

@ItsFlow

@ItsFlow ItsFlow commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Intent

Stop firstmate's primary session from delegating work through Claude Code's own subagent tool instead of firstmate's real crewmate dispatch (bin/fm-spawn.sh).

WHY: On 2026-07-22 the firstmate primary ran four workers through Claude Code's built-in subagent tool rather than bin/fm-spawn.sh. Observed, not hypothetical: the fleet view showed zero work under way the whole time (no state/.meta, no data//brief.md); on primary restart two workers died mid-flight and their work was lost; supervision then stayed down 73 minutes unnoticed, silently killing the captain's Workflowy intake channel. The deeper defect is that only bin/fm-spawn.sh writes state/.meta and every guard keys off it (bin/fm-supervision-lib.sh counts state/*.meta; bin/fm-turnend-guard.sh exits silently at zero), so a bypass makes the whole guard stack structurally INERT, not merely unenforced.

DELIBERATE DESIGN DECISIONS a reviewer reading only the diff would not know:

  1. TWO LAYERS ON PURPOSE, and layer 1 is the primary fix. The task originally asked only for a PreToolUse hook. Mid-task a parallel investigation empirically showed that a permissions.deny entry in .claude/settings.json REMOVES the tool from the model's schema entirely - the model is never offered it, so there is no call to intercept, no matcher to get wrong, and no fail-open path. That is strictly stronger than a hook, so the deny list became the primary fix and the hook was demoted to a backstop.

  2. THE HOOK WAS DELIBERATELY REDESIGNED, NOT KEPT AS-IS. A fixed-list hook behind a fixed deny list would be dead code duplicating layer 1. The explicit instruction was to keep it ONLY if it defends against FUTURE tools not yet on the deny list. So bin/fm-subagent-pretool-check.sh classifies the tool NAME BY SHAPE (stem list) rather than against a fixed list. This is verified live: with Workflow removed from the deny list, the backstop still blocked it. It is additive, not duplicative.

  3. permissions.allow is a PRE-APPROVAL list, not an availability list, so there is no fail-closed positive allowlist available. That is why the deny list is fail-open against future tools and why layer 2 must exist. Documented as a known residual gap.

  4. BOTH 'Task' AND 'Agent' ARE PINNED AS DENY KEYS. A prior finding claimed the key must be 'Task' and that 'Agent' silently does nothing. I disproved that with a five-way A/B, each variant in a fresh directory to rule out settings caching, including a nonsense-name control (deny ZzzNotARealTool leaves Agent present). Both keys independently remove the tool on Claude Code 2.1.217. Pinning both costs one line and removes the failure mode where a rename or rollback silently reopens the surface. The correction is recorded in docs/subagent-guard.md and the harness-adapters skill.

  5. THE OBSERVE-ONLY EXCLUSION IS INTENTIONAL AND ASYMMETRIC BETWEEN LAYERS. Layer 2 deliberately allows taskoutput/taskstop/taskget/tasklist/cronlist/bashoutput/killshell because those observe or stop work that already exists rather than creating it; blocking them could strand a runaway task with no way to inspect or end it. Layer 1 (captain-owned) still denies them. The asymmetry is deliberate so the backstop can never be the reason a runaway task cannot be stopped.

  6. mcp__* NAMES ARE NEVER CLASSIFIED. An MCP server chooses its own tool names and a task/agent noun there is common; classifying them would be a false positive with no bearing on fleet dispatch.

  7. DENY-LIST WIDTH IS EXPLICITLY THE CAPTAIN'S CALL, NOT MINE. I was instructed not to finalise the exact denied set myself because denying some of these changes how the captain works with the primary. It ships at the wider 18-name setting so the surface is closed by default, implemented as one flat array in one file so it is reviewable at a glance and narrowable in one line.

  8. SCOPING USES THE EXISTING SHARED PREDICATE fm_primary_scope_matches, not a new one, so the three tracked primary-scoped hooks (session-start nudge, turn-end guard, this one) cannot drift apart. A marked secondmate home is IN scope on purpose (it operates its own fleet); a crewmate's linked task worktree is OUT of scope on purpose (a worker using subagents there is legitimate). Verified live both ways with identical hook bytes.

  9. FAIL-OPEN ON TRANSPORT IS DELIBERATE and matches the sibling seatbelts (bin/fm-arm-pretool-check.sh, bin/fm-cd-pretool-check.sh): malformed stdin, missing jq, or an unconfirmable home is inert rather than blocking, so a broken environment can never deny every tool call.

  10. ONE ESCAPE HATCH, FM_ALLOW_SUBAGENT=1, as an ENV VAR specifically because it must be set at process launch. No in-session tool call can set it for the call that follows, so a deliberate use stays possible while an accidental one is impossible. It fails closed on every other value including empty, 0, yes, true.

  11. --claude SUPPRESSES STDOUT because Claude Code only honours a PreToolUse deny when stdout is empty (verified quirk already recorded in docs/arm-pretool-check.md). Default mode still emits the Grok stdout decision object.

  12. OTHER HARNESSES WERE REVIEWED, NOT SILENTLY SKIPPED. Codex 0.144.1 was empirically verified to expose NO delegation tool (full tool enumeration recorded in the doc), so it is genuinely not applicable. grok, opencode and pi are deliberately NOT wired: none of those binaries is installed on this host, so the exact tool-name tokens could not be confirmed and the wiring could not be validated against the real harness. The repo's own firstmate-coding-guidelines rule requires live validation before trusting a harness hook, and docs/arm-pretool-check.md records that a slightly-wrong Grok hook command fails to launch the hook entirely. Wiring an unvalidated matcher would trade a known gap for an unknown breakage. Each one's integration surface and exact follow-up procedure is documented instead.

CONSTRAINTS FOLLOWED: firstmate-coding-guidelines skill (knowledge placement - mechanics in script header/--help, reference detail and dated evidence in docs/, no AGENTS.md change since the siblings have none and the existing prime directive already states the rule); one full sentence per line in tracked Markdown; plain dash never em dash; no agent name as commit co-author; shellcheck clean via bin/fm-lint.sh (the single lint owner, pinned 0.11.0); test colocated in tests/ matching neighbours and registered in the existing bin/fm-test-run.sh family map rather than inventing a new runner.

VERIFICATION DONE: bin/fm-lint.sh clean; 13 new tests pass; pure-contract-unit family 28/28 with 0 failures; coverage guard ok. Live evidence against Claude Code 2.1.217 recorded in docs/subagent-guard.md with dates, versions, exact commands and exact output: tool-name discovery, the five-way deny-key A/B with control, layer 1 under the real tracked settings, layer 2 blocking an un-denied Workflow call, the same call ALLOWED in a linked worktree, and the escape hatch.

What Changed

  • Adds bin/fm-subagent-pretool-check.sh, a primary-scoped PreToolUse guard that denies delegation-shaped harness tools while preserving MCP, observe-only, linked-worktree, fail-open transport, and FM_ALLOW_SUBAGENT=1 paths.
  • Wires Claude’s PreToolUse matcher to run the guard for all tools and documents the guard contract, local Claude deny-list hardening, harness applicability, and related turn-end guard ownership.
  • Registers the new guard test in fm-test-run and adds behavior coverage for current and future delegation-shaped tool names, scope handling, output shapes, and tracked settings boundaries.

Risk Assessment

🚨 High: The implementation appears to address the prior scoped-hook concerns, but it now contradicts the authoritative source-verifiable acceptance criteria requiring a shipped tracked deny-list layer.

Testing

Inspected the diff and relevant guard/settings/docs surfaces, confirmed Claude Code 2.1.217, ran the focused behavioral test through fm-test-run, added and reran missing jq fail-open coverage, and captured CLI evidence for the deny list plus hook deny/allow/escape/scope behavior; all exercised checks passed, with no UI screenshot applicable for this CLI/hook change.

Evidence: Subagent guard CLI evidence transcript
subagent guard CLI evidence
date: 2026-07-22T13:10:09Z
claude-version: 2.1.217 (Claude Code)

tracked-deny-list-count: 18
tracked-deny-list:
  - Task
  - Agent
  - Workflow
  - RemoteTrigger
  - Monitor
  - ScheduleWakeup
  - SendMessage
  - EnterWorktree
  - ExitWorktree
  - CronCreate
  - CronDelete
  - CronList
  - TaskCreate
  - TaskGet
  - TaskList
  - TaskUpdate
  - TaskStop
  - TaskOutput
subagent-hook-matcher: .*
subagent-hook-command: "$CLAUDE_PROJECT_DIR"/bin/fm-subagent-pretool-check.sh --claude

case: primary_future_workflowrun_denied
tool: WorkflowRun
extra-env: <none>
root-kind: /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/manual-primary
exit: 2
stdout-bytes: 0
stderr-json: {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny"},"systemMessage":"[subagent-dispatch] the firstmate primary dispatches through the fleet, not the harness's own delegation tools: work started that way has no durable fleet record, leaves every firstmate guard inert, and dies with this session. Instead, investigation and ship work both go to bin/fm-brief.sh then bin/fm-spawn.sh (blocked tool: WorkflowRun, delegation-shaped on \"workflow\"). Launch the session with FM_ALLOW_SUBAGENT=1 for a deliberate exception."}

case: primary_observe_taskoutput_allowed
tool: TaskOutput
extra-env: <none>
root-kind: /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/manual-primary
exit: 0
stdout-bytes: 0
stderr-json: <empty>

case: primary_mcp_task_name_allowed
tool: mcp__tracker__create_task
extra-env: <none>
root-kind: /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/manual-primary
exit: 0
stdout-bytes: 0
stderr-json: <empty>

case: primary_escape_hatch_agent_allowed
tool: Agent
extra-env: FM_ALLOW_SUBAGENT=1
root-kind: /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/manual-primary
exit: 0
stdout-bytes: 0
stderr-json: <empty>

case: linked_worktree_agent_allowed
tool: Agent
extra-env: <none>
root-kind: /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/manual-child
exit: 0
stdout-bytes: 0
stderr-json: <empty>

case: primary_grok_stdin_agent_denied
transport: stdin {"toolName":"Agent"}, default output mode
exit: 2
stdout-json: {"decision":"deny","reason":"[subagent-dispatch] the firstmate primary dispatches through the fleet, not the harness's own delegation tools: work started that way has no durable fleet record, leaves every firstmate guard inert, and dies with this session. Instead, investigation and ship work both go to bin/fm-brief.sh then bin/fm-spawn.sh (blocked tool: Agent, delegation-shaped on \"agent\"). Launch the session with FM_ALLOW_SUBAGENT=1 for a deliberate exception."}
stderr-json: {"hookSpecificOutput":{"hookEventName":"PreToolUse","permissionDecision":"deny"},"systemMessage":"[subagent-dispatch] the firstmate primary dispatches through the fleet, not the harness's own delegation tools: work started that way has no durable fleet record, leaves every firstmate guard inert, and dies with this session. Instead, investigation and ship work both go to bin/fm-brief.sh then bin/fm-spawn.sh (blocked tool: Agent, delegation-shaped on \"agent\"). Launch the session with FM_ALLOW_SUBAGENT=1 for a deliberate exception."}

case: missing_jq_stdin_fails_open
transport: stdin {"tool_name":"Agent"}, --claude, PATH contains cat but no jq, script invoked via /bin/bash
exit: 0
stdout-bytes: 0
stderr-bytes: 0
Evidence: Focused test runner result
{
  "families": [
    {
      "count": 1,
      "duration_ms": 1488,
      "failed": 0,
      "name": "pure-contract-unit"
    }
  ],
  "finished_at": "2026-07-22T13:12:00Z",
  "run_id": "fm-test-run-1784725918846-71569",
  "scripts": [
    {
      "duration_ms": 1488,
      "exit": 0,
      "expected_gate_skip": "none",
      "family": "pure-contract-unit",
      "gate_skip": false,
      "path": "tests/fm-subagent-pretool-check.test.sh"
    }
  ],
  "selection": "scripts",
  "started_at": "2026-07-22T13:11:58Z",
  "summary": {
    "duration_ms": 1536,
    "failed": 0,
    "skipped_gate": 0,
    "total": 1
  }
}
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (14m16s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 error
  • 🚨 .claude/settings.json:55 - Layer 2 only runs if Claude's PreToolUse matcher fires first, but this matcher omits the Subagent casing while the checker/test matrix expects future names like SubagentCreate to be denied by shape. A SubagentCreate tool would not match this case-sensitive pattern, so the backstop would never call fm-subagent-pretool-check.sh; broaden the matcher or match all tools and let the script filter.
  • ⚠️ .claude/settings.json:2 - The stated criterion says a crewmate linked task worktree is out of scope because worker subagents are legitimate, but this project-level permissions.deny file is tracked and will be present in firstmate-repo linked worktrees too. That removes Agent/Task before the hook's linked-worktree scope check or FM_ALLOW_SUBAGENT=1 can help, so Claude crewmates working on this repo cannot use the delegation tools the intent says should remain legitimate.

🔧 Fix: Ship scoped Claude delegation guard
1 error still open:

  • 🚨 .claude/settings.json:1 - The original intent requires “TWO LAYERS ON PURPOSE, and layer 1 is the primary fix,” says both Task and Agent are pinned as deny keys, and says the 18-name deny list “ships at the wider 18-name setting.” The current tracked settings now contain only hooks and no permissions.deny, so the required schema-removal layer is absent; either update the authoritative intent to the follow-up local-hardening decision or restore the tracked deny layer.
🔧 **Test** - 1 issue found → auto-fixed ✅
  • 🚨 .claude/settings.json:1 - The authoritative intent says the Claude permissions.deny layer is the primary shipped fix and should ship as the wider 18-name deny list with both Task and Agent pinned. The tracked .claude/settings.json has no permissions.deny object at all, and the new test suite explicitly asserts that absence, so a fresh primary relies only on the weaker hook backstop instead of removing Claude delegation tools from the model schema as required.
  • bin/fm-test-run.sh --json /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/fm-subagent-pretool-check-run.json tests/fm-subagent-pretool-check.test.sh
  • Evidence transcript script wrote /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/fm-subagent-hook-e2e-transcript.txt after exercising primary Agent/Workflow denial, FM_ALLOW_SUBAGENT=1, observe-only and MCP allows, Claude/Grok stdin payloads, and linked-worktree allow behavior.

🔧 Fix: Ship Claude delegation deny list
✅ Re-checked - no issues remain.

  • command -v claude && claude --version
  • bin/fm-test-run.sh --json /var/folders/tc/llfmckm54ls5tzxm08q758lm0000gn/T/no-mistakes-evidence/01KY4WQ89NK5ZV3H3V6DEYQBKP/fm-subagent-pretool-test-run.json tests/fm-subagent-pretool-check.test.sh
  • Manual evidence transcript: checked .claude/settings.json has the 18-name deny list and fm-subagent-pretool-check.sh --claude is wired on matcher .*.
  • Manual evidence transcript: WorkflowRun in a firstmate-shaped primary fixture denied with exit 2, Claude-shaped stderr, and empty stdout.
  • Manual evidence transcript: TaskOutput, mcp__tracker__create_task, FM_ALLOW_SUBAGENT=1 Agent, and linked-worktree Agent calls allowed with empty output.
  • Manual evidence transcript: stdin {&#34;toolName&#34;:&#34;Agent&#34;} denied in default/Grok mode with stdout decision JSON, and stdin {&#34;tool_name&#34;:&#34;Agent&#34;} failed open with no jq on PATH.
✅ **Document** - passed

✅ No issues found.

🔧 **Lint** - 1 issue found → auto-fixed ✅
  • ⚠️ linter found issues (exit code 1)

🔧 Fix: Keep Claude deny list local
✅ Re-checked - no issues remain.

✅ **Push** - passed

✅ No issues found.

ItsFlow added 5 commits July 22, 2026 14:20
A firstmate primary that delegates through Claude Code's built-in
delegation tools creates work with no state/<id>.meta. Because
fm-supervision-lib.sh counts *.meta and fm-turnend-guard.sh exits
silently at zero, such work does not merely go unsupervised: it makes
the whole guard stack structurally inert, and it dies with the primary
session. On 2026-07-22 that cost two workers mid-flight and left
supervision down for 73 minutes unnoticed.

Layer 1, the primary fix: a permissions.deny list in
.claude/settings.json removes the 18 delegation, scheduling, worktree,
and task-tracking tools from the model's schema, so they are never
offered. This is removal rather than interception, so there is no call
to intercept and no fail-open path. The list is flat and in one file so
its width stays reviewable; the captain owns that width.

Layer 2, bin/fm-subagent-pretool-check.sh: a deny list is fail-open
against tools that do not exist yet, and permissions.allow is a
pre-approval list rather than an availability list, so there is no
fail-closed allowlist to use instead. This backstop classifies the tool
NAME by shape rather than against a fixed list, so a delegation tool
that ships before the deny list is updated is still refused. It excludes
mcp__* names and observe-or-stop operations, scopes itself to a genuine
primary home via the shared fm_primary_scope_matches predicate so a
crewmate's task worktree is unaffected, and offers one deliberate
FM_ALLOW_SUBAGENT=1 escape hatch that must be set at launch.

Verified live against Claude Code 2.1.217, including a deny-key A/B with
a nonsense-name control, layer 2 denying an un-denied Workflow call, the
same call allowed in a linked worktree, and the escape hatch. Corrects a
prior finding: both Task and Agent work as deny keys, so both are
pinned. Codex 0.144.1 verified to expose no delegation tool; grok,
opencode, and pi are inspected and documented as not wired because those
binaries are absent from this host and the repo requires live validation
before trusting a harness hook. Evidence in docs/subagent-guard.md.
@kunchenguid
kunchenguid merged commit 50cc24a into kunchenguid:main Jul 22, 2026
10 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Thanks @ItsFlow - merged! Really appreciate the contribution.

Keigyoku added a commit to Keigyoku/firstmate that referenced this pull request Jul 23, 2026
* fix: prevent no-mistakes gate agents from driving the fleet

Port upstream kunchenguid#518 (6556882): gate agents must not spawn/send/teardown.
Sourced refuse lib on fleet entrypoints; FM_GATE_REFUSE_BYPASS for suite.

Cherry-picked-from: 6556882 (kunchenguid#518)

* fix: block primary-session delegation outside the fleet

Port upstream kunchenguid#854 (50cc24a) plus primary-scope-lib dependency.
Compose subagent PreToolUse matcher with fork arm-pretool seatbelt and
claim-guard Stop path; do not track Claude permissions.deny.
Composition covered by tests/fm-pretool-stack-composition.test.sh.

Cherry-picked-from: 50cc24a (kunchenguid#854)

* feat: port primary cd-guard and secondmate turnend scope

B2: upstream kunchenguid#483 (88e38ea) + kunchenguid#505 (2364817).

- cd-guard PreToolUse seatbelt composed with arm-pretool and subagent stacks
- export arm shell classifier for reuse; do not replace private PreToolUse rails
- turnend force-includes marked secondmate homes via primary-scope-lib
- keep fork physical-identity matching, queue-pending, and claim-guard Stop path

Cherry-picked-from: 88e38ea (kunchenguid#483), 2364817 (kunchenguid#505)

* feat: port fm-lock-lib and reconcile teardown stale-lock proof

B3: replace deferred kunchenguid#435 with tip lock-lib ownership.
Teardown sources fm_lock_is_provably_stale for index.lock cleanup while
keeping fork path-spelling retry (7c0ad63 family) and landed-work refusals.

Cherry-picked-from: tip fm-lock-lib.sh (replaces deferred kunchenguid#435)

* feat: port durable captain decision holds and bearings wiring

B4: upstream kunchenguid#593 (cd218f2) + kunchenguid#654 (024b96b).
Adds fm-decision-hold.sh, decision-hold-lifecycle skill/docs, classify
status_open_decisions fold, scout teardown verify gate, and unstubs
bearings/fleet-snapshot decisions_open for structured captain holds.

Cherry-picked-from: cd218f2 (kunchenguid#593), 024b96b (kunchenguid#654)

* fix: make watcher process identity immune to wall-clock steps

B5 partial: upstream kunchenguid#752 (a26b37c). Prefer Linux /proc starttime+cmdline
over ps lstart so WSL2 btime drift cannot false-evict a live watcher.

Cherry-picked-from: a26b37c (kunchenguid#752)

* feat: enrich drained wakes with bounded status context

B5 partial: upstream kunchenguid#747 (4ab61fa). After raw queue commit, best-effort
annotations add home-local status context without blocking appends or
reordering authoritative drain rows. No watch-arm topology changes.

Cherry-picked-from: 4ab61fa (kunchenguid#747)

* no-mistakes(review): Captain: enforce durable decisions and deduplicate holds

* no-mistakes(review): Captain: clarify secondmate turn-end and claim-guard scope

* no-mistakes(review): Captain: unify marker-aware primary scope enforcement

* no-mistakes(test): Captain: complete scout decision inventories in teardown fixtures

* no-mistakes(test): Captain, stabilize teardown fixtures and OpenCode guard

* no-mistakes(document): Captain: refresh Batch B documentation and lint references

* no-mistakes: apply CI fixes
ItsFlow referenced this pull request in ItsFlow/firstmate Jul 26, 2026
* fix: block primary-session delegation outside the fleet (#854)

* feat: fence primary-session delegation outside the fleet

A firstmate primary that delegates through Claude Code's built-in
delegation tools creates work with no state/<id>.meta. Because
fm-supervision-lib.sh counts *.meta and fm-turnend-guard.sh exits
silently at zero, such work does not merely go unsupervised: it makes
the whole guard stack structurally inert, and it dies with the primary
session. On 2026-07-22 that cost two workers mid-flight and left
supervision down for 73 minutes unnoticed.

Layer 1, the primary fix: a permissions.deny list in
.claude/settings.json removes the 18 delegation, scheduling, worktree,
and task-tracking tools from the model's schema, so they are never
offered. This is removal rather than interception, so there is no call
to intercept and no fail-open path. The list is flat and in one file so
its width stays reviewable; the captain owns that width.

Layer 2, bin/fm-subagent-pretool-check.sh: a deny list is fail-open
against tools that do not exist yet, and permissions.allow is a
pre-approval list rather than an availability list, so there is no
fail-closed allowlist to use instead. This backstop classifies the tool
NAME by shape rather than against a fixed list, so a delegation tool
that ships before the deny list is updated is still refused. It excludes
mcp__* names and observe-or-stop operations, scopes itself to a genuine
primary home via the shared fm_primary_scope_matches predicate so a
crewmate's task worktree is unaffected, and offers one deliberate
FM_ALLOW_SUBAGENT=1 escape hatch that must be set at launch.

Verified live against Claude Code 2.1.217, including a deny-key A/B with
a nonsense-name control, layer 2 denying an un-denied Workflow call, the
same call allowed in a linked worktree, and the escape hatch. Corrects a
prior finding: both Task and Agent work as deny keys, so both are
pinned. Codex 0.144.1 verified to expose no delegation tool; grok,
opencode, and pi are inspected and documented as not wired because those
binaries are absent from this host and the repo requires live validation
before trusting a harness hook. Evidence in docs/subagent-guard.md.

* no-mistakes(review): Ship scoped Claude delegation guard

* no-mistakes(test): Ship Claude delegation deny list

* no-mistakes(document): Clarify PreToolUse guard ownership

* no-mistakes(lint): Keep Claude deny list local

* fix: install tasks-axi in portable CI shards (#866)

Reproduction: portable-parallel-2 completed successfully without tasks-axi while fm-decision-hold-lifecycle emitted a gate skip in 30 ms. The pre-shard lane installed tasks-axi and exercised the test fully. Installing tasks-axi is the smallest counterfactual and makes the representative shard execute the test with gate_skip=false in about 20 seconds. Both parallel jobs receive symmetric setup, while the exact 91-test inventory and coverage guard remain unchanged.

* feat(bin): make dispatch profiles quota aware (#867)

* feat: make dispatch profiles quota aware

* no-mistakes(review): Fix quota window and Grok product scoping

* no-mistakes(document): Document implicit quota-aware dispatch accurately

* Add built-in ahoy recap skill (#873)

* fix: preserve trustworthy Bearings data in partial snapshots (#875)

* fix: preserve mixed Bearings projections

* no-mistakes(review): Enforce strict invalidity precedence for partial snapshots

* no-mistakes(review): Enforce ownership for unknown child metadata

* no-mistakes(document): Document partial structured Bearings projections

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* feat(pi): add session-local calm mode (#884)

* Add session-local Pi calm mode

* no-mistakes(review): Preserve Pi HTML exports during calm mode

* no-mistakes(review): Preserve calm exports across submit bindings and share

* no-mistakes(document): Document calm-mode feasibility across supported harnesses

* fix(pi): prevent redundant watcher re-arms (#885)

* fix(pi): limit watcher arm tool to recovery

* no-mistakes(review): Strengthen Pi live re-arm regression coverage

* no-mistakes(document): Document Pi first-cycle and recovery-only watcher arming

* fix(pi): clean up Calm transcript rendering (#895)

* fix(pi): clean up Calm transcript rendering

* no-mistakes(review): Captain, preserve Calm exports and classify Pi launch briefs

* no-mistakes(review): Captain, eliminate Calm gaps and verify exported conversations

* no-mistakes(review): Restore Calm rows received while active

* no-mistakes(review): Preserve diagnostics during Calm restoration

* no-mistakes(document): Clarify Calm transcript behavior and injection paths

* fix: execute every PR body compliance event (#898)

* fix: execute every PR body compliance event

* no-mistakes(document): Document independent PR compliance events

* fix: exclude operational injections from ahoy boundaries (#899)

* fix: distinguish operational input in ahoy

* no-mistakes(review): Handle legacy Ahoy operational boundaries

* no-mistakes(review): Narrow legacy Ahoy boundaries with live regressions

* no-mistakes(document): Document Ahoy operational marker ownership

* no-mistakes(lint): Suppress intentional literal fixture lint warnings

* fix: canonically classify operational inputs across harnesses (#909)

* fix: type canonical operational inputs

* no-mistakes(document): Correct canonical operational-input documentation ownership

* fix: avoid generic secondmate start acknowledgements (#926)

* fix: avoid generic secondmate acknowledgements

* no-mistakes(document): Document sparse secondmate acknowledgement behavior

* no-mistakes: apply CI fixes

* fix(pi): make calm mode persistent and gapless (#927)

* fix(pi): preserve calm presentation across sessions

* no-mistakes(review): Fix Calm home fallback persistence

* no-mistakes(document): Clarify Calm gapless and export contracts

* no-mistakes: apply CI fixes

* fix(watch): retire merged PR polls after durable notification (#932)

* fix: retire merged PR polls after notification

* no-mistakes(review): Decouple PR retirement recovery from template updates

* no-mistakes(review): Recover pending PR retirements before poll migration

* no-mistakes(document): Document merged PR poll retirement contracts

* fix: refine scout intake and parallel dispatch (#934)

* Clarify intake evidence and overlap handling

* no-mistakes(review): Align scout guard with intake classification

* no-mistakes(document): Clarify scout documentation and intake ownership

* fix(pi): prevent duplicate assistant replies in Calm (#936)

* fix(pi): preserve operational follow-up semantics in Calm

* no-mistakes(document): Correct Calm operational-row visibility documentation

* perf(bin): shrink the ShellCheck source graph (#939)

* perf(lint): shrink shell source graph

* no-mistakes(review): Ensure lint workers terminate fully on cancellation

* no-mistakes(document): Repair stale lint documentation ownership

* fix(pi): remove Calm hidden-block gaps (#942)

* fix(pi): remove Calm hidden-block gaps

* no-mistakes(review): Validate Calm geometry against current viewport

* no-mistakes(review): Synchronize Calm geometry checks with reload completion

* fix: enforce contract boundaries for ask-user findings (#945)

* fix: escalate ask-user contract expansion

* no-mistakes(document): Point project management to authority owner

* docs: prefer direct operational paths (#946)

* fix(pi): hide operational user rows in Calm mode (#948)

* fix(pi): hide Calm operational user rows

* no-mistakes(review): Narrow Calm operational input suppression

* no-mistakes(review): Avoid Calm replay classifier subprocesses

* no-mistakes(document): docs: point Pi verification to Calm owner

* fix: relaunch missing second mates at session start (#950)

* fix(session-start): relaunch missing second mates

* fix(test): detect completed parallel workers

* no-mistakes(review): Isolate session-start recovery test cleanup

* no-mistakes(review): Complete backend-safe secondmate session recovery

* no-mistakes(review): Resolve Zellij task ownership before recovery

* no-mistakes(review): Recover relocated Zellij ghost tabs safely

* no-mistakes(review): Restore conservative Zellij recovery boundary

* no-mistakes(review): Reject malformed tmux recovery targets

* no-mistakes(document): Align secondmate recovery documentation

* no-mistakes: apply CI fixes

* fix(herdr): reclaim resumed task projections after restart (#967)

* fix(herdr): reclaim resumed task projections safely

* no-mistakes(review): Enforce safe Herdr reclaim close boundaries

* no-mistakes(document): docs: clarify Herdr restart projection contract

* Teach Ahoy to surface open decisions (#968)

* Require shipshape routine acknowledgement (#969)

* docs: separate current guidance from verification evidence (#994)

* docs: separate current guides from verification

* no-mistakes(review): Restore Herdr 0.7.5 restart-reclaim verification evidence

* fix: preserve Claude watcher continuity across Stop hooks (#997)

* feat(claude): Stop-owned tokenless watcher continuity via asyncRewake auto-arm

Claude primaries (main home and marked secondmate homes) no longer depend
on the model remembering to re-arm the watcher after each wake. A tracked
Stop asyncRewake hook (bin/fm-claude-stop-autoarm.sh, timeout 28800s)
fires on every turn end, claims one home-scoped single-flight owner,
foregrounds bin/fm-watch-arm.sh inside the hook-owned process tree, and
translates an actionable close or typed watcher failure into exactly one
exit-2 rewake. The hook scopes to genuine primary checkouts, requires the
session lock to be held by its own harness ancestor, stays inert while
AFK owns triage or the home is idle, and hands AFK transitions mid-cycle
to the daemon without rewaking.

The synchronous turn-end guard gains a --claude cooperative mode: it
ignores stop_hook_active (true on every post-continuation stop, which is
what re-opened the 2026-07-21 blind window), waits briefly for a watcher
health proof, a live auto-arm owner claim, or a fresh rewake epoch, and
re-blocks only when the auto-arm genuinely failed to establish - bounded
to 3 consecutive blocks per session, safely below Claude Code's 8-block
override, then a degraded allow with a visible systemMessage. Codex
keeps the previous one-block loop guard byte-identically, and Pi,
OpenCode, and Grok adapters are untouched.

Continuity PreToolUse gate and durable wake queue are preserved; the
gate's recovery guidance now names the Stop-owned re-arm and reserves
manual background arms for auto-arm failure. Claude supervision protocol,
harness-adapters facts, architecture, configuration, and continuity docs
updated; docs/turnend-guard.md records the 2026-07-24 Claude 2.1.218
contract revalidation (tokenless multi-cycle rewake, no-dedup, timeout
process-group kill, 8-block cap, interactive non-stall) and the 2.1.219
product live E2Es.

Regression matrix: hermetic tests cover scope, identity, AFK, need,
single-flight, translation, guard cooperation, budget, and registration;
the new live E2E proves two full tokenless auto-arm rewake cycles with
zero model arm commands; Pi and OpenCode Option B live E2Es pass
unchanged.

* no-mistakes(review): Fix Claude X-mode auto-arm continuity backstop

* no-mistakes(review): Remove unsupported Claude contract-lab verification claims

* no-mistakes(document): Update Claude auto-arm continuity documentation

* fix(herdr): clean stale projections at session start (#996)

* Clean stale Herdr projections at session start

* no-mistakes(document): Document stale Herdr session-start projection cleanup

* no-mistakes(review): Enforce locked exact Herdr projection cleanup

* no-mistakes(review): Fail closed on unverified session lock ownership

* no-mistakes(review): Serialize session lock acquisition atomically

* no-mistakes(document): Align session-start and Herdr cleanup documentation

* no-mistakes(document): Generalize lock-refusal diagnostics

* no-mistakes(lint): Avoid reserved keyword in concurrency test

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* feat(inbox): add the captain's decision and review board generator

bin/fm-inbox-view.sh writes one self-contained HTML board from live fleet
state, so every open captain decision, review-ready pull request and stopped
task is answerable from a single surface instead of arriving one chat
interrupt at a time.

It is a read-only projection in the same shape as fm-fleet-view.sh: it shells
out to fm-fleet-snapshot.sh --json and `tasks-axi show --full`, and writes
nothing but the board file. A test proves state/ and data/ stay byte-identical
across a generation.

Three selection defects the existing aggregated surface has are fixed here.
Decisions are selected on the captain hold alone, because the snapshot's own
captain_actionable flag also requires kind == "captain" and therefore hides
every thread gated with `tasks-axi hold --kind captain`, which is where the
oldest waiting decisions live.
Decision text is read through tasks-axi, because the snapshot's metadata
capture stops at the first comma and silently drops the options from any hold
reason that lists them.
A recorded pull request renders as unverified unless --verify-prs live-checks
it, because locally recorded metadata cannot know a pull request was closed
and a closed one must never read as ready to merge.

Decision cards lead with plain English. An optional captain-private cards file
supplies the plain question, what the captain is actually choosing, where it
came from, firstmate's recommendation, a link to research a product or
service, and a collapsed technical section. An item that is firstmate's own
assumption rather than a choice the captain made is flagged as one. A decision
with no card still renders and says so rather than looking complete.

Answers use the Lavish input contract: native radios plus a free-text note,
with exactly one queued prompt per question on submit. This change delivers
the surface only; regenerating on a cadence, relaying answers back, and any
escalation-routing change remain separate captain decisions.

* feat(inbox): free-form answers, discuss path, reliable delivery, overflow fix

Fold in the captain's hard requirements from live use of the board.

Free-form answers are now first-class. A card's predefined options are
optional quick-picks with a clear-selection reset; the answer submits with
just free text and no option selected. Previously the submit required picking
an offered option, so a genuine free-form answer could not be sent at all.

Each card gains a discuss path that sends a question back (DISCUSS <id>: ...)
instead of an answer (DECISION <id>: ...), so a decision can be clarified
rather than forced.

Delivery is made reliable end to end. bin/fm-inbox-serve.sh is one operator
command that regenerates the board, arms the answer relay, serves it on the
Tailscale address, and verifies the link. bin/fm-inbox-arm.sh writes and
registers state/inbox.check.sh, a bounded lavish poll bound by
fm-check-register, so firstmate's supervision cycle relays answers on its
normal check cadence without anyone remembering to poll. The relay fails
closed: when the board is not served the poll errors fast and it stays silent.
Submitting also sends immediately with a visible confirmation, closing the
window where an answer looked silently eaten.

Long titles and ids now wrap instead of overflowing horizontally, which
Lavish's own layout audit flags as an error. No-project items get readable
area names derived from their origin or id instead of a generic badge.

Behavior is covered by tests/fm-inbox-view.test.sh (generator, read-only,
free-form, discuss, immediate send, area names, wrapping) and
tests/fm-inbox-arm.test.sh (the relay is a valid registered fail-closed
check, silent while unserved, rejected after tampering). docs/inbox-board.md
records the design and verification evidence.

* no-mistakes(review): Fix inbox relay safety and PR verification

* no-mistakes(review): Gate inbox relay before polling

* no-mistakes(document): Align inbox board docs

* no-mistakes: apply CI fixes

---------

Co-authored-by: Kun Chen <[email protected]>
rega10 added a commit to rega10/firstmate that referenced this pull request Jul 27, 2026
* fix(herdr): group projected children beneath owning parents (kunchenguid#821)

* feat(herdr): correct all-home child presentation topology

Inherit the presentation opt-in to secondmate homes, label new projected
spaces with the approved corner format, insert each child under its owning
parent under one session-scoped lock, and keep flat non-destructive fallback.

* no-mistakes(review): Exclude secondmates from Herdr presentation projection

* no-mistakes(review): Harden shared Herdr locks and ambiguous child ordering

* no-mistakes(review): Use adjacency-only Herdr child ownership

* no-mistakes(review): Reject foreign legacy projections safely

* no-mistakes(review): Validate Herdr session sockets before projection

* no-mistakes(test): Fix Herdr teardown fixture session socket metadata

* fix(herdr): canonicalize presentation lock socket paths

Always resolve the session socket parent directory so symlink parents
such as /tmp -> /private/tmp cannot split the shared cross-home lock
identity. Refuse relative socket paths. Clarify lock-unavailable warnings.

* no-mistakes(test): Fix Bash-compatible GitLab merge request URL parsing

* no-mistakes(document): Document all-home Herdr child topology

* no-mistakes(lint): Quote fallback provenance string for ShellCheck

* fix: keep local no-mistakes tests intent-targeted (kunchenguid#823)

* fix(no-mistakes): drop full-suite local Test override

Local no-mistakes Test is intent-targeted; CI Behavior keeps the broad
tests/*.test.sh suite. Keep commands.lint on bin/fm-lint.sh and add a
focused contract test so the override cannot silently return.

* no-mistakes(lint): Make CI contract assertion ShellCheck-clean

* feat: add canonical timed test runner (kunchenguid#825)

* feat(test): add canonical timed suite runner and honest CI timeout

Introduce bin/fm-test-run.sh as the single serial owner for selecting
one script, a family, a conservative changed-file set, or the explicit
complete suite, with per-script timing markers and a JSON artifact.
Wire CI Behavior through the runner, raise the hang-tripwire timeout to
25 minutes, and document entry points without restoring a full-suite
local no-mistakes Test command.

* no-mistakes(review): Captain: fix changed selection and empty summaries

* no-mistakes(review): Captain: fail closed on unmapped changed sources

* no-mistakes(document): Document canonical timed test entry points

* fix: surface main inventory gaps in Bearings (kunchenguid#830)

* fix: disclose main-home orphan and unstructured inventory gaps

Main Bearings could report an empty fleet while structured in-flight rows
lacked meta or current backlog rows were free-form. Emit main_inventory from
the fleet snapshot, map it into Bearings omitted surfaces and a Charted Next
gate, and keep meta as the only live Underway source.

* no-mistakes(document): Document Bearings inventory-integrity projection

* no-mistakes: apply CI fixes

* feat: add bounded concurrent test isolation proof (kunchenguid#832)

* feat: add concurrent test isolation proof for Phase 2

Prove an audited portable candidate set passes under concurrent
workers with private mode-0700 temp roots, without enabling
production CI sharding or fm-test-run --jobs.

* no-mistakes(review): Pin isolation proof to audited candidate manifest

* feat: guard against missed secondmate reports (kunchenguid#834)

* feat(secondmate): parent-owned guards for missed status reports

Marked parent-to-secondmate requests now create a durable pending-reply
expectation with a privacy-safe correlation id before delivery. Transport
success never resolves it; only a correlated parent status or document
pointer does. After a completed turn with no report, the parent sends one
recovery repost and escalates once if that turn is also missed, without
scraping the secondmate conversation or looping.

* no-mistakes(review): Deduplicate wrong-home pending-reply sightings

* no-mistakes(review): Harden pending-reply recovery and escalation guards

* no-mistakes(review): Bound pending-reply backend polling

* no-mistakes(review): Cache pending-reply status scans

* no-mistakes(review): Protect undelivered pending-reply records from scans

* no-mistakes(review): Close pending-reply delivery durability gaps

* no-mistakes(review): Separate pending-reply transport outcomes

* no-mistakes(review): Escalate stalled pending-reply deliveries once

* no-mistakes(review): Resolve attempted deliveries from correlated reports

* no-mistakes(review): Resolve late reports after delivery escalation

* no-mistakes(document): Document pending-reply grace and ownership

* no-mistakes(lint): Silence intentional pending-reply test fixture lint warnings

* feat: require pinned real-Herdr CI coverage (kunchenguid#838)

* feat: add required pinned Herdr CI lane

Install exact Herdr 0.7.4 and Treehouse 2.0.1 with official assets and
SHA-256 pins, run the real-herdr-gated family serially through
fm-test-run with hard-fail on herdr-not-found, and keep portable
Behavior free of claimed Herdr coverage.

* no-mistakes(document): Consolidate real-Herdr CI documentation ownership

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* feat: shard portable tests and add bounded local parallelism (kunchenguid#841)

* feat: shard portable CI tests after isolation proof

Balance the Phase 2 proven-isolated set into two LPT portable parallel
lanes from Phase 1 timing evidence, keep stateful work in a required
portable serial lane, exclude real Herdr to its dedicated required lane,
and prove complete inventory coverage with a deterministic guard.
Add bounded local --jobs only for the proven set, per-lane timing plus
aggregate artifacts, and reduce the interim portable hang tripwire now
that the serial remainder owns the long wall-clock path.

* no-mistakes(review): Captain, fix CI contracts and completion-order worker scheduling

* no-mistakes(review): Captain, preserve stderr gate-skip detection in parallel tests

* no-mistakes(document): Document portable sharding and timing aggregation

* no-mistakes: apply CI fixes

* fix: block primary-session delegation outside the fleet (kunchenguid#854)

* feat: fence primary-session delegation outside the fleet

A firstmate primary that delegates through Claude Code's built-in
delegation tools creates work with no state/<id>.meta. Because
fm-supervision-lib.sh counts *.meta and fm-turnend-guard.sh exits
silently at zero, such work does not merely go unsupervised: it makes
the whole guard stack structurally inert, and it dies with the primary
session. On 2026-07-22 that cost two workers mid-flight and left
supervision down for 73 minutes unnoticed.

Layer 1, the primary fix: a permissions.deny list in
.claude/settings.json removes the 18 delegation, scheduling, worktree,
and task-tracking tools from the model's schema, so they are never
offered. This is removal rather than interception, so there is no call
to intercept and no fail-open path. The list is flat and in one file so
its width stays reviewable; the captain owns that width.

Layer 2, bin/fm-subagent-pretool-check.sh: a deny list is fail-open
against tools that do not exist yet, and permissions.allow is a
pre-approval list rather than an availability list, so there is no
fail-closed allowlist to use instead. This backstop classifies the tool
NAME by shape rather than against a fixed list, so a delegation tool
that ships before the deny list is updated is still refused. It excludes
mcp__* names and observe-or-stop operations, scopes itself to a genuine
primary home via the shared fm_primary_scope_matches predicate so a
crewmate's task worktree is unaffected, and offers one deliberate
FM_ALLOW_SUBAGENT=1 escape hatch that must be set at launch.

Verified live against Claude Code 2.1.217, including a deny-key A/B with
a nonsense-name control, layer 2 denying an un-denied Workflow call, the
same call allowed in a linked worktree, and the escape hatch. Corrects a
prior finding: both Task and Agent work as deny keys, so both are
pinned. Codex 0.144.1 verified to expose no delegation tool; grok,
opencode, and pi are inspected and documented as not wired because those
binaries are absent from this host and the repo requires live validation
before trusting a harness hook. Evidence in docs/subagent-guard.md.

* no-mistakes(review): Ship scoped Claude delegation guard

* no-mistakes(test): Ship Claude delegation deny list

* no-mistakes(document): Clarify PreToolUse guard ownership

* no-mistakes(lint): Keep Claude deny list local

* fix: install tasks-axi in portable CI shards (kunchenguid#866)

Reproduction: portable-parallel-2 completed successfully without tasks-axi while fm-decision-hold-lifecycle emitted a gate skip in 30 ms. The pre-shard lane installed tasks-axi and exercised the test fully. Installing tasks-axi is the smallest counterfactual and makes the representative shard execute the test with gate_skip=false in about 20 seconds. Both parallel jobs receive symmetric setup, while the exact 91-test inventory and coverage guard remain unchanged.

* feat(bin): make dispatch profiles quota aware (kunchenguid#867)

* feat: make dispatch profiles quota aware

* no-mistakes(review): Fix quota window and Grok product scoping

* no-mistakes(document): Document implicit quota-aware dispatch accurately

* Add built-in ahoy recap skill (kunchenguid#873)

* fix: preserve trustworthy Bearings data in partial snapshots (kunchenguid#875)

* fix: preserve mixed Bearings projections

* no-mistakes(review): Enforce strict invalidity precedence for partial snapshots

* no-mistakes(review): Enforce ownership for unknown child metadata

* no-mistakes(document): Document partial structured Bearings projections

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* feat(pi): add session-local calm mode (kunchenguid#884)

* Add session-local Pi calm mode

* no-mistakes(review): Preserve Pi HTML exports during calm mode

* no-mistakes(review): Preserve calm exports across submit bindings and share

* no-mistakes(document): Document calm-mode feasibility across supported harnesses

* fix(pi): prevent redundant watcher re-arms (kunchenguid#885)

* fix(pi): limit watcher arm tool to recovery

* no-mistakes(review): Strengthen Pi live re-arm regression coverage

* no-mistakes(document): Document Pi first-cycle and recovery-only watcher arming

* fix(pi): clean up Calm transcript rendering (kunchenguid#895)

* fix(pi): clean up Calm transcript rendering

* no-mistakes(review): Captain, preserve Calm exports and classify Pi launch briefs

* no-mistakes(review): Captain, eliminate Calm gaps and verify exported conversations

* no-mistakes(review): Restore Calm rows received while active

* no-mistakes(review): Preserve diagnostics during Calm restoration

* no-mistakes(document): Clarify Calm transcript behavior and injection paths

* fix: execute every PR body compliance event (kunchenguid#898)

* fix: execute every PR body compliance event

* no-mistakes(document): Document independent PR compliance events

* fix: exclude operational injections from ahoy boundaries (kunchenguid#899)

* fix: distinguish operational input in ahoy

* no-mistakes(review): Handle legacy Ahoy operational boundaries

* no-mistakes(review): Narrow legacy Ahoy boundaries with live regressions

* no-mistakes(document): Document Ahoy operational marker ownership

* no-mistakes(lint): Suppress intentional literal fixture lint warnings

* fix: canonically classify operational inputs across harnesses (kunchenguid#909)

* fix: type canonical operational inputs

* no-mistakes(document): Correct canonical operational-input documentation ownership

* fix: avoid generic secondmate start acknowledgements (kunchenguid#926)

* fix: avoid generic secondmate acknowledgements

* no-mistakes(document): Document sparse secondmate acknowledgement behavior

* no-mistakes: apply CI fixes

* fix(pi): make calm mode persistent and gapless (kunchenguid#927)

* fix(pi): preserve calm presentation across sessions

* no-mistakes(review): Fix Calm home fallback persistence

* no-mistakes(document): Clarify Calm gapless and export contracts

* no-mistakes: apply CI fixes

* fix(watch): retire merged PR polls after durable notification (kunchenguid#932)

* fix: retire merged PR polls after notification

* no-mistakes(review): Decouple PR retirement recovery from template updates

* no-mistakes(review): Recover pending PR retirements before poll migration

* no-mistakes(document): Document merged PR poll retirement contracts

* fix: refine scout intake and parallel dispatch (kunchenguid#934)

* Clarify intake evidence and overlap handling

* no-mistakes(review): Align scout guard with intake classification

* no-mistakes(document): Clarify scout documentation and intake ownership

* fix(pi): prevent duplicate assistant replies in Calm (kunchenguid#936)

* fix(pi): preserve operational follow-up semantics in Calm

* no-mistakes(document): Correct Calm operational-row visibility documentation

* perf(bin): shrink the ShellCheck source graph (kunchenguid#939)

* perf(lint): shrink shell source graph

* no-mistakes(review): Ensure lint workers terminate fully on cancellation

* no-mistakes(document): Repair stale lint documentation ownership

* fix(pi): remove Calm hidden-block gaps (kunchenguid#942)

* fix(pi): remove Calm hidden-block gaps

* no-mistakes(review): Validate Calm geometry against current viewport

* no-mistakes(review): Synchronize Calm geometry checks with reload completion

* fix: enforce contract boundaries for ask-user findings (kunchenguid#945)

* fix: escalate ask-user contract expansion

* no-mistakes(document): Point project management to authority owner

* docs: prefer direct operational paths (kunchenguid#946)

* fix(pi): hide operational user rows in Calm mode (kunchenguid#948)

* fix(pi): hide Calm operational user rows

* no-mistakes(review): Narrow Calm operational input suppression

* no-mistakes(review): Avoid Calm replay classifier subprocesses

* no-mistakes(document): docs: point Pi verification to Calm owner

* fix: relaunch missing second mates at session start (kunchenguid#950)

* fix(session-start): relaunch missing second mates

* fix(test): detect completed parallel workers

* no-mistakes(review): Isolate session-start recovery test cleanup

* no-mistakes(review): Complete backend-safe secondmate session recovery

* no-mistakes(review): Resolve Zellij task ownership before recovery

* no-mistakes(review): Recover relocated Zellij ghost tabs safely

* no-mistakes(review): Restore conservative Zellij recovery boundary

* no-mistakes(review): Reject malformed tmux recovery targets

* no-mistakes(document): Align secondmate recovery documentation

* no-mistakes: apply CI fixes

* fix(herdr): reclaim resumed task projections after restart (kunchenguid#967)

* fix(herdr): reclaim resumed task projections safely

* no-mistakes(review): Enforce safe Herdr reclaim close boundaries

* no-mistakes(document): docs: clarify Herdr restart projection contract

* Teach Ahoy to surface open decisions (kunchenguid#968)

* Require shipshape routine acknowledgement (kunchenguid#969)

* docs: separate current guidance from verification evidence (kunchenguid#994)

* docs: separate current guides from verification

* no-mistakes(review): Restore Herdr 0.7.5 restart-reclaim verification evidence

* fix: preserve Claude watcher continuity across Stop hooks (kunchenguid#997)

* feat(claude): Stop-owned tokenless watcher continuity via asyncRewake auto-arm

Claude primaries (main home and marked secondmate homes) no longer depend
on the model remembering to re-arm the watcher after each wake. A tracked
Stop asyncRewake hook (bin/fm-claude-stop-autoarm.sh, timeout 28800s)
fires on every turn end, claims one home-scoped single-flight owner,
foregrounds bin/fm-watch-arm.sh inside the hook-owned process tree, and
translates an actionable close or typed watcher failure into exactly one
exit-2 rewake. The hook scopes to genuine primary checkouts, requires the
session lock to be held by its own harness ancestor, stays inert while
AFK owns triage or the home is idle, and hands AFK transitions mid-cycle
to the daemon without rewaking.

The synchronous turn-end guard gains a --claude cooperative mode: it
ignores stop_hook_active (true on every post-continuation stop, which is
what re-opened the 2026-07-21 blind window), waits briefly for a watcher
health proof, a live auto-arm owner claim, or a fresh rewake epoch, and
re-blocks only when the auto-arm genuinely failed to establish - bounded
to 3 consecutive blocks per session, safely below Claude Code's 8-block
override, then a degraded allow with a visible systemMessage. Codex
keeps the previous one-block loop guard byte-identically, and Pi,
OpenCode, and Grok adapters are untouched.

Continuity PreToolUse gate and durable wake queue are preserved; the
gate's recovery guidance now names the Stop-owned re-arm and reserves
manual background arms for auto-arm failure. Claude supervision protocol,
harness-adapters facts, architecture, configuration, and continuity docs
updated; docs/turnend-guard.md records the 2026-07-24 Claude 2.1.218
contract revalidation (tokenless multi-cycle rewake, no-dedup, timeout
process-group kill, 8-block cap, interactive non-stall) and the 2.1.219
product live E2Es.

Regression matrix: hermetic tests cover scope, identity, AFK, need,
single-flight, translation, guard cooperation, budget, and registration;
the new live E2E proves two full tokenless auto-arm rewake cycles with
zero model arm commands; Pi and OpenCode Option B live E2Es pass
unchanged.

* no-mistakes(review): Fix Claude X-mode auto-arm continuity backstop

* no-mistakes(review): Remove unsupported Claude contract-lab verification claims

* no-mistakes(document): Update Claude auto-arm continuity documentation

* fix(herdr): clean stale projections at session start (kunchenguid#996)

* Clean stale Herdr projections at session start

* no-mistakes(document): Document stale Herdr session-start projection cleanup

* no-mistakes(review): Enforce locked exact Herdr projection cleanup

* no-mistakes(review): Fail closed on unverified session lock ownership

* no-mistakes(review): Serialize session lock acquisition atomically

* no-mistakes(document): Align session-start and Herdr cleanup documentation

* no-mistakes(document): Generalize lock-refusal diagnostics

* no-mistakes(lint): Avoid reserved keyword in concurrency test

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* fix: recover Claude supervision without watcher-status gate (kunchenguid#1001)

* fix: recover Claude supervision at session start

* fix: remove Claude watcher-status command gate

* no-mistakes(document): docs: remove stale continuity gate references

* fix: make quota-aware profile selection agent-owned (kunchenguid#1018)

* Replace quota dispatch selector instructions

* no-mistakes(review): Align bootstrap docs with agent-owned dispatch selection

* fix(bin): remove vestigial dispatch selector (kunchenguid#1026)

* remove vestigial dispatch selector

* no-mistakes(review): Synchronize isolation proof and portable shard evidence

* no-mistakes(review): Correct shard history and proof archive date

* no-mistakes(review): Remove reintroduced selector documentation reference

* no-mistakes(document): Remove stale dispatch strategy documentation

* docs(agents): drop superseded interim quota-window rule (kunchenguid#1039)

quota-axi 0.1.13 emits schemaVersion 2 with a quotaSemantics object per
provider, so the successor named in the interim rule has landed and the
rule's own removal condition is satisfied.

Keep the ownership clause so quota-axi remains the single owner of how
model or product windows relate to bounding account windows, and drop
the interim weakest-headroom instruction. The unknown-semantics case is
already covered by the existing requirement to stop and report a
candidate whose applicable quota data or interpretation cannot be
established.

Drop the matching assertion phrase from
tests/fm-instruction-owners.test.sh; the retained ownership phrase still
asserts.

* fix(tmux): scope busy detection and recognize current Claude turns (kunchenguid#1049)

* fix(tmux): scope Claude busy detection by harness

* no-mistakes(review): Separate verified and fallback busy signatures

* no-mistakes(test): Scope busy signatures to supplied harnesses

* no-mistakes(document): Document harness-scoped busy detection

* feat: add verified Kimi crewmate adapter (kunchenguid#1047)

* Add verified Kimi crewmate harness adapter

* no-mistakes(review): Scope Kimi moon detection to spinner lines

* no-mistakes(review): Match only complete Kimi spinner rows

* no-mistakes(review): Resolve Kimi binary portably before pane creation

* no-mistakes(document): Align Kimi adapter documentation

* no-mistakes(lint): Suppress false-positive ShellCheck warning for sourced watcher override

* Fix Kimi busy spinner detection

* no-mistakes(review): Recognize Kimi session-lock ancestry and holders

* no-mistakes(review): Scope pending-reply Kimi busy detection by harness

* no-mistakes(document): Correct Kimi spinner capture documentation

* no-mistakes(document): Clarify optional Kimi spinner whitespace

* no-mistakes(lint): Silence intentional pending-reply test stub warnings

* test: align rebased Kimi busy fixtures

* no-mistakes: apply CI fixes

* Reconcile Kimi busy detection after per-harness scoping

* no-mistakes(review): Clarify observed Kimi spinner whitespace contract

* no-mistakes(document): Clarify Kimi harness documentation

* fix: harden Kimi submission and spinner matching (kunchenguid#1058)

* fix kimi pointer submission and spinner conformance

* no-mistakes(review): Preserve Kimi submit target ownership guard

* feat(bin): add guarded Kimi turn-end wake (kunchenguid#1059)

* Add guarded Kimi turn-end hook

* no-mistakes(review): Require jq before installing Kimi turn-end hook

* no-mistakes(review): Expose jq inside isolated Kimi test fixtures

* no-mistakes(review): Preserve Kimi config boundaries during hook removal

* no-mistakes(review): Document Kimi removal newline safeguard

* no-mistakes(document): Document Kimi shared-home preservation

* fix(tmux): classify bordered composers across all rows (kunchenguid#1066)

* Fix structural tmux composer reading

* Verify Calm compatibility with Pi 0.82

* no-mistakes(review): Harden structural composer classification boundaries

* no-mistakes(review): Refresh composer and Kimi regression fixtures

* no-mistakes(review): Fail closed on unbounded composer edges

* no-mistakes(review): Enforce aligned composer geometry safely

* no-mistakes(review): Make composer ambiguity locale-safe

* no-mistakes(review): Preserve ambiguity through composer submission

* no-mistakes(review): Carry composer proof through retries

* no-mistakes(document): Document structural tmux composer delivery guarantees

* no-mistakes: apply CI fixes

* no-mistakes(review): Captain, serialize Herdr teardown across homes

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: ItsFlow <[email protected]>
Co-authored-by: Rene Garza Jr <[email protected]>
samchu8 added a commit to SABS-Technology/firstmate that referenced this pull request Jul 28, 2026