Repository navigation
[PR] DSH gate: Out-of-window requests guaranteed to be rejected upstream are no longer sent as raw direct calls (calibrated e | dsh 闸门:必然被上游拒绝的超窗请求不再裸发直连(校准估算 + 每次直连留痕) - #5875
Conversation
|
自审结论(按惯例直接发评审): 正确性:双档计价是严格嵌套关系——floor 档的每个拒绝都在新判定里保留( 留痕面:节奏为 首次/状态变化/每第 10 次,256 键 Map 上限与溢出清表行为未动(内存有界);#3651「none 不上面板」契约未动,新增信息只进 durable 日志。 风险与取舍:1.14 为当前标定值,计费比若下移则拒绝面偏严——代价是本地 422(可诊断、可重试压缩),换取不再出现上游炸会话,owner 已认可。 实现期发现并已修的小问题:① 测试文件 regex 内 本地证据:tsc 干净;定向电池 165/165 绿(75+160 去重后合计见 PR 描述)。等 CI。 |
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8530-pr.5875.0532a63This exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5875.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm/qwen3.8-27b) 查重: 不重复——开放 issue/PR 中无同主题条目,本 PR 即 #5613(owner 裁定 ①②③ 一个 PR)的交付物。 我独立重审了 PR head 独立审核结果正确性(与自审结论一致,独立复核)
行为变更披露(旧值→新值 + 原因)
本地定向验证(全量回归交给 CI)
CI 红项定位与处置
结构化八问
收工判定代码层面本 PR 可合(独立审核无回归,行为变更均已披露且获 owner 预先认可);CI 唯一红项为继承性(master 今日 phantom-pressure guard 使两个零基线 nudge 场景断言过期),已按政策 merge ci-fixes(新 head |
(ai: vllm/qwen3.8-27b) 补充更正(CI 全貌):首条回复时 12 个 test shard 尚在跑,现全部落定,更正快照——
|
(ai: vllm/qwen3.8-27b) 上一条 shard 列表表述有误,精确更正——新 head |
…ses large histories locally; log every direct send with its size
Owner ruling 2026-11-07 (items 1-3 as one PR; item 4 deferred):
(1) Calibrated estimate tier. The shared over-window predicate now
prices bodies at bytes/4 x CALIBRATED_TEXT_TOKEN_RATIO (1.14, the
measured billing bias from #5613's session ledger) on top of the
optimistic floor. The old bar is strictly nested: anything the floor
already refused is still refused (provablyOver); anything only the
calibrated estimate crosses is refused too, since direct-sending it
was a coin flip weighted toward a guaranteed upstream 4xx. Missing
data (no size / no window / undecodable stays all-core) keeps
fail-open by construction.
(2) Large-history fail-close lands on BOTH gate arms: the thrown-
attribution settle path (#2924/#3581/#5609 lineage) and the unattributed
arm (#4068). Local refusal = 422 with the token math in the durable
line; small lanes keep #1117 direct semantics byte-for-byte.
(3) Every bare DIRECT send now carries its body size (or an explicit
'size unknown - the fuse could not run' note) and logs on a bounded
cadence (first occurrence / state change / every 10th), so a leaking
agentless lane can no longer stay silent after line one. Streamed
bodies with a declared Content-Length are now priced from it instead
of being skipped, so the fuse also arms for large streaming sends.
50a87c4 to
e920fb0
Compare
…efs ledger, ranxianglei#5199 throttle429Scope, ranxianglei#5875 dsh gate safety net Adopts a fourteen-commit batch. Three genuine overlaps, all auto-merged without manual resolution: - `src/loop/core.ts` — master adds the `ranxianglei#5613` direct-send size guard in `dsh-native.ts`/`native-intercept.ts`; the lane's `isDraftDump` gate is on a different hunk. Both sides verified present after the merge. - `src/server/relay.ts` — master touches `forward()` bookkeeping; the lane's non-streaming `pipePluginJson` guard survives at `src/server/relay.ts:2062`. - `src/storage/mysql.ts` — master's incremental refs ledger lands in `store.ts`/`ingest.ts`; the lane's `export const MYSQL_SCHEMA_VERSION = 11;` at `src/storage/mysql.ts:77` is untouched. Everything else in the batch (process.yaml throttle scope knob, WAL/checkpoint observability, `ccr_entries`/`blocks` incremental legs) lands with zero lane contact. Verified on the merged tree (CI preload chain, BILI_STORAGE_UNIFIED=legacy, kernel rebuilt to 0.0.185): tests/issue5175-drift-name-leak.test.ts 58/0, tests/tag-echo.test.ts 79/0, tests/issue2190-degen-close.test.ts 32/0, tests/golden-storage-render.test.ts 5/0, tests/storage-engine-proofs.test.ts 12/0, tests/wire-contract.test.ts 23/0, tests/issue4666-migration-dedup.test.ts 2/0, tests/native-compact-terminal.test.ts 1/0, tests/issue5199-throttle429-scope.test.ts 6/0, tests/issue5744-incremental-refs.test.ts 2/0, tests/issue5744-ingest-diff.test.ts 5/0, tests/issue4739-storage-read-snapshot.test.ts 4/0, tests/dsh-native.test.ts 75/0. `tsc --noEmit` clean; the four repo gates exit 0; `gen-config-docs generate` is a no-op on the four generated artifacts.
…l lines Reconciled onto #5875 (owner ruling 2026-11-07): the every-10th cadence and the trailing size note stay verbatim; this change adds only the resolved context window to the size note so a single refusal line is self-describing (body scale + the window it was judged against), no provider-log correlation needed. An unresolvable window degrades to "window unknown" — never a fabricated number. Closes #5613
这是什么问题(一句话)
经网关进来的
ds-harness-remote大历史请求,在归属识别失败(none/threw)时会不压缩直接裸发上游;而本地那道「超窗就拒」的熔断用 bytes/4 乐观估算,系统性低估真实计费(实测 ≈×1.14),于是「其实必然被上游拒掉」的超大请求反而穿过熔断去裸发——上游要么 400/413、要么把 max_tokens 挤到 1(真实现场:927K prompt 只剩 1 token 回复;1.3M prompt 后整会话报废)。而且裸发只在第一次留一行日志,之后整条泄漏环路静默。#5613 的三层安全网(owner 2026-11-07 裁决:①②③ 一个 PR,④砖机自救另议)。改动三件事
src/util.ts+src/agent/native-intercept.ts共享谓词)CALIBRATED_TEXT_TOKEN_RATIO = 1.14(会话 ledger 实测计费偏差)。provablyOver),叠加 ×1.14 校准估算档;旧判定严格嵌套在新判定内——floor 已拒的全部照拒,只有校准档新跨线的那段区间改走本地拒绝。媒体字节仍在两档之前扣除(DSH's unattributed over-limit gate prices base64 images as text (bytes/4) — media-heavy requests are falsely rejected wi | dsh 无归属超限门把 base64 图片当文本计价(bytes/4)——媒体重的请求被假拒 422,上游本会正常接受 #4111 语义不变)。Content-Length的流式体现在按声明值计价(原来直接跳过)→ 大流式请求也能触发熔断;小体量不受影响。src/agent/dsh-native.ts闸门)threw归属结算臂([dsh-native] takeover-gate refusal (threw state) fails open with the FULL uncompressed transcript; a >window local history dies upstream with 400 (maximum context length) #2924/压缩接管失效后完全静默:面板与 /__bili/status 看不出压缩已停,用户全价直连直到重启才恢复 #3581/[PR] fix(resume): inherit timestamp ledger so resumed sessions re-render provider-cached tag bytes #5609 谱系)与 unattributed 臂(The input (6165048 tokens) is longer than the model's context length (1048580 tokens(todo fix)). #4068):校准估算过窗即本地 422,durable 日志带上完整算式(est ~N tok vs window W,declared D,media 排除数)。小车道(sidecar 短调用等)「BUG」native-intercept 进程级 globalThis.fetch 补丁按 URL 形状接管所有模型流量,无关调用者(如 MemOS)被卷入宿主压缩流程 #1117 直通逐字节保留。(this body N B);尺寸未知则明说(body size unknown — streamed/unreadable; the over-window fuse could not run)。DIRECT_SEND_LOG_EVERY = 10),走既有 bili.log[dsh-client]通道(GUI 可见,方式一安装的dsh 原生插件:llm-pi-ai 传输(OpenAI SDK + options.fetch 注入)绕过 globalThis.fetch 拦截,模型请求不进代理、压缩完全不生效 #1158/[Bug][native lane] #2827 同机制的剩余面:其他 native 车道的会话中途 console.* 仍直写宿主终端 #2831 契约不变);256 键上限的内存行为不变。连续泄漏环路从此必有痕。没改的东西
none车道永不向面板上报(只留日志),threw双频上报节奏不动。directSendOrRefuse)同步吃到新谓词与文案,行为对齐。验证
tsc --noEmit(kernel + pi-subagents 预构建后)干净。tests/dsh-native.test.ts(75)、tests/native-intercept.test.ts、tests/web-diagnostics-enrichment.test.ts合计 160、tests/issue4894-direct-window-guard.test.ts(5)。改动面 grep 确认仅这 4 个测试文件引用受影响符号/文案。provablyOver/estTokens字段。refs #5613