309 Commits
Author SHA1 Message Date
ci-check 2975a63da3 kernel: update stale directive-only 'exempt anywhere' wording after the #7270 precede-heal
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.
2026-11-19 17:56:32 +08:00
ci-check 88f67800c0 kernel: sync package-lock.json version to 0.0.200 (lock-sync with the 0.0.200 bump) 2026-11-19 17:40:02 +08:00
ci-check b805e43acb kernel: bump version to 0.0.200 (rebase onto master 0.0.199; resolve the 0.0.199 collision with #7252's kernel bump) 2026-11-19 17:37:07 +08:00
ci-check 7e53417a5d kernel: move illegally-positioned directive-only systems to the trailing run (#7270)
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
2026-11-19 17:36:35 +08:00
ework-agent 3a1bd65c0d chore: sync kernel lockfile to 0.0.199 (lock-sync #3782) 2026-11-18 12:46:11 +08:00
ework-agent 497efc7e31 fix: compress success receipt — drop head/tail labels (keep excerpts), fold timestamp, kernel anchor quote labeled as historical
⚠️ MODEL-FACING TEXT CHANGE(四处,均为模型可见回执文本;消费链推演 + receipt 级回归见 PR body)
kernel-change: last-user anchor 引文标注来源(历史引文≠新用户消息),owner 已批准(2026-11-18 会话 01a1e89d 诊断);机械性措辞修复 + 复现用例。

会话 01a1e89d(ti_an, qwen3.8-27b)诊断的三类混淆载体都在压缩回执里:
① 指纹行去掉 head/tail 标签、保留摘录:
   · b1 full summary 10600ch [2026-11-17 10:35:14 – …] · head "…" … tail "…"
   → · b1 full summary 10600ch [2026-11-17 10:35:14 – …] "… … …"
   标签读起来像「只存了开头和结尾」,触发模型对刚建的块做防御性
   decompress(#2544 误读源头是标签本身);摘录保留 #1294 自查价值
   与 #1615 surrogate 切口守卫(safePrefix/safeSuffix/scrubLoneSurrogates)。
② 成功回执头追加折叠时刻:… tokens saved.] folded at 2026-11-18 10:05:12
   回执是唯一一类引用用户话语却无 <acp> time= 的系统行;提交时墙钟,
   回执是全新尾消息,无缓存后果。
③ #2544 指引句去掉与摘录绑定的前半句(search_context 优先的检索路由保留)。
④ kernel(unit-projection.ts)保护带排除警告里的 Last-user anchor 引文
   标注为历史引文:Last-user anchor (historical quote, NOT a new user
   message): m00003 "…" —— 防模型把回执里的用户话语引文当成刚说的新指令
   (现场:编出 "user's latest message (m02386/m02387)" 并要求执行)。
   kernel 0.0.198 → 0.0.199。

金色快照(有意更新,见 PR body):② 的 folded at 是新墙钟形状,
tests/golden-storage-drive.ts 按既有 STAMP_ATTR/STAMP_SPAN 同类归一化
新增 FOLDED_AT_RE(5 处 digest 通道),重生成 tests/golden/storage-render/
四个快照(仅 fold 轮 sha + state digest 变化)。

回归:tests/compress-fingerprint-refold.test.ts(无标签形状 + #1615 四个
surrogate 切口/清洗用例钉新格式)、tests/issue4313-fingerprint.test.ts、
tests/issue4313-message-timestamp-toggle.test.ts、tests/text-safe.test.ts、
tests/issue5173-last-user-anchor.test.ts、tests/issue6021-image-offload-anchor.test.ts、
kernel/tests/issue5109-anchor-skip-injections.test.ts、
tests/golden-storage-render.test.ts(5/5)、storage-engine-proofs 四 wire 平价(4/4)。
本地:7 文件 66/66、8 文件关联清扫 61/61、kernel 套件 1640/1640、typecheck/build 绿。
全量以 CI 为准。

Ref: session 01a1e89d diagnosis (2026-11-17), plan approved by owner 2026-11-18.
2026-11-18 12:30:48 +08:00
ranxianglei 4ccccab15f kernel+host: remove the #4521 armed-but-silent '[ACP status: …]' refresh line (#6928)
⚠️ 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).
2026-11-16 17:55:54 +08:00
ranxianglei 399cd2b8c0 kernel: let content-free BLOCKED partners close their turn (#6709)
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
2026-11-15 11:48:29 +08:00
ranxianglei f1d696e1a3 Revert "sync: decide block liveness by coverage shape, not existence"
This reverts commit f7406e5ad9.
2026-11-13 22:19:49 +08:00
ranxianglei 7d7631f194 Revert "kernel: bridge span-safe gaps at the merge gate so mega-turn islands survive minCompressRange (production 2026-11-09 no-ranges incident)"
This reverts commit dcf4ff2004.
2026-11-13 21:41:44 +08:00
ranxianglei 1b15692af4 kernel: version 0.0.197 (batch4 kernel fixes: #6428 server-tool pair heal, #6345 span-safe gap bridging, #5166 liveness-by-coverage) 2026-11-13 17:57:37 +08:00
raydocs 7a2376d895 kernel: heal unpaired server_tool_use / *_tool_result blocks before forwarding
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)
2026-11-13 10:45:25 +08:00
guowenjie dcf4ff2004 kernel: bridge span-safe gaps at the merge gate so mega-turn islands survive minCompressRange (production 2026-11-09 no-ranges incident)
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)
2026-11-13 10:44:57 +08:00
rain f7406e5ad9 sync: decide block liveness by coverage shape, not existence
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)
2026-11-13 10:33:32 +08:00
ranxianglei f2ee94a58a kernel: version 0.0.196 2026-11-12 22:23:16 +08:00
ranxianglei 1b49f01f76 fix(prompts): teach the canonical string form in compress call examples
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.
2026-11-12 21:51:20 +08:00
ework-agent efa3df7857 chore: merge master ahead of the #5765 blockOps gate (kernel 0.0.195)
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.
2026-11-11 11:17:42 +08:00
ework-agent 6b33fd21a9 feat: gate the #5765 block-lifecycle tools behind compress.blockOps (default off)
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.
2026-11-11 11:12:54 +08:00
ework-agent 84d4f6a867 kernel: remove the compressAtFoldPoint fold-point relocation feature (#6132)
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)
2026-11-10 23:23:06 +08:00
ework-agent 552b62a032 chore: merge master ahead of #5765 review fixes
kernel version: 0.0.183 (PR) vs 0.0.192 (master) -> 0.0.193
2026-11-10 22:34:41 +08:00
ranxianglei a51e11fc8b Merge pull request #5609 from ranxianglei/2026-11-03_resume-timestamp-ledger-carry
[PR] fix(resume): inherit timestamp ledger so resumed sessions re-render provider-cached tag bytes
2026-11-10 21:27:40 +08:00
ci-check 201775a6a6 merge: sync master 4dea18eabf into #5609 branch — kernel version 0.0.185→0.0.192 (max+1: master advanced 0.0.186–0.0.191 since d640d0d06; branch carries #5608-B/C/D) 2026-11-10 18:26:49 +08:00
ci-check 52d287add1 Merge branch 'master' into 2026-11-08_batch-summary-floor
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)
2026-11-10 16:24:51 +08:00
Gong Liu 5ac2983c5c kernel: version 0.0.191 2026-11-10 01:24:25 +08:00
Gong Liu a279baf0d8 kernel: reuse the client's leading message role when rebuilding the Responses input (for #6063) 2026-11-10 01:24:25 +08:00
mz 3740f16f2c Merge remote-tracking branch 'origin/master' into 2026-10-25_system-position-heal 2026-11-09 12:51:44 +03:00
ranxianglei ec4b9f715c Merge pull request #5971 from ranxianglei/2026-11-09_codex-lane-small-fixes-batch
[PR] fix(codex): Codex lane minor fixes roundup #3 — WS error object + marketplace containment + Google part ordering | fix(codex): codex 车道小修合集第三辑 —— WS 错误对象 + marketplace 收容 + google part 序
2026-11-09 09:01:58 +08:00
ranxianglei d70e6e2efc Merge pull request #5949 from ranxianglei/kernel/relocate-fold-summary-v2
[PR] Put each compression summary at its fold point; the old slot keeps a pointer instead of a full compress command (compressAtFoldPoint v2)
2026-11-09 08:58:43 +08:00
ci-check 54ce2befcd docs: correct mis-cited issue numbers in batch-PR comments and test file name
#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.
2026-11-09 01:21:07 +08:00
ci-check 50e4cdc3ad fix(ci): sync root + kernel lockfiles to acp-kernel 0.0.189
The PR bumps kernel/package.json 0.0.188 -> 0.0.189 (required by the
Kernel Boundary for the kernel/src/wire/google.ts change) but left both
lockfiles at 0.0.188. Regenerated with npm install --package-lock-only
(matching the lock-sync CI job) so the embedded kernel entry in the root
lock and the kernel lock's own version line agree. Mechanical lockfile
sync only — no dependency or source change.

