Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag

- **中断后/usage 丢失后的「幻影紧急压缩」:本轮拿不到计费样本时,压力档压缩延后一轮再决定**:中断的流(用户 ESC)或上游短 TTL 缓存把 usage 报告弄丢时,本轮的「计量表针」只能落回字符级本地估算——它量的是即将被改写丢掉的入站字节,实测比真实计费高约 3 倍(0.1.212 当天两起真实现场:ESC 的会话从 9478 跳成 228376、长跑会话被连续两轮注入 153% 幻影压力带,徒劳改写并烧掉前缀缓存)。此前这种坏表针直接按 EMERGENCY/OVER-LIMIT 扣扳机。现在:内核收到以「估算值」计量的压力带读数(宿主标记 tokenCountSource="estimate")时,本轮压力档注压延后一轮——下一次请求必然带着新鲜计费报告,拿真数再决定,代价≈0;计费级读数("usage")与不传 source 的老调用方字节不变,非压力档(增长/节拍)完全不受影响,硬溢出兜底臂全程照旧武装。宿主侧提前广告臂(emergencyNudge)同步镜像该位,不会拿着同一个坏读数抢跑。逃生阀:`compress.requireUsageSampleForPressure: false` 恢复旧的估算驱动行为。tests:kernel/tests/nudge-pressure-no-sample-hold.test.ts(6 例)、tests/nudge-pressure-no-sample-armed.test.ts(3 例);kernel 既有套件 1582/1582 绿。
- **External-summary mode no longer reports protected or already-folded ranges as failed compression.** An unchanged kernel preview now returns the normal idempotent no-op or kernel-error receipt without a paid summarizer call; validated internal probe summaries prevent an irrelevant submitted-hint length from blocking that receipt. Probe-created blocks with no recoverable content still refuse rather than folding an unreviewed hint. Regression: `tests/external-summary-runtime.test.ts` (24/24).

