fix(bp-155): decide the L0a oversize cut over the canonical body (A1.2) - #36
Merged
Conversation
`_l0a_chunks` (core/ingest/code_corpus.py) decided the whole<->windowed split on the HEADER-BEARING length (`len(header + body) <= max_chars`), so the path's length participated in a chunk-identity decision: a rename or a move that crossed the budget flipped a slice whole<->windowed and minted a spurious atom (issue #31, bp-151's parked residue, ruled by Amendment A1.2 of dn-vector-membership-store). The fix is the one token the plan pins: `len(full) <= max_chars` becomes `len(body) <= max_chars`. Nothing else in the block moves — `text=full` stays `text=full`, so L0a embed text keeps its coordinate header (D0/R7). The KNOWN RESIDUE comment is replaced with one recording the decision is now canonical-body-scoped, per A1.2, and why. Converts bp-151's deliberate tripwire, `test_l0a_oversize_threshold_is_the_one_rename_residue` (its docstring named its own re-entry: "if #31 is ruled that way, this expectation becomes 0 and this test reddens"), to `test_l0a_oversize_cut_is_canonical_body_scoped`, asserting the residue is gone while keeping the straddle precondition (the fixture still crosses the OLD threshold, so the test has teeth). Measured (2026-08-06, real chunkers over all 580 tracked .py files, not a fixture): - Aggregate rename cost: 0 (was 3 at bp-151's 45c4a15 measurement; 23 on this tree pre-fix, confirming the measurement has teeth and the tree has grown since 45c4a15). A1.5's first falsifier does not fire. - L0a groups whose canonical body changed under the new rule: 72 across 57 files (was ~123/95 at 45c4a15; the tree has moved). Verified every one falls inside the predicted affected band (max_chars - len(header) <= len(body) <= max_chars) — A1.5's second falsifier does not fire. One additional group, core/ingest/code_corpus.py::_l0a_chunks, differs too, but that is this commit's own comment edit to the function whose body includes that comment, not a rule-driven change. Side effect, noted: for slices in the affected band, the OLD rule routed the body through `chunk_text`, whose `_blocks` calls `.strip()` on the block — silently stripping the first line's leading indentation for nested symbols even though the body itself fit under budget. The new rule takes the whole branch directly, so those 72 slices' canonical bodies (and embed text) are now the exact, unmangled source for the first time. No max_chars retune (A1.5's third falsifier), no other chunker change. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011LZZQPyGsoeGL73cbbEp3U
Records the build: the one-token fix, the converted tripwire, the aggregate rename cost re-measured at 0 (A1.5's first falsifier did not fire), the 72/57 in-band boundary-change census (A1.5's second falsifier did not fire), the exact gate results with diff-innocence proven on the 5 known-red tests, and the .strip()-indentation side-finding surfaced while verifying Item 3. Read-map + Follow-through block per the checkpoint contract.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes bp-155 — the L0a oversize cut in
_l0a_chunks(core/ingest/code_corpus.py) nowdecides the whole↔windowed split over the canonical body (
len(body) <= max_chars),not the header-bearing full text (
len(header + body) <= max_chars). This closes issue #31,bp-151's parked residue, per Amendment A1.2 of
dn-vector-membership-store(owner ruling2026-08-06). This completes D0: bp-151 took the aggregate rename cost from 11,096 → 3;
this takes it to 0.
core/ingest/code_corpus.py— the one-token change (:152), and the KNOWN RESIDUE commentreplaced with one recording the decision is now canonical-body-scoped, per A1.2. Nothing else
in the block moved —
text=fullstaystext=full, so L0a embed text keeps its coordinateheader (D0/R7 untouched).
tests/unit/test_code_corpus.py— bp-151's deliberate tripwire,test_l0a_oversize_threshold_is_the_one_rename_residue, converted totest_l0a_oversize_cut_is_canonical_body_scoped: same straddle-precondition fixture (therename still crosses the OLD header-bearing threshold), the mint-1 assertion flipped to
mint-0, docstring records it was bp-151's tripwire and that it reddened exactly as designed.
closes #31
Measured (real chunkers, real files, not a fixture — 2026-08-06)
Item 2 — aggregate rename cost: 0. Over all 580 tracked
.pyfiles: for each file,derive L0a/L0b/L1 at its own path and at a length-changed moved path (same directory, longer
basename), sum new
(layer, content_hash)atoms across all three layers.across 23 files — nonzero, confirming the measurement has teeth. (Larger than bp-151's
original 3 because the tree has grown since
45c4a15; not a discrepancy.)No issue filed.
Item 3 — L0a boundary-change census: 72 groups across 57 files, all in-band. Comparing
L0a
(path, qualname)groups' canonical-body hashes pre/post fix: 73 groups changedacross 58 files; 72/57 are rule-driven, and 1
(
core/ingest/code_corpus.py::_l0a_chunksitself) is a measurement artifact — this PR's owncomment edit inside that function's body, not a rule effect. Verified all 72 genuine
changes fall inside the predicted affected band
(
max_chars - len(header) <= len(body) <= max_chars) — A1.5's second falsifier (a changeoutside the band) does not fire. (Was ≈123/95 at
45c4a15; the tree has moved — this iswhat it reads now, not a regression from that number.)
A side-finding, not a defect. For groups in the affected band, the OLD rule routed the
body through
chunk_text(core/kernel/ingest/chunk.py), whose_blockscalls.strip()on a block even when the whole body is a single block under budget — silently stripping the
first line's leading indentation for nested symbols (a class method's body starts
indented). E.g.
config/secrets_backend.py::VaultClient.mint_token: old rendering was'def mint_token(self, role...'(dedented, corrupted); the raw body is' def mint_token(self, role...'(correct). The new rule takes the whole branch directlyfor all 72 slices, so their canonical bodies (and embed text) are the exact, unmangled source
for the first time — a side benefit, not new behavior to chase, and not filed as a separate
issue.
Gate — exact results
Each leg run separately, never piped (
pytest -q | tailreturns tail's exit code).5 failed / 2427 passed / 15 skipped — exactly the three known-red classes local-only, green
in CI: the finding-0103 core-self-containment ratchet (1),
tests/e2e/test_dream_v2_live.py(1),and
tests/integration/test_worktree_enforcement.py(issue #13 / finding-0280) (3). Same testnames, same count bp-151 reported for its own build.
tests/e2e/test_scheduler_live.py's knownflake did not fire in either run below.
Diff-innocence proven: stashed both changed files back to a byte-identical
origin/main(
git diff --stat origin/main HEADempty), re-ran the full suite on the clean base — same 5failures, same names,
5 failed, 2427 passed, 15 skippedin 249.76s.Test plan
ruff check .cleanmypy core agents eval ops scheduler scripts— 0 issues, 262 filesmypy(argless) — tail 69, unmovedops.type_gate— OKpytest -q— 5 known-red / 2427 passed / 15 skipped, proven diff-innocent against cleanorigin/maintest_l0a_oversize_cut_is_canonical_body_scopedpasses; inverted (stash the fix) toconfirm it reproduces the original mint-1 residue, then restored
.pyfiles (not a fixture)🤖 Generated with Claude Code
https://claude.ai/code/session_011LZZQPyGsoeGL73cbbEp3U