feat(lab): coding_markdown_v3 grep section-context + compaction runaway guard

↗ view on GitHub · Eli Ziff · 2026-08-06 · d33fd14a

v3 (one flag, MIKE_GREP_SECTION_CONTEXT): content-mode grep hits are
preceded by their enclosing SECTION lead rendered as an rg context row
at its real line number - document-true text, quotable, Read-able at
that coordinate. The legal analog of the enclosing symbol a coding
model expects near a hit, made explicit because legal sections outrun
context windows. Resolver is deliberately two-plane (docx detector
nodes anchored into served markdown via new anchoredSectionStarts):
probed 2026-08-06 - the skeleton compiler finds 0 nodes on pandoc
markdown, so a served-plane resolver would silently annotate nothing.
Version-memoized per document; non-docx and failures degrade soft.
Subsections excluded: a hit's own subsection is its neighborhood
already. v3 Grep description documents the rows CC-style; arm =
v2 env + flag; conformance asserts grep_section_context per arm;
fail-closed reset adds MIKE_GREP_SECTION_CONTEXT and the previously
missing MIKE_CODING_PARITY.

Compaction guard (Eli: "make sure that doesn't loop forever"): rounds
are unbounded on non-native arms and each CLI auto-compaction re-opens
window headroom, so thrash is structurally possible. Typed stop at 3
compactions (ClaudePFatalError "compaction_limit", never retried;
runner classifies the terminal status). Real-degradation bound: one
compaction is tolerable lossiness (tax pilot: 1 compaction, completed),
two produced summaries-of-summaries (v1 acq pilot).

Live validation same day: the tax v2 pilot's compaction was detected,
warned, and recorded end-to-end (iteration 6, preTokens 167,683,
context_compaction_count 1 in metrics).

Probes: plane sect 14/14 + parity 14/14 (v2 emits no lead rows -
byte-frozen), served-surface coding3 7/7 / coding2 7/7 / treatment 9/9,
suites 57/57, tsc clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011pfUVhNFTRvhYGXBwoKNj6
Repository eliziff/Beaver
Author Eli Ziff <eliasziff@gmail.com>
Authored
Parents dd525882
Stats 6 files changed , +267 , -19
Part of Evaluation harness: Beaver-CAN and LegalBench-RAG adapters

Capture this commit into my fork

Download a Markdown prompt that tells Claude how to port this exact commit into your working tree. Run it via claude -p < capture-commit-d33fd14a.md from inside the repo you want the change in.

⬇ Download capture-commit-d33fd14a.md