Skip to content

feat: add durable captain decision holds - #593

Merged
kunchenguid merged 9 commits into
mainfrom
fm/fm-decision-hold-lifecycle-k9
Jul 16, 2026
Merged

kunchenguid merged 9 commits into
mainfrom
fm/fm-decision-hold-lifecycle-k9

Conversation

@kunchenguid

@kunchenguid kunchenguid commented Jul 15, 2026 •

Copy link
Copy Markdown
Owner

Intent

The developer wanted to fix firstmate bearings so registered secondmates are summarized from authoritative structured state in each secondmate home rather than stale append-only parent status events, while preserving a complete standalone four-section report contract. They required an end-to-end reproduction of a stale parent event case, regression coverage for structured authority, externally held work, captain decisions, invalid or timed-out homes, bounded counts, zero-network default behavior, live-PR opt-in compatibility, and repeated reports retaining the same current recent-completions baseline. They also required loading and preserving the firstmate coding and bearings skills as contract owners, keeping AGENTS.md concise, updating script headers and help for mechanics, adding colocated tests, using plain dashes and one sentence per Markdown line, and avoiding agent co-author metadata. During review they explicitly approved fixes to keep parent decisions and terminal tails as untrusted contradiction evidence only, correctly classify parked/failed/done and inconsistent child state, surface registry-level unavailability, bound and timeout registry parsing with truncation metadata, avoid false unregistered labels when registry completeness is unknown, and treat unkeyed legacy evidence as inconclusive unless reliably matched. They wanted the no-mistakes pipeline driven through review, tests, lint, docs, push, PR, and green CI without using --yes, then report the final PR URL.

What Changed

  • Added fm-decision-hold.sh and a documented durable lifecycle for recording, verifying, retrying, and completing captain decision holds.
  • Wired structured decision holds into bearings, fleet snapshots, briefs, classification, and teardown so unresolved holds are tracked from durable backlog state.
  • Updated agent guidance, Orca/scout documentation, CI setup, and regression tests for decision inventory, terminal reconciliation, and snapshot/report behavior.

Risk Assessment

⚠️ Medium: The durable-hold lifecycle is mostly well-bounded, but the Bearings projection may now hide live main-home captain decisions unless the new structured-only behavior is explicitly intended.

Testing

The configured full baseline was already green; I reran the focused bearings, decision-hold lifecycle, fleet snapshot view, and brief tests, then manually exercised the CLI against a stale parent secondmate event with authoritative structured secondmate-home state and captured JSON/TOON evidence showing no default network access and the expected Captain's Call, Charted Next, and Recently Landed projection.

Evidence: Manual bearings structured-authority summary

Manual bearings structured-authority fixture passed. It shows stale parent event absent from in_flight, authoritative secondmate home as captain_decision, captain hold, legal gate, phase7 landed record, local-only PR mode, and an empty net log.

Manual bearings structured-authority fixture passed.
Evidence JSON: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KXMCCRPBVVP0ADE5WJ3NXGDN/bearings-structured-authority.json
Evidence TOON: /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KXMCCRPBVVP0ADE5WJ3NXGDN/bearings-structured-authority.toon
Checks: stale parent event absent from in_flight; authoritative secondmate home is captain_decision; captain hold, legal gate, and phase7 landed record are present; default PR mode is local-only; net log is empty.
{
  "prs": "not_requested (run: /bearings include PRs)",
  "in_flight": [],
  "secondmates": [
    {
      "id": "domain-alpha",
      "state": "captain_decision",
      "doing": "Choose release shape",
      "provenance": "structured-home",
      "freshness": "fresh",
      "age_seconds": 0,
      "contradiction": true,
      "reason": "-"
    }
  ],
  "decisions_open": [
    {
      "id": "domain-alpha/alpha-captain-release",
      "key": "alpha-captain-release",
      "verb": "captain-hold",
      "summary": "Choose release shape: captain release choice pending",
      "owner": "domain-alpha"
    }
  ],
  "gates": [
    {
      "id": "legal-release",
      "title": "Release approval",
      "blocked_by": "external-legal",
      "reason": "external legal dependency",
      "owner": "domain-alpha"
    }
  ],
  "landed": [
    {
      "id": "phase7",
      "what": "Sample rollout Phase 7",
      "artifact": "https://github.com/acme/sample/pull/7",
      "owner": "domain-alpha"
    },
    {
      "id": "main-landed",
      "what": "Parent-home landed item",
      "artifact": "https://github.com/kunchenguid/firstmate/pull/70",
      "owner": "(main)"
    }
  ]
}
Evidence: Manual bearings JSON output
{
  "schema": "fm-bearings.v1",
  "home": "manual-bearings-authority/parent-home",
  "generated": "2026-07-15T19:00:00Z",
  "prs": "not_requested (run: /bearings include PRs)",
  "in_flight": [],
  "secondmates": [
    {
      "id": "domain-alpha",
      "state": "captain_decision",
      "doing": "Choose release shape",
      "provenance": "structured-home",
      "freshness": "fresh",
      "age_seconds": 0,
      "contradiction": true,
      "reason": "-"
    }
  ],
  "decisions_open": [
    {
      "id": "domain-alpha/alpha-captain-release",
      "key": "alpha-captain-release",
      "verb": "captain-hold",
      "summary": "Choose release shape: captain release choice pending",
      "owner": "domain-alpha"
    }
  ],
  "landed": [
    {
      "id": "phase7",
      "what": "Sample rollout Phase 7",
      "artifact": "https://github.com/acme/sample/pull/7",
      "owner": "domain-alpha"
    },
    {
      "id": "main-landed",
      "what": "Parent-home landed item",
      "artifact": "https://github.com/kunchenguid/firstmate/pull/70",
      "owner": "(main)"
    }
  ],
  "gates": [
    {
      "id": "legal-release",
      "title": "Release approval",
      "blocked_by": "external-legal",
      "reason": "external legal dependency",
      "owner": "domain-alpha"
    }
  ],
  "reports": [],
  "recorded_prs": [],
  "omitted": [
    {
      "surface": "backlog item bodies",
      "reveal": "--fields bodies"
    },
    {
      "surface": "task paths",
      "reveal": "--fields paths"
    },
    {
      "surface": "watch/steer actions",
      "reveal": "--fields actions"
    },
    {
      "surface": "healthy endpoint detail",
      "reveal": "--fields endpoints"
    },
    {
      "surface": "full scout-report inventory",
      "reveal": "--all-reports"
    },
    {
      "surface": "superseded queued items",
      "reveal": "--all-queued"
    },
    {
      "surface": "live PR discovery + checks",
      "reveal": "--include-prs"
    }
  ]
}
Evidence: Manual bearings TOON output
schema: fm-bearings.v1
home: manual-bearings-authority/parent-home
generated: "2026-07-15T19:00:00Z"
prs: "not_requested (run: /bearings include PRs)"
in_flight: []
secondmates[1]{id,state,doing,provenance,freshness,age_seconds,contradiction,reason}:
  domain-alpha,captain_decision,Choose release shape,structured-home,fresh,0,true,"-"
