Repository navigation
fix(bin): let a secondmate's PR merge under the captain's away authority - #15
Merged
VasanthAmana merged 2 commits intoOct 16, 2026
Conversation
While the away-posture record exists, fm-pr-merge.sh --secondmate refused every merge because the owning home cannot see the parent's record and would merge as attended. A green child PR therefore could not be merged during away mode, by main or by the supervision branch. The parent now passes its away authority explicitly as a leading --parent-away-authority, and the owning home's own guarded merge applies the away rules: synchronous only, no red merge, --allow-red and --allow-missing refused, no unprovable merge queue, and away recorded as the merge authority. A local owning home proves the claim against its bound parent's live record and holds that record's lock across the forge call, so a lapsed or absent parent record refuses the merge; a home with no parent binding refuses the flag. A remote owning home cannot reach the record, so the parent holds its record lock across the synchronous transport call and reads the posture under it. The supervision branch may route the merge exactly when it may merge a main-home PR, and the owning home no longer inherits the parent's supervision actor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Let second-mate PRs merge while the captain is away.
Problem statement (this repository is public; the description below is the whole context):
bin/fm-pr-merge.sh --secondmate <mate> <child-task> <pr-url>refuses every merge with: "a secondmate's PR merge is refused while this home's away record exists: the secondmate's home cannot see that record and would merge as attended; nothing was merged".Wanted: under away mode, a second mate's green PR merges under the same away-authority rules that apply to a main-home PR - synchronous merge only, no red merge, no attended-only waivers (--allow-red / --allow-missing refused), merge metadata recorded - by passing the away authority across the home boundary to the owning home's guarded merge, rather than bypassing the owning home's guards.
What Changed
bin/fm-pr-merge.sh --secondmateno longer refuses a merge just because this home's away record exists. When an away record exists, it now adds a leading--parent-away-authorityto the owning home's merge, whether that home is local (viaexec) or remote (viafm-on.sh). For a remote home, this home holds its own away-record lock across the synchronous call. If the record can't be read or locked, the merge is refused. The routedexecalso drops this home'sFM_SUPERVISION_ACTOR. The supervision branch can now route a secondmate merge exactly when it could merge a main-home PR.A new
--parent-away-authorityentry path makes the owning home apply the away rules:--autoand GitLab auto-merge are refused;--allow-red/--allow-missingwaivers are refused;awayis recorded as the merge authority.A local owning home checks its claim against the live away record of the parent named in its
.fm-secondmate-parentbinding, holding that record's lock. If the parent's record no longer exists, the merge is refused. A remote owning home applies the away rules on the parent's word. The flag is refused when the home has no secondmate identity or parent binding, and when it is combined with--secondmate.Updated the script header and
docs/architecture.mdto describe how each route proves the away authority. Extendedtests/fm-pr-merge.test.shto cover the new routing and refusals.Risk Assessment
✅ Low: The fix round adds a narrow fail-closed guard. When the local secondmate route carries no away authority, the supervision branch is now refused before the exec, so it can no longer hand off an attended merge. The regression test drives the archive race through the real entrypoint and would fail without the guard.
Testing
All 8 secondmate-merge tests passed under stock bash 3.2. They drive the real fm-pr-merge.sh entrypoint, but against a fake gh and a fake ssh, so none of the results are live. The regression runs reproduce both bugs. With the base script, the old refusal comes back and the away-merge test fails. With the script from before the review fix, the lapse-race test fails. No scenario was driven against a real forge, so every scenario is marked untested. Merging a real GitHub PR was not run, because that needs a disposable repo and approval for an outward-facing merge.
fm-pr-merge.sh --secondmate mate-x task-x1 <green PR>: the merge lands through the owning home, which records away authority and reports 'merged ... away' upwardEvidence: Targeted secondmate merge test run (HEAD, bash 3.2)
Source: Targeted secondmate merge test run (HEAD, bash 3.2)
Evidence: Regression tests against the base and pre-review-fix scripts (both fail as expected)
Source: Regression tests against the base and pre-review-fix scripts (both fail as expected)
Evidence: CLI transcript: secondmate PR merge while the parent is away, base vs HEAD (fake gh)
Source: CLI transcript: secondmate PR merge while the parent is away, base vs HEAD (fake gh)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 1 issue found → auto-fixed ✅
bin/fm-pr-merge.sh:257- The local--secondmateroute can let the supervision branch trigger an attended merge. It checks the actor withfm_lease_forbid_branch --away-relocatedat line 213, which passes because the away record exists. It then reads the posture again inrouted_away_authoritywithout holding the record lock. If the captain returns and the record is archived between those two reads, ROUTED_AWAY_ARGS comes back empty. The script then execs the owning home withenv -u FM_SUPERVISION_ACTORand no--parent-away-authority, so the owning home runs an ordinary attended merge where--allow-red/--allow-missingare accepted, even though the branch must never do that. The main-home path closes this gap by repeating the actor check under the away-record lock (require_current_away_authority), and the remote route here does the same at lines 238-244. The local route has neither protection, and stripping the actor means the owning home cannot catch it either. Smallest fix: on the local route, refuse when the caller is the branch actor (fm_lease_actor= branch) and ROUTED_AWAY_ARGS is empty. With the flag, the owning home already checks the parent's live record under its lock and refuses if the record has lapsed, so this fails closed.🔧 Fix applied.
✅ Re-checked - no issues remain.
fm-pr-merge.sh --secondmate mate-x task-x1 <green PR>: the merge lands through the owning home, which records away authority and reports 'merged ... away' upward, While the parent is away, a routed merge with --allow-red, --allow-missing, or --auto is refused as attended-only and never reaches the forge, The captain's return (archiving the record) during the owning home's forge call is blocked by the parent's record lock, Adversarial: the away record is archived after the supervision branch's actor check but before routing; the branch is refused (exit 6) and no forge merge runs, Adversarial: --parent-away-authority with no parent away record, a record that lapses mid-preflight, no parent binding, or a re-route is refused with no forge merge, Remote secondmate: the parent holds its record lock across the ssh call and passes --parent-away-authority; the remote home applies the away rules, Attended (no away record) supervision branch is still refused a secondmate route; other owning-home guards are unchanged, Real GitHub PR built by a secondmate child merges during real away modefm-pr-merge.sh --secondmate mate-x task-x1 <green PR>: the merge lands through the owning home, which records away authority and reports 'merged ... away' upwardRan the 8 secondmate-merge test functions fromtests/fm-pr-merge.test.shunder stock/bin/bash3.2, sourcing the file without its top-level test calls: test_parent_merges_a_secondmate_child_pr_through_the_owning_home, test_secondmate_merge_keeps_the_owning_home_guards, test_secondmate_merge_refuses_what_the_parent_cannot_route, test_secondmate_merge_carries_the_parent_away_authority, test_secondmate_route_refuses_the_branch_when_the_record_lapses, test_owning_home_refuses_an_unbacked_parent_away_claim, test_remote_secondmate_merge_carries_the_parent_away_authority, test_remote_secondmate_merge_runs_in_the_owning_home. All 8 passed, with a fake gh and a fake ssh.Before/after regression check: ran the HEAD tests againstbin/fm-pr-merge.shfrom 9664eed7 (base) and from 176a7889 (before the review fix), each in its own git-archive export.CLI transcript offm-pr-merge.sh --secondmate mate-x task-x1 <url>, with and without--allow-red ci, run from a parent home with an active away record, at base and at HEAD, against a fake gh.✅ **Document** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.