Skip to content

fix(bin): route away-mode GitHub merges through the review ledger and stop phantom required-check holds - #36

Merged
twilwa merged 5 commits into
mainfrom
fm/fm-supervision-host-authority-fix
Oct 14, 2026
Merged

twilwa merged 5 commits into
mainfrom
fm/fm-supervision-host-authority-fix

Conversation

@twilwa

@twilwa twilwa commented Oct 13, 2026 •

Copy link
Copy Markdown
Owner

Intent

Asked on 2026-10-13: after the away session stalled the fleet twice, the captain accepted firstmate's recommendation to "let the scout on the away-mode stalls run now and ship its fix through firstmate's own pipeline" ("let's go with your strong recommendations, i trust you").

The scout report is data/fm-supervision-host-policy-holds/report.md in the firstmate home (read it in full first; it is the specification). Its finding: under the away record the supervision branch held every PR lacking an exact-model attestation instead of steering the worker to run the gate, sent every ask-user finding to the captain, held PR 218 after it was fully ready because the review snapshot invents a pending "required checks have not reported" check on a repo with no branch protection, and in the other direction merged PR 240 through bin/fm-pr-merge.sh without its exact-model attestation. The report's "Proposed change set" has four parts: A (snapshot reads the real required-check set via a shared reader in bin/fm-pr-lib.sh), B (while the away record exists bin/fm-pr-merge.sh refuses a GitHub merge without bin/fm-pr-review.sh merge's recorded ledger merge decision for the live head; release-hold refuses the branch actor), C (prompt and away-tail text naming MAIN's standing authority), D (matching one-line edits in the afk and pr-review-policy skills and docs/pi-supervision-branch.md).

What the report's proposed change set specifies, part by part:

A. The required-check reader in bin/fm-pr-merge.sh (github_urlencode_path_segment, github_branch_rules_unavailable_on_plan, github_read_required_contexts) moves into bin/fm-pr-lib.sh as fm_pr_github_* functions that take owner and repo as arguments; bin/fm-pr-merge.sh calls the library and its merge behaviour is unchanged. In bin/fm-pr-review-snapshot.sh, when gh pr checks --required prints "no required checks reported", the snapshot reads the base branch from the pull request (.base.ref) and calls the shared reader: if the read succeeds and the required set is empty it records no required checks ([]); if the set is non-empty or unreadable it keeps the existing pending "required checks have not reported" placeholder. One-time effect to name in the PR description: open review ledgers whose final-disposition digest includes the placeholder will show "final disposition ... not posted for the latest review state" on their next checkpoint until the final disposition is recorded again.

B. In bin/fm-pr-merge.sh, while the away-posture record exists, for a GitHub merge with a review ledger, the merge is refused unless the reviewed-head handoff (FM_PR_REVIEW_EXPECTED_HEAD) is set and the current ledger generation records merge_decision.decision == "merge" with verified_head equal to that head; bin/fm-pr-review.sh merge-decision writes that only after its ready check passes, so setting the environment variable by hand is not enough. Suggested refusal text: "while the away-posture record exists a GitHub merge goes through bin/fm-pr-review.sh merge, so the current review-ledger generation passes every gate for the live head". Attended behaviour and GitLab do not change. bin/fm-pr-review.sh release-hold refuses the supervision branch actor in every posture (fm_lease_forbid_branch with no away relocation), because away authority never releases a captain hold.

C. bin/fm-branch-prompt.sh: the captain-verdict line "a decision only the captain can make, including every ask-user finding from a validation gate" is qualified to the attended posture (away, only a finding the ask-user-authority policy escalates). In "Postures", after the line saying the record is the captain's away words, a block says MAIN's standing authority needs no words: away, do what MAIN does attended without asking the captain, through the same guarded scripts, whatever the words say or leave out - land a GitHub pull request whose current review-ledger generation passes every gate with bin/fm-pr-review.sh merge (a ledger hold, a task held for the captain, or an unresolved product, rights, spend, destructive, or security-sensitive decision still holds it); when the ledger lacks what the task's parked or finished worker can supply, steer that worker to supply it as routine steering (dispositions with evidence, the posted and recorded final disposition, or for high-stakes work a no-mistakes run on the current head at the policy's exact model with no init - if the repository is not already initialized it stops and reports - the rebase step skipped, no rebase or force-push, then the attestation, a done line, and a park, never a merge); decide each ask-user finding under the ask-user-authority policy and steer the worker with the decision, reporting verdict captain only for a finding that policy escalates, and treating a stop condition written into its own earlier steer as its checkpoint, not a captain instruction; the words add to this set and never subtract from it. The next sentence begins "Beyond that set, no script parses the words". The merge bullet says bin/fm-pr-review.sh merge is the GitHub merge entrypoint while away and bin/fm-pr-merge.sh refuses a GitHub merge under the record without that handoff's recorded ledger merge decision for the live head, remaining the direct GitLab entrypoint, while red or unreported-check merges stay refused away and --allow-red and --allow-missing stay refused under the record. The steering bullet says steering and lifecycle control stay the branch's as in any posture, and a run the words say to abort is aborted. "Never by analogy" becomes "beyond MAIN's standing authority, act only where the words plainly name the event and the action". The --resolve-key, hold-on-doubt, and never-set lines stay unchanged. The away wake tail in .pi/extensions/lib/fm-branch-dispatch.ts mirrors these rules: MAIN's standing authority needs no words (land a ledger-passing pull request through bin/fm-pr-review.sh merge, steer a parked worker to supply a missing gate, decide ask-user findings under the policy); beyond that act on the words only through the guarded scripts, with bin/fm-pr-merge.sh refusing a GitHub merge without that handoff; beyond standing authority, never by analogy, and hold on doubt. The prompt stays a pure function of tracked files.

D. .agents/skills/afk/SKILL.md: replace "any pull request green at its live head may merge (which one the words meant is the branch's reading)" with "a pull request whose review ledger passes every gate merges through bin/fm-pr-review.sh merge under standing authority, and a merge only the words could authorize is the branch's reading of them", and replace the away-merge sentence with "While the away-posture record exists, a GitHub pull request merges only through bin/fm-pr-review.sh merge, so its current ledger generation passes every gate; that merge is standing authority and needs no words, while a merge only the captain's words could authorize is the away session's reading of them and otherwise holds for the return." .agents/skills/pr-review-policy/SKILL.md gains: "While the away-posture record exists, every GitHub merge goes through bin/fm-pr-review.sh merge whatever the policy setting, and bin/fm-pr-merge.sh refuses one that did not." docs/pi-supervision-branch.md: the bin/fm-pr-merge.sh row adds that it refuses a GitHub merge lacking bin/fm-pr-review.sh merge's recorded ledger merge decision for the live head, a new bin/fm-pr-review.sh release-hold row says it is never relocated and refuses the branch actor in every posture, and "Verification" names the new merge and review tests.

Safety boundaries the report requires to hold after the change: no red merge and no merge with an unreported required check while away, with --allow-red and --allow-missing refused away; the snapshot records no required checks only when the shared reader proves the required set empty; captain holds stay (ledger holds refused by the ready check and the merge script, release-hold refuses the branch actor, captain-held tasks and unresolved human decisions still hold); no discards and no destructive or security-sensitive action, with the gate steer forbidding init, rebase, and force-push; the high-stakes exact-model attestation is script-enforced while away; local-only landing still waits for the captain; away authority dies at archive. Out of scope: changes to ask-user-authority, the supervision engine model, attended merge or ledger behaviour, the tracked review policy file, and GitLab.

What Changed

  • Required-check reader moved into a shared library; the snapshot now uses it. The GitHub required-check reader (URL-encoding, plan-gated rules detection, required-context read) moved from bin/fm-pr-merge.sh into bin/fm-pr-lib.sh as fm_pr_github_* functions that take owner and repo as arguments. Merge behavior is unchanged. When gh pr checks --required reports "no required checks reported", bin/fm-pr-review-snapshot.sh now reads the PR's .base.ref and checks it with the shared reader. It records no required checks only when that set is readable and empty. A non-empty or unreadable set still records the pending "required checks have not reported" placeholder. One-time effect: an open review ledger whose final-disposition digest includes the placeholder will show "final disposition ... not posted for the latest review state" on its next checkpoint, until the final disposition is recorded again.
  • Away-mode merge and hold-release are now enforced by the scripts.
    • While the away-posture record exists, bin/fm-pr-merge.sh refuses a GitHub merge with a review ledger unless both of these hold:
      • FM_PR_REVIEW_EXPECTED_HEAD is set.
      • The current ledger generation records merge_decision.decision == "merge" with verified_head equal to that head.
    • The refusal says to go through bin/fm-pr-review.sh merge.
    • Attended mode and GitLab merges are unchanged.
    • bin/fm-pr-review.sh release-hold now refuses the supervision branch actor in every posture (fm_lease_forbid_branch, never relocated). The bin/fm-lease-lib.sh role partition comments now list this case.
  • Away prompts, skills and docs describe MAIN's standing authority.
    • bin/fm-branch-prompt.sh and the away wake tail in .pi/extensions/lib/fm-branch-dispatch.ts now say that while away the branch acts under MAIN's standing authority without needing the captain's words. That authority covers:
      • initializing and arming a missing review ledger (bin/fm-pr-review.sh init / arm)
      • landing a ledger-passing PR through bin/fm-pr-review.sh merge
      • steering a parked worker to supply a missing gate: a no-mistakes run with no init, no rebase and no force-push, then park, never merge
      • deciding ask-user findings under the ask-user-authority policy, with verdict captain only for findings that policy escalates
    • Beyond that set the branch still acts only where the words plainly say so, never by analogy, and holds when in doubt.
    • The afk and pr-review-policy skills, AGENTS.md, docs/pi-supervision-branch.md, docs/architecture.md, docs/configuration.md, docs/scripts.md and bin/fm-afk-contract.sh comments were updated to match.
    • New tests in tests/fm-pr-merge.test.sh, tests/fm-pr-review.test.sh, tests/fm-branch-supervision.test.sh and tests/fm-supervision-host.test.sh cover the away merge refusal, release-hold refusal, snapshot required-check handling and prompt text. tests/fm-pi-branch-extension.test.sh assertions were updated for the new away-tail text.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The away-merge and release-hold gates both fail closed. The required-check reader moved into the library unchanged and now takes owner and repo as arguments, and the snapshot records no required checks only when that reader proves the set empty. The fix round matches the user's instruction exactly: a ledger-creation and arming item in both prompt surfaces, with no gate relaxed, and fm-pr-review.sh init and arm have no branch-actor guard, so the branch can actually run them.

Testing

All driven scenarios passed. Part A: required-check snapshot (live against real GitHub) - On this repo's own PR #36, whose base branch has no protection, the base snapshot invents a pending "required checks have not reported" check. The target snapshot records no required checks. - On a real cli/cli PR whose base branch requires 3 checks, the target keeps the pending placeholder. It also keeps it when the protection read is broken. Part B: away merge gate (lab FM_HOME with a real away record) - The branch actor initialized and armed a missing ledger. - Every GitHub merge attempt outside a passing bin/fm-pr-review.sh merge was refused with the specified text. That covers the direct call, a hand-set handoff, --allow-red, and a merge decision recorded for an earlier head. - fm-pr-review.sh merge refused the incomplete ledger. It named the missing checkpoint, dispositions, final disposition, and exact-model attestation. - release-hold refused the branch actor both away and attended. Main could still release the hold. - The read-only gh wrapper logged zero pr merge calls and no other mutating call. Part C: generated prompts (base vs target) - The diffs of the generated system prompt and away wake prompt show exactly the intended wording: standing authority, ledger init/arm, the merge handoff, the ask-user qualification, and "beyond standing authority". - The system prompt stays byte-identical across cwd and env. Targeted test files - The five relevant test files ran with 0 failures. fm-supervision-host was stopped at the background time limit after 69 passes, including the changed away-tail case. - On this host the tests needed the real node install dir first on PATH, because the mise node shim fails under the tests' fake HOME. This also fails at base, so it is not caused by this change. Not covered live - The positive away merge was not run against real GitHub, because that would merge a real PR. Only the stub-forge test covers it, so it is recorded as untested. - How a live model interprets the prompt was not tested. - The Part D skill and doc edits have no runtime surface. - There is no UI, so there are no screenshots.

  • Live validation: ✅ go - 8 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Review snapshot of a PR whose base branch requires no checks records no required checks (PR 218 stall) ✅ pass live scenario-A-snapshot-unprotected.txt: on real #36, base .checks=[placeholder PENDING], target .checks=[]
Adversarial: a base that does require checks, or whose required set is unreadable, keeps the pending required-check placeholder ✅ pass live scenario-A-snapshot-required-set-adversarial.txt: real cli/cli#14679 (trunk requires 3 checks) with gh pr checks forced ambiguous, and with the branch read returning 502; both keep one pending 'requir…
While away, the branch actor can initialize and arm a missing review ledger ✅ pass live scenario-B-away-merge-gate-lab.txt: FM_SUPERVISION_ACTOR=branch fm-pr-review.sh init -> 'initialized ... risk=high', arm -> 'armed', rc=0
While away, a direct bin/fm-pr-merge.sh GitHub merge (no handoff, a hand-set handoff, or a decision for another head) is refused and nothing merges (PR 240 path) ✅ pass live scenario-B-away-merge-gate-lab.txt B1/B2/B5: rc=2 with 'while the away-posture record exists a GitHub merge goes through bin/fm-pr-review.sh merge ...; nothing was merged'; gh call log shows 0 pr merg…
While away, --allow-red is refused under the record ✅ pass live scenario-B-away-merge-gate-lab.txt B3: 'error: --allow-red is attended-only; while the away-posture record exists the green check is absolute' rc=2
While away, bin/fm-pr-review.sh merge refuses a ledger missing dispositions, final disposition, or the exact-model attestation ✅ pass live scenario-B-away-merge-gate-lab.txt B4: four 'review gate:' refusals incl. 'high-stakes work lacks a no-mistakes attestation for the configured exact model', rc=1, merge_decision stays null
While away, bin/fm-pr-review.sh merge lands a ledger that passes every gate at its reviewed head ⏸️ untested no The prior payload did not establish a live result for this scenario. The only coverage was the stub-forge test in bash tests/fm-pr-merge.test.sh, which is not live. A live success would merge a real…
release-hold refuses the supervision branch actor in both postures, and main can still release ✅ pass live scenario-B-away-merge-gate-lab.txt C1 (away) and C2 (after archive): 'review hold release (fm-pr-review release-hold) refused' rc=6; C3 main 'hold-released' rc=0; B6 attended merge refused by the stil…
Generated branch system prompt and away wake prompt carry MAIN's standing authority (ledger init/arm, ledger-passing merge, steer for missing gate, ask-user under policy) and stay a pure function of t… ✅ pass live scenario-C-branch-system-prompt.diff and scenario-C-away-wake-prompt.diff (generated at base vs target from the real generators, wake prompt using the lab's real away readback); target prompt byte-ide…
A live supervision agent, given the away prompt, actually merges a ledger-passing PR and steers instead of holding ⏸️ untested no This tests how a model interprets the prompt, which is non-deterministic. The repo's test-quality rule assigns that to development-time evaluation, not gate validation. Driving it would also need a la…
Evidence: Snapshot on an unprotected real base: base invents a pending required check, target records none

Source: Snapshot on an unprotected real base: base invents a pending required check, target records none

\### Scenario A - live review snapshot against real GitHub (read-only)
$ gh pr checks https://github.com/twilwa/firstmate/pull/36 --required
no required checks reported on the 'fm/fm-supervision-host-authority-fix' branch

[base] fm-pr-review-snapshot.sh twilwa/firstmate#36 rc=0
[base] required-check placeholder rows: [{"name":"required checks have not reported","state":"PENDING","bucket":"pending","url":null,"status":"PENDING","conclusion":"pending","required":true}]
[base] .checks = [{"name":"required checks have not reported","status":"PENDING"}]
[target] fm-pr-review-snapshot.sh twilwa/firstmate#36 rc=0
[target] required-check placeholder rows: []
[target] .checks = []
Evidence: Snapshot adversarial: real cli/cli base requiring checks keeps the placeholder (also when the required set is unreadable)

Source: Snapshot adversarial: real cli/cli base requiring checks keeps the placeholder (also when the required set is unreadable)

\### Scenario A adversarial - real cli/cli PR (trunk requires 3 checks); only 'gh pr checks' is forced to print the ambiguous message
PR: https://github.com/cli/cli/pull/14679
[target] rc=0
[target] .checks status!=COMPLETED = [{"name":"required checks have not reported","status":"PENDING","required":true}]

\### Same PR, branch-protection read made unreadable (HTTP 502) -> required set unreadable
[target] rc=0
[target] .checks status!=COMPLETED = [{"name":"required checks have not reported","status":"PENDING","required":true}]
Evidence: Lab transcript: away entry, branch ledger init/arm, merge refusals B1-B6, release-hold partition C1-C3, gh call log with zero merges

Source: Lab transcript: away entry, branch ledger init/arm, merge refusals B1-B6, release-hold partition C1-C3, gh call log with zero merges

\### Lab FM_HOME=/tmp/fm-lab.5KWVaH (bin/fm-lab-home.sh create); gh = read-only pass-through to real GitHub, mutating calls BLOCKED
\### PR under test: https://github.com/twilwa/firstmate/pull/36 (live head 214f840f3095a226a156207232c781b435c61f44)

$ bin/fm-afk-contract.sh enter --words "keep the lanes running"   (captain enters away)
Away posture recorded at 2026-10-14T12:56:00Z: hold-for-return only. No phone channel is configured; anything that needs you waits for your return. Your away instructions are recorded verbatim; the away session will carry them out where it can, and anything it is unsure of, or that needs you, waits for your return. Destructive, irreversible, and security-sensitive actions are never pre-authorizable, whatever the words say. Expected return: not given. Spend cap: 4 concurrent workers.
Away posture (recorded):
  entered: 2026-10-14T12:56:00Z
  expected return: not given
  spend cap: 4 concurrent workers
  reach: hold-for-return only. No phone channel is configured; anything that needs you waits for your return.
  your words (verbatim):
    keep the lanes running
rc=0

$ FM_SUPERVISION_ACTOR=branch bin/fm-pr-review.sh init task-x1 https://github.com/twilwa/firstmate/pull/36   (standing authority: branch initializes the missing ledger)
initialized: https://github.com/twilwa/firstmate/pull/36 head=214f840f3095a226a156207232c781b435c61f44 risk=high checkpoint_due=1791983168
rc=0

$ FM_SUPERVISION_ACTOR=branch bin/fm-pr-review.sh arm
armed: state/review-policy.check.sh
rc=0

ledger files: github--twilwa--firstmate--36.json

===== B1: branch actor calls bin/fm-pr-merge.sh directly while away (no handoff) =====

$ env FM_SUPERVISION_ACTOR=branch /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-merge.sh task-x1 https://github.com/twilwa/firstmate/pull/36
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
error: while the away-posture record exists a GitHub merge goes through bin/fm-pr-review.sh merge, so the current review-ledger generation passes every gate for the live head; nothing was merged
rc=2

===== B2: same, with the reviewed-head handoff set by hand to the live head =====

$ env FM_SUPERVISION_ACTOR=branch FM_PR_REVIEW_EXPECTED_HEAD=214f840f3095a226a156207232c781b435c61f44 /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-merge.sh task-x1 https://github.com/twilwa/firstmate/pull/36
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
error: while the away-posture record exists a GitHub merge goes through bin/fm-pr-review.sh merge, so the current review-ledger generation passes every gate for the live head; nothing was merged
rc=2

===== B3: same, with --allow-red under the record =====

$ env FM_SUPERVISION_ACTOR=branch /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-merge.sh task-x1 https://github.com/twilwa/firstmate/pull/36 --allow-red Behavior portable parallel 1
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
error: --allow-red is attended-only; while the away-posture record exists the green check is absolute
rc=2

===== B4: branch actor goes through bin/fm-pr-review.sh merge on a ledger that does NOT pass every gate =====

$ env FM_SUPERVISION_ACTOR=branch /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-review.sh merge task-x1 https://github.com/twilwa/firstmate/pull/36
review gate: ten-minute review checkpoint has not completed on this head
review gate: a reviewer comment, submitted review, or inline thread lacks a disposition with evidence
review gate: final disposition and evidence have not been posted for the latest review state on this head
review gate: high-stakes work lacks a no-mistakes attestation for the configured exact model
rc=1

ledger merge_decision now: null

