Repository navigation
fix: captureModel omitted inherits the session's model (#139) - #270
Conversation
autoCapture:true is already the explicit opt-in; requiring a second config key was a syntax tax whose failure mode was a silent disable. An omitted captureModel now resolves per capture: the ref the session.context hook last carried, else ctx.model.default.get(), and only when both are missing does the pass skip (warn once, reason no_model in evidence). An explicit invalid captureModel keeps the fail-closed setup behaviour. Every capture evidence line now carries model= so cost is attributable to a named model. autoCapture stays default off.
There was a problem hiding this comment.
Head reviewed: 118ef00e619dcbc1fae7df79e7f1a47a676e309a
Contract: #139 (authored by abogartz, trusted). Spec anchor 3ae9e1424330770a recomputed and equal to the frozen anchor comment — spec unchanged.
Acceptance, verbatim: "Red-first: autoCapture: true with no captureModel, against a fake host whose session.context carries a model ref, must fire a capture pass with that ref. Red on main today, where it disables instead."
Per-criterion evidence (measured at this head, not from the PR body):
- "Omitted
captureModelresolves to the per-session ref last seen onsession.context; elsectx.model.default.get(); only if both are missing warn and disable." — Resolution chain atsrc/capture/runtime.ts:178(modelRef ?? sessionModel(sid) ?? hostDefault()); ref recorded in thesession.contexthook atsrc/events.ts:115; warn-once + skip atsrc/capture/runtime.ts:191-198withreason=no_modelon the refusal line. Testscapture model inheritance (#139)cover all four branches (inherit, host default, both-missing skip, explicit wins) — green. - "Record
model=on every capture evidence line" —auto_capture_refused(no-workspace)runtime.ts:186;auto_capture_partial/auto_capture_refusedruntime.ts:242; the per-candidate outcome line incl.auto_capture_promotedruntime.ts:260;capture_lagvia new optionalmodelparamsrc/evidence/record.ts:155. Test assertsmodel=fake/session-modelon both the promoted and the lag line — green. Thereason=no_modelline carries nomodel=by definition (nothing resolved); acceptable. - "Keep
autoCapturedefault off" — no diff touches the default; existing default-OFF tests still green; heartbeat testarmed with NO captureModel: capture=ongreen.
Red-first differential (verified myself at merge-base 2d2fce7): copied only this PR's test files onto the base tree (src untouched, one test-side no-op shim for the not-yet-existing resetSessionModels export): 5 fail. The acceptance test fails with the stated reason — autoCapture is on but captureModel "" is invalid (expected "provider/id"); auto-capture disabled. and subscribeCalls never reaches 2; heartbeat reads invalid_model where on is expected. At head: bun test test/capture.test.ts 41 pass / 0 fail. Differential holds: fixed side clean, broken side fails for the stated reason.
Commands run (Bun, macOS):
bun run typecheck— exit 0bun run lint— exit 0, 503 warnings = main baselinebun run test— 924 pass / 19 skip / 0 failbun run test:e2e— 30 pass / 0 fail (src/ changed)
Tests review: additive only (+102/−3 in test/capture.test.ts, −3 lines are header comment + import line; test/harness.ts +14/−2 adds the model.default.get fake and threads model through the context-hook replay). No deleted assertion, no .skip, no widened tolerance.
Findings:
- P0: none.
- P1: none.
- nit:
src/capture/session-model.ts:31-34eviction is insertion-order FIFO, not LRU — a long-lived session's ref can be evicted while still active after 2000 distinct sessions; the capture then falls back to the host default. Bounded and harmless (fallback exists); the cap comment declares the rule. No action needed.
Final-gate re-check (verbatim, at filing time):
{"headRefOid":"118ef00e619dcbc1fae7df79e7f1a47a676e309a"}
[{"bucket":"pass","name":"test-windows"},{"bucket":"pass","name":"lint"},{"bucket":"pass","name":"test"},{"bucket":"pass","name":"smoke"}]
Human merges.
|
🎉 This PR is included in version 0.15.15 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #139
What
autoCapture: truewith nocaptureModelnow inherits the session's model instead of disabling. Resolution order: explicitcaptureModeloption → theModel.Refthesession.contexthook last carried for that session →ctx.model.default.get()→ only then skip (warn once,reason=no_modelon the refusal evidence line). An explicit but malformedcaptureModelkeeps today's fail-closed setup behaviour. Every capture evidence line (auto_capture_*,auto_capture_refused/_partial,capture_lag) now carriesmodel=so cost is attributable to a named model.autoCapturedefault off is unchanged.Requirements taken from comments (not the body)
3d34a63: finding stands —src/capture/runtime.tsstill disables the whole subscription whencaptureModelis missing/invalid (no.modelread from the session.context event). Acceptance is explicit red-first:autoCapture: truewith nocaptureModelagainst a fake host whosesession.contextcarries a model ref must fire a capture pass with that ref; red on main today, green after. No overlap with open PR fix: resolve session identity before authorizing merge/forget/undo (#260) #269." — implemented as stated; the capture logic lives insrc/capture/runtime.tssince the perf: a session never pays a cache bust for bytes it is not riding (#165) #166 extraction, and thesession.contexthook registration lives insrc/events.tssince Proposal: express gate outcomes as a discriminated union #167, so those are the files the named behaviour occupies on current main.Acceptance evidence
Red-first, measured:
2d2fce7: the acceptance scenario (autoCapture on, no captureModel, fake host whosesession.contextcarries{providerID:"fake",id:"session-model"}) fails withexpect(subscribeCalls).toBe(2)→ Received 1 — the subscription is never registered, exactly the stated disable.generate.calls[0].modelequals{providerID:"fake", id:"session-model"}.describe("capture model inheritance (#139)")intest/capture.test.ts: session-ref inheritance, host-default fallback,reason=no_modelskip with zero model calls when both sources are empty, explicit option wins over the session ref, andmodel=fake/session-modelon theauto_capture_promotedandcapture_laglines. Plus a heartbeat test: omittedcaptureModel→capture=on; explicit malformed →capture=invalid_model(unchanged).Commands run (measured, Bun 1.4.3, macOS)
bun run typecheck— exit 0bun run lint— exit 0; 503 warnings, identical to main baseline (measured on stashed tree: 503; zero delta)bun run test— 924 pass / 19 skip / 0 fail (six consecutive clean runs; the very first run afterbun installshowed 1 failure whose name I did not capture and which did not reproduce in six subsequent runs — consistent with the documented cold-start timing flakes, CI re-verifies)bun run test:e2e— 30 pass / 0 failbun test test/capture.test.ts test/capture-compaction.test.ts test/capture-sid-race.test.ts— 54 pass / 0 failDeliberately not changed
autoCapturedefault off; the zero-token default is untouched (criterion 3).captureModelstill warns once at setup and skips registering the subscription — no silent substitution of a different model than the user typed.#152no-workspace refusal still precedes the model call (model resolution itself is token-free and runs first so the refusal line can carrymodel=).session.contextref per the ticket's fix text..github/workflows, labels beyondfix:*, or the issue body.