fix: finish session captures through lifetime bindings

Closed
TH
2mo ago
+307-435

Summary

Capture finishing and forced cleanup now use a lifetime-bound session binding. The coordinator keeps the captured handle/fence across native awaits; clearing checks that the same lifetime and resource still occupy the slot. A rebuilt record keeps its unrelated changes.

Capture-kit no longer accepts a whole session record or sessionSlot.replace projection. Daemon field owners provide explicit slot updates. Close, shutdown, audio, perf, app-log and record callers use the shared finish operations; shutdown and record-only removal retire captured lifetimes.

sequenceDiagram
  participant F as Finish operation
  participant N as Captured native handle
  participant S as Session binding
  F->>S: Read current owned resource
  F->>N: Finish captured handle
  Note over S: Record may rebuild or address may be reused
  N-->>F: Completion
  F->>S: Clear only matching lifetime and handle/fence

Depends on #3136. Ref #3116. Thirty-six files, 661 gross changed lines. Recording/journal and remaining session writers migrate next.

Validation

Tested 1376a9e26c: quick checks, Fallow and exact-head affected checks pass, including 277 related files / 1,726 tests. All 73 focused capture/teardown tests pass.

Removing clear, bypassing handle comparison or using address-only clearance each fails a held-finish control; restored code passes 19/19. R68 rejects former package writers and allows the daemon owners. Independent read-only review has no findings. CI-owned coverage/provider and live device evidence remain pending.