----- every gh call the lab made during B1-B4 -----
      1   api --paginate repos/twilwa/firstmate/rules/branches/main
      1   api /repos/twilwa/firstmate/issues/36/comments?per_page=100 --paginate --slurp
      1   api /repos/twilwa/firstmate/pulls/36
      1   api /repos/twilwa/firstmate/pulls/36/files?per_page=100 --paginate --slurp
      1   api /repos/twilwa/firstmate/pulls/36/reviews?per_page=100 --paginate --slurp
      1   api graphql --input /tmp/fm-pr-review-snapshot.VSI05U/graphql-request.json
      1   api repos/twilwa/firstmate/branches/main
      1   api user
      1   pr checks https://github.com/twilwa/firstmate/pull/36 --required --json name,state,bucket,link
      1   pr view https://github.com/twilwa/firstmate/pull/36 --json headRefOid -q .headRefOid
      1   pr view https://github.com/twilwa/firstmate/pull/36 --json headRefOid,statusCheckRollup
pr merge attempts: 0

===== B5: ledger records a merge decision for an EARLIER head (0000...), handoff names the live head =====

$ env FM_SUPERVISION_ACTOR=branch FM_PR_REVIEW_EXPECTED_HEAD=214f840f3095a226a156207232c781b435c61f44 /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-merge.sh task-x1 https://github.com/twilwa/firstmate/pull/36
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
note: PR merge (fm-pr-merge) proceeds for the supervision branch under the away-posture record: main is parked and its standing authority is relocated; this script's own gate still applies (docs/pi-supervision-branch.md "Postures")
error: while the away-posture record exists a GitHub merge goes through bin/fm-pr-review.sh merge, so the current review-ledger generation passes every gate for the live head; nothing was merged
rc=2
pr merge attempts: 0

===== C1: release-hold - main records a captain hold, the branch tries to release it while AWAY =====

$ /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-review.sh hold https://github.com/twilwa/firstmate/pull/36 214f840f3095a226a156207232c781b435c61f44 captain must decide the rollout
held: https://github.com/twilwa/firstmate/pull/36 head=214f840f3095a226a156207232c781b435c61f44 reason=captain must decide the rollout
rc=0

