Skip to content

Fix primary assistance session rebinding - #6536

Closed
huynhtandat223 wants to merge 87 commits into
kunchenguid:mainfrom
huynhtandat223:fm/fm-assist-binding-cursor
Closed

huynhtandat223 wants to merge 87 commits into
kunchenguid:mainfrom
huynhtandat223:fm/fm-assist-binding-cursor

Conversation

@huynhtandat223

Copy link
Copy Markdown

Closes #92

Review brief

The SessionStart hook now updates the primary assistance session only when this session owns the session lock. The assistance cursor now stays at its highest committed line when settled turns are reconciled after a history rebind. Check the lock-refusal case in tests/fm-sessionstart-nudge.test.sh and the rebind recovery case in tests/fm-orchestrator-assistance.test.sh. The change affects startup session identity and assistance recovery; the primary lock-owner publish path still needs confirmation in the captain's live home after merge.

Proof receipts

  • tests/fm-sessionstart-nudge.test.sh — passed; lock-refused SessionStart preserved both assistance records byte-for-byte.
  • tests/fm-orchestrator-assistance.test.sh — passed; switching to another history and back preserved cursor 1835 and removed the already-settled pending turn.
  • bin/fm-lint.sh — passed; changed-file ShellCheck and workflow checks.
  • git diff --check — passed.
  • The initial SessionStart fixture was updated to exercise a live foreign lock owner. The owner-path check remains in the existing session-start tests; this change's owner publish path still needs confirmation in the live primary home after merge.
  • Head: 41f8bd9a4bf3eb535c695d0ea0edda46b9e22689.

huynhtandat223 and others added 30 commits August 8, 2026 00:53
* fix(herdr): admit agy plain-ASCII '> ' composer via native identity

agy's interactive composer draws a bare ASCII "> " prompt with no side
border and no agent-specific glyph, so its empty-composer row is
byte-for-byte the dead-shell prompt the shared classifier in
bin/fm-composer-lib.sh deliberately refuses as unknown (never empty).
Under herdr that made a live-empty agy composer fall to unknown, unlike
bordered/agent-glyph shapes, so away-mode injection never fired.

Close the gap inside the herdr adapter only, mirroring the Pi separator
composer: locate the bottom-most "> " row structurally and admit it as
a real composer solely when native `agent get` corroborates the target
is agy and reports idle/done/blocked. A working agy, a non-agy or
unregistered agent, or an unreadable identity keeps the bare row unknown,
so the shared dead-shell rule is not weakened. Identity is fetched at
most once per call, shared with the Pi block.

* feat: add agy (Antigravity CLI) harness adapter

Wire Google Antigravity CLI (agy 1.1.5, Gemini-backed) as a crewmate harness.

- fm-harness.sh: detect agy via ANTIGRAVITY_AGENT=1 env marker plus
  agy/antigravity process-ancestry match.
- fm-spawn.sh: interactive launch template
  (agy --dangerously-skip-permissions -i "$(cat brief)"); add agy to the
  model flag (--model), effort flag (--effort, ceiling high), and the
  accepted-harness lists.
- fm-tmux-lib.sh / fm-watch.sh: add busy signature "esc to cancel" to the
  default busy regex (daemon inherits it).
- harness-adapters SKILL.md: full agy knowledge section, launch-profile-axes
  row, and no-mistakes invocation note.
- fm-session-start.test.sh: drop ANTIGRAVITY_AGENT in detect_own so the
  suite does not leak the marker.

Verified empirically on agy 1.1.5: env marker, interactive cwd inheritance,
--dangerously-skip-permissions autonomy, busy/idle footer, first-run trust
dialog. Turn-end hook and primary-session guard are NOT yet verified, so agy
is crewmate-only for now (documented in the skill).

* fix: read live pi sessions as live in session-lock liveness

fm_harness_pid_alive joined `basename comm` and `ps -o args=` into one
line before matching FM_HARNESS_RE. That broke every anchored
alternative: a live pi harness joins to "pi pi", which `^pi$` cannot
match, so each live pi session read as stale. bin/fm-lock.sh then let a
second session take the primary's lock, and bin/fm-claude-stop-autoarm.sh
reclaimed a lock whose owner was alive - a whole-home mutual-exclusion
failure that can double-dispatch or double-teardown.

Split the check the way fm_harness_ancestry_pid already does it: match
the basename of comm on its own line, and consult args only when comm is
a bare interpreter (node/python). FM_HARNESS_RE is unchanged, so `^pi$`
stays anchored and pip/pipx/paths containing "pi" keep reading as
not-a-harness.

tests/fm-session-lock-liveness.test.sh covers both directions against
real spawned processes (no fake ps) and fails on the pre-fix library.

* docs: record the gh-axi repo-resolution trap and the turn-boundary stall pattern

* fix: verify pruned resolved captain holds from the done archive

tasks-axi's Done-retention prune archives resolved captain holds out of the
live backlog (closing the originating task auto-prunes), and the completion
gate could then never verify them again: teardown refused, complete failed
with 'absent from data/backlog.md', and the task deadlocked with no
non-bypass exit (hit live with psak-compose-bringup on 2026-07-26).

Prune archives rather than deletes, so the durable resolution record
survives byte-identically in the markdown backend's archive file. Every
read that accepts a Done hold now falls back to that archive: complete,
verify, identical resolve retries, and reopen refusal are order-independent
with respect to pruning. An archived row without the resolution record
still fails the gate, and an active hold is never read from the archive,
so the safety boundary is unchanged - the gate verifies the same evidence
it always required, from where the backend moved it.

Two regression tests reproduce the deadlock sequence end-to-end and prove
the fail-closed path for an archived hold with no resolution record.

* docs: add the paired driver-and-navigator protocol as an agent-only skill

High-blast-radius ship work now runs as a pair launched together, exchanging
directly through a durable shared file rather than through firstmate, which was
the latency bottleneck when it supervises several threads at once. The protocol
body lives in the new agent-only `paired-review` skill; AGENTS.md gains only the
trigger, the narrowed communication rule, and the delivery-path exception.

The second worker is a navigator, not a reviewer: three of the four gates have
no diff to look at, and an agent told it reviews will idle until one exists,
which defeats the design. The plan gate is the cheap one - a wrong-layer
direction error is visible from a file-level plan in about two minutes and
invisible at PR time under hours of work built on it.

The pair may never settle a contract or scope change, anything destructive,
irreversible, or security-sensitive, or a disagreement surviving its one round
trip; removing firstmate from the exchange moves no approval authority to the
crewmates.

Also make the scope and seam statement a default section of every ship and
scout brief, since the direction error that motivated this protocol happened on
a brief that never named the module owning the code.

* docs: exclude diagnosis from pairing and give navigators four structural questions

Three rules the paired-review protocol did not carry, plus the rule that
keeps skill changes written against the skill-writing guide.

A diagnosis is not paired work. Pairing applies to implementation work; a
bug, regression, or crash-loop takes the diagnose-then-fix shape, one
worker following the diagnosing-bugs skill by absolute path. Until a root
cause exists there is no "where" for a navigator to hold a view about,
and the risk a bug carries is a wrong root cause rather than a wrong
layer, so sequence guards it where parallelism cannot.

The root-cause gate: firstmate judges the root cause before any fix
action. Confident, it authorises the fix and reports; otherwise it
escalates and waits. The root-cause document's own standard is the
confidence test. Destructive, irreversible, security-sensitive, and
contract-expanding fixes still go to the captain regardless.

Every navigator brief carries four fixed structural questions alongside
its task-specific checks: was the stated reason delivered, where did the
coupling go, does this add another instance of a shape the repo has been
burned by, and what did the brief not specify that the implementation had
to decide anyway. Each keeps its reason, because a checklist cannot reach
the destination - a navigator is pointed at a diff, and a diff shows what
changed, never whether the change moves toward where the work is going.

firstmate-coding-guidelines gains one requirement: a skill change begins
by loading writing-great-skills and is written against it.

AGENTS.md changes are two edited trigger lines and no new lines; the
rules themselves live in the skills.

* docs: add program orchestration skill

* docs: pin the paired navigator and state paired review's ownership boundary

