Skip to content

fix(bin): render the remote charter's steering-inbox path host-local - #5049

Merged
kunchenguid merged 2 commits into
kunchenguid:mainfrom
kesslerio:fix/remote-brief-host-local-paths
Sep 21, 2026
Merged

kunchenguid merged 2 commits into
kunchenguid:mainfrom
kesslerio:fix/remote-brief-host-local-paths

Conversation

@kesslerio

@kesslerio kesslerio commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Intent

Fix #5012: the remote charter render in bin/fm-remote-home-seed.sh shows the remote secondmate a parent-absolute steering-inbox path (the control plane's <FM_HOME>/state/.inbox) instead of the host-local remote surface state/parent-route/.inbox that docs/remote-secondmates.md specifies, so the remote mate burns a turn filing blocked for a misrouted steer. Extend the existing remote-copy rewrite loop to map the inbox path host-local, the same way the reply-log path is already rewritten, and fix the macOS bash 3.2 quoted-substitution quote leak that leaked literal quote characters into rewritten lines (plain assignments instead of quoted substitution in the printf loop). Pin the corrected render with regression assertions in tests/fm-remote-secondmate-lifecycle-e2e.test.sh: host-local inbox present, parent-absolute inbox absent, acknowledgement move rendered. Captain required local testing before opening the upstream PR: both new asserts fail on the old code and pass with the fix on bash 3.2.57. Ship as an upstream PR to kunchenguid/firstmate main (PR #5049 already open from the captain's fork, branch fix/remote-brief-host-local-paths). This is a resubmission after the previous run's review step failed on a Claude session limit at environmental level, not a code problem.

