Skip to content

feat(bin): add private-material check and scrub private fleet material from tracked files - #1260

Closed
LuckyB-UF wants to merge 49 commits into
kunchenguid:mainfrom
LuckyB-UF:fm/fm-tracked-surface-leak-audit
Closed

LuckyB-UF wants to merge 49 commits into
kunchenguid:mainfrom
LuckyB-UF:fm/fm-tracked-surface-leak-audit

Conversation

@LuckyB-UF

@LuckyB-UF LuckyB-UF commented Jul 29, 2026 •

Copy link
Copy Markdown

Closed - opened against the wrong repository in error. This work belongs on the author fork and has been re-raised there.

LuckyB-UF added 30 commits July 15, 2026 14:32
AGENTS.md section 10 has prescribed `tasks-axi hold <id> --kind captain` for
a captain-gated thread since holds were documented, but firstmate's own rules
and tooling never caught up, so a held item has been mishandled ever since:

- The standing queue rule and its three restatements said a queued item gets
  dispatched once its blocker is gone and its date gate has arrived, with no
  mention of holds. The tasks-axi path is saved by `tasks-axi ready`, which
  excludes held work, but the manual hand-edit path had nothing to save it.
- fm-teardown.sh's manual-backend reminder is what firstmate reads at the exact
  moment it re-scans Queued, and it was hold-blind for the same reason.
- fm-fleet-snapshot.sh stripped only repo/kind/priority/since/merged/reported/
  done, so a held item baked its hold markers into its title. Because the strip
  is anchored at end of line, the trailing hold paren also blocked the since and
  repo parens, and no held field was exposed at all. fm-fleet-view could not
  tell a held item from dispatchable work.
- Section 10's verb map had no hold/unhold entry and no hand-edit marker form.

`tasks-axi start` moves a held item anyway and carries its marker into In
flight, so the checks are stated where the reader acts rather than left to the
verb to refuse.

Also corrects the tasks-axi compatibility contract at its declared owner.
docs/configuration.md said the floor was 0.1.1 while, in the same sentence,
requiring the multi-ID `mv` probe introduced in 0.2.2. That probe is mandatory,
so the effective floor has always been 0.2.2. AGENTS.md and fm-tasks-axi-lib.sh
now point at the owner instead of restating a number that can drift, and
fm-bootstrap.sh's header drops the same stale claim. Probe behavior is
unchanged; the fail-closed version-parse precondition is now documented rather
than dropped.

Snapshot behavior is covered by a test that fails without the parser fix.
Three defects in the hold parsing, two of them introduced by this branch's
own earlier rounds.

The dedicated comma-preserving hold_reason capture only matched the paren
form, so a hand-written comma-form hold parsed as held: false and rendered a
Gate of "-", i.e. dispatchable. That is the one direction this must never
fail, and it regressed a case that worked earlier on the branch. Hold
detection is now separate from reason extraction and keys on the hold: key in
either form, so an unreadable reason can no longer downgrade an item to
dispatchable. The reason still prefers the paren form, which carries commas
verbatim because tasks-axi forbids ")" in --reason; the comma form is
hand-written only and inherently ambiguous for free text, so it truncates at
the first comma rather than guessing.

tasks-axi hold also accepts --until, whose (hold-until: DATE) marker was
unhandled: because the metadata strip is end-anchored, an unstripped trailing
marker also stranded the earlier repo and since parens in the title.

Known gap, deliberately not fixed here: --until means "inactive on and after
that date", but an expired hold is still reported held. That fails closed, so
it over-reports rather than dispatching held work.
Adds the idea-sharpening step missing between a fuzzy request and a crewmate
brief. /grill interviews the captain one question at a time and writes a short
spec to data/spec-<project>-<slug>.md: problem, solution shape, vocabulary,
scope boundary, open questions, constraints.

It is a planning front-end and nothing more. It creates no branch, dispatches
nothing, and writes only its spec file under data/. The spec feeds the existing
brief and dispatch path rather than becoming a parallel record of work, so the
backlog stays the only tracker.

Deliberately small: a skill file, a conversation, and a doc in data/, the same
shape /bearings and /stow already use. It files no backlog item and needs no
new state, because the sharpen-then-decompose path is meant to run inside one
context window.

The spec filename carries the project because two projects can easily want the
same slug, and an unnamespaced spec would silently overwrite another project's,
unrecoverably, since data/ is gitignored.

The trigger offers rather than auto-starts: an interview nobody asked for is
the main way this would become annoying, so it loads on an explicit invocation
and otherwise proposes in one line. It also names when it must NOT fire -
already-sharp requests, bugs, scout questions, trivial changes.

The interview stays with firstmate. Prime directive 4 makes firstmate the
captain's only point of contact, so grilling never routes to a secondmate even
when one's scope covers the work; the resulting work routes normally.

AGENTS.md section 7 gains the optional sharpening path before dispatch.
This fleet runs a customized fork, so advancing a home straight from
origin would strip the fleet's private adaptations. Upstream now enters
only by being merged into fork/main, and homes advance from the fork.

bin/fm-update.sh:
- Ingest upstream first: merge origin/<default> into fork/<default> and
  push it to the fork. The merge is built with merge-tree/commit-tree
  plumbing rather than a checkout, so no working tree is touched and a
  conflicting upstream can never leave a home stranded mid-merge.
- A conflicting ingest STOPS the run: it names each conflicted path,
  pushes nothing, advances nothing, and exits 1. Never forced.
