Skip to content

feat(bin): reconcile upstream steering inboxes with the fork's steer-ack contract - #10

Merged
adonis-garcia-git merged 29 commits into
mainfrom
fm/fm-upstream-catchup
Aug 26, 2026
Merged

adonis-garcia-git merged 29 commits into
mainfrom
fm/fm-upstream-catchup

Conversation

@adonis-garcia-git

@adonis-garcia-git adonis-garcia-git commented Aug 25, 2026 •

Copy link
Copy Markdown
Owner

Brings main up to date with 22 commits from kunchenguid/firstmate. Not a fast-forward: 22 behind, 18 ahead, 117 files touched.

Nine files conflicted (the trial merge predicted seven; tests/fm-tool-update-check.test.sh and tests/fm-voice-relay.test.sh also conflicted). None was resolved by picking a side. For each, I established what both sides were trying to achieve and produced a resolution that keeps both. No local behaviour was dropped, so there is no divergence list at the end of this description.

The one that mattered: the steer plane

This is the only conflict where both sides had built a real mechanism for the same problem, and it is worth reading before the rest.

Upstream's durable steering inbox (kunchenguid#2856, kunchenguid#2901) and our opt-in steer-acknowledgment contract (#5) both exist to catch a steer that silently never gets acted on. Left alone, the merge would have produced two parallel delivery paths.

They are now one layered mechanism:

  • The inbox is the sole transport. A steer becomes a durable record; the worker's terminal gets only a doorbell line.
  • --ack is a supervision layer on top of it, not a second transport.

The reason that works cleanly: --ack's own eligibility rules - a task recorded in this home, not a secondmate, not a / or codex $ invocation - are exactly the conditions that select the inbox plane. So every acknowledged order already rides a durable record. The two mechanisms answer different questions, which is why both are worth keeping:

catches
inbox ladder the worker never picked the instruction up
--ack the worker picked it up but never acted on it

A defect this merge would have shipped

Because --ack now always takes the inbox plane, the three typed-plane sites that used to discard the pending-ack record became unreachable, and the inbox plane's own failure exits never discarded it. An order whose record could not be written would have left an armed acknowledgment record behind, and the watcher would have escalated a steer the worker was never given.

Fixed by giving fm-send.sh a single owner for "this order was never delivered", wired into the inbox plane's pre-transport failure exits. That is the only place this fork's fm-send.sh now differs from upstream's; everything else in that file is upstream's verbatim.

I verified the fix is load-bearing rather than decorative: with it neutralised, the new regression fails; restored, it passes.

The other eight

file resolution
AGENTS.md Union of both state-layout additions. For the steer contract, took upstream's transport description and kept our --ack sentence, restated as a layer over the record.
bin/fm-inbox.sh Took upstream whole - see note below.
bin/fm-brief.sh Kept both teachings: the inbox acknowledgement and the [ack=] reply. Upstream's kunchenguid#2838 Herdr-gate fix applied cleanly.
bin/fm-watch.sh Positional only - two independent blocks added at the same line. Both kept.
docs/scripts.md Union: our reconcile row, upstream's GitLab-aware merge description.
tests/fm-gotmp.test.sh Union. Both sides add symlinks for libraries teardown genuinely sources; they are cumulative fixture requirements, not alternatives. Our local fixture work is intact.
tests/fm-tool-update-check.test.sh, tests/fm-voice-relay.test.sh Both sides fixed the same macOS wc -l padding. Took upstream's tr -d form, which also strips the padding out of the failure message.

Two of these deserve a sentence more.

AGENTS.md is the always-loaded contract, so a stale rule here is obeyed by every future session. Our side said "short single-line messages; put long instructions in a file." That was a workaround for a typed plane that could not carry newlines - upstream's inbox makes multi-line text legal. Keeping the stricter reading would have meant every session obeying a limit that no longer exists, so this is one place where the stricter wording was the wrong call and upstream's factual description wins. The safety boundaries on both sides are preserved.

bin/fm-inbox.sh: our commit had made a GNU-only sed -i BSD-safe for macOS. Upstream restructured so the note id is computed before the write, deleting the rewrite entirely. Our portability intent is preserved structurally and more robustly, so upstream's form is taken whole. Confirmed no sed -i remains anywhere in bin/.

Tests

tests/fm-steer-ack.test.sh asserted against the typed pane, which is no longer the carrier. Rather than relax it, I repointed each assertion at the durable record the order actually travels in. Its guarantees are unchanged in substance and the suite is now strictly stronger - it pins both directions of the delivery boundary, which it previously did not:

  • a record that cannot be written discards the pending-ack record (the defect above)
  • a doorbell that is skipped or fails keeps it armed (the record is the delivery)

Nothing was weakened, skipped, or deleted to make the merge pass.

