Repository navigation
feat: CCR content-cached retrieval — content store + acp_retrieve primitive - #358
Conversation
[bot] 🏷 PR #358 review complete — verified, regression-audited, one weak test fixed directly on the branch (pushed). Mergeable from my side. What I did
Gate 1 — diff cleanliness: PASS. Every hunk is CCR-related (3 new files + targeted edits); no off-topic, generated, or whitespace noise. Gate 2 — regression audit (touched existing behavior → verdict):
Contract checklist: replace-once byte-stability (cross-turn equality), tool-pair integrity (id/toolCallId/assistant args untouched), ephemeral injection (no ref, survives pipeline, outside fold space), placeholder wire shape (exact string match), archive resilience, absorb coexistence — all substantively tested, not just named. Fixed directly on the branch (commit Nits (flagged, non-blocking):
Verdict: the design fits the architecture — content-addressed store decoupled from the ref map is the right call for archive resilience, and ephemeral injections reuse the established exclusion machinery rather than inventing a parallel one. One weak test fixed and pushed; everything else verified as described. Mergeable (merging itself is yours, per house rules). 中文摘要:修复了 archive-resilience 测试名不副实的问题(测试声称模拟了 ref-map 剪枝但实际未剪枝,已补上真实的剪枝断言并推送为 |
…mitive Issue #352 (from billion-context#1097): kernel-side foundation for lossless tool-result offload. Oversized tool results are stored verbatim in a per-session content-addressed store and replaced by a deterministic placeholder at arrival; the model retrieves originals on demand via a new kernel primitive behind acp_retrieve. New modules: - src/content-store.ts: MessageContentStore — per-session, content-addressed (sha256) dedup store; per-ref append-only (first write wins), so stored originals survive fold/edit/truncate and messageRefs pruning (the id-never-reused contract). Host-persisted JSON ({version,byHash,byRef}). - src/ccr.ts: placeholder contract (deterministic, no model call, byte-stable), storeLargeResults pipeline node (ccr-store, after prune), retrieveByRef / applyRetrieve (ephemeral acp_retrieved_* injection that consumes no ref and never enters fold space), noteRetrieval stats, storeCoveredOriginals host-callable primitive for folded ranges. Wiring: processTurn accepts optional input.contentStore and always returns result.contentStore; CompressionCore.retrieve(store, ref); status breakdown gains storedMessages/retrievals; RETRIEVE_TOOL 3 wire shapes (opt-in, same pattern as absorb — not in ACP_TOOL_NAMES). Behavior change (disclosed): DEFAULT_ABSORB_CONFIG.minToolTokens raised 1000 -> 4000 (src/absorb.ts, src/config.ts). absorb stays disabled by default (enabled: false), so no regression for current users; the raise hands large-result handling to lossless CCR first. CCR itself is also disabled by default (config.ccr.enabled). Tests: tests/ccr.test.ts (32 tests) covering store primitives, placeholder contract/determinism, threshold/exclusion/idempotency rules, ref-safety vs archive pruning, ephemeral injection, fold-space exclusion, stats/status, config validation, tool wire shapes. Full suite 798/798.
2bd7eeb to
4dd2c97
Compare
|
Rebased onto current master (v0.0.83 + #359 crush gate + #363 image-compress). All 16 conflict hunks resolved as a union — CCR coexists with crush and imageCompression:
Pre-flight on the rebased head: typecheck ✅ / 984 tests pass ✅ / build ✅ |
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)In your adapter project: npm install acp-kernel@pr-358Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf acp-kernel-pr358.tgz
npm install ./packageThis comment is automatically updated on each push. |
[bot] 🏷 Rebase verified — independent pre-flight on the new head is green, and I audited every union-resolved hunk against master. No lost behavior found. Base check
Independent pre-flight on rebased head: typecheck clean · 984/984 tests pass, 0 fail · build OK. Matches your numbers exactly. Union hunk audit (file by file):
Coexistence safety (the part that actually matters): verified structurally — One observation (non-blocking): there's no explicit test for both ccr and crush+absorb enabled in one turn — the guarantee above is structural (order + size gate), not pinned by a test. A small coexistence test would lock it down; happy to add one if you want it in this PR, or leave it as follow-up. 中文摘要:独立复验了 rebase 后的新头( |
Closes #352
来源: ranxianglei/billion-context#1097 分析 content-addressed message store + acp_retrieve(built-in CCR)时发现 — 内核侧设计请求的内核先行实现(v1 phase)。
What this adds
Kernel-side foundation for lossless tool-result offload (billion-context#1097): oversized tool results are stored verbatim in a per-session content-addressed store and replaced by a deterministic placeholder at arrival; the model retrieves originals on demand through a new kernel primitive behind
acp_retrieve.New modules
src/content-store.ts—MessageContentStore: per-session store, sha256 content-addressed dedup (byHash) + ref index (byRef). Per-ref append-only with first-write-wins: stored originals survive fold/edit/truncate and any latermessageRefspruning (e.g. billion-context archive compaction), which is what makes the id-never-reused contract safe. Host persists the JSON envelope{version, byHash, byRef}alongsideCompressionStatevia its own StateStore path — kernel stays zero-I/O.src/ccr.ts— placeholder contract + pipeline node + retrieval primitive:📦 [acp-stored #m00423 · shell output · 4,213 tok] \npm run build`+→ acp_retrieve("m00423") returns the full text`ccrStoreNode(ccr-store, canonical order afterprune, beforefilter): stores + replaces once at arrival; idempotent on re-sight (tag-tolerant marker check); skips ACP tools, its own retrieve tool,excludeToolsglobs, protected tools, missing/BLOCKED refs.retrieveByRef/applyRetrieve→core.retrieve(store, ref): hit returns{ok:true, text, ackText, injection, entry}whereinjectionis an ephemeralacp_retrieved_*trailing message that consumes no ref (skipped byassignRefsNode/rebuild) and never enters fold space (excluded inresolveBoundaries); hallucinated refs → not-found ack (cost: one tool call, by design).noteRetrievalbumpsstats.retrievalCount; status breakdown gainsstoredMessages/retrievals(retrieval-rate metric for the "model never retrieves" risk).storeCoveredOriginals(store, messages, state, blockIds)— exported host-callable primitive so folded-range originals become retrievable afterapplyCompression(v2 groundwork; v1 does not auto-wire it into applyCompression).Wiring:
processTurnaccepts optionalinput.contentStore(omitted = empty store, pre-CCR sessions unaffected) and always returnsresult.contentStore;RETRIEVE_TOOL(+_OPENAI/_RESPONSES) follow the absorb opt-in pattern — NOT inACP_TOOL_NAMES/ACP_TOOLS_*arrays.DEFAULT_ABSORB_CONFIG.minToolTokens: 1000 → 4000 (src/absorb.ts:29, mirrored insrc/config.tsdefaultConfig).DEFAULT_ABSORB_CONFIG.enabledremainsfalse(absorb is off by default; only explicit opt-in configs are affected, and those can pin their own threshold). CCR itself is also disabled by default (config.ccr.enabled: false).Contracts honored (issue checklist)
tool_callsuntouched)maxHeadChars)Verification
npm run typecheckclean ·npm test798/798 pass (32 new tests intests/ccr.test.ts) ·npm run buildOK中文摘要:实现了 issue #352 请求的内核侧 CCR 基础(内容寻址存储 + 确定性占位符 + acp_retrieve 检索原语),纯增量、默认关闭;唯一行为变更是 absorb 的 minToolTokens 从 1000 提到 4000(absorb 本身仍默认关闭,无回归)。可以合并评审。