$ env FM_SUPERVISION_ACTOR=branch /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-review.sh release-hold https://github.com/twilwa/firstmate/pull/36 214f840f3095a226a156207232c781b435c61f44 branch thinks it is fine
error: review hold release (fm-pr-review release-hold) refused - the supervision branch never performs this action; report the outcome and leave it to main (role partition: docs/pi-supervision-branch.md)
rc=6
(the hold stays unreleased: the ledger's hold_release was still null, and B6 below is refused by this same hold)

===== captain returns: bin/fm-afk-contract.sh archive =====

$ /tmp/fm-lab.5KWVaH/run.sh bin/fm-afk-contract.sh archive
/tmp/fm-lab.5KWVaH/state/afk-contracts/1791982560.afk-contract
rc=0

===== C2: branch tries release-hold ATTENDED =====

$ env FM_SUPERVISION_ACTOR=branch /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-review.sh release-hold https://github.com/twilwa/firstmate/pull/36 214f840f3095a226a156207232c781b435c61f44 branch thinks it is fine
error: review hold release (fm-pr-review release-hold) refused - the supervision branch never performs this action; report the outcome and leave it to main (role partition: docs/pi-supervision-branch.md)
rc=6

===== B6 attended contrast: main calls bin/fm-pr-merge.sh directly (no handoff) - away gate no longer applies =====

$ /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-merge.sh task-x1 https://github.com/twilwa/firstmate/pull/36
error: GitHub merge refused: the review ledger holds this pull request: captain must decide the rollout; record the human decision with bin/fm-pr-review.sh release-hold before merging
rc=2

===== C3: main releases the hold with evidence (attended, MAIN's action) =====

$ /tmp/fm-lab.5KWVaH/run.sh bin/fm-pr-review.sh release-hold https://github.com/twilwa/firstmate/pull/36 214f840f3095a226a156207232c781b435c61f44 captain approved the rollout in chat
hold-released: https://github.com/twilwa/firstmate/pull/36 head=214f840f3095a226a156207232c781b435c61f44 evidence=captain approved the rollout in chat
rc=0

----- gh calls during B5-C3 -----
pr merge attempts: 0
Evidence: Lab review ledger final state (no merge decision recorded; hold released only by main)

Source: Lab review ledger final state (no merge decision recorded; hold released only by main)

{
  "task": "task-x1",
  "url": "https://github.com/twilwa/firstmate/pull/36",
  "current_head": "214f840f3095a226a156207232c781b435c61f44",
  "generation": {
    "head": "214f840f3095a226a156207232c781b435c61f44",
    "risk": {
      "level": "high",
      "reason": "broad change: 20 files and 832 changed lines"
    },
    "merge_decision": null,
    "final_disposition": null,
    "attestations": [],
    "hold": null,
    "hold_release": {
      "evidence": "captain approved the rollout in chat",
      "released_at": "2026-10-14T12:56:54Z"
    }
  }
}
Evidence: Generated branch system prompt diff, base vs target

Source: Generated branch system prompt diff, base vs target

\### Generated supervision-branch system prompt (bin/fm-branch-prompt.sh), base 2e07fc7 vs target 051aff9
--- base/branch-system-prompt
+++ target/branch-system-prompt
@@ -51,7 +51,7 @@
 When in doubt, render.
 Also report verdict captain for:
 - work ready for review - include the PR's full https:// URL when the task's ready status or `pr=` metadata holds one, otherwise only the identifier you actually have;
-- a decision only the captain can make, including every ask-user finding from a validation gate;
+- a decision only the captain can make, including every ask-user finding from a validation gate while attended (away, only a finding the ask-user-authority policy escalates);
 - a real blocker or failure after the playbook is exhausted;
 - a needed credential or login;
 - anything destructive, irreversible, or security-sensitive.
@@ -87,14 +87,20 @@
 Attended (no record): the role limits above apply exactly as written, main-owned rows never reach you, and MAIN processes every captain outcome you report.
 Away (the record exists): the wake message ends with a `POSTURE: AWAY` tail carrying the record's read-back verbatim; MAIN is parked, you take every row including check rows, decision rows, and heartbeat rows, and captain outcomes remain unprocessed for the return brief even though their visible transcript entries persist.
 The record is the captain's away words, recorded verbatim: the explicit instruction the captain gave before leaving, and the whole mandate.
-No script parses them; you read them at the tail of every wake, decide by your own judgment whether the event in front of you is the moment they name, and act on them only through the guarded scripts under MAIN's standing authority - never more than MAIN could do attended - which enforce what a script can check without reading words:
-- `bin/fm-pr-review.sh merge` is the GitHub merge entrypoint when `.github/firstmate-review-policy.json` sets `require_reviewed_head_handoff` to `true`, and requires the current head's review-ledger generation; otherwise `bin/fm-pr-merge.sh` merges GitHub directly and refuses while the review ledger records an unreleased hold, and it remains the direct GitLab merge entrypoint.
-  A merge proceeds only under the same authority MAIN would have attended, when the pull request is green at its live head, synchronously under the record lock; a red pull request, or one with a required check that has not reported, is never merged while away, whatever the words say, and `--allow-red` and `--allow-missing` are refused under the record.
+MAIN's standing authority needs no words: away, do what MAIN does attended without asking the captain, through the same guarded scripts, whatever the words say or leave out.
+- Initialize a GitHub pull request's missing review ledger with `bin/fm-pr-review.sh init <task> <url>` and arm it with `bin/fm-pr-review.sh arm`; creating and arming the ledger waives no gate below.
+- Land a GitHub pull request whose current review-ledger generation passes every gate with `bin/fm-pr-review.sh merge <task> <url>`, which takes a fresh checkpoint and refuses a missing disposition, final disposition, or exact-model attestation, a red or unreported check, or a ledger hold; a ledger hold, a task held for the captain, or an unresolved product, rights, spend, destructive, or security-sensitive decision still holds it.
+- When the ledger lacks what the task's parked or finished worker can supply, steer that worker to supply it, as routine steering: dispositions with evidence, the posted and recorded final disposition, or for high-stakes work a no-mistakes run on the current head at the policy's exact model with no init (if the repository is not already initialized, it stops and reports), the rebase step skipped, and no rebase or force-push, then the attestation, a done line, and a park, never a merge.
+- Decide each ask-user finding under the ask-user-authority policy at the end of this prompt and steer the worker with the decision; report verdict captain only for a finding that policy escalates, and treat a stop condition you wrote into your own earlier steer as your checkpoint, not a captain instruction.
+The words add to this set and never subtract from it.
+Beyond that set, no script parses the words; you read them at the tail of every wake, decide by your own judgment whether the event in front of you is the moment they name, and act on them only through the guarded scripts under MAIN's standing authority - never more than MAIN could do attended - which enforce what a script can check without reading words:
+- `bin/fm-pr-review.sh merge` is the GitHub merge entrypoint while away: `bin/fm-pr-merge.sh` refuses a GitHub merge under the record unless that handoff recorded a ledger merge decision for the live head, and it remains the direct GitLab merge entrypoint.
+  A merge proceeds only when the pull request is green at its live head, synchronously under the record lock; a red pull request, or one with a required check that has not reported, is never merged while away, whatever the words say, and `--allow-red` and `--allow-missing` are refused under the record.
 - `bin/fm-spawn.sh`: work the words explicitly call for is dispatched within the record's spend cap, from a queued backlog item - one already queued, or one you file yourself for exactly that step under the `backlog` lease, writing its brief intent from the captain's words and a backlog note citing them; filing the item the captain asked for is not inventing work, and anything the words do not call for is.
-- `bin/fm-send.sh` and `bin/fm-control.sh`: a run the words say to abort or a worker the words say to steer is steered, as in any posture.
+- `bin/fm-send.sh` and `bin/fm-control.sh`: steering and lifecycle control stay yours as in any posture, and a run the words say to abort is aborted.
 - `bin/fm-send.sh --resolve-key`: a decision the words pre-answer is answered with the captain's own answer, and every other decision only as the ask-user-authority policy at the end of this prompt lets firstmate decide; a finding it says to escalate is reported with verdict captain and left for the return.
 - `bin/fm-merge-local.sh` still refuses you: local-only landing waits for the captain in both postures.
-Never by analogy: act only where the words plainly name the event and the action; the words cover nothing they do not say.
+Never by analogy: beyond MAIN's standing authority, act only where the words plainly name the event and the action; the words cover nothing they do not say.
 Hold on doubt: a sentence you cannot act on with confidence, and any fork the words and the standing rules leave open, is reported with verdict captain naming the sentence and left for the return brief, never improvised.
 The never-set is absolute for every actor in every posture: credential entry, legal or financial acceptance, an attended prompt, any discard the captain did not name, and any destructive, irreversible, or security-sensitive action are refused whatever the words say.
 Log every action taken under the words in that event's outcome summary, opening with "per your away instructions:" and naming the sentence you acted on, so the return brief can account for each one.
Evidence: Generated away wake prompt diff, base vs target

Source: Generated away wake prompt diff, base vs target

\### Generated AWAY wake prompt (bin/fm-branch-dispatch.mjs wake-prompt --away, real readback from the lab's away record), base vs target
--- base/away-wake
+++ target/away-wake
@@ -4,8 +4,10 @@
 
 POSTURE: AWAY.
 The away-posture record state/.afk-contract exists, so the captain is not present and MAIN is parked: you take every row, including check rows and decision rows, and no outcome reaches the captain until the return brief.
-The record below is the captain's away words, verbatim, and the whole mandate: act on them by your own judgment where this event is the moment they name, only through the guarded scripts under MAIN's standing authority - never more - which enforce it: bin/fm-pr-merge.sh merges any pull request that is green at its live head, synchronously, and refuses a red one or --allow-red; bin/fm-spawn.sh dispatches queued work (already queued, or filed by you from the words) within the spend cap; bin/fm-send.sh --resolve-key answers a decision the words pre-answer, or one the ask-user-authority policy in your prompt lets firstmate decide; bin/fm-merge-local.sh still refuses you.
-Never by analogy, and hold on doubt: a sentence you cannot act on with confidence is reported with verdict captain, naming it, and left for the return.
+The record below is the captain's away words, verbatim.
+MAIN's standing authority needs no words: initialize and arm a missing review ledger with bin/fm-pr-review.sh init <task> <url> and bin/fm-pr-review.sh arm, land a pull request whose review ledger passes every gate through bin/fm-pr-review.sh merge, steer a parked worker to supply a missing gate, and decide ask-user findings under the ask-user-authority policy in your prompt.
+Beyond that, act on the words by your own judgment where this event is the moment they name, only through the guarded scripts - never more: bin/fm-pr-review.sh merge refuses a missing gate, a red or unreported check, or a ledger hold, and bin/fm-pr-merge.sh refuses a GitHub merge without that handoff and refuses --allow-red; bin/fm-spawn.sh dispatches queued work (already queued, or filed by you from the words) within the spend cap; bin/fm-send.sh --resolve-key answers a decision the words pre-answer, or one the ask-user-authority policy in your prompt lets firstmate decide; bin/fm-merge-local.sh still refuses you.
+Beyond standing authority, never by analogy, and hold on doubt: a sentence you cannot act on with confidence is reported with verdict captain, naming it, and left for the return.
 Credential entry, legal or financial acceptance, an attended prompt, any discard the captain did not name, and any destructive, irreversible, or security-sensitive action are refused for every actor in every posture, whatever the words say.
 Log every action taken under the words in its outcome summary, opening with "per your away instructions:".
 A mirrored captain sentence authorizes nothing new once the record exists.
Evidence: Generated target away wake prompt

Source: Generated target away wake prompt

FIRSTMATE SUPERVISION WAKE: check: pr ready: task-x1 https://github.com/twilwa/firstmate/pull/36

Handle this per your operating procedure and finish with the bin/fm-branch-report.sh command.

POSTURE: AWAY. The away-posture record state/.afk-contract exists, so the captain is not present and MAIN is parked: you take every row, including check rows and decision rows, and no outcome reaches the captain until the return brief. The record below is the captain's away words, verbatim. MAIN's standing authority needs no words: initialize and arm a missing review ledger with bin/fm-pr-review.sh init <task> <url> and bin/fm-pr-review.sh arm, land a pull request whose review ledger passes every gate through bin/fm-pr-review.sh merge, steer a parked worker to supply a missing gate, and decide ask-user findings under the ask-user-authority policy in your prompt. Beyond that, act on the words by your own judgment where this event is the moment they name, only through the guarded scripts - never more: bin/fm-pr-review.sh merge refuses a missing gate, a red or unreported check, or a ledger hold, and bin/fm-pr-merge.sh refuses a GitHub merge without that handoff and refuses --allow-red; bin/fm-spawn.sh dispatches queued work (already queued, or filed by you from the words) within the spend cap; bin/fm-send.sh --resolve-key answers a decision the words pre-answer, or one the ask-user-authority policy in your prompt lets firstmate decide; bin/fm-merge-local.sh still refuses you. Beyond standing authority, never by analogy, and hold on doubt: a sentence you cannot act on with confidence is reported with verdict captain, naming it, and left for the return. Credential entry, legal or financial acceptance, an attended prompt, any discard the captain did not name, and any destructive, irreversible, or security-sensitive action are refused for every actor in every posture, whatever the words say. Log every action taken under the words in its outcome summary, opening with "per your away instructions:". A mirrored captain sentence authorizes nothing new once the record exists. The record, verbatim:
Away posture (recorded):
  entered: 2026-10-14T12:57:27Z
  expected return: not given
  spend cap: 4 concurrent workers
  reach: hold-for-return only. No phone channel is configured; anything that needs you waits for your return.
  your words (verbatim):
    keep the lanes running
Evidence: fm-pr-review test log (empty required set, ready on no-protection base)

Source: fm-pr-review test log (empty required set, ready on no-protection base)

ok - pending reviews retry, and top-level comments, submissions, and inline threads all require dispositions
ok - a new head invalidates prior checks and review coverage
ok - high-stakes readiness requires the configured model and no independent review when the policy count is zero
ok - the risk classifier resolves incomplete changed-surface evidence to high stakes with a reason
ok - authentication and authorization filenames are high stakes
ok - conventional migrate directories are high stakes
ok - public API definitions and conventional production infrastructure paths are high stakes
ok - PR review, merge, shared identity, captain-hold, snapshot, classifier, and policy surfaces are high stakes
ok - attestation changes invalidate and become part of the bound final disposition state
ok - merge decisions bind the immediately verified head to the reviewed ledger generation
ok - live collection reads top-level comments, submitted reviews, inline threads, and pending reviewers
ok - only an observed exact ledger-bound final-disposition post is excluded from reviewer input
ok - unreported required checks remain pending instead of satisfying readiness
ok - the collector records no required checks only when the base branch provably requires none
ok - a complete review is ready on a base that requires no checks, and an unreadable required set still blocks it
ok - imported ledgers keep holds and null dispositions blocking ready and merge-decision
ok - human holds survive head changes and require an evidenced release
ok - the review wrapper applies one named red-check waiver and forwards guarded options
ok - the merge wrapper binds its task id to the task recorded in the review ledger
ok - review checkpoints reuse the authenticated watcher check without another monitor
ok - non-browser changes record a head-keyed N/A reason that a new head invalidates
ok - post-merge verification requires a forge merge of the reviewed source head
ok - post-merge validation and recording use one exact JSON document
ok - post-merge validates and records the same immutable staged evidence object
ok - browser changes require journeys, data and API checks, clean errors, viewport coverage, and posted screenshot evidence
ok - post-merge QA rejects superficial evidence, unsafe production actions, remote profiles, personal cookies, and paid cloud claims
ok - a failed post-merge smoke requires an owning bug and blocks Ready for QA

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/fm-branch-prompt.sh:123 - While away, a GitHub PR with no review ledger can no longer merge, and nothing tells the away branch how to create one. require_away_review_merge_decision (bin/fm-pr-merge.sh:1144-1155) refuses whenever the ledger file is missing, because REVIEW_LEDGER is a computed path that is set whenever the tracked policy exists, and the away-without-ledger test locks that in. bin/fm-pr-review.sh merge also dies with 'review ledger is unavailable' when there is no ledger. Only the pr-review-policy skill says to run bin/fm-pr-review.sh init &lt;task&gt; &lt;url&gt; (and arm) after fm-pr-check.sh, and that is MAIN's step. The branch prompt tells the branch to run bin/fm-pr-check.sh (bin/fm-branch-prompt.sh:53) but never mentions init. The standing-authority list (lines 122-124) only covers steering the worker to supply dispositions, the final disposition, or the attestation, and the worker cannot create the ledger. The same gap is in the away tail at .pi/extensions/lib/fm-branch-dispatch.ts:54. Concrete sequence: a worker opens and reports a PR during the away window; the branch runs fm-pr-check.sh; no ledger is initialized; fm-pr-review.sh merge dies; the branch holds on doubt and reports verdict captain. That is the same stall-until-return this change exists to remove, and before this change a green PR in this state merged. Failing closed in the script is correct, since it protects the exact-model attestation boundary. The fix belongs in the prompt: add 'initialize a missing review ledger with bin/fm-pr-review.sh init <task> <url> and arm' to MAIN's standing-authority set in fm-branch-prompt.sh and the away tail. That adds to the text the intent specifies, so the remedy needs authorization.

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

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 8 of 10 scenarios driven live against the product
Scenario Result Live Evidence
Review snapshot of a PR whose base branch requires no checks records no required checks (PR 218 stall) ✅ pass live scenario-A-snapshot-unprotected.txt: on real #36, base .checks=[placeholder PENDING], target .checks=[]
Adversarial: a base that does require checks, or whose required set is unreadable, keeps the pending required-check placeholder ✅ pass live scenario-A-snapshot-required-set-adversarial.txt: real cli/cli#14679 (trunk requires 3 checks) with gh pr checks forced ambiguous, and with the branch read returning 502; both keep one pending 'requir…
While away, the branch actor can initialize and arm a missing review ledger ✅ pass live scenario-B-away-merge-gate-lab.txt: FM_SUPERVISION_ACTOR=branch fm-pr-review.sh init -> 'initialized ... risk=high', arm -> 'armed', rc=0
While away, a direct bin/fm-pr-merge.sh GitHub merge (no handoff, a hand-set handoff, or a decision for another head) is refused and nothing merges (PR 240 path) ✅ pass live scenario-B-away-merge-gate-lab.txt B1/B2/B5: rc=2 with 'while the away-posture record exists a GitHub merge goes through bin/fm-pr-review.sh merge ...; nothing was merged'; gh call log shows 0 pr merg…
While away, --allow-red is refused under the record ✅ pass live scenario-B-away-merge-gate-lab.txt B3: 'error: --allow-red is attended-only; while the away-posture record exists the green check is absolute' rc=2
While away, bin/fm-pr-review.sh merge refuses a ledger missing dispositions, final disposition, or the exact-model attestation ✅ pass live scenario-B-away-merge-gate-lab.txt B4: four 'review gate:' refusals incl. 'high-stakes work lacks a no-mistakes attestation for the configured exact model', rc=1, merge_decision stays null
While away, bin/fm-pr-review.sh merge lands a ledger that passes every gate at its reviewed head ⏸️ untested no The prior payload did not establish a live result for this scenario. The only coverage was the stub-forge test in bash tests/fm-pr-merge.test.sh, which is not live. A live success would merge a real…
release-hold refuses the supervision branch actor in both postures, and main can still release ✅ pass live scenario-B-away-merge-gate-lab.txt C1 (away) and C2 (after archive): 'review hold release (fm-pr-review release-hold) refused' rc=6; C3 main 'hold-released' rc=0; B6 attended merge refused by the stil…
Generated branch system prompt and away wake prompt carry MAIN's standing authority (ledger init/arm, ledger-passing merge, steer for missing gate, ask-user under policy) and stay a pure function of t… ✅ pass live scenario-C-branch-system-prompt.diff and scenario-C-away-wake-prompt.diff (generated at base vs target from the real generators, wake prompt using the lab's real away readback); target prompt byte-ide…
A live supervision agent, given the away prompt, actually merges a ledger-passing PR and steers instead of holding ⏸️ untested no This tests how a model interprets the prompt, which is non-deterministic. The repo's test-quality rule assigns that to development-time evaluation, not gate validation. Driving it would also need a la…
  • bin/fm-pr-review-snapshot.sh https://github.com/twilwa/firstmate/pull/36 at base 2e07fc7 and target 051aff9 against real GitHub (main unprotected, rules [])
  • bin/fm-pr-review-snapshot.sh https://github.com/cli/cli/pull/14679 (trunk requires 3 checks) with only gh pr checks forced to print the ambiguous 'no required checks reported' message, plus a variant where the branch-protection read returns HTTP 502
  • Lab home via bin/fm-lab-home.sh create; bin/fm-afk-contract.sh enter --words &#39;keep the lanes running&#39;; FM_SUPERVISION_ACTOR=branch bin/fm-pr-review.sh init task-x1 &lt;PR36&gt; and arm
  • As the branch actor while away: direct bin/fm-pr-merge.sh task-x1 &lt;PR36&gt;; the same with a hand-set FM_PR_REVIEW_EXPECTED_HEAD=live head; with --allow-red; with a ledger merge decision recorded for an earlier head; and bin/fm-pr-review.sh merge task-x1 &lt;PR36&gt; on an incomplete ledger
  • bin/fm-pr-review.sh hold as main, then release-hold as the branch actor away and again after bin/fm-afk-contract.sh archive; attended direct bin/fm-pr-merge.sh as main (refused by the ledger hold); release-hold as main
  • bin/fm-branch-prompt.sh and bin/fm-branch-dispatch.mjs wake-prompt --away --readback-file &lt;real lab readback&gt; generated at base and target, then diffed; byte-identity checked across cwd/env
  • bash tests/fm-pr-merge.test.sh (114 ok)
  • bash tests/fm-pr-review.test.sh (27 ok)
  • bash tests/fm-branch-supervision.test.sh (34 ok)
  • bash tests/fm-pi-branch-extension.test.sh (49 ok, 2 skipped: installed Pi package not found)
  • bash tests/fm-supervision-host.test.sh (69 ok, 0 failed, including the changed dispatch away-tail case, before the run was stopped at the background time limit)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…eview ledger

Under the away record on 2026-10-13 the supervision branch held every pull
request that lacked an exact-model attestation instead of steering its worker
to run the gate, sent every ask-user finding to the captain, held a fully
ready pull request because the review snapshot invented a pending "required
checks have not reported" check on a repository with no branch protection,
and in the other direction merged a high-stakes pull request through
bin/fm-pr-merge.sh with no exact-model attestation. This implements the
four-part fix from that investigation.

A. The required-check reader (urlencode, plan-gated rules 403, classic
protection plus rulesets) moves unchanged from bin/fm-pr-merge.sh into
bin/fm-pr-lib.sh as fm_pr_github_* functions taking owner and repo, and
bin/fm-pr-review-snapshot.sh uses it when gh prints "no required checks
reported": a readable, empty required set records no required checks, while
a non-empty or unreadable set keeps the pending placeholder. Merge behaviour
is unchanged.

B. While the away-posture record exists, bin/fm-pr-merge.sh refuses a GitHub
merge unless bin/fm-pr-review.sh merge recorded the current generation's
ledger merge decision for the live head (merge-decision writes it only after
every review gate passes), so a direct call or a hand-set reviewed head is
refused. bin/fm-pr-review.sh release-hold refuses the supervision branch
actor in every posture. Attended merges and GitLab are unchanged.

C. bin/fm-branch-prompt.sh "Postures" and the away wake tail in
.pi/extensions/lib/fm-branch-dispatch.ts name MAIN's standing authority: land
a pull request whose ledger passes every gate through bin/fm-pr-review.sh
merge, steer a parked worker to supply a missing gate (no init, rebase step
skipped, no rebase or force-push, never a merge), and decide ask-user
findings under ask-user-authority; the ask-user captain verdict is qualified
to the attended posture.

D. Matching edits in the afk and pr-review-policy skills,
docs/pi-supervision-branch.md, and the merge-path lines in AGENTS.md section
7 and docs/architecture.md that the away gate made incomplete.

One-time effect of A: an open review ledger whose bound final disposition
digest includes the old "required checks have not reported" placeholder
reports "final disposition and evidence have not been posted for the latest
review state on this head" at its next checkpoint, until the final
disposition is recorded again with bin/fm-pr-review.sh final-disposition.

The opt-in credentialed replay test the investigation proposed was not added
or run: this change is scoped to the named deterministic tests and adds no
new scripts. The deterministic tests cover the PR 218 shape (ready and
merged away through the wrapper), the PR 240 shape (refused for the missing
exact-model attestation, and refused as a direct away merge), release-hold
for the branch actor attended and away, and the prompt and away-tail text.

Follow-ups noted in the structure pass: bin/fm-pr-lib.sh is now about 1500
lines and the GitHub forge reads could become their own library; the older
fake forge in test_live_collector_keeps_unreported_required_checks_pending
duplicates the new write_required_set_fake_gh and was left unchanged as
specified.
@sourcery-ai

sourcery-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Sorry @twilwa, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 4 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T22:07:51.280645Z fc2b0aa PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@sourcery-ai

sourcery-ai Bot commented Oct 13, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR closes both away-mode failure paths by routing GitHub merges through a verified review-ledger decision bound to the live head and by making snapshot required-check state reflect the actual branch protection/ruleset configuration, while documenting and testing the expanded but guarded standing authority.

Sequence diagram for an away-mode GitHub merge

sequenceDiagram
    participant Branch as SupervisionBranch
    participant Review as bin/fm-pr-review.sh
    participant Ledger as ReviewLedger
    participant Merge as bin/fm-pr-merge.sh
    participant GitHub as GitHub

    Branch->>Review: merge task url
    Review->>Review: merge-decision
    Review->>Ledger: record decision=merge and verified_head
    Review->>Merge: invoke guarded merge with reviewed head
    Merge->>Ledger: verify current generation decision and head
    Merge->>GitHub: gh pr merge --match-head-commit
    GitHub-->>Merge: merge result
    Merge-->>Branch: report landed or refusal
Loading

State diagram for away-mode merge authority

stateDiagram-v2
    [*] --> Attended
    Attended --> Away: away-posture record exists
    Away --> ReviewGate: bin/fm-pr-review.sh merge
    ReviewGate --> LedgerDecision: all review gates pass
    ReviewGate --> Held: missing gate, red check, or ledger hold
    LedgerDecision --> LiveHeadCheck: record verified_head
    LiveHeadCheck --> Merged: live head matches
    LiveHeadCheck --> Held: direct, hand-set, or stale handoff
    Merged --> Away
    Held --> Away
    Away --> Attended: away record archived
Loading

Flow diagram for accurate required-check snapshotting

flowchart TD
    A[gh pr checks --required] --> B{Reports required checks?}
    B -->|Yes| C[Record reported checks]
    B -->|No| D[Read pull request base branch]
    D --> E[fm_pr_github_read_required_contexts]
    E --> F{Read succeeds and set is empty?}
    F -->|Yes| G[Record no required checks]
    F -->|No| H[Record pending required checks placeholder]
    C --> I[Review snapshot]
    G --> I
    H --> I
Loading

File-Level Changes

Change Details Files
Enforce the review-ledger handoff for away-mode GitHub merges and keep captain-held work owned by MAIN.
  • Require a live-head ledger merge decision and reviewed-head handoff before away GitHub merges can reach the forge.
  • Keep GitLab and attended behavior unchanged, while continuing to reject red or unreported checks and away-only waivers.
  • Refuse supervision-branch release of review holds in every posture and update lease-role documentation.
bin/fm-pr-merge.sh
bin/fm-pr-review.sh
bin/fm-lease-lib.sh
AGENTS.md
bin/fm-afk-contract.sh
docs/pi-supervision-branch.md
docs/architecture.md
docs/configuration.md
docs/scripts.md
Centralize GitHub required-check discovery and distinguish genuinely unprotected bases from unreadable or pending required checks.
  • Move branch protection/ruleset parsing and URL encoding into reusable fm-pr-lib.sh functions.
  • Have snapshots consult the PR base branch and record an empty required-check set only after a successful empty-set read.
  • Preserve the pending placeholder for non-empty or unreadable required-check sources, with existing ledger re-recording implications.
bin/fm-pr-lib.sh
bin/fm-pr-merge.sh
bin/fm-pr-review-snapshot.sh
Expand away-mode standing authority and align generated prompts, skills, and documentation with the guarded execution model.
  • Authorize ledger-passing GitHub merges, routine steering to supply missing gates, and ask-user decisions allowed by policy without requiring away words.
  • Clarify that away words supplement rather than replace MAIN's standing authority, with holds, never-set actions, and local-only landing still protected.
  • Mirror the updated authority and merge-entrypoint rules in the wake tail, AFK/pr-review skills, and supervision documentation.
bin/fm-branch-prompt.sh
.pi/extensions/lib/fm-branch-dispatch.ts
.agents/skills/afk/SKILL.md
.agents/skills/pr-review-policy/SKILL.md
Add regression coverage for merge routing, head binding, required-check interpretation, hold ownership, and prompt behavior.
  • Test direct, hand-set, stale-head, unattested, red-check, captain-held, and successfully reviewed away merge scenarios.
  • Test empty, required, plan-gated, and unreadable required-check sources in snapshots and review readiness.
  • Verify branch-role refusals, generated prompt/wake-tail content, and updated away supervision behavior.
tests/fm-pr-merge.test.sh
tests/fm-pr-review.test.sh
tests/fm-branch-supervision.test.sh
tests/fm-supervision-host.test.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fc2b0aa0db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 54 to +60
elif grep -q "^no required checks reported on the '" "$TMP/checks.err"; then
printf '%s\n' \
'[{"name":"required checks have not reported","state":"PENDING","bucket":"pending","link":null}]' \
> "$TMP/required.json"
# gh prints this both when the base requires no checks and when required
# checks have not reported yet; only a readable, empty required set is the
# first, and anything else stays one pending required check.
BASE=$(jq -er '.base.ref | select(type == "string" and length > 0)' "$TMP/core.json" 2>/dev/null) || BASE=
if [ -n "$BASE" ] && fm_pr_github_read_required_contexts "$OWNER" "$REPO" "$BASE" \
&& [ "$FM_PR_GITHUB_REQUIRED" = '[]' ]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the zero-check error before clearing requirements

When no check run exists yet on a PR whose base requires a check, gh pr checks --required emits no checks reported... before applying the required-check filter, as shown in the GitHub CLI v2.96 source. This fallback verifies the required set only for no required checks reported; the following branch still converts no checks reported to [], allowing the review ledger to become ready and record a merge decision before required CI has started. Although fm-pr-merge.sh later refuses the merge, the away workflow can post and attest a falsely ready ledger and then stall, so both diagnostics should use the shared required-set reader.

AGENTS.md reference: AGENTS.md:L237-L238

Useful? React with 👍 / 👎.

… is fixed. Behavior portable parallel 1 comes from an upstream package release, not from this PR's code. ci-2 (Behavior portable serial 4): tests/fm-pi-branch-extension.test.sh checked the away-mode prompt for the phrase "act on them by your own judgment". Part C of this PR rewrote that text in .pi/extensions/lib/fm-branch-dispatch.ts, so it now reads "act on the words by your own judgment", and the test was never updated. CI failed with "the away tail lost the words-execution rule". The rule being checked is that the away prompt must still tell the agent to act on the captain's words, and that one assertion is the only place that checks it; nothing else in the repo still uses the old wording. I updated the assertion to the new phrase and added one check that the prompt contains "MAIN's standing authority needs no words". Both checks read the final prompt text sent to the agent, not source code. The test file passes locally (exit 0, 49 ok lines), including the away-posture case that failed in CI. Two other cases in that file skip locally because the Pi package isn't installed globally here. ci-1 (Behavior portable parallel 1): tests/fm-pi-primary-types.test.sh fails a type check with "Property 'prompt' does not exist on type 'BeforeAgentStartEvent'". The errors are in .pi/extensions/fm-branch-supervision.ts and .pi/extensions/fm-primary-pi-watch.ts, which this PR doesn't touch. CI installs @earendil-works/pi-coding-agent without a pinned version (ci.yml:118 and :222). Version 1.2.0 came out on 2026-10-12, after the last passing runs on 2026-10-10, so CI is now checking against a newer API. It will fail on main too until the extensions are updated for Pi 1.2.0 or CI pins an earlier version. That should be its own change and is outside this PR's scope. Pi isn't installed on this host, so it couldn't be reproduced or fixed here
@twilwa twilwa changed the title fix(bin): route away-mode GitHub merges through the review ledger and stop phantom required checks fix(bin): route away-mode GitHub merges through the review ledger and stop phantom required-check holds Oct 14, 2026
@twilwa
twilwa merged commit d447e08 into main Oct 14, 2026
24 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