Skip to content

feat: full Rex support, including second mates - #7646

Closed
roderik wants to merge 16 commits into
kunchenguid:mainfrom
roderik:main
Closed

roderik wants to merge 16 commits into
kunchenguid:mainfrom
roderik:main

Conversation

@roderik

@roderik roderik commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

No description provided.

* feat(bin): add experimental Rex runtime backend for crewmates and scouts

Add bin/backends/rex.sh, a session-provider adapter that spawns, steers,
peeks, interrupts, exits, and cleans up ship and scout workers as unfocused
Rex tabs, selected by --backend rex, config/backend, or auto-detection from
a structurally proven Rex pane (after $TMUX and HERDR_ENV).

Every rex call passes the recorded server with -S and --autostart=false,
addresses sessions and blocks by full id, and strips REX_SESSION, REX_BLOCK,
REX_CLIENT, and REX_SERVER. Exit 3 on a full id means gone; exit 4 means
unknown. Tasks record rex_server, rex_server_instance, rex_session_id,
rex_window_id, and rex_block_id. Outside Rex each home adopts or creates
one firstmate session under state/.rex-session.lock and retires it with
its last tab. Rex capture includes scrollback, so rex stays out of the
visible-capture list. Secondmates and relaunch rebinding are refused.

Add bin/fm-rex-lab.sh (private lab server with a live-server tripwire) and
fm-brief.sh --rex-lab, a fake-binary suite, a token-free real-binary smoke,
an opt-in live Claude guard, docs/rex-backend.md, and the verification
record.

* no-mistakes(review): Hold Rex session lock across label check, create, rename
* feat(bin): run secondmates on Rex locally and remotely, with away mode

Secondmates now spawn on the rex backend: each opens as the first tab
of its own fm-<id> session, relaunch and reclaim reuse the recorded
session, and a dead endpoint is proven by exit 3 and respawned. Primary
workers move to a dedicated fm-local session, never the supervisor's
own session, and one adapter function owns placement and naming.

Remote secondmates can run on a host's own Rex app server in a visible
fm-<id> session (fm-spawn/fm-remote-home-seed --backend rex), with the
doctor checking the rex CLI and server instead of Herdr.

The away daemon supports a Rex supervisor pane through ancestry-proven
discovery, runs in a detached block of the captain's session, and keeps
the composer gate.

* fix(bin): skip busy-state retire when the record's state dir is gone

A remote secondmate's host-side record lives under its own home, so
retiring the home removes the busy state with it; the later retire
step then failed on the missing directory and left the route half
retired.

* test(bin): cover the remote Rex host control and record the ds9 run

The host control's rex arm now relies on endpoint validation for the
session binding, and a fake-rex unit test covers its route, missing,
unverified, and cross-backend refusal paths. The verification record
gains the live remote second mate run on a real Rex host.

* no-mistakes(review): Drop redundant parent-side Rex session check and record field

* no-mistakes(test): Wait for Pi to settle before ringing Rex secondmate doorbell

