Repository navigation
fix: salvage single-entry object in the compress content slot (#470) - #471
Conversation
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: Each push to this PR publishes a new version under the Option B — Download artifact
This comment is automatically updated on each push. |
[bot] 🏷 Review complete — mergeable. This is my own earlier work (opened from #470, floor 2 there); per policy I did NOT redo it — I pulled the branch, audited the diff against current master, and re-verified everything fresh. Verification performed
① Original issue direction — sound#470's diagnosis is correct and hits the root cause, not the symptom: the asymmetry lives in the final ② Regression review — existing behaviors on the touched path, item by item
No high-risk patterns found: no fail-fast→swallowing, no default/threshold/timing drift, no wire-artifact format change (the new §7.3 contract checkNone touched: wire-artifact format, ref immutability, single-owner content, lossless round-trip, tool-pair atomicity, protected-tool filtering, Prompts rules, pipeline ordering, zero-deps, platform-agnostic — all intact. The lenient parser is host-facing argument recovery, not a kernel-owned contract. ③ Code reviewThe core change is 11 lines in ④ Test validity13 new tests, all with teeth — exact refs, exact ⑤ Diff cleanliness3 files, +205/−7, every line serves #470 (parser branch + diagnostics field + header comment, contract-test update, regression tests). No unrelated files, no whitespace churn, no generated/lock noise. Auto-merge gate (§7.4)Eligible on all seven counts: single-module scope, pure regression repro, green on rebased head, no §7.3 contract, pure 中文摘要:审核了 #471(修复 compress 参数解析中 content 槽位单对象被硬拒的不对称问题)——代码改动最小且正确、回归面逐项核对无意外破坏、测试有牙、CI 与本地预检全绿,可以合并。 |
|
Deep review — verdict: MERGEABLE (reviewed on the PR head, clean tree). Verified
Design check
Downstream note for the owner: after merge + kernel release, the bili pin bump can drop its own normalization or keep it (idempotent) — either is safe. Ready to merge; CI green → merge → tag/release → bili pin bump lands the #470 root fix for bili users. |
[bot] 🏷 收到,独立复核了你点名的那个承重论断,确认无误: Entry schema 确实没有 你的 mutation 结果(删 salvage 分支 → 10 red;坏 unwrap → 1 red)与我这边的测试有效性审查互为印证:13 个新测试对两处核心逻辑都有牙,回归时抓得住。 后续链路无异议:merge(人来执行,PR: #471 )→ 进 master 后由下一个 release 分支带出 → bili pin bump 后 #1497 的 pre-normalization 变纯防御性 no-op,留不留都安全。本仓库侧我这边没有待办动作了。 中文摘要:复核确认 entry schema 无 ranges 字段、unwrap 分支无歧义,与你的 mutation 结论一致;PR 可合并,合并及后续发布链路由 owner 执行。 |
Fixes #470
What changed
parseCompressArgsnow salvages a single entry OBJECT given in thecontentslot instead of a one-element array — the retry drift observed in billion-context #1494/#1495 (a model that lost one range of a batch re-issues just that range as{content: {startId, endId, summary}}). Previously that was a hardcontent-not-arrayfailure with no recovery, while the same drift at the top level (bare entry object withoutcontent) was already tolerated — an asymmetric salvage wall.In
src/parse-compress-input.ts(parseObjectValue): whencontentis neither an array nor a string but is a plain object, it is wrapped into a one-element array so the shared entry validation applies unchanged; if the object instead carries a nestedrangesarray, that array is unwrapped. A new additive diagnostic flagdiagnostics.contentSalvage === truemarks recovered inputs so hosts can observe the drift rate.This mirrors the proxy-lane normalization in ranxianglei/billion-context#1497 (
normalizeCompressInput), so proxy-mode and plugin-mode agents converge on identical parse semantics for the same input — the divergence this issue calls out.Behavior change (old → new)
{content: {startId,endId,summary}}(well-formed entry)kind=content-not-array, ok=false, 0 rangeskind=ok, ok=true, 1 range,contentSalvage=true{content: {foo: 1}}(garbage object)kind=content-not-arraykind=no-valid-rangeswith per-entry reason ("missing range bounds"), still 0 ranges{content: {ranges: [...]}}{content: <number/null/boolean>}content-not-arraytruncated, 0 ranges{content: [...]}contentSalvagestaysundefinedThe schema layer (
COMPRESS_PARAMETERS) is untouched and still structurally rejects an object undercontent— only the lenient parser changed, and its contract test now pins both layers' roles. Wrapped entries passvalidateEntry(bounds + summary gates) unchanged, so nothing security-bearing shifts.Tests
tests/parse-compress-input.test.ts(parseCompressArgs: content given as a single entry object is rejected (content-not-array) while the same drift at the top level is tolerated — asymmetric salvage wall #470 section): wrap, per-entry/top-level topic & summaryMaxChars, compressCallId stamping, string-encoded + fenced double-stringified variants, nested-ranges unwrap, garbage/incomplete degradation, truncated non-guessing, non-object values unchanged, canonical inputs unmarked, rebuild end-to-end.tests/compress-schema-contract.test.ts: the old "object under content stays rejected" test updated to pin the new two-layer contract (schema strict, parser salvages).Pre-flight on master head 6915978: format:check, typecheck, 1196/1196 tests, build — all green.