Replace the paired-review default-routing guidance with a deterministic
navigator rule: every paired navigator runs on pi with the model
cx/gpt-5.6-terra, and only an explicit per-task captain choice of another
navigator runtime or model replaces it. Ordinary dispatch resolution keeps
owning the concrete launch mechanics and carries the pin through instead of
substituting a best-fit alternative.

State the ownership boundary in the same file: paired review is a universal
implementation-task execution protocol owned by whichever firstmate owns the
task, so a standalone paired task needs no persistent orchestrator, while a
program orchestrator dispatches the same protocol unchanged.

Drop the reroute-to-claude clause under the handed-out-skill limitation, which
would otherwise silently replace the pinned navigator runtime.

* feat(skills): add the captain-invoked planner session

A planner session is one temporary worker the captain talks to directly.
Firstmate opens it, points it at a captain-defined project, scope, and
planning question, then leaves the conversation and monitors only whether
the session is alive, waiting, finished, or failed.

The planner investigates before it asks anything, reconstructing both what
the code does today and where the project's accepted decisions say it is
going, and surfaces every conflict between them instead of quietly choosing.
It reads tests as evidence and runs nothing. It then grills the captain one
question at a time, each question carrying its recommended answer and each
prescriptive choice carrying both the simplest workable and the best-practice
case. It may not produce a plan until the captain opens the crystallize gate,
after which it publishes a spec or dependency-aware tickets through the
project's own established conventions. Planning never authorizes
implementation.

Two artifact contracts travel downstream, each with one owner:

- The scope envelope carries the accepted boundary at spec level and per
  ticket, reusing bin/fm-brief.sh's existing scope and seam vocabulary plus
  the two fields a brief cannot carry before the target is chosen.
- The test contract carries acceptance intent, not executable test code, and
  the captain approves it together with scope.

planner owns those artifact fields. program-orchestration owns consuming
them: preserve provenance, revalidate, narrow per worker, never widen,
escalate a stale envelope. bin/fm-brief.sh keeps the final worker statement
and paired-review keeps sharing it with the driver and navigator, plus the
navigator's plan-gate challenge to the approved test contract.

The planning disciplines are vendored from mattpocock/skills at 2ab9580 with
the MIT license and a provenance record, adapted only in paths, tracker
assumptions, and delegation wording. No bundled file is named SKILL.md, so
the bundle stays off every harness's skill index and costs no context; it
also cannot silently clobber a captain's own locally installed copy, which
git overwrites without a conflict on fast-forward when the install path is
locally excluded.

Launch reuses the ordinary brief, spawn, and scout-report mechanics with no
new runtime: pi cx/gpt-5.6-sol at high effort by default, claude
claude-opus-5 when explicitly selected.

Also fixes fm-doc-audience-check.sh treating markdown links inside fenced
code blocks as navigation targets, which a vendored example listing exposed.

* feat(skills): give the navigator a question form and the decision history

A navigator could only assert findings, so a question had to be dressed as a
defect or stay silent, and nothing systematically told it what had already been
decided. One program's navigator invented an undeclared Q entry to work around
exactly this, and another raised a cross-ticket scope question as a finding,
forcing the driver to adjudicate something it had no authority over.

paired-review gains an evidence-backed Q<k> form beside N<k>, on the same one
round trip but with no forced accepted/rejected verdict. The owning firstmate
answers by default and answers it itself, escalating upward only when it lacks
the authority or the knowledge; the driver answers only its own implementation
choices. Navigator briefs carry the decisions bearing on the ticket where a
record exists, and the skill now states that cross-package and whole-solution
direction sits outside one navigator's field of view.

program-orchestration takes the matching duties: maintaining the program's
cross-ticket decision record, handing the bearing decisions to both halves of
every dispatched pair, and holding direction across tickets.

N semantics and the four structural questions are unchanged, and no fifth
question was added. Both briefs are written at dispatch, so this reaches the
next dispatch and leaves a pair already under way on the protocol it launched
with.

* fix(skills): state the Q id discipline the N form already carries

The Q form said a question runs "its own sequence" but never said that
sequence is sequential and never reused, so the identifier rule was
checkable for N and not for Q. Match the N wording.

* fix(herdr): place the lab --session ahead of any -- separator

fm_herdr_lab_raw appended `--session <name>` to the end of the herdr argv.
`--session` is a herdr global option, and `herdr agent start <name> ... -- <argv...>`
hands every token after `--` to the inner command, so for any subcommand with a
separator the flag never reached herdr: the call silently ran against whatever
session herdr resolved by default, and the inner command received two junk
arguments. The reported repro, `agent start envcheck -- bash`, executed as
`bash --session fm-lab-...` and the pane died immediately.

The confirmed hypothesis is argument placement, not content. Placement was
inherited from fm_backend_herdr_cli, whose comment records that leading position
was already verified to work and that trailing was chosen only to keep call-site
diffs append-only; the blind spot in that choice is the `--` separator.

Every rejection rule is unaffected: the caller-supplied --session scan, the
leading-option refusal, the lifecycle and server refusals, and the fresh
refuse-default checks all run in fm_herdr_lab_cli on the caller's arguments
before fm_herdr_lab_raw assembles the herdr argv.

The existing behavior test asserted the trailing position as the contract, so the
suite was green on the defect; its assertions are re-pointed, and a new case
records the herdr argv token by token and asserts the session pair leads and
never lands past a `--`, with the inner command passed through untouched.

The identical latent pattern in fm_backend_herdr_cli is deliberately out of scope
here; no current backend call site uses a `--` separator.

* feat(skills): add the captain-invoked orchestrator session

Open a long-running programme orchestrator the captain talks to directly,
driving an already-authorized spec, ticket set, or GitHub issues to
completion through workers the session dispatches itself.

The skill splits across the branch boundary it actually has: firstmate
reads SKILL.md to open the session, and only the session reads
CONTRACT.md, so the judgment written for the orchestrator costs
firstmate a pointer rather than a context load. program-orchestration
keeps ownership of custody, routing, host ramp, envelope consumption,
and handoff; both files point at it rather than restating it.

AGENTS.md gains the third direct-conversation exception and one
deliverable-classification bullet. The planner test's closed-exception
assertion moves to the new count rather than dropping the invariant.

* fix: reconcile adapter and documentation replay conflicts
agy's interactive composer draws a bare ASCII "> " prompt with no side
border and no agent-specific glyph, so its empty-composer row is
byte-for-byte the dead-shell prompt the shared classifier in
bin/fm-composer-lib.sh deliberately refuses as unknown (never empty).
Under herdr that made a live-empty agy composer fall to unknown, unlike
bordered/agent-glyph shapes, so away-mode injection never fired.

Close the gap inside the herdr adapter only, mirroring the Pi separator
composer: locate the bottom-most "> " row structurally and admit it as
a real composer solely when native `agent get` corroborates the target
is agy and reports idle/done/blocked. A working agy, a non-agy or
unregistered agent, or an unreadable identity keeps the bare row unknown,
so the shared dead-shell rule is not weakened. Identity is fetched at
most once per call, shared with the Pi block.
Wire Google Antigravity CLI (agy 1.1.5, Gemini-backed) as a crewmate harness.

- fm-harness.sh: detect agy via ANTIGRAVITY_AGENT=1 env marker plus
  agy/antigravity process-ancestry match.
- fm-spawn.sh: interactive launch template
  (agy --dangerously-skip-permissions -i "$(cat brief)"); add agy to the
  model flag (--model), effort flag (--effort, ceiling high), and the
  accepted-harness lists.
- fm-tmux-lib.sh / fm-watch.sh: add busy signature "esc to cancel" to the
  default busy regex (daemon inherits it).
- harness-adapters SKILL.md: full agy knowledge section, launch-profile-axes
  row, and no-mistakes invocation note.
- fm-session-start.test.sh: drop ANTIGRAVITY_AGENT in detect_own so the
  suite does not leak the marker.

