Repository navigation
fix(reef): avoid shutdown delays during friend reconciliation - #129016
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Land-ready verificationPrepared head: 3c1c502908067bc19bd85d7fe846197a2234feba Focused local proof:
Exact-head hosted CI is green: run 32811365956. Proof gap: the patched head was not deployed to the operator canary because running an unmerged branch there would mutate production. The changed owner boundary is covered by real local HTTP, exact-head hosted CI, and the native prepare gate. ClawSweeper's exact-head review publisher is still running and has published no rank-up moves. The latest comment was read immediately before merge; there are therefore no moves to skip or apply, and repository policy treats a queued/late publisher update as non-blocking. |
|
Codex review: needs maintainer review before merge. Reviewed August 25, 2026, 1:13 AM ET / 05:13 UTC. ClawSweeper reviewWhat this changesThe PR passes the Reef channel lifecycle abort signal through friend reconciliation and pairing-candidate relay requests, preventing shutdown from waiting for their request deadline. Merge readinessKeep open for normal maintainer landing: no blocking correctness or security finding was identified, and the protected maintainer-authored PR repairs the cancellation path at its lifecycle owner. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherReef is a bundled channel plugin whose account lifecycle refreshes relay friendship state before and during inbox operation. Those relay calls affect trust and pairing updates, while lifecycle shutdown must stop both the inbox and reconciliation work promptly. flowchart LR
A[Gateway stop or replacement] --> B[Reef account lifecycle]
B --> C[Friend reconciliation]
C --> D[Reef transport request]
D --> E[Relay friends endpoint]
B --> F[Lifecycle abort signal]
F --> D
C --> G[Trust and pairing updates]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +1, Tests +68. Total +69 across 5 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain one lifecycle-owned abort signal through both friend-list calls and the existing transport deadline, then land after exact-head required checks complete. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main starts reconciliation without its lifecycle signal, while the transport already supports combining a caller signal with its request deadline. The PR’s supplied real-local-HTTP scenario directly exercises that path, though this read-only review did not execute it. Is this the best way to solve the issue? Yes. Propagating the existing lifecycle signal through the lifecycle callback, friend manager, and existing transport timeout is the narrow owner-boundary repair; downstream shutdown guards would leave the stalled request alive. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ebc70fa1b3f6. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where stopping or replacing a Reef channel while friend reconciliation was waiting on the relay could leave the old account task running until the full relay deadline. That can exceed the Gateway's bounded channel-stop window even though the lifecycle has already been aborted.
The observed startup timeout itself remained retryable and Reef recovered to connected/ready; the defect was cancellation ownership during shutdown, not the timeout duration, retry policy, log severity, or peer-trust policy.
Why This Change Was Made
The Reef account lifecycle now passes its abort signal through both friend-list requests and the existing transport deadline, and it stops before dispatching local overdue-delivery notices after cancellation. The existing 15-second request deadline, 30-second reconciliation cadence, error reporting, serialization, and fail-closed trust checks are unchanged.
This PR is AI-assisted. I reviewed the source, live evidence, regression behavior, and final diff.
User Impact
Gateway shutdowns, reloads, and account replacements no longer wait for a stalled Reef friend-reconciliation request after the account lifecycle has ended. Transient relay failures during normal startup continue to recover as before, and unrefreshed or changed peer keys remain fail-closed.
Evidence
TimeoutErrorentries followed by Reef returning torunning,connected,lifecycle: ready, with a later promotion producing zero Reef timeout entries./v1/friendsrequest remained pending after 100 ms and settled after 804 ms only when its artificial 800 ms deadline fired.node scripts/run-vitest.mjs extensions/reef/src/channel.test.ts— 17 passed.node scripts/run-vitest.mjs extensions/reef/src/friends.test.ts— 21 passed.node scripts/run-vitest.mjs extensions/reef/src/transport.test.ts— 39 passed.node scripts/run-vitest.mjs extensions/reef/src/transport.timeout.test.ts— 3 passed.node scripts/check-changed.mjs -- extensions/reef/src/channel-lifecycle.ts extensions/reef/src/channel.ts extensions/reef/src/friends.ts extensions/reef/src/transport.ts extensions/reef/src/channel.test.ts— passed, including extension typechecks, lint, import-cycle, dead-code, and repository guards.