* no-mistakes(document): Update stale Herdr-only away-mode and remote-backend claims
…hort sidebar tab labels (#3)

* feat(bin): Rex-native attention marks, event push, and sidebar tab labels

Phase 3 of the Rex backend: the captain sees which worker needs them from
Rex itself, and the watcher wakes on Rex events instead of only polling.

- fm-rex-marks.sh maps each Rex task's latest status to one OSC 7501
  id=fm program-status record on its pane plus an OSC 777 notification on
  each new attention state; the watcher syncs it each poll and cleanup
  clears it. config/rex-status-marks selects on (default), off, or labels.
- The Rex adapter follows `rex events` per session, reconciles after every
  subscribe, escalates a blocked root status or an exited agent or closed
  pane at once, ignores Firstmate's own records, and treats exit 4 as
  unusable, never dead.
- busy_state and submit confirmation read the root program status only for
  harnesses a live guard proves (Claude Code today).
- The away-mode wedge alarm gains a rex channel, added by auto when
  Firstmate runs in a Rex pane.
- Worker tab labels are sidebar-sized: kind marker plus a few words from
  fm-spawn --title, the backlog title, or the task id, at most 24 visible
  characters; the block label stays the identity check.
- New opt-in per-harness program-status live guard, docs, and dated
  verification evidence.

* no-mistakes(review): Suppress Rex teardown dead wakes and guard Claude turn end

* no-mistakes(review): Drop Rex labels mark channel and retired-pane dead wakes

* no-mistakes(review): Correct stale Rex smoke evidence after labels removal

* no-mistakes(document): Clarify Rex tab label rule for explicit titles
…rompts (#4)

Rex's agent SessionStart hook tells every Claude and Codex agent to rename
its session, which for a Rex-backed worker or second mate is a shared
session Firstmate finds by name. Only --rex-lab briefs carried the guard;
every ship and scout brief now carries it as rule 9 and every secondmate
charter in its operating model.
* feat(bin): add Firstmate commands to the Rex command palette

Add a Firstmate group to Rex's command palette: Show Fleet, This Worker,
Peek Worker, Go to Waiting Worker, Show or Hide Away Pane, Answer
Decision, Tell Firstmate, and Request Merge.

- bin/fm-rex-palette.sh installs, removes, checks, and reports one marked
  block at the top of this machine's Rex init.lua: it refuses unbalanced
  markers, a failing config check, and a remote server, backs the file up,
  keeps its mode, edits a symlink's target, and uninstalls byte for byte.
  No key is bound.
- bin/backends/rex-palette.lua defines the actions; each asks
  bin/fm-rex-popup.sh plan what to do, opens a floating popup, and moves
  the view only for a key or palette use.
- bin/fm-rex-popup.sh resolves the focused pane to a task, or a pane on
  another host to its remote second mate, shows popups on this machine,
  ranks waiting workers for goto, and shows or hides the away daemon's
  detached block. The acting popups only file captain inbox notes;
  nothing steers a worker or merges.
- Tests: a fake-rex unit suite and a token-free lab-server smoke, mapped
  to the rex family; docs and dated verification evidence.

* no-mistakes(review): Fix This Worker project label and installer server handling

* fix(bin): keep Rex palette go-to on this machine and trim the palette surface

Go to Waiting Worker shows this machine's fm-local session for a remote
second mate instead of selecting another host's session id. The away
command is a plain toggle, the installer keeps only install and uninstall,
an unchanged install still reloads, and This Worker shows its fallback
for a task with no status line.
…abel titles (#6)

Firstmate's Rex records and notifications now carry the task's tab label as
their title. A validating no-mistakes ship gets an id=fm/validate progress
record that Rex shows in hover cards, and config/rex-tint opts in to a subtle
OSC 11 background tint on waiting and failed workers, reset with OSC 111.
…cleanup (#7)

* feat(bin): let Rex workers open labeled side panes and close them at cleanup

Add bin/fm-rex-side.sh (open|list|close): from a proven worker pane it
splits the worker's own tab without taking focus, labels each pane
<worker block label>/<name>, keeps its output after the command exits,
and with --wait returns the command's status. Task cleanup closes only
those labeled panes in the task's tab (or its recorded tab once the
worker block is gone), so no orphan tab remains and foreign panes are
untouched; list_live no longer counts side panes as tasks. Ship and
scout briefs outside the Rex lab contract name the helper.

* fix(bin): fail Rex task cleanup when a side pane may remain, and search the worker's current and recorded tabs

* refactor(bin): trim the Rex side-pane helper to open, list, and close <name>
…ycle tests pass on a loaded macOS host (#8)

The doctor and guard tests used the system jq as the socket-owner stand-in, which macOS now ships as a platform binary whose environment ps hides, so every owner read as unproven. They now share a holder helper that proves the environment is readable on the host.

The lifecycle test waited 30 seconds for remote spawns and the watcher relaunch, which production allows 120 seconds; the waits now share one bound that only catches a hang.

The Rex secondmate e2e also pins that a single teardown retires a secondmate completely.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @roderik. Second mates, away mode, the command palette and side panes on Rex add up to a lot of careful work, and it's clear you've been running this for real.

What I checked: draft head e3697bff against main 1935d27b. Your branch forks from 6eb8b7f8, which is before Kun's own Rex work landed today: #7633 (auto-detected Rex backend for crewmates and scouts), #7639 (Rex push notifications and cursor-aware composer detection) and #7649 (real-Rex suites on private servers). The two Rex implementations now collide directly. bin/backends/rex.sh is an add/add conflict, and about 20 more files conflict, including fm-backend.sh, fm-spawn.sh, fm-watch.sh, fm-supervise-daemon.sh and fm-busy-lib.sh. Much of what main now has (the backend itself, crewmate/scout spawning, composer detection) overlaps with your first commit. What main doesn't have yet is your later work: Rex second mates and away mode, attention marks and event-driven wakes, the palette, side panes, and the session-rename guard.

Contract-class: new-default (my own read, on what I could inspect of an 8k-line draft). Rex is auto-detected on main, so on a Rex host these paths run unconfigured. The tip adds a new wake path (event-driven watcher wakes), new rule 9 text in every ship and scout brief (which also collides with #6459's rule 9), and new captain-facing surfaces (palette, marks, side panes). None of that is a repair of a broken specified path, so whatever lands is Kun's call. It won't auto-merge.

VISION.md: Vendor/session manager: aligns in spirit (another session manager the distro can inhabit). Authority: cannot tell yet (new wakes and palette commands need a read of what they do unprompted). One captain: cannot tell (new captain-facing surfaces). Scripts/agents: aligns where I looked. Restart: cannot tell (second mate recovery on Rex isn't evidenced). Delegation: cannot tell (no validation evidence yet). Scope: cannot tell at this size; VISION asks new surfaces to be opt-in and to stay out of the captaincy's way.

What's needed from you (this one is waiting on you, not the captain): whenever you're ready to take it out of draft:

  1. Rebase onto current main and build on main's bin/backends/rex.sh instead of a second backend, keeping only what main doesn't cover yet.
  2. Please consider splitting it into a few focused PRs, e.g. Rex second mates and away mode first, then marks and wakes, then palette and side panes. Each one is much easier to verify, and each new captain-facing surface can be gated as opt-in.
  3. Add a PR description and raise each one via git push no-mistakes, with live evidence against a real Rex server, so the attestation binds the head.

There's no CI on this draft yet, so I haven't approved any runs.

…egrations

Merge kunchenguid/firstmate main (f3252b2) into roderik/firstmate-rex,
resolving the conflict between the fork's Rex backend (PRs 1-9) and
upstream's independent Rex integration (kunchenguid#7633, kunchenguid#7639, kunchenguid#7649, kunchenguid#7656) into
one canonical Rex backend.

Kept from the fork: recorded-server addressing with autostart always off,
structural detection, fm-local and fm-<id> placement with sidebar tab
labels, second mates local and remote, away mode in a detached block,
attention marks, validation progress, tint, palette, side panes, the
rename guard, and bin/fm-rex-lab.sh as the single private-server
isolation mechanism (now with a restart command).

Adopted from upstream: the API revision 5 CLI and server gate, the 200x50
block resize, the derived viewport with its cursor row (Rex joins the
visible-capture backends), the cursor-anchored composer with identity
probe, foreground-and-ancestors agent state, the owner-trust rule for
program status (restricted to harness root records), queued-Enter
conversion, the bounded rex do event reader with blocked kind and
message, the shared transition dedupe with gone as a rescan, and reclaim
husk cleanup, plus its push-latency smoke and live composer guard ported
onto the lab helper.

Every upstream change outside Rex merges unchanged.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @roderik for the follow-up push. Here's a quick update, because main moved again.

I read draft head 409f8861 against main e930d960.

  • Rex second mates are now on main. Kun merged fix: correct Rex secondmate grouping and lifecycle #7656 (fix: correct Rex secondmate grouping and lifecycle). With feat: add auto-detected Rex session backend #7633, main's bin/backends/rex.sh now opens a local secondmate in its own 2ndmate-<id>-<hash> session. That session sits right after its parent, a respawned secondmate tab moves first, and retire closes only the exact, empty, matching session. So the second-mate part of this PR is covered. Away mode, marks and wakes, the command palette and side panes are not on main, so I'm leaving this open instead of closing it as superseded.
  • New commit 409f8861 (FM_SPAWN_WORKTREE_WAIT_SECS, a 600 s treehouse wait in fm-spawn.sh) isn't Rex work. It changes spawn timing for every home, so it would fit best as its own small PR.
  • The branch still forks from 6eb8b7f8, and about 30 files conflict with main, including the add/add on bin/backends/rex.sh. There's no CI or attestation yet.

Contract-class (my read): new-default, unchanged. VISION: the same as my last note. The parts not yet on main add captain-facing surfaces that should be opt-in.

Where it stands: waiting on you. My earlier suggestion still holds: rebase onto main's Rex backend, keep only what main lacks, split it into focused PRs (with the new captain-facing pieces gated), and raise each via git push no-mistakes with live Rex evidence.

roderik and others added 4 commits October 23, 2026 10:09
…on wake backstop (#10)

* fix(bin): restore downtime on host pass-through and add an idle-session wake backstop

On 2026-10-23 a main-only close queued during a host engine turn reached the
Claude Stop hook with the recovery marker in handling (the engine's own drain
had begun handling on the shared generation), so the hook refused the rewake
and exited 0 beside the healthy successor the pass-through left. Nothing else
could wake the idle primary, and it stayed unsupervised for 197 minutes.

- fm-supervision-host.sh: every attended pass-through republishes downtime
  before printing the close; a failed republication leaves no successor and
  exits 1, so the hook's lost-hand-back path delivers a failure notice.
- fm-wake-backstop.sh: a detached, home-scoped loop per Claude primary
  session, ensured at session start and every owned Stop. When the oldest
  durable wake has waited past FM_WAKE_BACKSTOP_SECS with no open Stop-hook
  claim, it rings the idle primary's pane once with a record-backed watcher
  doorbell through the away daemon's guards. It never starts or stops a
  watcher and is inert in secondmate homes and under away or quiet mode.
- fm-host-mirror.sh: a live record-backed doorbell is machinery, not
  captain dialog.
- Tests replay the incident state and the drain race; docs describe the
  backstop and the cause.

* no-mistakes(document): Add wake backstop to script inventory
…10's downtime restoration

Main gained PR 10 (idle-session wake backstop and downtime restoration on
host pass-through) after the upstream merge started. Upstream's kunchenguid#6588
fixed the same lost hand-back with a narrower main-only restore that
prints a FAILED line instead of the close; PR 10's restore_downtime_for_main
covers every attended pass-through, including a successor that failed to
start, and prints the close before exiting 1 so the Stop hook's
lost-hand-back path reports it. The resolution keeps PR 10's
implementation and its docs, alongside upstream's handling-settle and
announced hand-back changes, and adds the wake backstop section to
docs/watcher-continuity.md after upstream's handoff-settle text.
…ex integrations (#11)

* feat: add auto-detected Rex session backend (kunchenguid#7633)

* feat(bin): add Rex as an auto-detected session backend

Add bin/backends/rex.sh, a session-provider adapter for the Rex terminal
multiplexer, and wire it through the dispatcher, spawn, control plane,
crew state, busy evidence, and away-mode supervision.

- Auto-detect Rex from TERM_PROGRAM=rex with REX_BLOCK, after tmux and
  Herdr and before cmux; explicit --backend, FM_BACKEND, and
  config/backend still win, and a nested tmux or Herdr is never read
  as Rex.
- One focus-safe tab per task: in Firstmate's own Rex session when it
  runs directly inside Rex (confirmed against the server), otherwise in
  one session per home; new blocks are resized to 200x50; every call
  names its session and block by immutable id.
- Recovery-grade agent state from Rex's process view, OSC 7501 program
  status as positive busy evidence only while its owner is in the
  foreground chain, and a viewport derived from the last size.rows rows
  of the styled capture.
- Absence proof from a structured not-found on the recorded server
  (rex_server), so fm-control exit and relaunch work on Rex and a gone
  block is reclaimed into a fresh tab in its recorded session.
- Away mode for a Rex-hosted primary runs its daemon in a dedicated Rex
  session killed by exact id.
- Docs: docs/rex-backend.md, configuration and control-plane tables,
  and a dated live verification record; tests: a stateful fake-CLI
  suite, a real-server smoke test guarded to its own fm-test- session,
  and a Rex away-launcher e2e.

* no-mistakes(review): Recover Rex reclaim after server stops; document deferred asks

* no-mistakes(document): Correct Rex documentation and consolidate stale backend guidance

* fix(bin): guard the wedge cap-fire counter reset with the cap-state rollback (kunchenguid#7625)

* no-mistakes(review): wedge cap: guard the cap-fire counter reset with rollback

* no-mistakes(document): docs: repair shard-pack wording and wedge-cap marker shorthand

* no-mistakes(review): docs: correct away-release terminal-row bound claim

* no-mistakes(document): docs: cover third guarded cap-state write in watcher comment

* no-mistakes(ci): Reweighted the packing hint for tests/fm-supervision-host.test.sh from the local 789123 ms to 1192918 ms, the one completed successful CI sample (run 39642852135, job 119276758966), and let the LPT packer rebalance. The guard was not weakened (PORTABLE_SERIAL_MAX_WEIGHT_MS=1200000, PORTABLE_SERIAL_SHARDS=9, coverage guard and packing-boundary check untouched) and nothing was hand-placed. New packed hint sums of the 9 serial shards (ms): 1=1192918 (1 script), 2=1139923 (18), 3=1139903 (30), 4=1139922 (30), 5=1139917 (30), 6=1139886 (29), 7=1139891 (30), 8=1139880 (29), 9=1139911 (31). Total 228 scripts = the serial lane exactly; max 1192918 < 1200000, so it fits. Packing guard: bin/fm-test-run.sh --check-coverage -> FM_TEST_COVERAGE ok total=268 parallel=24 parallel_max_ms=665545 parallel_imbalance_ms=2 parallel_unhinted=0 serial=228 serial_shards=9 serial_unhinted=15 serial_max_ms=1192918 serial_budget_ms=1200000 herdr=16, exit 0. tests/fm-test-run.test.sh passes both packing contracts: 'coverage guard bounds the unmeasured share and serial packing within twenty minutes' and 'serial packing accepts the exact budget and refuses one millisecond above it'. bin/fm-doc-audience-check.sh ok (surfaces=124 local_links=851). docs/fm-test-portable-shards.md now states the same 1192918 ms for that script, citing run 39642852135 (documented duration == packed weight), and adds the required honesty note in the same paragraph style: run 39765114423 cancelled this script alone in a shard at the 30-minute job cap and upstream run 39618934309 hangs identically, so the weight is a fit to the 20-minute packing target, not a cure, and the underlying slowness is an upstream defect this branch does not own. No other file, weight, test or doc line touched. Unrelated pre-existing failure, verified by git stash at base commit 5af4072: tests/fm-session-lock-ancestry.test.sh asserts 'the pty-host was not reparented to init after the daemon ended' and fails identically on the unmodified tree (sandbox pty behaviour); the --jobs family-admission assertion in the same suite fails only because of it. Not caused by this change

* fix(bin): restore watcher downtime before main-only hand-back (kunchenguid#6588)

* fix(bin): restore inherited handling before main-only hand-back

* Restored downtime so an earlier engine turn could not suppress a later
  main-owned close while leaving a healthy successor behind
* Routed restoration failures through the existing Stop-hook alarm
  instead of silently discarding the hand-back
* Added host-and-hook regressions plus attended and away idle-return
  controls to separate missing monitoring from status classification

* no-mistakes(test): Assert ordered stale event in returned-driver controls

* no-mistakes(document): Document main-only hand-back downtime restoration and failure

* no-mistakes(document): Correct host header on main-only downtime republish

* test(herdr): bound the piped composer probe with fm_run_timed instead of GNU timeout (kunchenguid#7636)

* feat: add Rex push notifications and cursor-aware composer detection (kunchenguid#7639)

* feat(rex): push blocked edges from Rex program status through a bounded Lua reader

Rex joins Herdr as a push-capable backend: a bounded rex do reader streams
program_status_changed, child_exited, and block_closed for the watched task
blocks, and a trusted blocked edge wakes the supervisor with Rex's blocked
kind and message in the reason. The per-pane dedupe moves into the shared
transition lib, the record gains a detail field, and gone edges end the wait
for an immediate poll. The real-Rex test isolation is shared by both smokes.

* fix(rex): anchor the composer read on Rex's cursor position

Rex's format method reports the cursor alongside the styled grid, so the
composer verdict now uses the same cursor-anchored read as tmux and falls
back to the cursorless read only where that is unknown. OpenCode 1.19 draws
a status line below its composer, which made every cursorless read of an
idle OpenCode worker on Rex unknown and refused steers, exit, and relaunch.

* test(rex): add a live composer guard for every installed harness on Rex

* docs(rex): record push-event and per-tool live evidence on Rex

* no-mistakes(document): Clarify Rex documentation and shared transition ownership

* no-mistakes(ci): Fixed flaky public-followup fixture teardown: killing only the remote worker child allowed its supervisor to restart and race directory removal. Cleanup now uses the existing whole-worker-tree stop helper. Verified the full public-followup suite, remote-job orphan-reap suite, shell syntax, and git diff checks all pass

* feat(bin): notify owned PR conflicts and failing required checks behind an opt-in flag (kunchenguid#7634)

* refactor(bin): share the branch-to-PR lookup through fm-pr-lib

* feat(bin): notify owned PR health changes behind an opt-in flag

* no-mistakes(review): drop status-line ownership, key checks per name, remove PR wait rule

* no-mistakes(review): rediscover the branch PR once the cached one is final

* no-mistakes(review): refuse retired re-enrollment, require marked checks, verify owned records

* no-mistakes(document): note shared branch-to-PR lookup in scripts table

* fix(bin): notify reported failures when no checks are required

* no-mistakes(document): inventory PR health flag and state, note new pr-forge member

* test: isolate real-Rex suites on private servers (kunchenguid#7649)

* Isolate real Rex tests with private servers

* no-mistakes(review): Trap Rex cleanup early and prove passive-read autostart guard

* no-mistakes(document): Consolidate Rex test isolation documentation

* fix: distinguish outdated tools from missing tools (kunchenguid#5688)

* fix(bin): report an outdated bootstrap tool instead of a missing one

detect_local_tools printed "MISSING:" for a treehouse without --lease, a
no-mistakes below 1.46.0, a gh-axi below its floor, and an incompatible
tasks-axi or quota-axi, so a supervisor read an installed tool as absent
and took the first-install remediation again.

Report those as "OUTDATED:" with the installed version, the requirement
and the tool's own upgrade command: treehouse update, no-mistakes update,
gh-axi update and quota-axi update. tasks-axi ships no self-updater, so it
keeps its install command. "MISSING:" stays for absent tools only, and
lavish-axi keeps PRESENTATION_UNAVAILABLE with its text fallback.

Update the bootstrap-diagnostics handler, the AGENTS.md section 13 trigger
list and the operator diagnostics in docs/configuration.md, and cover
absent, below-floor and at-floor for every floored tool in
tests/fm-bootstrap.test.sh.

* no-mistakes(document): Documented distinct bootstrap tool diagnostics

* fix(bin): reuse the tasks-axi check's own probe results

Rendering the tasks-axi OUTDATED requirement text ran the two `--help`
capability probes again after the compatibility check had already run
them, including when session start handed bootstrap an incompatible
verdict. The check now records the reason behind its verdict - the
version floor, or the capability probes the build fails - and reuses it,
both within the process and across the existing one-hop handoff, so
naming a missing capability costs no second probe pass. A build below the
floor is answered by its version alone and never pays for capability
probes it cannot use.

The bootstrap tests that simulate a tool as absent removed it from the
fake bin directory while bootstrap kept searching the fallback base PATH,
so a real host install could satisfy the lookup instead of the expected
MISSING line. Those cases now hide the tool from the base path as well,
and a new case pins the contrast between a bare and a curated fallback.

Verified: the touched bootstrap suite passes, and its probe-count and
capability assertions fail against the pre-fix scripts. Run with a
fallback base PATH carrying real installs of the absent tools, the
pre-fix suite fails on "absent treehouse reports a missing tool" while
the fixed suite passes every case.

* no-mistakes(document): Documented missing versus outdated tool diagnostics

* no-mistakes(document): Refresh outdated-tool documentation

* no-mistakes(review): Reuse shared version parser for outdated diagnostics

* no-mistakes(document): Correct outdated-tool diagnostics documentation

* no-mistakes(document): Align toolchain upgrade documentation

* fix(skills): keep main's bootstrap-diagnostics description and only add OUTDATED

* fix(bin): clarify ahoy skill legacy session-start exclusion to require verbatim match (kunchenguid#7530)

* Clarify ahoy legacy startup exclusion

* Fix quoted payload code span

* fix(bin): resolve timeout/gtimeout to executable paths via type -P (kunchenguid#7637)

* fix(timeout): bypass shell builtins when invoking external runners

* no-mistakes(review): Remove redundant slashless runner resolution from external timeout

* fix(bin): count answered captain holds moved to the Done archive as durable (kunchenguid#6094)

* fix: count answered captain holds in the Done archive at the completion gate

Done retention moves closed markdown rows into the configured Done archive,
which tasks-axi show never reads, so verify, complete, and scout teardown
refused an answered captain hold once retention archived it. The completion
gate now reads the newest archived block for an attested entry, under its
exact or legacy identity, and accepts it only through a recorded resolution.
Unanswered archived closes and holds found nowhere still refuse.

* no-mistakes(document): document Done-archive durability in captain-hold verification record

* no-mistakes(ci): Fixed the selected Greptile findings in bin/fm-captain-hold.sh (all in the Done-archive read path added by this PR). code_change_needed=true. ci-3 (Archived reads can hang): task_show_archived() now bounds the replayed archive `tasks-axi show` with the same read bound the live backlog read uses (FM_BACKLOG_ROW_TIMEOUT_SECS via fm_run_timed, sanitising a non-positive/padded value to 10s, mirroring fm_backlog_row_show). A bound hit is treated as 124, not absence: task_show_archived returns 124 and prints a loud reason; archived_entry() propagates 124; verify_entry_durable() exits 124 on the archived-read bound (alongside its existing resolve 124 handling); verify_hold_durable() exits 124 rather than reading the row as absent. So verify can no longer hang and complete can no longer stay blocked while holding the origin metadata lock. ci-4 (User-level archive setting ignored): added captain_markdown_archive_setting(), which resolves the [markdown] archive key with tasks-axi's own source precedence — the backlog root's .tasks.toml first, then $HOME/.tasks-axi/config.toml — before the existing default of done-archive.md beside the backlog; a relative value still resolves against the backlog root, which I verified empirically matches tasks-axi (root config wins over home config; a relative home-config value resolves against the backlog root; default stays data/done-archive.md). tasks-axi exposes no command for the archive path, so re-parsing with matched precedence is the available approach. Added test_archived_answer_in_a_user_configured_archive_satisfies_the_gate, which sets the archive only in a fixture $HOME/.tasks-axi/config.toml and drives the whole hold→answer→retention→verify/complete/teardown flow with that HOME, asserting the answered call archived to the relocated location still satisfies the gate. ci-5 (repeated archive scans, P2): left unchanged per the instruction's opt-out. A clean reuse of the row archived_entry already found is not small: archived_entry runs inside a command substitution, so its TASK_SHOW_OUTPUT dies with the subshell and cannot be handed to verify_hold_durable without restructuring both to pass the loaded row through the current shell. The growth is bounded (O(archive size) per attested entry) and P2, so hardening it would add more machinery than the fix warrants. Unanswered archived closes and holds found nowhere still refuse (existing test coverage retained). Verification: `bash -n` clean; pinned ShellCheck 0.11.0 (`shellcheck -x bin/fm-captain-hold.sh`) reports 0 findings; tasks-axi archive-precedence behaviour confirmed by direct experiment. The full fm-captain-hold-lifecycle.test.sh suite (which exercises both the pre-existing archived-gate test and the new user-config test) is slow due to beads spawns and was still running at report time; recommend confirming it green before merge. ci-1/ci-2 need no code change (action_required fork workflow runs awaiting maintainer approval), per the recorded user decision

* no-mistakes(document): Document Done-archive reads under backlog row timeout

* docs: say only the archive row replay is bounded, not the archive scan

* no-mistakes(document): Move Done-archive rule to the complete section

* fix(bin): read a PR with no CI checks as unverified, not checks green (kunchenguid#7627)

* fix(bin): optionally read a PR with no CI checks as unverified, not checks green

nm_ci_checks_state maps the ci log marker "no CI checks reported - still
monitoring" to green, the same verdict as "all CI checks passed". A pull
request that no check ever ran against therefore surfaced as "checks green: PR
ready for review" (kunchenguid#3216).

Add a no-checks verdict for that marker, returned only in a home that creates
config/ci-no-checks-not-green. The run-step consumer reports working with a
detail naming the real condition, and the status-log override no longer
promotes a crew's own "checks green" report while that marker is the latest.
Without the flag every reading is unchanged.

Co-authored-by: Harlan Do <[email protected]>

* no-mistakes(document): document ended-monitor reading under the zero-checks flag

* fix(bin): read a PR with no CI checks as unverified on every home

The ci log marker "no CI checks reported - still monitoring" now always
yields the no-checks verdict, so a pull request that no check ran against is
reported as working instead of checks green (kunchenguid#3216). The opt-in flag, its
docs section, and its skill entry are removed, the default-path test now
expects working, and the usage header and architecture note describe the
no-checks reading.

---------

Co-authored-by: Harlan Do <[email protected]>

* fix(bin): correct the wedge reset-failure log line and make the fault test root-safe (kunchenguid#7650)

* no-mistakes(review): correct the counter-reset log line, the sentinel comment, and the root proof

Three findings the review step recorded but never applied, all in this branch's own change.

The clean-rollback branch of the counter-reset guard logged "cap state rolled back", copied
from the sibling marker-write branch. That is wrong here: the cap marker was already written
before this block and _wedge_cap_rollback only truncates the counter, re-arms the since-file
and clears write tracking - it never clears the markers. The window therefore stays silenced
for FM_CAP_HORIZON_SECS, so the one operator-facing line must say that rather than claim the
cap state was rolled back. The rollback behaviour is unchanged and no marker-clear call is
added: the marker is deliberately kept so the window stays quiet.

The sentinel short-circuit comment opened "from either route that has to defend cap state"
and then enumerated three routes. Wording only.

The new regression case injected its fault with chmod 444, which does not restrict root, so
under root the guard would never fire and the case would fail on its own exit-code
assertion. It now skips as root the way this suite's other mode-based faults do. The
assertions are untouched: as the ordinary user the case still proves the guard.

* no-mistakes(review): name both ways a capped window leaves the silence in the reset log line

The tier-0 message for a refused post-fire escalation-counter reset says the cap marker
stands, so the window stays silent until its horizon elapses. That names one release route
where there are two: wedge_episode_end drops the marker through _wedge_cap_markers_clear, so
any episode-ending route ends the silence early, and docs/configuration.md records deleting
the marker as the operator's way to re-engage a capped window at once. This tier writes no
sentinel, so the marker is the only thing left to remove.

The message now names the horizon, an episode-ending route, and the operator remedy, in one
line in the same shape and position as its sibling tier-0 messages. The rollback behaviour,
the marker handling and the tier are unchanged.

* no-mistakes(document): correct root-skip comment's mode-bit precedent in wedge-cap test

* fix: resurface queued wakes from handling successors (kunchenguid#7466)

* fix(bin): resurface wakes appended while a handling successor is parked

The supervision host parks on the handling successor it starts for a wake
its engine handled, and a handling successor never resurfaced recovery, so
a row another script appended during the park (a captain inbox note from
the Basecamp integration) sat queued until an unrelated close - four hours
in the observed case.

A handling successor now records the newest queued sequence at its start
and closes once with the recovery wake while a newer row is still queued;
a newer row already consumed only advances that mark, so the predecessor's
delivered episode is still never re-announced.

Follow-ups, not built here:
- A row appended in the short window between a handled close and its
  successor's start (about a second) is below the successor's mark; if the
  engine handles that close without claiming the row, the row waits for the
  next close. Closing that window needs the host to treat rows left queued
  after a handled attended turn as main's, which is a separate host change.
- After a machine reboot the primary session does not restart on its own,
  so queued wakes wait until it is resumed by hand. Either auto-resume the
  primary session after boot, or alert the owner when the primary session
  is down while wakes are queued.

* no-mistakes(review): Close handling-successor startup wake race

* no-mistakes(test): Stabilize parked-host inbox wake regression timeout

* no-mistakes(document): Clarify handling-successor wake continuity guarantees

* no-mistakes(ci): Stabilized the flaky remote secondmate lifecycle test by extending the auto-relaunch watcher deadline from ~30 to ~60 seconds. The CI runner exceeded the old deadline by about 3 seconds; the changed production branch was not reachable in this fixture. `bash -n` and `git diff --check` pass. The full test was attempted but exceeded the 600-second local execution limit before reaching this case

* no-mistakes(ci): Fixed flaky concurrent Herdr recovery testing by retrying only documented session-lock contention after both competitors finish. Cleanup now handles fixture-owned read-only hooks. Targeted E2E passed; bash syntax and diff checks passed. Shellcheck reported only existing SC1091 source-following notices

* no-mistakes(test): Preserve successor wake boundaries across handoffs

* no-mistakes(test): Revert successor boundaries and drain teardown fixture wake

* no-mistakes(test): Notify main when downtime handback publication fails

* no-mistakes(test): Revert downtime handback notification changes

* no-mistakes(document): Correct stale supervision wake routing documentation

* fix(bin): stop the supervision host deadlocking and re-announcing handed-back closes

Two defects in this branch's handling-successor changes surfaced as the
"Behavior portable serial 2" shard hanging at its 30-minute limit.

A TERM that lands while the host settles a handled turn's successor handoff
left the host holding the wake-queue and recovery-marker locks; its exit
cleanup then waited forever on the queue lock it still owned. The cleanup now
releases those locks if this process owns them before releasing its grant.

When an accepted close turns main-only at its turn, the host hands it back and
leaves the successor running, but republished the episode as pending
downtime, so that successor re-announced the same close and exited. The
handback now republishes the episode as already announced; a later durable
append still opens a pending episode the successor recovers.

* no-mistakes(test): Park on successor after handling settlement failure

* no-mistakes(test): Use tab-delimited handled-settlement failure logs

---------

Co-authored-by: Caleb LeNoir <[email protected]>

* fix(bin): preserve accents in pending-reply summaries (kunchenguid#7618)

* fix(bin): keep accented letters in pending-reply request summaries

fm_pending_reply_summarize deleted every byte outside printable ASCII, so a Portuguese summary lost its accents: "não faça a correção" was stored as "no faa a correo". It now removes control characters only. The 120-character cap counts UTF-8 characters from lead bytes, so it never splits a letter under any caller locale, including the C locale.

* no-mistakes(document): Documentar preservação de acentos nos resumos

---------

Co-authored-by: Alexandre Custodio <[email protected]>

* feat: add OpenRouter support for typed dispatch resolution (kunchenguid#7149)

* Add explicit OpenRouter Jev dispatch resolution

* no-mistakes(document): Clarify dispatch documentation and remove stale duplicates

* chore: exclude local Stele binding from PR

* no-mistakes(document): Correct dispatch help and never-send documentation

* ci: retrigger CI after a timed-out test shard

* no-mistakes(document): Correct dispatch architecture documentation ownership

* feat(bin): publish lane capacity facts with beat pressure and keyed limits (kunchenguid#6983)

Opt-in: fm-watch.sh publishes state/lane-capacity.json via bin/fm-capacity.sh --publish only while config/lane-capacity exists; adds beat pressure and keyed limits to fm-capacity.sh. Unconfigured fm-capacity output unchanged.

* fix(bin): propagate contribution input assembly failures (kunchenguid#5359)

* fix(bin): transport contribution-input JSON through slurpfile, not argjson

bin/fm-fleet-snapshot.sh --contribution-input passed the full backlog and
task-record JSON to jq through --argjson. A single --argjson argument is
capped by the kernel's MAX_ARG_STRLEN (131072 bytes on Linux), so a large
enough backlog made the kernel refuse to exec jq while the script still
exited 0 with a broken result.

Transport both documents through temporary files and --slurpfile, matching
the pattern the default snapshot path already uses, and propagate a
non-zero exit when that jq invocation fails.

Fixes kunchenguid#5349

* test: narrow contribution-input regression to final assembly failure

The ARG_MAX transport is already fixed on main by kunchenguid#6830, so keep only the regression proving a failing final jq assembly exits non-zero.

* fix: correct Rex secondmate grouping and lifecycle (kunchenguid#7656)

* Fix Rex secondmate session lifecycle

* no-mistakes(review): Retire Rex secondmate sessions under the owning home identity

* no-mistakes(review): Limit Rex FM_ROOT label override to secondmate launches

* no-mistakes(document): Clarify Rex secondmate grouping and lifecycle documentation

* docs: describe the merged Rex spawn gate and guide contents

---------

Co-authored-by: Kun Chen <[email protected]>
Co-authored-by: Lorenzo Minghini <[email protected]>
Co-authored-by: zachlandes <[email protected]>
Co-authored-by: Tiago <[email protected]>
Co-authored-by: YifuGu <[email protected]>
Co-authored-by: laffy-999 <[email protected]>
Co-authored-by: chsong <[email protected]>
Co-authored-by: Hamish <[email protected]>
Co-authored-by: Harlan Do <[email protected]>
Co-authored-by: Caleb LeNoir <[email protected]>
Co-authored-by: Caleb LeNoir <[email protected]>
Co-authored-by: Alexandre Custodio <[email protected]>
Co-authored-by: Alexandre Custodio <[email protected]>
Co-authored-by: Pedro Guimarães <[email protected]>
Co-authored-by: Konner Moshier <[email protected]>
Co-authored-by: Oscar Santis Brante <[email protected]>
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @roderik for the new pushes (now 7f5718ff). GitHub still reports this draft as conflicting with main 8818a804, so my last note stands: please rebase onto current main, which already has Rex second mates (#7633, #7656), split the remaining away-mode / marks / wakes / palette / side-pane work (and the unrelated treehouse-wait change) into focused PRs, and raise them via git push no-mistakes. I haven't approved CI on this head because it can't merge as is. This one is waiting on you, and there's no rush.

…onest (#12)

A first remote Rex secondmate launch on ds9 refused to publish its task
record because the existing parent-route state directory transiently could
not be canonicalized, then reported that failed-dispatch cleanup had not
removed both records although nothing had been published. The same remote
spawn also relayed bash's job-control setpgid race message from an earlier
remote job.

- fm_backlog_canonical_existing now reports the component lstat refused and
  its errno (or perl's exit status), and every "cannot be resolved" refusal
  carries that reason.
- The failed-dispatch rollback treats a provisional record that lstat proves
  absent as removed, so a dispatch that never published its record no longer
  reports incomplete cleanup; a record a refused lookup could still hide is
  still reported.
- The remote job worker keeps supervising a command that is not in its own
  process group (the state a failed setpgid leaves), signaling the command
  process instead of returning at once with its timeout, cancellation, and
  preemption unenforced, and keeps bash's fork-time setpgid race message out
  of the job's stderr.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @roderik for the new push (now 52b2dc6a). It's still a draft, and GitHub still reports it as conflicting with main (6163dc36), so my earlier note stands. When you're ready, please rebase onto current main (it already has Rex second mates from #7633 and #7656), split the rest into focused PRs, and raise each one via git push no-mistakes. I haven't approved CI on this head because it can't merge as it is. This is waiting on you, and there's no rush.

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.

2 participants