Verified empirically on agy 1.1.5: env marker, interactive cwd inheritance,
--dangerously-skip-permissions autonomy, busy/idle footer, first-run trust
dialog. Turn-end hook and primary-session guard are NOT yet verified, so agy
is crewmate-only for now (documented in the skill).
fm_harness_pid_alive joined `basename comm` and `ps -o args=` into one
line before matching FM_HARNESS_RE. That broke every anchored
alternative: a live pi harness joins to "pi pi", which `^pi$` cannot
match, so each live pi session read as stale. bin/fm-lock.sh then let a
second session take the primary's lock, and bin/fm-claude-stop-autoarm.sh
reclaimed a lock whose owner was alive - a whole-home mutual-exclusion
failure that can double-dispatch or double-teardown.

Split the check the way fm_harness_ancestry_pid already does it: match
the basename of comm on its own line, and consult args only when comm is
a bare interpreter (node/python). FM_HARNESS_RE is unchanged, so `^pi$`
stays anchored and pip/pipx/paths containing "pi" keep reading as
not-a-harness.

tests/fm-session-lock-liveness.test.sh covers both directions against
real spawned processes (no fake ps) and fails on the pre-fix library.
tasks-axi's Done-retention prune archives resolved captain holds out of the
live backlog (closing the originating task auto-prunes), and the completion
gate could then never verify them again: teardown refused, complete failed
with 'absent from data/backlog.md', and the task deadlocked with no
non-bypass exit (hit live with psak-compose-bringup on 2026-07-26).

Prune archives rather than deletes, so the durable resolution record
survives byte-identically in the markdown backend's archive file. Every
read that accepts a Done hold now falls back to that archive: complete,
verify, identical resolve retries, and reopen refusal are order-independent
with respect to pruning. An archived row without the resolution record
still fails the gate, and an active hold is never read from the archive,
so the safety boundary is unchanged - the gate verifies the same evidence
it always required, from where the backend moved it.

Two regression tests reproduce the deadlock sequence end-to-end and prove
the fail-closed path for an archived hold with no resolution record.
…kill

High-blast-radius ship work now runs as a pair launched together, exchanging
directly through a durable shared file rather than through firstmate, which was
the latency bottleneck when it supervises several threads at once. The protocol
body lives in the new agent-only `paired-review` skill; AGENTS.md gains only the
trigger, the narrowed communication rule, and the delivery-path exception.

The second worker is a navigator, not a reviewer: three of the four gates have
no diff to look at, and an agent told it reviews will idle until one exists,
which defeats the design. The plan gate is the cheap one - a wrong-layer
direction error is visible from a file-level plan in about two minutes and
invisible at PR time under hours of work built on it.

The pair may never settle a contract or scope change, anything destructive,
irreversible, or security-sensitive, or a disagreement surviving its one round
trip; removing firstmate from the exchange moves no approval authority to the
crewmates.

Also make the scope and seam statement a default section of every ship and
scout brief, since the direction error that motivated this protocol happened on
a brief that never named the module owning the code.
…ral questions

Three rules the paired-review protocol did not carry, plus the rule that
keeps skill changes written against the skill-writing guide.

A diagnosis is not paired work. Pairing applies to implementation work; a
bug, regression, or crash-loop takes the diagnose-then-fix shape, one
worker following the diagnosing-bugs skill by absolute path. Until a root
cause exists there is no "where" for a navigator to hold a view about,
and the risk a bug carries is a wrong root cause rather than a wrong
layer, so sequence guards it where parallelism cannot.

The root-cause gate: firstmate judges the root cause before any fix
action. Confident, it authorises the fix and reports; otherwise it
escalates and waits. The root-cause document's own standard is the
confidence test. Destructive, irreversible, security-sensitive, and
contract-expanding fixes still go to the captain regardless.

Every navigator brief carries four fixed structural questions alongside
its task-specific checks: was the stated reason delivered, where did the
coupling go, does this add another instance of a shape the repo has been
burned by, and what did the brief not specify that the implementation had
to decide anyway. Each keeps its reason, because a checklist cannot reach
the destination - a navigator is pointed at a diff, and a diff shows what
changed, never whether the change moves toward where the work is going.

firstmate-coding-guidelines gains one requirement: a skill change begins
by loading writing-great-skills and is written against it.

AGENTS.md changes are two edited trigger lines and no new lines; the
rules themselves live in the skills.
The snapshot passed the parsed backlog and task inventory to jq as --argjson
argv strings. A single argument is capped by MAX_ARG_STRLEN (128 KiB), a
separate and far smaller limit than ARG_MAX, so once a home's backlog grew past
roughly 70 KB every snapshot - and therefore every bearings report - failed with
"Argument list too long". Shortening the other arguments could not help because
only one argument's size is measured.

Add jq_json, which wraps the growable values in one object fed to jq on stdin
and binds each back to its original name, so filter bodies are unchanged. Route
every call site whose value scales with backlog, task, secondmate, or report
volume through it, including the recursive per-home summary, the secondmate
record accumulator, and the final document assembly. Fixed-size values such as
booleans, counts, one path, and one status line stay on argv.

Cover the regression with an oversized-backlog fixture that asserts the full
inventory survives, not merely that the command exits 0.
…undary

Replace the paired-review default-routing guidance with a deterministic
navigator rule: every paired navigator runs on pi with the model
cx/gpt-5.6-terra, and only an explicit per-task captain choice of another
navigator runtime or model replaces it. Ordinary dispatch resolution keeps
owning the concrete launch mechanics and carries the pin through instead of
substituting a best-fit alternative.

State the ownership boundary in the same file: paired review is a universal
implementation-task execution protocol owned by whichever firstmate owns the
task, so a standalone paired task needs no persistent orchestrator, while a
program orchestrator dispatches the same protocol unchanged.

Drop the reroute-to-claude clause under the handed-out-skill limitation, which
would otherwise silently replace the pinned navigator runtime.
A planner session is one temporary worker the captain talks to directly.
Firstmate opens it, points it at a captain-defined project, scope, and
planning question, then leaves the conversation and monitors only whether
the session is alive, waiting, finished, or failed.

The planner investigates before it asks anything, reconstructing both what
the code does today and where the project's accepted decisions say it is
going, and surfaces every conflict between them instead of quietly choosing.
It reads tests as evidence and runs nothing. It then grills the captain one
question at a time, each question carrying its recommended answer and each
prescriptive choice carrying both the simplest workable and the best-practice
case. It may not produce a plan until the captain opens the crystallize gate,
after which it publishes a spec or dependency-aware tickets through the
project's own established conventions. Planning never authorizes
implementation.

Two artifact contracts travel downstream, each with one owner:

- The scope envelope carries the accepted boundary at spec level and per
  ticket, reusing bin/fm-brief.sh's existing scope and seam vocabulary plus
  the two fields a brief cannot carry before the target is chosen.
- The test contract carries acceptance intent, not executable test code, and
  the captain approves it together with scope.

planner owns those artifact fields. program-orchestration owns consuming
them: preserve provenance, revalidate, narrow per worker, never widen,
escalate a stale envelope. bin/fm-brief.sh keeps the final worker statement
and paired-review keeps sharing it with the driver and navigator, plus the
navigator's plan-gate challenge to the approved test contract.

The planning disciplines are vendored from mattpocock/skills at 2ab9580 with
the MIT license and a provenance record, adapted only in paths, tracker
assumptions, and delegation wording. No bundled file is named SKILL.md, so
the bundle stays off every harness's skill index and costs no context; it
also cannot silently clobber a captain's own locally installed copy, which
git overwrites without a conflict on fast-forward when the install path is
locally excluded.

Launch reuses the ordinary brief, spawn, and scout-report mechanics with no
new runtime: pi cx/gpt-5.6-sol at high effort by default, claude
claude-opus-5 when explicitly selected.

Also fixes fm-doc-audience-check.sh treating markdown links inside fenced
code blocks as navigation targets, which a vendored example listing exposed.
…tory

A navigator could only assert findings, so a question had to be dressed as a
defect or stay silent, and nothing systematically told it what had already been
decided. One program's navigator invented an undeclared Q entry to work around
exactly this, and another raised a cross-ticket scope question as a finding,
forcing the driver to adjudicate something it had no authority over.

