diff --git a/.agents/skills/bootstrap-diagnostics/SKILL.md b/.agents/skills/bootstrap-diagnostics/SKILL.md index b06d419b689..95932444f83 100644 --- a/.agents/skills/bootstrap-diagnostics/SKILL.md +++ b/.agents/skills/bootstrap-diagnostics/SKILL.md @@ -2,7 +2,7 @@ name: bootstrap-diagnostics description: >- Agent-only handling playbook for session-start bootstrap diagnostics. - Use whenever the session-start digest's bootstrap section prints an actionable diagnostic line - MISSING, MISSING_MANUAL, BACKEND_INVALID, NEEDS_GH_AUTH, TANGLE, STARTUP_MEMORY_BUDGET, CREW_DISPATCH invalid, FLEET_SYNC, PR_CHECK_MIGRATION, SECONDMATE_SYNC, SECONDMATE_LIVENESS, SECONDMATE_HANDOFF, NUDGE_SECONDMATES, or FMX - or when a standalone bin/fm-bootstrap.sh run prints one of those lines. + Use whenever the session-start digest's bootstrap or network-checks section prints an actionable diagnostic line - MISSING, MISSING_MANUAL, BACKEND_INVALID, NEEDS_GH_AUTH, TANGLE, STARTUP_MEMORY_BUDGET, CREW_DISPATCH invalid, FLEET_SYNC, NETWORK_CHECKS, PR_CHECK_MIGRATION, SECONDMATE_SYNC, SECONDMATE_LIVENESS, SECONDMATE_HANDOFF, NUDGE_SECONDMATES, or FMX - or when a standalone bin/fm-bootstrap.sh or bin/fm-startup-network.sh run prints one of those lines. A silent bootstrap section, or a BOOTSTRAP_INFO fact, means no skill load. user-invocable: false metadata: @@ -25,6 +25,10 @@ When any diagnostic needs captain attention, report the plain consequence and re - `MISSING_MANUAL: (instructions: )` - tell the captain why the tool is required and give them the printed instructions URL, but do not pass the tool to `bin/fm-bootstrap.sh install`; wait for the captain to complete the manual installation, then rerun session start to confirm the dependency is present. - `BACKEND_INVALID: (known: )` - the resolved runtime backend has no verified dependency or lifecycle contract, so do not dispatch work until the invalid `FM_BACKEND` or `config/backend` value is corrected to one of the listed backends. - `NEEDS_GH_AUTH` - ask the captain to run `! gh auth login` (interactive; you cannot run it for them). + This probe now arrives from the deferred network stage, so it is also how an unreachable network shows up: `gh` cannot validate its token offline and reports the same failure. Confirm reachability before asking the captain to re-authenticate a credential that may be fine. +- `NETWORK_CHECKS: ; rerun ` - the deferred network stage itself could not finish, so the checks it names are simply unknown, not failed. + Rerun the printed command; it is idempotent and re-derives every finding. + A `hit the ...s bound` line means one of those checks is slow or unreachable - most often a remote secondmate host - and the stage stopped rather than letting it wedge; a `lock was no longer held` line means the session that asked for the sweeps no longer owns them, so leave them to the session that does. - `TANGLE: ` - the primary checkout is stranded on a feature branch instead of its default branch; `AGENTS.md` section 8 explains why this guard exists and what it protects. The work is safe on that branch ref; restore the primary to its default branch with the printed `git -C checkout `, then re-validate that branch in a proper worktree. This is the only sanctioned firstmate-initiated git write to the primary, and it is a non-destructive branch switch that strands nothing. diff --git a/.agents/skills/maintenance-agent-grading/SKILL.md b/.agents/skills/maintenance-agent-grading/SKILL.md new file mode 100644 index 00000000000..52afc3ca384 --- /dev/null +++ b/.agents/skills/maintenance-agent-grading/SKILL.md @@ -0,0 +1,54 @@ +--- +name: maintenance-agent-grading +description: >- + Agent-only procedure for recording recurring maintenance-agent outcomes, + reading their scoreboard, and proposing reviewed reusable-brief refinements. + Load after a maintenance-agent PR resolves, before recording its final grade + or teardown, and before reviewing grades or proposing a brief change. +user-invocable: false +metadata: + internal: true +--- + +# Maintenance-agent grading and reviewed improvement + +This skill owns the review procedure for Dead Code Cleanup, Abstraction Police, Experiment Clean-up, Test Coverage, and Useless Test Removal. +`bin/fm-agent-grade.sh --help` owns the ledger path, row contract, validation rules, outcome vocabulary, commands, and scoreboard formulas. + +## Record the outcome + +After the PR disposition and reviewer feedback are known, and before task teardown and backlog archival, record the maintenance run exactly once. +Use a stable privacy-safe agent slug and the Firstmate task id. +Pass the canonical PR URL when one exists, label each known false-positive candidate with a privacy-safe identifier, and keep raw prompts, private source text, and diffs out of the ledger. +Choose `rejected` only when review rejected the maintenance output on its merits. +Use `closed` for an unmerged PR closed for another reason, so timing, overlap, or custody does not become a false quality signal. + +```sh +bin/fm-agent-grade.sh record dead-code-cleanup cleanup-123 \ + --pr https://github.com/example/repo/pull/123 \ + --outcome merged_changed \ + --false-positive generated-path \ + --note "review removed one candidate" +``` + +Do not add this call to every PR merge or teardown. +Only Firstmate tasks identified as one of these recurring maintenance agents produce a grade. + +## Review the scoreboard + +Run `bin/fm-agent-grade.sh report` for the fleet view or add `--agent ` for one agent. +Treat the displayed rates as small-sample evidence with explicit denominators, not as one magic score. +Ringer execution grades and no-mistakes findings are complementary evidence when those systems were selected, but this first loop does not import or modify either system's data. + +## Propose a reviewed brief refinement + +1. Review one agent's rejected runs and false-positive-labeled runs from the scoreboard and ledger. +2. Read the linked PR and review evidence before deciding that the reusable brief, rather than execution or context, caused the miss. +3. Prepare one surgical reusable-brief diff that addresses the repeated failure pattern without changing authority, safety boundaries, or the agent's approved scope. +4. Present the proposal as an ordinary governed change in the reusable brief's owner repository, with its supporting examples and expected effect. +5. Keep the proposal inert until the captain approves the diff and the selected delivery path merges it. +6. Activate or sync the merged brief only through its existing governed path, then grade later runs against the resulting behavior. + +This follows the Hermes and Mercury governance boundary: an agent may propose a change, while Firstmate and the captain retain review, merge, deployment, and activation custody. +Maintenance agents never rewrite their own reusable briefs unsupervised. +This skill and the grading helper do not run a daemon, schedule reviews, generate autonomous patches, or activate a proposed refinement. diff --git a/.agents/skills/process-event-sources/SKILL.md b/.agents/skills/process-event-sources/SKILL.md index 8b02dc4b504..705d4dc5563 100644 --- a/.agents/skills/process-event-sources/SKILL.md +++ b/.agents/skills/process-event-sources/SKILL.md @@ -4,7 +4,8 @@ description: >- Agent-only procedure for registered process-to-event sources and their wakes. Use before arming a long-polling source firstmate owns, and on any `procevent ` check wake. - Owns the arming commands, the durable result read, the handled + Owns the arming commands, the durable result read, which wakes must be + routed to their adapter instead of acknowledged generically, the handled acknowledgement contract, the one-owner rule, the precise durability boundary, and the Lavish adapter's loss limitation. user-invocable: false @@ -43,6 +44,15 @@ Two rules the commands cannot enforce for you: `procevent ` : The named durable result is waiting at `state/procevent-inbox/..result`. Read that exact result; separate wakes identify later results independently. +: **When the adapter owns applying the result, run the adapter, not the generic acknowledgement below.** The `` field of the wake decides this, and `remote-reply` is such an adapter: a captured delta is applied only by + ```sh + bin/fm-procevent-remote-reply.sh handle + ``` + Here `` is the `` with its `remote-reply-` prefix removed. + The runner normally applies the result on capture, but this call is the required idempotent confirmation when the wake remains unacknowledged. + Never acknowledge a `remote-reply` wake through the generic command, because only the adapter ingests the delta, acknowledges it, and re-arms its source. + Use the generic path below only after fully handling a result whose adapter has no applying command. + [`docs/configuration.md`](../../../docs/configuration.md#process-to-event-sources-stateprocevent) owns the automatic-application contract and its failure boundary. : A captured result with no durable handled acknowledgement stays eligible for bounded re-announcement on the existing wake queue - across any number of drains and firstmate restarts, not only the crash window right after capture - until it is explicitly acknowledged. Once you have fully handled a result, durably record it: ```sh bin/fm-procevent.sh handled @@ -59,7 +69,7 @@ Supported by tests: - output that reached the runner is stored atomically at mode `0600` **before** any event referencing it is published; - the remote-reply adapter reads its append-only source non-destructively from an offset plus prefix hash, so a pre-capture retry can derive the same bytes again, while source truncation or replacement is detected rather than silently rebased; -- proactive delivery and adapter-owned terminal retirement follow the operating contract in [`docs/configuration.md`](../../../docs/configuration.md); +- proactive delivery, adapter-owned terminal retirement, and adapter-owned automatic application follow the operating contract in [`docs/configuration.md`](../../../docs/configuration.md); - a durably captured result with no handled acknowledgement remains eligible for bounded re-announcement across any number of drains and restarts, and repeat wakes retain the same source and sequence for deduplication; - the handled acknowledgement is generation-keyed to the exact source and sequence, private, path-safe, durable, and idempotent, and is the only thing that stops re-announcement; - one identity-matched owner per canonical source, across homes that share one underlying source store; diff --git a/.agents/skills/secondmate-provisioning/SKILL.md b/.agents/skills/secondmate-provisioning/SKILL.md index 12b90bed3ab..b6fda865d13 100644 --- a/.agents/skills/secondmate-provisioning/SKILL.md +++ b/.agents/skills/secondmate-provisioning/SKILL.md @@ -3,7 +3,7 @@ name: secondmate-provisioning description: >- Agent-only reference for persistent secondmate setup and retirement. Use when creating, seeding, validating, launching, recovering, handing backlog to, pushing inherited local material into, or retiring a secondmate home, or when editing data/secondmates.md. - Covers local leases, whole-home remote routes, transactional seeding, project clone restrictions, secondmate harness pins, inherited local-material push, idle charter, handoff helper, and teardown safety. + Covers local leases, whole-home remote routes, transactional seeding, record intake for an existing or inherited domain, project clone restrictions, secondmate harness pins, inherited local-material push, idle charter, handoff helper, and teardown safety. user-invocable: false metadata: internal: true @@ -69,11 +69,13 @@ bin/fm-home-seed.sh {...|--no-projects} Provision a whole remote home through its configured SSH host with: ```sh -bin/fm-remote-home-seed.sh {...|--no-projects} +bin/fm-remote-home-seed.sh {[=]...|--no-projects} ``` -The remote command transfers a bounded charter and project-origin manifest, then the remote host clones its own Firstmate home and project origins. -It never copies a project tree or the primary process environment. +You resolve each project's origin yourself - from the captain, the project registry, a clone that exists elsewhere, `gh-axi`, or an explicit paste - and name it as `=`; the seed validates and transports what you supply. +A remote seed therefore creates nothing in this home beyond the route, the charter brief, and a launch record once it is launched: never clone a project into `projects/`, initialize no-mistakes here, or run a fleet sync just to seed a remote secondmate. +A bare `` remains a convenience for a project this home already has cloned, whose configured origin is read instead. +[`docs/remote-secondmates.md`](../../../docs/remote-secondmates.md#provision-a-route) owns the rest of the operator contract, and [`bin/fm-project-origin-lib.sh`](../../../bin/fm-project-origin-lib.sh) owns the accepted origin forms. Pass `--no-projects` in the project position to seed the project-less home described above; the same mutual-exclusion and fail-loud-on-omission rules apply. It may only seed a home with no project clones or project-registry entries, and refuses conversion of populated homes without changing them. `-` durably leases a fresh firstmate worktree via `treehouse get --lease` under the secondmate id. @@ -97,12 +99,12 @@ This is secondmate-only: crewmate/scout model resolution is untouched by this fi This section is the single owner of the secondmate sync and inherited-local-material propagation contract; `AGENTS.md` sections 3 and 4 point here. Before a local launch, `fm-spawn.sh --secondmate` locally fast-forwards the home to the primary firstmate checkout's current default-branch commit when it is safe; dirty, diverged, or in-flight homes launch unchanged with a warning. -The locked session-start bootstrap sweep runs the same guarded fast-forward for every live local secondmate home, discovered from `state/.meta` records with `kind=secondmate` (`data/secondmates.md` only backfills `home=` for older records). +The locked session-start deferred network stage runs the same bootstrap sweep for every live local secondmate home, discovered from `state/.meta` records with `kind=secondmate` (`data/secondmates.md` only backfills `home=` for older records). That no-fetch path is a purely local fast-forward of tracked files, never an origin fetch, and it never touches the gitignored operational dirs, so a secondmate's backlog, projects, and in-flight work are never disturbed; a linked worktree advances immediately, while a standalone clone that lacks the target receives firstmate updates through `/updatefirstmate`'s origin refresh. -A remote launch and locked bootstrap sweep ask the configured host to fast-forward its persistent home to that host's code-root commit under the same clean and ancestry guards. +A remote launch and the deferred bootstrap sweep ask the configured host to fast-forward its persistent home to that host's code-root commit under the same clean and ancestry guards. `/updatefirstmate` first updates the remote code root from its own origin, then runs that guarded home sync. SSH exit 255 preserves the route and reports unknown completion; it never triggers local respawn or failover. -The same placement-specific launch and locked bootstrap sweep also propagate the primary's declared inherited local material: `config/crew-dispatch.json`, `config/crew-harness`, `config/backlog-backend`, `config/backend`, `config/herdr-presentation-spaces`, `config/startup-memory-budget`, and the one shared captain-preference file `data/captain-shared.md`. +The same placement-specific launch and deferred bootstrap sweep also propagate the primary's declared inherited local material: `config/crew-dispatch.json`, `config/crew-harness`, `config/backlog-backend`, `config/backend`, `config/herdr-presentation-spaces`, `config/startup-memory-budget`, and the one shared captain-preference file `data/captain-shared.md`. Because these paths are gitignored, that propagation is a separate, primary-authoritative copy independent of the tracked-files fast-forward: it re-converges every live home whether or not its tracked files advanced, and it touches only the declared items. Propagation failures warn without blocking secondmate launch or session-start continuation, and the destination keeps whatever safely validated state the helper left behind. Inheritance copies the literal `config/crew-harness` file, so a secondmate's own crewmates use the primary's crewmate harness only when it names a concrete adapter such as `codex`; an unset or `default` value has nothing concrete to inherit, and the secondmate's own crewmates fall back to the secondmate's own or detected harness instead. @@ -152,6 +154,26 @@ Secondmate project lists may include `no-mistakes` and `direct-PR` projects only `local-only` projects stay with the main firstmate. For `no-mistakes` projects, seeding initializes only projects newly cloned into a secondmate home and refuses to mutate a preexisting clone that is not already initialized. +## Record intake for an existing or inherited domain + +Classify the domain before seeding, because this step applies to only one of the two cases. +A greenfield domain has no delivered domain work yet: nothing already shipped in its projects, no live deployment, and no predecessor records to import. +Seed a greenfield domain normally; there is nothing to reconcile and this section adds no work to it. +An existing or inherited domain is any domain whose product is already in development, and any predecessor's domain a new mate takes over, including a consolidation after a retirement. +Both of those cases require record intake before the new mate acts on any inherited plan. + +For an existing or inherited domain, the creating agent must: + +1. Reconcile every inherited plan against the domain's authoritative shipped state, which is `origin/main` for each relevant project plus the live deployment. + A fetched clone of each relevant project is a precondition of that reconciliation, so wire the home to its projects before reconciling rather than on first task. + The imported backlog, the predecessor's own notes, instruction-surface prose, and an absent or unfetched local view are all inadmissible as shipped-state evidence. +2. Seed the new home with only genuinely open work plus the domain's durable knowledge, meaning the learnings, decisions, and delivery posture that are still live. +3. Never inherit a plan backlog blind. + A plan row whose work is already shipped is dropped, or recorded as done with the merged evidence that settles it, and is never carried forward as open. + +A live backlog keeps only the configured recent Done entries by design, so an inherited queue structurally over-represents plans and under-represents deliveries. +Treat an inherited queue that carries plans with no matching delivery record as unreconciled rather than as open work, and record whatever could not be reconciled as an explicit residual-uncertainty list in the new home rather than leaving that gap silent. + ## Backlog handoff Apply `AGENTS.md` section 10's work-items-only backlog contract before creation or handoff. @@ -164,6 +186,7 @@ bin/fm-backlog-handoff.sh ... ``` After seeding, run this handoff for the new secondmate's in-scope queued items. +For an existing or inherited domain, complete record intake first so no already-shipped plan row is handed off as open work. For a local route, the helper resolves and validates the secondmate home from `data/secondmates.md`, then delegates the item move to `tasks-axi mv` (the single owner of the backlog format), which moves each named item - and a whole connected set, blocker plus dependents, atomically - from the main `data/backlog.md` into the secondmate home's `data/backlog.md`. For a remote route, the same helper first moves the dependency-closed set atomically from the main backlog into `data/handoff/.outbox.md`, then transfers that backlog-format outbox through `fm-on.sh` and lets the remote home's `fm-backlog-receive.sh` move every not-already-present key under the destination lock. The outbox is the whole recovery record: its presence means delivery is unfinished, `--resume-pending` safely re-delivers it, and confirmed receipt removes it. diff --git a/AGENTS.md b/AGENTS.md index 7547155a593..5ee2224b159 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -111,6 +111,7 @@ state/ volatile runtime signals; gitignored x-outbox/ generated Relay dry-run reply and dismiss previews; inspect it when FMX_DRY_RUN is set (section 14) public-followup/ generated private transport for promised public replies: commitment registrations, typed terminal-result inbox, accepted/rejected ledgers (section 14; bin/fm-public-followup.sh) x-poll.error x-poll.claim-error generated Relay and offer-claim diagnostic dedupe markers + .startup-network.* status, report, inline-print claim, and lock for the deferred network stage session start runs off its blocking path; bin/fm-startup-network.sh .wake-queue durable queued wakes: epochseqkindkeypayload ..open-decisions-cursor per-task byte cursor and folded open-decision set bounding the OPEN DECISIONS scan's cost to new status-log appends; written only by fm-classify-lib.sh's status_open_decisions_incremental, removed by teardown, safe to delete (forces one full re-fold) .afk durable away-mode flag; present = sub-supervisor may inject escalations (set by /afk, cleared on user return) @@ -131,7 +132,7 @@ Treat `data/captain.md` as the domain-local record of captain preferences, optio Run `bin/fm-session-start.sh` exactly once at session start. Its header is the single owner of composed commands, ordering, and digest contents. `bin/fm-supervision-instructions.sh` renders the emitted supervision block from `docs/supervision-protocols/`. -Do not reimplement it by separately running its lock, bootstrap, or initial wake-drain components. +Do not reimplement it by separately running its lock, bootstrap, initial wake-drain, or deferred-network components. Run-tier harness surfaces run this command for you at session open while the rest only nudge it, so confirm the digest is present in this session and run it yourself when it is not; `docs/sessionstart-nudge.md` owns adapter tiers, source routing, and compatibility. Read the complete digest once and trust it as this turn's startup and recovery input. @@ -142,21 +143,27 @@ An `ABSENT` captain, shared-captain, secondmate, or learnings file means the fir If the session lock cannot be acquired and verified, report its exact diagnostic and remain read-only; another active session is only one possible cause. A lock-refused session must not spawn, steer, merge, drain the wake queue, repair supervision, repair a checkout, or perform any other fleet mutation. -1. **Lock** - acquires the per-home session lock first, before anything mutates shared state. -2. **Bootstrap** - detect-only checks (tool/version problems, GitHub auth, the worktree-tangle check, harness override, dispatch-profile validation, backlog-backend status) always run, but routine confirmations stay silent by default. +The digest itself makes no external-network call and never waits for one. +Every network check a session start owes - GitHub auth, dead-secondmate relaunch, secondmate convergence, pending handoff delivery, and project clone refresh - runs concurrently in a bounded worker owned by `bin/fm-startup-network.sh` and is reported in the digest's own `NETWORK CHECKS` section. +When that section reports its checks still in progress it names exactly what is unconfirmed; treat none of those as passed until the result lands, either from `bin/fm-startup-network.sh report` or as a `check: startup-network` wake. + +1. **Lock** - acquires the per-home session lock first, before anything mutates shared state, then starts the deferred network stage above. +2. **Bootstrap** - detect-only checks (tool/version problems, the worktree-tangle check, harness override, dispatch-profile validation, backlog-backend status) always run, but routine confirmations stay silent by default. When the lock could not be acquired, the worktree-tangle check uses read-only advisory wording without a checkout repair command. - Home-local stale Herdr projection cleanup and the six bootstrap MUTATING sweeps - non-executing legacy PR-check migration, fleet sync, secondmate convergence, secondmate liveness, pending remote handoff retry, and Relay artifact writes - run only when this session actually holds the lock from step 1. + Home-local stale Herdr projection cleanup and the six bootstrap MUTATING sweeps - non-executing legacy PR-check migration, fleet sync, secondmate convergence, secondmate liveness, pending remote handoff retry, and Relay artifact writes - run only when this session actually holds the lock from step 1; the four network ones among them run in the deferred stage rather than in this section. The secondmate liveness sweep deterministically accounts for every registered secondmate: it relaunches only from the recovery-grade `dead` or `missing` states, preserves ambiguous, unreadable, or unreachable remote targets, and reports skipped or failed guarantees as `SECONDMATE_LIVENESS:` lines (`bin/fm-bootstrap.sh`; `bin/fm-backend.sh`'s `fm_backend_agent_state`; `docs/remote-secondmates.md`). 3. **Wake queue** - when locked, drains the durable wake queue and prints the raw records prominently as this turn's first work queue; a bounded, clearly labeled historical status-event annotation may follow a valid `signal` record but never replaces it or current-state reconciliation, and a lapsed watcher chain still surfaces here via the same guard alarm. Every locked drain also prints a bounded fleet-wide `OPEN DECISIONS` section when durable decision records remain open, including when the queue itself is empty; reconcile those entries before continuing. When the lock could not be acquired and verified, the queue is left untouched because no session mutation is authorized, and the guard's tangle/watcher-liveness alarms still print in read-only advisory mode without drain, supervision repair, or checkout repair commands. -4. **Context digest** - the full contents of `data/projects.md`, `data/secondmates.md`, `data/captain.md`, `data/captain-shared.md`, and `data/learnings.md`, each clearly delimited. - A file that does not exist prints an explicit `ABSENT` marker, never confused with an empty-but-present file: absence is meaningful (`captain.md` absent means use the firstmate repo's built-in defaults, `projects.md` absent means rebuild it from the clones under `projects/`, etc.). -5. **Fleet-state digest** - the compact backlog listing owned by `bin/fm-session-start.sh`; every `state/.meta`; a bounded tail of each task's `state/.status` (labeled as wake-EVENT history, not current state, with the full log path printed for a deeper read); the `state/.afk` flag; and one cheap alive/dead read of each task's recorded backend endpoint. - That liveness line is a fast presence check only, not a full state read - when you need a crew's actual current state (a run-step, not just "is the pane there"), read it with `bin/fm-crew-state.sh ` as before; the digest deliberately skips that deeper, slower read for every task so it stays fast and bounded. -6. **Supervision operating instructions and next step** - after the wake queue and before context, the digest emits exactly one operating block for the detected primary harness. - The closing reminder points back to that emitted block and preserves only the lock, afk, Relay, and read-once reminders. +4. **Supervision operating instructions** - after the wake queue and before both digests, the digest emits exactly one operating block for the detected primary harness, followed by the read-once contract that governs them. The script itself never starts supervision; the emitted harness protocol owns the exact wait or wake mechanism. +5. **Fleet-state digest** - after that read-once contract and ahead of the context digest, the compact backlog listing owned by `bin/fm-session-start.sh`; every `state/.meta`; a bounded tail of each task's `state/.status` (labeled as wake-EVENT history, not current state, with the full log path printed for a deeper read); the `state/.afk` flag; and one cheap alive/dead read of each task's recorded backend endpoint. + That liveness line is a fast presence check only, not a full state read - when you need a crew's actual current state (a run-step, not just "is the pane there"), read it with `bin/fm-crew-state.sh ` as before; the digest deliberately skips that deeper, slower read for every task so it stays fast and bounded. +6. **Network checks** - after the fleet-state digest, the deferred stage's result, or an explicit statement of what it has not confirmed yet. + A read-only session runs no network checks at all and says so. +7. **Context digest and next step** - last of the bulk sections, the full contents of `data/projects.md`, `data/secondmates.md`, `data/captain.md`, `data/captain-shared.md`, and `data/learnings.md`, each clearly delimited, followed by the closing reminder. + A file that does not exist prints an explicit `ABSENT` marker, never confused with an empty-but-present file: absence is meaningful (`captain.md` absent means use the firstmate repo's built-in defaults, `projects.md` absent means rebuild it from the clones under `projects/`, etc.). + The closing reminder points back to the emitted supervision block and preserves only the lock, afk, Relay, and read-once reminders. Bootstrap detects first, asks for consent, and installs only after the captain approves in the current session. Do not dispatch until the required tools are present and GitHub authentication is good. @@ -281,6 +288,7 @@ After spawning, confirm the worker is processing the brief, handle any trust dia A persistent secondmate is recorded in the secondmate registry and runtime state, never as a backlog work item. Steer a worker with short single-line messages through fail-closed `fm-send`; put long instructions in a file. +When a steer answers an open keyed decision or blocker, pass `fm-send`'s `--resolve-key` so the answer itself closes that decision record at answer time, identically for local and remote workers (contract: `bin/fm-send.sh` header). A secondmate's routed reply returns through status or a document pointer, not by firstmate peeking into its chat. For the parent-owned correlation, recovery, and escalation contract on marked secondmate requests, see `bin/fm-pending-reply-lib.sh`. Supervise all live work under section 8. @@ -324,7 +332,7 @@ Apart from that single supported abort, do not hand-edit, commit, restart, or st Once ownership is settled, validate exactly once against that final head so no obsolete or intermediate head is ever treated as authoritative. An ask-user finding returns as `needs-decision`; firstmate decides only when the configured authority permits, otherwise escalates to the captain. -Send the same worker one exact decision naming the decision key, step, action, affected finding IDs, instructions where needed, and exact response command. +Send the same worker one exact decision naming the decision key, step, action, affected finding IDs, instructions where needed, and exact response command, passing `--resolve-key` so the worker's open decision record closes at answer time. Require the matching `resolved` event, forbid `--yes`, and require the worker to process every synchronous return until completion or a genuinely new escalation. Resume fleet supervision immediately after the decision lands. @@ -500,11 +508,12 @@ It performs guarded fast-forward updates of firstmate and registered secondmate These skills are not captain-invocable; load them only at their precise triggers. -- `bootstrap-diagnostics` - load whenever the session-start digest's bootstrap section prints an actionable diagnostic line (`MISSING:`, `MISSING_MANUAL:`, `BACKEND_INVALID:`, `NEEDS_GH_AUTH`, `TANGLE:`, `STARTUP_MEMORY_BUDGET:`, `CREW_DISPATCH: invalid`, `FLEET_SYNC:`, `PR_CHECK_MIGRATION:`, `SECONDMATE_SYNC:`, `SECONDMATE_LIVENESS:`, `SECONDMATE_HANDOFF:`, `NUDGE_SECONDMATES:`, or `FMX:`); silence and `BOOTSTRAP_INFO:` need no load. +- `bootstrap-diagnostics` - load whenever the session-start digest's bootstrap or network-checks section prints an actionable diagnostic line (`MISSING:`, `MISSING_MANUAL:`, `BACKEND_INVALID:`, `NEEDS_GH_AUTH`, `TANGLE:`, `STARTUP_MEMORY_BUDGET:`, `CREW_DISPATCH: invalid`, `FLEET_SYNC:`, `NETWORK_CHECKS:`, `PR_CHECK_MIGRATION:`, `SECONDMATE_SYNC:`, `SECONDMATE_LIVENESS:`, `SECONDMATE_HANDOFF:`, `NUDGE_SECONDMATES:`, or `FMX:`); silence and `BOOTSTRAP_INFO:` need no load. - `diagnostic-reasoning` - load before scoping a reported bug and before acting on a diagnostic report. - `ask-user-authority` - load before deciding any ask-user finding, regardless of the project's `yolo` posture. - `quota-array-dispatch` - load before choosing among a matched crew-dispatch profile array from current quota-axi output. - `harness-adapters` - load before spawning or recovering a crewmate or secondmate, handling a trust dialog, sending a harness-specific skill invocation, interrupting or exiting an agent, resuming an exited agent, or verifying a new harness adapter. +- `maintenance-agent-grading` - load after a recurring maintenance-agent PR resolves and before recording its final grade or tearing down its task, and before reviewing grades or proposing a reusable-brief refinement. - `firstmate-orca` - load before switching to Orca, spawning or supervising Orca-backed work, smoke-testing Orca backend behavior, debugging Orca task state, or reconciling Orca-backed task metadata. - `project-management` - load before adding, creating, removing, or initializing a project. Cloning or registering a project is add intake and uses the same trigger. diff --git a/bin/fm-agent-grade.sh b/bin/fm-agent-grade.sh new file mode 100755 index 00000000000..ef4c40caf5e --- /dev/null +++ b/bin/fm-agent-grade.sh @@ -0,0 +1,323 @@ +#!/usr/bin/env bash +# fm-agent-grade.sh - record and report recurring maintenance-agent outcomes. +# +# The captain-private append-only ledger lives at: +# $FM_HOME/data/maintenance-agent-grades/events.jsonl +# FM_DATA_OVERRIDE replaces the data directory for tests and isolated operators. +# +# Each JSONL row has exactly these fields: +# agent, task_id, pr_url, outcome, false_positive_labels, timestamp, note +# Agent, task, and false-positive labels are privacy-safe slugs. +# `pr_url` is empty or an HTTPS URL, `timestamp` is UTC to whole seconds, and +# `outcome` is one of merged_clean, merged_changed, rejected, closed, or pending. +# One final row is allowed per agent/task pair; duplicate record attempts refuse. +# Keep raw prompts, private source text, and diffs out of labels and notes. +# +# Report rates are intentionally simple and show their denominators: +# merge rate = merged_clean + merged_changed / all runs +# changed-on-merge rate = merged_changed / merged runs +# rejected rate = rejected / all runs +# false-positive rate = runs with one or more false-positive labels / all runs +# +# Usage: +# fm-agent-grade.sh record [--pr ] [--outcome ] +# [--false-positive