Skip to content

docs: move situational AGENTS.md contracts into skills - #173

Merged
dnth merged 1 commit into
mainfrom
fm/port-5872-agents-md-skills
Sep 28, 2026
Merged

dnth merged 1 commit into
mainfrom
fm/port-5872-agents-md-skills

Conversation

@dnth

@dnth dnth commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Ports upstream kunchenguid#5872 (merged as 49a218bb) onto this fork. Situational contracts leave the always-loaded AGENTS.md and go into agent-only skills that load at their triggers. The fork diverged a lot from upstream, so this is a port and not a cherry-pick: every moved block is the fork's own wording moved verbatim, fork-only rules included. Upstream's text was used only as a map.

AGENTS.md goes from 624 lines / 79,878 bytes / 26,626 estimated tokens to 433 lines / 46,783 bytes / 15,595 estimated tokens, a 41.4% cut. The estimate is ceil(UTF-8 bytes / 3) from fm_startup_memory_measure_file in bin/fm-startup-memory-budget-lib.sh, the fork's own estimator.

What moved where

New agent-only skills. Each one has user-invocable: false and metadata.internal: true, and each is registered as agent-runtime in docs/documentation-audiences.json.

Old AGENTS.md text New home Trigger (in the skill's description and in an AGENTS.md pointer)
§2 fenced layout block (all rows, including fork-only ones: crew-harness-fallback, omp-max-time, treehouse-sweep-clean, ext-, inbox-result-targets, runpod, Hermes/Devin/OMP state files, stall-recovery, inbox-results) operational-home-layout locating, interpreting, or changing home/config/data/state/project/runtime paths, and before touching any state/ file (§2 pointer)
§3 digest steps 1-8 and the "secondmate-provisioning owns startup sync" line session-start-recovery digest reports recovery inputs, board drift, or output needing interpretation, or before relying on digest order, lock behavior, or contents (§3 pointer)
§7 ### Validate body (receipt-check lifecycle, run ownership, supersession, ask-user return, ordinary-finding custody return, state judgment) validation-supervision implementation-complete done:, any ship with a no-mistakes run starting or active, a mid-run requirement change or finding, and before deciding or answering any ask-user finding (§7 pointer plus the merge-authority line)
§7 ### PR ready, landing, and teardown body (including the fm-pr-check arm, custom-check rules, teardown, and secondmate retirement) ship-landing every PR-ready or ready-branch signal before reporting it, landing decisions and monitoring, writing or retiring a custom state/<id>.check.sh, and before any teardown or secondmate retirement (§7 pointer)
§7 ### Scout outcome and promotion body scout-completion a scout reports completion or is considered for promotion (§7 pointer)
§8 Away-mode stub bullets: marker format, daemon ownership, marked and unmarked message handling, bias to exit away-quiet-supervision (upstream's name kept; the fork has no quiet mode, and the skill says so) loaded together with /afk on the same triggers (§8 pointer)
§13 agent-only skill list (verbatim, including ext-respond, the Cloud Devin /handoff clause, and the decision-hold-lifecycle redirect), plus entries for the new skills agent-skill-trigger-index only when auditing or maintaining the full index (§13 pointer)

Moves into existing skills:

Old text New home
§14 X-mode config pointer, live-cycle requirement, terminal-outcome rule, "promised reply is durable state", and "only the consenting home posts" new ## X mode activation and ownership contract section in fmx-respond (this is the counterpart of upstream's Relay move)
§15 "docs/configuration.md owns activation..." ext-respond, next to its existing enablement line
§15 "Do not use the hosted X-mode relay, FMX_PAIRING_TOKEN, or pending-reply" removed as a duplicate; ext-respond line 22 already owns it
§12 omp refresh sentence removed as a duplicate; updatefirstmate step 5 already owns both the stopped-fleet proof and the detect-only --check
§3 gh-axi / chrome-devtools-axi / lavish-axi line moved to §1 only, because it applies to every session (upstream put it in both places)

firstmate-coding-guidelines gets upstream's new rule to run bin/-sourcing tests under bash explicitly. Its placement and trigger-hygiene rules are updated for the new structure.

Cross-references fixed: captain-hold-lifecycle (it pointed at §7 Validate), fmx-respond (it pointed at §13), harness-adapters (session-start owner, plus the Cloud Devin /handoff trigger added to its description), the firstmate-codexapp description (smoke-evidence trigger), and docs/sessionstart-nudge.md. No bin/ script changed. The fork's startup-memory budget measures only data/ files, so the move needed no budget wiring.

Where I deviated from upstream, and why

  • Every skill keeps an inline AGENTS.md pointer, and I did not rely on skill descriptions being always loaded. In the headless Claude smoke below, Claude listed the skills by name but showed no descriptions. So upstream's "skill descriptions are the always-loaded trigger index" does not hold on every harness here. Some skills were named only in the old §13 list, so each now gets a one-line pointer in the section where its trigger fires:
    • firstmate-orca and firstmate-codexapp in §4;
    • process-event-sources in §8, together with the "never run a registered source's blocking command yourself" rule;
    • captain-hold-lifecycle, for RECORD DIVERGENCE, in §8;
    • firstmate-coding-guidelines in §1.
  • Authority boundaries stay inline where upstream moved them:
    • "Bootstrap detects first, asks for consent..." and "Do not dispatch until tools and GitHub auth are good" stay in §3; docs/configuration.md and bootstrap-diagnostics already describe them as inline.
    • The away-mode authority line stays in §8.
    • The X-mode token's consent and authority limit stays in §14.
    • The ext-bridge's three authority lines stay in §15.
  • "Firstmate never invokes no-mistakes axi respond for a crew-owned run" stays in §7 as one deliberate reinforcement, next to the validation-supervision pointer.
  • Upstream items with no counterpart in the fork were not ported:
    • deferred NETWORK CHECKS;
    • worker account pins;
    • the mid-task ## Captain's intent rule;
    • the Relay rename;
    • the Lavish visual-scout line;
    • upstream's "Role exception" header line (the fork's hard rule 4 already covers it);
    • upstream's bullet-list reformatting of kept sections, which is formatting only.

Section-by-section assessment (including fork-only sections)

Section Verdict Reason
Header, captain address kept captain-facing etiquette
§1 hard rules, shared-material rules kept hard rules; gained the coding-guidelines pointer and the axi tool line
§2 intro, status-line and captain.md lines kept apply every session
§2 layout block moved → operational-home-layout needed only when working with paths
§3 run-once, FM_TASK_ID worker refusal, read-once, ABSENT, lock-refused read-only, todo re-projection (fork-only), install consent, bootstrap-diagnostics trigger kept apply at every session start or are safety boundaries
§3 digest steps 1-8 moved → session-start-recovery needed only when interpreting the digest
§4 harness list and dispatch intake (incl. Hermes/Devin, secondmate fallback) kept fires at every intake and gates unverified adapters
§4 quota/profile-array paragraph deferred about 15 lines, but it fires at every crewmate intake, upstream kept it, and quota-array-dispatch already owns the procedure; a later pass could shrink it
§5 recovery kept every session start
§6 project and knowledge routing kept always-on routing; project-management and secondmate-provisioning already hold the procedures
§7 intake, dispatch, merge authority kept merge-authority rules never move
§7 Validate, PR ready/landing, scout moved → validation-supervision, ship-landing, scout-completion lifecycle-step specific
§8 supervision core, wake drain, wake handling, merged-PR reconcile, STATUS OUTCOME BACKSTOP receipt (OMP supervision-branch clause), watcher-kill ban, guard warnings kept fire on every wake; this includes the no-turn-ends-blind contract
§8 RunPod scale-to-zero "never escalate as failure" (fork-only) kept fires on ordinary stale or heartbeat wakes where no skill is guaranteed to be loaded; moving it risks escalating a healthy route
§8 away-mode safety facts moved → away-quiet-supervision only matter while away; the authority line stays
§8 stuck-worker trigger kept a trigger line
§9 escalation and captain etiquette kept captain-facing etiquette
§10 backlog contract kept board changes and todo re-projection happen on nearly every turn; the mechanics already sit in .tasks.toml, tasks-axi, and fm-todo-project.sh
§11 briefs kept every dispatch; worktree-isolation safety
§12 self-update kept (omp sentence deduped into updatefirstmate) already a stub
§13 skill list moved → agent-skill-trigger-index only needed for audits, since operating sections carry the pointers
§14 X mode (fork wording) mechanics moved → fmx-respond; opt-in, authority, and trigger kept authority stays inline
§15 Local Communication Officer bridge (fork-only) config pointer moved → ext-respond; opt-in, authority, and trigger kept authority stays inline
Captain instruction precedence (fork-only) kept authority rule
Maintaining this file kept self-governance
OMP supervision-branch details no dedicated fork section; OMP layout rows moved with the layout; omp self-update deduped see the §8 and §12 rows
Remote/RunPod secondmates layout rows moved; the §8 scale-to-zero line kept see the §8 row
Devin/Hermes adapters verified-harness list kept in §4; state rows moved; Cloud Devin /handoff trigger in harness-adapters and the index

Hard-rule and boundary locations (AC2)

Boundary Where it is now
Hard rules 1-5 (never write to a project, merge only on captain's word, never tear down unlanded work or --force, crewmates never address the captain, report faithfully) §1, unchanged
Merge authority (yolo, never merge red, destructive/irreversible/security escalation, fm-pr-merge.sh/fm-merge-local.sh guards, autonomous-merge report) §7 "Selected delivery path and merge authority", unchanged
"A captain instruction to merge is explicit authority; yolo is the only standing routine merge authority" ship-landing; the same authority is still stated inline by hard rule 2 and §7
Worker never answers its own ask-user finding §7, inline
Forbid --yes; process every synchronous return validation-supervision, loaded before deciding or answering any ask-user finding
Firstmate never runs axi respond for a crew run §7 inline, and validation-supervision
Teardown only after landing; refusal means stop and investigate; never force without discard authority hard rule 3 in §1 (inline), full text in ship-landing
Scout scratch discarded only after report plus completion gate hard rule 3 in §1 (inline), full text in scout-completion
Captain instruction precedence unchanged
No turn ends blind §8, unchanged
Lock-refused read-only mode §3, §5, §8, unchanged
Session start refused for task workers (FM_TASK_ID) §3, unchanged
Install consent; no dispatch without tools and GitHub auth §3, inline
Away mode never changes merge, finding, or destructive authority §8, inline
X-mode token is not authority for destructive action §14, inline
Ext-bridge is not authority for destructive action or project changes §15, inline
Only the consenting home posts a promised public reply fmx-respond (loaded before promising one and on every follow-up trigger)
Never run a registered source's blocking command yourself §8, inline
Never broadly kill watchers §8, unchanged
Worktree isolation §7, §8, §11, unchanged
"Never touch" runtime internals operational-home-layout, loaded before touching any state/ file
omp refresh only after stopped-fleet proof updatefirstmate step 5
Custom check rules (mode 0700, register, unregister) ship-landing, loaded before writing or retiring a custom check

Test plan

Every command was run with bash explicitly, in the task worktree:

  • bash tests/fm-startup-memory-budget.test.sh: all passed
  • bash tests/fm-supervision-instructions.test.sh: all passed
  • bash tests/fm-ensure-agents-md.test.sh: all passed
  • bash tests/fm-documentation-audiences.test.sh: all passed
  • bash bin/fm-doc-audience-check.sh: ok surfaces=87 local_links=321
  • env -u FM_TASK_ID bash tests/fm-session-start.test.sh: all passed
  • fm-ensure-agents-md.sh .: unchanged
  • Throwaway home smoke at /tmp/port5872/smoke-home, a copy of the tracked files:
    • fm-session-start.sh rendered every section: lock, bootstrap, wake queue, supervision instructions, fleet state, context, next step. It correctly stayed read-only because no harness owned the lock.
    • fm-supervision-instructions.sh rendered.
    • fm-startup-memory-budget.sh report returned within-budget at 7500.
    • Headless claude -p with hooks disabled and read-only tools listed validation-supervision and ship-landing as available skills. It quoted the exact new §7 pointer lines when asked which skill to load for a checks-green PR and for an implementation-complete done:.

The no-mistakes Test step came back inconclusive because only the session-start smoke counted as live. It was approved as a recorded exception, because AC3, AC4, and AC5 name their own proofs and the receipts carry them. The pipeline also could not drive a live Claude session.

Pipeline testing record

The prior payload recorded four affected test shards, an AGENTS.md word-count comparison, and an isolated live session-start smoke. Only the session-start smoke had live=true with evidence; the other scenarios are downgraded to untested as required.

  • Live validation: ⚠️ inconclusive - 1 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Affected acceptance checks validate startup budget, supervision rendering, AGENTS scaffolding, and documentation manifest behavior ⏸️ untested no The prior payload listed command-based test runs but explicitly marked this scenario live=false; those checks do not establish a live product result.
Start an isolated throwaway firstmate home and run session start; the digest completes, acquires the lock, renders supervision instructions, and includes the session-start/read-once/fleet/context surf… ✅ pass live Artifact: Live session-start digest smoke
A moved agent-only skill is discovered and triggered by a real supported agent harness from the new AGENTS.md pointer ⏸️ untested no No authorized live agent session/credential was available to exercise skill loading and trigger dispatch; the repository tests validate the manifest and pointers, but that is not live harness evidence…
AGENTS.md is measurably smaller after the restructuring ⏸️ untested no The prior payload provided a word-count comparison but explicitly marked this scenario live=false; static measurement does not establish a live product result.
Evidence: Live session-start digest smoke

================================================================================
SESSION START - ~/.no-mistakes/worktrees/dd71c22cc6d7/01M3JTHKPTVGX4DBEZS1H7M7E3/.tmp-session-smoke
================================================================================

LOCK
--------------------------------------------------------------------------------
lock acquired: harness pid 1956185

BOOTSTRAP
--------------------------------------------------------------------------------
MISSING: treehouse (install: curl -fsSL https://kunchenguid.github.io/treehouse/install.sh | sh)
MISSING: gh (install: brew install gh  # or the platform's package manager)
MISSING: no-mistakes (install: curl -fsSL https://raw.githubusercontent.com/kunchenguid/no-mistakes/main/docs/install.sh | sh)
NEEDS_GH_AUTH

WAKE QUEUE
--------------------------------------------------------------------------------
(no queued wakes)
================================================================================
SUPERVISION OPERATING INSTRUCTIONS - primary harness: codex
================================================================================
Current state:
- Lock: held by this session; this session owns normal supervision unless away mode says otherwise.
- Away mode: inactive.
- X mode: inactive; use the default watcher cadence.
- Ordinary wake: take the next foreground bin/fm-watch-checkpoint.sh checkpoint as directed below.

Mode: Codex foreground checkpoint.

When this session owns supervision and away mode is not active:
1. Drain first with `bin/fm-wake-drain.sh`.
   After handling all emitted wakes and reconciling open decisions, unread status lines, and any STATUS OUTCOME BACKSTOP entry, run the exact `--ack-through` command printed as `WAKE_ACK_REQUIRED`; until then the work remains durable for idempotent re-handling after interruption.
   Every STATUS OUTCOME BACKSTOP entry stays pending until its printed `bin/fm-branch-outcome.sh deliver` receipt is recorded; relay the event to the captain, then run that exact command.
2. Source `~/.no-mistakes/worktrees/dd71c22cc6d7/01M3JTHKPTVGX4DBEZS1H7M7E3/.tmp-session-smoke/config/x-mode.env` first when X mode is active.
3. First cycle: run one foreground watcher checkpoint with `bin/fm-watch-checkpoint.sh --seconds "${FM_CODEX_WATCH_CHECKPOINT:-180}"`.
4. Ordinary wake: if the command prints `signal:`, `stale:`, `check:`, or `heartbeat`, drain queued wakes, handle that wake, then start the next checkpoint.
5. If the command prints `checkpoint:` or exits 124 with no wake, drain queued wakes anyway, process any queued user message now visible to Codex, then start the next checkpoint.
6. Never use shell `&` or Codex background tasks for firstmate watcher supervision.
7. Do not run `bin/fm-watch-arm.sh` as Codex's normal supervision command.
   If it is ever shelled anyway, a backgrounded, piped, or bundled anti-pattern is denied automatically by the PreToolUse seatbelt (`bin/fm-arm-pretool-check.sh`) registered in `.codex/hooks.json`.
8. Failure or missing cycle only: drain queued wakes, inspect the failure, then start a fresh foreground checkpoint.

Codex cannot reason while a foreground tool call is running.
The bounded checkpoint returns control regularly so user messages and queued wakes can be handled without relying on background-task wake semantics.


================================================================================
READ-ONCE CONTRACT
================================================================================
Everything below is printed in full for this session start: every state/*.meta,
a compact data/backlog.md listing, a bounded tail of every state/*.status,
data/projects.md, data/secondmates.md, data/captain.md, data/captain-shared.md,
and data/learnings.md.
Do NOT re-read any of them after reading this digest, and do NOT bulk-read
data/backlog.md or state/*.status: re-reading everything defeats the entire
point of this command.

Go to a source directly only when:
  - this digest flagged it ABSENT (then rebuild or create it per AGENTS.md),
  - its contents looked unparseable or corrupt,
  - an individual full status log is needed for older wake-event history, or a
    status line was capped and its tail matters (each task's full log path is
    printed with its tail),
  - a full task body is needed (bin/fm-tasks-axi.sh show <id> --full, or data/backlog.md),
  - the backlog listing disclosed omitted queued items and this turn needs them,
  - or a STARTUP TRUNCATED banner named the stage that would have printed it, in
    which case that stage's sources were never emitted and must be reconciled.

================================================================================
FLEET STATE
================================================================================

data/backlog.md
--------------------------------------------------------------------------------
compact backlog listing (tasks-axi; done rows omitted; every in-flight, held, and blocked row shown in full; ready queued bounded to 20; task bodies omitted)

in flight:
count: 0
tasks: 0 in_flight tasks in this backlog

held (captain- or time-gated; an in-flight item that is also held appears in both groups):
count: 0
tasks: 0 held tasks in this backlog

blocked queued:
count: 0
tasks: 0 blocked queued tasks in this backlog

ready queued (dispatchable now):
count: 0
ready: 0 unblocked queued tasks
ready_public_followups: 0 delivery-ready obligations
Full task bodies remain available on demand: bin/fm-tasks-axi.sh show <id> --full when compatible tasks-axi is available, or data/backlog.md.

Work under way (state/*.meta)
--------------------------------------------------------------------------------
(none)

Orphan status logs (state/*.status without matching .meta)
--------------------------------------------------------------------------------
(none)

AFK
--------------------------------------------------------------------------------
absent

================================================================================
CONTEXT
================================================================================

data/projects.md
--------------------------------------------------------------------------------
# smoke projects

data/secondmates.md
--------------------------------------------------------------------------------
# smoke secondmates

data/captain.md
--------------------------------------------------------------------------------
# smoke captain

data/captain-shared.md (shared, main-authoritative, read-only in secondmate homes)
--------------------------------------------------------------------------------
ABSENT

data/learnings.md
--------------------------------------------------------------------------------
# smoke learnings

================================================================================
NEXT STEP
================================================================================
Follow the supervision operating instructions block above for harness 'codex'.
This script never starts supervision itself.

The digest above is complete for this session start. The READ-ONCE CONTRACT
section near the top of it governs what may still be read from disk.
- Outcome: ⚠️ 1 warning across 1 run (3m8s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (1 of 4 scenarios were driven live against the product); untested: Affected acceptance checks validate startup budget, supervision rendering, AGENTS scaffolding, and documentation manifest behavior, A moved agent-only skill is discovered and triggered by a real supported agent harness from the new AGENTS.md pointer, AGENTS.md is measurably smaller after the restructuring
  • Live validation: ⚠️ inconclusive - 1 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Affected acceptance checks validate startup budget, supervision rendering, AGENTS scaffolding, and documentation manifest behavior ⏸️ untested no The prior payload listed command-based test runs but explicitly marked this scenario live=false; those checks do not establish a live product result.
Start an isolated throwaway firstmate home and run session start; the digest completes, acquires the lock, renders supervision instructions, and includes the session-start/read-once/fleet/context surf… ✅ pass live Artifact: Live session-start digest smoke
A moved agent-only skill is discovered and triggered by a real supported agent harness from the new AGENTS.md pointer ⏸️ untested no No authorized live agent session/credential was available to exercise skill loading and trigger dispatch; the repository tests validate the manifest and pointers, but that is not live harness evidence…
AGENTS.md is measurably smaller after the restructuring ⏸️ untested no The prior payload provided a word-count comparison but explicitly marked this scenario live=false; static measurement does not establish a live product result.
  • bash tests/fm-startup-memory-budget.test.sh
  • bash tests/fm-supervision-instructions.test.sh
  • bash tests/fm-ensure-agents-md.test.sh
  • bash tests/fm-documentation-audiences.test.sh
  • FM_HOME=.tmp-session-smoke FM_ROOT_OVERRIDE=$PWD FM_BOOTSTRAP_DETECT_ONLY=1 bin/fm-session-start.sh
  • AGENTS.md before/after word-count comparison
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Port upstream kunchenguid#5872's intent onto the fork's own AGENTS.md text: the home
layout, session-start digest steps, validation supervision, PR landing and
teardown, scout completion, away-mode safety facts, and the agent-only
trigger list move verbatim into agent-only skills loaded at their triggers.
X-mode and ext-bridge mechanics move into fmx-respond and ext-respond.
Hard rules, merge authority, lock-refused read-only mode, install consent,
and the away/X/ext authority boundaries stay inline, and every operating
section keeps an inline pointer for each skill it depends on.
@dnth
dnth merged commit 6358157 into main Sep 28, 2026
42 of 44 checks passed
@dnth
dnth deleted the fm/port-5872-agents-md-skills branch September 28, 2026 03:15
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