Skip to content

fix(bin): anchor supervision markers and wake grants on the lock holder - #5172

Open
ardydedase wants to merge 8 commits into
kunchenguid:mainfrom
ardydedase:ardy/pi-extension-markers-descendant-clobber
Open

ardydedase wants to merge 8 commits into
kunchenguid:mainfrom
ardydedase:ardy/pi-extension-markers-descendant-clobber

Conversation

@ardydedase

@ardydedase ardydedase commented Sep 21, 2026 •

Copy link
Copy Markdown

Intent

The developer tasked an autonomous worker with fixing two supervision-durability bugs in the firstmate repo: (1) pi primary extension "loaded" markers in .pi/extensions/fm-primary-pi-watch.ts, fm-primary-turnend-guard.ts, and fm-branch-supervision.ts were being overwritten by transient descendant pi processes recording their own process.pid instead of the live lock-holder pid, and (2) lost .branch-eligible-rows/.main-eligible-rows snapshots were wedging wake-queue drain/acknowledgement. The fix direction was to record the lock pid resolved by the ownership walk while keeping the cold-start missing-lock path writable, and to make lost snapshots regenerate durably inside the documented contract in docs/watcher-continuity.md (studying bin/fm-wake-grant.sh first) rather than inventing a parallel recovery path. Explicit constraints included reading and following the firstmate-coding-guidelines skill before editing, colocated tests for testable extension logic and snapshot regeneration, shellcheck-clean changed bin/ scripts, no changes to supervision semantics beyond these fixes, reporting a needs-decision line if the root cause proved different, and never stopping/restarting the shared no-mistakes daemon.

What Changed

  • Pi, pi-signed, and omp primary extensions (watch, turn-end guard, branch supervision) now write their loaded/generation state markers naming the lock-holder pid resolved by the ownership walk instead of the caller's own transient pid, so a descendant process (e.g. a compaction child) can no longer clobber the live session's markers and strand supervision continuity.
  • The branch eligible owner record is extended to a v2 format carrying the reserved sequence numbers, written on every publish and cleared on release; fm-wake-drain.sh rebuilds a lost or corrupt state/.branch-eligible-rows snapshot from that record under the queue lock before presenting, acknowledging, claiming, or reclaiming, and fm-wake-grant.sh refuses activation while a live different-pid owner holds the grant (same pid may still reactivate, dead owners stay replaceable).
  • Updated the turn-end guard and watcher-continuity docs to the new marker and owner-record contracts, and added regression coverage in tests/fm-wake-queue.test.sh plus extension, turn-end guard, and omp harness suites for descendant-clobbered markers, lost-snapshot rebuilds, and refused takeovers.

Risk Assessment

✅ Low: Both durability fixes are well-bounded, anchor their invariants at shared boundaries (the lock-holder pid and the queue-locked v2 owner record), carry executed behavioral regression tests for every claimed failure shape, and update the documented contract; the only residual note is a minor multi-reader maintenance hazard on the new record format.

Testing

Exercised the descendant-marker fix with a side-by-side regression driver that reproduces the bug on the base commit (marker names the transient descendant pid 20100 instead of holder 20097) and shows the fixed commit anchoring on the holder through both the init and session_start markLoaded paths, then ran the six targeted suites (turnend-guard, pi-watch, pi-branch, omp-harness, wake-queue, contributions) covering the marker anchoring across all four extensions and the lost-eligible-snapshot regeneration in drain and ack for both branch and main actors - all 286 tests pass with Node 22.24.2; three initial failures were environment artifacts (default node v18 cannot import .ts plugins, the ancestry-based omp-harness tests see the pi agent running this validation as a structural ancestor, and fm-pi-branch-extension.test.sh must run from the repo root), each reproduced and confirmed green once the environment was corrected, so no product defects were found.

Evidence: Base-vs-fixed descendant marker regression driver transcript

Source: Base-vs-fixed descendant marker regression driver transcript