- Advance every home (main home's branch + live secondmate homes) to
  fork/<default> instead of origin/<default>.
- Secondmate discovery, the reread nudge, the projects/ boundary, and
  fast-forward-only safety for the advances are unchanged.

bin/fm-ff-lib.sh:
- Add the "fork" base mode alongside "origin" and <commit-ish>. The
  remote base modes are now named after the remote they track, so one
  case arm serves both and the contract is stated once.
- A target without a fork remote is skipped, never advanced from origin
  as a fallback.
- Generalize fetch_once to take a remote, deduping per (object store,
  remote) so worktrees still share a single fetch.

Docs (AGENTS.md section 12, the updatefirstmate skill, README,
docs/architecture.md, docs/scripts.md) describe the two-hop model and
carry the conflict-stop as a captain-facing decision.

tests/fm-update.test.sh: the fixture is now a real fork world (origin,
fork carrying a private adaptation, and a home tracking the fork).
Covers the ingest, the fork-based advance with adaptations intact, the
conflict stop, fork-history preservation, and the no-fork-remote skip.
Secondmate sessions launch with Claude Code's native predicted-next-prompt
suggestion enabled, so the operator sees the soft-text next-prompt hint in a
secondmate window exactly as in their own session. Ship/scout crewmates keep it
disabled: an autonomous worker has no reader to help, so the ghost text is pure
classifier risk. Safety for the enabled path rests on the existing fleet-wide
fm_composer_strip_ghost extractor, which every secondmate-reachable composer read
already routes through.

Refuse --secondmate on the plain-screen backends (orca, cmux, zellij) that cannot
strip ghost styling, collapsing the three refusals into one guard, so no secondmate
can land on a backend without the extractor. Docs and tests updated.
Fork ingest: resolved 8 conflicts (AGENTS.md, ci.yml, fm-bootstrap.sh,
fm-bearings-snapshot.sh, fm-fleet-snapshot.sh, bearings/SKILL.md,
configuration.md, zellij-backend.md). Preserved fork adaptations
(dispatch holds, /grill, origin->fork->homes self-update, secondmate
native prompt suggestions + zellij secondmate refusal) while adopting
upstream's instruction-ownership compression and #593/#640 changes.
See data/fm-fork-ingest-r3/report.md for per-file rationale.
…nded (#1)

* fix(teardown): refuse when a task's worktree slot was re-handed after an outage

fm-teardown.sh read worktree= straight from a task's meta and then killed the
recorded processes and returned that worktree to treehouse. That pointer goes
stale after an outage: treehouse frees a dead task's interactive pool slot and
re-hands it to a NEW task, but the dead task's meta still records the old slot
path, so tearing the dead task down would kill and return the live new owner's
worktree.

Add assert_treehouse_worktree_owner, layered before every destructive action.
Using treehouse's own status, it refuses on positive evidence that the recorded
slot was re-handed: the slot is now leased to a different holder, or it is
in-use by a live process while this task's own backend endpoint is gone. It
names the recorded path, this task id, and the current owner. The guard is
scoped to interactive treehouse worktrees; Orca, secondmate homes (leased
durably, so immune), and paths treehouse does not list pass through unchanged,
and it refuses only on positive foreign-owner evidence so it never breaks a
legitimate teardown.

The guard is intentionally not bypassed by --force: --force authorizes
discarding this task's own unlanded work, never destroying a different task's
live worktree.

Add regression cases covering a slot re-leased to another task, a slot in-use
by a live owner after this task's session is gone, --force not bypassing the
guard, and a still-owned slot proceeding as before.

* no-mistakes(review): fail closed on unrecognized treehouse slot states in teardown guard

* no-mistakes(review): align teardown treehouse guard docs and pin status contract

* test(fm-backend): expect teardown's treehouse status guard in conformance log

The reboot-hazard guard (assert_treehouse_worktree_owner) reads treehouse
status once before any destructive action, so the old-vs-new command-log
conformance check saw one extra leading status probe and failed. Filter that
single intended probe line out of the new log, still require the destructive
treehouse return --force + tmux kill-window sequence to be byte-identical old
vs new, and positively assert the guard ran.

* no-mistakes(review): harden teardown treehouse guard: confident liveness, exact lease, spaced paths

* no-mistakes(review): split treehouse guard state vs liveness so zellij/cmux teardowns proceed

* no-mistakes(document): document teardown re-handed treehouse slot guard in architecture and zellij docs
…r, bearings trigger, five-sweeps delegation, check.sh contract, orca date) (#2)

* docs(conformance): close firstmate-coding-guidelines drift findings

Apply the recommended low-cost subset from the fm-cg-review-r1 self-review,
all within firstmate's own shared tracked material:

- Add the missing bearings skill load trigger in section 9 (trigger hygiene).
- Trim the state/<id>.meta field enumeration to a pointer at
  bin/fm-spawn.sh --help and docs/configuration.md (kills schema drift).
- Delegate the mutating-sweeps roster to bin/fm-session-start.sh while
  keeping the lock-gated safety invariant inline (one-owner rule).
- Move the custom check.sh authoring contract into fm-check-register.sh's
  header and --help, leaving only the trigger and bind-before-run invariant
  inline; reduce the secondmate-liveness narrative to its invariant.
- Add the derived smoke-run date (2026-07-03) to docs/orca-backend.md.
- Reflow .agents/skills/afk/SKILL.md to one sentence per line (wording
  unchanged, line breaks only).

Relocations and restyles only; no contract meaning changed. fm-lint.sh clean.

* no-mistakes(review): document state meta fields in fm-spawn header and help

* no-mistakes(document): sync docs with fork-update and zellij secondmate-refusal changes
…o ship briefs (#3)

Complete the Matt Pocock planning-pipeline adoption (back half of the
grill -> spec -> decompose flow).

/decompose: new captain-invocable, internal skill that turns a grill spec
at data/spec-<project>-<slug>.md into dependency-ordered, independently
shippable vertical-slice backlog items via tasks-axi, wiring blocked-by
edges between slices (add upstream-first, since --blocked-by requires the
blocker to exist). Plans only: no branch, dispatch, or code, matching
/grill. Owns the decomposition procedure and defers backlog syntax to
section 10.

Ship-brief contract: fold the tdd seam-agreement discipline (agree the
test seam first, named anti-patterns) into fm-brief.sh's ship scaffold so
every ship brief carries it; not a standalone skill, per the plan. Scout
and secondmate briefs stay unaffected.

Wiring: AGENTS.md section 7 intake gains the optional grill -> decompose
path before dispatch; README lists /decompose beside /grill.

Colocated fm-brief tests assert the test-discipline section renders in all
three ship modes and is absent from scout and secondmate briefs.
…conformance (#7)

* fix(tests): filter teardown guard probe from both logs in old-vs-new conformance

The fm-teardown old-vs-new conformance test filtered the treehouse status
re-handed-slot guard probe out of only the NEW command log, assuming
BASE_REF (merge-base with main) always pre-dates the guard commit.
Once the guard landed on main, the old teardown emits the same probe and
the one-sided filter misreports it as a one-line regression, turning the
Behavior tests job red on every subsequent main build.

Filter the non-destructive probe from both logs symmetrically. Slot-occupancy
safety stays proven: the assert_contains directly above still requires the
new teardown to run the treehouse status guard before any destructive action,
and bin/fm-teardown.sh still calls assert_treehouse_worktree_owner before
treehouse return --force.

* fix(tests): expect the timeout refusal for non-worktree spawn aborts

Since the WSL spawn-worktree race fix (c61a5ac), fm-spawn.sh's detection
loop polls until the pane path passes spawn_worktree_ok instead of
aborting on the first non-worktree read, so a pane that never reaches a
genuine isolated worktree is refused via the loop's 60s timeout rather
than validate_spawn_worktree's immediate isolation error. The tangle-guard
abort expectations still asserted the old message, which failed both
locally and in CI - unnoticed in CI because the suite aborted earlier at
the fm-backend teardown conformance test.

Update the two abort cases to the current refusal message. The isolation
safety property is unchanged and still verified: the spawn refuses with
exit 1 and records no meta in both abort cases, and the success case now
also asserts the timeout refusal did not fire. A fast-refusal early abort
(avoiding the two 60s poll windows) is deliberately out of scope here and
filed as a follow-up.

* ci: raise Behavior tests timeout to fit the grown suite

The Behavior tests job was cancelled at its 15-minute cap with every
completed test green: the suite now takes ~15-18 minutes on the ubuntu
runner, including the two deliberate 60s non-worktree spawn-abort poll
windows exercised by fm-tangle-guard since the WSL spawn-worktree race
fix. Raise the cap to 25 minutes so a full green run fits with headroom
while still failing loudly on a genuinely hung watcher or tmux test.
Reconciles 8 conflicted files, preserving both sides' intent:
- .agents/skills/afk/SKILL.md: upstream's new terminal-verb/legacy-token
  classification semantics, reflowed to this repo's one-sentence-per-line style
  (the fork side was pure formatting normalization).
- .agents/skills/bearings/SKILL.md: took upstream's new (main-inventory) gate
  guidance; dropped upstream's duplicate 'queued item' sentence because the
  fork's hold-aware version of the same sentence already stands above it.
- .github/workflows/ci.yml: upstream's sharded lane structure (coverage guard,
  two portable parallel shards, portable serial, real-Herdr lane) as-is; the
  fork's old 25-minute monolithic-job cap is subsumed by the sharding (the
  serial lane keeps upstream's pinned 20m cap, with the fork's tangle-guard
  60s poll windows noted in its comment; fm-test-run.test.sh enforces the
  pin); macos-stock-bash counts set to the measured merged totals
  (snapshot 16, bearings 40).
- AGENTS.md: kept the fork's meta-field pointer trim (one-owner rule), folded
  upstream's GitLab merge-request fact into the pointer, took upstream's new
  <id>.herdr-presentation line.
- bin/fm-bearings-snapshot.sh: upstream's (main-inventory) synthetic gate row
  composed with the fork's hold-aware gate_by/gate_reason record mapping.
- bin/fm-spawn.sh: combined worktree-detect poll - a read must pass the fork's
  spawn_worktree_ok AND upstream's two-consecutive-stable-reads confirmation;
  restored real_path_or_raw which upstream's logic needs.
- docs/zellij-backend.md: fork's secondmate-refusal sentence with upstream's
  renamed herdr doc section reference.
- tests/fm-teardown.test.sh: add/add - kept both the fork's reused-slot guard
  family and upstream's herdr projection teardown family.
Upstream's shell-readiness loop in fm-backend-tmux-smoke opens every
iteration with a blind C-c. A SIGINT delivered while the freshly created
pane's shell is still sourcing its startup files can terminate the shell
before its interactive SIGINT handler is installed, closing the window and
turning the loop into 100 rounds of "can't find window" before the
readiness failure. Reproduced deterministically on WSL (tmux 3.6, slow
shell startup): an immediate C-c kills the new window, a C-c after ~2s
does not; pristine origin/main fails this test here while the pre-ingest
fork passes its older no-signal variant.

C-u keeps the loop's cleanup intent - discarding a stale unexecuted probe
line - as a line-editor kill consumed harmlessly from the pty buffer at
any startup stage, with no signal delivered to the shell. The probe never
leaves a running command behind (printf exits instantly), so C-c's extra
power to interrupt running commands is never needed here.

Verified: the test now passes all seven assertions in this environment.
…ocess

runProcess piped input into the child with child.stdin.end(input) and no
'error' listener on the stdin stream. A child that exits before consuming
stdin - a fast git rev-parse or an immediately-exiting guard - makes that
write raise EPIPE as a stream 'error' event, which Node treats as unhandled
and kills the whole plugin host process. In the suite this surfaced as an
intermittent fm-pi-watch-extension failure ("external healthy output"
case, ~1 in 3 full runs on a loaded WSL box) with a node:events unhandled
'error' traceback; the plugin is byte-identical on the merge base, the
fork, and upstream, so this is a pre-existing latent race exposed by load,
not an ingest regression.

Attach a no-op 'error' listener to child.stdin before ending it, the
standard guard for exactly this race; child.on('error') only covers spawn
failures, not stdin stream errors. Verified: six consecutive
fm-daemon + fm-pi-watch-extension pair runs green where the crash
previously reproduced within four.
…pant

CI's real-Herdr lane (PR #8) exposed a false-positive refusal in the
re-handed-slot guard: real `treehouse status` reports every plain
spawn-time `treehouse get` acquisition - every ordinary crewmate spawn -
as 'in-use' with NO holder name (named leases exist only for durable
holders such as secondmate homes). The guard demanded a live agent as the
only ownership proof for an occupied row, so a completely normal teardown
whose agent had already exited (its command finished, or the harness died)
was refused as 'held by another process' even though the occupant was the
task's own treehouse-get subshell, plainly listed under the row. All three
real-Herdr E2E teardown failures were this one misread; it never surfaced
before because no earlier CI lane combined a real treehouse with a real
backend teardown, and it would equally hit a real tmux teardown whose
agent exited before cleanup.

Add a positive-ownership axis, checked BEFORE the liveness heuristic: when
the recorded endpoint still exists and its current path resolves to the
disputed worktree, the occupant is this task's own pane, and the slot
cannot have been re-handed (treehouse's in-use detection is process-cwd
based - a slot our live pane occupies was never free). Every refusal path
is unchanged and still refuses: a foreign lease, a gone endpoint, a bare
shell parked outside the worktree, an unrecognized state, and --force
still does not bypass the guard.

fm_backend_current_path is the new backend-generic accessor beside
fm_backend_agent_alive; two colocated regression tests pin the proceed
(own pane in worktree, dead agent - the CI shape) and refuse (same dead
agent, pane parked elsewhere) directions. Verified against real Herdr
0.7.4 + real treehouse locally: all 3 previously failing E2E tests pass.
…ee poll

Implements the fast-refusal follow-up filed with the WSL spawn-worktree
race fix (PR #7), in its provably-safe subset. A pane whose reported path
is NONEXISTENT on two consecutive identical reads can never become an
isolated worktree, so the detection loop now refuses it in ~2s ('did not
yield an isolated worktree: ... nonexistent path') instead of burning the
full 60s window. The WSL transient the loop defends against - a
pre-shell-init cwd such as the multiplexer's default directory - is always
an EXISTING directory, so it can never match this fast path; existing
non-worktree paths still wait the full 60s timeout, and every refusal
shape exits 1, publishes no metadata, and runs the same cleanup.

This matters under the herdr presentation-order lock: its bounded (5s)
contention window surrounds this poll, so upstream's post-create abort
fixtures - which arm a nonexistent foreground_cwd and expect create+abort+
cleanup to serialize inside one lock hold - forced a concurrent sibling
into its flat fallback whenever an abort took 60s. With the fast refusal
the armed abort concludes in upstream's original timing envelope and the
serialized-cleanup invariant holds again. The fixture's refusal grep now
accepts both the fast-refusal and the poll-timeout message shapes,
asserting the abort rather than one message lineage.

Verified locally on real Herdr 0.7.4: the full real-herdr-gated family
passes 9/9 with --fail-on-gate-skip, including all three E2E tests that
failed on CI; fm-spawn-worktree-settle, fm-spawn-worktree-race, and
fm-tangle-guard (whose existing-path abort fixtures still take the 60s
window) stay green.
Reconciles 4 conflicted files, preserving both sides' intent:
- .agents/skills/afk/SKILL.md: upstream's new FM_OPERATIONAL_PREFIX semantics
  (with legacy FM_INJECT_MARK support) in all three hunks, reflowed to this
  repo's one-sentence-per-line style (the fork side was formatting only).
- .github/workflows/ci.yml: macos-stock-bash counts set to the measured merged
  totals (snapshot 17 = fork 16 + upstream's 1; bearings 43 = fork 40 +
  upstream's 3).
- bin/fm-bearings-snapshot.sh: adopted upstream's canonical partial-snapshot
  fields as the data source (unresolved_blocker_ids for blocked_by ids,
  captain_actionable for the secondmate queued filter - the canonicalized form
  of the fork's old hold-triple) while keeping the fork's hold-aware
  gate_by/gate_reason rendering: unresolved blocker ids join with ',' when any
  remain, a hold with no unresolved blockers still renders 'hold (<kind>)',
  and hold_reason still leads the reason field. Help text updated to the
  combined contract; the merged 43-test suite (fork hold tests + upstream
  partial-snapshot tests) passes.
- bin/fm-bootstrap.sh: header comment combines the fork's tasks-axi version
  floor detail (0.2.2+ effective, docs/configuration.md owns it) with
  upstream's new quota-aware dispatch semantics (every profile array calls
  quota-axi automatically; OS-backed random fallback).
Fold a captain-approved chat-conveyance discipline into section 9's
escalation etiquette: every captain-facing message should close on the
one decision, blocker, or next step it is asking for rather than a
recap of what was just done.
* feat: auto-apply session display names at spawn

Secondmate spawns now resolve a durable session display name on every
launch: an optional trailing 'label:' field on the data/secondmates.md
registry line, then a prior label= carried in the task's meta, then the
derived 'SM <Title-cased id suffix>' fallback. The resolved label is
recorded as label= in meta and threaded into the launch only for
harnesses with a verified session-name flag (claude -n/--name, verified
on Claude Code 2.1.217); other harnesses keep the label in meta and emit
no flag, the same omission contract as an unsupported effort value.
fm-home-seed.sh accepts FM_SECONDMATE_LABEL to pin an explicit label at
seed time and refuses labels that would break the single-line registry
format. The captain's main session is not spawned by fm-spawn, so the
new bin/fm-main.sh launch helper owns its 'FM Main' name. Ship and
scout spawns stay label-free and byte-identical.

* no-mistakes(review): preserve pinned secondmate label on reseed and fail-fast label validation

* no-mistakes(review): quote launch placeholder substitutions against patsub ampersand expansion

* no-mistakes(document): docs: cover session display names in scripts inventory, architecture, README

* test: expect the derived secondmate session name in the prompt-suggestion launch pin

The fork-main prompt-suggestion split test pinned the exact secondmate claude
launch suffix before the session-name feature existed; after the rebase the
launch legitimately carries the derived --name flag, so the pin now includes it.
…recon

# Conflicts:
#	.agents/skills/afk/SKILL.md
#	AGENTS.md
#	README.md
#	bin/fm-backend.sh
#	bin/fm-spawn.sh
#	docs/tmux-backend.md
#	docs/zellij-backend.md
#	tests/fm-backend-zellij.test.sh
#	tests/fm-spawn-dispatch-profile.test.sh
Reconcile shared upstream (origin/main) into fork main
Reconcile upstream's session-start, supervision, Kimi-adapter, and
documentation-split work with this fork's local adaptations.

Every conflict kept the fork's behavior and re-applied it on upstream's new
shape rather than taking whichever side read cleaner:

- fm-spawn.sh keeps the worktree-settle race fix, the fast nonexistent-path
  refusal, the per-kind claude launch templates, the session display-name flag,
  and the zellij --secondmate refusal, and gains upstream's Kimi binary
  resolution and turn-end hook install.
- fm-bootstrap.sh keeps the precise tasks-axi version-gate prose and takes
  upstream's corrected quota-axi sentence, since the selector it named is gone.
- The backend guides adopt upstream's guidance/evidence split; the fork's
  zellij --secondmate refusal is re-applied on the new shape, and the Orca
  smoke date moves to the verification record that now owns it.
- AGENTS.md and the afk skill keep the fork's size-discipline pointers and
  one-sentence-per-line style while adopting upstream's renamed doc targets,
  which the fork's own pointers no longer resolved to.
- tests/fm-kimi-harness.test.sh pins both per-kind claude templates so its
  byte-pinned guard covers the fork's actual shape.
- docs/documentation-audiences.json registers the fork's own skills so
  upstream's new classification check passes.
Merge upstream into the fork (round 3)
A fleet may ship to its own fork rather than to the repository it cloned:
origin is the shared upstream and ingest-only, a second remote is the fork,
and fm-update.sh advances every home from the fork. `gh repo set-default`
records which of the two is the pull-request base.

Two tools that decide where work lands never see that record, because neither
runs in the project checkout. The worktree pool resets each worktree to
refs/remotes/origin/HEAD, and the no-mistakes pipeline builds a worktree of a
bare mirror whose only remote is whatever origin was when the gate was
initialized. On a fork-shipping fleet both resolve the upstream, so pull
requests open there and branches start on the upstream's default branch -
which also makes every pull request carry the commits separating the two
repositories.

Converge those tools onto the configured base repository instead of relying on
telling a worker where to aim, and never rename or repoint the checkout's own
remotes, because the origin/fork split is what the update path is built on:

- fm-pr-base-lib.sh resolves the base repository from gh-resolved, else origin,
  and spots a branch cut from another remote's default branch. A branch that
  deliberately merges the other side in is told apart by containment.
- fm-pr-base.sh points the pipeline's own checkout at the base repository, on
  both keys that decide it. Run at each locked session start, idempotent, and
  reported as PR_BASE when it cannot converge.
- fm-worktree-base.sh puts a fresh task worktree on the right default branch
  before a branch is cut from it. fm-spawn.sh calls it after the isolation
  assertion. A worktree holding work is reported, never moved.
- fm-pr-check.sh refuses a pull request that reached the wrong repository or
  was cut from the wrong default branch anyway, recording and arming nothing.

The expected repository is always derived from configuration, so each fleet
resolves its own fork. All of it is a no-op for a project that ships to its
own origin.
LuckyB-UF added 19 commits July 29, 2026 14:03
…mpty (#13)

* fix(composer): trim Unicode blanks so an idle Claude composer reads empty

Claude Code 2.1.220 draws its idle composer as an unbordered `❯` (U+276F)
followed by U+00A0, a no-break space that `[[:space:]]` does not cover. The
shared composer classifier trimmed only ASCII whitespace, so the residual
no-break space survived and read as real unsubmitted text: every idle Claude
pane classified as `pending` instead of `empty`. Away-mode escalation injects
only on an affirmative `empty`, so it deferred every escalation indefinitely -
one window logged 2113 deferrals over 42062 seconds with no live delivery.

Add fm_composer_trim as the one fleet-wide blank trim - ASCII whitespace plus
every Unicode space separator and the two zero-width characters - and apply it
inside fm_composer_classify_content, which fixes all four backends that share
the classifier (tmux, herdr, orca, cmux) at their single owner. The blanks are
matched as literal UTF-8 byte strings rather than a byte class, because U+202F
(E2 80 AF) shares its lead byte with `❯` (E2 9D AF), so the trim stays correct
under LC_ALL=C.

The injection-safety direction is unchanged and pinned by tests: real
unsubmitted text still reads `pending`, a bare shell prompt still reads
`unknown`, ghost-only rows still read `empty`, and FM_COMPOSER_IDLE_RE still
works as a per-harness override.

docs/herdr-backend.md records the captured bytes, the verified CLI version, and
the exact commands and output as a dated incident entry.

* no-mistakes(review): Strip composer glyphs locale-safely; document structural trim gap

* no-mistakes(review): Name per-backend verdicts for structural blank gap

* no-mistakes(review): Narrow blank-trim contract; pin orca/cmux unbordered unknown verdict

* no-mistakes(review): Scope composer blank-trim doc claims to measured backends

* no-mistakes(review): Collapse duplicated composer blank-trim contract to one owner

* no-mistakes(review): Read empty composer rows as empty only when structural

* no-mistakes(review): Fix e2e pane fixture, drop dead empty branch, correct bordered contract

* no-mistakes(review): Scope composer empty-row rule; keep container-less delivery

* no-mistakes(review): Close plain-row blank-trim injection gap; refresh fixture comments

* no-mistakes(review): Narrow composer trim locale-independence claims to measured scope

* fix(composer): stop blank-trimming the plain row; scope the declined permission

The plain-content path was blank-trimmed while closing the Unicode-blank gap,
which let a blanks-only raw row skip the ghost-only branch and reach the
empty-row decision as `empty`. Measured against fork/main:
`fm_composer_classify_content 0 '' '' sensitive '   '` read `unknown` before and
`empty` with the trim in place - the injection-permitting direction, on a row
carrying no evidence it is an agent composer.

`[plain_content]` is the RAW row and the branch consuming it asks whether that
row carried anything at all, so it is deliberately left untrimmed and the second
ascii_only_plain guard it needed is removed with it.

Verdicts this branch changes against fork/main, measured under LC_ALL=C.UTF-8
with a harness that asserts the known-good controls on both libraries first:
glyph plus Unicode blanks goes pending -> empty (the reported claude wedge);
a Unicode-blanks-only row goes pending -> unknown (the one new permission,
declined); a row of only a glibc-wide blank such as U+3000 goes empty ->
unknown; and an untrimmed all-ASCII-blank row goes empty -> unknown. The last
two defer in the safe direction and no adapter produces them, since tmux, herdr,
orca, and cmux all ASCII-trim their candidate row before calling this owner.

Re-verified end to end with no FM_COMPOSER_IDLE_RE override: four live claude
panes read empty, Pi's container-less composer on real tmux still reads empty,
and the away-mode defer diagnostic now names the new unknown cause.

* no-mistakes(review): Correct stale plain-content trim claim; record two residual gaps

* no-mistakes(review): Assert exact composer verdicts in idle-row regression tests

* no-mistakes(review): Record ghost-only de-emphasised-glyph deferral as residual gap

* no-mistakes(document): sync composer blank-trim docs across backends and skills
…ce (#15)

* perf: cut firstmate's own token overhead on four axes

Firstmate's coordination cost is calls x context size x rate. Four changes,
one per term.

Context size:
- AGENTS.md section 2's inline state/ and config/ tree was a second full copy
  of a contract docs/configuration.md already owns, which its own first line
  says. Apply the inline-stub pattern: keep the four top-level directories,
  their read/write posture, and the hand-editing prohibition on watcher,
  wake-queue, auto-arm, and sub-supervisor coordination records; move the
  per-file ownership map into docs/configuration.md. Sections 1 and 7 are
  byte-identical and section 8 is additive only.
- Add a context-recycling cadence: a three-line trigger in section 8, with the
  threshold, the seven-condition safe-point test, the no-loss guarantee, and
  the reset handoff owned by the stow skill. Recycling refuses rather than
  resetting while any condition fails, and rests on durable state (the wake
  queue on disk, task status and metadata, and a session lock keyed to the
  harness process id) rather than on conversation.

Rate:
- Extend docs/examples/crew-dispatch.json with a routine-implementation mid
  tier and document the cheap/mid/strong/specialist tiering plus the one
  activation command. config/ is captain-private, so the live config is not
  written here.

Call count:
- State the cwd rule where it is read before the first shell call: never cd,
  use an absolute path or git -C. Add the same rule to both crewmate brief
  scaffolds, covered by a new fm-brief test. State once, in AGENTS.md, that
  the file is already in context and need not be re-read.

Measured on the always-loaded surface: AGENTS.md 53,152 -> 45,349 bytes
(-14.7%), section 2 alone 10,336 -> 2,053 bytes.

* no-mistakes(review): fix stow recycle gate, cd rule, and dispatch config activation

* no-mistakes(review): document wake-queue layout and orphaned state records

* no-mistakes(review): correct spawn, config, and migrate header ownership claims

* no-mistakes(review): scope AGENTS.md re-read rule and correct two header claims

* no-mistakes(document): sync docs with token-overhead reduction changes
* feat(skills): vendor the /watch video skill for the whole fleet

Vendor bradautomates/claude-video's `watch` skill into `.agents/skills/watch/`
so every home and clone gets it, replacing a machine-local user-scope install.

The skill downloads a video with yt-dlp, extracts frames with ffmpeg, and pulls
a transcript from captions (Whisper API fallback), giving the agent a video
input it otherwise lacks.

SKILL.md is kept byte-identical to upstream below its vendoring banner, so a
future upstream refresh stays a clean diff. This repo's one-sentence-per-line
and plain-dash Markdown rules are deliberately not applied to it; the banner
records that, the refresh procedure, the upstream commit pin, and an ffmpeg
version trap (`-vsync` is gone from master builds, so frame extraction needs a
7.x or 8.x release build). Upstream's dev-only build script and .skillignore
were dropped; the MIT LICENSE is retained.

The skill is captain-invocable, so its load trigger goes in AGENTS.md section 3
alongside the other capability tools rather than section 13, which is
explicitly agent-only.

Extends tests/fm-instruction-owners.test.sh with the vendoring invariants a
future edit could quietly break: the LICENSE, the upstream commit pin, the
refresh banner, the bundled scripts, exactly one trigger line, and no
agent-only listing.

Provenance: upstream skills/watch @ 83da59fa78c3eee9e20f515fe75c438bb5166efd,
v0.2.0, MIT.

* no-mistakes(review): classify vendored watch skill and gate its first run

* no-mistakes(review): bind watch consent to Step 0 and parse-check vendored scripts

* no-mistakes(review): bind watch install consent to every path and flag rm -rf trap

* no-mistakes(review): exempt vendored material from repo style rules

* no-mistakes(document): document vendored watch skill license and style exemption
…refusal (#12)

* feat(spawn): refuse provably-hopeless launches before the settle window

fm-spawn only ever runs a ship/scout task in an isolated git worktree of the
project. When it cannot get one, it previously discovered that only by burning
the full 60-second post-launch settle poll and then reporting "did not enter a
worktree within 60s" - a message naming neither the path involved nor why it
failed. An earlier round already fast-refused the one provably-safe pane-path
case (a stable NONEXISTENT path); this covers what remained.

Split the problem by what is actually provable:

- Provable from the project argument, before any window exists: the path names
  no directory, or names one outside any git repository. Neither can ever yield
  a worktree, by treehouse get in the pane or by Orca directly, so both now
  refuse in milliseconds with the path, the expectation, what was found, and
  what to do. The nonexistent-path case previously aborted with bash's own raw
  `cd` error.
- Not provable from the pane's cwd: a live shell can cd at any moment, so an
  existing non-worktree pane path stays polled for the whole window however
  stable it looks. A wrong refusal here would be worse than a slow one, so that
  loop is deliberately unchanged.

The settle timeout now names the path the window is parked on and the concrete
reason it is not an isolated worktree, and FM_SPAWN_WORKTREE_POLLS makes the
window sizeable (a malformed value is refused rather than silently shortening
the wait into an accidental fast refusal).

tests/fm-spawn-nonworktree-refusal.test.sh pins both sides of the line,
including that a pane reaching its worktree only after several polls still
succeeds. fm-tangle-guard uses the new knob, so its two deliberate non-worktree
aborts cost seconds instead of two minutes.

* no-mistakes(review): validate settle-window knob before launch, floor at 2

* no-mistakes(review): harden settle-window validation and derive help range

* fix(spawn): gate the nonexistent-path refusal on a confirmed project sighting

Two findings routed into the settle poll.

The nonexistent-path fast refusal rested on the claim that the pre-shell-init
transient it might collide with is always an existing directory, so it could
never match. That claim is not provable and the tree contradicted it:
tests/fm-spawn-worktree-race.test.sh reports a transient path it never creates,
and the loop's own comment always said the transient can span the first poll(s),
plural. On WSL a path can also read as absent while a mount is still coming up.
Reproduced: a nonexistent transient sustained across two consecutive polls
aborted a spawn whose pane went on to reach a genuine isolated worktree. That
wrong refusal is the one outcome this loop must never produce.

The refusal is now gated on having seen the pane at the project directory at
least once, which is the proof that shell init finished and treehouse get had
its chance - the same "confirmed sighting before trusting a divergence" shape the
WSL race fix established. The gate can only withhold the refusal and fall back
to the full window, so it fails in the safe direction, and the consecutive-read
requirement moved above the two reads acceptance needs. The unprovable claim is
gone from the comment.

The race fixture is strengthened rather than softened: its transient stays a path
that is never created, and the sustained-transient case is now a regression test,
red before this change and green after.

Second finding: only half the kimi poll pattern had been followed. The count was
overridable but the interval was still a hardcoded sleep 1, so
FM_SPAWN_WORKTREE_POLL_INTERVAL completes the pair, validated on the same
shape-before-arithmetic rule as the count because it reaches sleep directly and a
zero interval would busy-spin. fm-tangle-guard's two isolation aborts now cost a
fraction of a second of real sleep instead of two minutes; that script is down
from 2m13s to 11s. The herdr presentation fixture never reports the project
directory, so it can no longer take the gated refusal - its abort ids get a
bounded window there, keeping the abort on its previous timescale and well
outside the 5s presentation-order lock window, while healthy spawns in that file
keep the full default window.

* no-mistakes(review): reclaim orphaned settle-abort windows, bound settle window, widen interval shape, cover fast refusal

* no-mistakes(review): split settle-abort into safe reclaim and loud report

* no-mistakes(review): confirm settle-abort window removal and correct its orphan report

* no-mistakes(test): pass herdr abort settle window via env, not assignment prefix

* no-mistakes(document): sync spawn refusal docs, drop dangling kimi knob reference
…rowser (#14)

* feat(brief): direct crewmates to debug web work as a real user

The generated brief's Rule 3 only said "use chrome-devtools-axi for browser
operations", which was too weak to make browser-as-a-user reproduction a
standard step. A recent web investigation could not confirm what a page
actually rendered and fell back to reading code and querying the database.

Replace that line with a shared browser rule owned once and interpolated into
both the ship and scout scaffolds, so the two variants cannot drift. It names
chrome-devtools-axi for interactive inspection of live rendered state and the
project's Playwright/e2e harness for a scripted, repeatable user flow that
becomes the regression test once a fix is authorized.

The rule stays environment-agnostic: when a bundled interactive browser cannot
launch, it directs the worker to drive the system browser with Playwright
rather than falling back to code reading. No machine-specific detail is baked
into the shared scaffold.

Every existing safety line is untouched and rule numbering is preserved. The
brief test gains coverage asserting the guidance renders in both variants and
that the two copies remain byte-identical.

* no-mistakes(review): scope browser rule to existing harnesses, escalation, worktree carve-out

* no-mistakes(review): fix browser rule contradiction, escalation trigger, drift guards

* no-mistakes(review): bound browser carve-out to browser paths, guard empty blocks

* no-mistakes(review): scope browser fallback/escalation to web tasks, preserve reproduction

* no-mistakes(review): reduce header to pointer, scope browser carve-out outside worktree
Round 4 of the upstream ingest. 14 upstream commits against 35 fork-only
commits, 9 conflicted files. Both sides' intent is kept throughout; no
upstream hunk and no fork hunk was dropped to make a conflict disappear.

Mechanical both-sides merges:
- docs/examples/crew-dispatch.json: kept the fork's "Strong tier." label and
  upstream's quota-window pace wording.
- bin/fm-test-run.sh: union of both sides' additions to the backend-dispatch
  family; --check-coverage confirms all 106 tests stay mapped.
- bin/fm-bootstrap.sh: kept the fork's tasks-axi version detail and upstream's
  quota-array-dispatch pointer.
- bin/fm-spawn.sh: kept the fork's display-name flag and quoted launch
  substitutions, plus upstream's CLAUDE_CONFIG_DIR forwarding.
- .agents/skills/secondmate-provisioning/SKILL.md: kept the fork's
  origin->fork->homes self-update wording and upstream's config/backend entry
  in the inherited-material list.
- tests/fm-teardown.test.sh: kept the fork's optional window argument on
  write_meta and took upstream's session-qualified default plus the new
  endpoint_task_id field.
- AGENTS.md: kept the fork's retirement of the layout tree in favour of the
  docs/configuration.md pointer. Both upstream facts edited inside that tree
  survive in that owner (endpoint_task_id, config/backend inheritance), and
  upstream's four edits outside it merged unchanged.

Judgement calls:
- tests/fm-backend.test.sh: upstream's exact tmux selectors make the old
  byte-identical old-vs-new teardown log comparison unsatisfiable by
  construction, so upstream's removal of it is taken; the fork's assertion that
  teardown still runs its re-handed-slot guard is kept.
- bin/fm-brief.sh: upstream forbids a heredoc nested in a command substitution
  (stock macOS Bash 3.2). The conflicted TDD section and the two fork-only
  browser sections are converted to the read -r -d '' form with the matching
  trailing-newline trim; generated briefs are byte-identical across all six
  mode/kind combinations.
- bin/backends/tmux.sh: upstream's hardened kill accepts only session:window
  and applies '=' exactness markers, which rejects the tmux window id the
  fork's settle abort deliberately targets. Window ids are already unique
  server-wide, so they are now passed through unchanged and the name form keeps
  upstream's exact selectors. Both safety properties hold.

Fixture updates required by upstream's hardened endpoint validation:
- tests/fm-teardown.test.sh: session-qualified the whitespace-path fixture,
  gave the two zellij fixtures their explicit endpoint binding, and taught the
  default tmux mock to answer the list-windows inventory the agent-state probe
  now reads.

Documentation correction created by the merge itself:
- docs/configuration.md: upstream flipped config/backend to inherited while the
  fork had separately written a zellij sentence whose reasoning depended on the
  old contract. Both merged cleanly and left the file asserting both; the
  fork's sentence is restated under the new contract.
fork: reconcile upstream into fork main (14 upstream commits, 9 conflicts, both sides kept)
Firstmate's tracked surface is meant to be shareable: it must let a fleet
orchestrate private repositories without naming any of them. Publishing is
irreversible, so this both fixes what was present and leaves a check behind.

Fixes:
- fm-pr-base-lib.sh used a real fork owner as the case-folding example. Use a
  generic pair that already appears in tests/fm-pr-base.test.sh.
- The secondmate session-label examples in fm-spawn.sh, fm-home-seed.sh,
  docs/configuration.md, the secondmate-provisioning skill, and two tests used
  three real secondmate ids, which together disclosed the fleet's product
  surface. Replace them with generic ids that illustrate the same rule better:
  the derived form mangles an acronym (sm-api) and an abbreviation (sm-svc),
  which is exactly why an explicit label field exists.
- .gitignore enumerated ten config/ files, so any future config file was
  tracked by default and would leak on the commit that created it. Ignore the
  directory, which is private in full.

New check, bin/fm-private-material-check.sh:
- Derives markers at runtime from local gitignored sources (project clone
  names, registered project and secondmate ids, git remote owners, the account
  name, plus an operator file for what nothing can derive), so the check itself
  names no real entity and a public reader learns nothing from it.
- Matching is case-insensitive, word-bounded, and separator-insensitive, so a
  registered id is also caught in its display-name spelling. That is what found
  the two derived-form residuals a case-sensitive grep had missed.
- --history additionally scans past commit content and commit metadata, since a
  pull request carries author identity and messages into the target repository.
- A run with no marker sources reports SKIPPED and disclaims its own result, so
  a vacuous CI run cannot be mistaken for evidence the surface is clean.

The check matches names only and cannot see private strategy expressed as
ordinary prose; the header states its limits and CONTRIBUTING.md points to it.
Applies the four items from the third review round, which the pipeline
surfaced but could not commit because its fix agent died on exec.

- headhits-dedup-swallows-grep-failure: the HEAD-scan dedup ended in
  `|| true`, so a grep error read identically to "nothing left after
  dedup" and every committed-only hit was silently dropped. Capture the
  status and route anything above 1 through scan_failed, as the other
  scans in that loop already do, and guard the TIPHITS write too. This
  was a fresh instance of the fail-open class introduced by the previous
  round's own HEAD-scan fix, which is why it is the priority item.
- account-name-makes-tests-environment-dependent: the account-name marker
  source made the suite depend on the host account, because a name that
  is a STOPWORD or shorter than MIN_LEN raises a coverage gap and
  downgrades cases that assert a clean run. Shim `id` to a synthetic
  name so the result is deterministic, without weakening the source in
  real use and without hardcoding any real account name.
- allow-file-docs-say-token-but-code-accepts-lines: the prose said "one
  token per line" while the implementation and its test deliberately
  support multi-word identities. Correct the prose to match.
- The intermediate-commit hole is deliberately NOT fixed here. The
  default mode scans the working tree and HEAD, so a marker added and
  then removed on the same unpushed branch passes even though pushing
  publishes it. Defining the scanned surface once as the push range is
  the right fix and is filed separately rather than landing as a fourth
  patch in this round.
- Because that hole ships, the stated limit must be accurate: the
  guidelines scoped --history to upstream contribution while the hole
  applies to any push, so anyone following our own guidance would skip
  the mode that covers it. Widen the trigger to any push in the
  coding-guidelines skill and CONTRIBUTING.md, and record the hole in
  the script header's limits. A guard whose documentation steers you
  away from the mode that would have caught the leak is worse than no
  guard, because it manufactures the confidence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant