Drive-by (review of #7281): the PR updated the isDirectiveOnlySystem comment
but left three stale spots that now contradict the new behavior —
- anthropic.ts heal comment: 'accepted at ANY position, so it is never healed'
- issue5432 orphanSystems helper: still exempted directive-only on BOTH sides
(a divergent mirror of the old behavior; the real heal now checks the
PRECEDE side for them). Made the helper judge directive-only systems on the
precede side only, matching healIllegalSystemPositions.
- issue5432 test name + issue4292 header comment: 'exempt at any position' /
'directive-only anywhere'.
All 53 targeted system-position tests still pass; kernel typecheck clean.
kernel-change: the ANY-position exemption for directive-only systems
(content:[] + output_config) does not hold on every upstream. A real
Anthropic endpoint rejected system(directive)→user adjacency with the
same 'must precede an assistant' 400 as content-bearing systems,
permanently bricking the session after a degenerate fold. The fix moves
an illegally-positioned directive-only system to the trailing run
instead of skipping it, preserving the effort/tool-control semantics.
Closes#7270
⚠️ MODEL-FACING TEXT CHANGE: removes a per-turn model-visible status line
(this is prompt-surface removal; see §7.3 regression inference below).
The line only fired on turns where the nudge banner was NOT delivered
(!nudge.shouldInject), so its "compressible now" list was always the
below-gate residue — exactly the runs the compress receipt in the same
turns labels "named for visibility, not as fold suggestions" / "No
compressible ranges remain — continue the task without compressing".
Two channels of one kernel gave opposite fold instructions every turn.
Live session 01a1dd94 (2026-11-16, v0.1.215): a 51K two-range fold,
then 1.4K/2.5K fragment folds (b118/b119) while the line fired on every
turn — and the model still guessed an end ref above the highest
(m05664 > m05609), so the line's anti-guessing payoff was not delivered
while its standing fold-directive cost was. The dominant ref-guessing
source it chased (#6855 phantom headline echo) was fixed in #6856; the
ceiling keeps being carried by the compress receipt ("Session highest
allocated ref is mX") and the unknown-ref refusal.
Regression inference (§7.3): the removed field is the ceiling ref the
model read between banners. After removal the model learns it from
receipts / unknown-ref refusals / refs visible on incoming messages.
Residual risk (owner-ruled, 2026-11-16): in a long quiet window the
model can extrapolate a tail ref again; since #6856 the success headline
no longer plants a phantom endpoint, and any wrong guess self-corrects
within one refused round-trip (the refusal lists the highest ref and the
valid refs). No number is introduced; the change removes text only.
- kernel/src/compress.ts: drop the construction block + formatK helper
+ ProcessTurnResult.statusLine
- kernel/src/types.ts: drop the statusLine field
- src/server/prepare-{openai,anthropic,google,responses}.ts: drop the
four ephemeral trailing-user-message append sites
- kernel/tests/issue4521-retry-livelock.test.ts: armed-but-silent
assertions inverted to absence (regression test)
Verified locally: typecheck clean; issue4521-retry-livelock 5/5;
compress.test + issue3910-lane-nudge-wiring + side-lane-invariants +
verif-responses-ingress + 9 nudge/banner suites = 84 pass / 0 fail
(1 env-skip, no SMT solver); build + unused-exports + test-import-graph
clean. Full-suite verdict = CI test lane on the pushed head (§7.2).
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
Server tools (advisor, web_search, code_execution, ...) carry both halves of
an exchange inside one assistant message. anthropicToCore splits every block
into its own BiliMessage, so a fold can cover one half and leave the other;
Anthropic then rejects the whole request:
messages.5.content.0: unexpected tool_use_id found in advisor_tool_result
blocks: srvtoolu_... Each advisor_tool_result block must have a
corresponding server_tool_use block in the same message.
coreToAnthropic now drops a *_tool_result without its server_tool_use (and a
server_tool_use without its result, except in the last message) within the
same assistant message. Legal shapes round-trip byte-identical; plain
tool_use/tool_result is untouched. Bumps acp-kernel to 0.0.196.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit ca177b9c74)
Production shape (acp host, 2026-11-09 night): a mega-turn with a
protected-tool exchange every ~4 rounds + a mid-turn block cut mid-group
fragmented the compressible surface into 3-5K-char islands. Every island
sat below compress.minCompressRange (5000 chars), mergeRangesToThreshold
dropped them all, recommendedRanges=[] reached the host, and the
emergency lane fell back to irreversible physical pruning three times in
one night — while the host's message-level diagnostic still counted
84-149 'collectible' messages. 28 spine-cut no-range diagnostics same
day, other sessions.
Two independent killers, both fixed:
1. mergeRangesToThreshold closed its batch at every index gap, so
sub-gate islands could never accumulate. It now bridges across gaps
buildCompressibleRanges marks span-safe (bridgeableGapBefore):
protected-tool exchanges (apply carves them via
filterProtectedToolMessages, 'Bug 39') and integrity-withdrawn members
(apply withdraws them again, they stay visible — #564 reverse-split
semantics). The per-CALL #847 gate sums chars over all ranges in the
request, so a bridged span clears the gate each island missed. Hard
gaps (blocks, carriers, media, dead refs, unrefed, soft zone — whose
interior hits truncate the fold at the first protected message,
#3953) still close the batch, and sub-gate remnants still emit
nothing. buildCompressibleRanges tracks gap composition
(hardGapSinceCompressible) and chains it across withdrawals.
2. Ranges ending adjacent to a mid-group block cut died at screening
regardless: the pair-boundary adjustment widened the span across the
coverage boundary, dragging the block in as nested/consumed, and the
merge-integrity path resolved the unit to fold-nothing (fatal=null,
filteredIds=0). projectUnit now clamps the ADJUSTMENT's widened
head/tail at the coverage boundary (clampAdjustmentAtCoverage) —
safe because covered halves are invisible to the integrity judge
(#5531); the requested span itself is never clamped, so refold
candidates keep resolving. The clamp reuses the shared index map so
the #5337 O(units x n) discipline holds.
Observability (the incident was undiagnosable from the host side):
screenRecommendedUnits warns (budgeted) for every silent drop class —
fatal, empty projection, refold-guard — and the recommend node warns
with stage-by-stage numbers when the funnel zeroes with material
present.
Tests: tests/megaturn-protected-gap-bridging.test.ts pins the incident
shape end-to-end (bridge + clamp + full-chain advertise, plus a
negative for hard gaps). issue5531 closed-loop updated: the recovery
block is found by coverage now that the clamp keeps the seed block
active instead of dragging it into a merge. Full suite 1626/1626.
(cherry picked from commit fe375e5738)
A compressed block's summary may only be injected while it still describes
content on the wire. The current predicate asks whether ANY covered message is
still present, so a host rewind that truncates part of a span keeps the whole
summary alive and the model reads a description of history that no longer
exists. Reap (#2695) does not catch it either: it needs a strict majority of
covered ids absent for three consecutive passes, and a partially truncated span
keeps its majority.
The gap's shape, in the block's own coverage order, is the discriminator:
- survivors a prefix, missing the newest end -> the rewind shape; deactivate
- survivors a suffix, missing the oldest end -> the host dropped old history;
the summary is the only record of it, so keep it active
- interior/ragged holes -> the id-churn shape (ids are
content hashes); keep it and let fold-reconcile re-key the churned ids
- nothing covered visible -> defer to the positional
witness (#4316, unchanged): a surviving ledger position is the churn /
merged-pair shape, not a deletion
Everything except the tail gap keeps today's keep-alive behaviour, so the only
behaviour that changes is the shape this change names. The positional witness
is not touched: narrowing it to exact coverage would false-kill merged content
(a pair collapse covers fewer ids than positions).
Tests: sync-config gains the four shapes plus the positional-witness
composition and the no-witness deletion case.
(cherry picked from commit 7c4d4b9239)
Two model-facing texts still demoed the retired raw-array shape for
compress content (schema accepts ONE string only; strict hosts reject
the array):
- tierActionHint (kernel/src/compress.ts): tier distillation/
condensation offer — appended to the 'range already compressed'
receipt, exactly where a weak model is most likely to copy it
- armed-breaker format reminder (src/stream.ts): taught 'content'
must be a non-empty array of {startId,endId,summary} objects
Both now mirror the compress tool schema and the nudge example
(content: "b1-b5 optional topic\nsummary markdown..."); PLUGIN.md's
/__bili/plugin/tool example shows the string form with a note that a
JSON-encoded array inside that same string is still accepted.
Tests: regression-bili-470 pins the new wording; issue4812 gains a
negative assert against the old array phrasing. Kernel 1565/1565,
host typecheck green.
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)
#5392 is an unrelated open DSH pruner bug and #5585 an unrelated compaction-leak
issue; the real source threads are #5390 (Claude-through-Google tool_result-first
part order) and #5584 (codex marketplace .tmp containment). Comments and the
test file now cite the verified GitHub numbers.
kernel-change: make normalizeGoogleUserPartOrder/coreToGoogle model-aware so Claude-through-Google targets keep tool_result-first part order. The host side cannot solve this: the offending reorder happens INSIDE the kernel codec (coreToGoogle's flushUser), and the stable text-first partition is non-invertible, so no host-only workaround exists. Owner approval via decision request #5393 (option A). Kernel version 0.0.188 -> 0.0.189 (master was already at 0.0.188 past this PR's 0.0.175->0.0.176 base bump).
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).
Follow-up to 2dd1f997c: the v2 fold-point carrier (plain user text carrying
the relocated summary) had NO checkpoint protection — a plain message-ref
compress range could fold it as if it were ordinary user text, re-distilling
a summary whose source history is already folded away (#335's exact hazard).
The carrier now carries summaryOfBlockId = the anchor block of the pair
(first block; multi-block pairs virtually always get consumed together by
the block-ref distillation that spans them). While the anchor is active:
- recommend.ts screens the carrier as a protected gap — no advertised range
bridges it;
- unit-projection carves it out of any hand-rolled plain range (it stays
visible, with the existing warning pointing at block refs);
- once the anchor block is consumed by a block-ref distillation — which
sees and absorbs the carrier text into the new summary — the carrier goes
stale and folds like ordinary text: the RESULT remains compressible, the
SUMMARY cannot be silently re-distilled as plain text.
v1 (pair moved verbatim) had the same gap; nothing marked the moved pair.
kernel-change: carrier protection hook-up (#335 predicate); 0.0.188 → 0.0.189.
v1 moved each still-visible compress call/result pair verbatim to its fold
point. With the knob ON that leaves a mid-history wall of fully-shaped
compress interactions, which weak-attention models (qwen3-27b) read as an
invitation to keep compressing — observed as voluntary re-compress loops
even while the ledger showed healthy headroom.
v2 keeps exactly what the model needs at each spot:
- the SUMMARY TEXT (args content) is re-emitted as a plain user text carrier
at the fold point it describes ('[bili fold summary — block(s) bN …]');
- the pair KEEPS its chronological slot; the call core's args are replaced
by a short pointer ('compression succeeded — summary relocated …; already
folded — do not re-compress'), so it no longer reads as an open command;
- the result core is forwarded verbatim (compression still 'succeeded').
View-only and deterministic as before; idempotent via carrier id
(acp_reloc_<callId>) plus an args marker probe (survives host round-trips
that strip synthetic ids). The call core rewrite is a shallow clone — input
cores are never mutated. Boundary rule, ambiguity skips, #4732 tail
fallback and the predicate-gated thinking clear are unchanged.
kernel-change: fold-point relocation semantics v2 (owner-directed fix after
live mis-behaviour analysis on a dev lane); kernel 0.0.187 → 0.0.188.
v0.1.213 regression (issue #5919, session-ad47cd30): when a turn group is
shredded across blocks — reasoning covered by a surviving higher-tier block,
call covered by the block being merged, result still visible (or protected /
BLOCKED) — the #5789 exclusion ladder had no rung left:
* fatal path: the error promised the partners would "age into coverage",
which never happens for a covered call's result (INV2: a lone result can
never fold) — every retry of the advertised merge re-failed identically.
* silent path: the exclusion retry "succeeded" by folding nothing (the
span's geometry trims the call whose result sits outside), so the merge
no-oped forever with the conflict still live.
Fix (unit-projection.ts, merge stuck-branch):
1. Doomed check — if any stranded visible partner can NEVER fold (BLOCKED,
recent-zone, protected tool, unrecoverable media), the merge is an
idempotent no-op success (every block stays active — the #4484
never-drop-coverage invariant holds) with guidance that says exactly
what is protected and that retrying will not help.
2. Rung 2 — when rung 1 (the exclusion ladder) cannot complete the merge
(retry fatal, or retry folded nothing) and every stranded partner is
foldable, the fold extends itself to those partners (bounded: <=16,
fixed-point integrity re-judge must come back clean): the new block's
coverage closes the turn, the conflict clears, and the merge proceeds.
This is the exact manual unblock the old error text directed, now done
automatically.
3. actionableSplitError keeps the "cannot satisfy turn integrity" phrase
but names the exact unblock range (plain compress over
mNNNNN..mMMMMM, then retry) and drops the false "age into coverage"
promise.
compress.ts: the filteredIds=0/consumed=0 no-op now propagates the
projection's warning (the skip guidance reaches the model) instead of
replacing it.
Pinned: kernel/tests/issue5919-shredded-merge.test.ts (4 shapes: extend,
BLOCKED no-op, protected-tool no-op, in-span control). Two #5789/#4484 pins
amended — they pinned the pre-fix dead-end itself (b4..b4 self-range no-op,
b2..b2 "impossible merge" refusal); both now pin the recovery, and the
breaker-safety property (a retry never errors) is asserted explicitly.
Full kernel suite: 1619/1619.
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.
- upstream-throttle: a saturated hold map (64/64 account-wide, no model-scoped
hold to evict) silently dropped the next model-scoped 429 — now it warns
once and the send is documented as ungoverned (#5199/#5889)
- knobs: network.throttle429Scope matches its value EXACTLY; a typo now warns
once and falls back to credential instead of silently doing so (#5199)
- kernel media-refs: block summaries written by older builds can carry refs
looksEphemeralSignedUrl would reject today; the carry-forward into merged
blocks now applies the same filter so a dead signed URL cannot survive
forever (#5865 review). EPHEMERAL_QUERY_PARAM also gains the Huawei OBS
x-obs-*, Tencent COS x-cos-* and Baidu BCE x-bce-* prefix families.
- native-intercept/dsh-native oversize refusals now say what to DO (restart
host / fix the model window declaration), and dsh durable lines format
numbers with thousands separators (#2924/#4068)
- website: streamKeepaliveMs → streamKeepAliveMs (the real knob name) across
main.js, docs/index.html, config-reference/process.yaml
- CONFIGURATION.md/.zh-CN.md: throttle429Scope exact-match + model-string
aliasing caveat documented
- store/persist: #5755 refs ord-crossing guard (touching rows stay in the
old-refs set until the new-refs commit lands) kept as defense-in-depth
with a regression test
kernel-change: 0.0.186 → 0.0.187 (media-refs carry-forward filter + cloud
prefix families; compress.ts starvation-bound comment corrected)
A multi-candidate compress batch now passes minSummaryLength when its
COMBINED summaries reach the floor; one lazy paragraph no longer sinks
the whole batch. A single folding candidate still guards its own
summary (legacy error text unchanged); EMPTY and MAX stay per-range in
both shapes. The batch verdict is threaded into apply-time validation
via minFloorCovered so a short refold/fresh range cannot re-fire the
per-range min after the pre-check passed. kernel 0.0.180 -> 0.0.181.
The alternation's $ anchor made 'X-Amz-Algorithm' (and every other
x-<provider>-* signed param) fall through as durable. Keep $ only on the
exact-key branch.
- 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).
A pressure/emergency nudge waits for a usage-grade meter reading, so a session whose upstream never reports usage was deferred forever — estimate on every round, hold forever, no automatic compression (#728/#553: silent backends and anonymous zero-baseline forks live there). Add nudge.maxEstimateHoldRounds (default 2): the first two consecutive estimate rounds keep the phantom-ghost protection (#5860), after that the pressure band fires on the estimate like legacy. 0 disables the hold; off-switch remain nudge.requireUsageSampleForPressure=false.
Aborted streams (user ESC) and short-TTL upstreams drop the usage report; the
meter then falls back to a char-bound LOCAL ESTIMATE that structurally runs
~3x what will actually be billed (two same-day field cases on 0.1.212: an
ESC'd session's needle jumped 9478→228376; a marathon session took two
back-to-back 153% phantom EMERGENCY injections and burned T2/T3 rewrites plus
prefix cache). The pressure band historically fired on such bad meters at once.
Now the kernel defers the pressure-band nudge ONE round when the host marks
the reading estimate-grade (tokenCountSource="estimate"): the next request
carries a fresh billing report and decides from real numbers, cost ≈ 0. Billed
readings and hosts omitting the source marker keep byte-identical behavior;
non-pressure tiers (growth/cadence/first-sight mass) and the hard overflow
backstops are untouched. The host-side early-advertising arm (emergencyNudge)
mirrors the breakdown bit so no lane races ahead on the same bad reading.
Escape hatch: compress.requireUsageSampleForPressure=false (user files merge
per field global→provider→model like every other compress field) restores the
legacy estimate-driven pressure injection.
Plumbing: prepare-openai(3)/prepare-google/prepare-anthropic/prepare-responses
pass effectiveTokenCount().source into processTurn; diagnostic/probe call
sites intentionally stay unmarked (= legacy). Config threads through
src/config.ts → compress-settings.ts → kernel NudgeConfig
(requireUsageSampleForPressure, default true).
Tests: kernel/tests/nudge-pressure-no-sample-hold.test.ts (6),
tests/nudge-pressure-no-sample-armed.test.ts (3). Kernel suite green
1582/1582 incl. new; full typecheck clean. Docs: CHANGELOG,
CONFIGURATION.md/.zh-CN.md, website compress.yaml.
Long sessions accumulate T1 blocks whose coverage cuts through a turn
group (reasoning/tool-call/result) with the partner still visible outside
the span. Any block merge consuming such a block failed the turn-integrity
gate permanently: survivingCoverage is global, so ONE historical poison
block doomed every merge in the session (even two adjacent clean blocks),
and the nudge kept advertising the same doomed first..last run.
Apply-side fix (unit-projection only — the advertise-side screening of
tier-distill runs is PR #5777, which owns compress.ts; zero file overlap,
either may merge first):
- conflicts touching nothing the merge newly folds or re-owns are
inherited with an honest warning (pre-existing, merge-neutral) instead
of refusing every merge in the session;
- conflicts owned by consumed blocks retry the projection with those
blocks excluded: they stay ACTIVE (coverage intact, host #3322 gate
passes) and the merge completes around them, warning by name;
- only unfixable spans refuse, now with actionable text naming the exact
conflicted refs, their covering blocks, and the concrete next move
(fold the stranded partner first). Keeps the 'cannot satisfy turn
integrity' phrase the host and the #4484 suite key on.
Behavior change (old -> new): merges touching historical mid-turn blocks
hard-failed forever -> partial success excluding offenders by name;
pre-existing merge-neutral conflicts no longer block clean merges;
(single-defective-block ranges still refuse); refusal texts replaced with
actionable versions. No coverage ever dropped; no config surface added.
Conditional spreads in the two kernel clone paths (sync.ts syncBlocks
clone, compress.ts fold clone) plus delete-style flag clearing in the
stamp node: states created before this feature must not acquire the
`timestampsHighWaterRefSeq` / `suppressMintingOnce` KEYS with
undefined values — key presence itself moved golden stateKeyDigests
and would have flapped parity digests turn-to-turn (golden-storage-render
suite red on 3edf28b0). The B arm still clears the key (not
`undefined`) so a consumed flag leaves no trace; C writes its mark as a
plain number after first init. Version 0.0.183 -> 0.0.184.
Only conflict: kernel/package.json version line — both sides bumped after
base 0.0.180 (ours 0.0.181 via #5608-B/C time-attr work, master 0.0.182 via
#5758/#5759). The merged tree carries BOTH unreleased change sets, which no
single prior version denotes, so reconcile to 0.0.183 (max+1).
Owner ruling (#5608 decision thread follow-up): the three one-shot
full-prefix-invalidation producers get fold-boundary discipline, closed
inline on PR #5609 per 「不要立issue,原来的pr改」.
C — timestampsHighWaterRefSeq: a rendered ACP tag gains its time=
attribute only when its ref index exceeds the mark recorded pre-pass.
The mark freezes from state across sync/fold/hydration and ledger
alignment raises it to the aligned max — so flipping #4313 on
mid-session (incl. the v0.1.209→v0.1.210 default off→on upgrade)
changes ZERO prefix bytes until a tag's own content edit/fold remints
it onto a higher seat. Brand-new sessions stay fully functional.
B — suppressMintingOnce: the stamp node records ids without fabricating
Date.now() while armed, instead of seeding false timestamps that would
ride into future lineage via seedTimestampsFromParent. Host arms it on
bulk-old-history paths (miss-adoption fallbacks, weak adoption, forks);
strong byte-exact resume stays un-armed (uncovered tail provably new).
Self-clearing; deliberately not hydrated after restart.
kernel/package.json 0.0.180 → 0.0.181. New pins:
kernel/tests/issue5608-timestamp-tails.test.ts (4).
The #5765 field additions landed at 3-space indent and re-indented the adjacent restoredInline/durationMs lines with them; the interface uses 2 spaces throughout.
Add three state operations on CompressionBlock, all roll-backable and
storage-format-neutral (optional fields ride the payload_json blob):
- retireBlocks / restoreBlocks: retired blocks keep active status and
full coverage bookkeeping, but prune() stops injecting their summary
anchor into the resident view (syncBlocks keeps them alive instead of
deactivating the intentionally-absent content); usage metering,
distillation pending tiers, and tier hints skip them; apply-side
rejects whole batches whose ranges would consume a retired block so
retirement can never be silently destroyed by re-compression.
- rewriteBlockSummary: replaces a stored summary with caller-supplied
text (single or batch), keeping previousSummary one step deep for
rollback; compressedTokens untouched (it records original input).
- acp_status overview gains a RETIRED BLOCKS section when non-empty;
the compressed drilldown marks retired rows.
- New model tools acp_retire / acp_restore / acp_rewrite declared for
all four wire dialects, classified mutating (session lock + same-turn
re-request); prompt prose updated four -> seven tools with fixtures
regenerated.
kernel-change: owner-requested capability #5765 — long single-session
context management needs per-block opt-out of the resident view and
post-hoc summary replacement that neither the compression pipeline nor
the existing generation-time external-summary config can express.
The id-exact pairing rewrite rebuilt a whole-array toolCallId position index
inside adjustBoundariesForToolPairs on every call — once per screened unit
(<=2 passes), i.e. U units x O(n), the exact quadratic class #5337 removed.
On a 20k-message history with ~1900 units the real recommend chain went from
a 614ms baseline to 1346ms locally (3184ms on the windows CI node, over the
3000ms cap pinned by tests/issue5337-shared-screening.test.ts).
Hoist the index into ProjectionShared.toolPairExtremes: built once per pass
in buildProjectionShared, consumed by applyPairBoundaryAdjustments via the
existing shared-context pattern (same as pairByCallId et al.). Standalone
callers without a shared context still build inline — behavior unchanged.
Zero behavior change: identical data, computed once per pass instead of per
unit. Local: all four pinned suites green (tool-pairs, issue5751,
issue3236, issue5337); scale record back at baseline (613ms vs 3000ms cap).
The pair-widening pre-pass capped its scan at 20 slots with
stop-on-gap, so a call whose result lands further away (parallel
tool bursts, host-injected filler, delayed results) straddled the
fold boundary. The turn-integrity gate then withdrew the pair from
every candidate range: in tool-dense regions no legal range
remained and folding wedged (#5746), or a split pair reached the
wire and upstream answered 400 on every retry until the session was
manually repaired (#5751, 17 MB / 2M tokens of retry debris).
Pairing is now id-exact: each toolCallId's extremes are indexed
over the whole array once and boundaries widen to a fixed point, so
interleaved chains and duplicate echoes fold on one side of the
boundary. compress stays a non-seed (force-protected) but its
position still widens in, preserving #4348's aged-receipt lace.
Fixes#5751
Refs #5746
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