Verification

  • Every suite covering what this merge touches passes: fm-steer-ack, fm-task-inbox, fm-send-inbox, fm-send-strict, fm-send-resolve-key, fm-send-remote-delivery, fm-brief, fm-gotmp, fm-tool-update-check, fm-voice-relay, fm-completion-alarm.
  • A full local --all pass was attempted and abandoned deliberately. It ran on a busy interactive desktop (83 Chrome processes; load average 16-28) and began manufacturing failures in concurrency suites whose synchronisation waits are only 2-5 seconds. CI's sharded lanes on clean runners are the authoritative gate; a local sequential pass on a loaded workstation is not, and continuing it would have bought noise rather than signal.
  • All four failures from the partial full pass were re-run in isolation on a quiet machine (77-89% idle, measured at each run). fm-remote-job and fm-secondmate-harness passed cleanly, confirming those two as load-induced - fm-secondmate-harness ran 160s alone against 2059s under load, a 13x swing on identical code.
  • bin/fm-lint.sh: clean (ShellCheck 0.11.0 pinned, actionlint 1.7.12, 3 workflows valid). Note: actionlint is not installed on this machine, so fm-lint.sh exits 1 both locally and inside the no-mistakes agent until bin/fm-install-actionlint.sh <dir> is run and that directory is on PATH. The pipeline's lint gate was approved on that basis - ShellCheck passed there, and the same head lints clean with actionlint present. CI installs pinned actionlint itself, so the workflow lint is enforced regardless.
  • bin/fm-doc-audience-check.sh: clean, 74 surfaces / 277 local links.
  • bin/fm-lint.sh: clean (shellcheck 0.11.0 pinned, actionlint 1.7.12, 3 workflows valid).
  • bin/fm-doc-audience-check.sh: clean, 74 surfaces / 277 local links.
  • Nothing under projects/ touched.

Also confirmed the auto-merged regions did not quietly drop local work: the PR-reconcile sweep, steer-ack, completion-alarm and decision-wait scripts are all present and still wired into the watcher, and the recorded-PR reconcile still runs inside the deferred network phase rather than the blocking path, so upstream's startup parallelisation (kunchenguid#2927) did not push it back onto session start. Both macOS event-loop fixes in bin/fm-voice-relay.py survived intact.

What the pipeline caught that I missed

The documentation step found two stale comments this merge left behind, and both are worth naming rather than burying in the diff:

  • bin/fm-steer-ack-lib.sh is the owner of the pending-ack contract, and its header still described arming "BEFORE submitting" with a delivered-but-unconfirmed submit (exit 3) keeping the record armed. That path is unreachable for --ack orders now. I rewrote bin/fm-send.sh's header for the new boundary but never updated the owning library's own description of the same contract - the inverse of the one-owner rule, which says to patch the owner and then update its cross-references.
  • tests/fm-steer-ack.test.sh's file header still summarised the contract as "a failed or unconfirmed submit discards the record", contradicting the per-case comments this merge did update.

Both fixes are comment-only; the suite passes 16/16 and the doc-audience check still passes.

Two intermittently failing remote suites - investigated, NOT attributed to this merge

A partial full-suite run surfaced failures in fm-remote-backlog-handoff and fm-remote-secondmate-lifecycle-e2e. Both were chased to a conclusion. Neither is caused by this merge, and the evidence is recorded here because the intermittency is real and will resurface.

Repeat sampling on a quiet machine (77-91% idle, measured per run):

suite unmodified merge merge, our wake-lib reverted merge, our fm-spawn.sh reverted
handoff PASS x4 (~40s) PASS x4 (~40s) -
lifecycle PASS x3 (210s) PASS x2 (210s) PASS x2 (210s)

Both suites also pass on pure upstream/main and on this fork's pre-merge HEAD. Across every observation the merge's failure rate is: handoff 1 failure in 6 runs, lifecycle 2 failures in 5 runs (one 417s assertion failure, one multi-hour hang).