=== base extension === lock holder pid: 20097 transient descendant (node): 20100 marker pid after init: 20100 marker pid after session_start: 20100 VERDICT: marker anchored on the TRANSIENT DESCENDANT (bug reproduced) === fixed extension === lock holder pid: 20097 transient descendant (node): 20159 marker pid after init: 20097 marker pid after session_start: 20097 VERDICT: marker anchored on the LOCK HOLDER (correct)

Descendant-marker regression: base (da9607d) vs fixed (077a914) fm-primary-turnend-guard.ts

Driver: a real node process writes state/.lock naming its parent as the holder,
imports the extension as a genuine descendant (the Pi compaction-child shape),
fires the session_start handler, and prints which pid the loaded marker records.

=== base extension ===
lock holder pid:              20097
transient descendant (node): 20100
marker pid after init:        20100
marker pid after session_start: 20100
VERDICT: marker anchored on the TRANSIENT DESCENDANT (bug reproduced)

=== fixed extension ===
lock holder pid:              20097
transient descendant (node): 20159
marker pid after init:        20097
marker pid after session_start: 20097
VERDICT: marker anchored on the LOCK HOLDER (correct)
Evidence: Targeted suite transcripts (turnend-guard, pi-watch, pi-branch, omp-harness, wake-queue, contributions)

Source: Targeted suite transcripts (turnend-guard, pi-watch, pi-branch, omp-harness, wake-queue, contributions)

Targeted suite transcripts (Node 22.23.2) for branch 077a914

########## tests/fm-pi-watch-extension.test.sh (run from repo root)
ok - Pi extension reports external healthy watcher output
ok - Pi watch extension marker anchors on the lock holder from a descendant process
ok - Pi custom tool exposes repair-only metadata and returns automatic-continuation guidance
ok - Pi redundant tool call returns ownership guidance and spawns no second child
ok - Pi scheduled retry remains extension-owned after another tool call
ok - Pi actionable close starts one successor before wake delivery settles
ok - Pi actionable output waits for predecessor close before successor restoration
ok - Pi dispatcher branch offer owns accepted wakes and falls back to main
ok - Pi dispatcher flags a fleet-wide heartbeat offer as branch-eligible
ok - a co-present check row neither vetoes nor rides a heartbeat into main
ok - every main-only check class still reaches main, never the supervision branch
ok - a captain-held signal trigger reaches main with routine rows present
ok - an unread pending-reply escalation keeps later stale aliases on main
ok - a mixed batch of two distinct files - one routine, one needs-decision - routes wholly to main
ok - a co-present needs-decision row neither vetoes nor rides a heartbeat into main
ok - heartbeat restoration failure stays on main
ok - watcher-failure repair stays with main even with a live, accepting branch listener
ok - under the away-posture record every actionable row is offered to the branch while broken-queue wakes and watcher-failure alarms still reach main
ok - Pi refused handling handshake is classified and not swallowed
ok - Pi hung successor falls back to one typed actionable wake
ok - Pi unretired successor falls back without an overlapping retry
ok - Pi late unretired closes resume classified supervision
ok - Pi clean empty close triggers a bounded continuity retry
ok - Pi established clean closes stop at the configured retry limit
ok - Pi close handler verifies session-lock ownership before successor launch
ok - Pi watcher arm distinguishes all session lock ownership states
ok - Pi session transitions auto-arm through a generation owner across /new /resume /fork/reload, stale callbacks, and quit
ok - Pi session replacement auto-arms and carries its in-flight actionable close
ok - Pi replacement replays a streaming follow-up before consumption
ok - Pi streaming-time wake delivery keeps the successor chain and replays only unconsumed wakes
ok - Pi retries a verified successor that failed during wake delivery once that delivery settles
ok - Pi replacement receives actionable closes after retirement timeout
ok - Pi replacement handoff tokens stay unique across fresh modules
ok - Pi replacement persistence failure keeps its predecessor until a successor commits
ok - Pi process-exit cleanup listener remains singular across session replacement
ok - Pi process-exit cleanup stops the attached arm child
ok - OpenCode plugins have an explicit ESM boundary even under a typeless parent package
ok - OpenCode watcher plugin uses the effective FM_HOME state
ok - OpenCode watcher plugin sources the effective config
ok - OpenCode watcher plugin requires session lock ownership
ok - OpenCode watcher coordinator respects primary scope
ok - OpenCode watcher plugin starts one successor before wake prompt delivery settles
ok - OpenCode pre-ready actionable close preserves its successor
ok - OpenCode hung successor falls back to one typed actionable wake
ok - OpenCode unretired successor falls back without an overlapping retry
ok - OpenCode late unretired closes resume classified supervision
ok - OpenCode clean empty close triggers a bounded continuity retry
ok - OpenCode established clean closes stop at the configured retry limit
ok - OpenCode close handler verifies session-lock ownership before successor launch
ok - OpenCode watcher plugin coordinates with the turn-end guard
ok - OpenCode healthy arm output does not suppress the turn-end guard

