Skip to content

feat: pin acp-kernel 0.0.90 + wire refold-in-place into proxy decompress - #1316

Merged
ranxianglei merged 2 commits into
masterfrom
2026-09-25_kernel-0.0.90-refold-wiring
Sep 25, 2026
Merged

ranxianglei merged 2 commits into
masterfrom
2026-09-25_kernel-0.0.90-refold-wiring

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Pairs with acp-kernel 0.0.90 (PR ranxianglei/acp-kernel#420) — pin bump plus the host-side wiring that makes the kernel's refold-in-place capability real in bili's proxy lane.

Why bundle them

Kernel #403 shipped markBlockRestoredInline with zero host callers — in bili proxy mode the flag could never flip, so:

Pinning without the wiring would ship an inert feature + a dead-end instruction.

The wiring (src/decompress-shared.ts)

resolveDecompress flips restoredInline (via markBlockRestoredInline) + markDirty on a successful full-block restore (default one-level view or full:true) — the tool result stays in the client's re-sent history, so the model genuinely holds the re-summarization material. Guards:

  • Range restores (startId/endId) never flip — partial content is not refold material
  • Inactive blocks are skipped

Plugin lanes are unaffected: full-log hosts (pi) use the kernel's resolving route (#400) which needs no flag.

Tests (tests/refold-wiring.test.ts, 5)

  1. full-block decompress flips the flag (idempotent)
  2. full:true parity
  3. range restore excluded
  4. end-to-end proxy shape: decompress → empty view (originals left the wire) → re-compress same span → refolds in place: same blockId, new summary, marker cleared, no second block (Compressed … → 1 block(s), ~0 tokens saved)
  5. negative control: no restore → honest already-compressed rejection, summary untouched

Verification

  • Kernel 0.0.90 verified live on npm before pinning (markBlockRestoredInline + refold code present in the published tarball)
  • typecheck ✓ / full suite 2559 pass / 0 fail / build ✓ — all against the published package
  • Earlier integration probe (master tarball on pin-0.0.89 tree) also green: 2556/0

…ess (kernel #398/#403)

Kernel 0.0.90 ships the refold-in-place stack (#398/#400/#402) but
markBlockRestoredInline had no host caller — the capability was inert in
bili's proxy lane: a decompress→recompress loop could never refold, and
the kernel's blocked-refold guidance promised an inline-restore path
that never materialized on this wire.

Wiring: resolveDecompress flips restoredInline (and markDirty) on a
successful FULL-BLOCK restore (default one-level view or full) — the
tool result stays in the client's re-sent history, so the model holds
the re-summarization material. Range restores (startId/endId) return
partial content and must NOT flip the flag; inactive blocks are skipped.

Tests (tests/refold-wiring.test.ts): flag flip + idempotence, full:true
parity, range-restore exclusion, end-to-end proxy-shaped refold (empty
view, in-place update, marker cleared, no second block), and a negative
control pinning the honest already-compressed rejection.

Downstream verification against the published 0.0.90: typecheck ✓,
full suite 2559 pass / 0 fail, build ✓.
@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-09-25_kernel-0.0.90-refold-wiring (92c07dd)

Option A — Install from npm PR tag (recommended)

npm install -g billion-context@pr-1316

Each push to this PR publishes a new version under the pr-1316 npm tag.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr1316.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

[bot] 🏷 Review of #1316 — verified on branch 2026-09-25_kernel-0.0.90-refold-wiring (head 3ce56449)

What I did: pulled the branch (base == current master tip 5e7b0854, single commit — fresh, no rebase needed), audited the diff, ran typecheck + full suite + build locally, verified the published kernel artifact, and audited the full kernel delta v0.0.89→v0.0.90.

Verification: all green

  • Local: typecheck ✓ / 2559 pass, 0 fail (10 skipped) / build ✓ — matches your claimed numbers exactly.
  • CI on head: e2e ✓, build-artifact ✓, hermetic registry e2e ✓, codex overlay ✓, real codex lane ✓, real pi native lane ✓, version-guard ✓ (the 4 test-matrix jobs were still running when I checked; covered by my local run).
  • Kernel artifact: npm acp-kernel@0.0.90 integrity matches package-lock.json byte-for-byte; markBlockRestoredInline present in the published tarball (dist/index.js, index.d.ts).
  • Pin discipline: exact pin, no caret; no version bump in the content commit ✓.

① Direction (issue review): correct. The one-way ratchet is real — without this wiring, proxy-mode decompress→re-compress of the same span dies on "already compressed" despite kernel #398's refold path, and the kernel's blocked-refold guidance pointed at a nonexistent downstream route. Bundling pin+wiring in one PR is the right call (pinning alone would ship an inert feature).

② Regression review (existing behaviors touched):

③ Code review: the wiring is minimal and correctly placed — after the range early-return, guarded by block.active && !block.restoredInline, state reassigned through markBlockRestoredInline(...).state + markDirty, matching the existing applyRanges mutation pattern under the session lock. One design point to be aware of: the flip happens before the >10KB temp-file spill, so toFile restores also mark restoredInline (model holds the 2KB prefix + file path reference). Defensible, but see finding A below — this exact edge is where a sibling PR disagrees.

④ Test validity: the 5 tests have teeth. Test 4 is a genuine end-to-end refold through applyRanges with the proxy-shaped empty view (originals left the wire) asserting same blockId + replaced summary + cleared marker + no second block; test 5 is a proper negative control (honest rejection, summary untouched). Gaps: the >10KB toFile path is untested (the semantically interesting edge), and test 3 passes via the CCR-disabled rejection rather than a successful range restore — acceptable given the structural guard, but worth knowing.

⑤ Diff cleanliness: clean — 4 files, every line on-purpose.

Findings needing owner attention:

A. Overlap with open PR #1298 (biggest item). #1298 ("compress receipts carry per-block summary fingerprints; inline decompress ends with re-fold guidance", fixes #1294) wires the same markBlockRestoredInline call into resolveDecompress (at function tail, so its toFile path does NOT flip — directly conflicting with this PR's semantics there) and additionally appends a wire-visible Re-fold: hint line to every non-toFile decompress result plus fingerprint lines to compress receipts. #1298's CI is currently red (build-artifact + all test matrix + both e2e lanes) precisely because it imports the 0.0.90-only API without carrying the pin bump — it cannot pass until this PR lands first. If both merge as-is you get a textual conflict in src/decompress-shared.ts, duplicated flip logic, and two opposite answers to the toFile question. Recommendation: land this PR first (it carries the pin and has the stronger e2e-style tests), then rebase #1298 onto it, drop its redundant P2 wiring (keeping P1 fingerprints + hint-shape tests), and let the owner decide the toFile edge and whether the hint lines ship (those are output-format changes, i.e. product decisions). Happy to do that rebase once this merges.

B. "Plugin lanes are unaffected" is inaccurate. The plugin tool API routes agent decompress calls through executeProxyTool → resolveDecompress (src/plugin.ts tool endpoint, under session lock), so the flag flips for plugin-mode sessions too. Net effect is consistent and harmless — the model holds the material in its own history on both lanes, so refold-in-place is equally valid there — but please correct the wording in the PR description.

Behavior-change disclosure (old → new): in bili proxy mode (and, per B, plugin mode), re-compressing a span already folded into an active block was rejected with "already compressed"; after a successful full-block decompress it now refolds in place (same blockId, replaced summary, marker cleared). This is the intended fix of the kernel #398 ratchet, not drift. Tool-result text is unchanged by this PR.

Verdict: code is correct, minimal, well-tested, green on a fresh base; kernel artifact verified; no regression identified in the bundled kernel delta. From my side this is mergeable — but per §7.4 the acp-kernel pin bump is a cross-repo dependency change, so the merge stays human-gated, and finding A should be sequenced deliberately (this PR first).


中文摘要:PR #1316(pin acp-kernel 0.0.90 + 把 refold-in-place 接入 proxy 的 decompress)已核分支、跑通本地 typecheck/2559 测试全绿/build、验证了 npm 上 0.0.90 产物与锁文件一致,代码正确且最小化,可合并;但需先与同改 resolveDecompress 的 #1298 排序(建议本 PR 先行、#1298 rebase 后去掉重复接线),且跨仓依赖升级按规范由人工合并。

@ranxianglei
ranxianglei merged commit d4f630b into master Sep 25, 2026
11 checks passed
ranxianglei pushed a commit that referenced this pull request Sep 25, 2026
…eat restores keep the exact-refs hint

Rebase of #1298 onto master-with-#1316 surfaced a semantic duplicate: both
PRs flagged restoredInline in resolveDecompress, but #1316 marked BEFORE the
toFile early-return (violating the frozen contract 'file mode behavior fully
unchanged') while #1298 marked only on the inline path. This keeps the
contract-correct inline-only marking and additionally:

- repeat inline restores now re-derive the exact span (kernel result is
  idempotent) so the hint stays byte-identical across repeats — the legacy
  'repeat decompress returns identical content' invariant holds unchanged
- only the FIRST restore pays the state write + persist
- new pin test: >10K spill does NOT flip restoredInline and carries no hint

Fixes #1294 (P1 fingerprint lines + P2 re-fold guidance, P2 live via the
0.0.90 pin from #1316)
@github-actions github-actions Bot mentioned this pull request Sep 25, 2026
@ranxianglei
ranxianglei deleted the 2026-09-25_kernel-0.0.90-refold-wiring branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant