Skip to content

test(compress): make multi-block afterTokens scale guard non-vacuous (#378) - #379

Merged
ranxianglei merged 1 commit into
masterfrom
2026-09-11_fix-vacuous-multiblock-scale-test
Sep 12, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-09-11_fix-vacuous-multiblock-scale-test

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Fixes #378

Problem

tests/compress-tool.test.ts "compress afterTokens is measured on the same sent-view scale as beforeTokens (multi-block)" claimed to guard the #289 invariant (afterTokens must be measured on the post-processTurn sent view, which carries every active block's summary anchor + ref-tag overhead), but both compress calls in it were rejected by the kernel's minCompressRange gate (default 5000 chars — the payloads were 52 / 193 chars). Both panels rendered as no-ops (646 → 646 tokens (~0 reclaimed, 0 block) + Errors: Total compressible content too small ...) and every assertion passed anyway: the guard was vacuous.

Change (tests/compress-tool.test.ts only)

Follows the #309/#322 test pattern:

  • entries are now 4 × 6000-CJK-char messages (clears the 5000-char gate per range) with preserveRecentMessages: 1, so m00001/m00003 are actually compressible;
  • summaries are 300 CJK chars each, so the two blocks' cumulative anchor mass is ~600 tokens — wide enough to survive formatK's ±50-token rounding buckets;
  • BEFORE the scale checks, the test now proves compression really happened (format-independent, valid before/after compress 工具结果缺少新块 ID 与实际 ref 跨度,模型块账本随会话漂移 #376's panel reformatting merges): both panels contain the ACP line and NO Errors: line, and the sidecar state file holds exactly 2 blocks with non-empty stored summaries;
  • scale assertions re-calibrated against measured values: after >= 12300 (visible-only e2+e4 = 12000; true sent view ≈ 12600; raw projection reports exactly 12000) and reclaimed <= 6000 (true ≈ 5700; raw over-claims ≈ 6300);
  • the old exact-equality consistency check becomes |before − after − reclaimed| <= 150 because at K scale each panel figure is rounded into a 100-token bucket (three roundings → <150 combined slack).

Verification

  • Full suite green on real code: 693 pass / 0 fail / 3 skipped.
  • Guard-bite proof: temporarily swapped src/compress-tool.ts:418 back to the raw projection (estimateTokens(coreMessages, ...) instead of estimateTokens(afterTurn.messages, ...)); the rewritten test FAILS with afterTokens 12000 missing the summary-anchor scale (raw projection reports 12000): ▣ ACP | 18.3K → 12.0K tokens (~6.3K reclaimed, 1 block). Reverted; only the test file changes.
  • npm run typecheck + npm run build clean.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Extension Artifact

Branch: 2026-09-11_fix-vacuous-multiblock-scale-test (6b31f1f)

Option A — Install from npm PR tag (recommended)

pi install npm:billion-context-pi@pr-379

Each push to this PR publishes a new version under the pr-379 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pi-pr379.tgz
pi install ./package

This comment is automatically updated on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Reviewed #379 (fixes #378). Verified independently on top of current master (a8dfb49):

Duplicate screening: no other open PR/issue touches #378 — #379 is the sole fix. Related to #377 (panel reformatting) but deliberately orthogonal: the "compression really happened" proof uses format-independent signals (ACP line present, no Errors: line, sidecar holds exactly 2 blocks with non-empty summaries), so this merges cleanly regardless of whether #377 lands first. That deviation from #378's suggested literal blocks: bN= assertion is the right call.

Triage verdict

  1. Reproduced: the vacuity is real — compress-tool 的 multi-block afterTokens 守卫测试在 minCompressRange 门槛下空转(两条压缩均被拒仍通过) #378's evidence shows both old payloads (52 / 193 chars) rejected by the minCompressRange 5000-char gate, panels rendering as no-ops while every assertion passed.
  2. Layer: the issue describes the root cause directly (sub-gate payloads → rejection → vacuous pass); the fix targets it at the right layer — payloads now clear the gate AND the test asserts compression actually happened before touching scale numbers, so future no-op regressions fail loudly instead of passing silently.
  3. Solution: follows the compress 摘要双重转义(\uXXXX)入库+渲染;幻觉用户原话被摘要永久化为 CURRENT TASK 导致循环复发 #309/[Bug] in-memory 子代理压缩状态未写回 cache,导致 152 次重复压缩 #322 pattern; calibration math checks out — each threshold sits strictly between the true sent-view value and the raw-projection value with margin wider than formatK's ±50-token buckets: after >= 12300 (raw = 12000, true ≈ 12600), reclaimed <= 6000 (raw ≈ 6300, true ≈ 5700), and |before − after − reclaimed| <= 150 is exactly the combined bound of three independent ±50 roundings.

Verification (all done by me, not taken on faith)

  • Diff hygiene: single file tests/compress-tool.test.ts, 28+/12−, every line on-purpose, no whitespace/unrelated churn. Clean.
  • npm run typecheck clean; npm run build clean.
  • Full suite on real code: 693 pass / 0 fail / 3 skipped — matches your claim exactly.
  • Guard-bite reproduced independently: I temporarily swapped src/compress-tool.ts:418 back to the raw projection (estimateTokens(coreMessages, ...)) and ran the multi-block test — it fails with precisely your quoted error: afterTokens 12000 missing the summary-anchor scale (raw projection reports 12000): ▣ ACP | 18.3K → 12.0K tokens (~6.3K reclaimed, 1 block). Reverted; working tree back to the PR's exact state (verified via git status + diff vs master).

Minor (non-blocking): the new const blocks = stored.blocks as any[]; uses as any, which §3 forbids in src/ (0 occurrences there) — but it's the established test-file convention (23 test files already use it, 7 in this very file for the mock API). Consistent as-is; no change requested.

No fixes needed from me — nothing to patch. Ready to merge (merge itself stays human-only per repo rules).

一句话中文摘要:独立复验通过——diff 干净(仅测试文件 28+/12−)、全套 693 绿、且我亲手把 src/compress-tool.ts:418 换回 raw projection 确认新守卫确实咬合(测试如预期失败后已还原),#289 多块尺度不变量从此有有效守卫,可以合并。

@ranxianglei
ranxianglei merged commit 2bdc831 into master Sep 12, 2026
9 checks passed
HangxiangMa pushed a commit to HangxiangMa/billion-context-pi that referenced this pull request Sep 21, 2026
…cuous-multiblock-scale-test

test(compress): make multi-block afterTokens scale guard non-vacuous (ranxianglei#378)
HangxiangMa pushed a commit to HangxiangMa/billion-context-pi that referenced this pull request Sep 29, 2026
…ildState carries image ledgers

- kernel 0.0.83 -> 0.0.86: bundles ranxianglei#379/ranxianglei#380 (tier2Trigger 5->1000,
  tier3Trigger 10->2000, ranxianglei#238 usage gate deleted) — count-triggered
  distillation is default-off; growth/token-mass stay the need signal.
  Fixes the prefix-cache sawtooth class (billion-context#1249).
- deriveChildState: carry imageFullRestored/imageShrinks from the parent
  (ref space is NOT re-issued on derive, so the ledgers stay valid for
  inherited content; kernel resetImageFullState applies only to
  ref-reissue resets). Without them image_full on an inherited shrunk ref
  falsely refused.
- t3-rewrite-guard ranxianglei#344 test pins the hint mechanism with explicit low
  triggers; new tier-ready-hint.test.ts asserts default-off silence.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

compress-tool 的 multi-block afterTokens 守卫测试在 minCompressRange 门槛下空转(两条压缩均被拒仍通过)

1 participant