Skip to content

feat(personal): first mate 1.5.0 with a kill-safe detector, loop rules and references - #12

Merged
mogul merged 5 commits into
mainfrom
feat/first-mate-1.5.0
Nov 20, 2026
Merged

mogul merged 5 commits into
mainfrom
feat/first-mate-1.5.0

Conversation

@mogul

@mogul mogul commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

paseo-first-mate 1.4.0 -> 1.5.0
├── detector and wait loop: a missed or killed loop can no longer lose a change silently
│   ├── two-phase save (--peek / --commit), digest and txn bound
│   ├── status shows last-run age and warns when stale; cap expiry prints one line; cap 60 -> 480 min
│   └── merge-state collapse, auto-prune, current head and stale-review marker, absolute FIRST_MATE_DIR
├── SKILL.md: Loop Rule (read first), heartbeat backstop as default, Secrets, Reporting, permission-prompt handling
├── references/: delegation prompt, status doc, handoff and successor, host commands, stacking, cross-PR checklist
└── tests: offline detector and wait-loop suite (fake gh and paseo on PATH), wired into personal/scripts/verify

The input was the lessons from one two-day coordination session (about 28 PRs, up to 4 delegated agents, a wait loop, a heartbeat, a coordinator handoff). The two worst failures: the loop ended (on a change, then at its cap) and was not restarted, so reviews sat unseen for about three hours; and a loop killed between "report saved" and "report delivered" lost the change for good.

AI-assisted change: written with OpenCode (model claude-sonnet-5.5). Human review required.

What changed

Assets (assets/first-mate-check.py, assets/first-mate-wait.sh; start from the locally patched copies, reviewed and corrected)

Area Change
Two-phase save --peek prints and stages a pending save bound to a digest of the saved state and to the loop's FIRST_MATE_TXN; --commit applies it only if both still match. The loop runs peek, prints, then commit. A kill in between yields a duplicate report, never a miss.
Locking The state lock covers only local file work (the patched version held it across the network calls, which blocked --commit, add, and --show). A separate report lock makes concurrent one-step runs take turns. Writes are atomic with fsync; --reset clears pending too. Without fcntl (Windows) it runs unserialized.
Silent end made visible status prints last-run=<age> ago and a WARNING when older than twice the interval (a loop younger than two intervals does not warn). Cap expiry (exit 3) prints one line. A detector that exits non-zero with no output is reported instead of looping quietly. Default cap 60 -> 480 minutes (8 hours): sessions ran 10 hours; the skill recommends 480 to 600.
Own-login filter Option `selffilter on
Merge state Collapsed to conflict, behind, ok. UNKNOWN is re-queried 3 times, then keeps the previous value (the patched version could report a flip to ok).
Prune Merged and closed PRs and closed issues are pruned when the report showing them is committed, and the report says PRUNED .... autoprune off and the manual prune remain. Matching now parses the state field instead of searching for " CLOSED " anywhere in the line.
Report content Current head on every PR line; stale-review=[...] when a reviewer's latest approval or change request was on an older head.
FIRST_MATE_DIR Resolved to an absolute path. When a relative value does not exist and the script itself sits in a directory with that tail, that directory is used, so running from inside tmp/ no longer creates tmp/tmp.

SKILL.md (version 1.5.0 with changelog entry; description unchanged, scope did not change): a read-first Loop Rule scoped to the confirmed coordinator; hourly heartbeat backstop as part of the default procedure (with the prompt shape and path placeholders); Secrets section; Reporting section; permission-prompt handling (deny with a message; archive a stuck idle agent; standing-policy line); credential-limit note; successor pointer; troubleshooting rows. The output-contract sections (Summary, Critical Path, Actions, Verification) are intact.

references/ (linked from SKILL.md and listed in personal/spec.yaml): delegation-prompt.md, status-doc.md, handoff-and-successor.md, host-commands.md, stacking.md (points to github/gh-stack's own skill instead of repeating it), cross-pr-checklist.md.

Kit: personal/spec.yaml (6 new files), personal/README.md, personal/TROUBLESHOOTING.md, personal/scripts/verify (new section 4c), personal/scripts/test-wait-lock (cap-expiry now expects one line), Makefile lint paths.

Verification

All run in this sandbox (Linux, Python 3.14.4 and 3.9.25, bash 5.3 and a bash 3.2.57 musl build).

Command Result
python3 personal/scripts/test-first-mate-detector.py (34 tests) OK on Python 3.14 and 3.9; also OK with FIRST_MATE_TEST_BASH set to bash 3.2.57
Same suite against the 1.4.0 assets (FIRST_MATE_ASSETS) red: 19 failures and 1 error out of 34
Same suite against the locally patched assets red: 14 failures (missing: txn binding, default-off filter, ghost author, previous-value on UNKNOWN, stray tmp/tmp, auto-prune, stale marker, cap line, cap default, status age)
Same suite against the new assets green, repeated 4 times (one timing flake in the stale-status test was fixed)
bash personal/scripts/test-wait-lock 27 passed, 0 failed
bash personal/scripts/verify (also via python scripts/run-kit-tests.py personal) 31 passed, 0 failed (acq kit validate skipped: acq not installed)
make lint validate PATTERNS=.patterns (pinned patterns checkout, hash-locked venv) ruff check and format clean; all 6 kits valid
python -m pytest scripts/tests -q 69 passed
shellcheck --severity=warning on the wait script clean
pip_audit on requirements-dev.lock no known vulnerabilities
scan_unsafe_shell.py on the skill directory; gitleaks git . 0 findings
gitleaks dir on claude-code, codex, antigravity, scripts clean

Fixtures: gh and paseo are fake executables on PATH inside a temp directory. The fake gh answers pr view (with a scripted mergeStateStatus sequence), api user, api .../pulls/N/comments, and api .../commits/BRANCH, and fails on anything else, including auth and token calls (the tests assert none are made and that a fake GITHUB_TOKEN value never appears in any output). Covered: repeat-peek identical; peek without commit consumes nothing; state moved between peek and commit drops the commit; txn mismatch; kill before commit loses nothing; concurrent one-step runs report once; own-login filter on and off; merge-state flicker; UNKNOWN retry and never-settles; auto-prune and its switch; stale-review marker; absolute directory; status age and warning; cap-expiry line; default cap.

Not run or not verified

  • The new detector has never run against real GitHub or a real Paseo daemon. Fixtures reproduce the gh pr view --json fields the code uses; real output may differ at the edges (for example how reviews[].commit or submittedAt appear for old reviews).
  • make test kit suites for opencode-go-provider and pi-coding-agent (npm install needed), the other kits' scripts, pip_audit of the claude-code lock, and acq kit validate were not run. The first two do not touch this change.
  • gitleaks dir personal reports 2 generic-api-key hits in personal/vendor/diagram-design.json, identical on the base commit (a provenance hash false positive that CI handles via .gitleaksignore/its own scope). gitleaks git . is clean.
  • CI on the PR has not run.
  • The skill text about permission-prompt shapes and env -u is from one session on one Paseo and gh-stack version and is labelled as such. The label re-parenting via paseo_update_agent is marked untested.

Adversarial review (read-only, blocker-only subagent, two rounds): round 1 found four SKILL.md blockers (loop rule claimed a silent cap exit; not scoped to the confirmed coordinator; heartbeat still described as an alternative; heartbeat prompt ignored the stale-run WARNING). All fixed; round 2: no blockers. It found no blockers in the detector for kill, crash or concurrency, secrets, or Python 3.9 and bash 3.2 compatibility (the 3.2 point was reviewed statically; I additionally ran the suite under bash 3.2.57).

Not adopted, and why

  • Names of the session's repos, accounts, reviewers, and PR, ADR, bats, workspace and agent numbers: session-specific. Examples became placeholders or generic phrases ("sequence numbers").
  • Model advice (which model at which reasoning level): provider-specific; section 5 already covers model choice.
  • Reading review requests or requesting reviewers inside the detector: only the REST fallback is documented.
  • Suppressing repeated identical ERROR lines: not shown to be a failure and would add state.
  • Making the heartbeat an alternative to the loop: kept as an always-on backstop.
  • Windows-agent specifics beyond the generic recipe pitfalls (git clone --config, forced re-materialization, signing, PATH narrowing).

Merge Danger

Door: two-way. Revert the commits; sandboxes pick up the kit by pinned SHA, so existing sandboxes are unaffected until re-pinned.

Blast Radius: personal kit only, the First Mate skill and its scripts. Risk is concentrated in the detector changes (two-phase save, locking, prune): a bug could make the loop miss or repeat a change. The design prefers duplicates to misses, and a kill between report and commit is covered by tests, but real-GitHub behavior is unverified. State saved by 1.4.0 holds the old merge wording, so run first-mate-check.py --reset once after upgrading (or expect one CHANGED per PR); this is in Troubleshooting. first-mate-wait.sh status now prints extra lines after the first; callers must parse only the first word, as the skill already says.

No new network allowances, startup commands, or credentials. The scripts call only gh and paseo and never read or print a token.

Rollback

Revert the merge, re-pin the previous kit SHA, recreate the sandbox. For a local copy in a coordinator's tmp/, copy the 1.4.0 scripts back and run first-mate-check.py --reset.

AI-assistance disclosure: this change was written by an AI coding agent (OpenCode, claude-sonnet-5.5) and adversarially reviewed by a second agent; it needs human review before merge.

…and loud

Two-phase save (--peek/--commit) bound to a state digest and a loop txn,
flock-serialized local file work, optional own-login filter (default off),
merge-state collapse with UNKNOWN retry, auto-prune, current head and stale
review marker, absolute FIRST_MATE_DIR, last-run age in status, a cap-expiry
line, and an 8 hour default cap.
Fake gh and paseo on PATH; wired into personal/scripts/verify and the ruff
lint paths. test-wait-lock now expects the cap-expiry line.
…irst mate 1.5.0

Bump the skill to 1.5.0 with a changelog entry. SKILL.md gains a read-first
loop rule, the heartbeat backstop as default, a Secrets section, reporting
rules, permission-prompt handling, and troubleshooting rows. Longer procedures
(delegation prompt, status doc, handoff and successor, host commands,
stacking, cross-PR checklist) live in references/ and are listed in spec.yaml.
…eartbeat watch for stale runs

Reviewer findings: the loop rule said the loop stops silently at its cap, was
not scoped to the confirmed coordinator, the heartbeat was still described as an
alternative, and the heartbeat prompt ignored the stale-run WARNING.
@mogul
mogul merged commit c394ef8 into main Nov 20, 2026
10 checks passed
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