refactor: bind session resources to stable lifetimes - #3135
Conversation
Size Report
Startup median (7 runs, lower is better):
|
There was a problem hiding this comment.
All reported issues were addressed across 12 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
At e180d9f, one change is needed before merge. closeAdmission() at daemon-runtime.ts:751 runs before Not blocking, take or leave: the shutdown test in session-store-lifetime.test.ts:95 calls Could this land together with #3140? On checks, Smoke Tests failed in The close teardown route changed, since teardown now re-resolves the record and can throw Before merge, the teardown snapshot fix and its shutdown-route test need to land, and Smoke needs a green run that reaches open and close. |
e180d9f to
a760a6a
Compare
a760a6a to
4011de9
Compare
4011de9 to
4e4f87d
Compare
4e4f87d to
4ef85e9
Compare
|
4ef85e9 to
5aa8134
Compare
|
Thanks for the update. The 5aa8134 head still has one defect from the earlier review (#3135 (comment)). The daemon_startup_failed Smoke failure no longer stands: all 19 checks pass, including four Smoke lanes, and no conflicts are known. In The rule: admission closes atomically with the teardown snapshot, so every publish or adopt either lands in the set that Not blocking: Is there a smaller owner for the new I did not run the tests, On the open inline threads: the thread on |
5aa8134 to
2392e8e
Compare
|
The iOS failure at 2392e8e is run 37170774472: |
There was a problem hiding this comment.
All reported issues were addressed across 58 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
9178384 to
558ef2b
Compare
There was a problem hiding this comment.
All reported issues were addressed across 15 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
|
Updated review fixes are included at All eight actionable inline findings are fixed and resolved: join admitted dispatches before retirement, close admission with the teardown snapshot, fence log clearing and capture completion, retain the latest observed slot when clearing mismatches, protect fixture cleanup and assert refusal outside the swallowed-error boundary. Shared capture binding lives behind a dedicated package facet; daemon and fixture adapters exercise the same policy. Four fresh controls were red before their fixes; all 26 focused binding/transition/shutdown controls pass. All 759 eager-closure controls and twelve binding controls pass after the dedicated-facet correction, without relaxed budgets. Current dependencies, exact-head gates and evidence still required. Fresh GitHub/native evidence and approval remain separate; pending or canceled runs are not passing evidence. The user handles all merges. |
32487f8 to
9644a9f
Compare
|
This PR is ready. At 9252d82 the earlier blocking finding from #3135 (comment) is fixed, and all 19 checks pass, so there is nothing to attribute. There are no conflicts. Nothing else must happen before merge. Not blocking: Of the review threads, the P2 and P3 threads on clearStoppedSessionAppLog, perf recording, the record stop action, the layering kill criterion, the shutdown test setup, the finalize refusal assertion and the session-binding fence are fixed at this commit: #3135 (comment), #3135 (comment), #3135 (comment), #3135 (comment), #3135 (comment), #3135 (comment) and #3135 (comment). The P1 thread on the in-flight join is also fixed, except for the missing time bound noted above: #3135 (comment). Two threads are benign and can be resolved: the ref.session divergence predates this PR and capture updates do not write those fields (#3135 (comment)), and session-close not calling retire(ref) is unreachable today and owned by the stacked #3140 (#3135 (comment)). No P1 or P2 thread still applies, and no lower-priority threads remain. I did not run tests, check:affected or mutation checks. I judged each new test by reading the old code against it. I reviewed only the logical change after the rebase, and treated the upstream files as out of scope. |
|
I kept the dispatch join before runner handoff and session disposal. Racing the join against a timer and then continuing teardown would let unfinished dispatches overlap resource cleanup; closing session admission does not stop native effects already dispatched. The five-second constant in server-shutdown.ts bounds connection closure, not completion of device work. Explicit stop/retirement already has a bounded TERM/KILL policy and process-birth verification. I have not added a separate timed teardown path or claimed every handler honors cancellation. A bounded join needs an explicit terminal policy for unfinished operations first; this remains a non-blocking liveness concern rather than a reason to weaken the join invariant. That distinction also matches the timeout-ownership gap in the architecture audit. |
|
Thanks, that reasoning holds. A timed join without a terminal policy for unfinished operations would let device work overlap cleanup, which is worse than a slow shutdown. Keeping the join as is makes sense; the liveness gap belongs with the timeout-ownership follow-up. The verdict at 9252d82 is unchanged. |
Summary
Capture session lifetimes with SessionRef and carry them through resource adoption/disposal. Join admitted dispatches after socket closure, then close admission atomically with the teardown snapshot. Fence log clearing and recording completion against successor sessions. Share the capture-binding policy between production and transition controls.
62 files; part of #3116. Base: main.
Validation
Commit
9252d8251fe1c2d95250f7b84e463db9a87e3e1c. The exact-headpnpm check:affected --base 294dc7d024 --rungate passed. Test Files 1633 passed (1633); Tests 13343 passed | 1 skipped (13344); Test Files 1 passed (1); Tests 12 passed (12).Fresh GitHub CI and review remain separate. Required native confirmation remains pending; physical recording-health proof is blocked by Xcode signing. The user handles merges. Dependencies, regression evidence and remaining checks.