Fixes #5971
2026-11-09 00:51:18 +08:00
ranxianglei 86aae0d1f5 fix(google): keep tool_result-first part order for Claude-through-Google targets (for #5397, closes #5392)
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).
2026-11-09 00:27:26 +08:00
ranxianglei e03cc4bfca Stop the compress-burst loop: ack fold-point pointer echoes, collapse repeat failure receipts, credit overrides cycle-stale meter
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).
2026-11-08 23:18:55 +08:00
ranxianglei e316d3fea1 chore: sync kernel/package-lock.json version fields to 0.0.189 (lock-sync) 2026-11-08 19:55:09 +08:00
ranxianglei ad242bf6c2 kernel: relocated fold summaries ride the #335 live-carrier protection
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.
2026-11-08 19:48:20 +08:00
ranxianglei cc1e2408c8 kernel: relocate-compress v2 — summary text moves to the fold point, the pair stays in its slot with pointer args (#5470 follow-up)
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.
2026-11-08 19:48:20 +08:00
ranxianglei ae5c9a5224 kernel: version 0.0.188 (#5919 shredded-merge recovery) 2026-11-08 14:39:56 +08:00
ranxianglei 4cb3e064a8 kernel: close shredded-merge dead-ends — auto-extend to stranded partners or no-op with exact guidance (#5919)
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.
2026-11-08 14:39:38 +08:00
ework-agent 8bbe7d55bd fix: docs-sync/lock-sync — throttle429Scope notes belong in the process.yaml seed (CONFIGURATION.* are generated), kernel lockfile 0.0.187 2026-11-08 01:31:51 +08:00
ci-check 4e5e8c635e Merge origin/master into 2026-11-08_batch-summary-floor (#5903)
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.
2026-11-08 01:29:47 +08:00
ework-agent 81619f3dfe fix: #5898 review batch — 429-hold saturation warn + scope-value guard, media-refs carry-forward filter & cloud prefix families, oversize refusal messages that name the real fix, dsh durable lines with readable numbers, website streamKeepAliveMs typo, 5755 ord-crossing guard kept with regression tests
- 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)
2026-11-08 01:28:42 +08:00
ci-check a5bb6a14dd kernel: judge the summary floor at batch level for multi-range compressions (#5894)
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.
2026-11-08 00:45:24 +08:00
ework-agent 178fc03184 fix(kernel): EPHEMERAL_QUERY_PARAM prefix branch must match x-amz-ANYTHING, not the bare prefix
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.
2026-11-07 23:09:14 +08:00
ework-agent 5fff033a4b fix: P2 review batch — scan memo, ephemeral-ref pinning, preoom snapshot, msgid-rescue trace
- 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).
2026-11-07 23:06:19 +08:00
ranxianglei bcda253a56 kernel: bump 0.0.185 (nudge estimate-hold backstop; #5860 follow-up) 2026-11-07 20:10:22 +08:00
ranxianglei f1f67e4ddf kernel: cap the #5860 estimate-grade pressure hold at N consecutive rounds (backstop)
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.
2026-11-07 19:11:28 +08:00
ework-agent 482fd0cb2c lock-sync: regenerate lockfiles for kernel 0.0.184 bump 2026-11-07 15:48:26 +08:00
ework-agent 139aca5a0f kernel: bump 0.0.184 (phantom-pressure guard) 2026-11-07 15:45:06 +08:00
ework-agent a7cbfd12fc fix(nudge): no billing sample this round → hold pressure-band injection one round (phantom-pressure guard)
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.
2026-11-07 15:40:18 +08:00
ci-check 4eeb781f2e merge: sync master d640d0d06 into #5609 branch — kernel version 0.0.182→0.0.185 (max+1: branch #5608-B/C/D at 0.0.184 + master #5789 unit-projection at 0.0.183) 2026-11-07 10:35:11 +08:00
ci-check 43f1dabb50 test: fix misleading title on the surviving-block inheritance case (it pins tolerance, not refusal) 2026-11-06 23:32:03 +08:00