Three candidate causes were proposed and each was falsified:

  • Inherited upstream defect - refuted by running both parents. Both pass; provenance reasoning (the test and script are byte-identical to upstream) proved nothing, because a merge defect can live entirely in what the fixture is fed.
  • Our bin/fm-spawn.sh (fix(bin): freshen remote-less pooled worktrees from the primary local copy #8) - refuted by code reachability. Every hunk sits in freshen_spawn_worktree_base, gated behind KIND != secondmate, and the failing subtest is a secondmate spawn. The single-variable swap that appeared to indict it was one sample against one sample, which cannot attribute an intermittent failure.
  • Our bin/fm-wake-lib.sh (fix(watch): close false-liveness and false-death holes in watcher supervision #6) - refuted by configuration. tests/lib.sh already exports FM_SYSTEM_WAKE_EPOCH_OVERRIDE=0, which makes the changed code fall back to plain wall-clock age, and that export propagates through the fake-ssh boundary into the remote leg. The change is inert everywhere these suites run.

The lifecycle hang deserves its own investigation independent of this merge: it wedged for ~3 hours on a quiet machine, blocked on head -c 1048577 in bin/fm-remote-job-lib.sh reading a remote job's stdin that never reached EOF. That is a real deadlock in the remote job path, reproducible roughly 1 run in 4, and a live spawn hitting it would hang silently rather than fail. It is not introduced here - it does not reproduce on any tree preferentially - but it is worth a dedicated task.

One thing for you to decide (not blocking)

The two layers now overlap in exactly one case: an --ack order the worker ignores completely wakes you twice - once from --ack at ~180s, once from the inbox ladder at ~270s. Different reasons, both true, both actionable.

I left both in rather than silencing one, because suppressing the acknowledgment escalation whenever the record is still unhandled is a change to escalation semantics on a supervision contract, and that is your call rather than mine. Happy to make that change as a follow-up if you want the quieter behaviour.

Inthuson and others added 29 commits August 21, 2026 23:23
…ath (kunchenguid#2779)

* feat(bin): merge GitLab merge requests through the guarded PR merge path

bin/fm-pr-lib.sh already parses a GitLab merge request URL for the watcher,
but bin/fm-pr-merge.sh refused every non-github provider, so a merge request
had to be merged by hand and got none of the recording, guards, or audit
trail a pull request gets.

The merge path now dispatches on the parsed provider. A GitHub URL keeps its
exact previous behavior. A GitLab URL is addressed through glab by the project
URL rebuilt from the parsed host and path, so a merge request on any instance
resolves and no host is hardcoded, and no merge-method flag is added because
the project's own merge method is what should apply.

A GitLab merge happens only after one live read of the merge request confirms
it is open, detailed_merge_status is mergeable, has_conflicts is false,
blocking_discussions_resolved is true, and the head pipeline succeeded at the
exact current head. Every failing condition is reported, not just the first.
The verified head is bound to the merge with glab's --sha, so a push landing
between the read and the merge fails the merge instead of landing commits
nothing verified. Recorded metadata is never the authority for any of this: a
rebase moves the head and leaves a recorded value stale, so a recorded head
that disagrees with the live one is reported rather than trusted, and the
recorded value is read before the recording step because that step drops a
GitLab head it cannot resolve.

* no-mistakes(review): reject bundled -R clusters and make tool-absence cases host-independent

* no-mistakes(test): state authorised GitHub narrowing of bundled -R guard

This branch NARROWS GitHub behaviour. The narrowing was authorised
deliberately rather than slipping in by accident, and it applies to both
providers, GitHub and GitLab alike, because a script that guards one provider
and not the other is a trap for the next reader.

What bin/fm-pr-merge.sh now refuses is extra merge arguments containing a
bundled short-option cluster that includes R, for example "-dR other/repo".
The forge CLIs expand such a cluster one character at a time, so it carries
"--repo other/repo", and that later value wins over the repository the URL
named. Before this change, "fm-pr-merge.sh <task> <github-url> -- -dR
other/repo" reached "gh-axi pr merge 12 --repo example/repo --squash -dR
other/repo" and exited 0 with pr= recorded and the merge poll armed. It now
exits 1 with "extra merge arguments must not override the repository", records
nothing, and invokes no forge merge command. Every other GitHub invocation is
byte-identical to the base commit.

Closing that hole honours the existing rule rather than departing from it. The
file header already forbids --repo and -R because the repository must come
only from the URL, so a bundled cluster carrying a repository override was
never legitimate behaviour to preserve: it was that guard being evaded.
Redirecting a merge to a repository the URL does not name is exactly what the
guard exists to prevent.

The refusal is already pinned on both paths by the existing case
test_bundled_repo_override_args_refuse_before_recording in
tests/fm-pr-merge.test.sh. On GitHub ("-dR wrong/repo") and on GitLab ("-yR
https://other.example/g/p") it asserts exit 1, the refusal wording, no pr= in
the task meta, no armed merge poll, and no forge merge command invoked, with a
control case proving a cluster that carries no repository override still
reaches the forge. No duplicate assertion was added. Both assertions were
confirmed to have teeth by narrowing the guard back to a bare -R and watching
each path fail.

This commit carries no file change: the guard and its coverage landed in
614853d, and this message exists so the pull request description states the
narrowing.

* no-mistakes(document): fix README pointer for GitLab watch and merge doc

* no-mistakes: apply CI fixes
kunchenguid#2788)

* no-mistakes: apply CI fixes

* fix(bin): drop a private record citation and narrow the review rule

Three corrections to the spoken interface that landed in kunchenguid#2767, plus one
fix carried over from that branch after its pull request had already been
merged.

The confidentiality fix. The module docstring of bin/fm-voice-relay.py
cited a private, gitignored fleet record by exact path and section number.
That widens what this public repository points at, and it cannot resolve
for any reader here, because the path has never been in the repository.
Both traps it pointed at are already described in full in the list
immediately below it, and docs/voice-relay.md carries the same two for
operators with no citation at all, so the pointer is removed and no claim
is weakened by losing it. Two comments that referred to "the survey" as
though it were something a reader could open are reworded the same way.
Neither exposed a path, so that half is comprehensibility rather than
confidentiality.

The review rule. .greptile/rules.md is kept, because its conditions are
right and deleting it would leave the next reviewer to re-litigate a
decision already argued out. What was wrong with it is narrower than its
existence: it read as settled repository policy, when whether VISION.md
itself should be reconciled is an open question belonging to the captain.
One sentence now says so, and says that the conditions listed below it are
what the interpretation depends on. That narrows the claim rather than
widening it.

The carried-over fix. The first commit on this branch is 7f98e79 from
fm/voice-relay-build-v4, taken verbatim rather than rewritten. It closes
the window where a transport failure was recorded and then erased, so a
run could be emitted as answered false with relay_error null. That matters
more than it looks: relay_error is the field that keeps an infrastructure
failure from being averaged into a latency figure, so the failure mode is
a dead connection wearing the costume of a slow reply. It landed fifteen
minutes after kunchenguid#2767 merged and so never reached the default branch.

* no-mistakes(review): name a reason on every unanswered-turn close path

* no-mistakes(review): guard the downlink body and pin frames to their turn

* no-mistakes(review): attribute reply audio to its own turn and tell endings apart

* no-mistakes(review): tell a cut-short reply from an unanswered turn

* no-mistakes(review): discard reply audio arriving after the output closes

* no-mistakes(review): count discarded reply audio on the speaker path too

* no-mistakes(review): keep a reason off a turn already answered in full

* no-mistakes(review): say a reset cut a reply short, not that none arrived

* no-mistakes(review): read one turn's audio count once, and hush a tidy exit

* no-mistakes(document): fix stale session-end relay_error claim in voice-relay guide
…unchenguid#2811)

A pi worker parked on an interactive prompt - a permission dialog, a
question menu, a trust dialog - reports agent_status=blocked, because it
is waiting on a human keystroke. Pi draws that menu above its separator
pair, so the composer region between the rules is blank and structure
alone looks like a free composer. _fm_composer_pi_verdict admitted
blocked alongside idle and done, so the shared classifier reported an
affirmatively empty composer for exactly the pane where typing is unsafe.

Every "is it safe to type here?" consumer reads that verdict and proceeds
only on an affirmative empty, so both are told yes on a parked prompt:
the away-mode injection guard in bin/fm-supervise-daemon.sh, and fm-send's
pre-type refusal. The keys then answer the menu instead of composing a
message - the highlighted default is selected, the text is discarded, and
the record attributes a decision to a human who never made it.

blocked now defers to unknown, which every consumer already treats as
fail-closed. idle and done still prove an empty composer, so ordinary
steering is unchanged, and Cursor is unaffected because its always-blocked
panes never reach this pi-only branch.

Regression coverage lands first at both levels: the verdict owner
(a blocked pi defers) and the herdr adapter (a parked pi prompt is not an
empty composer).
…2849)

* fix(bin): require a clone root before fleet-sync touches a project

Git repository discovery walks upward, so `git -C projects/<dir>` on a plain
directory nested under projects/ resolves to the enclosing repository - in a
firstmate home, the firstmate checkout itself. fm-fleet-sync.sh guarded its
candidates with `rev-parse --is-inside-work-tree`, which such a directory
passes, so every later git call read, pruned and fast-forwarded firstmate's own
default branch and reported it under the project directory's label. A running
session's AGENTS.md changed underneath it, and the report named a project that
had nothing to do with the change.

Require each candidate to be the root of its own work tree before any other git
command: compare `rev-parse --show-toplevel` against the directory's own
physical path. Both sides are physical, so a symlinked clone still compares
equal. Anything else is skipped by name, naming the repository that would have
been touched, and bootstrap relays that as a FLEET_SYNC line.

Regression coverage reproduces the wrong-repo fast-forward against a home nested
inside another repository, in both the whole-fleet and single-project forms, and
pins that a symlinked clone dir still syncs.

* no-mistakes(review): Keep enclosing fixture clean during clone-root regression
* fix(procevent): retry a transient Lavish poll interruption quietly

A live Lavish listener can be cut short by the server with exactly

    error: Lavish Editor poll response was interrupted
    code: SERVER_ERROR

while the session's marks remain available. Firstmate registered raw
`lavish-axi poll` output, so the generic process-event runner captured
that transient response as a result and woke the whole fleet over what is
really an internal retry.

The Lavish adapter now registers its own listener command, which reruns
the published blocking poll up to 12 times at 5 second intervals for that
one exact two-line response. The match is deliberately narrow: real
feedback, ended and missing sessions, any other SERVER_ERROR, and the same
interruption still standing once the bound is spent all pass straight
through and are captured and announced as before. The retry is a Lavish
fact, so the generic runner stays adapter-agnostic.

`FM_LAVISH_POLL_RETRY_DELAY` is a bounded 0 to 60 second override for the
interval only, refused rather than rounded when malformed, so a test can
exercise the real bound without waiting it out.

* no-mistakes(review): Harden Lavish retry matching, validation, and cleanup

* no-mistakes(review): Bound Lavish retry staging and stabilize regression

* no-mistakes(document): docs: explain Lavish retry adoption

* no-mistakes(lint): Restore Lavish trap ShellCheck suppression
… gate (kunchenguid#2838)

The unguarded Herdr declaration quoted `{TASK}` in its own prose while the
scaffold instructs firstmate to replace every `{TASK}` placeholder. The
documented global replace therefore spliced the whole task body into the
middle of the safety gate's sentence, silently destroying the one contract
that exists precisely because the scaffold cannot inspect the task text.

Reword the gate to refer to the task text filled in above, leaving the
placeholder only at its genuine fill site. Rewording rather than renaming the
token keeps the unfilled-charter guards in fm-home-seed.sh and
fm-remote-home-seed.sh working unchanged.

Add a regression test that performs the documented global fill on ship and
scout scaffolds and asserts the body lands once and the gate survives.
…tat form (kunchenguid#2837)

The writer lock's stale-lock branch read the lock's mtime with
`stat -f %m ... || stat -c %Y ...`. On GNU coreutils `-f` is filesystem
stat, so it consumed the format string as a path, complained on stderr,
printed a partial filesystem dump ("  File: ...") on stdout, and still
exited 0. The GNU form in the fallback therefore never ran, and the
following arithmetic evaluated the word `File`, aborting the writer under
`set -u` with "File: unbound variable".

fm-teardown.sh died there after returning the worktree, leaving
state/<id>.meta, .status, .busy-gen, .busy-state, .busy-state.lock/ and
.turn-ended behind. The surviving metadata kept the watcher monitoring an
endpoint whose agent was gone, so a finished task produced stale wakes
forever, and every re-run died identically because the abandoned lock was
never broken.

Detect the platform once and pick the right stat form, the pattern
bin/fm-watch.sh already documents, and treat any non-numeric result as
"just created" so a future portability surprise degrades to a lock-timeout
refusal rather than killing teardown mid-way.
* fix(stow): give memory decay a per-pass horizon so the clock fires

The tiered decay clocks were wall-clock only, while admission is per-pass:
each /stow admits the findings that pass produced. In a home that stows
daily those two rates diverge by the stow cadence, an entry the fleet keeps
exercising never reaches 30 days unreinforced, and memory only grows while
the pass reports decay evaluated.

Give each dated marker an optional unreinforced-pass counter and make both
tiers stale at whichever horizon comes first: 10 passes or 30 days for
aging, 3 passes or 7 days for perishable. Reinforcement clears the counter
and nothing else does, so the existing evidence-based restamp rule stays
the only way an entry renews its lease. An absent /N means zero, so entries
that stay exercised carry no extra marker bytes, and a rarely stowed home
keeps its current behaviour through the unchanged date horizon.

* no-mistakes(document): Align stow workflow with dual decay clocks

* fix(stow): make the per-pass decay horizon opt-in

The unreinforced-pass horizon shipped as a new default archival cadence,
which is a product default rather than a restoration of the existing
wall-clock contract. Keep the 30-day and 7-day horizons as the only
default clock, and put the 10-pass and 3-pass horizons behind an explicit
opt-in: config/stow-pass-horizon for the firstmate home, and the file's
own header pointer for the public skill.

With the opt-in absent no counter is written and no counter is read, so a
home that does not ask for it decays exactly as it does today.

* no-mistakes(review): Preserve frozen counters and correct archive provenance
…artup (kunchenguid#2876)

tests/fm-watcher-lock.test.sh passed in isolation but failed intermittently
under full-suite and ambient concurrent load. bin/fm-watch-arm.sh computes its
confirmation deadline immediately after forking the real child watcher, so the
child's entire fork, exec, lock acquisition and beacon publication has to land
inside that wall clock. Two cases shrank that budget to one second, leaving a
two-second window for work measured at 3.1-4.9s under CPU oversubscription, so
the arm honestly reported "FAILED - no live watcher with a fresh beacon" and
their premises collapsed. A third case ran on the production budget, but its
child must also execute a registered check before exiting: measured at 1.9-2.3s
idle and 9.1-13.1s under load, against an 11s budget.

The two cases that must confirm a real child now hold the arm to production's
own budget instead of a shrunken fixture one, the immediate-wake case gets an
explicit budget with headroom over its measured loaded cost, and the two waits
for the arm's typed failure are sized off the largest production default rather
than a fixed eight seconds.

No bin/ change and no default behavior change: the lock's fail-closed semantics,
SIGSTOP handling, stale-heartbeat detection and the arm's typed failures are
untouched. Verified 4/4 green at 3x CPU oversubscription (loadavg 75-80) after
3/3 red before the change, and CONTRIBUTING.md records the convention.
* fix(bin): order discovered tool installs by the shell's own expansion

fm_remote_job_compose_operator_path built the asdf and mise install
directories with `compgen -G`, which does not sort. Bash sorts glob
matches in pathexp.c, on the shell's own pathname-expansion path only;
`compgen -G` reaches the same glob_filename through pcomplete.c, which
sorts nothing. On bash 3.2 (macOS /bin/bash) and every bash before 5.3
that handed the composition raw readdir order, so which install of a
multi-version tool a remote job resolved was decided by directory order
on disk rather than by this composition.

Expand the globs at the call sites and let the function take the matches,
so the composition and the documented portable-PATH contract are the same
operation. Quoting the account home at the call site also stops a home
whose name contains glob metacharacters from being reinterpreted.

The colocated regression pins both the order and the mechanism: bash 5.3
moved sorting into the glob library, so an order-only assertion cannot
see the defect there.

* no-mistakes(review): Remove source-reading PATH regression guard
…2848)

* fix: surface stalled secondmate queues and wake handoffs

* no-mistakes(review): Make handoff wakes retryable and stall alerts crash-safe

* no-mistakes(review): Prevent duplicate handoff wakes and cover remote delivery

* no-mistakes(review): Serialize local handoffs and preserve pre-move wake intent

* no-mistakes(review): Serialize teardown with handoffs and retain remote wake confirmation

* no-mistakes(review): Reconcile correlated handoff wake delivery after crashes

* no-mistakes(review): Keep failed wakes retryable and isolate stall receipts

* no-mistakes(review): Reset known-undelivered wake attempts for durable retries

* no-mistakes(review): Refuse duplicate sends for unresolved delivery attempts

* no-mistakes(review): Atomically restore retryability after reconciled send failures

* no-mistakes(review): Serialize delivery confirmation with reconciliation

* no-mistakes(document): Document routed wake and stall supervision

* no-mistakes(lint): Fix ShellCheck expansion and subshell warnings

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes(review): Retire stale wake state and defer pre-move wakes

* no-mistakes(review): Secure markers, bind batches, and preserve teardown routes

* no-mistakes(review): Preserve unresolved prepared wakes across unrelated handoffs

* no-mistakes(review): Preserve prepared wakes before unrelated moving handoffs

* no-mistakes(document): Document prepared wake batch ownership

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes(review): Make local wake retirement recoverable

* no-mistakes(document): Clarify handoff recovery and teardown documentation
…guid#2856)

* feat(bin): steer local tasks by durable inbox record plus constant doorbell

Stage 1 (local steers) of the captain-adopted reframe in
data/fm-send-reliability-reframe-s1/report.md: an ordinary fm-send text
steer to a task recorded in this home is appended as a sequenced durable
record under state/<id>.inbox/ and the terminal receives only one constant
self-describing doorbell line, best-effort. The worker acknowledges by
moving the record into handled/; the watcher re-rings an unacknowledged
message on an idle pane and escalates once as an ordinary stale wake.
--resolve-key closes decisions at enqueue time, because the durable
enqueue IS delivery to the task's record. bin/fm-task-inbox-lib.sh owns
the record format, doorbell line, and re-ring ladder.

The typed plane remains for what must reach the terminal itself:
lifecycle keys, harness-native slash and codex $-skill invocations,
explicit backend targets, and the remote secondmate leg (unchanged until
the remote inbox leg ships separately). The composer classifier is
demoted from delivery proof to an advisory ring guard that skips only on
a proven pending verdict.

Verified live against claude, codex, opencode, pi, grok, and muse: each
real worker read its record, acted, and acked with the mv
(docs/verification/runtime-backends.md "Steering-inbox doorbell").

* docs(verification): flag the grok 1.0.5 composer-matrix staleness observed by the doorbell run

* test(captain-hold): read the chat-channel answer from the durable inbox record

* test: migrate fm-control's marker contrast to the inbox record and fix macOS wc padding in the tool-update suite

* no-mistakes(review): Harden inbox locking, teardown races, and acknowledgements

* no-mistakes(review): Serialize watcher actions with inbox acknowledgements

* no-mistakes(review): Bound metadata locking and tighten acknowledgement rechecks

* no-mistakes(review): Preserve exact inbox bytes and harden delivery recovery

* no-mistakes(review): Harden watcher bookkeeping against concurrent inbox teardown

* no-mistakes(document): Update inbox and typed-plane documentation

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* revert(pipeline): keep parser-native secondmate marking and the both-failed exit out of stage 1

The CI monitor's fix changed the secondmate marking contract for
parser-native invocations (appending the marker after the text) and
softened the both-commit-and-marker-failed branch to exit 0. The merge
authority ruled the marking question out of scope for this stage-1
transport PR (follow-up: fm-send-secondmate-harness-invocation-r1) and
ruled the both-failed case a loud nonzero local failure. Restore both,
keeping the monitor's legitimate migrations and hardening.

* no-mistakes(document): Document inbox and typed-plane boundaries

* no-mistakes(document): Scope backend transport docs to typed plane

* no-mistakes(document): Clarify inbox attempt-budget documentation

* no-mistakes: apply CI fixes

* fix(send): the durable record alone governs the inbox exit status

Captain-refined ruling on the F2/Greptile finding: the durable inbox
record is what delivers the steer, so pending-reply bookkeeping trouble
after a successful enqueue never exits nonzero - a resend-inviting status
would make automated callers enqueue the delivered instruction again
under a new sequence. With the recovery marker stored the watcher
reconciles silently; with the commit and marker both lost the send
surfaces a distinct reply-tracking-degraded do-not-resend warning and
still exits 0. Nonzero remains only where nothing was delivered (or a
decision close needs its manual command). Regression: record durable +
both bookkeeping writes lost -> exit 0, one record, no duplicate.

* no-mistakes(review): Preserve inbox ordering with drain-all doorbells

* no-mistakes(review): Surface unwritable inbox ladder bookkeeping

* no-mistakes(review): Silence ladder failures after inbox acknowledgement

* no-mistakes(document): Update steering inbox documentation

* no-mistakes: apply CI fixes
* feat: add fast local lint mode

* fix: preserve complete fm-lint help

* fix: isolate fast lint mode

* no-mistakes(document): Clarify lint mode documentation ownership

* no-mistakes: apply CI fixes
…#2901)

* feat(bin): deliver remote secondmate steers through durable task inboxes

Stage 2 of the inbox+doorbell steer channel (stage 1: kunchenguid#2856). A remote
secondmate steer now crosses fm-on.sh as a durable record written
idempotently into the remote home's steering inbox plus a best-effort
remote doorbell, and the last typed-payload steer transport is deleted:

- fm-remote-secondmate-control.sh cmd_send writes the record via the new
  fm_task_inbox_write_idempotent and rings the doorbell; it no longer
  types the payload through an inner fm-send at an explicit pane target.
- fm-send.sh routes every remote text steer (harness-native included,
  which marking already reduced to chat) onto the remote inbox leg,
  retries the identical leg once on ssh 255, closes --resolve-key
  decisions at enqueue for remote too, and preserves a marked request's
  reply expectation when completion stays unknown. The exit-3-as-
  delivered remap, the 255 do-not-resend trap, and the remote typed
  submit block are removed.
- fm-task-inbox-lib.sh owns the idempotent enqueue: an exact-body re-run
  lands on the existing record, handled or not, so an ambiguous
  transport can always be safely re-run.
- Tests pin the new contract end to end (record + doorbell + no typed
  payload across ssh, one-record idempotence under an ambiguous
  transport, enqueue-time decision close, loud real failures, and the
  deleted typed-payload behaviors gone), and AGENTS.md plus
  docs/remote-secondmates.md describe the remote leg's new semantics.

* no-mistakes(review): Harden remote inbox delivery against lifecycle races

* no-mistakes(review): Enable correlation-preserving remote steer resends

* no-mistakes(review): Fail closed on stale correlation resends

* no-mistakes(review): Include home context in remote resend commands

* no-mistakes(review): Lock and revalidate remote parent routes

* no-mistakes(document): Clarify remote steer retry documentation

* no-mistakes: apply CI fixes
* wip: forked supervision on Pi (checkpoint before docs)

* fix(pi-branch): harden mirror delivery, fallback encoding, and session replacement

Peek-then-shift mirror flush so a failed append retries instead of dropping;
durable mirror cursor commits only after delivery into the branch;
the main fallback wake is operational-encoded like every watcher injection;
session_shutdown quiesces the generation and session_start re-arms, so /new
and /resume no longer kill the branch permanently. Registers the extension in
the strict typecheck, adds the dispatch handshake test, the branch extension
suite, the bash-level regression suite, the session-start replay test, and
the opt-in real-SDK live guard.

* test(fixtures): carry the branch-dispatch lib and lease lib into isolated fixtures

The watcher extension now imports lib/fm-branch-dispatch.ts and fm-teardown
sources fm-lease-lib.sh, so every fixture that copies or symlinks those
files in isolation gains the new sibling.

* no-mistakes(review): Prevent shutdown wake loss and serialize lease claims

* no-mistakes(review): Durably hand off wakes and retain portable leases

* no-mistakes(review): Require durable reports and clear disposed branch leases

* no-mistakes(review): Enforce per-wake outcomes and quiescent lease cleanup

* no-mistakes(review): Require wake acknowledgements and tighten branch lifecycle boundaries

* no-mistakes(review): Require complete acknowledgements and replay cleanup failures

* no-mistakes(review): Bind supervision to lock ownership and durable delivery

* no-mistakes(review): Activate branch lazily after session lock acquisition

* no-mistakes(review): Preserve undelivered mirror context across extension rebinds

* no-mistakes(review): Acknowledge startup replay only after main delivery

* no-mistakes(review): Isolate replay metadata from untrusted digest content

* no-mistakes(review): Reject duplicate reports for active wake sequences

* no-mistakes(review): Retain failed fallbacks and deduplicate outcome replay

* no-mistakes(review): Deduplicate durable outcomes and cache delivery receipts

* no-mistakes(review): Anchor wake sequence matching to outcome fields

* no-mistakes(document): Clarify Pi supervision durability contracts

* no-mistakes(lint): Fix ShellCheck issues in branch supervision scripts

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* refactor(pi-branch): collapse to confused-agent-grade guards per captain decision

Captain decision A: the lease/actor guards target the CONFUSED-AGENT threat
model bin/fm-gate-refuse-lib.sh already documents; adversarial-grade
separation is impossible in the shared-process design and is filed as
separate follow-up work. Rip out the machinery that chased it: the
generation fence and shell-provenance markers, the wrapper-tagged ancestry
walks, guard auto-claim with per-script release traps, the pending-wake
files and ack-receipt correlation (the durable wake queue already
re-presents anything unacknowledged), the delivery-receipt store with
contiguous cursor advancement, the session-start replay-metadata channel,
and the branch tool quiescence counters.

Keep the behaviors the board requires, each on its simplest implementation:
lazy per-action session-lock ownership (cold start activates after the lock
lands; a secondary session stays inert), mirror durability across extension
rebinds via the durable cursor, replay-exactly-once from the one read
cursor, the awaited operational-encoded fallback, per-generation stray-lease
cleanup, session-lock-bound lease liveness (a recycled pid or a non-Pi home
never honors a leftover lease), the loud accidental-override guards
(readonly actor prelude, cross-actor claim refusal), and the role-partition
refinements (no forced teardown, no direct relaunch for the branch).
Default-on-for-Pi is unchanged.

* no-mistakes(review): Enforce lock ownership and serialize lease mutations

* no-mistakes(review): Synchronize guard cleanup and bind leases to lock owner

* no-mistakes(review): Report outcomes before acknowledging durable wakes

* no-mistakes(review): Restrict leases to Pi and instruct main claims

* no-mistakes(review): Reject malformed lease locks and torn outcome tails

* no-mistakes(review): Validate complete outcome tails before appending

* no-mistakes(review): Guard branch side effects across session replacements

* no-mistakes(document): Update Pi supervision durability and lease documentation

* no-mistakes(lint): Suppress intentional nested-shell expansion warning

* no-mistakes: apply CI fixes

* fix(pi-branch): authorize lease releases by caller

* fix(lint): break redundant source-analysis path in fm-lease-lib.sh

fm-lease-lib.sh's lazy fallback source of fm-wake-lib.sh gave ShellCheck's
--external-sources traversal a second path into an already 1540-line file
that fm-send.sh and fm-teardown.sh also source directly, blowing up the
recursive analysis past CI's lint timeout. Mark it a source=/dev/null
analysis boundary, matching the existing fm-task-inbox-lib.sh convention.

Also restores bin/fm-lint.sh and tests/fm-lint.test.sh to the shared
serial-lint definition (dropping an unrelated parallel-sharding change
that was itself hanging and masked this root cause).

* no-mistakes(document): Correct lease caller-authorization documentation

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes
* feat(bin): parallelize session-start remote secondmate network sweeps

Run per-secondmate liveness and convergence probes concurrently and overlap clone refresh, while replaying each mate's fail-closed diagnostic in original order. Ignore scratchpad* so untracked scratch no longer blocks remote sync.

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

* no-mistakes(document): Document parallel startup network sweeps

* no-mistakes(lint): Fix empty environment assignment lint warning

* no-mistakes: apply CI fixes

---------

Co-authored-by: Cursor <[email protected]>
* fix(tests): count declared-pause wakes without crashing on an absent queue

The exited-declared-pause case counts queued stale wakes by handing
state/.wake-queue straight to awk. A watcher that queues nothing never
creates that file, and awk aborts on a missing path before its END rule
runs, so the count collapses to the empty string. The next comparison
then fails as an integer-expression error and surfaces as a wake flood
with no number, hiding the real contract breach the following grep names.

Read the queue the way the drain-count assertion at the end of this file
already does: silence awk's open error and default an absent queue to
zero. Applied to all four counts in this case, including the live
external-decision gate pair whose queue an acknowledged drain can also
leave behind. An absent queue now reports "did not use the bounded
paused recheck", while a genuine flood still fails with its real count.

Fixes kunchenguid#2628

* no-mistakes: apply CI fixes

* no-mistakes: apply CI fixes
… icon (kunchenguid#2934)

* style(pi): restyle supervision merge notes with a sailboat and matching pad

Secondary-session notes were flush against the TUI edge and fully tinted.
Use the sailboat prefix, Pi's default outputPad, boat-only color, and dim remainder so they sit like real messages.

* style(pi): distinguish routine and captain merge notes by icon only

Visible notes now lead with a sailboat or anchor, then only the dim outcome.
Drop the branch-merged wording and verdict brackets so the icon is the only kind signal.
…id#2938)

The markdown contract stays the owner; the still is only the visual of the idea.
* fix(bin): bound remote worker supervisors

* no-mistakes(review): release incumbent supervisor before starting its replacement

* no-mistakes(review): wait out a healthy same-root supervisor instead of replacing it

* no-mistakes(review): narrow remote worker change to restart accounting only

* no-mistakes(document): clarify supervisor restart guard is a lifetime total
Brings in 22 upstream commits. Nine files conflicted; each was resolved by
establishing what both sides were trying to achieve and keeping both intents.

The substantive reconciliation is the steer plane. Upstream's durable steering
inbox (kunchenguid#2856/kunchenguid#2901) and this fork's opt-in steer-acknowledgment contract both
target silent steer loss, so they are merged into one layered mechanism rather
than two competing paths: the inbox is now the sole transport, and --ack is a
supervision layer over it. Because --ack's own eligibility rules are exactly
the conditions that select the inbox plane, every acknowledged order now rides
a durable record, and the typed-plane discard sites it used to rely on became
unreachable. fm-send.sh gains a single known-undelivered cleanup owner that
clears the pending-ack record alongside the pending-reply expectation, wired
into the inbox plane's pre-transport failure exits - without it an order that
was never recorded would still have escalated as unacknowledged.

Other resolutions:
- AGENTS.md: union of both state-layout additions; the steer contract takes
  upstream's transport description (multi-line text is now legal, so the old
  single-line rule would have been a stale instruction obeyed by every
  session) and keeps the --ack sentence, restated as a layer over the record.
- bin/fm-inbox.sh: upstream computes the note id before the write, removing
  the sed rewrite this fork had made BSD-safe. Its portability intent is kept
  structurally, so upstream's form is taken whole.
- bin/fm-brief.sh: upstream's kunchenguid#2838 Herdr-gate fix applies cleanly; this fork
  had no competing fix there. Scaffolds teach both the inbox acknowledgement
  and the [ack=<token>] reply.
- bin/fm-watch.sh, docs/scripts.md, tests/fm-gotmp.test.sh: positional or
  additive conflicts, resolved as unions.
- tests/fm-tool-update-check.test.sh, tests/fm-voice-relay.test.sh: both sides
  fixed the same macOS wc -l padding; upstream's tr -d form also cleans the
  padding out of the failure message, so it is taken.

tests/fm-steer-ack.test.sh is updated to assert against the carrier the order
actually travels on now. Its guarantees are unchanged in substance and the
suite is strictly stronger: it now pins both directions of the delivery
boundary - a record that cannot be written discards the pending-ack record,
while a failed or skipped doorbell keeps it armed.

No local behaviour was dropped.
…omment

The repo style rule is a plain dash, never an em dash. This comment
predates the merge and is the last em dash left in the merged file set.
…on cannot race the clock

test_tick_underivable_identity_still_matures_the_alarm computed
epoch_ago 400 separately for the tick time and for the expected
first_epoch. When a wall-clock second elapsed between those two
evaluations the expectation was one second off and the test failed,
reporting a window-arithmetic defect that did not exist. Observed as an
intermittent failure in a full-suite run.

Anchor the epoch once and derive the later tick from it, so the suite
asserts about window arithmetic rather than about the clock.
@adonis-garcia-git
adonis-garcia-git merged commit 74c54c1 into main Aug 26, 2026
12 of 13 checks passed
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.

5 participants