paired-review gains an evidence-backed Q<k> form beside N<k>, on the same one
round trip but with no forced accepted/rejected verdict. The owning firstmate
answers by default and answers it itself, escalating upward only when it lacks
the authority or the knowledge; the driver answers only its own implementation
choices. Navigator briefs carry the decisions bearing on the ticket where a
record exists, and the skill now states that cross-package and whole-solution
direction sits outside one navigator's field of view.

program-orchestration takes the matching duties: maintaining the program's
cross-ticket decision record, handing the bearing decisions to both halves of
every dispatched pair, and holding direction across tickets.

N semantics and the four structural questions are unchanged, and no fifth
question was added. Both briefs are written at dispatch, so this reaches the
next dispatch and leaves a pair already under way on the protocol it launched
with.
The Q form said a question runs "its own sequence" but never said that
sequence is sequential and never reused, so the identifier rule was
checkable for N and not for Q. Match the N wording.
fm_herdr_lab_raw appended `--session <name>` to the end of the herdr argv.
`--session` is a herdr global option, and `herdr agent start <name> ... -- <argv...>`
hands every token after `--` to the inner command, so for any subcommand with a
separator the flag never reached herdr: the call silently ran against whatever
session herdr resolved by default, and the inner command received two junk
arguments. The reported repro, `agent start envcheck -- bash`, executed as
`bash --session fm-lab-...` and the pane died immediately.

The confirmed hypothesis is argument placement, not content. Placement was
inherited from fm_backend_herdr_cli, whose comment records that leading position
was already verified to work and that trailing was chosen only to keep call-site
diffs append-only; the blind spot in that choice is the `--` separator.

Every rejection rule is unaffected: the caller-supplied --session scan, the
leading-option refusal, the lifecycle and server refusals, and the fresh
refuse-default checks all run in fm_herdr_lab_cli on the caller's arguments
before fm_herdr_lab_raw assembles the herdr argv.

The existing behavior test asserted the trailing position as the contract, so the
suite was green on the defect; its assertions are re-pointed, and a new case
records the herdr argv token by token and asserts the session pair leads and
never lands past a `--`, with the inner command passed through untouched.

The identical latent pattern in fm_backend_herdr_cli is deliberately out of scope
here; no current backend call site uses a `--` separator.
Open a long-running programme orchestrator the captain talks to directly,
driving an already-authorized spec, ticket set, or GitHub issues to
completion through workers the session dispatches itself.

The skill splits across the branch boundary it actually has: firstmate
reads SKILL.md to open the session, and only the session reads
CONTRACT.md, so the judgment written for the orchestrator costs
firstmate a pointer rather than a context load. program-orchestration
keeps ownership of custody, routing, host ramp, envelope consumption,
and handoff; both files point at it rather than restating it.

