Repository navigation
[PR] test: guard resetSessionCompression field coverage (#6181 item 3) - #6304
ranxianglei wants to merge 2 commits into
Conversation
resetSessionCompression is a hand-enumerated, field-by-field clear of per-turn compression state after a host-native-compaction rebase; every line carries an issue comment, so a new Session state field added without touching it silently leaks stale state across the ref-space reset (the #5984 class). Classify every top-level Session field into exactly one reset bucket (RESET / INTENTIONAL_WRITE / PRESERVED) and add a compile-time exhaustiveness gate: UncoveredSessionFields must stay `never`, so an unclassified field fails the build naming exactly what to classify. Add a runtime test that drives a fully populated session through a real resetSessionCompression and pins each bucket's post-condition, plus the stats/metadata sub-field surface where the #5984 free-form-key gap lived. Additive only: no change to resetSessionCompression behavior. The free-form metadata namespace (e.g. COMPRESS_LOOP_KEY at src/stream.ts:231) stays out of scope by design — proposal 6 (discussion #5874) is the structural replacement.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.9209-pr.6304.a231952This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr6304.tgz
npm install -g packageInstall instructions are refreshed on each push. |
…s passes (#6304) The unused-exports CI gate flagged two of the new compile-time helpers from the reset-completeness guard: INTERNAL_ONLY src/session.ts: ResetSurfaceField DEAD src/session.ts: _resetCoverageGate They are internal mechanisms, not API surface: the only external consumers are the three const field lists (imported by the completeness test), and _resetCoverageGate is a tsc-only assertion whose teeth live at its declaration site, so exporting it changes nothing. De-export all three helper types (UncoveredSessionFields was only kept green by a comment mention in the test header, a fragile dependency) so the module exports exactly what is consumed. Compile-time coverage gate unchanged: dropping "lockChain" from PRESERVED_SESSION_FIELDS still fails tsc with TS2344 naming the field.
(ai: vllm-qwen/qwen3.8-27b) CI takeover: the Dup screen: scanned all 140 open Root cause (verified locally, not inherited): master tip Both are compile-time helpers of the guard, never consumed outside Fix (additive commit on the PR branch; the original commit stays untouched): drop Local verification (all on the pushed tree):
Conflict check: floor 4 mentioned conflicts — live GitHub state shows Labels: verified live — the PR carries Status: new head 八问(中文):
判定:修复已推送( |
(ai: vllm-qwen/qwen3.8-27b) Final verdict: CI green on |
What
Adds a completeness guard for
resetSessionCompression(#6181 item 3) — turns the "remember to add a line here when you add a new state field" discipline into an enforced contract.Addresses #6181 item 3 (the optional transition meta-test). Items 1 (stop expanding the rebase line — policy, recorded in the issue) and 2 (retire rebase when proposal 6 lands — gated on discussion #5874) are out of scope for this PR.
How
Three exported field lists in
src/session.ts, co-located aboveresetSessionCompression:RESET_SESSION_FIELDS— back to fresh/absent after reset (wholesale-replace, clear-in-place, set-undefined, or consumed by the markDirty→save boundary).INTENTIONAL_WRITE_SESSION_FIELDS— deliberately written to a non-default value (contentStoreDirty=true,ccrReconcilePending=false,revisionEpoch+1).PRESERVED_SESSION_FIELDS— left untouched (identity / persistence / cumulative billing / recovery markers).Two layers of teeth:
as const satisfies readonly (keyof Session)[];UncoveredSessionFields = Exclude<keyof Session, ResetSurfaceField>MUST staynever, enforced by a type gate that fails the build naming the unclassified field. A newSessionstate field added without being classified is now a build error, not a runtime surprise. Verified: removing one field from a list reproduceserror TS2344: Type '"lockChain"' does not satisfy the constraint 'never'.tests/issue6181-reset-completeness.test.tsdrives a fully-populated session through a realresetSessionCompressionand pins every bucket's post-condition, plus thestatssub-field surface (cumulative counters survive; per-turn estimate baselines zeroed/deleted) and themetadatakey surface (ccr/anchor keys dropped,nativeCompactionAtstamped, identity keys kept).Behavior change
None. Purely additive — new exported constants/types + one test file.
resetSessionCompressionitself is untouched. No config surface change, no wire/persistence change, no kernel change.Known boundary (documented, not fixed)
session.metadatais a free-formRecord<string, unknown>, so ad-hoc keys (e.g.COMPRESS_LOOP_KEY = "compressFailStreak"atsrc/stream.ts:231) sit outside the typed surface and cannot be enumerated here. That is exactly the class proposal 6 (discussion #5874) closes structurally — noted in both the source comment and the test header.Verification
tests/issue6181-reset-completeness.test.ts: 4/4 pass (targeted run).tsc --noEmit --project tsconfig.json: clean.