Repository navigation
fix(daemon-contracts): bound stale-claim recovery disposal - #4952
Conversation
A recovery transaction awaited its gateway's shutdown with no bound. After the durable acquisition deadline or a cancellation abandoned an owner load that never settles, gateway.shutdown() stays pending by design, so the stale-claim caller (open, startup reconciliation, device release --stale) hung forever. createOwnerScopedDeviceClaimReconciler now waits at most 5 s for disposal through settleWithin. When the budget expires it emits device_claim_recovery_dispose_pending, keeps an earlier retained reason or primary error, and turns a reconciled outcome into the typed recovery-dispose-pending retention so the claim file stays on disk. A late disposal failure is still reported as device_claim_recovery_dispose_failed with afterBudget: true and never replaces the returned outcome. Closes callstack#4106 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for working on this. At 3672be2 the bound works, but the pending disposal is left with no owner after the budget. device-claim-owner-recovery.ts:116 detaches the promise, and nothing in the process awaits it or reports it. Two routes are affected. In daemonless Could the bound and the outcome mapping stay as written, and only the ownership move? For example, Not blocking, and fine to take or leave: the disposal wait at The required evidence is present. The two non-passing checks are cancelled |
|
Note 🤖 Gemini 4 Neon responding on behalf of samanyudas Updated in
|
|
Thanks for the follow-up. The PR is ready: the earlier findings from 3672be2 are fixed, and nothing from that review remains. At eae9e56, late disposals now drain through one tracker per process on both routes: daemon close under the owner budget, reporting pending work at the deadline, and the CLI drain before exit. Each route has tests. CI is green, with 15 checks and none failing, and there are no conflicts. Not blocking, and fine to take or leave: the disposal outcome flags and the late re-check in device-claim-owner-recovery.ts guard a race that cannot drop a report, because a handler attached to an already-settled promise still runs, so attaching the late handlers directly on deadline would remove that state; and |
|
Note 🤖 Gemini 4 Neon responding on behalf of samanyudas Applied both non-blocking nits in
|
|
Thanks for the follow-up change. The delta at 8986f58 keeps every stale-claim recovery disposal tracked, and the earlier clean review still applies to the simplified code. All 15 checks pass at this commit, and no conflicts are known. Not verified here: the tests were not run locally, so the claim that both the daemon and CLI routes still drain every active recovery disposal rests on reading the code and on the passing checks. Please confirm that with a local run of the bounded-close tests before merge. Not blocking: the re-drain test at daemon-runtime-bounded-close.test.ts#L669 waits until the reconciler has registered its lifecycle before it calls close, so the first drain already sees the pending lifecycle and the test still passes if the second drain is removed; gating gateway composition until root shutdown starts would cover it, and this can be taken or left. Could daemon-runtime.ts await the root gateway shutdown attempt and then drain the claim-recovery tracker once within the same owner budget? Registration already observes each lifecycle as it runs, so the initial drain does not start any cleanup. |
|
Note 🤖 Gemini 4 Neon responding on behalf of samanyudas Applied the single-drain simplification in
|
|
Thanks for the update. This PR is ready on review at 99da454, and the re-drain change fixes what the earlier review left open. The re-drain test note on |
Summary
Stale-claim recovery awaited
gateway.shutdown()with no time limit, so a never-settling runtime owner load heldopen, startup reconciliation, anddevice release --staleopen past the 5 s acquisition deadline.Now
createOwnerScopedDeviceClaimReconcilerbounds disposal withsettleWithin(5 s, dynamically imported) and requirestrackDisposalso every recovery transaction is owned from gateway composition through disposal settlement and late diagnostic flush (device_claim_recovery_dispose_settled/device_claim_recovery_dispose_failedwithafterBudget: true). Daemon close drains tracked disposals underownerMs(re-draining after root shutdown, keepingplatformOwners: pending/hasUnfinishedWork()true on deadline). Daemonlessdevice release --stalewrites outcomes at the bound and keeps Node alive until tracked disposals drain before exit.Closes #4106.
Before / after
Validation
Head
8986f58a077053b4e2168c1e9995d0259aa45d53, baseb03e32bf7a363b3aa91258dbe8e66af022d94f05.8986f58a0:format,lint(0 warnings/errors),typecheck,fallow(0 issues in 26 files),build, 6 recovery/daemon-close suites (73/73), and 11 touched suites includingeager-closure-budgets(1,020/1,020). Fullcheck:affectedpassed oneae9e563d; CI validates8986f58a0.Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved.
Created with Claude Opus 5.5 and Gemini 4 Neon in T3 Code.