########## tests/fm-turnend-guard.test.sh
ok - fm_supervision_unhealthy: false with no state/*.meta at all
ok - fm_supervision_unhealthy: true with in-flight task and no beacon ever
ok - fm_supervision_unhealthy: true with in-flight task and a beacon far outside the grace window
ok - fm_supervision_unhealthy: false with in-flight task and a fresh beacon
ok - fm_supervision_status: FM_SUP_QUEUE_PENDING tracks state/.wake-queue
ok - fm_supervision_needed: X-mode relay poll needs supervision
ok - fm_supervision_unhealthy: source-only home needs supervision
ok - fm_supervision_needed: a registered custom check needs supervision with no task in flight
ok - fm_supervision_needed: a registered check whose bytes drifted still needs supervision
ok - fm_supervision_needed: false for a check.sh with no registration binding
ok - fm_supervision_needed: a task PR poll without a trust binding is not a registered custom check
ok - fm_supervision_status: the relay shim is not counted as a registered custom check
ok - fm-turnend-guard: silent no-op with nothing in flight
ok - fm-turnend-guard: blocks when a fresh beacon has no live watcher lock
ok - fm-turnend-guard: non-Claude path blocks a source-only home
ok - fm-turnend-guard: blocks on a dead watcher lock even when the beacon is fresh
ok - fm-turnend-guard: silent no-op with a live watcher lock and fresh beacon
ok - fm-turnend-guard: healthy non-Claude harness paths ignore Claude episode contention
ok - fm-turnend-guard: blocks on a live watcher lock with an ancient beacon
ok - fm-turnend-guard: blocks with the exact required reason in the primary when unhealthy
ok - fm-turnend-guard: blocks from active FM_HOME state, not only repo-root state
ok - fm-turnend-guard: X-mode repair reason sources the cadence config
ok - fm-turnend-guard: X-mode-only supervision remains guarded in default mode
ok - fm-turnend-guard: registered-check-only supervision is named in the block banner
ok - fm-turnend-guard: ignores stale repo-root state when FM_HOME is set
ok - fm-turnend-guard: uses FM_STATE_OVERRIDE ahead of FM_HOME/state
ok - fm-turnend-guard: stop_hook_active=true always allows the stop (never blocks twice in one turn)
ok - fm-turnend-guard: blocks a blind turn end in a secondmate's own home (.fm-secondmate-home no longer excludes it)
ok - fm-turnend-guard: idle-by-default - silent in a secondmate home with nothing in flight
ok - fm-turnend-guard: stop_hook_active=true allows the stop in a secondmate home (never blocks twice in one turn)
ok - fm-turnend-guard: secondmate deferred-death recovery - silent while watched, forces re-arm once the watcher exits
ok - fm-turnend-guard: inert in a secondmate's own child worktree (linked git worktree) even when unhealthy
ok - fm-turnend-guard: blocks a blind turn end in a treehouse-leased LINKED secondmate home (marker force-include)
ok - fm-turnend-guard: an invalid (empty) marker cannot spoof inclusion; linked worktree stays exempt
ok - fm-turnend-guard: a non-ASCII marker cannot spoof inclusion; linked worktree stays exempt
ok - fm-turnend-guard: inert in a crewmate/scout task worktree (linked git worktree) even when unhealthy
ok - fm-turnend-guard: fails open (never blocks) when jq is missing
ok - fm-turnend-guard: silent no-op on empty stdin
ok - fm-turnend-guard: runs well under the generous timing margin (0s)
ok - fm-turnend-guard-grok: forces one explicitly marked same-session resume when the shared predicate blocks
ok - fm-turnend-guard-grok: legacy environment loop guard prevents a nested resume loop
ok - fm-turnend-guard-grok: native false delegates blocking feedback with zero resume processes
ok - fm-turnend-guard-grok: native true remains bounded and starts no resume process
ok - fm-turnend-guard-grok: both spellings are typed and camelCase has deterministic precedence
ok - fm-turnend-guard-grok: malformed, invalidly typed, and missing-prerequisite payloads start neither path
ok - fm-turnend-guard-grok: missing jq and no-supervision-needed stops stay silent and bounded
ok - tracked .claude/settings.json entries: 5 inert under grok, the documented subagent exception still armed, all live under Claude
ok - .codex/ho

... [14009 bytes truncated] ...

oaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - registered custom check output is queued before cadence suppression
ok - concurrent drains replay until one post-handling acknowledgement consumes records
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 4 --recovery-generation 4116583.1790057370.Yffi2A
ok - drain collapses obvious duplicate heartbeat and signal records
ok - drain asserts watcher liveness: warns on a lapse, stays silent for a live watcher with a fresh beacon
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 8 --recovery-generation 4119779.1790057376.UOZgM7
ok - structural signal enrichment is separate, deduped, home-local, and tier-zero for other wakes
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 13 --recovery-generation 4120833.1790057378.1ljAcz
ok - every readable unread status line is annotated in full while invalid status files preserve their raw wakes
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 4122803.1790057381.9Byhh3
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 4122803.1790057381.9Byhh3
ok - slow annotation releases the append lock and a deleted status file fails open
ok - a branch-actor scoped ack never swallows an unacked main-owned row, and main's later drain sees exactly what remains
ok - main drain and acknowledgement exclude an active branch grant
ok - a branch-held row raises no queued-wake warning for main, and the same row is presented and acknowledged once the grant clears
ok - a queue that cannot be counted keeps the queued-wake alarm up
ok - structurally unusable rows are retired by main alone, leaving every remaining row presentable and acknowledgeable
ok - branch grant cannot take a row already claimed by main
ok - actor ownership filtering precedes same-key deduplication
ok - main reclaims rows granted to an exited branch owner
ok - a branch-actor drain with no eligible-row snapshot refuses loudly instead of draining nothing
wake drain: restored a lost branch-eligible row snapshot from the live owner record
ok - a lost branch-eligible row snapshot is rebuilt from the live owner record for both drain and ack
ok - a main drain rebuilds a lost eligible snapshot and stays fenced out of the branch rows
ok - grant activation refuses a live foreign owner while allowing generation bumps and dead-owner takeover
ok - a released grant cannot be resurrected from its own record
ok - an idempotent republish leaves no temp files and keeps the recorded list
ok - main drain and acknowledgement re-derive a lost or corrupt presented claim
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation existing
ok - wake append publishes atomic recovery evidence before durable rows
ok - wake drain: generation-less legacy wakes are adopted and acknowledged
ok - wake drain: a stale acknowledgement cannot retire or consume a newer recovery episode
ok - wake drain: an acknowledgement that consumes nothing says so and names the exact command for the current wake
ok - wake drain: a branch acknowledgement that consumes nothing names the exact command for its granted wake
ok - wake drain: recovery acknowledgement failures are explicit and retryable
ok - interruptions preserve durable rows until post-handling acknowledgement

########## tests/fm-omp-harness.test.sh (run via systemd transient service so no pi process is in the ancestry; the suite's ancestry assertions otherwise see the agent running this validation)
ok - fm-harness: omp detects by its anchored name; the marker is a precedence override that needs real omp ancestry
ok - session lock and tmux liveness: omp is anchored, decoys stay out
ok - fm-spawn: the omp launch line clears markers, pins posture, and wires the state-resident extension
ok - fm-spawn: omp model validation is scoped to providers the listing can prove
ok - fm-spawn: a real omp secondmate launch relies on auto-discovery while crewmates load one -e
ok - fm-spawn: the config/secondmate-harness model pin is validated against the omp catalog before launch
ok - omp extension: agent_start busy, willContinue stays busy, plain agent_end idle, turn_end a notification
ok - control, composer, and supervision-model tables carry omp's verified values
ok - fm-wake-lib: the omp ownership proof is keyed on its own extensions and gates the hand-off tolerance
ok - .omp turn-end guard: digest delivery, seatbelt block, one compelled continuation, flagged stop stands down
ok - .omp turn-end guard: the loaded marker anchors on the lock holder from a descendant process
ok - .omp watch extension: fm_watch_arm_omp arms once, repeats as a no-op, and delivers an actionable close as one follow-up
ok - .omp watch extension: the loaded marker anchors on the lock holder from a descendant process

########## tests/fm-contributions.test.sh
ok - only required-captain contributions are rows; other actors are counted
ok - replaced-head verdict is stale and cannot create a captain requirement
ok - unchecked ownership is disclosed and cannot prove silence
ok - newest check with no verdict is distinct from passing and pending
ok - new maintainer comment wakes once and stays pending until acknowledged
ok - new maintainer review wakes once and stays pending until acknowledged
ok - new maintainer inline wakes once and stays pending until acknowledged
ok - ready-for-pr on a filed issue becomes a planning wake
ok - a fresh open issue remains measured maintainer triage
ok - an absent check lane remains missing across repeated observations
ok - mixed freshness retains measured captain work and discloses the gap
ok - malformed durable evidence cannot prove silence
ok - a transient ready-for-pr label wakes and its exact acknowledgement survives replay
ok - recorded judgment keeps its exact head and is stale immediately on a published replacement
ok - a current forge observation refreshes a verdict after a replacement
ok - an unavailable current head leaves verdict freshness unknown
ok - away yolo delivery is fleet work without granting merge authority
actionable: PR https://github.com/o/r/pull/8 is registered but its ready line did not reach the parent channel (rc=3)
ok - cross-home away yolo delivery is fleet work
ok - retired ownership persists and unsupported forge remains visibly unmeasured
ok - unsupported forge coverage is disclosed without inventing fleet work
ok - held unsupported forge coverage remains unmeasured
ok - shared contribution signal wakes once while retaining both acknowledgements
ok - watcher keeps observer diagnostics separate from contribution wakes
ok - expired child unsupported-forge coverage remains unmeasured
ok - watcher surfaces one newly durable contribution signal without re-ringing it
ok - parent consumes measured child coverage and refuses expired child silence
ok - unreadable pending signals refuse an empty-inbox claim
ok - budget exhausted mid-observation (exhaust) keeps the prior record and stays silent
ok - budget exhausted mid-observation (hang) keeps the prior record and stays silent
ok - a genuine forge failure inside the budget still records the error and wakes
ok - a URL owned by two tasks is observed once and every owner receives the result
ok - a merged or closed contribution settles once, is not re-read, and never wakes again
ok - a late owner inherits a terminal observation without a forge read or wake
ok - an open PR linked from a done task keeps being observed
ok - a later URL waits when fewer than fifteen seconds remain for its observation
ok - eight 3-second PR reads complete fresh within one 20-second poll cycle
ok - a genuinely unavailable forge records an error and wakes once per failure episode
ok - a late owner does not restart a shared forge failure episode

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-wake-lib.sh:2072 - The v2 owner-record five-line shape is now parsed independently in fm_wake_branch_owner_matches (fm-wake-lib.sh:2014), fm_wake_branch_owner_seqs (fm-wake-lib.sh:2072), owner_record_seqs_rewritten's three sed reads (bin/fm-wake-grant.sh:40), and the activate refusal's sed -n '2p' (bin/fm-wake-grant.sh:66). No reachable bug exists today - each reader validates before use and all writers hold the queue lock - but a future format change must keep four readers in lockstep; a single record reader in fm-wake-lib.sh would be the natural consolidation point. Purely a maintenance note on code introduced by this change.
✅ **Test** - passed

✅ No issues found.

  • Manual regression driver: real node descendant writes state/.lock naming its parent as holder, imports fm-primary-turnend-guard.ts from both da9607d (marker records the transient descendant pid - bug reproduced) and 077a914 (marker records the lock holder pid) across both init and session_start markLoaded paths
  • bash tests/fm-turnend-guard.test.sh (Node 22) - 90 ok, includes '.pi primary extension: the loaded marker anchors on the lock holder from a descendant process'
  • bash tests/fm-pi-watch-extension.test.sh (Node 22, from repo root) - 51 ok, includes 'Pi watch extension marker anchors on the lock holder from a descendant process'
  • bash tests/fm-pi-branch-extension.test.sh (Node 22, from repo root) - 46 ok
  • bash tests/fm-omp-harness.test.sh (Node 22, via systemd transient service so no pi process is in the ancestry) - 13 ok, includes descendant-marker tests for both .omp extensions
  • bash tests/fm-wake-queue.test.sh (Node 22) - 48 ok, includes 'a lost branch-eligible row snapshot is rebuilt from the live owner record for both drain and ack', 'a main drain rebuilds a lost eligible snapshot and stays fenced out of the branch rows', and the runtime log 'wake drain: restored a lost branch-eligible row snapshot from the live owner record'
  • bash tests/fm-contributions.test.sh (Node 22) - 38 ok
✅ **Document** - passed

✅ No issues found.

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

✅ No issues found.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: stamped waiting-ci.

HEAD fcdc7b369214ae6f0cbd9b461b2acc97af4c76b7. Attestation MATCH. workflow-zero yes. MERGEABLE.

contract-class: restore — tip restores two specified broken paths: (1) extension loaded markers record the lock-holder pid from the ownership walk instead of a descendant process.pid; (2) lost/corrupt state/.branch-eligible-rows rebuilds from the live v2 owner sequence list under the queue lock so drain/ack is not wedged. Cold-start (no lock) still writes own pid; foreign live holder still writes nothing. Unconfigured path keeps the same supervision semantics with correct ownership evidence.

VISION: One captain/interface aligns (durable supervision evidence); Authority aligns (activation refuses live foreign owner); Scripts/judgment aligns; Restart aligns (markers + owner record survive churn); Delegation aligns (wake drain spine); Fleet/vendor aligns (Pi + omp ports); Scope aligns. Align: strengthens refusal/continuity under process churn.

Security skim: no workflow changes; no secret handling. Fork CI approved this pass: runs 35638392306 (CI), 35638392488 (Require no-mistakes) — now queued.

Overlaps with open #5174 on Pi/omp watch extensions, bin/fm-wake-lib.sh, and continuity docs. Will reconsider auto-merge only when CI/NM fully green on this HEAD.

Firstmate-flag: no.

@ardydedase
ardydedase force-pushed the ardy/pi-extension-markers-descendant-clobber branch from fcdc7b3 to 816d9a7 Compare September 22, 2026 01:24
@ardydedase ardydedase changed the title fix(bin): anchor supervision markers and branch grants on the lock holder fix(bin): anchor supervision markers and eligible-row recovery on the lock holder Sep 22, 2026
@ardydedase
ardydedase force-pushed the ardy/pi-extension-markers-descendant-clobber branch from 816d9a7 to 182c290 Compare September 22, 2026 06:22
@ardydedase ardydedase changed the title fix(bin): anchor supervision markers and eligible-row recovery on the lock holder fix(bin): anchor supervision markers and wake grants on the lock holder Sep 22, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: stamped waiting-ci.

HEAD 182c2905751c671aa89d4a31d5d0cca2d8121463 vs main da9607d7bb945e499fd70d4bf548edb37247d0cc. MERGEABLE. Attestation MATCH (head_sha equals tip).

contract-class: restore — tip restores two already-specified broken paths: (1) extension loaded markers record the lock-holder pid from the ownership walk instead of a descendant process.pid; (2) lost/corrupt state/.branch-eligible-rows rebuilds from the live v2 owner sequence list under the queue lock so drain/ack is not wedged. Cold-start (no lock) still writes own pid; foreign live holder still writes nothing.

VISION: One captain/interface aligns (durable supervision evidence); Authority aligns (activation refuses live foreign owner); Scripts/judgment aligns; Restart aligns (markers + owner record survive churn); Delegation aligns (wake drain spine); Fleet/vendor aligns (Pi + omp ports); Scope aligns.

Overlap with merged #5174: #5174 (retain Pi watcher predecessor / handoff phase) landed and is a different fix. Main tip still writes process.pid in marker publish; #5172's lock-holder anchoring + eligible-rows regeneration remain distinct — not leftover-to-close.

Fork workflows approved this pass: CI 35694571123, Require no-mistakes 35694571138/35694604724. Will reconsider auto-merge only when CI/NM fully green on this HEAD (restore + MATCH + safe).

Firstmate-flag: no. Security FYI: none. closes-claim: n/a (no Fixes).

actions-user and others added 8 commits September 22, 2026 18:42
…lder

Pi and omp primary extensions recorded their loaded markers with process.pid,
so a transient descendant pi process (a compaction child) that loaded the
extensions rewrote the markers with its own pid; the live lock-holder session
then read healthy extensions as foreign and the lazy branch marker audit
depended on who happened to load first. All five markers now anchor on the
lock-holder pid the ownership walk resolves to, keeping process.pid only on
the cold-start path where no lock exists yet.

The 2026-09-17 branch recovery also lost the eligible-rows snapshots to
descendant-process churn, wedging the drain and acknowledgement until the
snapshots were hand-regenerated. The branch owner grant record now carries the
published seq list (v2 record), activation refuses a live different-pid owner,
release clears the list, and the branch drain and acknowledgement rebuild a
lost or corrupt snapshot from that record under the queue lock before
presenting, acknowledging, or reclaiming. docs/watcher-continuity.md records
the new durable contract.
The review round caught two real hazards the new code introduced. The ack
section calls restore_branch_eligible_rows_locked with its own live ack temp,
but the restore reassigned the shared DRAIN_TMP and cleared it on success, so
an ack-window rebuild that actually fired would redirect the following awk to
an empty filename and fail the acknowledgement it was added to protect, while
orphaning the ack temp. The restore now uses a dedicated local temp it cleans
on every failure path, leaving the caller's variable untouched.

In fm-wake-grant.sh, publish's idempotent republish path kept the rows temp in
the shared TMP when owner_record_seqs_rewritten reassigned it for the owner
record, leaking the rows temp on every same-content republish and orphaning it
whenever the owner-record mktemp failed. The rows temp is now removed on the
replace=0 path and the owner-record rewrite uses its own trap-free dedicated
temp with explicit cleanup, so no path can leak either temp. A colocated test
asserts an idempotent republish leaves no temp files and keeps the recorded
sequence list.
…ck atomic

Stock macOS Bash 3.2 reparses quotes inside a heredoc nested in command
substitution, so the three new JavaScript comments in the descendant-marker
test each drop their apostrophe to keep the body quote-balanced while the
heredoc stays nested, preserving the subshell holder that keeps the test
robust when the test shell itself is pid 1.

The contributions fake forge advanced its clock with a truncate write, so a
concurrent reader could observe an empty clock that bash arithmetic treats
as 0 and reset the budget window; advances now rename a unique temp into
place atomically.
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.

3 participants