Skip to content

[PR] test: guard resetSessionCompression field coverage (#6181 item 3) - #6304

Open
ranxianglei wants to merge 2 commits into
masterfrom
2026-11-12_reset-completeness-guard
Open

ranxianglei wants to merge 2 commits into
masterfrom
2026-11-12_reset-completeness-guard

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

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 above resetSessionCompression:

  • 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:

  1. Compile-time: each list is as const satisfies readonly (keyof Session)[]; UncoveredSessionFields = Exclude<keyof Session, ResetSurfaceField> MUST stay never, enforced by a type gate that fails the build naming the unclassified field. A new Session state field added without being classified is now a build error, not a runtime surprise. Verified: removing one field from a list reproduces error TS2344: Type '"lockChain"' does not satisfy the constraint 'never'.
  2. Runtime: tests/issue6181-reset-completeness.test.ts drives a fully-populated session through a real resetSessionCompression and pins every bucket's post-condition, plus the stats sub-field surface (cumulative counters survive; per-turn estimate baselines zeroed/deleted) and the metadata key surface (ccr/anchor keys dropped, nativeCompactionAt stamped, identity keys kept).

Behavior change

None. Purely additive — new exported constants/types + one test file. resetSessionCompression itself is untouched. No config surface change, no wire/persistence change, no kernel change.

Known boundary (documented, not fixed)

session.metadata is a free-form Record<string, unknown>, so ad-hoc keys (e.g. COMPRESS_LOOP_KEY = "compressFailStreak" at src/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.
  • Negative check: dropping a field from a list fails the build naming the field (the gate is toothed).

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.
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-11-12_reset-completeness-guard (e45c65b)

Latest build — install this exact version

npm install -g billion-context@0.0.9209-pr.6304.a231952

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
e45c65b billion-context@0.0.9209-pr.6304.a231952 build
1efeb28 billion-context@0.0.9198-pr.6304.4579a01 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6304.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title test: guard resetSessionCompression field coverage (#6181 item 3) [PR] test: guard resetSessionCompression field coverage (#6181 item 3) Nov 11, 2026
@ranxianglei ranxianglei added enhancement New feature or request p3 scope/kernel labels Nov 11, 2026
…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.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI takeover: the unused-exports red is born-red on this branch — root-caused, fixed, pushed.

Dup screen: scanned all 140 open [PR] rows — only this thread targets #6181 item 3 / reset-completeness; no parallel PR exists. No duplicates.

Root cause (verified locally, not inherited): master tip 33104b1f passes the gate clean, so the failure comes from this PR's own new declarations:

INTERNAL_ONLY src/session.ts: ResetSurfaceField
DEAD          src/session.ts: _resetCoverageGate

Both are compile-time helpers of the guard, never consumed outside src/session.ts — the test imports only the three const field lists. _resetCoverageGate is a tsc-only assertion whose teeth sit at its declaration site, so exporting it buys nothing. (UncoveredSessionFields was technically internal-only as well; it only stayed green because the test header comment mentions its name — the gate counts comments as usage. De-exported it in the same pass so the module exports exactly what is consumed.)

Fix (additive commit on the PR branch; the original commit stays untouched): drop export from the three helper types at src/session.ts:1810/1821/1824. Three words total, zero runtime impact (type aliases erase at build). Not a WAIVERS entry — the waiver list is for deliberately-public payload interfaces with structural consumers; these have none, and de-exporting is the gate's own first-choice fix.

Local verification (all on the pushed tree):

  • node scripts/check-unused-exports.mjs → ✓ clean (12 waived)
  • npm run typecheck (kernel build + tsc --noEmit) → clean
  • node --import tsx --test tests/issue6181-reset-completeness.test.ts → 4/4 pass
  • Negative check (gate still toothed after the change): dropping "lockChain" from PRESERVED_SESSION_FIELDS reproduces error TS2344: Type '"lockChain"' does not satisfy the constraint 'never'; restored afterwards

Conflict check: floor 4 mentioned conflicts — live GitHub state shows mergeable=true, mergeable_state=behind. Master moved 5 commits ahead since the branch point, all part of the compressAtFoldPoint removal (#6132/#6150/#6160); none touch src/session.ts or the Session field surface (it was a config key, not a Session field), so the three lists remain accurate against current master and no rebase is needed.

Labels: verified live — the PR carries enhancement, p3, scope/kernel, which match my independent read of the diff (test-only completeness guard, no behavior change). Left untouched per policy.

Status: new head e45c65b2b5 pushed; CI is re-running (mirror cache at time of writing still shows the previous run). I'll report the final verdict here once the unused-exports job lands.


八问(中文):

  1. 是什么问题:PR 新增的编译期护栏辅助类型(ResetSurfaceField、_resetCoverageGate)被误标为模块导出,而仓库 unused-exports 门禁对「只在本文件使用」的导出零容忍,CI 因此红。
  2. 什么原因导致的:护栏机制本身设计正确(三个字段列表 + tsc 断言类型),但实现时把纯内部辅助类型也加了 export;门禁按「导出即对外 API」约定判 INTERNAL_ONLY / DEAD。非继承性失败——master tip 在同一门禁下全绿。
  3. 影响范围与严重程度:仅阻塞本 PR 合并(CI 红),无任何运行时/用户面影响——改动是 3 个 type alias 的可见性修饰符,构建后擦除。
  4. 怎么修复的:去掉三个辅助类型的 export(唯一外部消费者是测试导入的三个 const 列表,保持不变)。tsc 在声明处照样检查断言类型,编译期齿不变——已用负向检查复现证明;不走 WAIVERS 豁免表(那里留给「刻意保持公开」的载荷接口)。
  5. 是否有回归问题:无。逐条过既有行为:resetSessionCompression 本体一字未动;三个 const 列表仍导出且测试照常导入;豁免表未动;wire/persistence/config/kernel 面零触碰。高危模式(语义漂移、吞错、阈值/时序/输出格式)逐项核对均不涉及。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:不涉及。rebase needs to be replaced by msgid+snapshot Proposal 6 (discussion #5874) | rebase 需要被 msgid+snapshot 提案6 替代(discussion #5874) #6181 item 3 的机制(编译期全覆盖断言 + 运行时桶契约)原样保留,只修正符号可见性。
  8. 是否引入了新的配置:不涉及。

判定:修复已推送(e45c65b2b5),本地四道验证全绿;等 CI 重跑 unused-exports 落绿即可合,无决策依赖项。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

Final verdict: CI green on e45c65b2b5. Verified via the mirror check cache plus a single direct check-runs fetch on the head commit: unused-exports = success, all other guards (kernel-guard / pi-subagents-guard / config-surface-guard / lifecycle-ledger-guard / version-guard / test-import-graph / lane-guard / static-gates ×2) = success, and all 11 test shards = success. The 14 skipped entries are the gated e2e lanes that don't trigger on this diff — same as the previous run. No red items remain; the PR is ready for merge whenever you are. (One-line conclusion also posted to #4599 per the CI coordination flow.)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request p3 scope/kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant