Repository navigation
fix: archive blocks across omp native compaction instead of silently deactivating them (#395) - #421
Conversation
…deactivating them (#395) omp's in-session native compaction re-sends a shortened history (its summary + retained tail) without rotating the session id, so bili's per-sid registry reuses stale state and syncBlocks silently deactivates every block whose raw ids left the history — making decompress permanently unreachable and decoupling acp_status from the real visible context (the ledger break #19 shelved). Wire the omp session_compact hook bili was ignoring: - agent plugin (pi/omp) POSTs /__bili/plugin/compact on session_compact - proxy marks a compaction boundary; the next processTurn degrades the active->inactive blocks into an auditable pre-compaction archive - acp_status lists archived blocks with reason; decompress returns an explicit error instead of silent failure or wrong-block content - prune byRaw/byRef to live raw ids at the boundary (stops the #390 additive leak); nextIndex is left alone so a freed ref slot is never re-allocated onto a retained tail's live tag
📦 Built Package ArtifactBranch: Option A — Install from npm PR tag (recommended)npm install -g billion-context@pr-421Each push to this PR publishes a new version under the Option B — Download artifact
tar xzf billion-context-pr421.tgz
npm install -g packageThis comment is automatically updated on each push. |
[bot] 🏷 PR review — verified, LGTM with 2 minor nits + 1 merge gate. Pre-flight re-run (independent):
Design verified against source:
Minor nits (non-blocking):
Out-of-scope items ( Verdict: LGTM. Merge is gated only on the E2E run on a codex host. (Reminder: PR merges are human-only — I won't merge.) |
[bot] 🏷 Addendum (minor, pre-existing — not from this PR): |
…rip list + handlePluginCompact); add compact endpoint test
|
Re-review: verified against current master (v0.1.74), cleared the E2E merge gate, resolved ework's nit #3 (endpoint test) — pushed as The 8-31 review was against a v0.1.67-era base. Since then #440/#444/#475 landed (all touching What I pushed (
|
[bot] 🏷 Re-verified Merge state: branch merges master@0647309 (v0.1.74). Master has since advanced to 09ef208 (#396 windows-overlay-review-fixes), which touches only Pre-flight on
E2E gate: couldn't re-run independently here — the sandbox now has the codex binary but no reachable Responses upstream. I accept your first-hand E2E PASS (real codex 0.147.0, 4-phase core, zero failures) as the gate clearance. Your three minor notes: agree with all, non-blocking as characterized. One optional suggestion on (a): the lock-free path's safety rests entirely on the consumer stretch staying synchronous, so a one-line invariant note near One pre-existing item (report-only, same pattern flagged earlier): after the master merge, Verdict: LGTM stands, now verified against current master. Ready for human merge per AGENTS.md whenever you click. |
Picks up ranxianglei#422/ranxianglei#421: syncBlocks no longer crashes processTurn on id-less host-shaped messages (0.0.90 regression from the ranxianglei#233 subid-coverage pass; every earlier release silently digested that shape). No bili-side changes required — both lanes normalize ids on their own paths; this keeps the pinned floor at the fixed kernel.
…anglei#2149) Add the solver lane of ranxianglei#2149 as a model-specification (route 4) proof: - proof/spec/*.smt2: byte-level contract of outbound-body assembly (String theory over bytes; impure points modeled at the interface as free functions/free inputs per owner stance) plus nine obligations: T1 growth stability (f(H+[m]) vs f(H) share a prefix of depth D past the merge-anchor's stable content; two scenarios: anchor flip and stationary) proven UNSAT in refutation form, T2 ref non-reuse under the persisted monotone cursor (UNSAT), and mutation twins that MUST be found (stable-region byte rewrite below D; post-archive cursor reset reissuing the dead high number 5 = the documented ranxianglei#421 residual, model hui=3 creset=4 n3=4 n4=5). - tests/cache-theorem.test.ts: z3 driver (PATH CLI or python module; solver subtests skip individually when absent so the main suite stays green) with per-check timing, plus grounding subtests pinning each spec axiom to the real code it abstracts (esc algebra vs JSON string encoder, mktag vs indexToRef, allocation rules vs assignRefs/ allocateFreeRef). - .github/workflows/ci-theorem.yml: dedicated ubuntu-only theorem lane, pinned z3-solver==4.9.1.0, paths-filtered to the assembly surface. Pure test/proof surface: zero production code touched, kernel/** untouched, no config surface added, no behavior changes.
What
Fixes #395: after an in-session omp native compaction (
/compactor auto-threshold), bili's per-sid registry silently reuses stale state,syncBlocksdeactivates every block whose raw ids left the shortened history, anddecompressbecomes permanently unreachable — the ledger break #19 shelved.This wires the omp
session_compacthook bili was ignoring and degrades the now-unreachable blocks into an auditable pre-compaction archive instead of silently dropping them.Mechanism (from the issue, confirmed against source)
syncBlocksdeactivates blocks whoseeffectiveMessageIdsno longer intersect the visible history — silently. Retained-tail tags point at dead blocks → unsolvable.byRaw/byRefare additive (never removed) → stale mappings persist (the 幽灵 ref 永不回收:编号单调膨胀、逼近 99999 时 throw 并静默停摆该请求压缩;orphan-gc 失活块同样泄漏映射 #390 leak).Changes
src/agent/pi.ts(omp reuses this factory): subscribe tosession_compact, fire-and-forgetPOST /__bili/plugin/compact {conversationId}. A failed notification never breaks the agent's compaction.src/plugin.ts+src/server.ts: newPOST /__bili/plugin/compact→handlePluginCompactmarks a compaction boundary on the session for that conversation.src/session.ts:markCompactionBoundary/applyCompactionArchive/preCompactionArchiveOf. After the processTurn that follows the boundary, blocks that were active before but inactive now are recorded insession.metadata.preCompactionArchive(with a reason + timestamp);byRaw/byRefare pruned to the live raw ids.nextIndexis left alone so a freed ref slot is never re-allocated onto a retained tail's live tag. Distinct from the existing Responses/codexnativeCompactionBoundary(which rebases by resetting state).src/server.tsprepareAnthropic+prepareOpenai: capture active block ids beforeprocessTurn, callapplyCompactionArchiveafter it (before orphan-gc). The Responses path is untouched (it has its own rebase).src/loop/core.tsacp_status: lists archived blocks with reason — "content was replaced by the client's native compaction summary … decompress is unavailable".src/decompress-shared.ts:decompresson an archived block returns an explicit error + reason instead of silent failure or wrong-block content.Acceptance criteria
/compact:acp_statusno longer lists unreachable blocks as active;decompresson a retained-tail tag gives an explicit error + reason.compactionBoundary.archivedBlocks);byRawis pruned at the boundary (related 幽灵 ref 永不回收:编号单调膨胀、逼近 99999 时 throw 并静默停摆该请求压缩;orphan-gc 失活块同样泄漏映射 #390).Pre-flight
npm run typecheck— cleannpm test— 873 pass (868 + 5 new intests/compaction-archive.test.ts)npm run build— successtests/e2e/e2e-codex.test.ts) — not run: the sandbox has nocodexbinary (spawn codex ENOENT). The changes are additive to the request pipeline (no behavior change unless a compaction boundary is marked), so regression risk is low; please run the E2E on a host with codex before merge.Note: the
recordAnchoredHistoryRewrite(omp token-accounting) and provider-id-rotation options from the issue are out of scope here — this is the minimal-to-complete bili-side fix.