What Changed

  • bin/fm-remote-home-seed.sh: the remote-copy rewrite loop now also maps the parent-absolute steering inbox (<FM_HOME>/state/<id>.inbox) to the host-local <REMOTE_HOME>/state/parent-route/<id>.inbox, alongside the existing reply-log rewrite. Each substitution is a plain line=${line//...} assignment instead of a quoted substitution nested inside the printf argument, which on macOS bash 3.2 leaked literal quote characters into rewritten lines.
  • tests/fm-remote-secondmate-lifecycle-e2e.test.sh: introduces a single PARENT_ROUTE_INBOX fixture, reuses it for the existing inbox record and chmod checks, and adds three charter-render assertions: the host-local inbox path is present, the parent-absolute inbox path is absent, and the NNN.msg -> handled/ acknowledgement move is rendered host-local.
  • docs/remote-secondmates.md: documents that the remote charter names its steering inbox as state/parent-route/<id>.inbox in the remote home, the surface the routed transport writes to.

Risk Assessment

✅ Low: A two-line whole-string rewrite extension in one render loop plus fixed-string assertions over the generated remote charter; the parent status and inbox patterns are disjoint so the rewrites are order-independent, the unquoted assignment form sidesteps the bash 3.2 quote leak, and every inbox mention the brief template emits (bare, /*.msg, mv NNN.msg handled/) is covered.

Testing

Ran the full tests/fm-remote-secondmate-lifecycle-e2e.test.sh under /bin/bash 3.2.57 on the fixed code (ALL TESTS PASSED, ~9.6 min), then built two throwaway copies of the tree outside the worktree, one with the base-commit seed script and one with the fix, and drove the seed section of the e2e test against each while capturing the generated remote charter. On the old code the new host-local-inbox assertion fails, and evaluating all three new assertions against the captured old render shows every one failing; the old render also visibly contains the bash 3.2 quote leak ('"…"'). On the fixed code all three assertions pass, the charter contains four host-local inbox mentions and zero parent-absolute ones, has no leaked quote sequences, and equals the parent brief with the two paths rewritten by an independent Python substitution. A standalone bash 3.2.57 reproduction confirms the old quoted-substitution pattern leaks quotes while the plain-assignment pattern does not. No UI surface exists; artifacts are CLI logs and the generated charter files. Lab copies were removed and the worktree is clean.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Captain seeds a remote secondmate home; the published remote charter names the host-local steering inbox state/parent-route/<id>.inbox in every mention (bare path, /*.msg listing, handled/ acknowledge… ✅ pass live fixed/remote-charter.md lines 42-43; charter-assertion-matrix.txt (fixed: 3 PASS); seed-section-fixed-code.log
The remote charter contains no parent-absolute <FM_HOME>/state/<id>.inbox path the remote mate cannot reach ✅ pass live charter-exact-render-check.txt: fixed charter mentions of parent-absolute inbox: 0; assertion matrix 'parent-absolute inbox absent: PASS'
Regression proof: the three new charter assertions fail against the base-commit seed script and pass with the fix, both on bash 3.2.57 ✅ pass live old/seed-section-old-code.log ends 'not ok - remote charter did not name its host-local steering inbox'; charter-assertion-matrix.txt shows old 3 FAIL / fixed 3 PASS
Adversarial: on macOS bash 3.2.57 the rewritten charter lines carry no leaked literal quote characters and are byte-identical to the brief with only the two paths replaced ✅ pass live fixed/charter-exact-render-check.txt (equality True, leak False); old/remote-charter.md line 22 shows '"…parent-replies.status"' leak on old code; bash32-quote-leak-repro.txt
Existing reply-log rewrite still lands host-local (state/parent-replies.status) alongside the new inbox rewrite ✅ pass live fixed/remote-charter.md lines 22 and 49; e2e-fixed-bash3.2.log 'remote seed registers the route and provisions the whole home and project clone on that host'
A steer sent to the remote mate is recorded as a .msg in the same parent-route inbox the charter names, and the full remote lifecycle (spawn, send, config push, retire) still passes ✅ pass live e2e-fixed-bash3.2.log: ALL TESTS PASSED; the test's single PARENT_ROUTE_INBOX fixture drives both the charter assertions and the fm-send record-count checks
Evidence: Rendered remote charter, fixed code (host-local inbox and reply log, no leaked quotes)

Source: Rendered remote charter, fixed code (host-local inbox and reply log, no leaked quotes)

You are a persistent second mate managed by the main firstmate. Work on your own; do not wait for a human.

# Charter
Own iOS delivery on the build Mac.

# Routing scope
iOS implementation and Xcode validation

# Project clones
- alpha

# Operating model
You are in an isolated firstmate home. The local `AGENTS.md` is your job description, and your local `data/`, `state/`, `config/`, and `projects/` dirs are yours to operate.
The projects above are local clones for work you supervise; they are not an exclusive ownership claim.
Delegate project work to your own crewmates with the normal firstmate lifecycle: brief, spawn, status, watcher, steer, teardown, and recovery.
Do not invent a second delegation system.
You do not generate your own work.
Act only on tasks the main firstmate routes to you.
Never start a survey, audit, or "find improvements" sweep on your own initiative; that is not your job and it is unwanted.

# The captain and the parent channel
Nobody reads this chat: the captain and the main firstmate see only what is appended to '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-replies.status', and a captain-facing sentence that is not appended there has not been sent.
That file is your parent channel, and in this home it IS the captain: every sentence you would say to the captain, and every outcome the local AGENTS.md tells a firstmate to bring to the captain, is one appended line there, never chat.
Your own machinery publishes the durable facts about your crew's work for you (`bin/fm-parent-channel-lib.sh`): a child's terminal done or failed line with its note and PR on every supervision poll, a PR-ready line when you register a PR, a task you hold for the captain and its answer, a merge, and a child's final line at cleanup all reach the parent channel from the scripts that record them, whether or not you append anything.
What only you can append is judgement: the answer to a marked request below, a recommendation or caveat on a delivered outcome, a blocker or failure of your own, and anything else you would otherwise say to the captain.

# Requests from the main firstmate
You are a firstmate in your own home, so an incoming message reaches you in your own chat.
You must distinguish who it is from, because the answer goes to a different place.
A request relayed to you by the main firstmate is tagged with a leading `[fm-from-firstmate]` marker followed by an invisible system separator; this marker is untypable, so a human never produces it.
When a message carries that marker, do the work, then respond via the STATUS/ESCALATION path below, never only in this chat: the main firstmate does not read your chat, so a chat-only reply is lost.
Marked requests also carry a privacy-safe `corr=<id>` token after the marker; include that exact token in your parent status reply (or in the status pointer to a detailed doc) so the parent can correlate the answer.
Optional helper: `bin/fm-secondmate-report.sh <verb> <corr_id> <note>` appends that correlated line to the parent channel itself - do not pass a status path, and do not write a hand path under this home.
A plain `echo` that includes the same `corr=<id>` on this parent channel is equally valid; do not depend on the helper being present.
For a terse result, a status line is the whole answer.
For a detailed answer (an investigation, a plan, an audit), write it to a doc under your home's `data/` and append a status line that points to that doc - the scout-report pattern - so the main firstmate is woken and can read it.
Before treating an investigation or visual review as complete, load `captain-hold-lifecycle` from this home's `.agents/skills/` and pass its shared completion gate.
A message with NO marker is the captain typing directly into your pane: treat it as authoritative captain intervention and stay conversational exactly as you would for any captain message; do not force it onto the status path.
A request arriving through the instruction inbox below follows the same marker and reply rules.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'/NNN.msg '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'/handled/`.
The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.

# Escalation to main firstmate
Handle routine work yourself.
Report only true captain-relevant outcomes or a declared external wait by appending one line:
   `echo "{state} [at=<epoch>]: {one short line}" >> '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-replies.status'`
States: working, needs-decision, blocked, paused, done, failed.
Substitute `<epoch>` with the current Unix time in seconds - run `date +%s` and write the number it printed; a stamp that is not plain digits records no time at all.
Use `paused: {why}` (distinct from `blocked:`) only when your domain is deliberately idling on a known external wait you expect to clear on its own, naming when it clears with `until <YYYY-MM-DDTHH:MMZ>` (UTC) when you know; use `blocked:` when you are stuck and need firstmate to act.
Use this only for material phase changes, a captain decision, a real blocker, a failure, work ready for review, or work you landed.
Work you landed includes a merge you performed yourself under standing merge authority and one the captain merged on the forge: under that authority nothing is ever \"ready for review\", so a landed merge that goes unreported reaches the captain as silence.
This is also how you return the answer to a marked from-firstmate request above.
A marked request requires one correlated answer after the work; it does not require a separate receipt or start acknowledgement.
Never append `working:` merely to acknowledge receipt or announce that a marked request has started.
When a routed-work phase has a supervisor-actionable material change worth reporting under the rule above, give that reported phase a stable key.
If its first reportable event is `working [key=<work-slug>]: {material phase}`, use the same key on its later `paused`, `done`, `failed`, `needs-decision`, or `blocked` event so the earlier working phase is superseded.
When a keyed phase ends without another reportable state, append `resolved [key=<work-slug>] [at=<epoch>]: {why it is no longer active}`.
`resolved` separately closes an escalated decision or blocker, and only a `resolved` line carrying that decision's exact key closes it: a later `done` or `working` event never does, even when the answer is what started that work.
The main firstmate's answer normally writes that closing line at answer time; when a blocker or wait clears WITHOUT an answer from the main firstmate, append `resolved [at=<epoch>]: {how it cleared}` yourself (keyed with `[key=<slug>]` if you opened it with one) as your domain resumes.
Routine internal supervision, heartbeats, retries, and crewmate churn stay inside your own home and must not touch that status file.

# Definition of done
You are persistent by default. Do not exit just because your queue is empty.
On startup and restart, run normal firstmate bootstrap and recovery through `bin/fm-session-start.sh` for your own home, but only to RECONCILE work that is already yours: in-flight crewmates, tracked backlog items, and durable watches recorded in this home.
When you have no assigned or in-flight work after that reconciliation, go idle and wait silently for the main firstmate to route you a task.
An empty queue is a healthy resting state, not a cue to invent work: never spawn a survey, audit, or any self-directed "find work" task on your own initiative.
If this charter cannot be carried out, append `blocked [at=<epoch>]: {why}` or `failed [at=<epoch>]: {why}` to the main status file and stop.
Evidence: Rendered remote charter, old code (parent-absolute inbox, leaked quotes around reply log)

Source: Rendered remote charter, old code (parent-absolute inbox, leaked quotes around reply log)

You are a persistent second mate managed by the main firstmate. Work on your own; do not wait for a human.

# Charter
Own iOS delivery on the build Mac.

# Routing scope
iOS implementation and Xcode validation

# Project clones
- alpha

# Operating model
You are in an isolated firstmate home. The local `AGENTS.md` is your job description, and your local `data/`, `state/`, `config/`, and `projects/` dirs are yours to operate.
The projects above are local clones for work you supervise; they are not an exclusive ownership claim.
Delegate project work to your own crewmates with the normal firstmate lifecycle: brief, spawn, status, watcher, steer, teardown, and recovery.
Do not invent a second delegation system.
You do not generate your own work.
Act only on tasks the main firstmate routes to you.
Never start a survey, audit, or "find improvements" sweep on your own initiative; that is not your job and it is unwanted.

# The captain and the parent channel
Nobody reads this chat: the captain and the main firstmate see only what is appended to '"/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/remote-home/state/parent-replies.status"', and a captain-facing sentence that is not appended there has not been sent.
That file is your parent channel, and in this home it IS the captain: every sentence you would say to the captain, and every outcome the local AGENTS.md tells a firstmate to bring to the captain, is one appended line there, never chat.
Your own machinery publishes the durable facts about your crew's work for you (`bin/fm-parent-channel-lib.sh`): a child's terminal done or failed line with its note and PR on every supervision poll, a PR-ready line when you register a PR, a task you hold for the captain and its answer, a merge, and a child's final line at cleanup all reach the parent channel from the scripts that record them, whether or not you append anything.
What only you can append is judgement: the answer to a marked request below, a recommendation or caveat on a delivered outcome, a blocker or failure of your own, and anything else you would otherwise say to the captain.

# Requests from the main firstmate
You are a firstmate in your own home, so an incoming message reaches you in your own chat.
You must distinguish who it is from, because the answer goes to a different place.
A request relayed to you by the main firstmate is tagged with a leading `[fm-from-firstmate]` marker followed by an invisible system separator; this marker is untypable, so a human never produces it.
When a message carries that marker, do the work, then respond via the STATUS/ESCALATION path below, never only in this chat: the main firstmate does not read your chat, so a chat-only reply is lost.
Marked requests also carry a privacy-safe `corr=<id>` token after the marker; include that exact token in your parent status reply (or in the status pointer to a detailed doc) so the parent can correlate the answer.
Optional helper: `bin/fm-secondmate-report.sh <verb> <corr_id> <note>` appends that correlated line to the parent channel itself - do not pass a status path, and do not write a hand path under this home.
A plain `echo` that includes the same `corr=<id>` on this parent channel is equally valid; do not depend on the helper being present.
For a terse result, a status line is the whole answer.
For a detailed answer (an investigation, a plan, an audit), write it to a doc under your home's `data/` and append a status line that points to that doc - the scout-report pattern - so the main firstmate is woken and can read it.
Before treating an investigation or visual review as complete, load `captain-hold-lifecycle` from this home's `.agents/skills/` and pass its shared completion gate.
A message with NO marker is the captain typing directly into your pane: treat it as authoritative captain intervention and stay conversational exactly as you would for any captain message; do not force it onto the status path.
A request arriving through the instruction inbox below follows the same marker and reply rules.

# Firstmate instruction inbox
Firstmate steers you through durable message files in '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'.
When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'/NNN.msg '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'/handled/`.
The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.

# Escalation to main firstmate
Handle routine work yourself.
Report only true captain-relevant outcomes or a declared external wait by appending one line:
   `echo "{state} [at=<epoch>]: {one short line}" >> '"/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/remote-home/state/parent-replies.status"'`
States: working, needs-decision, blocked, paused, done, failed.
Substitute `<epoch>` with the current Unix time in seconds - run `date +%s` and write the number it printed; a stamp that is not plain digits records no time at all.
Use `paused: {why}` (distinct from `blocked:`) only when your domain is deliberately idling on a known external wait you expect to clear on its own, naming when it clears with `until <YYYY-MM-DDTHH:MMZ>` (UTC) when you know; use `blocked:` when you are stuck and need firstmate to act.
Use this only for material phase changes, a captain decision, a real blocker, a failure, work ready for review, or work you landed.
Work you landed includes a merge you performed yourself under standing merge authority and one the captain merged on the forge: under that authority nothing is ever \"ready for review\", so a landed merge that goes unreported reaches the captain as silence.
This is also how you return the answer to a marked from-firstmate request above.
A marked request requires one correlated answer after the work; it does not require a separate receipt or start acknowledgement.
Never append `working:` merely to acknowledge receipt or announce that a marked request has started.
When a routed-work phase has a supervisor-actionable material change worth reporting under the rule above, give that reported phase a stable key.
If its first reportable event is `working [key=<work-slug>]: {material phase}`, use the same key on its later `paused`, `done`, `failed`, `needs-decision`, or `blocked` event so the earlier working phase is superseded.
When a keyed phase ends without another reportable state, append `resolved [key=<work-slug>] [at=<epoch>]: {why it is no longer active}`.
`resolved` separately closes an escalated decision or blocker, and only a `resolved` line carrying that decision's exact key closes it: a later `done` or `working` event never does, even when the answer is what started that work.
The main firstmate's answer normally writes that closing line at answer time; when a blocker or wait clears WITHOUT an answer from the main firstmate, append `resolved [at=<epoch>]: {how it cleared}` yourself (keyed with `[key=<slug>]` if you opened it with one) as your domain resumes.
Routine internal supervision, heartbeats, retries, and crewmate churn stay inside your own home and must not touch that status file.

# Definition of done
You are persistent by default. Do not exit just because your queue is empty.
On startup and restart, run normal firstmate bootstrap and recovery through `bin/fm-session-start.sh` for your own home, but only to RECONCILE work that is already yours: in-flight crewmates, tracked backlog items, and durable watches recorded in this home.
When you have no assigned or in-flight work after that reconciliation, go idle and wait silently for the main firstmate to route you a task.
An empty queue is a healthy resting state, not a cue to invent work: never spawn a survey, audit, or any self-directed "find work" task on your own initiative.
If this charter cannot be carried out, append `blocked [at=<epoch>]: {why}` or `failed [at=<epoch>]: {why}` to the main status file and stop.
Evidence: New assertions evaluated against old vs fixed renders

Source: New assertions evaluated against old vs fixed renders

-- individual new assertions against old render -- host-local inbox present: FAIL parent-absolute inbox absent: FAIL (still present) ack move rendered host-local: FAIL -- individual new assertions against fixed render -- host-local inbox present: PASS parent-absolute inbox absent: PASS ack move rendered host-local: PASS

===== old render: inbox / status lines in remote charter =====
22:Nobody reads this chat: the captain and the main firstmate see only what is appended to '"/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/remote-home/state/parent-replies.status"', and a captain-facing sentence that is not appended there has not been sent.
39:A request arriving through the instruction inbox below follows the same marker and reply rules.
41:# Firstmate instruction inbox
42:Firstmate steers you through durable message files in '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'.
43:When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'/NNN.msg '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/parent/state/ios.inbox'/handled/`.
44:The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.
49:   `echo "{state} [at=<epoch>]: {one short line}" >> '"/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.fmU9Kz/remote-home/state/parent-replies.status"'`

-- individual new assertions against old render --
host-local inbox present: FAIL
parent-absolute inbox absent: FAIL (still present)
ack move rendered host-local: FAIL

===== fixed render: inbox / status lines in remote charter =====
22:Nobody reads this chat: the captain and the main firstmate see only what is appended to '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-replies.status', and a captain-facing sentence that is not appended there has not been sent.
39:A request arriving through the instruction inbox below follows the same marker and reply rules.
41:# Firstmate instruction inbox
42:Firstmate steers you through durable message files in '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'.
43:When a terminal message says an instruction is waiting there - and at any natural checkpoint when you are unsure - list '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'/*.msg, read and act on each message in numeric order, then acknowledge each handled message by moving it: `mv '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'/NNN.msg '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-route/ios.inbox'/handled/`.
44:The move IS the acknowledgement: without it firstmate rings again and eventually treats you as stuck. An empty or absent inbox needs no action.
49:   `echo "{state} [at=<epoch>]: {one short line}" >> '/private/var/folders/lw/83_wpdv92g5ff57h6hflw6wr0000gp/T/fm-remote-secondmate-e2e.U2CO6C/remote-home/state/parent-replies.status'`

-- individual new assertions against fixed render --
host-local inbox present: PASS
parent-absolute inbox absent: PASS
ack move rendered host-local: PASS
Evidence: Exact render check (fixed charter equals independent rewrite, no quote leak)

Source: Exact render check (fixed charter equals independent rewrite, no quote leak)

fixed charter == parent brief with the two paths rewritten (independent python rewrite): True fixed charter contains leaked '"' or '"' quote sequences: False old charter contains leaked '"' quote sequences (bash 3.2 leak): True fixed charter mentions of host-local inbox: 4 fixed charter mentions of parent-absolute inbox: 0 old charter still mentions parent-absolute inbox: True count= 4

fixed charter == parent brief with the two paths rewritten (independent python rewrite): True
fixed charter contains leaked '"' or '"' quote sequences: False
old charter contains leaked '"' quote sequences (bash 3.2 leak): True
old charter still mentions parent-absolute inbox: False
fixed charter mentions of host-local inbox: 4
fixed charter mentions of parent-absolute inbox: 0
CORRECTION (old run's own PARENT path): old charter still mentions parent-absolute inbox: True count= 4
Evidence: bash 3.2.57 quote-leak reproduction (old pattern vs plain assignment)

Source: bash 3.2.57 quote-leak reproduction (old pattern vs plain assignment)

bash: 3.2.57(1)-release input : Append replies to '/fm/state/ios.status' when done. old pattern: Append replies to '"/fm/state/parent-replies.status"' when done. new pattern: Append replies to '~/fm/state/parent-replies.status' when done. old pattern: MISMATCH (leaked quote characters) new pattern: exact match

bash: 3.2.57(1)-release
input      : Append replies to '~/fm/state/ios.status' when done.
old pattern: Append replies to '"~/fm/state/parent-replies.status"' when done.
new pattern: Append replies to '~/fm/state/parent-replies.status' when done.
old pattern: MISMATCH (leaked quote characters)
new pattern: exact match
Evidence: Seed-section run on old code (new assert fails)

Source: Seed-section run on old code (new assert fails)

ok - overlapping remote home provisioning serializes through publication and rollback
ok - remote seed rollback preserves serialized competing routes
ok - unknown readiness preserves its route and brief for reconciliation
ok - remote seeding checks, repairs, and re-checks readiness, then stops on a remaining gap
ok - remote seeding proceeds once the repair closes every gap
ok - remote seeding provisions a supplied origin without touching the primary project tree
ok - remote provisioning re-validates a supplied origin at the receiving host
ok - seeding carries bitbucket, self-hosted, and scp-like origins through to the remote clone
not ok - remote charter did not name its host-local steering inbox
Evidence: Seed-section run on fixed code (passes)

Source: Seed-section run on fixed code (passes)

ok - overlapping remote home provisioning serializes through publication and rollback
ok - remote seed rollback preserves serialized competing routes
ok - unknown readiness preserves its route and brief for reconciliation
ok - remote seeding checks, repairs, and re-checks readiness, then stops on a remaining gap
ok - remote seeding proceeds once the repair closes every gap
ok - remote seeding provisions a supplied origin without touching the primary project tree
ok - remote provisioning re-validates a supplied origin at the receiving host
ok - seeding carries bitbucket, self-hosted, and scp-like origins through to the remote clone
ok - remote seed registers the route and provisions the whole home and project clone on that host
Evidence: Full remote secondmate lifecycle e2e on fixed code, bash 3.2.57

Source: Full remote secondmate lifecycle e2e on fixed code, bash 3.2.57

FM_TEST_BEGIN 2026-09-21T00:07:01Z tests/fm-remote-secondmate-lifecycle-e2e.test.sh family=secondmate expected_gate_skip=none
ok - overlapping remote home provisioning serializes through publication and rollback
ok - remote seed rollback preserves serialized competing routes
ok - unknown readiness preserves its route and brief for reconciliation
ok - remote seeding checks, repairs, and re-checks readiness, then stops on a remaining gap
ok - remote seeding proceeds once the repair closes every gap
ok - remote seeding provisions a supplied origin without touching the primary project tree
ok - remote provisioning re-validates a supplied origin at the receiving host
ok - seeding carries bitbucket, self-hosted, and scp-like origins through to the remote clone
ok - remote seed registers the route and provisions the whole home and project clone on that host
ok - remote inheritance rejects incomplete and superseded payload generations
ok - mixed local and remote routes validate without migration
ok - remote spawn launches on the remote-local backend and records a host-qualified route
ok - legacy and mismatched remote endpoints fail closed before backend access
ok - non-herdr remote endpoints are refused without changing either route
ok - remote spawn serializes inheritance through launch publication
cannot retire terminal source; it remains registered: remote-reply-ios
ok - marked send and routed reply complete through the existing parent correlation owner
cannot retire terminal source; it remains registered: remote-reply-ios
ok - partial remote inheritance retains reread intent through bootstrap convergence
ok - config push and bootstrap serialize remote inheritance convergence
cannot retire terminal source; it remains registered: remote-reply-ios
ok - remote inherited config retains and retries a failed live reread nudge
cannot retire terminal source; it remains registered: remote-reply-ios
cannot retire terminal source; it remains registered: remote-reply-ios
cannot retire terminal source; it remains registered: remote-reply-ios
ok - fleet snapshot projects mixed local and remote structured state
ok - remote update imports and fast-forwards the persistent home on its configured host
ok - the remote restart verb delegates to the host-local control plane and refuses before stopping anything
ok - startup repairs remote readiness before probing without relaunching
ok - the host-local state read steps around a stale shadowing herdr client
ok - startup reports alive legacy backends without changing their routes
ok - unreachable no-ledger remote state remains explicit with no local respawn or failover
cannot retire terminal source; it remains registered: remote-reply-ios
ok - remote retirement refuses child work, then removes only its own endpoint while a shared-session sibling survives
ALL TESTS PASSED
FM_TEST_END 2026-09-21T00:16:39Z tests/fm-remote-secondmate-lifecycle-e2e.test.sh exit=0 duration_ms=578467 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=578588
FM_TEST_SUMMARY_FAMILY family=secondmate count=1 duration_ms=578467 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-remote-secondmate-lifecycle-e2e.test.sh duration_ms=578467
/bin/bash bin/fm-test-run.sh tests/fm-remote-secondmate-lifecycle-e2e.test.sh  98.44s user 201.89s system 51% cpu 9:38.63 total

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 6 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Captain seeds a remote secondmate home; the published remote charter names the host-local steering inbox state/parent-route/<id>.inbox in every mention (bare path, /*.msg listing, handled/ acknowledge… ✅ pass live fixed/remote-charter.md lines 42-43; charter-assertion-matrix.txt (fixed: 3 PASS); seed-section-fixed-code.log
The remote charter contains no parent-absolute <FM_HOME>/state/<id>.inbox path the remote mate cannot reach ✅ pass live charter-exact-render-check.txt: fixed charter mentions of parent-absolute inbox: 0; assertion matrix 'parent-absolute inbox absent: PASS'
Regression proof: the three new charter assertions fail against the base-commit seed script and pass with the fix, both on bash 3.2.57 ✅ pass live old/seed-section-old-code.log ends 'not ok - remote charter did not name its host-local steering inbox'; charter-assertion-matrix.txt shows old 3 FAIL / fixed 3 PASS
Adversarial: on macOS bash 3.2.57 the rewritten charter lines carry no leaked literal quote characters and are byte-identical to the brief with only the two paths replaced ✅ pass live fixed/charter-exact-render-check.txt (equality True, leak False); old/remote-charter.md line 22 shows '"…parent-replies.status"' leak on old code; bash32-quote-leak-repro.txt
Existing reply-log rewrite still lands host-local (state/parent-replies.status) alongside the new inbox rewrite ✅ pass live fixed/remote-charter.md lines 22 and 49; e2e-fixed-bash3.2.log 'remote seed registers the route and provisions the whole home and project clone on that host'
A steer sent to the remote mate is recorded as a .msg in the same parent-route inbox the charter names, and the full remote lifecycle (spawn, send, config push, retire) still passes ✅ pass live e2e-fixed-bash3.2.log: ALL TESTS PASSED; the test's single PARENT_ROUTE_INBOX fixture drives both the charter assertions and the fm-send record-count checks
  • /bin/bash bin/fm-test-run.sh tests/fm-remote-secondmate-lifecycle-e2e.test.sh on bash 3.2.57 (fixed code, full lifecycle: ALL TESTS PASSED)
  • Seed-section of the e2e test (lines 1-675 plus a charter-capture hook) run against a tree copy with the base-commit bin/fm-remote-home-seed.sh: fails at not ok - remote charter did not name its host-local steering inbox
  • Same seed-section run against the fixed tree copy: passes remote seed registers the route and provisions the whole home and project clone on that host
  • Per-assertion matrix over the captured old and fixed data/charter.md renders: host-local inbox present, parent-absolute inbox absent, ack move rendered host-local (old: 3 FAIL, fixed: 3 PASS)
  • Python exact-equality check: fixed remote charter == parent brief with status and inbox paths rewritten; no &#39;&#34; / &#34;&#39; quote leaks; old render contains the leak
  • Standalone bash 3.2.57 reproduction of the quoted-substitution quote leak versus the plain-assignment rewrite
✅ **Document** - passed

✅ No issues found.

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

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

First look on main a09090d13ef24ce3cf71d171ade119896d6db301. Tip 5934b6f469dc73106cd9324ce89642d61cdc8c3c. Attestation MISSING (no no-mistakes-pipeline-attestation in body). Tip NM/CI were action_required — workflow-approved 2 (CI 35527698234, Require no-mistakes 35527698262); checks now queued. MERGEABLE / UNSTABLE. Closes #5012 verified (author body Closes #5012; issue open ready-for-pr restore — tip maps host-local parent-route/<id>.inbox in the remote charter seed rewrite the same way reply-log already was). No auto-merge. Waiting on author to attach a matching no-mistakes attestation (and for CI/NM to finish green). Do not flag Firstmate while attestation is missing.

What I inspected

  • bin/fm-remote-home-seed.sh: adds PARENT_INBOX → REMOTE_INBOX whole-string rewrite alongside the existing status rewrite; plain assignments avoid macOS bash 3.2 quote leak inside printf.
  • tests/fm-remote-secondmate-lifecycle-e2e.test.sh: pins host-local inbox present, parent-absolute inbox absent, and handled/ acknowledgement move; shares one fixture with delivery checks.
  • Unconfigured remote seed path: charter published to the mate now names the control-plane host-local inbox docs already specify (docs/remote-secondmates.md / control-plane send).

VISION.md (each rule)

  • One captain, one interface: aligns — mate no longer burns a turn filing blocked for a render defect.
  • Authority is explicit: aligns — restores the already-specified host-local remote surfaces; no new autonomy grant.
  • Scripts own the mechanics: aligns — deterministic path rewrite in seed script + e2e pins.
  • A restart is a non-event: aligns — durable charter render on provision.
  • Delegation with a spine: aligns — remote secondmate can follow the inbox contract it was given.
  • The fleet outlives any vendor: aligns — control-plane / host-local path contract, not harness-specific.
  • Scope: aligns — command-layer remote secondmate provisioning.

contract-class: restore. Reply-log rewrite already existed on main; inbox was the missing half of the same specified remote surface. No auto-merge until MATCH attestation + green CI + NM SUCCESS.

Security FYI (not waiting-captain): path rewrite only; no new network/exec surface; tip only.

A freshly provisioned remote secondmate read a parent-home absolute
steering-inbox path in its charter - a location that exists on no route -
and spent its first turn discovering the gap and filing a blocked
decision for what was a render defect. The seed's remote-copy rewrite now
maps the inbox to the route's host-local parent-route inbox, exactly as
it already maps the reply-log path, so every mention - bare path, listing,
and handled/ acknowledgement - lands host-local.

Both rewrites also become plain assignments, because a quoted substitution
nested inside a double-quoted printf argument leaks literal quotes into
the replacement text on stock macOS bash. The lifecycle suite pins the
corrected render both directions against the real seed, provisioning,
and delivery route, sharing one fixture value between the render truth
and the delivery truth.

Closes kunchenguid#5012
@kesslerio
kesslerio force-pushed the fix/remote-brief-host-local-paths branch from 5934b6f to cc97c49 Compare September 21, 2026 01:21
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: re-triage on #5049 (kesslerio). Whole thread read (prior stamp waiting-author attestation-MISSING; tip now has MATCH attestation + docs commit). Tip vs main dee119b41e1664d7903f34d170e89987b88957cb.

HEAD: cc97c4900499d1e501938dbf3268389449a31c8c
Attestation: MATCH (body binds tip).
mergeable: MERGEABLE / UNSTABLE (required CI still running).
CI/NM: Require no-mistakes SUCCESS (35554245763 edited-event, after synchronize payload lacked body). CI 35550658899 in_progress (Lint/Behavior shards running after workflow approve).

Contract-class: restore (own verdict)

  • Main bin/fm-remote-home-seed.sh only rewrites parent status → host-local parent-replies.status; inbox path stays parent-absolute $STATE/$ID.inbox.
  • Tip adds the missing half of the already-specified remote surface: PARENT_INBOX → REMOTE_INBOX (state/parent-route/<id>.inbox) with plain assignments (bash 3.2 quote-leak fix) + e2e pins + docs line.
  • Unconfigured remote seed path: charter published to the mate now names the control-plane host-local inbox docs already specify. Not a new default-on surface.

VISION (per-rule, tip vs main inspected):

  1. One captain/interface — aligns (mate no longer burns a turn filing blocked for a render defect).
  2. Authority explicit — aligns (restores already-specified host-local remote surfaces; no new autonomy grant).
  3. Scripts/mechanics — aligns (deterministic path rewrite in seed script + e2e pins).
  4. Restart non-event — aligns (durable charter render on provision).
  5. Delegation spine — aligns (remote secondmate can follow the inbox contract it was given).
  6. Fleet outlives vendor — aligns (control-plane / host-local path contract).
  7. Scope — aligns (command-layer remote secondmate provisioning).

Security skim: path rewrite only; no new network/exec/workflow surface. Not a security withhold.

Closes: body/intent closes #5012 verified (issue open ready-for-pr restore).

Outcome: waiting-ci. Auto-merge eligible when CI greens (restore + MATCH + NM SUCCESS + safe review). Firstmate flag no while CI unresolved. workflow-approved this pass: NM 35554245763 (+ stale-head NM 35553945584/35553477611; earlier CI/NM 35550658899/35550658913).

@kunchenguid
kunchenguid merged commit 804394e into kunchenguid:main Sep 21, 2026
19 of 21 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @kesslerio — really appreciate you taking the time on this.

HEAD merged: cc97c4900499d1e501938dbf3268389449a31c8c → squash 804394e8b6b6ca0ab98a635c24957dd11a78f0c7
Attestation: MATCH · CI+NM: SUCCESS · contract-class: restore (host-local remote steering-inbox rewrite — missing half of the already-specified remote charter surface).
Closes: #5012 verified.

dscott98 added a commit to Simplifying-Cloud/firstmate that referenced this pull request Sep 21, 2026
* fix(bin): preserve Claude lock ownership after helper recycling (kunchenguid#4894)

* fix(bin): let a background Claude session keep owning its session lock

Session-lock ownership was decided by process ancestry alone. Under an
unattended Claude session the model loop runs in a transient bg-spare
bridged to the front-end by a shared daemon; when that bridge is
recycled the contiguous claude-named ancestry from a hook to the
recorded owner breaks while the owner pid stays alive, so the Stop
auto-arm stood down as a foreign live owner, the turn-end guard ended
every turn with its read-only diagnostic, and fm-lock.sh refused - a
self-sustaining outage until restart.

Ownership is now ancestry membership OR a trusted same-session id,
never id-first:

- fm-session-lock-lib.sh accepts CLAUDE_CODE_SESSION_ID only when
  CLAUDE_PID is a Claude-shaped member of the current contiguous run,
  compares it against the id recorded in state/.lock-session, and
  requires the recorded pid to still be a live harness. No id, no
  sidecar, an untrusted id, a different id, or a dead recorded pid
  leaves the ancestry verdict unchanged. Ids are never read from ps
  argv.
- fm-lock.sh accepts a same-session holder at both refusal sites,
  writes, refreshes, and clears the sidecar only under its claim lock
  (including the early already-mine exit, skipped only while the
  deferred startup sweep leases that lock), keeps it byte-identical
  across a same-session confirmation, records CLAUDE_PID on lock line 1
  for a session with a trusted id so a shared daemon or front-end that
  outlives the session never keeps a dead session's lock alive, never
  rewrites a live line 1 on a same-session confirmation, and names the
  recorded id in the live-owner refusal.
- The .lock line-1 format is unchanged, so every reader that takes the
  whole first line as the pid keeps working; the guard's foreign-owner
  exit is unchanged and inherits the fix through the shared predicate.

Tests: the ancestry suite drives the ancestry and id signals apart in a
deterministic process table (asserting the divergence) and runs a real
orphaned front-end/daemon/pty-host/spare tree through six phases with
the real lock, auto-arm, and guard scripts; the foreign-owner repro
keeps its negative control and adds a same-id positive control.

Disclosure: no live unattended Claude background session ran on the
verifying machine. The topology is documented by the real process
listings in kunchenguid#3902, kunchenguid#2314, kunchenguid#3398, and kunchenguid#4066; coverage is the structural
predicate plus the executable fixtures, not a live pass.

Residual: bin/fm-sessionstart-nudge.sh keeps its own private ancestry
walk (it only decides whether to print a nudge) and may nudge on a
resume in the recycled case.

Out of scope, deliberately: no structured lock format, no guard budget
changes, no daemon-identity rejection, no fork lineage.

* no-mistakes(review): Wait for claim lock; revert failed sidecars

* no-mistakes(review): Revalidate ownership after wait; restore sidecars

* no-mistakes(review): Roll back sidecar by publication phase

* no-mistakes(review): Restore sidecar only if lock line is unchanged

* no-mistakes(review): Trust session ids without a spelling allowlist

* no-mistakes(review): Disarm sidecar rollback before backup cleanup

* no-mistakes(document): Updated session-lock ownership documentation

* feat: park main under the away posture on Pi (kunchenguid#4889)

* feat: park main under the away posture on Pi

While the away-posture record exists on a Pi primary, the supervision branch
takes every actionable wake, no processing turn opens on main, captain rows
accumulate for the return brief, and main's standing authority relocates to
the branch through the existing guarded scripts.

- lib/fm-branch-dispatch.ts: read the record at every routing decision; while
  it exists claim check, decision-owned, and heartbeat rows too, keeping the
  two broken-queue vetoes; expose checkSeqs so a claimed check row lifts task
  scoping.
- fm-primary-pi-watch.ts: offer every actionable row under the record; a
  declined wake and every watcher-failure alarm still reach main.
- fm-branch-supervision.ts: drop the legacy .afk decline; append a fixed
  POSTURE: AWAY tail carrying the record's read-back verbatim per wake; open no
  processing request while the record exists, re-checked immediately before a
  request would open and at every run boundary; present the accumulated rows
  at the first run boundary after archive.
- fm-lease-lib.sh: fm_lease_forbid_branch passes the branch for opted-in
  actions only while fm-afk-contract.sh validate succeeds on a confirmed live
  record; PR merge, fresh spawn, and decision answer opt in, local landing
  never does.
- fm-send.sh: a --resolve-key naming an open needs-decision or captain-held
  task is a decision answer and meets the partition; blocked: keys stay
  steering.
- fm-spawn.sh: enforce the record's spend cap for a fresh ordinary spawn by
  either actor; relaunches and secondmates exempt.
- fm-branch-prompt.sh: fixed Postures section and the verbatim
  ask-user-authority policy; the prefix stays byte-stable.
- fm-afk-return.sh: count what the away session handled from the store.
- docs, afk skill, AGENTS.md stub: main parked on Pi, green merge gate
  absolute while away.
- tests: watcher and branch extension suites, fleet-record, merge, and
  decision-answer suites cover the relocation, the vetoes, the tail, the
  parked processing turn, the cancellation, the re-presentation, and the
  spend cap; dated live-guard evidence recorded.

* no-mistakes(review): Refuse branch merge after preflight archive race

* no-mistakes(review): Fix away wake, spawn, and processing races

* no-mistakes(review): Suppress parked processing; narrow away-only rejection

* no-mistakes(review): Abort dedicated processing; gate branch spawn once

* no-mistakes(review): Stamp away-only on the dispatch offer

* no-mistakes(review): Treat invalid away records as spend-cap absence

* no-mistakes(review): Drop spawn test hook; abort processing-opened runs

* no-mistakes(review): Bind abort to opening prompt; cap-read absence

* no-mistakes(review): Limit away branch spawn to queued work only

* no-mistakes(document): Correct AFK posture documentation

* ci: standardize workflow timeouts into three tiers (kunchenguid#4910)

* ci: simplify CI job timeouts to a three-tier policy

Replace the scattered per-job timeout values (10m parallel, 25m lint, 30m
serial, 10m macOS) with three readable tiers, each a hang tripwire with
headroom rather than a packing estimate:

- fast (5m): coverage guard, repo invariants, timing aggregate
- normal (30m, one shared budget): lint partitions, portable parallel
  shards, portable serial shards, macOS stock Bash
- heavy (Herdr only): 20m step tripwire on the family run so always()
  cleanup still runs, under a 75m job-level last-resort backstop

The workflow's header comment states the policy and points at
docs/fm-test-portable-shards.md "Timeouts", which now owns it, and each
job names its tier beside timeout-minutes. tests/fm-ci-workflow.test.sh
asserts the policy against the parsed workflow instead of the old
per-job minute values: every job joins exactly one tier, exactly three
distinct job-level values exist, the fast tier stays within 5-10
minutes, the normal budget stays at least double the modeled parallel
lane sum reported by fm-test-run.sh --check-coverage, and the Herdr step
tripwire stays below its job backstop with an always() cleanup after it.

Concurrency supersession, shard counts, lane membership, and fail-fast
settings are unchanged.

* no-mistakes(review): Decouple the normal timeout from packing estimates

* no-mistakes(review): Assert Herdr teardown follows the family run

* no-mistakes(review): Pin Herdr family-run timeout to 20 minutes

* no-mistakes(review): Ignore comments when identifying Herdr steps

* no-mistakes(review): Identify Herdr steps by declarative ids

* no-mistakes(document): Clarify authoritative three-tier timeout policy

* fix(bin): keep supervisor status closes from waking the same home (kunchenguid#4895)

* fix(bin): keep supervisor status closes from waking the same home

A drain that already folded OPEN DECISIONS has presented those bytes even
when the watcher has no matching seen marker. Treat that fold, and the
presentation cursor, as known so the bookkeeping close stays quiet while
later worker lines still signal.

* no-mistakes(review): Keep folded worker failures waking past supervisor closes

* no-mistakes(review): Wake on unlisted folded worker lines; batch multi-key closes

* no-mistakes(review): Stop folded worker resolved lines from counting as already read

* no-mistakes(document): Correct self-announced close marker contract in docs

* fix(bin): stop labeling Herdr as experimental (kunchenguid#4972)

* Stop steering operators away from Herdr

* no-mistakes(review): Neutralize remaining Herdr opt-out documentation wording

* fix(bin): treat a live no-mistakes run as current after rebase (kunchenguid#4973)

* fix(bin): treat a live no-mistakes run as current after rebase

A running run on the task's branch is authoritative regardless of head.
Matching only the local head made a rebased in-flight run look failed.

* no-mistakes(review): restrict coarse live-any-head to foreign-branch answers

* no-mistakes(review): reject gate-parked runs from the executing predicate

* no-mistakes(review): hoist gate-marker patterns into single run-lib owner

* no-mistakes(review): require live daemon for head-free run binding

* no-mistakes(review): require answered daemon-down before unbinding live runs

* no-mistakes(review): extend daemon guard to anchored continuation routes

* no-mistakes(review): delete live-any-head; restore dead-daemon verdict

* no-mistakes(review): keep parked gates parked; name dead daemon everywhere

* no-mistakes(review): set dead-daemon verdict instead of emitting early

* no-mistakes(review): align selected route with legacy dead-daemon handling

* no-mistakes(review): drop unproven-record binds; narrow coarse gate reading

* no-mistakes(review): narrow header, drop vestigial guard, retarget tests

* no-mistakes(review): revert coarse gate override; require answered-down probe

* no-mistakes(review): cache one daemon probe; stop duplicating run id

* no-mistakes(review): restrict coarse dead-daemon verdict to moved-off rows

* no-mistakes(review): delete coarse dead-daemon extension and gate note

* no-mistakes(review): delete remaining coarse dead-daemon block and stale docs

* no-mistakes(document): document rebase-safe live-run bind and unverified-record verdict

* fix(bin): prevent long worker launch command truncation (kunchenguid#4994)

* fix(bin): stage the launch command in a private file and type a short source line

A long launch line typed while the fresh pane shell is still busy waits in the
terminal's canonical line buffer, which drops input past about 1,024 bytes on
macOS, so the pane was left at an unfinished command with no agent running.
fm-spawn now writes the assembled command to the task's own temp root under
umask 077 and types only a short line that sources it.

Refs kunchenguid#4559

* fix(bin): keep the per-task temp root private before staging the launch command

The root lives at a predictable path under /tmp and now holds the whole launch
command. Create it with mode 0700, refuse one that already exists as anything but
a directory owned by this user that nobody else can write, and tighten an owned
one, so no other local user can plant or swap the staged file.

Refs kunchenguid#4559

* fix(bin): enforce private staged launch file mode

* test(spawn): cover long staged Claude launches

* no-mistakes(review): Namespace launch files and prove truncation staging

* no-mistakes(review): Use immutable per-spawn launch filenames

* no-mistakes(document): Document staged launch delivery safeguards

* no-mistakes(ci): Updated eight behavior tests/fakes to execute or inspect immutable staged launch files instead of expecting inline launch commands. This restores Muse, secondmate lifecycle/restart, remote trace/parent binding, compact-adviser, and Orca coverage. All affected tests, dispatch-profile regression, fixture tests, syntax checks, ShellCheck, and git diff checks pass

---------

Co-authored-by: Vytautas Stankus <[email protected]>

* test: authorize isolated Herdr lab validation (kunchenguid#4998)

* Add isolated Herdr runbook to test instructions

* no-mistakes(review): Drop substring matching from test.instructions contract

* no-mistakes(review): Assert commands.test key absence in YAML

* Drop unit-first sentence and instructions contract test

Captain-scoped follow-up on the Herdr-lab test.instructions ship:
keep the lab safety runbook only, and leave the no-mistakes contract
test focused on commands.test absence.

* docs(vision): accept vendor-semantics and 9k AGENTS ceiling (kunchenguid#4873) (kunchenguid#5001)

* docs(vision): accept vendor-semantics and 9k contract-ceiling amendments (kunchenguid#4873)

Replace the pixels-of-today's-UI rule with a quarantined, version-pinned
surface-adapter exception recorded as standing debt. Cap the always-loaded
contract at 9,000 words and require prune-or-trigger before a crossing change
lands.

Co-authored-by: Kun Chen <[email protected]>

* docs(vision): restore accepted three-sentence vendor-semantics form (kunchenguid#4873)

Replace the compressed paraphrase with the issue's accepted wording:
a named quarantined version-pinned adapter, expected to break, recorded
as standing debt that never hardens into a shared contract.

Co-authored-by: Kun Chen <[email protected]>

---------

Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Kun Chen <[email protected]>

* feat(bin): defer the wedge escalation for a lane parked at a supervisor-owed gate (kunchenguid#4974)

* fix(watch): recheck a gate awaiting a human instead of wedge-escalating it

A lane whose validation run is parked at a gate waiting on a human
decision is correctly quiet, but nothing in its status line says so: the
evidence is the pipeline's own gate state rather than anything the worker
wrote. The wedge timer read that silence as a suspected wedge and climbed
the escalation ladder for as long as the wait lasted, and each escalation
cost a supervising turn. The landed declared-wait consult does not reach
it, because a live ordinary crewmate never reports a declared pause, and
raising FM_STALE_ESCALATE_SECS would delay genuine wedge detection for
every lane by the same amount.

The threshold now reads a second, independent record when the status line
accounts for nothing: whether the crew's current state is a gate whose
answer is owed by a human. That is minted only from the gate's own
findings table, by a row whose `action` column is exactly `ask-user`,
located by position out of the table header the way nm_gate_step_row
already reads its row - never searched for over the run payload, where a
finding's free-text description or a branch name satisfies a search just
as well. A gate awaiting the CREWMATE's own answer keeps the unchanged
escalation schedule, reason and demand-deep-inspection wording, because a
crewmate that goes quiet before answering its own gate is exactly the
wedge the ladder exists to catch.

Each kind of wait now carries the human it is on, the action that clears
it, and whether that human is the captain as data alongside the verdict,
rather than as wording chosen per branch where the recheck is written, so
the deferral cannot word one kind of wait as another and a new kind
cannot ship without deciding all of them. A parked gate has no written
record of when its wait began, so its recheck publishes no wait age at
all rather than one read from the quiet window this deferral resets on
every pass, which would report the same small number for a gate of any
age. Like every other captain-facing recheck here it is absorbed in
silence while the away-posture record exists, arming no throttle, so the
recheck is owed in full the moment the record is archived.

The consult runs only in the at-threshold branch that was about to
escalate, beside the worktree walk already there, and only for lanes
whose status line explained nothing.

Closes kunchenguid#3055

* no-mistakes(review): require an unanswered decision before deferring a parked gate

* no-mistakes(review): reset the away-silenced timer, fail-safe findings parse, US-joined wait records

* test(watch): pass the pane hash wedge_timer_check now takes

Upstream gave wedge_timer_check a sixth <pane-hash> argument for its
dead-record probe. The malformed-wait-record rounds drive the real function
directly, so they pass one, and stub fm_backend_agent_state to a live agent so
the probe that runs after a refused deferral keeps the unchanged ladder rather
than reading a backend the child shell has none of.

* no-mistakes(review): Bind parked-gate wait to its run, owe it firstmate

* no-mistakes(document): correct wait-kind count, crew-state reader scope, gate-key coupling

* feat(watch): make the parked-gate wait deferral opt-in

The wedge timer deferring a lane parked at a validation gate is new
supervision behaviour rather than a restored one, and it decides which
lanes give up the escalation ladder, so it now ships as a default-off
per-home option instead of changing every home on upgrade.

config/wedge-defer-parked-gate arms it. The flag is read before the
decision fold, so an unconfigured home spends no fold or current-state
read, writes no record, and keeps the unchanged escalation schedule,
reasons and demand-deep-inspection wording; a test counts the reader
calls in both directions to pin that.

It is not inherited by secondmate homes: each home supervises its own
crew and owns that trade separately, the same reason
config/turnend-churn-absorb is home-local.

The away-posture absorb returns to leaving the idle timer alone, which
it had restarted only because the costly consult could reach it. A
parked-gate wait is owed to the supervisor rather than the captain, so
it never enters that branch, and the recheck owed on return is again
owed in full the moment the record is archived.

* test(watch): pin that the away-silenced hold leaves the idle timer alone

The absorb no longer restarts the timer, so the recheck owed on return is
owed in full rather than a cadence into the return. Nothing asserted
that, so a restart could be reintroduced silently.

* no-mistakes(review): document away-silence rationale, pin captured gate component

* no-mistakes(test): anchor gate row scan to the braced findings header

* no-mistakes(document): pin same-block gate row invariant in crew-state comment

* fix(bin): reclaim a task whose herdr endpoint was destroyed (kunchenguid#5007)

* fix(control): let the owning seat reclaim a task whose endpoint is gone

A destroyed pane or workspace made `missing` a terminal state. Relaunch
accepted only `dead` and said to stop the agent first; exit refused
`missing` and said to reconcile the task first; there is no reconcile
verb. Each command named the other as its prerequisite, so a task whose
terminal went away could not be reclaimed by anything, and a no-mistakes
approval it was parked on had no seat left to answer it.

`missing` is agent-free a fortiori: there is no endpoint, so there is no
agent in it. Widen the existing guards rather than add a verb.

- fm-spawn --relaunch accepts a positively proven `missing` and creates
  one fresh endpoint in the recorded worktree; the record it already
  republishes rebinds the task to it. A `dead` endpoint is still adopted
  in place.
- fm-control exit reports `endpoint-gone` instead of dying, so the
  relaunch transaction's stop step no longer dead-ends, and re-resolves
  the endpoint from the record before verifying the replacement.

The duplicate-agent refusal is untouched: both verdicts come from the
same recovery-grade classifier, which claims `missing` only from positive
absence, so `alive`, `ambiguous`, and `unreadable` all still refuse. The
backends' own create paths refuse a live same-labeled endpoint as a
second independent guard. The worktree, its branch, commits, uncommitted
changes, armed poll and registration, record rows, and status log are all
untouched - a reclaim is a recovery, never a teardown.

A secondmate is excluded: its gone-endpoint recovery already has one
owner in the session-start liveness sweep, so relaunch refuses and names
it rather than becoming a second path to the same outcome.

Tests reproduce both halves of the deadlock, the reclaim succeeding,
unlanded work surviving it, and the refusals that still hold.

* no-mistakes(review): prove endpoint absence per backend before reclaim rebinds

* no-mistakes(review): give exit and relaunch one absence proof; pin herdr rebind session

* no-mistakes(review): narrow endpoint reclaim to herdr; tmux refuses honestly

* no-mistakes(review): stop refusals and docs asserting unestablished causes

* no-mistakes(review): stop herdr fixture helper losing tmp-root registration

* no-mistakes(review): document workspace drift and absence-probe server residue

* no-mistakes(review): correct rebind limitation to its one reachable case

* no-mistakes(review): stop claiming reclaim leaves instructions untouched

* no-mistakes(document): scope fm-control-lib purity claim, note reclaim coverage

* no-mistakes(rebase): read the staged launch file in the herdr fixture

Rebasing onto main picked up kunchenguid#4994, which stages a long worker launch
command into a script and delivers the short `. '<path>'` line instead of
the literal command. The tmux fake and tests/fixtures.sh were updated for
that; the herdr fake this branch adds was written before it and still
keyed "an agent now exists on this pane" off the literal
`encode launch-brief` text, so after the rebase it never marked the
rebound pane live and the reclaim's alive-wait read `dead`.

Dereference the staged file first, exactly as the tmux fake above does.
Test-fixture only; no production path changes.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* no-mistakes(document): note reclaim placement in herdr and scripts inventories

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

* feat(bin): stamp status events with their emission time (kunchenguid#3764)

* test(status): reproduce missing event emission time

* wip(status): preserve optional event emission time

* test(status): document indirect clock stub invocation

* no-mistakes(review): Preserve historical status bytes during reply recovery

* no-mistakes(test): Fix timestamped status assertions and remote fixture dependencies

* no-mistakes(review): Preserve captain regex overrides for timestamped status events

* no-mistakes(document): Clarify status event timing and publication contracts

* no-mistakes(lint): Quote literal done to satisfy ShellCheck

* no-mistakes(ci): Captain, updated .github/workflows/ci.yml to expect 19 snapshot tests instead of 18, matching the PR’s added regression. Reproduced the failure before the fix. Stock Bash 3.2.57 verification passed: parse sweep, 19 snapshot tests, 53 Bearings tests, and the public-followup regression. Workflow lint and diff checks passed

* no-mistakes(test): Preserve terminal notifications with malformed timestamp tags

* no-mistakes(test): Stamp Rovo spawn failures with emission time

* no-mistakes(document): Verify status event documentation

* no-mistakes(lint): Fix ShellCheck quoting in status emission-time tests

* no-mistakes(ci): Captain, fixed four lifecycle assertions to accept emission timestamps while preserving publication and retry checks. Reproduced the CI failure before the fix. The lifecycle suite now passes with six Beads capability skips; syntax, targeted ShellCheck, and diff checks passed

* no-mistakes(ci): Captain, fixed malformed timestamp colons hiding actionable events using shared normalization. Original bytes and unknown ages are preserved. Regression reproduced before the fix; classifier and remote-reply suites, targeted lint, syntax, and diff checks passed

* no-mistakes(review): Stamp remote escalations at call sites, drop new flag

* no-mistakes(review): Accept stamped escalation and close lines in test assertions

* no-mistakes(review): Restore reserved-key answered-note guard for stamped closes

* test(status): accept optional emission time in PR-provenance assertions

The kunchenguid#4148 provenance test landed on main with exact unstamped greps.
Parent-channel lines from this branch carry [at=<epoch>], so strip only
that tag before the same exact match. No production change.

* no-mistakes(review): Accept stamped ready signal in PR fallback scrape

* no-mistakes(review): Drop relay flag, stamp parent events at call sites

* no-mistakes(review): Stamp worker terminal-signal instructions, revert fm-on fixture

* no-mistakes(review): Accept optional stamp in live cmux drift guard

* no-mistakes(review): Restore original test invocation order in two suites

* no-mistakes(review): Strip only well-formed numeric status time tags

* no-mistakes(document): Drop stale unstamped PR-ready line spelling from channel doc

* no-mistakes(review): Stamp agy spawn-failure status lines with event time

* fix(bin): normalize status event times in-shell and freeze the budget test clock

Two paths made a status event's emission time cost more than it should.

The captain-relevance fallback piped every line through awk to drop a
well-formed `[at=<epoch>]` tag before matching, so a supervisor sweep paid a
fork per line just to prepare a regex match. Shell parameter expansion does the
same strip with no fork, and the retry-dedup scan now reuses that one helper
instead of carrying a second copy of the rule in awk. The copies had already
drifted: the shell side stripped tags from lines with no colon, which the awk
rule left whole, so a colonless line could be mistaken for one already
recorded. One definition, checked against the awk rule it replaces over the
edge cases and a 4000-line fuzz.

tests/fm-contributions.test.sh froze its fixture clock only in exhaust mode. In
hang mode the poll set DEADLINE to the real now plus a one-second budget, and
when the second ticked before the first forge call the loop broke without ever
calling gh: forge/calls was never written and the assertion failed reading a
missing file. Freezing the clock in both modes removes the dependence on wall
time; the bounded call is still cut by the real timeout, so the observation the
test asserts still starts.

Emission time stays optional on new status records, and legacy or malformed
lines keep an unknown age.

* no-mistakes(review): Stamp ask-user escalation line and fix Kimi status assertion

* no-mistakes(document): Drop stale unstamped done-line spelling from watcher docs

* test: fold emission-time snapshot coverage into the fixture case

Drop the incidental ci.yml 18-to-19 count hunk so the PR no longer
touches workflows. Keep every emission-time assertion by folding it
into test_fixture_snapshot_json.

* no-mistakes(review): replace brief date substitution with epoch placeholder; drop emitted_at_epoch

* no-mistakes(review): align untimed normalizer with epoch parser; tolerate placeholder stamp in PR scrape

* no-mistakes(review): strip undelimited at-tags; correct brief stamp header

* no-mistakes(review): normalize stamps at both captain-regex sites; restore mtime freshness

* no-mistakes(review): strip colon-bearing stamps for relevance; fix headers and test oracles

* no-mistakes(review): narrow escalation match to stamp tolerance; pin note verb

* no-mistakes(review): read note and key past colon-bearing stamps

* test(status): keep inactive reconcile assertions stamp-tolerant

These two oracles were made stamp-tolerant while resolving one of the
branch's merges from main. The rebase drops merge commits, so that
adaptation was lost and both assertions went back to matching an exact
substring that a stamped line no longer contains: the tag lands before
the colon, so "failed [key=k]: ..." is now "failed [key=k] [at=N]: ...".
Strip a well-formed tag before matching, as the branch's other oracles do.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* no-mistakes(review): unstamp fold colon tests; reserve stamp width in cap

* no-mistakes(document): correct stale unstamped status-line spellings in docs

* no-mistakes(document): quote brief-test literals for lint; correct stamp-helper contract comments

* no-mistakes(ci): rename subshell-local epoch in delivery-race stub

The serialization test overrides fm_pending_reply_mark_delivered inside a
(..) subshell. Its `epoch` local collided with the same name in
status_line_at_epoch/status_stamp_line, which this branch added and this
suite now calls at top level, so ShellCheck 0.11.0 reported SC2030 and
failed Lint 2. The stub already prefixes its other locals with `pending_`
for the same reason; `epoch` was the leftover.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>

* fix(bin): unify Lavish host and disconnect handling (kunchenguid#5060)

* fix: ship clean Lavish host fixes

* no-mistakes(review): Fix Lavish classifications and fail-closed host loading

* no-mistakes(review): Restore Lavish host state across retries and launches

* no-mistakes(review): Preserve destination Lavish host when configuration is absent

* no-mistakes(document): Document Lavish status and host guarantees

* feat: act on captain's away words during AFK supervision (kunchenguid#5076)

* feat(afk): make the captain's away words the whole mandate

Retire the clause fields, verb list, never-set scan, refused records, and
the per-task merge-grant list from the away-posture record. The record is
now version 2: the captain's words verbatim plus expected return, spend
cap, and reach line; a version 1 record still validates, reads, and
archives so a live away window is never broken by the upgrade.

The supervision branch reads the words at the tail of every wake and acts
on them by its own judgment through the guarded scripts under standing
authority, never by analogy, holding for the return on doubt, and opens
each such outcome summary with "per your away instructions:" so the
return brief can render the words beside the session's account. While the
record exists any green merge runs under away authority (ledger tag
"away"); red merges, --allow-red, asynchronous and queued merges, and
local-only landing stay refused. The branch may file a backlog item the
words explicitly call for before dispatching it under the spend cap.

Tests drive fm-afk-contract.sh, fm-afk-launch.sh, fm-afk-return.sh, and
fm-pr-merge.sh as commands: version 2 written, version 1 read, retired
flags and subcommands refused by name, green merges landing under the
record, red and waived-red refused, the record lock still closing the
authority-read window, and the Pi away tail carrying the words.

* no-mistakes(review): carry the away read-back to the session verbatim

* no-mistakes(review): match the exact away-action marker in the return brief

* no-mistakes(review): refuse a words block truncated by a damaged line

* no-mistakes(document): Refresh away-role contract documentation

* fix(bin): render the remote charter's steering-inbox path host-local (kunchenguid#5049)

* fix(bin): render the remote charter's steering-inbox path host-local

A freshly provisioned remote secondmate read a parent-home absolute
steering-inbox path in its charter - a location that exists on no route -
and spent its first turn discovering the gap and filing a blocked
decision for what was a render defect. The seed's remote-copy rewrite now
maps the inbox to the route's host-local parent-route inbox, exactly as
it already maps the reply-log path, so every mention - bare path, listing,
and handled/ acknowledgement - lands host-local.

Both rewrites also become plain assignments, because a quoted substitution
nested inside a double-quoted printf argument leaks literal quotes into
the replacement text on stock macOS bash. The lifecycle suite pins the
corrected render both directions against the real seed, provisioning,
and delivery route, sharing one fixture value between the render truth
and the delivery truth.

Closes kunchenguid#5012

* no-mistakes(document): document remote charter's host-local steering inbox

* no-mistakes(document): Correct quiet-mode guidance and launch environment documentation

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Tiago <[email protected]>
Co-authored-by: rovermike <[email protected]>
Co-authored-by: Vytautas Stankus <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Amin Roudaki <[email protected]>
Co-authored-by: Jon Roosevelt <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Co-authored-by: Martin Kessler <[email protected]>
haris-siddiqui-1 pushed a commit to haris-siddiqui-1/firstmate that referenced this pull request Sep 21, 2026
…unchenguid#5049)

* fix(bin): render the remote charter's steering-inbox path host-local

A freshly provisioned remote secondmate read a parent-home absolute
steering-inbox path in its charter - a location that exists on no route -
and spent its first turn discovering the gap and filing a blocked
decision for what was a render defect. The seed's remote-copy rewrite now
maps the inbox to the route's host-local parent-route inbox, exactly as
it already maps the reply-log path, so every mention - bare path, listing,
and handled/ acknowledgement - lands host-local.

Both rewrites also become plain assignments, because a quoted substitution
nested inside a double-quoted printf argument leaks literal quotes into
the replacement text on stock macOS bash. The lifecycle suite pins the
corrected render both directions against the real seed, provisioning,
and delivery route, sharing one fixture value between the render truth
and the delivery truth.

Closes kunchenguid#5012

* no-mistakes(document): document remote charter's host-local steering inbox
haris-siddiqui-1 pushed a commit to haris-siddiqui-1/firstmate that referenced this pull request Sep 21, 2026
…unchenguid#5049)

* fix(bin): render the remote charter's steering-inbox path host-local

A freshly provisioned remote secondmate read a parent-home absolute
steering-inbox path in its charter - a location that exists on no route -
and spent its first turn discovering the gap and filing a blocked
decision for what was a render defect. The seed's remote-copy rewrite now
maps the inbox to the route's host-local parent-route inbox, exactly as
it already maps the reply-log path, so every mention - bare path, listing,
and handled/ acknowledgement - lands host-local.

Both rewrites also become plain assignments, because a quoted substitution
nested inside a double-quoted printf argument leaks literal quotes into
the replacement text on stock macOS bash. The lifecycle suite pins the
corrected render both directions against the real seed, provisioning,
and delivery route, sharing one fixture value between the render truth
and the delivery truth.

Closes kunchenguid#5012

* no-mistakes(document): document remote charter's host-local steering inbox
andrewesweet pushed a commit to andrewesweet/firstmate that referenced this pull request Sep 21, 2026
…unchenguid#5049)

* fix(bin): render the remote charter's steering-inbox path host-local

A freshly provisioned remote secondmate read a parent-home absolute
steering-inbox path in its charter - a location that exists on no route -
and spent its first turn discovering the gap and filing a blocked
decision for what was a render defect. The seed's remote-copy rewrite now
maps the inbox to the route's host-local parent-route inbox, exactly as
it already maps the reply-log path, so every mention - bare path, listing,
and handled/ acknowledgement - lands host-local.

Both rewrites also become plain assignments, because a quoted substitution
nested inside a double-quoted printf argument leaks literal quotes into
the replacement text on stock macOS bash. The lifecycle suite pins the
corrected render both directions against the real seed, provisioning,
and delivery route, sharing one fixture value between the render truth
and the delivery truth.

Closes kunchenguid#5012

* no-mistakes(document): document remote charter's host-local steering inbox
bcriswell added a commit to bcriswell/firstmate that referenced this pull request Sep 23, 2026