Adds a kernel-level 'WHEN NOT TO COMPRESS' section to every compress system
prompt (function / text / hybrid), sitting between philosophy and
howToCompress. Previously the only 'when not to compress' guidance in the
kernel was the one-line 'be frugal' philosophy sentence; the dedicated
gate (mid-task work, live user discussion, closing-ritual folds, tiny
ranges, nudge voice) existed only in the pi adapter package and the
lean pack removed even that. Wording owner-approved in chat 2026-11-30.
Changes:
- kernel: new whenNotToCompress section slot (surface-config), gate
constant + builder wiring (compress-tools), lean-pack variant and
pack validation key (packs), new kernel test, regenerated fixtures
- root: ACP-TAGS-only lead prefix in src/compress-tool.ts now includes
the gate between philosophy and howToCompress, keeping the #1881
NEVER-echo prohibition for injectTool=false hosts
- tests: compress-prompt overhead (~450 tok/request) budget calibrations
- e2e-google-compress: demand measured on conversation contents,
self-calibrated against the session's own first-request overhead
(fixed whole-body threshold made the demand point depend on prompt
size); fold span proportional (first 2/3 of refs)
- threads-lane plugin window 5000->6000; issue2672 split window
8000->8500; preflight-hold/compress-responses/window-clamp/
max-output-tokens budgets absorb the gate
- cache-proof: FILLER(0,5) seed phase + byte-based rearm assertion +
ZOMBIE_SETTLE_BOUND 9->10 (gate shifts the fold schedule)
- storage-render goldens regenerated (+1798 B/turn, mechanically
verified: only sha/bytes leaves)
- versions: kernel 0.0.217->0.0.218, root 0.1.218->0.1.219
Tests: kernel 1665/1665, root targeted compress/preflight set 252/252,
typecheck clean; full-suite delta vs clean-master baseline = 0 new
failures (remaining reds fail identically on the baseline).
Resolves the kernel version conflict: master independently bumped to 0.0.214 (past the PR's 0.0.212); the PR's kernel changes (compress.ts/recommend.ts) now sit on top of master, so merged version = 0.0.215 (kernel version discipline). Root + kernel lockfiles synced to 0.0.215. No code conflicts — master's changes (sessions.dir #7803, etc.) auto-merged cleanly.
e7bf782c2 bumped kernel/package.json to 0.0.212 but only the root lock's
'kernel' entry and the kernel's own lock were still at 0.0.211 — the lane
that checks npm install --package-lock-only drift fails on exactly that.
kernel-change: mid-turn diagnostics now go through an injected Ports.warn sink
instead of console.warn, so the inline lane (whose process IS the pi host, whose
stderr is the TUI) no longer paints kernel lines over the input box; and the
funnel-zero diagnostic now only fires for units that cleared the merge gate and
then died at the screen, not for every ordinary short session (every sub-gate
island is the correct, everyday outcome). (#7791)
The host side cannot fix this: the kernel is inlined into every dist entry and
has no host-facing diagnostic port at all, so bili's tee logger could never own
these lines.
PR #7684 (wire-granularity pinning + cross-lane render fidelity + switch
hardening) was developed against the pre-7773 egress state shape. Aligned
on merge:
- stampEgressSeqs: featureEnabled -> egressPlaneGateOn (the plane has ONE
gate, 7773 follow-up)
- tests/egress-authority-rethrow.test.ts: corrupt the materialized state
by deleting it (no payload column left) — flow corruption unchanged
- c6/c7/fold-coords/switch-fold-db: the rollback sections audit the
legacy tables, which a fresh 7-table eg instance never has — force the
full DDL (BILI_TEST_FORCE_FULL_DDL, test-only) so those audits keep
their meaning; the 7-table gate itself stays covered by
eg-sweep-egress-identity
- lock-sync: regenerate root + kernel package-lock.json (the PR bumped
kernel/package.json without its lock — the CI red it landed with)
Verified: kernel 1683/0, new PR suites green (c4-c7, crosslane-wire-pin,
rethrow, fold-coords, switch-fold-db, msgid-pin-wire-form, 6525), egress
family 201/202 (1 skip = bench gate), wire-contract 26/26, typecheck,
build, architecture-docs + lifecycle-ledger + config-coverage guards.
Retarget the kernel version bump from 0.0.207 to 0.0.209: master has moved
to 0.0.208 (0.0.207 was consumed by an unrelated kernel release), and the
code does not depend on the number.
Co-authored-by: guowenjie1992 <52691423+guowenjie1992@users.noreply.github.com>
Source-PR: #6345
(cherry picked from commit bd4548a4d346b363c8fdb06b6e2602fb8184b9e9)
(cherry picked from commit 6ac84b74b3250ead06c5013a6742e3f03b43cb62)
Kernel Boundary rule 2 requires a version bump whenever kernel/src changes.
#7614 (covered-reasoning stopgap) changes instance-reid.ts + prune.ts but
dropped its bump (the original 0.0.206 -> 0.0.207 went stale against
master's 0.0.208). Re-bump from the current master version.
Fixes CI kernel-guard rule 2. Rule 1 (the 'kernel-change:' PR-body
declaration) still needs the author.
A fresh-fold range whose integrity withdrawal leaves NOTHING foldable (a
tool turn astride the protected-zone boundary) used to fatal with
'Range would split N turn(s)...', and under the atomic batch contract that
one fatal rolled back every sibling range that would have folded fine.
The model then re-sent the same batch — full context re-read every time —
until the breaker fired. Like the zone fatal (#4521), an empty-after-
withdrawal fresh fold is now a legal no-op: siblings fold, the doomed
range gets one accurate warning pointing at older ranges.
UnitProjectionFatal gains 'degradable', set only by the fresh-fold
withdrawal path; the merge split fatals (excluded-merge / actionable
split) do not set it and stay hard errors. recommend/report sides are
unchanged (fatal units still demote to gaps / flag rows).
kernel-change: downgrade an apply-side fatal to a no-op receipt so one
doomed range can no longer kill a multi-range batch; the host side cannot
express this — the verdict is produced in the kernel projection.
⚠️ MODEL-FACING TEXT CHANGE: one new warning string (the no-op receipt);
no existing instruction text moved. The pinned turn-integrity tests
(issue684 / issue5531 / tool-pair-integrity) keep asserting the guard
holds — nothing of a split turn ever folds — while expecting the new
no-op outcome instead of the old error.
The batch rejection message told a too-short summary to "shorten or split
... to fit its cap" — backwards advice that made the summary shorter, so the
model retried into a guaranteed-fail loop (full context re-read each round)
until the circuit breaker fired.
validateSummaryLength now throws a typed SummaryLengthError carrying the
direction (empty / tooShort / tooLong); the batch screen tracks which
directions fired and renders direction-aware remediation: too-short/empty
-> "expand ... do NOT shorten it", too-long -> "shorten or split ... to fit
its cap", mixed -> both. The drop-the-range exit is always offered.
kernel-change: fix a self-contradictory error-message literal (mechanical
bug) — no algorithmic/state/wire-shape change, only the remediation text of
the batch length-rejection. Regression test:
kernel/tests/issue6730-length-remediation-direction.test.ts.
⚠️ MODEL-FACING TEXT CHANGE: none — no model-visible string moves;
sweep/fate recognition only.
kernel-change: owner-directed ("kernel 的也一起提交吧", 2026-11-22,
issue #7521 thread provenance) — the mechanical-recognition gap class:
a carrier detector that provably mis-negates the current wire shape.
Reproducing regression rows added (line-form carrier exempt + line-form
negative control), declaration present, human review tier still gates.
The defect: hide-consumed's sweep-exemption detectors
(quotesActiveBlock / quotedRangeKeys) parsed only the JSON arg shapes
({content:[…]}, flat {startId,endId}, stringified array). The current
wire form is {content: "m00150–m00220 topic\n<summary>"} — a line-form
string — so JSON.parse failed, the re-sent carrier pair read as a
failed orphan, and the next fold at/before its ref swept it
permanently. With the bili-side anchor strip (#7479) in place that is
a zero-wire-carrier fold: the block's summary exists nowhere on the
wire (storage keeps it for decompress, but every bN citation
round-trips through decompress). The same blind spot demoted
foreign-name (MCP-dialect) line-form carriers from fate "active" to
"orphan".
The fix: quotedRangeKeys now UNIONs the legacy field extraction with
the canonical compress-args parser (parseCompressArgs — the grammar
applyCompression itself executes, #3236 single-projection discipline),
so every range shape the kernel will execute is recognized as a quote.
Recognition only grows (monotonic superset), keeping the established
fail-safe direction (unparseable = not a carrier = under-sweep, never
over-sweep). quotesActiveBlock is unified onto quotedRangeKeys — the
two near-duplicate detectors can no longer drift apart.
Evidence: kernel suite 1655/1655 on the stacked head; the #3769
carrier table gains the line-form carrier row and the line-form
negative control (both directions, #3617); typecheck clean.
Fixes#7521
The top commit bumped kernel/package.json to 0.0.201 but skipped lockfile
regen, leaving acp-kernel at 0.0.200 in both package-lock.json (root,
acp-kernel entry) and kernel/package-lock.json. The lock-sync CI job (#2704
drift guard) regenerates via 'npm install --package-lock-only' and fails on
any residual diff. This commit is the exact output of that regeneration
(idempotent fixed point): 3 version lines 0.0.200 -> 0.0.201, no registry
churn. Fixes the red lock-sync check on PR #7428.
The #5919 merge no-op treats every ref='BLOCKED' partner as "cannot be
closed now", but that conflates two very different cases. A content-free
BLOCKED partner (body removed by native compression) carries no live wire
content and can never age into foldability, so letting it doom the merge
turns the no-op into a permanent deadlock: every merge covering its turn
re-hits the same skip and the session stays stuck at its context ceiling
(#6709, session-ad47cd30, 6,115 BLOCKED). A LIVE protected tool /
unrecoverable media is pinned to ref 'BLOCKED' by assignRefs too, with its
full body still in the wire — folding it in drops protected content and
leaving it split emits an orphaned tool_call/tool_result.
Exempt only content-free BLOCKED partners (ref BLOCKED AND not
live-protected-tool AND not host-protected AND not unrecoverable-media)
from the merge-deadlock; they flow to the #5919 rung-2 fallback and are
folded into the merged block, closing the turn. Live protected tools /
media still doom the merge into the honest no-op.
This is the correct superset of the two related PRs (#6719: flow-all-
BLOCKED-to-rung2; #6731: key-on-ref-BLOCKED, keep-split) — both keyed on
ref==='BLOCKED' alone, and both masked the live-protected case by giving
the protected partner a numeric ref in their regression tests. 5919-5 adds
that guard (live protected tool stored as ref BLOCKED still no-ops).
Refs: #6709, #6719, #6731
Conflicts: kernel version files (master 0.0.193 from the #6132 fold-point
removal + this branch's 0.0.194 -> 0.0.195) and one relay.ts import line
(master dropped relocateCompressCarriers; this branch adds
buildBlockOpsSystemPrompt — the resolved import carries only the latter;
no fold-point call sites survive in the merged relay).
Re-verified on the merged tree: kernel 1631/1631, host targeted 201/201 +
surface/config 374/374, typecheck + build green.
Owner ruling (review of this PR): acp_retire / acp_restore / acp_rewrite
must sit behind ONE switch, default OFF, injected only when ON — the
always-on surface costs ~0.7k estimated tokens per request on every
session of an enabled proxy.
Follows the absorb opt-in pattern end to end:
- kernel: definitions + name consts stay exported, but the 3 tools leave
the default arrays (ACP_TOOLS_{OPENAI,ANTHROPIC,RESPONSES,GOOGLE},
ACP_READONLY_TOOLS_RESPONSES, ACP_TOOL_NAMES); they stay in
ACP_MUTATING_TOOLS (dispatch must drive the compress loop when enabled).
New BLOCK_OP_TOOL_NAMES set + buildBlockOpsSystemPrompt(lane) section
builder; the default prompts are back to "four context-management
tools". New Config.blockOps { enabled } (off by default); absorb/ccr
tool-name predicates include the block ops.
- host: compress.blockOps config (3-level merge like absorb);
blockOpsEnabled / effectiveBlockOpsConfig / storeEffectiveBlockOps
(per-session, plugin tool API parity); isProxyToolFor, the proxy-lane
inject* extras, the responses hybrid lane, the round-2 cache seam, the
plugin manifest + tool API, the MCP dialect note and the system prompt
all inject/advertise the 3 only while enabled; the MCP note, prompt
and per-session metadata stay byte-identical to pre-#5765 while off
(zero footprint: no metadata key written while off — the storage-render
goldens match master byte-for-byte).
- dispatch: enabled calls run the kernel ops exactly as before; a stray
call while disabled gets a model-facing "not enabled on this bili proxy
(compress.blockOps.enabled is not true)" receipt and never touches state.
- wire-contract goldens revert to the master shapes (the default surface
is unchanged), and this commit supersedes the three earlier fix commits
on this branch (test-pin updates + storage-render regen + payload
retunes): with the default surface back to the master shape, those
test files return to the master versions and the 27 red CI tests are
green again without any calibration changes.
- docs: compress.blockOps in configuration.md/.zh-CN.md + website seed;
kernel 0.0.194.
Verified: kernel 1656/1656; host targeted 201/201 (the 15 previously
red CI files + block-ops/snapshot/wire-contract), 348/348 + 63/63
surface/config invariant files; typecheck + build green.
Owner-directed full removal of the experimental compressAtFoldPoint /
compressAtFoldPointClearThinking feature (v1 #5471 + unreleased v2 #5949):
two distinct live pathologies in 9 days on its own target model family —
2026-11-08 voluntary re-compress loops (v1, #5949 field report) and
2026-11-10 authorship misattribution (v1 in v0.1.213 production: the pair's
relocation left the turn's own answer text bare at the transcript tail, and
a 27B model read its own last utterance as a user message, m00376 chain).
- delete kernel/src/relocate-compress.ts + kernel/tests/relocate-compress.test.ts
- drop the relocate-compress-carriers pipeline node (after hide-compress-calls,
before view-latch) and its registration
- drop Config.compressAtFoldPoint / .compressAtFoldPointClearThinking /
.reasoningDroppable and the public relocateCompressCarriers/plan exports
- drop the already-folded-echo parse kind + v2 pointer marker
(parse-compress-input.ts) and the two echo tests
- kernel 0.0.192 -> 0.0.193 (both package-locks)
kernel-change: removed relocate-compress.ts, the pipeline node, 3 Config
fields and the public exports (full feature removal, owner decision after the
2026-11-10 incident, #6132); with the switch off the transform was a
byte-identical no-op, so removal changes nothing for the default layout.
kernel 0.0.192 -> 0.0.193.
Closes#6132 (kernel side; host/web/docs follow in the next commit of this PR)
Resolve conflicts after master advanced (PR #5903):
- acp-kernel version -> 0.0.192 (master 0.0.191 + 1 for this PR's kernel/src change); synced kernel/package.json, root package-lock.json, kernel/package-lock.json
- CONFIGURATION.md/.zh-CN.md are redirect stubs now (docs moved to docs/ on master); regenerated docs/configuration*.md so compress.minSummaryLength carries the batch-total wording (#5894)
Field incident (2026-11-08, session 01a1b6b3, four symptoms, one loop):
a model under nudge pressure copied its most recent compress call as a
template — but compressAtFoldPoint v2 had rewritten that call's args to a
short ack pointer, so every re-send failed content-not-array; each failure
receipt re-appended the ~200-word format lecture plus a repeat counter the
model misread as "the user asked the same thing N times"; and because the
burst's turns never reached an upstream settle, the token meter fell back
to the raw resent-history bound and read 112% right after a successful
fold (238112/212992 while the real outbound was 83K) — re-nudging the very
loop the fold was supposed to end.
1. kernel: parse-compress-input classifies content echoing the v2
relocation pointer as kind=already-folded-echo (no lecture), and
salvages a content STRING that encodes one entry OBJECT (refs inside
the JSON) through the shared entry validator.
2. host: stream.ts acks already-folded-echo as a one-line no-op (no
repeat-guard counter; still loop-tracked so runaway bursts hit the
#2146 breaker), and collapses identical parse-failure receipts to a
one-liner from the 2nd occurrence on — first failure keeps the full
teaching receipt.
3. meter: effectiveTokenCount's #5135 pending-credit branch no longer
requires !anchorStale — during a compress burst the send chokepoint
keeps contextTokensSource="estimate" so the credit exemption was dead
exactly when needed; credit is still bounded by the next real settle.
kernel-change: acp-kernel 0.0.188 -> 0.0.189 (parse-compress-input: new
CompressParseKind member + stringified-entry salvage; owner-directed fix
per 2026-11-08 field review of session 01a1b6b3).
Resolve version/lockfile conflicts: acp-kernel converges to 0.0.187
(master was at 0.0.186; the PR's kernel/src change sits on top, so it
bumps one past master). Synced across kernel/package.json, root
package-lock.json (kernel workspace entry), and kernel/package-lock.json
(top + packages[\u201c\u201d]) so all three surfaces agree.
- throttle F1: requestModelFromBody memoizes {body→model} on a request-scoped
cacheHost so the pre-ingest early-hold gate and the full 429 gate share ONE
body scan instead of walking the multi-MiB document twice per POST
- media-refs F2 (kernel): pre-signed/expiring HTTP(S) URLs (X-Amz-*/X-Goog-*/
X-MS-*/SAS/Expires/Signature/…) are classified NON-recoverable — the handle
lapses before a folded summary is decompressed, so the message keeps pinning
- persist: an envelope that OOM'd on decode is snapshotted before the next
save overwrites it (preoomPending set + withPreoomSnapshot)
- session-resolve: every msgid-rescue firing now logs hits/exit-context as
#5719 overlap-rung reachability evidence
- kernel 0.0.185 → 0.0.186 (media-refs change), lockfile synced
Review findings from #5865 master-diff review (P2 batch).
Conflict resolution: master shipped the sibling fix for this family (#5438 via PR #5522: two-sided heal inside coreToAnthropic, demote-only) plus the insertBeforeTrailingSystemRun helper (host wiring pending in #5441). Take master's approved heal semantics wholesale; keep #4715's residual contribution: the healAnthropicSystemPositions standalone export + the three host final-array call sites + WC-023 pins (ledger entry kept from master's side, one entry per id). Branch move-past-next-user design superseded by the owner-approved #5438 approach. Kernel bumped 0.0.180 -> 0.0.181 (kernel-change-vs-base rule).
The #5620 usage wall: in image-heavy workflows every message carrying
remote-URL images / DeepSeek Files API file refs was permanently pinned
by hasUnrecoverableMediaPayload, turn integrity pinned its partners, and
the context floor climbed to ~70% of the window while folds kept pace
with growth but could never lower it.
Split the class (conservative enumeration):
- new kernel/src/media-refs.ts: extractMediaRefs pulls known re-access
handles (non-data: URLs, file ids, fileUris) from all five wire
sidecar families; hasRefRecoverableMediaPayload = at least one handle;
unknown opaque shapes keep pinning until their semantics are known
- hasUnrecoverableMediaPayload media branches now return
!hasRefRecoverableMediaPayload(msg); control-plane structured system
branches (#3992/#4166) and refless shapes are untouched
- apply path appends a deterministic MEDIA REFS section to the stored
block summary (applySingleRange union incl. consumed-block carry;
applyRefolds per-block carry), so handles survive folds/merges/
distillations mechanically — never model discretion (on the wire a
URL part is often invisible to the summarizer); decompress restores
the original losslessly either way
- compression-rules: MEDIA REFS preservation added to T1/T2/T3 rules;
golden regenerated (justification: #5620 root fix, three prompt fields
extended additively, COMPRESS_PHILOSOPHY unchanged)
- cosmetic: normalize one stray leading space on the tier-2
Open-objectives bullet (pre-existing, touched while inserting the
sibling line)
Legacy sessions self-heal without migration code: pre-#5620 BLOCKED refs
on now-foldable media migrate to fresh numbers via the existing #3805
deferred-render path (carrier render deferred to next fold boundary).
kernel version 0.0.179 -> 0.0.180
#5293 re-anchors the growth reference to the current meter on every
user-aborted turn, which also zeroes the MEASURED growth from the old
reference up to the pre-abort anchor. Abort-heavy clients (85 absorbs
in one reported 4.5h log) never cross the growth floor again: a 300K
ready mass idles for hours ("growth 4450 < floor 33750, ready: T1
302220") and the session finally compresses a ~330K backlog.
Fix, v2 semantics (single abort stays byte-identically quiet as #5293
pinned):
- the host banks the skipped measured growth into
state.nudge.absorbedDebt and counts the absorbs (absorbCount);
- debt and the new backlog-drain guard pay only once absorbCount >= 2 —
one abort after a long quiet stretch can bank a whole interval, but
it must not re-fire the cadence on the user's redirect (#5293 pin);
the second absorb proves the session is abort-heavy, not
redirect-polite, and the 209-era cadence recovers;
- backlog-drain guard (same philosophy as the #194 first-sight
bypass): count >= 2 + debt > 0 + no outstanding nudge + ready mass
>= 2x the T1 threshold drains now instead of idling behind the
starved growth leg;
- applyCompression resets the debt bank and the count with the other
baselines; idle reasons surface the debt for diagnosability
("growth X + absorbed Y across N aborts < floor Z", or "held
(single abort, #5293)" for count 1).
kernel-change: nudge decision only (kernel/src/compress.ts, types),
host booking only (src/session.ts absorbAbortedTurnGrowth); no config
surface added.
tests: kernel/tests/issue5415-absorb-debt-nudge.test.ts (8 cases incl.
the #5293 single-absorb pin), tests/issue5415-absorb-debt.test.ts
(booking arithmetic + count), #5293 e2e unchanged and green; kernel
suite 1521/1521; host nudge/abort suites 23/23; tsc clean.