fix(rebuilder): honour use_type_aware_compression in pack accounting (#798) - #815
Conversation
rebuild_v14 was re-packing retrieve()'s candidate set with verbatim token cost regardless of use_type_aware_compression, so the ON-arm extras retrieve() admitted got trimmed back to the OFF-arm count. Per-row A4 fidelity delta was 0 by construction. Resolve the flag once at function entry, pass to retrieve() so its pack is compression-aware, and thread compress_on into _estimate_belief_tokens so the rebuilder's own L0 / session / L1 budget math matches. Default-OFF leaves _estimate_belief_tokens byte-identical (compress_on=False); _retrieve_for_rebuild (legacy v1.2.0a0 path, byte-identical alpha contract) stays untouched. Tests assert (a) ON packs strictly more beliefs than OFF at a budget that forces trim, and (b) default-OFF block equals the explicit use_type_aware_compression=False block.
) Record the rebuilder pack-accounting fix under [Unreleased]/Fixed and replace the obsolete §"vs. context rebuilder" wording in the type-aware compression spec (which described an Option-B-style `RetrievalResult` shape change that never shipped) with the Option-A-style flag-threading behavior that actually ships now. Adds a prerequisite note to §A4 pointing at the pack-size property test — the A4 bench gate stays vacuous until rebuild_v14's pack accounting honors the flag, and that prerequisite is the #798 fix.
There was a problem hiding this comment.
Sorry @robotrocketscience, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR-size soft capThis PR is over the advisory size threshold:
Bigger PRs collide with more open work, which under the parallel-session workflow tends to produce repeated This is advisory only — nothing is blocked. If the size is intentional (large refactor, module removal, generated code), apply the |
|
[claim:review:bagheera:2026-05-14T20:32:17Z] |
|
Review (sister-session, cannot
Labeling |
|
[release:review:bagheera:2026-05-14T20:35:55Z] |
|
merge-train: merged d6f0deb → |
Summary
Closes #798.
rebuild_v14was re-packingretrieve()'s candidate set with verbatim token cost regardless ofuse_type_aware_compression, so any ON-arm extrasretrieve()admitted at compressed cost got trimmed back to the OFF-arm count. The downstream A4 continuation-fidelity bench gate (#775 / PR #776) was therefore structurally vacuous — per-row fidelity delta = 0 by construction, regardless of corpus.Operator decision on #798: Option A — thread
compress_oninto rebuilder pack accounting. Smallest diff; rebuild-block content stays verbatim; A4 gate becomes structurally measurable. Options B (rebuilder emitscompressed_beliefs[i].rendered) and C (drop A4 from #769 acceptance) declined.What ships
src/aelfrice/context_rebuilder.pyuse_type_aware_compression: bool | None = Nonekwarg onrebuild_v14. Resolves once viaresolve_use_type_aware_compression(...)at function entry; resolved boolean threaded to all sites.retrieve()call insiderebuild_v14now passesuse_type_aware_compression=compress_onso retrieve's L1 / L2.5 pack is compression-aware on the rebuilder path._estimate_belief_tokens(b, *, compress_on=False)gains a keyword-only flag. When True, it returnscompress_for_retrieval(b, locked=(b.lock_level == LOCK_USER)).rendered_tokens; else the existing verbatim(len + 3) // 4math. Default-OFF preserves the byte-identical contract for the [v1.4] PreCompact hook + rebuild logic (augment mode) #139 / Rebuild redesign: eval harness — per-rebuild log + fixed-corpus precision #288 regression tests and for the legacy_retrieve_for_rebuild(v1.2.0a0 alpha) path, which keeps its default-OFF call.compress_on=compress_on.tests/test_context_rebuilder.py— two new tests:test_rebuild_v14_pack_size_matches_compression_flag— asserts ON packs strictly more beliefs than OFF at a budget that forces trim. Failing this means_estimate_belief_tokensis ignoring the flag and A4 bench gate is structurally vacuous — rebuilder uses verbatim token cost, ignoring compression flag #798's verbatim-cost re-pack bug has regressed.test_rebuild_v14_compression_off_byte_identical_default— assertsrebuild_v14(...)with no kwarg and no env override equalsrebuild_v14(..., use_type_aware_compression=False).CHANGELOG.md— entry under[Unreleased]/ Fixed.docs/feature-type-aware-compression.md— §"vs. context rebuilder" rewritten (the old text described an Option-B-styleRetrievalResultshape change that never shipped); §A4 gains a prerequisite note pointing at the pack-size property test.Observable behaviour change
AELFRICE_TYPE_AWARE_COMPRESSION=1or explicit kwarg): rebuild block now contains strictly more beliefs at the sametoken_budgetwhen the candidate set under verbatim cost would have trimmed. Each belief still renders verbatim.Tests
uv run pytest tests/ --ignore=tests/bench_gate— 4164 passed, 33 skipped, 75 xfailed (pre-existing).The bench-gate tests at
tests/bench_gate/test_compression_a4_fidelity.pyremainbench_gated(skip withoutAELFRICE_CORPUS_ROOT); now that the rebuilder honours the flag, a lab-side run against a populated corpus will produce nonzero per-row deltas instead of 0-by-construction.What this unblocks
#769 (flip default
use_type_aware_compressionon). The A4 axis of that flip-default decision was load-bearing on a gate that could not measure compression; with this fix it can. The A2 axis was unaffected (#769 acceptance remains as-is for both bench runs).Risk
#139(byte-identical v1.x rebuild) and#288(rebuild_log shape) regression tests both run green under default-OFF; the keyword-onlycompress_onparameter on_estimate_belief_tokensdefaults to False._retrieve_for_rebuild(v1.2.0a0 alpha contract, frozen docstring) is intentionally not modified — its two_estimate_belief_tokens(b)call sites use the defaultcompress_on=False.