AGENTS.md gains the third direct-conversation exception and one
deliverable-classification bullet. The planner test's closed-exception
assertion moves to the new count rather than dropping the invariant.
* fix(bin): keep tracked Claude hook entries inert under grok 1.0.0 (#1917)

* fix(hooks): keep tracked Claude entries inert under grok 1.0.0 hooks

Grok loads Claude-compatible settings, so the tracked `.claude/settings.json`
hook entries also fire under Grok. They were meant to be inert there, guarded
by `[ -z "${GROK_AGENT:-}" ] || exit 0`. That guard silently stopped working.

Verified from the live process environment of a wedged grok 1.0.0 Stop hook on
2026-08-07: a grok 1.0.0 HOOK process carries GROK_HOOK_EVENT, GROK_HOOK_NAME,
GROK_SESSION_ID, and GROK_WORKSPACE_ROOT, but no GROK_AGENT. The observed hook
process was labelled `GROK_HOOK_NAME=project/settings:stop[0].hooks[1]`, which
is the Claude-only auto-arm entry.

Consequence: Grok ran `bin/fm-claude-stop-autoarm.sh` synchronously. Grok has
no `asyncRewake`, so it waited on the foregrounded watcher for that entry's
declared 28800-second timeout and the Grok turn never ended - the operator saw
an infinite "Responding".

Widen the guard to `[ -z "${GROK_AGENT:-}${GROK_HOOK_EVENT:-}" ] || exit 0` on
the five entries that have a `.grok/hooks/` counterpart: both Stop entries, the
SessionStart entry, and the two PreToolUse Bash entries.

Two deliberate limits:

- The guard is NOT widened to GROK_SESSION_ID. Grok injects it into every child
  process, so it can survive into a Claude session that Grok launched and would
  silently disable Claude's own watcher continuity. GROK_HOOK_EVENT is
  per-hook-invocation and does not leak that way.
- `bin/fm-subagent-pretool-check.sh` stays unguarded on purpose. It is the one
  tracked entry with no `.grok/hooks/` counterpart, so guarding it would remove
  the guard from Grok entirely rather than deduplicate it. The new test asserts
  it stays unguarded so the exception cannot be closed silently, and
  docs/subagent-guard.md is honest that the coverage it leaves is partial.

`bin/fm-harness.sh` corrects a comment that presented GROK_AGENT as reliably
present; it is a fast path only, and the ancestry walk is what actually
guarantees grok identification.

tests/fm-turnend-guard.test.sh adds test_tracked_claude_entries_inert_under_grok,
which runs every tracked entry under a real grok 1.0.0 hook environment, a
legacy GROK_AGENT environment, and a native Claude environment.

* no-mistakes(document): docs: sync grok hook-marker guard facts to owners

* no-mistakes(review): docs: state grok guard criterion by event coverage

* feat(startup-network): record per-step elapsed times for the deferred stage (#1918)

The deferred network stage published one aggregate started/finished pair, so
a run that took a minute could not be attributed to a phase, a host, or a
clone without re-running it by hand under manual tracing.

Add bin/fm-timing-lib.sh as the single owner of elapsed-time records, and
bracket each network owner with one: the gh auth probe, the secondmate
liveness sweep, secondmate convergence, pending handoff delivery, and the
project clone refresh, plus one record per secondmate for the remote-touching
steps (id and host) and one per project clone. Each record carries a start
offset from one shared origin, so the artifact reads as a timeline.

The stage publishes them beside its report as state/.startup-network.timings,
for a timed-out or failed run too, where the partial record is the answer.
Only the on-demand `report` command prints them: `harvest` composes the
session-start digest, so its output, the wake cadence, and every other part
of a normal session start are unchanged.

Recording is inert unless a run asks for it, so nothing else that sources
these scripts pays for it. Details are identities only - a detail carrying
whitespace is refused rather than cleaned up, which is what keeps a command
line, an environment dump, or a captured error out of the file.

Split two per-item loop bodies into their own functions so each iteration can
be timed; every `continue` became a `return 0` with the same meaning, and the
sweeps still run directly, in the same order, returning the same results.

* feat(stow): cascade the internal /stow to every registered secondmate (#1928)

* feat(stow): cascade the internal /stow to every registered secondmate

Invoked in a primary home, /stow now sweeps every registered secondmate
after the primary's own required pass, enforcing the same startup-memory
threshold in each home against that home's own allowance rather than a
fleet total.

bin/fm-stow-cascade.sh owns the mechanical inputs: it enumerates each
registered secondmate exactly once from data/secondmates.md, reports that
home's own budget accounting, and resolves how the sweep reaches it. A
live agent sweeps its own home so its uncaptured session knowledge is
captured too; a local home without one is curated in place; a remote home
without one is accounted read-only and deferred, because there is no
generic remote write path for a home's own memory files. Every host-
crossing step and each home's accounting runs under one hard bound, so a
slow or unreachable home reports an exception and the sweep continues.

Nothing changes until /stow is invoked: no new notification, digest
section, or background work. The public skills/stow skill is untouched.

* no-mistakes(review): fix(stow): extend cascade --help range to include full exit-code contract

* fix(remote-job): stop workers abandoned by a pruned code root (#1927)

29 fm-remote-job-worker.sh processes were found running at ppid 1, 1-2 days
old, each still polling and appending to a log inside a no-mistakes gate
worktree that had already been returned.

Three things combined to make that possible:

- The recorded worker.pid is the serving child, not the restart supervisor
  above it, so a teardown that stops that one pid only makes the supervisor
  respawn. The Linux start path also left the worker tree in the launching
  command's process group, so there was no group to signal instead.
- Neither the serving loop nor the supervisor ever rechecked whether its
  configured FM_ROOT still existed, so a worker launched from a worktree
  outlived that worktree indefinitely.
- The supervisor restarted a failing child with a fixed 0.1s delay and no
  bound, which is what grew the logs (~66MB/day measured).

The Linux start path now puts the worker tree in its own process group, and
fm_remote_job_stop_worker_tree signals that whole group - refusing any group
whose leader is not itself a worker, so a worker from an older build or from
launchd's own session is still stopped safely as a single process. The worker
stops itself once its code root stops being a Firstmate checkout, confirmed
across a grace window so an ordinary transient cannot stop a healthy worker.
The supervisor backs off and gives up rather than restarting forever.

bin/fm-remote-job-reap-orphans.sh is the belt-and-suspenders sweep for workers
already orphaned that way, wired into fm-teardown.sh. Its reap condition is
exactly "the code root named in the worker's own command line is gone", which
is why the account's healthy LaunchAgent worker and every live remote
secondmate worker are never candidates.

The two suites that leaked these in the first place now stop the worker tree
rather than the recorded pid alone.

* feat(bin): lint only the changed shard locally, full lint in CI (#1925)

* fix(bin): lint only the changed shard locally, full lint in CI

Two ships hitting fm-lint.sh at once could spike CPU to 190% and load
to 8.58 on a captain's Mac, even though each run finishes quickly.
fm-lint.sh now defaults to linting only the canonical-set files
changed since the merge-base with origin/main (including uncommitted
edits) on an ordinary local branch, using plain local git with no
network calls. It still lints the full canonical set in CI
(GITHUB_ACTIONS=true or CI=true), on the main branch, or whenever no
merge-base can be found, so CI coverage never depends on a local diff.
Explicit paths keep bypassing this selection entirely.

* no-mistakes: apply CI fixes

* fix(herdr): admit agy plain-ASCII '> ' composer via native identity

agy's interactive composer draws a bare ASCII "> " prompt with no side
border and no agent-specific glyph, so its empty-composer row is
byte-for-byte the dead-shell prompt the shared classifier in
bin/fm-composer-lib.sh deliberately refuses as unknown (never empty).
Under herdr that made a live-empty agy composer fall to unknown, unlike
bordered/agent-glyph shapes, so away-mode injection never fired.

Close the gap inside the herdr adapter only, mirroring the Pi separator
composer: locate the bottom-most "> " row structurally and admit it as
a real composer solely when native `agent get` corroborates the target
is agy and reports idle/done/blocked. A working agy, a non-agy or
unregistered agent, or an unreadable identity keeps the bare row unknown,
so the shared dead-shell rule is not weakened. Identity is fetched at
most once per call, shared with the Pi block.

* feat: add agy (Antigravity CLI) harness adapter

Wire Google Antigravity CLI (agy 1.1.5, Gemini-backed) as a crewmate harness.

- fm-harness.sh: detect agy via ANTIGRAVITY_AGENT=1 env marker plus
  agy/antigravity process-ancestry match.
- fm-spawn.sh: interactive launch template
  (agy --dangerously-skip-permissions -i "$(cat brief)"); add agy to the
  model flag (--model), effort flag (--effort, ceiling high), and the
  accepted-harness lists.
- fm-tmux-lib.sh / fm-watch.sh: add busy signature "esc to cancel" to the
  default busy regex (daemon inherits it).
- harness-adapters SKILL.md: full agy knowledge section, launch-profile-axes
  row, and no-mistakes invocation note.
- fm-session-start.test.sh: drop ANTIGRAVITY_AGENT in detect_own so the
  suite does not leak the marker.

Verified empirically on agy 1.1.5: env marker, interactive cwd inheritance,
--dangerously-skip-permissions autonomy, busy/idle footer, first-run trust
dialog. Turn-end hook and primary-session guard are NOT yet verified, so agy
is crewmate-only for now (documented in the skill).

* fix: read live pi sessions as live in session-lock liveness

fm_harness_pid_alive joined `basename comm` and `ps -o args=` into one
line before matching FM_HARNESS_RE. That broke every anchored
alternative: a live pi harness joins to "pi pi", which `^pi$` cannot
match, so each live pi session read as stale. bin/fm-lock.sh then let a
second session take the primary's lock, and bin/fm-claude-stop-autoarm.sh
reclaimed a lock whose owner was alive - a whole-home mutual-exclusion
failure that can double-dispatch or double-teardown.

Split the check the way fm_harness_ancestry_pid already does it: match
the basename of comm on its own line, and consult args only when comm is
a bare interpreter (node/python). FM_HARNESS_RE is unchanged, so `^pi$`
stays anchored and pip/pipx/paths containing "pi" keep reading as
not-a-harness.

tests/fm-session-lock-liveness.test.sh covers both directions against
real spawned processes (no fake ps) and fails on the pre-fix library.

* docs: record the gh-axi repo-resolution trap and the turn-boundary stall pattern

* fix: verify pruned resolved captain holds from the done archive

tasks-axi's Done-retention prune archives resolved captain holds out of the
live backlog (closing the originating task auto-prunes), and the completion
gate could then never verify them again: teardown refused, complete failed
with 'absent from data/backlog.md', and the task deadlocked with no
non-bypass exit (hit live with psak-compose-bringup on 2026-07-26).

Prune archives rather than deletes, so the durable resolution record
survives byte-identically in the markdown backend's archive file. Every
read that accepts a Done hold now falls back to that archive: complete,
verify, identical resolve retries, and reopen refusal are order-independent
with respect to pruning. An archived row without the resolution record
still fails the gate, and an active hold is never read from the archive,
so the safety boundary is unchanged - the gate verifies the same evidence
it always required, from where the backend moved it.

Two regression tests reproduce the deadlock sequence end-to-end and prove
the fail-closed path for an archived hold with no resolution record.

* docs: add the paired driver-and-navigator protocol as an agent-only skill

High-blast-radius ship work now runs as a pair launched together, exchanging
directly through a durable shared file rather than through firstmate, which was
the latency bottleneck when it supervises several threads at once. The protocol
body lives in the new agent-only `paired-review` skill; AGENTS.md gains only the
trigger, the narrowed communication rule, and the delivery-path exception.

The second worker is a navigator, not a reviewer: three of the four gates have
no diff to look at, and an agent told it reviews will idle until one exists,
which defeats the design. The plan gate is the cheap one - a wrong-layer
direction error is visible from a file-level plan in about two minutes and
invisible at PR time under hours of work built on it.

The pair may never settle a contract or scope change, anything destructive,
irreversible, or security-sensitive, or a disagreement surviving its one round
trip; removing firstmate from the exchange moves no approval authority to the
crewmates.

Also make the scope and seam statement a default section of every ship and
scout brief, since the direction error that motivated this protocol happened on
a brief that never named the module owning the code.

* docs: exclude diagnosis from pairing and give navigators four structural questions

Three rules the paired-review protocol did not carry, plus the rule that
keeps skill changes written against the skill-writing guide.

A diagnosis is not paired work. Pairing applies to implementation work; a
bug, regression, or crash-loop takes the diagnose-then-fix shape, one
worker following the diagnosing-bugs skill by absolute path. Until a root
cause exists there is no "where" for a navigator to hold a view about,
and the risk a bug carries is a wrong root cause rather than a wrong
layer, so sequence guards it where parallelism cannot.

The root-cause gate: firstmate judges the root cause before any fix
action. Confident, it authorises the fix and reports; otherwise it
escalates and waits. The root-cause document's own standard is the
confidence test. Destructive, irreversible, security-sensitive, and
contract-expanding fixes still go to the captain regardless.

Every navigator brief carries four fixed structural questions alongside
its task-specific checks: was the stated reason delivered, where did the
coupling go, does this add another instance of a shape the repo has been
burned by, and what did the brief not specify that the implementation had
to decide anyway. Each keeps its reason, because a checklist cannot reach
the destination - a navigator is pointed at a diff, and a diff shows what
changed, never whether the change moves toward where the work is going.

firstmate-coding-guidelines gains one requirement: a skill change begins
by loading writing-great-skills and is written against it.

AGENTS.md changes are two edited trigger lines and no new lines; the
rules themselves live in the skills.

* fix: keep whole-fleet JSON off the jq command line in the fleet snapshot

The snapshot passed the parsed backlog and task inventory to jq as --argjson
argv strings. A single argument is capped by MAX_ARG_STRLEN (128 KiB), a
separate and far smaller limit than ARG_MAX, so once a home's backlog grew past
roughly 70 KB every snapshot - and therefore every bearings report - failed with
"Argument list too long". Shortening the other arguments could not help because
only one argument's size is measured.

Add jq_json, which wraps the growable values in one object fed to jq on stdin
and binds each back to its original name, so filter bodies are unchanged. Route
every call site whose value scales with backlog, task, secondmate, or report
volume through it, including the recursive per-home summary, the secondmate
record accumulator, and the final document assembly. Fixed-size values such as
booleans, counts, one path, and one status line stay on argv.

Cover the regression with an oversized-backlog fixture that asserts the full
inventory survives, not merely that the command exits 0.

* docs: add program orchestration skill

* docs: pin the paired navigator and state paired review's ownership boundary

Replace the paired-review default-routing guidance with a deterministic
navigator rule: every paired navigator runs on pi with the model
cx/gpt-5.6-terra, and only an explicit per-task captain choice of another
navigator runtime or model replaces it. Ordinary dispatch resolution keeps
owning the concrete launch mechanics and carries the pin through instead of
substituting a best-fit alternative.

State the ownership boundary in the same file: paired review is a universal
implementation-task execution protocol owned by whichever firstmate owns the
task, so a standalone paired task needs no persistent orchestrator, while a
program orchestrator dispatches the same protocol unchanged.

Drop the reroute-to-claude clause under the handed-out-skill limitation, which
would otherwise silently replace the pinned navigator runtime.

* feat(skills): add the captain-invoked planner session

A planner session is one temporary worker the captain talks to directly.
Firstmate opens it, points it at a captain-defined project, scope, and
planning question, then leaves the conversation and monitors only whether
the session is alive, waiting, finished, or failed.

The planner investigates before it asks anything, reconstructing both what
the code does today and where the project's accepted decisions say it is
going, and surfaces every conflict between them instead of quietly choosing.
It reads tests as evidence and runs nothing. It then grills the captain one
question at a time, each question carrying its recommended answer and each
prescriptive choice carrying both the simplest workable and the best-practice
case. It may not produce a plan until the captain opens the crystallize gate,
after which it publishes a spec or dependency-aware tickets through the
project's own established conventions. Planning never authorizes
implementation.

Two artifact contracts travel downstream, each with one owner:

- The scope envelope carries the accepted boundary at spec level and per
  ticket, reusing bin/fm-brief.sh's existing scope and seam vocabulary plus
  the two fields a brief cannot carry before the target is chosen.
- The test contract carries acceptance intent, not executable test code, and
  the captain approves it together with scope.

planner owns those artifact fields. program-orchestration owns consuming
them: preserve provenance, revalidate, narrow per worker, never widen,
escalate a stale envelope. bin/fm-brief.sh keeps the final worker statement
and paired-review keeps sharing it with the driver and navigator, plus the
navigator's plan-gate challenge to the approved test contract.

The planning disciplines are vendored from mattpocock/skills at 2ab9580 with
the MIT license and a provenance record, adapted only in paths, tracker
assumptions, and delegation wording. No bundled file is named SKILL.md, so
the bundle stays off every harness's skill index and costs no context; it
also cannot silently clobber a captain's own locally installed copy, which
git overwrites without a conflict on fast-forward when the install path is
locally excluded.

Launch reuses the ordinary brief, spawn, and scout-report mechanics with no
new runtime: pi cx/gpt-5.6-sol at high effort by default, claude
claude-opus-5 when explicitly selected.

Also fixes fm-doc-audience-check.sh treating markdown links inside fenced
code blocks as navigation targets, which a vendored example listing exposed.

* feat(skills): give the navigator a question form and the decision history

A navigator could only assert findings, so a question had to be dressed as a
defect or stay silent, and nothing systematically told it what had already been
decided. One program's navigator invented an undeclared Q entry to work around
exactly this, and another raised a cross-ticket scope question as a finding,
forcing the driver to adjudicate something it had no authority over.

paired-review gains an evidence-backed Q<k> form beside N<k>, on the same one
round trip but with no forced accepted/rejected verdict. The owning firstmate
answers by default and answers it itself, escalating upward only when it lacks
the authority or the knowledge; the driver answers only its own implementation
choices. Navigator briefs carry the decisions bearing on the ticket where a
record exists, and the skill now states that cross-package and whole-solution
direction sits outside one navigator's field of view.

program-orchestration takes the matching duties: maintaining the program's
cross-ticket decision record, handing the bearing decisions to both halves of
every dispatched pair, and holding direction across tickets.

N semantics and the four structural questions are unchanged, and no fifth
question was added. Both briefs are written at dispatch, so this reaches the
next dispatch and leaves a pair already under way on the protocol it launched
with.

* fix(skills): state the Q id discipline the N form already carries

The Q form said a question runs "its own sequence" but never said that
sequence is sequential and never reused, so the identifier rule was
checkable for N and not for Q. Match the N wording.

* fix(herdr): place the lab --session ahead of any -- separator

fm_herdr_lab_raw appended `--session <name>` to the end of the herdr argv.
`--session` is a herdr global option, and `herdr agent start <name> ... -- <argv...>`
hands every token after `--` to the inner command, so for any subcommand with a
separator the flag never reached herdr: the call silently ran against whatever
session herdr resolved by default, and the inner command received two junk
arguments. The reported repro, `agent start envcheck -- bash`, executed as
`bash --session fm-lab-...` and the pane died immediately.

The confirmed hypothesis is argument placement, not content. Placement was
inherited from fm_backend_herdr_cli, whose comment records that leading position
was already verified to work and that trailing was chosen only to keep call-site
diffs append-only; the blind spot in that choice is the `--` separator.

Every rejection rule is unaffected: the caller-supplied --session scan, the
leading-option refusal, the lifecycle and server refusals, and the fresh
refuse-default checks all run in fm_herdr_lab_cli on the caller's arguments
before fm_herdr_lab_raw assembles the herdr argv.

The existing behavior test asserted the trailing position as the contract, so the
suite was green on the defect; its assertions are re-pointed, and a new case
records the herdr argv token by token and asserts the session pair leads and
never lands past a `--`, with the inner command passed through untouched.

The identical latent pattern in fm_backend_herdr_cli is deliberately out of scope
here; no current backend call site uses a `--` separator.

* feat(skills): add the captain-invoked orchestrator session

Open a long-running programme orchestrator the captain talks to directly,
driving an already-authorized spec, ticket set, or GitHub issues to
completion through workers the session dispatches itself.

The skill splits across the branch boundary it actually has: firstmate
reads SKILL.md to open the session, and only the session reads
CONTRACT.md, so the judgment written for the orchestrator costs
firstmate a pointer rather than a context load. program-orchestration
keeps ownership of custody, routing, host ramp, envelope consumption,
and handoff; both files point at it rather than restating it.

AGENTS.md gains the third direct-conversation exception and one
deliverable-classification bullet. The planner test's closed-exception
assertion moves to the new count rather than dropping the invariant.

* fix: resolve inherited test-run conflict marker

* ci: remove inherited no-mistakes requirement

* fix: restore scoped reconciliation regressions

* ci: update snapshot compatibility count

---------

Co-authored-by: Jay Park <jay.jongcheol.park@gmail.com>
Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
…ncestry

Restore accepted reconciliation ancestry
* vendor Matt productivity and engineering skills snapshot

* classify vendored Matt documentation surfaces
* feat(policy): add planner policy launcher and focused test

* fix(policy): keep recommendation path singular by default

* refactor(planner): remove stale planner surfaces

* docs(agents): retain only policy pointer

* fix(agents): restore upstream surface for policy pointer

* test(planner): accept static instruction contract
Move the paired implement-and-check protocol to custom-skills/paired-review as
the sole custom owner, adapted from the upstream-path owner with the accepted
hardening: Herdr pair composition in adjacent panes with direct communication
supplementing the canonical pair-log, navigator immediate-stop, the safe-boundary
hold, explicit no-shared-Git and no-new-transport limits, and a bounded
cross-owner pointer to /orchestrator and program-orchestration. Delete the old
.agents/skills/paired-review owner so no stale duplicate remains. Add first-match
role=driver and role=navigator trigger rows to custom-skills/policy before the
generic implement and review routes, move the agent-runtime inventory entry to
the custom owner path, and add a colocated focused test proving the policy route
and path resolution including the .claude/skills symlink. No core scripts changed.
* chore: remove stale orchestrator test from test runner

* fix: revert firstmate-coding-guidelines to upstream
huynhtandat223 and others added 27 commits August 22, 2026 12:05
Use the existing process-event runner to wake a bound companion on transcript growth, expose lag and stale primary bindings, and make the ordinary primary bind spelling resolve the hook-recorded active session. Rotation now measures Claude usage against its effective auto-compact window rather than nominal model capacity.
A stale pane whose crew was provably working still escalated as a possible
wedge once FM_STALE_ESCALATE_SECS elapsed, and that fixed 240s timer is
shorter than the work itself: a frontend gate measured at 311s crosses the
threshold before it can finish, so the same worker false-alarmed on every
cycle of it.

The stale path now asks a second, structural source before firing that timer.
crew_work_evidence reads two kernel facts about the task's recorded worktree -
a live process rooted there, and the newest mtime among the files git reports
as changed - and a positive answer RESTARTS the escalation clock instead of
escalating. Nothing in it reads rendered output, a spinner, or a vendor
process name.

The extension is bounded twice. Only positive evidence buys it, so an
unrecorded worktree, an unreadable path, or a host where neither source can
answer keeps today's behaviour exactly. And one stale episode may spend at
most FM_WORK_EVIDENCE_MAX_SECS on it, defaulting to FM_BUSY_TURN_MAX_SECS, so
a hung process that never exits still escalates - within an hour of the pane
going quiet - and then keeps escalating on the ordinary cadence with its
escalation count and demand-deep-inspection marker intact.

The probe runs only when an escalation is otherwise about to fire, at most
once per FM_STALE_ESCALATE_SECS per stale window, and adds nothing to the
per-wake path. Measured on Linux with 177 processes and a 526-file worktree:
2ms for the process scan, 9ms when it falls through to the changed-file read.

tests/fm-stale-work-evidence.test.sh pins the behaviour with real processes,
real mtimes, and no harness, and drives the two sources apart so no case can
pass vacuously on the other one.
)

A brief scoped to one module should put the agent in that module rather
than only asking it to stay there, and a worker that starts narrower reads
less of the tree.

fm-spawn.sh gains an optional --agent-path <path>, resolved against the
task worktree and recorded as an absolute agent_path= in state/<id>.meta.
Only two universal facts are validated: the path exists as a directory and
resolves inside the task's own worktree. Nothing about the directory's
contents is inspected, so no project's layout is baked into the tool.

Placement is the pane's own directory change, prepended after every
environment prefix and grouped behind && so a directory that vanished
between validation and launch stops the worker instead of silently
starting it at the worktree root. Cursor, the one adapter that takes its
directory as --workspace rather than inheriting it, receives the same
value, as do the muse and cursor turn-state bindings.

Relaunch treats the recorded value as an identity axis: it is re-validated
rather than trusted, the adopted endpoint must be sitting in it, and
--agent-path is refused alongside --relaunch. A secondmate and a temporary
supervisor refuse the flag because their worktree is their firstmate home,
and batch dispatch refuses it because a starting directory belongs to one
task's worktree.

Omitting the flag writes no agent_path= line and leaves the launch command
unchanged.

tests/fm-spawn-agent-path.test.sh pins the resolution, the record, the
refusals, relaunch preservation, and cursor's workspace with a fake
terminal and real git worktrees.

Co-authored-by: dat.huynh <dat.huynh@titandms.com.au>
…tions (#60)

- Remove five-minute timer wait at release barrier
- Replace polling language with event-driven idle behavior
- Navigator now remains idle between direct signals
- Driver writes plan/milestone to pair log and sends single notification
- Preserve immediate STOP authority with concrete evidence
- Recovery expressed as owner/event-driven, not timer-based
* Route mandatory PR-review capabilities into navigator phases

- Plan gate: apply Spec axis of code-review/SKILL.md, review architecture/direction, form initial changed-actor trigger/proof map using classical-testing/SKILL.md
- Milestones: apply Standards axis, scope/coupling checks, proof sensitivity, strongest-authorized-real-path checks
- Navigator loads writing-for-agents/SKILL.md directly on agent-facing material (not merely remind driver)
- Final gate: apply complete Standards and Spec review, writing-for-agents on every changed agent-facing document, classical-testing across every changed actor trigger against exact driver/PR head. Record self-contained verdict naming exact head, findings, proof map, and whether each capability completed

* Add parent owner contract: three-capability PR-review verdict requirement and replacement reviewer commissioning

- One completed clean navigator verdict on exact PR head satisfies independent three-capability requirement
- Three capabilities: Spec axis, Standards axis, Classical-testing across every changed actor trigger
- Firstmate commissions replacement reviewer when coverage incomplete, solo, stale-head, or recovered without completed exact-head final verdict
- Any code change after verdict invalidates it
- Navigator independence, STOP authority, event-driven idle behavior, driver/navigator boundaries preserved
- Phase execution in navigator, acceptance/replacement ownership in parent; concise pointer elsewhere only

* Fix parent three-capability definitions and navigator final-gate scope

- Parent: three capabilities are code-review (Standards+Spec axes), writing-for-agents on changed agent-facing docs, classical-testing across every changed actor trigger
- Navigator step 6: changed from 'at every gate answer' to 'at the final gate answer', preserving plan/milestone duties
- Authoritative skill paths used: code-review/SKILL.md, writing-for-agents/SKILL.md, classical-testing/SKILL.md

* Fix skill pointers to exact relative authoritative paths

- navigator/SKILL.md: code-review → ../../matt/engineering/code-review/SKILL.md, classical-testing → ../../classical-testing/SKILL.md, writing-for-agents → ../../matt/productivity/writing-for-agents/SKILL.md
- parent SKILL.md: three capabilities use ../matt/engineering/code-review/SKILL.md, ../matt/productivity/writing-for-agents/SKILL.md, ../classical-testing/SKILL.md
- All other content unchanged
* fix: scope brief scaffold guidance by mode

* fix: restore navigator writing skill pointer
The scaffold told every worker it may run code-review's parallel review
subagents, and named Pi cx/gpt-5.6-luna as a permitted model for them.

Both halves are now wrong. Review runs through the review-rulesets skill,
which states the reviewing agent performs the review itself rather than
dispatching it, so there are no review subagents to constrain. And the
captain's standing preference prohibits dispatching Pi sol, terra, or luna,
so the line handed every generated brief a prohibited selector.

The sentence existed at exactly one place in the repo and no test pinned
its text, so nothing cross-references it and no second copy can drift.
The remaining preference it carried, that Fable and cx/gpt-5.6-sol are not
used, already lives with the captain's other model preferences and stays
there rather than moving into tracked material.
review-rulesets is the current review path: it carries code-review's
Standards and Spec axes plus classical-testing and writing-for-agents,
and it states that the reviewing agent performs the review itself.

Generated briefs now point there when it is installed, guarded by the
same existence check the writing-for-agents line already uses, and fall
back to code-review when it is not. The fallback matters because the
skill lives outside this repo, so a home without it still gets a review
instruction rather than none.
* feat(brief): emit worker self-review on faster-path ship briefs

direct-PR and local-only now require review-rulesets on the worker's
exact head as part of finishing, in parallel with CI. The step is
evidence for firstmate, not merge authority. no-mistakes, scout, and
secondmate stay unchanged so the pipeline is not stacked with a second
review.

* fix(brief): keep CI-parallel self-review off local-only briefs

The two CI sentences are direct-PR facts. local-only never pushes, so
its self-review is part of finishing and its merge is gated on ready-
branch approval, not CI.
The scaffold told every generated brief to use Claude Superpowers TDD and
verification-before-completion 'where the selected harness provides them'.

Superpowers is not a default. The captain names it explicitly when a task
should use it, so the scaffold must not hand it to every worker instead.

The line was also unverifiable in both directions. It named no path, so a
worker could not tell what to load, and 'where the selected harness
provides them' resolved differently per harness with nothing saying which
way it went: a Claude worker carries superpowers as a user-scope plugin and
sees it, while Pi reaches it only through a packages entry that is absent,
against a submodule that is not checked out. The remaining lines each name
an absolute path and a condition, so a worker can act on them.

classical-testing already owns completion verification and is still loaded
by every brief, so nothing is lost here.
* fix(watcher): stop re-waking a live crew that declared a pause

pause_state_class ran its dead-agent gate on every poll of an ordinary
crew, so an authoritative paused verdict from crew_absorb_class was
replaced with "none" for as long as the agent stayed alive. Every change
in the idle pane's rendered tail then re-entered the first-sight branch
and surfaced a bare "stale: <window>" - four wakes in twenty minutes
against a crew standing by exactly as its instructions told it to, each
one blocking a turn end.

Bound the gate to whether a pause episode is already open. The onset of a
pause still surfaces once, so firstmate learns the crew paused, and that
one wake now carries the same "(paused Ns, awaiting external ...)"
annotation the long-cadence recheck uses instead of reading like a pane
gone quiet. Every later poll of the same episode is absorbed, with
handle_paused_stale owning re-surfacing on the PAUSE_RESURFACE_SECS
cadence, so a pause that rots is still caught. The dead-agent rescue the
gate exists for is unchanged.

tests/fm-watch-paused-live-crew.test.sh pins both levels: a real watcher
driven across five pane-content changes surfaces 5 stale wakes before
this change and exactly 1 annotated wake with 0 bare wakes after it, and
the pause_state_class verdicts are pinned with the classifier verdict and
backend liveness driven apart so no case passes on the status line alone.

Closes the fm-paused-stale-false-wake and
fm-watch-live-paused-crew-never-absorbed records.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

* test(watcher): classify the paused-crew regression with the watcher suites

The new regression drives real watcher subprocesses and the durable wake
queue, so it belongs in the watcher-wake-lock family with its neighbours
rather than the unclassified serial remainder. Split the architecture
sentence it corrected onto one sentence per line.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
The scaffold told every ship brief to load the vendored implement skill,
and policy routed planning, paired drivers, CFW frontend work, and
generic implementation through implement or tdd.

classical-testing already owns proof. Drop those routes and keep policy
plus classical-testing on generated briefs.
* Sync fork with upstream main

* fix(snapshot): stage the backlog on disk for contribution input

`--contribution-input` passed the whole parsed backlog to jq as a command-line
argument, so on any home with a real backlog it died with
`jq: Argument list too long` before producing anything. Session start runs this
path, so the failure printed on every start.

The same script already stages the backlog to a file and reads it with
`--slurpfile` for its other consumer. Move that staging above the
`contribution-input` early exit and reuse it, so both paths read the backlog
from disk and neither can outgrow a command line.

Verified against a live home whose backlog is 353 KB: the path now returns the
full document instead of failing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Give every worker its own chrome-devtools-axi session, stopped at teardown

* Pin the per-task browser session export in launch-shape tests
* Escalate idle bare turn-end signals

* Keep churn handling in watcher
)

* Add handoff-session skill: fresh context on the same worker adapter

A handoff moves a live worker's task onto a fresh session of the same harness,
model and effort. The skill owns the three steps (worker writes the handoff with
Matt's handoff skill to data/<task-id>/handoff.md, firstmate relaunches on the
recorded adapter with a note, then restores PR monitoring); the policy router
gains its trigger row.

* Move handoff-session into .agents/skills with a section 13 trigger

Skills under .agents/skills are listed to firstmate with their descriptions, so the
skill loads on its trigger instead of only through the role policy router.

* handoff-session: front-load the trigger word, state the rule positively

* handoff-session: keep the adapter recorded at handoff time
* Add automatic context handoff notifications for Claude and Pi workers

* Preserve Pi turn-end notification when context helper fails

* Let Pi finish its run before supervisor handoff

* Respect explicit 200k suffix across Claude 5 families

* Keep Pi turn-end compatible with contexts without usage API

* Reuse Pi stock call formatting for branch outcomes

* Fit Calm restored transcript in default fullscreen viewport

* Check hidden export rows using Pi 1.0 template visibility

* Reject synthetic export markers outside verified hidden rows
* Require review brief sections in worker PR bodies

* Require issue links alongside worker PR review briefs
* Resolve worker handoff thresholds by model and preserve on relaunch

* Omit disabled Pi handoff wiring and prove both hook guards
* Isolate Calm renderer fixtures from Chrome confinement and user bindings

* Use Pi 1.0.1 HTML tool renderer lookup in Calm fixture
… relaunch it after the sync (#85)

* Source-check decisions and worker PR heads in the assistance companion

The companion now answers three questions against current source for every
observed decision and every worker-reported PR head: does it match, is it
already implemented, does it break a rule. It also runs on Pi sol.

Part of #84

* Relaunch the assistance companion after the supervisor kind was removed

The upstream sync (#70) removed fm-spawn's supervisor kind and the Claude
SessionStart publication of the running primary session, so the companion
could no longer launch and lost its parent after every context clear. Launch
it as a read-only scout of this repository and publish the Claude primary
session again.

Part of #84

* Point the source check at a landed task's PR record

Part of #84

* Keep the source check inside one reminder per turn

Part of #84

* Open a companion with the brief and backlog item its scout launch needs

A scout spawn refuses without a brief and a backlog item, so open writes
whichever the home lacks. A regression case pins the restored Claude
primary-session publication.

Part of #84

* Watch every PR for the reviews the captain requires before merge

Part of #84

* Keep each standing watch item beside its own rationale

Part of #84
* Fix Claude context handoff fallback

* Use latest Claude usage during Stop retries
* Fix primary assistance binding after clear

* Bind assistance companion on session start

* Rebind assistance observer after primary clear

* Bind the newly published primary session

* Handle first transcript creation for assistance
@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[High risk] Restructures session supervision and decision handling across agent skills.

The PR is not ready to merge because fresh-session publication and observation after an already-grown history rebind can both miss assistance work.

Reviews (1) · Last reviewed commit: "Fix primary assistance session rebinding"

# Publish that identity for an already-enabled primary assistance companion so a
# context clear becomes an exact binding change instead of silent transcript
# abandonment. Other harnesses publish through their own session-start adapter.
if fm_session_lock_owned_by_self "$STATE" \

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Fresh starts miss assistance publication

When a Claude session starts with primary assistance enabled but has not yet acquired the session lock, this check skips publication. fm-session-start.sh acquires the lock afterward, but nothing retries publication. Assistance remains bound to the previous session until another SessionStart occurs.

Comment on lines +240 to +242
# Outcomes are keyed by turn identity across history rebinds. Preserve the
# cursor and pending batch so settled turns are not replayed as new input.
rm -f "$(fm_assistance_pending_path "$FM_HOME" "$pid")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Rebind skips new session turns

The preserved cursor is a line number from the old transcript. If the new transcript has already grown to at least that many lines, observe does not reset it and skips the earlier turns in the new session. Assistance can permanently miss decisions and reminders from those turns.

Comment on lines +1058 to +1062
[ "$(sha256sum "$root/state/primary-assistance.assistance-current")" = "$current_before" ] \
|| fail "lock-refused SessionStart changed the current session record"
[ "$(sha256sum "$root/state/primary-assistance.assistance-binding")" = "$binding_before" ] \
|| fail "lock-refused SessionStart changed the assistance binding"
pass "run wrapper: lock-refused Claude SessionStart leaves assistance records unchanged"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Owner publication loses test coverage

The revised test verifies only that a foreign lock leaves assistance records unchanged. It removes the checks that an owning session publishes its identity, updates the binding, and arms observation. A failure in that publish path could now pass this test unnoticed.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

1 participant