Skip to content

fix(bin): skip stale-grant reclaim in branch wake drains - #8310

Merged
kunchenguid merged 2 commits into
kunchenguid:mainfrom
stuartmercer:fm/fm-upstream-pr
Nov 11, 2026
Merged

kunchenguid merged 2 commits into
kunchenguid:mainfrom
stuartmercer:fm/fm-upstream-pr

Conversation

@stuartmercer

@stuartmercer stuartmercer commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • bin/fm-wake-drain.sh: a branch-actor drain no longer calls reclaim_stale_branch_grant_locked. Only main reclaims stale grants. Before this, a branch whose sandbox could not inspect the host pid via ps could treat its own just-published grant as stale and delete its snapshot before draining. A comment on the function explains why.
  • docs/watcher-continuity.md: documents that a branch drain never reclaims, because it drains the grant just published for its turn.
  • tests/fm-wake-queue.test.sh: adds 40 lines of tests in the wake-queue suite for this branch-drain case.

Risk Assessment

✅ Low: A one-line guard skips stale-grant reclaim for the branch actor, as the intent specifies. It is covered by a behavioral regression test that stubs ps and drives the real drain and ack. No other liveness check sits on the branch path.

Testing

I ran tests/fm-wake-queue.test.sh against the real fm-wake-drain.sh and fm-wake-grant.sh scripts, using a fake ps that always exits 1. With the fix the whole suite passes. With the pre-fix drain script the new test fails because the branch drain reclaims and deletes its own grant. Only the test suite file was run, since this change has no UI surface. The sandbox blocks ps, which the test harness needs, so I ran those commands unsandboxed.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Branch-actor drain and ack succeed when ps cannot inspect the host, draining only the granted row and leaving the main-owned row queued ✅ pass live tests/fm-wake-queue.test.sh: 'ok - branch drain and acknowledgement keep their published grant when ps cannot inspect the host'
Regression guard: the same test fails against the pre-fix fm-wake-drain.sh ✅ pass live Base-version run: 'not ok - branch lost its live grant when ps was unavailable ... no branch-eligible row snapshot'
Evidence: Test run on the fixed code (new test passes)
ok - branch drain and acknowledgement keep their published grant when ps cannot inspect the host
Evidence: Test run on the base drain script (new test fails)
not ok - branch lost its live grant when ps was unavailable: wake drain: no branch-eligible row snapshot at .../branch-ps-denied/state/.branch-eligible-rows; refusing to guess what this actor may consume

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Branch-actor drain and ack succeed when ps cannot inspect the host, draining only the granted row and leaving the main-owned row queued ✅ pass live tests/fm-wake-queue.test.sh: 'ok - branch drain and acknowledgement keep their published grant when ps cannot inspect the host'
Regression guard: the same test fails against the pre-fix fm-wake-drain.sh ✅ pass live Base-version run: 'not ok - branch lost its live grant when ps was unavailable ... no branch-eligible row snapshot'
  • bash tests/fm-wake-queue.test.sh on the target commit: exit 0, no not ok lines, including the new ps-denied test
  • The same suite with bin/fm-wake-drain.sh temporarily reverted to c8d8fdad: exit 1, the new test fails with 'no branch-eligible row snapshot', then the fix was restored with git checkout
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge; no actionable issues were found.

Reviews (5) · Last reviewed commit: "no-mistakes(document): Document branch d..." · Reviewed by Greptile

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @stuartmercer for this, and welcome. Skipping the branch's own stale-grant reclaim makes sense. Main already reclaims a grant whose owner has died. For the branch, that reclaim is a no-op whenever its grant is live, and a false "dead" verdict is exactly what wedges a drain where ps can't see the host. The new test pins that case, and the main-owned row stays queued.

What I checked on e1199a7a against main bc9370e8: I read the full diff (bin/fm-wake-drain.sh plus one test). It has no workflow, CI-config, network or credential changes, so I approved this head's first-time fork runs: CI 42619301991 and Require no-mistakes 42619301979 and 42620579578. The coverage guard and repo invariants pass, and Greptile is 5/5 with no threads.

Contract-class (my own read): restore. The Pi supervision branch is a documented default-on path. Its drain of its own published grant broke where ps can't inspect the host pid. Nothing new runs on an unconfigured home. VISION.md: aligns on every rule. The branch still consumes only its published rows, and main keeps the stale-grant repair.

Waiting on you for one thing: the no-mistakes attestation in the PR body is cut off mid-JSON ({"step... (truncated)). It stops after lint and its closing marker is missing. So the "PR must be raised via no-mistakes" check fails with "This PR is missing structured pipeline step attestation." Please re-raise once with git push no-mistakes, and leave the generated Pipeline section unedited so the attestation binds the final head with no skipped steps.

After that, we run the full suite. The red Full suite check only means our label isn't on yet. It isn't your code.

@stuartmercer stuartmercer changed the title fix(bin): keep a branch wake grant when the branch cannot inspect its host pid fix(bin): skip stale-grant reclaim in branch wake drains Nov 9, 2026
@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 9, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @stuartmercer for the clean re-raise.

What I checked on b560a777 against main c8d8fdad: the code change and its test are the same as before. The only addition is one line in docs/watcher-continuity.md saying a branch drain never reclaims. I read the full diff again. It has no workflow, CI-config, network or credential changes, so I approved this head's fork runs: CI 42651539367 and Require no-mistakes 42651539197 and 42651564531. The no-mistakes attestation now binds b560a777 with no skipped steps, and "PR must be raised via no-mistakes" passes. The coverage guard and repo invariants pass, and Greptile is 5/5 with no threads. Main still reclaims unconditionally in the branch drain, so the fix is still needed.

Contract-class (my own read): restore. The Pi supervision branch is documented as default-on. This only drops the branch's own reclaim of the grant just published for its turn, and main still reclaims grants whose owner has died. VISION.md: aligns on every rule.

Nothing is waiting on you. I've queued the full suite (full-ci), and this PR is waiting on CI. The earlier red Full suite check only meant the label wasn't on yet.

@kunchenguid kunchenguid added full-ci Maintainer go-ahead: run the full CI suite on this outside pull request and removed full-ci Maintainer go-ahead: run the full CI suite on this outside pull request labels Nov 9, 2026
@kunchenguid
kunchenguid merged commit 6d56ea4 into kunchenguid:main Nov 11, 2026
75 of 80 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @stuartmercer — really appreciate you taking the time on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants