fix(core): reconcile a platform close where it happens, not at the ne…
…xt tick
CI caught this; a local run could not. Reconciling live codecs against
their `state` only at sample time and census time loses a race with the
GC: the codec is unreachable the moment the error callback returns, and
if collection wins, the finalizer files it as collectedUnclosed — the
false leak report this change set exists to remove. macOS sampled in
time and passed. Linux collected first and failed all four assertions.
The error callback is the deterministic point. The spec closes the codec
at step 2 and invokes the callback at step 4, so by the time it runs the
resource is already gone and the codec is still reachable. Record it
there. The sampler keeps its reconciliation as a backstop for a platform
close that arrives by some other path.
The codec does not exist until Reflect.construct returns, so the wrapped
init closes over a holder whose `codec` getter derefs a WeakRef — the
instrumentation must not be what keeps a codec alive.
The test now samples 30s apart, so a fast tick cannot rescue it on a
lucky machine: only reconciliation at the error callback can pass it. It
reproduces CI's exact four failures when that reconciliation is removed.
Suite 42 pass, typecheck clean.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>