Repository navigation
[PR] feat: forbid unprompted/out-of-bounds compression (compress.requireNudge / requireRecommendation) - #5685
Conversation
…4599) Master 9dc4c94 red on test (windows-latest, 22, 2) only: the two SSE abort cells exhausted the 10s teardown poll (closed=0, ~11s each) while the same code went green on ubuntu22/24 and windows24 shard-2 siblings (pass durations 23-352ms). The audit mandated by the constant's own note found no teardown hang: relay.ts arms res.on('close') -> clientAbort.abort() synchronously with no linger/backstop on this path, and no commit since d244fff touched destroy/abort wiring. Residual latency is runner-side event-loop starvation on loaded Windows runners (same family as the recorded 3s/6s eras). Platform-scoped response: win32 doubles to 20s; every other platform keeps the tight 10s gate so a genuine hang still fails fast.
#5428 made inline the pi lane default; this suite documents the spawn contract (instance record + proxy origin, per-request stamps, the shared-proxy delegate-child channel, /__bili/plugin/status over HTTP) and was not updated with the flip. Under the inline default its delegate-child stamp assertions get 0 stamped child requests (child traffic reaches upstream unstamped, conv=null) and the /acp instance- record assertion fails structurally. Pin BILI_PI_INLINE=0 for the whole suite so the spawn-posture coverage stays deterministic; inline posture is covered by tests/pi-inline-ws.test.ts / tests/pi-native.test.ts.
…76902208 flaked at 20s (#4599)
…40s raise (#4599) Run 41776902208 flaked openai-sse at the 20s win32 budget (closed=0 after 20.5s; siblings 131-410ms in the same run). The flat-raise ladder (3s->6s->10s->20s->40s in 850eca9) measures the runner, not the teardown: the poller shares ONE event loop with whatever starves it, so a close event cannot arrive faster than the loop itself. Keep the win32 base at 20s and extend the window by the poll's own measured event-loop lag, capped at 2xbase (<=40s - the same worst-case ceiling as the flat raise, applied only when lag is actually observed; healthy-loop gate byte-for-byte unchanged so a genuine hang still fails fast). Arithmetic pinned by a regression test.
(ai: vllm-qwen/qwen3.8-27b) 查重: 不重复 —— 检索了 open/closed issue 与 PR,没有其他条目覆盖同一「模型主动压缩策略门」;相关条目只有来源需求 #5683(qwen-27b unprompted compress case)。 收到 PR 线程(#5685,Closes #5683)。初步状态:
|
Two opt-in compress policy gates for models that fold on their own (e.g. qwen 27b), configurable globally / per provider / per model and toggleable from the web panel compress card: - compress.requireNudge: a model-initiated compress call is refused with an error receipt unless a compression nudge actually reached the model this turn (post-gate delivery fact: round nudgeOutcome "injected"). The arm persists across loop rounds of the same turn and dies with the next un-nudged turn; stamped per round from the prepare outcome. - compress.requireRecommendation: every submitted range must stay within what bili currently recommends folding (prepare-time offer when present, else live recompute; viable + dead-ref + minCompressRange filters). Judgment by coverage, not equality: subdividing a recommended span passes; refolds updating an active block are exempt; a range escaping the set is refused whole, naming the offending span(s). Both gates run in applyRanges — the single choke point every lane's model-initiated compress call funnels through (proxy loop, JSON wires, anthropic proxy tools, and all native plugin lanes via /__bili/plugin/tool) — so one enforcement covers every client. bili's own overflow backstop folds ride loopTracking:false and stay exempt: availability unaffected. Default off; no env vars; host-only fields (kernel untouched).
#5683) 16 tests: parse/merge semantics of both knobs (deepest-wins, explicit-false disables, non-boolean rejected), default-off success pin, timing gate (unarmed refusal / armed success / preflight-lane exemption / both-gates ordering), scope gate (in-offer + subdivision pass, outside + mixed-span refusal naming spans atomically, refold carve-out, empty-recommendation strict refusal), and the plugin-lane shape (no prepare snapshot: live recompute source, dead-ref span out of bounds).
18183be to
f392749
Compare
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.8175-pr.5685.230395bThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5685.tgz
npm install -g packageInstall instructions are refreshed on each push. |
(ai: vllm-qwen/qwen3.8-27b) 冲突已解决并推送。rebase 到当前 master(c9ba485),force-push 后 PR #5685 的 mergeable 已翻为 true,当前状态 blocked = 等新一轮 CI 跑完(推送时镜像缓存里还没有新 run 的记录,CI 红了我这个 bot 接着修)。 结构化八问
收工判定:冲突阻塞已清除(mergeable=true),无需要决策的事项;等新一轮 CI 结果,红了由我继续跟。 |
…the #5683 scope gate (agent review cleanup, PR #5685) The scope-gate if/else was inserted between the #4797 translation check and its else branch, hijacking it: 'else { ranges = supersededRes.translatedRanges }' now pairs with the gate test instead of the translation count. Behavior stayed byte-identical only because supersededRefRejection returns a full identity copy even when nothing was translated, but the surviving else reads as dead logic and will mislead the next editor. Restore the pre-PR shape: adopt the translated list unconditionally (master's original assigned in both branches), keep the log-only check, drop the misleading else.
…erate artifacts (agent review fix, PR #5685) The feature hand-edited the generated param-ref block in CONFIGURATION.md / CONFIGURATION.zh-CN.md without touching the declared single source of truth (website/config-reference/compress.yaml, #2107), which reds two CI jobs: docs-sync (regenerate-then-diff over CONFIGURATION*.md, website/main.js, website/docs/index.html) and config-surface-guard (#2643: every nested leaf field needs a seed key entry). Add the two seed entries with desc text identical to the merged table rows — regeneration now reproduces the committed md byte-for-byte (verified: zero drift) — plus the website main.js site-dict keys and docs table rows the generator owns.
[bot] 🏷 (ai: vllm-qwen/qwen3.8-27b) 进度更新——审查完成,两个修复已推送到 PR 分支(bbe8ceaa4),等 CI。 审查期间发现分支被重写为
本地验证(最终树 bbe8cea):typecheck 干净、build OK、定向测试 89/89 通过(issue5683 套件 16 个 + compress-reject-reasons / compress-settings / config-surface-guard / fix-1124 / compress-fingerprint-refold)。PR 内容本身审查结论:方向正确、单一咽喉点、双模式推理到位、gate 双向纪律(#3617)齐全、16 测试套件扎实。CI 结果出来给八问终回复。 |
(ai: vllm-qwen/qwen3.8-27b) 两个红 gate(config-surface-guard、docs-sync)的修复已经在分支上了——我诊断并独立做完修复的过程中,另一个 review-fix bot 把同样的修复推上来了;按查重纪律我弃掉了自己的重复 commit,改为对它的树做独立验证,全部绿。本轮我没有推任何新提交。 结构化八问
收工判定:分支头 bbe8cea 已含完整修复且经我独立验证,等这两个 job 重跑结果;其余 test 矩阵仍在排队中,再有红我继续跟。 |
…bort-teardown flake, #4599 family) The test (windows-latest, 22, 2) shard red at bbe8cea failed with the in-archive signature: abort x proxy-{openai,responses}-sse socket not closed within the absolute wall-clock budget (closed=0, ~10.6s) while the sibling anthropic case passed in 214ms — runner event-loop starvation, zero intersection with this PR's diff. The lag-aware budget fix (win32 base + measured poll-lag extension, healthy-loop threshold byte-identical) is converged in ci-fixes; per #4599 policy the fix rides the permanent branch.
(ai: vllm-qwen/qwen3.8-27b) 审查与收尾完成,结论如下(八问体例)。 1. 是什么问题:bili 对模型自己发起的压缩调用没有任何策略拦截面——#5683 里 qwen-27b 在没有收到任何压缩提示的情况下自行发起 compress。本 PR 加两个 opt-in 门: 2. 什么原因导致的:applyRanges 这个所有压缩路径的咽喉点只校验「范围合不合法」,从不问「这一轮该不该压、压的是不是推荐集里的东西」——缺 timing 和 scope 两个判定维度。 3. 影响范围与严重程度:两门都默认关闭,不配置 = 零行为变更;开启后只约束模型发起的 compress,bili 自身的溢出兜底折叠经 4. 怎么修复的:单一咽喉点 applyRanges 双门。timing 门:prepare 每轮把「本轮 nudge 是否真正送达(nudgeOutcome==injected)」盖章进内存态 session.transient,loop 多轮保持武装、下一未提示轮自动解除;scope 门:提交范围必须被当前推荐集覆盖(覆盖判定而非精确相等——拆小段合法、重折活跃块更新摘要豁免),越界整体拒绝并回执点名越界跨度、指向 acp_status。plugin/proxy 双模式推理到位,内核未动,无新依赖。测试 16 例双向断言齐(#3617 纪律)。 5. 是否有回归问题:逐项审过既有行为——gate 关闭时管道逐字节不变(有 default-off 成功用例钉住);审查中发现并修掉一处结构瑕疵(PR 把新 gate 块插进原 superseded 翻译的 if/else 之间,劫持了 else 分支——行为等价但误导后人,已恢复为 master 原样的无条件赋值,独立 commit 9c5e1ec);preflight 兜底折叠、nudge 三种注入路径(advisory/decide-directive/emergency)全部确认走同一 armed 事实。本地定向验证:typecheck 干净、build 通过、相关 7 个测试套件 97/97。 6. 是否破坏缓存:不涉及——无缓存/重试/游标/去重键路径变更。 7. 是否改了设计方向:不转向。host-only 策略层加在既有咽喉点上,内核零改动,单写者契约不受影响。 8. 是否引入新配置:是,已按配置面纪律全登记。 过程披露:① 审查期间分支被作者重写为已 rebase 到当前 master 的状态,我此前的整分支 rebase 作废,两处审查修复改为追加提交、完整保留作者历史;② CI 终态:全矩阵 run 41880828212 completed/success(head 6f38517);期间 windows-latest 单格 wire-exit-matrix abort-teardown flake 复发两次(继承性家族,#4599 在档,ci-fixes d7a1a91 的 lag-aware 预算已在树内),单次 rerun 后转绿,系统性加固已报备哨兵裁量,本分支未自行动预算。 标签:scope/wiring + p3(协议接线层的可选策略面,默认关闭无用户可见变化)。 |
(ai: vllm-qwen/qwen3.8-27b) 本轮红条 结构化八问
备注一条观测:镜像的 check 状态缓存在本轮长时间停更(快照冻结),我按允许的回退方式用少量间隔式单次 API 读取确认了最终状态,未做轮询。 收工判定:head |
…commendation set (agent review addendum, PR #5685)
ranxianglei
left a comment
There was a problem hiding this comment.
审查判定:APPROVE(可合)——GitHub 禁止作者账号 approve 自己的 PR(422),故以 review comment 形式提交本结论。
(ai: vllm-qwen/qwen3.8-27b)
APPROVE — 独立审查完成:方向正确、单一咽喉点实现准确、默认关 = 零行为变化、双门双向断言齐全,不触碰 kernel/wire/缓存。可合(待 owner 合并;本审查推了一个顺手补测 commit,CI 将在新 head c42120f51 上重跑)。
结构化八问
- 是什么问题:qwen 系模型在没有收到任何压缩提示(nudge)、也没有推荐依据的情况下自行发起 compress(#5683);需要非侵入的开关禁止「未提示 / 越界压缩」,并允许 web 面板配置。
- 什么原因导致的:
applyRanges(所有车道模型发起压缩的唯一执行点)只校验「范围合不合法」,从不问「这一轮该不该压、压的是不是推荐集里的东西」——nudge 只是建议文本,不构成拦截面。本 PR 在该点加两个 opt-in 策略门:requireNudge(本轮必须真正送达过 nudge——handle.ts 每轮把nudgeOutcome === "injected"盖进内存态session.transient)与requireRecommendation(提交跨度必须被当前推荐集覆盖——拆小段合法、重折活跃块合法、越界跨度整体拒绝且回执点名跨度并指向 acp_status)。 - 影响范围与严重程度:两门默认关 ⇒ 存量用户零变化;只有显式开启的路由改变行为(此前会被执行的自发/越界 compress 变为拒绝回执)。属体验/成本类防护功能,无存量用户受影响。
- 怎么修复的:单一咽喉点 + 每轮盖章 + 覆盖判定。timing 门在解析前运行(拒绝优先);scope 门在 #1001 顺序归一与 #4316 superseded 翻译之后运行,比对对象是「fold 将实际作用的 refs」。推荐集复用展示面的同一过滤链(viable + dead-ref 排除 + minCompressRange),与 nudge submitGate / acp_status
liveCompressionRanges逐行一致——用户看到什么,门就放行什么。preflight 自留 / 溢出兜底走既有的loopTracking:false豁免,nudge 通道自身被抑制时可用性也不受影响。 - 是否有回归问题:无。diff 触碰路径的既有行为逐项清点:
- gate 关闭/未盖章路径:控制流不变、逐字节等价(default-off 成功用例钉住;compress 相邻套件全绿);
supersededRefRejection:「两个分支都赋translatedRanges」改为无条件赋值——master 基线(c9ba485 stream.ts:1047/1050)本就两边同赋,语义完全等价(commit 9c5e1ec);superseded 回归套件(issue4797/issue4383)10/10 绿;- preflight 车道(
loopTracking:false):豁免保持(专项测试钉住); - refold(更新活跃块摘要):
coveredRefRuns车出,不被 scope 门误杀(专项测试钉住); - 空推荐集:严格拒绝 + preflight 豁免保住可用性(专项测试钉住);
- config 解析:非布尔值整块拒绝,与 compress 其余字段一致(测试钉住);
- web 面板新行与既有 cafRow/abRow 模式完全一致(
row()自动挂入 box;取消勾选删 key 并清理空compress对象),与其他 quick toggle 行为一致; - 高危模式逐项过:fail-fast 未变吞错(拒绝 = 显式回执 + log 行)、无阈值/时序漂移(默认关)、输出格式不变(仅启用后新增回执文本)、缓存策略不受影响。
- 是否破坏缓存:不涉及。拒绝发生在 kernel apply 之前,历史前缀字节不动;gate 关闭时请求路径与原流程逐字节一致;无缓存键/去重游标/增量水位变更。
- 是否改了设计方向:不转向。host-only 策略层挂在既有咽喉点上,kernel/ 零改动,wire 格式/会话身份/存储格式未动;「单执行点 + loopTracking 判别器」与既有架构一致(#2146 breaker 豁免用同一机制)。
- 是否引入了新的配置:是,已按配置面纪律全登记——
compress.requireNudge/compress.requireRecommendation,布尔,默认 off(unset = 禁用),随 global→provider→model 三级级联逐字段合并(深层显式 false 可覆盖),经既有 config PUT 热生效,无 env var(env 纪律 #2030);CONFIGURATION.md en/zh +website/config-reference/compress.yamlseed(cw.rnug/cw.rrec)+ 再生成产物已同步,config-surface-guard 绿。
测试有效性:17 例(含本审查补的 1 例),全部按 #3617 纪律双向断言(该触发时触发 / 不该触发时安静);原子性(blocks.length===0)、回执措辞(区分本门回执 vs kernel 回执)、plugin-lane ctx 形状(无 lastNudge → live recompute)均有覆盖。本地定向验证:typecheck 干净;新套件 17/17;相邻 7 套件(config-surface-guard/compress-settings/acp-status/compress-reject-reasons/compress-success-tail/compress-fingerprint-refold/compress-at-fold-point)95/95;superseded 回归 10/10。全量判定以远程 CI 为准。
已顺手修:scope 门的 minCompressRange 下限过滤原本没有测试钉住(offer 里低于下限的跨度应视为 out-of-bounds)——补 1 例钉住,commit c42120f(已推 PR 分支)。
一条非阻塞观测(不改代码):nudge.shouldInject=false 的回合里,fold 后的 hint(submitGate)会显示空列表,比 scope 门本身(跟随 acp_status 面)更保守——门比自己的 hint 略宽,方向安全(更宽 ≠ 数据丢失),仅记录在案。
结论:APPROVE,可合。
(ai: vllm-qwen/qwen3.8-27b) 审查完成,判定:APPROVE(可合)。独立审完原 issue(#5683)、完整 diff 与全部触碰路径:单一咽喉点 applyRanges 双门实现准确、默认关零行为变化、推荐集与展示面(nudge/acp_status)过滤链逐行一致、preflight 豁免保住可用性、superseded 无条件赋值与 master 基线语义等价、web 面板行与既有 quick toggle 模式一致、配置面纪律全登记(en/zh + yaml seed + 再生成产物)。本地定向验证:typecheck 干净;新套件 17/17;相邻 7 套件 95/95;superseded 回归 10/10。八问全文见 GitHub PR #5685 的 review(GitHub 禁止作者账号 approve 自己的 PR,故以 review comment 形式提交,结论 = 可合,待 owner 合并)。 已顺手修:scope 门的 minCompressRange 下限过滤原本没有测试钉住(offer 里低于下限的跨度应视为 out-of-bounds)——补 1 例钉住 + commit c42120f(已推 PR 分支,CI 将在新 head 上重跑)。 非阻塞观测一条: |
ranxianglei
left a comment
There was a problem hiding this comment.
(ai: vllm-qwen/qwen3.8-27b)
复审确认(新 head c42120f):判定不变 — APPROVE,可合。
- 本 head 相对上一审查头 6f38517 的唯一增量 = 上一轮审查自己补的回归钉 commit c42120f(仅 tests/issue5683-forbid-unprompted-compress.test.ts +15 行:minCompressRange 下限过滤的 out-of-bounds 钉)。该 commit 提交前已本地验证:套件 17/17、typecheck 干净。
- 完整八问审查(方向/单咽喉点实现/双门双向断言/配置面登记/缓存与 kernel 零触碰)已在本 PR 的上一条 review 中给出——那条 review 正是在 c42120f 推送之后提交的,即针对的就是当前这个 head,不重复粘贴。
- 镜像 check 缓存(本 head):0 failed;mergeable=true、无冲突。
- 形式说明:GitHub 禁止作者账号 approve 自己的 PR(API 422,账号与作者同为 ranxianglei),故正式 approval 动作无法由 agent 执行——请 owner 直接合并。
收工判定:无新增发现、无需决策项、无 kernel 变更,可合。
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.1034-master.a3f0e8c # this exact build
npm install -g billion-context@master # always the newest merged build
|
Closes #5683
Two opt-in policy gates for models that fold on their own (the qwen-27b case from the issue: unprompted
compresscalls all the time), plus web-panel toggles.What
compress.requireNudge(bool, default off): a model-initiatedcompresscall is refused with an error receipt unless a compression nudge actually reached the model this turn. Arm = post-gate delivery fact (roundnudgeOutcome === "injected"; advisory, decide-directive and emergency injections all arm it). The arm persists across loop rounds of the same turn and dies with the next un-nudged turn — exactly the issue's 「注入这一轮直接压缩的放过」.compress.requireRecommendation(bool, default off): every submitted range must stay within what bili currently recommends folding — the same live set nudge text / acp_status show (prepare-time offer when present, else live recompute; viable + dead-ref + minCompressRange filters). Judgment by COVERAGE not equality: subdividing a recommended span passes; refolds updating an active block are exempt (those refs never sit in fresh recommendation lists); a range escaping the set is refused whole, naming the offending span(s) and pointing at acp_status.Both knobs merge global → provider → model per field like every other compress field (explicit
falseat a deeper level disables).Enforcement design
One choke point:
applyRangesin src/stream.ts is where EVERY lane's model-initiated compress call lands (proxy loop, OpenAI/Responses JSON wires, Anthropic proxy tools, and all native plugin lanes via/__bili/plugin/tool). The gates run there, before any kernel apply, so one enforcement covers every client and our refusal receipt deterministically wins over kernel-side rejections. bili's own overflow backstop folds ride the existingloopTracking:falsediscriminator and stay exempt — availability is unaffected even when the nudge channel itself is suppressed (self-heal D1 interaction documented in CONFIGURATION.md). Gate state is stamped per round in handle.ts from the prepare outcome into an in-memory session.transient field (src/unprompted-gate.ts); restart reads all-off until the first round re-stamps, which is safe because no tool call can reach applyRanges before its own round's prepare.config surface
Two NEW boolean fields under the existing three-level
compresshierarchy:requireNudge,requireRecommendation. No env vars (env discipline #2030). Neither existing mechanism expresses this: theinjectTool/lane gates control whether bili OFFERS compression to the model, not what the model may DO with the tool once declared; per-provider/model scoping of a model-behavior policy only exists through the compress cascade. Considered and rejected: a lane-level kill switch (wrong layer — the tool surface must stay visible so nudges still work), an env var (policy belongs in config). Compat/migration: both default off ⇒ zero behavior change for every existing install; enabling is a pure addition; nothing to migrate.behavior change disclosure
Default-off: no change for anyone who doesn't enable a knob. When enabled, the intended behavior change is precisely the feature: previously-honored unprompted/out-of-bounds model compress calls become refused error receipts (model-visible text names the knob and tells the model to continue without folding / consult acp_status). No threshold, timing, format or cache-key drift elsewhere.
Web panel
Two checkboxes on the compress card (en/zh labels + hints), hot-applied through the existing config PUT path (no restart); unchecked deletes the key so deeper-level settings re-surface.
Tests & verification
New
tests/issue5683-forbid-unprompted-compress.test.ts: 16 tests covering parse/merge semantics, default-off success pin, timing gate (unarmed refusal / armed success / preflight-lane exemption / both-gates ordering), scope gate (in-offer + subdivision pass, outside + mixed-span atomic refusal naming spans, refold carve-out, empty-recommendation strict refusal), plugin-lane shape (live-recompute source, dead-ref span out of bounds). Local: typecheck clean, build clean (dist-external OK — no new deps), targeted suite + adjacent compress suites green (33 tests). Full-suite verdict = CI on this head.No kernel changes (host-only fields); no new dependencies; docs updated in CONFIGURATION.md en/zh.