decisions_open[1]{id,key,verb,summary,owner}:
  domain-alpha/alpha-captain-release,alpha-captain-release,captain-hold,"Choose release shape: captain release choice pending",domain-alpha
landed[2]{id,what,artifact,owner}:
  phase7,Sample rollout Phase 7,"https://github.com/acme/sample/pull/7",domain-alpha
  main-landed,Parent-home landed item,"https://github.com/kunchenguid/firstmate/pull/70",(main)
gates[1]{id,title,blocked_by,reason,owner}:
  legal-release,Release approval,external-legal,external legal dependency,domain-alpha
reports: []
recorded_prs: []
omitted[7]{surface,reveal}:
  backlog item bodies,"--fields bodies"
  task paths,"--fields paths"
  watch/steer actions,"--fields actions"
  healthy endpoint detail,"--fields endpoints"
  full scout-report inventory,"--all-reports"
  superseded queued items,"--all-queued"
  live PR discovery + checks,"--include-prs"

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ AGENTS.md - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Review** - 1 warning
  • ⚠️ bin/fm-decision-hold.sh:293 - complete/verify check the raw status_open_decisions fold, so a single-owner scout that logged needs-decision: and later done: is still treated as having an open default decision. The fleet snapshot already clears that stale status state for terminal scout/ship tasks, but this new teardown gate does not, so fm-decision-hold.sh complete <id> --none and later scout teardown can be refused for a completed report whose semantic inventory has no unresolved decision. Apply the same lifecycle reconciliation here, or otherwise ignore terminal stale status decisions for non-secondmate origins.

🔧 Fix: Reconcile terminal decision holds
1 warning still open:

  • ⚠️ bin/fm-bearings-snapshot.sh:360 - decisions_open is now built only from structured captain-hold backlog rows, so a live main-home crewmate that follows the existing brief and appends needs-decision: will no longer appear in Bearings' Captain's Call. That is intentional for untrusted secondmate parent/status evidence, but for ordinary direct reports the canonical snapshot still exposes .tasks[].hints.open_decisions, and without projecting those rows the captain can get an empty decision list while a task is parked waiting for them.
✅ **Test** - passed

✅ No issues found.

  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • Configured baseline already ran successfully before this validation: command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • bash tests/fm-bearings-snapshot.test.sh
  • bash tests/fm-decision-hold-lifecycle.test.sh
  • bash tests/fm-fleet-snapshot-view.test.sh
  • bash tests/fm-brief.test.sh
  • Manual evidence fixture under /var/folders/5x/4nqprlbx0518k3ybcb1sz6gr0000gn/T/no-mistakes-evidence/01KXMCCRPBVVP0ADE5WJ3NXGDN/manual-bearings-authority: ran bin/fm-bearings-snapshot.sh --json and default TOON against a parent stale secondmate event plus authoritative secondmate-home backlog, then asserted the JSON fields with jq and verified the default net log stayed empty.
  • Final cleanup/status checks: git status --short and find . -maxdepth 3 \( -name '.pytest_cache' -o -name 'node_modules' -o -name 'coverage' -o -name '.cache' -o -name 'tmp' -o -name '*.tmp' \) -print
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@kunchenguid
kunchenguid force-pushed the fm/fm-decision-hold-lifecycle-k9 branch from e7fe825 to d39703b Compare July 16, 2026 03:13
@kunchenguid
kunchenguid merged commit cd218f2 into main Jul 16, 2026
5 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-decision-hold-lifecycle-k9 branch July 16, 2026 03:26
Marl0nL added a commit to Marl0nL/firstmate that referenced this pull request Jul 16, 2026