123 Commits
Author SHA1 Message Date
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 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 3bf59febfa chore(kernel): bump 0.0.204 -> 0.0.205 (BLOCKED-residue report changes) 2026-11-22 20:26:52 +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
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
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
ework-agent 6d1f5c2a39 kernel: bump version to 0.0.201 (batch seam double-claim fix) 2026-11-21 10:59:27 +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
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 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 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
ranxianglei f2ee94a58a kernel: version 0.0.196 2026-11-12 22:23:16 +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
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
mz 3740f16f2c Merge remote-tracking branch 'origin/master' into 2026-10-25_system-position-heal 2026-11-09 12:51:44 +03: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 ae5c9a5224 kernel: version 0.0.188 (#5919 shredded-merge recovery) 2026-11-08 14:39:56 +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 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
ework-agent 139aca5a0f kernel: bump 0.0.184 (phantom-pressure guard) 2026-11-07 15:45:06 +08:00
ci-check fe4ab8dae5 kernel: recover tier-distillation merges around historical mid-turn blocks (#5789)
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.
2026-11-06 23:32:03 +08:00
ci-check 912fa39b23 Merge remote-tracking branch 'origin/master' into wt-5767-ework-daemon
# Conflicts:
#	kernel/package.json
2026-11-06 09:49:01 +08:00
ci-check 403ac93572 kernel: block retirement and external summary rewrite (#5765)
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.
2026-11-06 09:39:38 +08:00
ranxianglei a39ce3a232 kernel: fold tool-call/result pairs by exact id at any distance (#5751)
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
2026-11-06 00:52:57 +08:00
ranxianglei e3d1a887eb fix: T1 harvest-stall escalation — mass-qualified T2/T3 distillation fires ahead of a non-draining T1 channel (#5698, #5671 treadmill) 2026-11-05 11:16:49 +08:00
ci-check 15adc9b448 merge: sync master into #4570 fix branch (adopt #5438 two-sided heal; keep final-array backstop; kernel 0.0.181)
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).
2026-11-04 19:15:50 +08:00
ci-check d126087abc kernel: ref-based media becomes foldable — re-access handles ride the stored summary (#5620)
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
2026-11-04 09:05:34 +08:00
ranxianglei 8f2cb35dc5 fix(kernel): false-ad batch — declare real schemas, align prompts, accept .. separators (#5555)
- acp_status: scope/view/tool/sort/limit/archiveDetail declared on ALL four wires (shared ACP_STATUS_PARAMETERS) — handler always read them, models could only guess
- google wire gains acp_cache (was acp_status-only; Gemini lanes got cache questions with no tool)
- compress input parser: '..' accepted like '...' in REF_PAIR_IN_LINE + LINE_ENTRY_REFS_RE — pre-fix an advertised separator was rejected and a two-dot header silently became continuation lines of the previous entry (#5555 audit item 8)
- prompt copy: five->four tools count (4 listed), decompress leaf-block note, search_context no-visible-messages correction, per-generation refs paragraph, ACP-TAGS addressable-only phrasing (BLOCKED/protected carry none)
- acp_retrieve desc: file-export branch for very large originals; 📦 bracket balanced
- acp_cache detail: full = line-item breakdown w/ stated cap, not 'every line item'
- absorb: '(nothing needed)' discard escape hatch
- report overview Tip no longer leaks buildStatusReport() internals; acp-panel LEGACY_STATUS_SECTION_STARTS accepts both tip wordings
- version 0.0.178 -> 0.0.179 (+lockfiles); wire-contract goldens regenerated (status params x13, new descs, google+cache); prompt fixtures regenerated
2026-11-03 00:39:06 +08:00
ranxianglei ca532d4f31 kernel: heal the follow side of Anthropic's mid-conversation system rule (#5438) 2026-11-02 13:25:01 +08:00
ranxianglei 079f8cfba7 feat(compress): relocate visible compress pair to its fold point + optional unsigned-think clear (#5470)
两个默认关闭的实验开关(BILI_COMPRESS_AT_FOLD_POINT / ..._CLEAR_THINKING,配置文件键 compress.compressAtFoldPoint / compressAtFoldPointClearThinking)。弱注意力模型会把重放历史尾部挂着的未折叠 compress 调用对误读成新命令(pi 稳态位置别扭;代理模式第 2 轮甚至追加到请求最末)。开关打开后布局变为 [已折叠区] – [compress 调用对] – [保护消息]:acp-kernel 新节点 relocate-compress-carriers(hide-compress-calls 之后、view-latch 之前),落点=第一条 ref > max(endRef) 的存活消息之前,不存在则追加到尾部(#4732);纯视图变换,off 时字节级一致。第二个开关在挪位瞬间清紧邻的未签名思考段;strict-echo(#684)或存在签名思考块(#1658)时整个机制不出手。host 镜像:4 条 prepare* + relay round-2(幂等)+ S4 render;Responses 重请求循环 v1 不覆盖。kernel 0.0.177。验证:kernel 1542/1542(新增 21 单测);root 全套 9927 测试中 22 个失败已在干净 master 复现(外网/环境依赖),与本改动无关。
2026-11-01 22:13:50 +08:00
ranxianglei c91ef1a813 kernel: abort-heavy sessions stop starving the nudge cadence (#5415)
#5293 re-anchors the growth reference to the current meter on every
user-aborted turn, which also zeroes the MEASURED growth from the old
reference up to the pre-abort anchor. Abort-heavy clients (85 absorbs
in one reported 4.5h log) never cross the growth floor again: a 300K
ready mass idles for hours ("growth 4450 < floor 33750, ready: T1
302220") and the session finally compresses a ~330K backlog.

Fix, v2 semantics (single abort stays byte-identically quiet as #5293
pinned):
- the host banks the skipped measured growth into
  state.nudge.absorbedDebt and counts the absorbs (absorbCount);
- debt and the new backlog-drain guard pay only once absorbCount >= 2 —
  one abort after a long quiet stretch can bank a whole interval, but
  it must not re-fire the cadence on the user's redirect (#5293 pin);
  the second absorb proves the session is abort-heavy, not
  redirect-polite, and the 209-era cadence recovers;
- backlog-drain guard (same philosophy as the #194 first-sight
  bypass): count >= 2 + debt > 0 + no outstanding nudge + ready mass
  >= 2x the T1 threshold drains now instead of idling behind the
  starved growth leg;
- applyCompression resets the debt bank and the count with the other
  baselines; idle reasons surface the debt for diagnosability
  ("growth X + absorbed Y across N aborts < floor Z", or "held
  (single abort, #5293)" for count 1).

kernel-change: nudge decision only (kernel/src/compress.ts, types),
host booking only (src/session.ts absorbAbortedTurnGrowth); no config
surface added.

tests: kernel/tests/issue5415-absorb-debt-nudge.test.ts (8 cases incl.
the #5293 single-absorb pin), tests/issue5415-absorb-debt.test.ts
(booking arithmetic + count), #5293 e2e unchanged and green; kernel
suite 1521/1521; host nudge/abort suites 23/23; tsc clean.
2026-11-01 16:17:17 +08:00
ci-check ef0d1a4623 kernel: bump acp-kernel 0.0.174 → 0.0.175 after master merged #5196's 0.0.174 (version collision on merge; order coupling noted here) 2026-10-31 23:27:42 +08:00
ranxianglei-devbox ce95ef67aa fix(#5337): share per-pass O(n) derivations across screened units — quadratic recommend screen goes linear
The recommend node re-screened every candidate unit through projectUnit,
and each projection rebuilt its full-history derivations from scratch:
five indexless linear id lookups (.find/.includes) plus repeated whole-
array rescans (protected/latest/aged tool-call sets, tool-pair map,
last-user anchor, turn-integrity pre-scan). Cost: O(units x n) on top of
O(n) — ~17s of blocked event loop for one processTurn at 23k core
messages on the #5304 repro machine; every turn of every large session
paid it (#5337).

buildProjectionShared(messages, state, config) computes each derivation
ONCE per screening pass; screenRecommendedUnits shares it with every
unit in that pass. projectUnit accepts an optional shared context and
falls back to the exact legacy inline computation when absent, so the
single-shot apply/report paths stay byte-identical. Id lookups go
through a built-once raw-id->index map; the truncation-check dropped-
set membership becomes Set-based (was includes-in-some). The judgment
itself (#3236 one-judgment discipline) is unchanged — only how its
inputs arrive.

Same-machine same-corpus wall clock (warm, best-of-3): real recommend
chain n=20000 9028ms -> ~572ms (~16x). kernel v0.0.174.
2026-10-31 22:05:49 +08:00
ranxianglei 1fa1f11812 kernel: bump acp-kernel 0.0.172 → 0.0.173 after master merged #5253's 0.0.172 (order coupling noted in PR 5253) 2026-10-31 12:25:23 +08:00
ranxianglei 7efd514ce0 kernel(#4313): make timestamps opt-in via Ports.timestamps (default off)
The stamp node and tag/summary time rendering now key off a ports flag
(createCore({timestamps})); with the default core nothing is minted or
rendered, so default-off bytes stay identical to pre-feature master.
Prompt defaults revert to the exact pre-feature texts; the timestamped
wordings survive as exported variants hosts select behind their own
flag. Version bump 0.0.171 -> 0.0.172 (kernel-change: host-side opt-in
toggle for PR #5236 requires per-instance pipeline gating).
2026-10-30 23:52:53 +08:00
ranxianglei 539896c88e kernel(#4313): immutable per-message wall-clock stamps — first-sight tsStamps mint, <acp> time attribute rendering (no wall-clock read on the render path), fold-receipt time spans, prompt ordering rules (smaller ref/time = earlier) 2026-10-30 20:11:48 +08:00
ci-check 65f9b2bd10 chore: bump acp-kernel 0.0.170 -> 0.0.171 after master sync (kernel-change-vs-base rule) 2026-10-29 23:51:18 +08:00
Cury 8d24316a23 kernel: reject shared BLOCKED emergency truncate latches (#5101) 2026-10-29 13:57:31 +08:00
ci-check f6f671f7bc chore: bump acp-kernel 0.0.169 -> 0.0.170 after master sync (kernel-change-vs-base rule) 2026-10-28 09:26:59 +08:00
ci-check 0934aa9c9e chore: bump acp-kernel 0.0.168 -> 0.0.169 after master sync (kernel-change-vs-base rule) 2026-10-28 03:39:40 +08:00
ci-check e47fd311a4 kernel: preserve existing block coverage when merging blocks (#4484)
kernel-change: merging existing blocks retracted their own coverage. The
turn-integrity gate judged the fold over this unit's ids only and withdrew ids
carried solely by the consumed blocks; those blocks deactivate on apply and the
new block does not inherit them, so the folded messages lose all coverage and
the host pre-commit guard refuses the fold (gate:coverage-regression), causing
repeated rejections of legitimate merges.

Fix lives in projectUnit's integrity step, scoped to merges (consumedBlockIds >
0); fresh folds keep the legacy behavior verbatim:
- judge post-fold coverage as this unit's ids PLUS every still-active sibling
  block's coverage, so a tool half already covered by an unconsumed sibling reads
  as folded rather than as a spurious visible half (#3322 facet);
- unfold only ids whose coverage does not depend on a consumed block, re-checking
  to a fixed point; if consistency would force unfolding such an id, fail honestly
  (split fatal) instead of emitting a doomed regressive candidate.

Host coverage guard (src/stream.ts, #3353/#3322) left intact as defense-in-depth.
Regression tests: kernel/tests/issue4484-merge-coverage.test.ts (interior
hard-protected tool; tail cut mid-tool-group; clean-merge control). Bumps
acp-kernel 0.0.161 -> 0.0.162.
2026-10-27 23:50:13 +08:00
ci-check 809b33a3ad kernel: bump acp-kernel 0.0.167 -> 0.0.168
Version discipline (Kernel Boundary rule 2): this PR touches kernel/src/wire/demoted-thinking.ts (FORMS becomes an exported single source), which requires a kernel version bump. Lockfile regenerated with npm install --package-lock-only (mirrors the lock-sync CI check).
2026-10-27 00:30:43 +08:00
ci-check 35c3fc6425 merge: sync master into #4570 fix branch (kernel 0.0.164 + master 0.0.167 -> 0.0.168) 2026-10-26 23:30:02 +08:00