Commit Graph
333 Commits
Author SHA1 Message Date
ranxianglei 356209602b [PR] kernel: bridge span-safe gaps at the merge gate so mega-turn islands …
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)
2026-11-24 23:31:34 +08:00
ci-check accbec4bfb kernel: bump version 0.0.208 -> 0.0.209 for #7614 kernel/src change
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.
2026-11-24 10:53:32 +08:00
ranxiangleiandferiaref e207896fbb Kernel: stop covered reasoning leaking back onto the wire between thinking drop/restore
Drop the 0.0.206 -> 0.0.207 version bump from the original PR: master has
since moved to 0.0.208, and the code change does not depend on the number.

Co-authored-by: feriaref <295336358+feriaref@users.noreply.github.com>
Source-PR: #7614
2026-11-24 09:48:07 +08:00
ranxianglei 4c8f0395ec kernel: no-op a split-doomed range instead of rejecting the whole batch (#7596)
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.
2026-11-24 00:26:47 +08:00
ci-check d3b249e545 fix: compress length error as factory + type guard, inside the verif subset (#6730)
The verif-subset-guard CI job rejects the class form: CLASS_DECL for
'class SummaryLengthError extends Error' and UNKNOWN_GLOBAL for the three
'new SummaryLengthError' throws (the guarded-file subset only allows
NEWABLE constructors: Map/Set/Error/RangeError/TypeError/RegExp).

Rewrite as a plain-Error factory (summaryLengthError) plus a type guard
(isSummaryLengthError) — same error name, same kind field, same messages,
behavior byte-identical; the issue6730 regression tests pin the visible
rejection text and pass unchanged. No exception added to
verif/exceptions.ts: the code now conforms to the subset instead of
weakening the guard.
2026-11-23 23:10:05 +08:00
ci-check f9d9a01fef kernel: make compress length-rejection advice match the failure direction (#6730)
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.
2026-11-23 23:09:19 +08:00
ci-check 856b4119cf kernel: sync package-lock.json version to 0.0.206 (lock-sync) 2026-11-23 10:33:49 +08:00
ci-check 52372e4905 kernel: bump 0.0.205 → 0.0.206 (compress 文案统一, rebase onto master, kernel-guard 规则 2) 2026-11-23 10:30:51 +08:00
ranxianglei ce073589a7 fix(compress): 统一唯一广告格式——line-form 大 string,删掉全部 'JSON array also accepted' 文案
session 01a2040e(qwen3.8-27b)实证:工具描述广告 '大 string'、拒收消息同时广告
'string 里塞 JSON array',模型失败一次后照拒收消息改走 array 格式,随后误信
compress 工具消失、停发调用。两种被广告格式 = 没有可信格式。

- kernel: 参数/工具描述与系统提示词 TOOLS 段删掉 'a valid JSON string…
  a JSON-encoded array as that string is also accepted'
- stream.ts: 四条拒收文案(lost-in-transit / empty / no-valid-ranges / breaker)
  删 array 引导句; notArrayHint 从 'wrap it in square brackets' 改为
  '不要 JSON 编码,只教 line form'
- lean pack + nudge ONE_CALL_HINT: 'JSON-escaped string' → 'plain string'
- 解析行为不变: string 里塞 array、flat object、双转义 \n 等 legacy 形状
  照样接受——只删广告,不删接受(acceptance never advertised)
- 4 个 wire-contract golden + kernel prompt fixture 再生; 2 个断言旧文案的
  测试改为反向断言(不得再出现 'JSON-encoded array'/'also accepted')
2026-11-23 10:26:59 +08:00
ranxianglei e4e6f53844 fix: keep the internal ref sentinel out of model-facing acp_status output
#6936's regression pin: with pinned (unrefed) rows present, no
model-facing surface may print the internal sentinel, and clean
sessions must render byte-identical to before.

- range-view header keeps the historical 'N visible messages' format
  and appends '+ N unrefed' only when pinned rows exist
- 'BLOCKED MESSAGES' section renamed to 'UNREFED MESSAGES' (src/marker/
  status-body.ts section head registered in step)
- detail rows render pinned halves as '(unrefed)' instead of the raw
  sentinel; aged/newest labels unchanged
- tests pin both: no literal sentinel in any uncompressed surface
2026-11-23 00:17:29 +08:00
ci-check bdacb1ba7a chore(kernel): sync kernel/package-lock.json to 0.0.205 (lock-sync) 2026-11-22 20:48:05 +08:00
ranxianglei 3bf59febfa chore(kernel): bump 0.0.204 -> 0.0.205 (BLOCKED-residue report changes) 2026-11-22 20:26:52 +08:00
ranxianglei 53eebd2679 merge origin branch (master sync + kernel rebump) 2026-11-22 20:26:13 +08:00
ranxianglei 6fb56ee3b3 fix: acp_status stops listing pinned compress residue as fold targets
Real long sessions are full of successful compress exchanges: their
receipt halves carry the BLOCKED ref sentinel (ALWAYS_PROTECTED_TOOLS)
and never get numeric refs, while the nudge table skips them silently.
The uncompressed status view bridged over them and rendered rows like
`m00007–BLOCKED ⚠ not foldable: refs unresolvable` — the whole turn died
on one pinned pair — and the detail view flooded with identical
`BLOCKED (x) compress` rows that read as uncompressible junk.

Now all three surfaces agree:
- range rows are built from the resolvable entries only; every offered
  range has resolvable endpoints (same splits as the nudge table, which
  bridges over BLOCKED without a gap);
- the pinned mass gets a labeled section carrying the #4348 truth: aged
  compress receipts (all but the newest 3) ARE consumed by any fold that
  spans their position; the newest 3 are protected working memory;
- the detail view labels each BLOCKED compress row aged vs newest
  instead of printing bare BLOCKED rows.

kernel/src/report.ts: BLOCKED rows split out of range rows into a
"BLOCKED MESSAGES" section (counts + tokens + #4348 aged/newest split,
config-gated); detail rows get suffixes; header separates raw from
blocked counts. src/marker/status-body.ts: SECTION_HEADS += new head.
kernel 0.0.203 -> 0.0.204.

Tests: kernel/tests/status-blocked-compress.test.ts (new, 5 tests incl.
row-for-row alignment with buildCompressibleRanges); status-summary-nodes
header assertion updated.
2026-11-22 20:25:44 +08:00
ci-check ecee5cf283 chore(kernel): rebump 0.0.203 -> 0.0.204 after merging master (#7522 landed 0.0.203) 2026-11-22 20:24:16 +08:00
ci-check 8f44a4ae6a Merge remote-tracking branch 'origin/master' into 2026-11-22_acp-status-uncompressed-nudge-align 2026-11-22 20:21:40 +08:00
ranxianglei ed832d7a7e fix(status): stop listing rendered summary nodes as uncompressed; align the ranges view with the nudge table
- collectVisible carves out rendered block-summary nodes (acp_summary_bN,
  role system) into their own ledger and splits at them — the exact gap
  rule buildCompressibleRanges applies, so the uncompressed ranges view
  now segments identically to the injected nudge table instead of
  bridging over the nodes and offering already-compressed mass as fresh
  fold targets.
- renderUncompressedRanges shows them in a labeled
  ALREADY-COMPRESSED SUMMARY NODES section (bN + tier + tokens) with the
  byte-identical tierActionHint once distillation is armed, plus a static
  compress() call-shape line next to the raw ranges.
- overview: tip now points at the ranges view instead of steering models
  into view:"messages"; summary-node mass is no longer double-counted
  (it was in both the summaries ledger and the text bucket).
- compress-tools: view param declares "ranges" as the default.
- marker/status-body: register the new section head in the legacy strip
  grammar (#2789 lineage — otherwise the section tail leaks back into
  model-visible text on persisted reports).
- kernel 0.0.202 -> 0.0.203.

Tests: kernel/tests/status-summary-nodes.test.ts (8 tests incl. the
nudge-alignment assertion); kernel suite 1656 pass / 0 fail; typecheck +
unused-exports clean; host sweep of status/marker/nudge/prune/range/
compress suites green apart from 8 failures that reproduce identically
on pristine HEAD (environmental, unrelated).
2026-11-22 19:56:20 +08:00
ranxianglei ce781e54af kernel: orphan-sweep exemption recognizes the line-form compress args
⚠️ 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
2026-11-22 18:38:23 +08:00
ework-agent f717b6908b chore: sync kernel lockfile to v0.0.202 (lock-sync drift from the protectedMass param bump, #7465) 2026-11-21 21:01:37 +08:00
ework-agent 471e5afa2a ⚠️ MODEL-FACING TEXT CHANGE: acp_status gains an opt-in protectedMass param (kernel tool table, all four wire variants) whose description grows one clause; the ledger line itself renders ONLY with protectedMass:true, so default model-visible output is byte-identical to pre-branch. Human-facing surfaces (bili log, /acp panel, dsh Context tab) carry the PROTECTED MASS attribution line by default; the drained-fold receipt keeps its "Also protected" fragment.
Protected mass = token mass metered into usage but reachable by no compress offer: hard protection (BLOCKED_REF — no numeric ref to cite; offer/audit/model all skip it) plus the soft protected recent window (zone). In the #7463 log30 case the meter billed ~400K while every surface the model sees named at most ~120K of it — the gap was invisible everywhere.

Surfaces (per owner ruling 2026-11-21 in the #7463 thread — acp_status is the model's everyday read, attribution must not ride there by default):
- bili log: one [acp-compress-obs] line per qualifying fold (hard/zone split + top carriers)
- web/dsh Context tab: context-view protectedMass field (slice of sentTotal, not a new category)
- /acp panel: human-only preFooter line, one extra relaxed offer pass paid only on demand
- acp_status: protectedMass:true (off by default); the line explains, it does not offer work
- drained-fold stop-signal receipt: "Also protected (never in any offer): ..." fragment under the existing #6522 latch

kernel-change: extend ACP_STATUS_PARAMETERS with protectedMass (boolean) — the parameter table is kernel-owned (#5555: one declaration, all four wire variants share it) and the host cannot declare it; without it the opt-in param is undiscoverable by models. Kernel v0.0.201 -> v0.0.202; wire-contract goldens regenerated via scripts/update-wire-contract-goldens.ts (diff = the new param + one description clause in each variant, nothing else).

Render floor: PROTECTED_MASS_RENDER_FLOOR = 5K tok hardcoded (no config surface; #1911 precedent) — sub-floor mass renders nothing anywhere.

Regression evidence: issue7463-protected-mass 9/9 (opt-in both directions, sub-floor silence on every surface, pure-protected gap, receipt fragment, legacy-delegation transparency), issue4331 10/10, wire-contract 62/62 across the affected suites, kernel suite 1648/1648, typecheck clean, unused-exports gate clean.

Fixes #7463
2026-11-21 20:54:05 +08:00
ci-check 54f37fb7cb ⚠️ MODEL-FACING TEXT CHANGE: covered no-op warning no longer claims same-batch involvement (false for pre-existing covering blocks)
Review finding (reproduced with a two-turn probe): the new allCovered
no-op wording fired for a PRE-EXISTING block covering a requested
sub-range (anchor outside the range, so the block is not nested in it)
— a case that existed before this fix and previously got the
'protected or filtered' wording. There the clause 'including block(s)
created earlier in this same batch' asserted same-batch involvement
that did not exist (no block was created in this batch).

Fix: drop the clause — the actionable guidance ('do not resend this
range; reference them by block ID instead') is identical in both
cases, so the clause carried no decision value, only the false claim.
The wording now states only what is true in every case reaching this
branch: every resolvable message is covered by an active block.

Added regression test 3: pre-existing covering block (no same-batch
block) gets the covered wording and the warning is asserted to NOT
contain a same-batch claim. kernel-change: mechanical-bug exemption
(provably-false guard text + reproducing test); human review tier
still gates this merge.
2026-11-21 11:27:03 +08:00
ci-check 0f4e18dda4 fix(lock): sync lockfiles with kernel 0.0.201 bump (lock-sync drift)
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.
2026-11-21 11:19:43 +08:00
ework-agent 6d1f5c2a39 kernel: bump version to 0.0.201 (batch seam double-claim fix) 2026-11-21 10:59:27 +08:00
ework-agent 5b80d79fdb ⚠️ MODEL-FACING TEXT CHANGE: the #4521 no-op warning ("folded nothing …
do not resend this range") gains a second, more accurate wording for the
case where every resolvable message of a range is already covered by
active block(s) — the previous "all of its content is protected or
filtered" wording is kept VERBATIM for its original class; the new
wording only appears for the newly-impossible-to-misread covered case
(it names the covering class and points to block-ID refs).

kernel: refresh batch coverage snapshot per range (seam double-claim fix)

Two adjacent ranges in ONE compress batch both claimed the tool pair on
their shared seam: the coverage snapshot (collectCoverage) was frozen
before the batch, so each range's projection judged "already covered"
without seeing what an earlier sibling had just claimed. Result: two
active sibling blocks directly owning the same messages, overlapping
seq intervals, and a later fold consuming one of them positionally
although its ref range lay outside the newer block's range (pi session
01a1f6ff: b100/b101 shared two directMessageIds; b102 then consumed b101
across its ref range).

The no-overlapping-active-siblings invariant (file header) now holds on
the last path that bypassed it: the apply loop refreshes the snapshot
each iteration (first-come-first-served seam ownership); a range left
with nothing new becomes the #4521 idempotent no-op (warning, no error,
batch survives).

kernel-change: mechanical-bug exemption (owner policy 2026-11-06) — a
single-point state-refresh omission with a reproducing regression test
(kernel/tests/regression-batch-seam-double-claim.test.ts, red before /
green after; full kernel suite 1647/1647 green). The human review tier
still gates the merge.
2026-11-21 10:59:27 +08:00
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