Repository navigation
[PR] fix: classify in-unit growth as a semantic append in body stability (#3476) - #3479
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.4963-pr.3479.a77323dThis exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr3479.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复。 open+closed 全搜:涉及「单元内增长被误判 mid」机制的只有本源 #3476 与本 PR;最近的相邻项 #3372(CRLF 帧容差,保留字节精确比较)、#2982/#2983(tail 类,方向相反)均不重叠。热文件提示:PR #3333 也改 审核结论(先行):方向正确、实现干净、本地验证全过、CI 已全绿;但发现一处超出 PR 披露范围的行为变化(谓词匹配面比「单一单元原地增长」更宽),证据与选项见下,需 owner 拍板后收工。 八问(对本 PR 现状)
发现:谓词匹配面超出披露范围(需拍板)
后果:真实 host 侧 mid-history 插入(正是 #3023/#3027 与 §8 session-0b4de63c 那类现象,dsh host 插入有生产案例)在离线 diff 工具里失去生产者归因——原来 选项(均为语义取舍,请 owner 拍板):
拍板 A 的话我直接在 PR 分支补 additive commit(含 guard 测试)并跑定向验证。 本地验证(PR head f4a6fb6)
CI(f4a6fb6)全绿:29 success(含 kernel-guard / pi-subagents-guard / config-surface-guard / version-guard / lane-guard / docs-sync 等全部 guard 道)+ 13 skipped(zero-token e2e 道),0 failure。 判定代码质量达标(命名达意、注释讲为什么、无死代码、风格与既有 tail-class 注释体例一致)、方向成立、回归清点除发现项外干净、CI 全绿。待办一项:谓词收窄 A/B 拍板;落实后即可合并。 |
f4a6fb6 to
e289228
Compare
e289228 to
64f28ad
Compare
…3476) The panel bs classifier and the acp-cache diff tool both defined 'append' by the first diverging byte offset. A layout that grows inside a single logical unit -- auto-review's giant user message whose FILTERED_HISTORY gains entries while a fixed PENDING_ACTION block stays pinned at the end -- is semantically an append (no prior byte moved or changed) yet its first divergence lands mid-body, so both stably reported 'mid' / mid-stream-rewrite (false positive). Recognize a semantic append: when the older payload is fully covered by common prefix+suffix (empty middle residual) and the newer one carries extra bytes in that middle. A genuine in-place rewrite leaves a non-empty residual on the shorter side, so it is never matched -- this cannot mask a real mid-history break.
64f28ad to
62e2dcd
Compare
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.727-master.c080a62 # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #3476
What & why
The BODY STABILITY panel (
/acp-cache,src/cache-ledger.ts) and the offlinebili acp-cache difftool (src/acp-cache-diff.ts) both defined an "append" purely by the FIRST diverging byte offset / LCP. A layout that grows inside a single logical unit — auto-review's giant single user message whoseFILTERED_HISTORYgains entries while a fixedPENDING_ACTIONblock stays pinned at the very end — is semantically an append (no prior byte moved or changed) yet its first divergence lands mid-body, so both classifiers stably reportedmid/mid-stream-rewrite. That is the 机制2 false positive from the issue: the panel's 51/51-midsidecar rows and the diff tool's 6 main-sessionmid-stream-rewriteare the same blind spot at two entry points.机制1 (the dump HTTP request-header preamble folded into the byte comparison) was investigated and found not to be the cause. Headers are stripped before comparison everywhere: the dump writers emit
METHOD url\nhdrs\n\nbodyandparseDumpFilesplits at the first blank line comparing only the body; the panel'snoteForwardedBodycallers pass the JSON wire-body string only. A repro confirmed a header-only-differing pair still classifiespure-append/tail. The diff tool's sixmid-stream-rewriteare all 机制2, none header-related.Fix
Recognize a semantic append instead of flagging a rewrite when the older payload is fully covered by common prefix + common suffix (its middle residual is empty) while the newer one carries extra bytes in that middle. A genuine in-place rewrite leaves a non-empty residual on the shorter side, so it is never matched — this cannot mask a real mid-history break. One small mirrored helper
isMidInsertionAppend(prev, cur, lcp)is used by both entry points:compareWiresreturnsrel: "append"with a newAppendInfo.kind === "mid-insert"for these pairs.bsternary maps these to the existing"append"class rather than"mid".Behavior change (old → new + why)
Pairs where a single logical unit grows in place (stable head, stable trailer, new bytes inserted between them) were previously classified:
mid-stream-rewrite→ nowpure-append(outgoing = append,kind = mid-insert)bs = mid→ nowbs = append(and no longer incrementsstability.mid)This is the intended fix — those pairs were always semantically appends; the old classification was the false positive being removed. No byte-exactness, fail-fast, or dedup semantics changed;
bsremains display-only (no behavior branches on it). Healthy appends (strict/json-tail/tail-fields) and genuine rewrites are unchanged (existing suites + new guards).Tests
New
tests/issue3476-mid-insertion-append.test.ts(6 tests): pins the growing-container insert →append/mid-insertat both entry points, plus guards that (a) an in-place REWRITE of the same unit still diverges /mid, and (b) healthy array-appends still classifyjson-tail. Existingtests/acp-cache-diff.test.ts(18) andtests/issue2982-body-stability-tail-class.test.ts(8) pass unchanged on the rebased head; typecheck clean.Config surface
None — no new/renamed/re-semantics config field. The fix is internal to the classifier.
Out of scope (per issue §8): the
session-0b4de63creal host-side mid-insert case is a separate phenomenon and may be split out by the reporter.