Skip to content
This repository was archived by the owner on Aug 25, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9a64dc5
feat(herdr): add optional presentation spaces (#784)
kunchenguid Jul 21, 2026
1419c33
feat(herdr): order presentation spaces while preserving focus (#790)
kunchenguid Jul 21, 2026
c13bf0c
fix(herdr): group projected children beneath owning parents (#821)
kunchenguid Jul 22, 2026
20c0430
feat: require pinned real-Herdr CI coverage (#838)
kunchenguid Jul 22, 2026
b16a147
fix(herdr): reclaim resumed task projections after restart (#967)
kunchenguid Jul 24, 2026
36d419c
fix(herdr): clean stale projections at session start (#996)
kunchenguid Jul 24, 2026
5198996
fix(send): treat opencode busy-queued composer state as submitted (#775)
KostadinP Jul 21, 2026
e1a36c2
fix: prevent AFK idle stalls and stale run attribution (#758)
jjames27th-eng Jul 21, 2026
5f16296
fix(herdr): preserve fork labels across upstream reliability series
JTInventory Jul 25, 2026
8178ab2
fix(bin): send literal config reread nudges after pushes (#809)
kunchenguid Jul 21, 2026
bb0d07b
fix(herdr): reconcile upstream reliability with fork contracts
JTInventory Jul 25, 2026
b77cf7a
no-mistakes(review): Harden Herdr lifecycle and real-CI coverage
JTInventory Jul 25, 2026
5f732cc
no-mistakes(review): Harden Herdr lifecycle, delivery, and CI contracts
JTInventory Jul 25, 2026
2a0ebff
no-mistakes(review): Harden Herdr lifecycle, inheritance, and CI
JTInventory Jul 25, 2026
559b476
no-mistakes(review): Harden Herdr recovery, teardown, and inheritance…
JTInventory Jul 25, 2026
7f1b3f1
no-mistakes(review): Harden Herdr send and lifecycle uncertainty hand…
JTInventory Jul 25, 2026
a4f7e6c
no-mistakes(review): Harden Herdr mutation and teardown failure handling
JTInventory Jul 25, 2026
84b0f0c
no-mistakes(review): Enforce Herdr identity and truthful pending verd…
JTInventory Jul 25, 2026
24450d0
no-mistakes(review): Implement truthful Herdr final Enter submission
JTInventory Jul 25, 2026
12e2722
no-mistakes(review): Harden Herdr final Enter ownership verification
JTInventory Jul 25, 2026
374622b
no-mistakes(review): Require idle proof for Herdr final Enter
JTInventory Jul 25, 2026
e4981e6
no-mistakes(review): Order Herdr ownership before idle proof
JTInventory Jul 25, 2026
e50e777
no-mistakes(test): Restore flat Herdr spawning without presentation l…
JTInventory Jul 25, 2026
b1ed03f
no-mistakes(document): Correct Herdr documentation and proof references
JTInventory Jul 25, 2026
d642c4c
no-mistakes(document): Isolate Herdr routing test from gate refusal
JTInventory Jul 25, 2026
5dc11c9
no-mistakes(lint): Remove unused Herdr lint variables
JTInventory Jul 25, 2026
de5c47f
no-mistakes: apply CI fixes
JTInventory Jul 25, 2026
e4bd713
no-mistakes: apply CI fixes
JTInventory Jul 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 49 additions & 27 deletions .agents/skills/afk/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,22 @@ Enter; Herdr uses its pane composer read.
when a steer's Enter is positively swallowed, so firstmate learns an instruction
did not land instead of leaving it unsubmitted.

**Busy-queued Enter exception (tmux backend, opencode 1.18.4).** While opencode
is mid-turn, Enter is accepted and queued for after the current turn but the
composer keeps showing the typed text the whole time, so the cleared-composer
check alone false-positives on a swallowed Enter for every steer sent to a
busy opencode pane. The shared `fm_tmux_submit_enter_core` falls back to
`fm_pane_is_busy` once the Enter-retry budget is spent: a busy pane means the
Enter was accepted and queued (reported as `empty` so the caller does not
re-send), while an idle pane keeps `pending` as a genuine swallow. The
strict-buffer-clears-only-on-`empty` policy above still holds for the daemon
and the lenient-`pending`-fails-for-`fm-send` policy still holds for steer
verification - this exception is a busy queue treated as a delivered Enter,
not a swallowed one. Herdr applies the same exception only after successful
Enter transport when contemporaneous native state remains busy and the pending
composer still contains the exact submitted text; autocomplete-expanded content
retries.

## Classification policy

The daemon wraps `fm-watch.sh`, runs the watcher as a child, classifies each
Expand All @@ -137,24 +153,17 @@ the two never run their triage at the same time.

Classify each wake this way:

- `signal` whose status content has no captain-relevant verb
(`done:|needs-decision:|blocked:|failed:|PR ready|checks green|ready in branch|merged`)
-> self-handle. Captain-relevant verb -> escalate.
A valid `paused: <reason>` is a declared external wait, not a wedge: record it
for re-review. A paused secondmate is included in the digest immediately so
its parent can see the handoff, then follows the same re-review cadence.
- `signal` with a terminal captain verb (`done:`, `needs-decision:`, `blocked:`, or `failed:`) -> escalate.
A nonterminal progress verb remains nonterminal even when its prose contains a legacy free-text token such as `PR ready`, `checks green`, `ready in branch`, or `merged`; only a bare legacy line with such a token escalates.
Other signals with no captain-relevant status -> self-handle.
- `signal` or `stale` for a declared `paused:` external wait -> self-handle and track the pause rather than a wedge.
If it remains declared and idle past `FM_PAUSE_RESURFACE_SECS` (default 3600s), housekeeping sends one awaiting-external recheck and resets the pause window.
- `check` -> always escalate. Check scripts print only when firstmate should wake.
- `stale` with a terminal status -> escalate. Non-terminal stale is transient:
record a marker and self-handle. If the pane is still idle past
`FM_STALE_ESCALATE_SECS` (default 240s), housekeeping escalates it as a
possible wedge. This bounds wedge-detection latency to the threshold plus a
tick: a delay, never a loss. Healthy crewmates are autonomous and do not wait
on firstmate mid-task.
A still-valid `paused: <reason>` instead uses `FM_PAUSE_RESURFACE_SECS`
(default 3600): housekeeping confirms that no active or terminal run
superseded it, then adds one "recheck the declared wait" digest item and
resets the cadence. It clears the pause marker when the status changes, the
pane disappears, or work resumes.
- `stale` with a terminal status or bare legacy captain-relevant line -> escalate.
Nonterminal progress remains transient even when its prose contains a legacy free-text token or its seen-status marker already matches, so record a marker and self-handle.
If the pane is still idle past `FM_STALE_ESCALATE_SECS` (default 240s), housekeeping escalates it as a possible wedge.
This bounds wedge-detection latency to the threshold plus a tick: a delay, never a loss.
Healthy crewmates are autonomous and do not wait on firstmate mid-task.
- `heartbeat` -> self-handle. The daemon runs its own cheap bash fleet scan
every `FM_HEARTBEAT_SCAN_SECS` (default 300s) as the catch-all for a
captain-relevant status line the per-wake classifier might miss.
Expand Down Expand Up @@ -201,16 +210,29 @@ the marker lets firstmate distinguish it from a real captain message.
classification or relay, so the digest text firstmate sees is clean.
- **Portable singleton lock** - the daemon uses the repo's portable lock helper
(`fm-wake-lib.sh`) instead of `flock`, which is absent on macOS.
- **Dedupe across signal/stale/scan** - `classify_signal` and `classify_stale`
both check the seen-status marker before escalating, so a status escalated by
one path is not re-escalated by another in the same digest.
- **Auto-discovered supervisor pane** - the daemon selects
`FM_SUPERVISOR_BACKEND=tmux|herdr` from explicit configuration or the runtime
markers, then resolves `FM_SUPERVISOR_TARGET` or that backend's runtime pane
marker. Tmux falls back to `firstmate:0` with a warning; Herdr requires
`HERDR_PANE_ID` or an explicit target. Unsupported backends are refused at
startup. The target/backend resolution source is logged so a
wrong-but-resolving fallback is detectable.
- **Dedupe across signal/stale/scan** - `classify_signal` and terminal `classify_stale` paths check the seen-status marker before escalating, so a captain-relevant status escalated by one path is not re-escalated by another in the same digest.
The marker does not clear or suppress possible-wedge aging for a nonterminal progress line.
- **Auto-discovered supervisor pane** - the daemon resolves its own BACKEND
(tmux vs herdr) and TARGET independently, mirroring
`bin/fm-backend.sh`'s own runtime auto-detection. Backend: `FM_SUPERVISOR_BACKEND`
override, then `$TMUX_PANE` set (tmux), then `$HERDR_ENV=1` with
`$HERDR_PANE_ID` present (herdr), then a tmux fallback. Target:
`FM_SUPERVISOR_TARGET` override (a tmux target or a herdr
`"<session>:<pane-id>"` target), then `$TMUX_PANE`, then
`"${HERDR_SESSION:-default}:${HERDR_PANE_ID}"` under herdr, then a
`firstmate:0` fallback with a warning. Both resolution sources are logged at
startup so a wrong-but-resolving fallback is detectable. Other runtime
backends other than tmux and Herdr are not supported as
supervisor backends; the daemon refuses loudly at startup instead of
misapplying tmux primitives to a pane that isn't one
(docs/herdr-backend.md "Away-mode supervisor support").

## Stale-artifact lifecycle

Treat `state/.subsuper-escalations`, its `.since` sidecar, and `state/.subsuper-inject-wedged` as session-scoped delivery artifacts, not as the durable work record.
Always enter through `bin/fm-afk-launch.sh`, which clears prior-session artifacts only for a fresh entry and preserves the current session's buffer on refresh.
Always exit through `bin/fm-afk-launch.sh stop`, which keeps `state/.afk` present through the daemon's shutdown flush and clears it last.
This section owns the stale-artifact lifecycle contract.

## Reliability properties

Expand Down
39 changes: 37 additions & 2 deletions .agents/skills/harness-adapters/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ The captain may override that file at bootstrap or later; a per-task instruction
Secondmates have their own harness knob, so a secondmate can run on a different adapter than crewmates.
`config/secondmate-harness` is the harness the primary uses to launch SECONDMATE agents, resolved through the fallback chain `config/secondmate-harness` -> `config/crew-harness` -> firstmate's own.
An absent or `default` `config/secondmate-harness` therefore behaves exactly as the crew harness did before this knob existed (secondmates launched on the crew harness); setting it splits the two.
`config/crew-dispatch.json` and `config/crew-harness` are inherited by secondmate homes (the primary pushes them down so a secondmate's own crewmates use the primary's dispatch profiles and static harness value), while `config/secondmate-harness` is the primary's own setting and is never inherited - secondmates do not spawn secondmates.
The [`secondmate-provisioning` skill](../secondmate-provisioning/SKILL.md) owns the complete inherited-local-material allowlist and propagation contract.
This skill owns only the harness-relevant consequence: a secondmate's own crewmates use the primary's inherited dispatch profiles and static harness value, while `config/secondmate-harness` is the primary's own setting and is never inherited - secondmates do not spawn secondmates.
Inheritance copies the literal `config/crew-harness` file, so for a secondmate's own crewmates to run on the primary's crewmate harness the captain must set `config/crew-harness` to a concrete adapter name, such as `codex`.
If `config/crew-harness` is unset or `default`, there is no concrete value to inherit, so the secondmate's own crewmates fall back to the secondmate's own/detected harness rather than the primary's effective crewmate harness.
Inheritance also copies the literal `config/crew-dispatch.json` file, so secondmates apply the same best-fit profile rules for their own crewmates.
Expand Down Expand Up @@ -114,7 +115,16 @@ The decision persists for the repo, so later worktrees of the same project skip
Resume after exit with `codex resume <session-id>`.
The session id is printed on quit.

## opencode (VERIFIED 2026-06-11, v1.15.7-1.17.3)
**Primary-session guard fact (verified 2026-07-08, codex-cli 0.142.1).**
The firstmate PRIMARY's own `.codex/hooks.json` registers a Stop hook that pipes Codex's Stop payload to `bin/fm-turnend-guard.sh`.
Codex Stop hooks block on exit 2 and expose `stop_hook_active` for the same one-block loop safety Claude uses.
Codex's Stop payload includes `cwd`, but the tracked primary hook does not use it to choose the guard executable.
Verified on 2026-07-08: Codex runs the Stop hook command with process PWD set to the hook-loaded project root, and no `CODEX_PROJECT_DIR`, `CODEX_WORKSPACE_ROOT`, or `CODEX_CWD` root variable is set.
The tracked hook anchors to `pwd -P`, verifies that root is firstmate-shaped and hook-bearing, and then invokes `bin/fm-turnend-guard.sh` with the original payload.
Codex's primary watcher protocol is `bin/fm-watch-checkpoint.sh --seconds "${FM_CODEX_WATCH_CHECKPOINT:-180}"`, not `bin/fm-watch-arm.sh`.
The checkpoint is deliberately foreground and bounded so Codex regains control regularly to process user messages and queued wakes.

## opencode (VERIFIED 2026-06-11, v1.15.7-1.17.6; 1.18.4 busy-queue re-verified 2026-07-20)

| Fact | Value |
|---|---|
Expand All @@ -127,6 +137,31 @@ Opencode can auto-upgrade itself in the background and the running TUI can exit
If a pane shows the exit banner, relaunch with `--continue` to resume the session.
`--prompt` does not auto-submit alongside `--continue`, so send the next instruction via `fm-send` once the TUI is up.

**Busy-queued Enter (opencode 1.18.4, tmux and Herdr).**
While opencode is mid-turn, the composer accepts Enter as a "send when the turn
ends" keystroke but does not clear the typed text from the composer until the
turn actually finishes.
Without a fix, every `fm-send` to a busy opencode pane exits non-zero on a
false "Enter swallowed", and every daemon escalation that lands while the
primary is mid-turn is treated as wedged.
The shared `fm_tmux_submit_enter_core` (`bin/fm-tmux-lib.sh`) now falls back
to `fm_pane_is_busy` once the Enter-retry budget is spent: a busy pane means
the Enter was accepted and queued (reported as `empty` so the caller does not
re-send), while an idle pane keeps `pending` as a genuine swallow. Herdr accepts
the busy queue only after Enter transport succeeds, contemporaneous native state
remains busy, and the pending composer still contains the exact submitted text;
autocomplete-expanded content retries.
Regression coverage: `tests/fm-tmux-submit-busy.test.sh` covers the four
scenarios (busy + pending -> `empty`, idle + pending -> `pending`, busy +
cleared -> `empty`, idle + cleared -> `empty`), and
`tests/fm-backend-herdr.test.sh` covers Herdr queue, autocomplete, and transport failure.

**Primary-session guard fact (verified 2026-07-08, OpenCode 1.17.6).**
The firstmate PRIMARY's own `.opencode/plugins/fm-primary-turnend-guard.js` listens for `session.idle`.
Throwing from `session.idle` does not block `opencode run`, so the primary adapter treats the event as passive and uses `client.session.promptAsync` to force one follow-up turn when `bin/fm-turnend-guard.sh` returns 2.
The companion `.opencode/plugins/fm-primary-watch-arm.js` owns normal TUI watcher wake supervision and coordinates with the guard plugin before the guard tries a blind-turn follow-up.
The follow-up was verified in the interactive TUI; `opencode run` can exit before displaying a queued follow-up, so the adapter is fail-open in headless mode.

## pi (VERIFIED 2026-06-11)

| Fact | Value |
Expand Down
Loading
Loading