Repository navigation
Description
Problem
Capture completion at teardown is raced against hardcoded timers instead of awaited as an event, and the timers are shorter than what the hosts grant. Passes are abandoned while the host is still waiting for us.
Current bounds, all ours:
src/capture/runtime.ts—DRAIN_LIMIT_MS = 1000, raced indrainInFlight().src/adapters/oh-my-pi/extension.ts—if (!config.capture) await capture.settle(500), withsettle()implemented asPromise.raceagainst a timer.
Measured ceilings on the installed hosts:
| Host | session_shutdown in print mode |
Handler budget the host enforces |
|---|---|---|
| Pi 1.7.0 | yes (reason=quit) |
none — an observer handler sleeping 3000 ms was awaited to completion |
| Pi 0.74.2 | yes (reason=quit) |
none |
| oh-my-pi 19.2.1 | yes | 2000 ms per handler, host-reported: handler timed out after 2000ms |
A pass that mines a transcript measured 3.4 s to save in a long-running session. The cost of the current bounds is already recorded in this repository: passes that logged capture_cost with no row, 9 of 12 in one sample and 6 of 12 in a controlled A/B.
Required shape
- Cleanup awaits the capture pass. No
Promise.raceagainst a timer on the teardown path, in core or in an adapter. - The model request owns its own timeout and abort signal, so the completion event fires on answer, error, or request timeout. This bound is a property of the request and must not be expressed as a teardown duration.
- Abandoning a pass must cancel it. Resolving a bookkeeping promise while the request continues is not cancellation.
- A host that enforces a handler budget declares it; the core verifies the declaration at install time and uses it to decide whether to start a pass at all. Deriving the value at runtime from a hardcoded per-harness number is not acceptable.
- A pass that does not complete reports a reason. The inference-from-missing-telemetry path can be retired once nothing is abandoned.
Acceptance criteria
- Both teardown bounds are gone; a mutation that reintroduces a numeric bound on the cleanup path fails a test that names it.
- With a provider that answers slower than any previous bound, a print-mode run on a host that awaits handlers saves the row. Prove it on a real host, not only a fake.
- With a provider that never answers, the run terminates because the request's own timeout fires; the conformance fake includes that host.
- An abandoned or cancelled pass aborts its in-flight request; a test observes the abort.
- A declared handler budget that the host does not honor fails at install time, alongside the verification required for other declarations.
- On a host whose declared grant is shorter than the work, the run states that capture did not run and why, rather than starting work that cannot land.
Existing assertions that must change
integration/oh-my-pi/capture-shutdown-runner.ts asserts teardown finishes under 1900 ms and that the unanswered scenario saves nothing. Those assertions pin the current abandonment, so any correct implementation fails them; the expectations must be rewritten with the behavior, and the rewrite has to stay falsifiable.
Out of scope
Provider billing behavior for aborted streams, and any per-harness timing constant that merely replaces the existing ones.
Activity
ocsi-architect commentedon Nov 28, 2026
Sequencing: this ticket is not startable yet, and that is deliberate.
It rewrites teardown in core, while the core/adapter seam is still moving through the shared-interface work. Doing it before that seam lands means writing the change twice — once against code that is being relocated, once against its new home — and the second write is where mistakes hide.
Start after the adapter isolation lands. At that point the work has a stable shape:
Host budgets measured on real installs, so nobody has to re-derive them: one host awaits extension handlers to completion in print mode with no timeout; the other enforces 2000 ms per handler. A pass that mines a transcript measured 3.4 s, which is why a per-harness constant is the wrong instrument here.
fix(pi): join capture completion during cooperative shutdown (abogart…
ocsi-architect commentedon Nov 29, 2026
Satisfied by the shared capture fix on the open host-contract pull request, and I verified the structural claims rather than reading the commit message: the drain timer is absent from
srcat that head, completion is joined as an event, the request owns its deadline and abort signal with typed reasons, and the host handler deadline is read from the installed host and probe-verified against its running dispatcher instead of being hardcoded. One item still open in reporting, tracked separately under #603 (capture stop reasons that never reach the human report). Closing this ticket is reasonable at merge time; the core teardown timers are gone.fix(capture): await passes and bound provider requests (#578)
chore(release): 0.39.0 [skip ci]
chore(release): 0.40.0 [skip ci]
ocsi-architect commentedon Nov 29, 2026
Closed — shipped in 0.40.0 and verified on
mainatdb2c6f3, not from the diff.DRAIN_LIMIT_MS: zero occurrences anywhere undersrc/.settle()insrc/adapters/oh-my-pi/capture.tstakes no argument, so the adapter joins completion instead of racing a timer, and the core drain awaits the in-flight set.Promise.racecalls insrc/are the shape the design keeps, named here because the second one will otherwise read like a violation:src/capture/request.ts:61races the provider response against the request's own abort signal. That is the single bound, owned by the model request.src/adapters/oh-my-pi/lifetime.ts:36is the startup capability probe, not a cleanup path. Its watchdog is derived from the grant the host declares —max(10_000, declared * 2)— and its failure mode is a loud installation error rather than a silent drop.test/capture/request-lifecycle.test.tsonmain: 5 pass, 0 fail, including "a request deadline starts at request creation, independently of teardown".