* **dsh 车道的输出预算被「被拒压缩回放的字节数」踩死在 4096 地板、整会话不恢复(#5596)**:#1729 守卫拒发 dsh 的原生压缩回放时会把字节数记成会话级粘性高水位(`dshCompactionRefusedBytes`),#2490 规划下限把它换算成输出预算的规划下限(#3384 门控后在「请求 ≥ 25% 窗口或视图已超 headroom」时生效)——但被拒的字节**从未发出**,不是未来输入。高水位粘住会话生命周期内最大的一次回放,而请求默认 ≥ 25% 窗口的客户端(恰是常见情形)整条车道被踩死:真实事故 256K 窗口/128384 请求下 866760 字节被拒回放 → floor 216690 → cap 1172 → wire max_tokens=4096(#3071 地板),模型在恰好 4096 output tokens 处句中截断,直到泳道结束。修复 = clamp 只按**本请求实测输入**规划(溢出防御本来就是逐请求的:preflight/egress fuse #4079/#4185);记录保留为诊断水印(acp_status 单列 `DSH COMPACTION REPLAYS REFUSED` 行,明标不参与规划)。行为变更(旧→新):有拒绝记录的车道上,max_tokens 从地板踩死的值(如 4096/62797)回到实测输入决定的诚实值(至多到请求值);#2490 怪物回放形状(floor≈900K/窗口 1M)此前预算被压到 55K,现在跟随实测值——真实溢出由 preflight/fuse 处理,不再静默写出。tests/issue5596-refusal-floor-no-planning.test.ts(事故形状双向钉 + e2e:拒绝记账后下一回合 30K 预算原样通过);既有 pins issue2490/issue3384/issue3071/issue3148 改锚到新契约。
* **#5412: 异步存储后端的「压缩冻结会话」现在也能自愈。** #5408 事故(一个会话连续 17 次摘要漂移后被保护机制冻住、8 小时无人知晓)的主修复 #5409 只教了同步存储路径(SQLite 直写)自救:漂移挂起期间保存会自动升级为全量重导入并清掉索引里的残留行。异步路径(opt-in 网络后端,如 mysql)那份孪生代码没搬——同样被冻住的会话在那上面永远救不回来,每次保存都重写不完整视图、下轮采样继续漂移。本 PR 在 `src/storage/shadow.ts` 的异步入队路径补上同一行对齐(`completeLog = hasRawTail || driftedSessions.has(id)`),行为与同步路径逐字一致;回归测试同时钉住正门(latch 挂起的折叠保存清掉外来行)与负门(未挂起保存不清扫)。
- **中断频繁的会话压缩提醒几乎不触发,积到几十万 token 才压一次(#5415,0.1.210 引入)**:#5293 的修复把每次用户中断后的增长参照点直接抬到当前读数,连「中断前已实测的真实增长」也一起清零;高频中断的客户端(实测一份日志 4.5 小时 85 次中断)永远攒不到增长台阶,30 万可压内容 idle 数小时,最后一次性压 33 万。现在吸收时把被清零的实测增长记入「欠账」(`nudge.absorbedDebt`)并累计吸收次数(`nudge.absorbCount`),两者都只在**第 2 次起**的中断后生效:单次中断字节级保持 #5293 的安静(不打扰用户刚改的主意——欠账再多也不当场弹提醒);第二次中断才证明会话是「高频中断型」而非「改主意」,欠账从此与新增量一起计入增长台阶,恢复 209 时代的节奏。另加「大积压排水」兑底:欠账>0 且可压量≥2×阈值且当前无未消化提醒时不再等增长台阶(与 #194 同哲学);无欠账/单次中断的会话决策字节不变。压缩成功时欠账与计数随其它基线一起清零;idle 日志同步显示 `growth X + absorbed Y across N aborts < floor Z`(单次中断显示 `held (single abort, #5293)`)便于排查。tests:kernel/tests/issue5415-absorb-debt-nudge.test.ts(欠账付台阶/单次中断钉死不弹/排水兑底/忽略提醒不重发/无欠账字节不变/压缩后清账+清计数);tests/issue5415-absorb-debt.test.ts(吸收记账算术、欠账+计数、累次累计、参照点已越过 anchor 不记账也计数、陈旧 flag 丢弃)。
- **长会话每回合把 Node 主线程卡死十几秒、网页面板冻结(#5337)**:每回合的压缩筛查把历史切成若干可折叠单元,逐个跑「能否折叠」判定——而每次判定都从零重扫全量消息数组(id 查找无索引,五处线性 `.find()`/`includes`),还重复重算全套整史统计(受保护/过期工具调用集合、工具配对表、末尾锚点、完整性预扫)。总工作量≈单元数×全史长度=历史规模平方级,且同步跑在主线程:2.3万条核心消息实测单回合约17秒(事件循环被占死,请求排队;#5304 同签名报告)。修复=把这批 O(n) 推导提升为每轮筛查**一次**构建(`buildProjectionShared`)、共享给同一轮所有单元;id→序号一次性建表替五处线性查找;「已丢弃」成员判断从 includes-in-some 改为 Set。判定逻辑本身一字未动(#3236 单一判定纪律),只是输入到达判定的方式变了。同机同语料实测:2万条消息完整推荐链 9028ms→约572ms(≈16×),回落到线性量级。单次调用路径(apply/report)保持原有内联计算,输出逐字节不变。kernel v0.0.175。tests/issue5337-shared-screening.test.ts(共享/非共享投影逐字段等价+降级边界一致+n=20000 耗时上界钉);既有 issue3406 曲线钉与 #3236 一致性回归不变。
Expand Down Expand Up @@ -236,7 +238,7 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag

### Changes

- **bili-authored dsh client compaction: the #1729 guard can now ANSWER instead of refuse (#3733, fixes #3723's growth loop).** dsh's own compaction was refused locally since #1729 because a landed dsh checkpoint durably shadows the raw history; post-#3644 that substrate concern is gone (the server snapshot is the base), but a native checkpoint is still a foreign summary and — worse — with the refusal standing, dsh's context gauge only grows while its session file balloons unboundedly (#3723: a 39.7 MB / 9001-message file choked the desktop UI). With `BILI_DSH_AUTHORED_COMPACTION=1` (env-only rollout window, read per-request), when the guard fires AND the session holds an active fold block, bili answers the compaction summarize call LOCALLY — zero egress, the autoModeForge discipline — with OUR folded snapshot as the payload: one identity header line `<bili-snapshot v1 conv="…" seq="…" blocks="…" />` plus every active block's summary in the kernel render format. dsh records that as its checkpoint, so the client file shrinks while the recorded content is byte-identical to what the upstream already reads — client display, model context and server state finally agree. The identity tag rides in the message text, so replay recognition is declarative (`carriesBiliSnapshotCheckpoint`, the #2621 carrier+novelty discipline): the #2432 rebase handles the landing exactly like a foreign checkpoint but records `dshAuthoredCheckpointLanded` and logs info instead of warn. Precedence: an explicit `allowDshCompaction` (forward natively) still wins; no active blocks → falls through to the same 422; the passthrough-lane guard (no session) is untouched. Originals stay recoverable via CCR/export/fork; `dshCompactionRefusedBytes` keeps recording the raw-ledger high-water on authored answers too, so the #2490 output-clamp regimes keep planning against the raw scale.
- **bili-authored dsh client compaction: the #1729 guard can now ANSWER instead of refuse (#3733, fixes #3723's growth loop).** dsh's own compaction was refused locally since #1729 because a landed dsh checkpoint durably shadows the raw history; post-#3644 that substrate concern is gone (the server snapshot is the base), but a native checkpoint is still a foreign summary and — worse — with the refusal standing, dsh's context gauge only grows while its session file balloons unboundedly (#3723: a 39.7 MB / 9001-message file choked the desktop UI). With `BILI_DSH_AUTHORED_COMPACTION=1` (env-only rollout window, read per-request), when the guard fires AND the session holds an active fold block, bili answers the compaction summarize call LOCALLY — zero egress, the autoModeForge discipline — with OUR folded snapshot as the payload: one identity header line `<bili-snapshot v1 conv="…" seq="…" blocks="…" />` plus every active block's summary in the kernel render format. dsh records that as its checkpoint, so the client file shrinks while the recorded content is byte-identical to what the upstream already reads — client display, model context and server state finally agree. The identity tag rides in the message text, so replay recognition is declarative (`carriesBiliSnapshotCheckpoint`, the #2621 carrier+novelty discipline): the #2432 rebase handles the landing exactly like a foreign checkpoint but records `dshAuthoredCheckpointLanded` and logs info instead of warn. Precedence: an explicit `allowDshCompaction` (forward natively) still wins; no active blocks → falls through to the same 422; the passthrough-lane guard (no session) is untouched. Originals stay recoverable via CCR/export/fork; `dshCompactionRefusedBytes` kept recording the raw-ledger high-water on authored answers too so the #2490 output clamp could plan against the raw scale (that planning consumer was removed in #5596 — the recording is now a diagnostic watermark only, no longer fed to the budget clamp).
- **存储收尾六修+缺省模式翻 full(#3818,修复 #3135)**:`storage.unified` 缺省从 shadow 翻为 full——shadow 干跑自 #2815 起对账干净,索引成为默认加载路径;JSON 信封照写,legacy 仍是一行逃生口。同车修六项:①writerOff 存档在边车 3-strike 自禁用的当拍立即补写 JSON 信封(消除「两边都没有」窗口);②BILI_PERSIST=0/持久化关闭视为有意退出(banner 不再假报降级);③存档印章改为实例真实印章(边车开不了/自禁用→盖 legacy,不再把请求模式盖到只存在 JSON 上的记录上);④verifyDrift 计数上 /__bili/status wire,漂移会话回退信封供数直到下次采样干净;⑤自举缓存损坏(Node 大版本升级等)从「警告并永不再试」改为删缓存重下一次钉死下载(sha512 保证重试安全);⑥有界 boot 并入纯索引会话(jsonWriter=off 用户的会话重启后可枚举;并入仍受 maxSessions+解码字节双预算约束,预算口径=序列化记录字节,与文件路径 #2803 同律)。加保:索引无法忠实表达的记录(blockContents 带孤儿 id、state.blocks 无对应块——手搓档案/web seeds 形状)跳过镜像与 viewFor 重建,永远从 JSON 信封供数(orphanSkips 计数可见)——修掉该形状首载后 contents 静默丢失。真实 #2695 收割形状(块从 state.blocks 移除、原文保留给 decompress 兜底)同样命中该守卫并被钉为『永不入索引』语义;writerOff 下该形状触发安全阀强制落一份 JSON 信封(索引跳过+无文件=零副本死亡的窗口不存在)。
- **`bili claude` stops leaking a proxy and a CA into the child it spawns.** The claude lane routes over a plain http loopback URL (`ANTHROPIC_BASE_URL` → `/bili/…`), so there is no TLS hop for a proxy to tunnel and no certificate for `NODE_EXTRA_CA_CERTS` to vouch for. What the bili-owned `HTTPS_PROXY` did there depended on the client build — older ones ignored it, Claude Code ≥ 2.1.301 honours it and the `/bili/` leg self-tunnelled (#3446) — and in every case the variable was inherited by each process the child spawned, so in-session `curl`/`git`/`npm` issued CONNECT through bili's MITM, logging CONNECT destinations the compression pipeline never sees. Both are gone from the claude env; a user's own proxy variables now ride through untouched, and a child that has none of its own is handed the proxy THIS instance resolves for auxiliary egress (file-config `upstreamProxy`, or the shell proxy the launcher forwards as `BILI_INHERITED_*`) via a new `auxProxy` field on `/__bili/health` — so egress survives without bili sitting in the child's path. Keeping the `/bili/` leg direct when the child DOES carry a proxy is the `NO_PROXY` loopback merge in `buildClientEnv` (#3446), which holds whatever proxy the child brings. **Attaching to a proxy instance started by an older build** reports no `auxProxy`, and then nothing is handed over rather than guessing — restart the proxy on this build if your only proxy comes from the config file.

Expand Down
8 changes: 6 additions & 2 deletions src/acp-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,13 @@ export function handleAcpStatus(args: Record<string, unknown>, ctx: AcpStatusCtx
}
const ledgerFloor = dshLedgerFloorTokens(ctx.session.metadata);
const lastClamp = ctx.session.stats.lastOutputClamp;
if (ledgerFloor > 0 || lastClamp !== undefined) {
if (lastClamp !== undefined) {
extra.push("");
extra.push(`OUTPUT BUDGET CLAMP —${lastClamp !== undefined ? ` last: max_tokens ${lastClamp.raw} -> ${lastClamp.capped} (window ${lastClamp.window}, input~${Math.round(lastClamp.planningInput)}) @ ${new Date(lastClamp.at).toISOString()}` : ""} · planning floor ${ledgerFloor} tok from the refused dsh compaction replay (#2490, sticky for the session lifetime). Only compression can recover the input; this clamp guarantees native-window fit.`);
extra.push(`OUTPUT BUDGET CLAMP — last: max_tokens ${lastClamp.raw} -> ${lastClamp.capped} (window ${lastClamp.window}, input~${Math.round(lastClamp.planningInput)}) @ ${new Date(lastClamp.at).toISOString()}. Only compression can recover the input; this clamp guarantees native-window fit.`);
}
if (ledgerFloor > 0) {
extra.push("");
extra.push(`DSH COMPACTION REPLAYS REFUSED — raw-ledger high-water ${ledgerFloor} tok (recorded by the #1729 guard; diagnostic only — refusals never drive the output budget, #5596).`);
}
// #1097: the processTurn above already resolved the envelope when armed
// (contentStoreOf is idempotent); when disarmed skip the disk read.
Expand Down
Loading
Loading