Skip to content

[PR] EN | #3977 step 1: extract size-evidence ledger facade + land preflight verdict enum (zero behavior change) - #4012

Closed
ranxianglei wants to merge 5 commits into
masterfrom
2026-10-20_size-evidence-facade
Closed

ranxianglei wants to merge 5 commits into
masterfrom
2026-10-20_size-evidence-facade

Conversation

@ranxianglei

@ranxianglei ranxianglei commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

(ai: vllm-qwen/qwen3.8-27b)

#3977 migration step 1/5 — pure extraction: size-evidence ledger facade + preflight verdict enum, judgments byte-identical. Work stack sits on the #3971 integration branch per the issue plan.

Contents (2 commits, stacked)

This branch stacks on PR #4009 (step-0 pins):

  1. test: pin preflight escape-hatch × local-refusal edges + calibration boundary (#3977) — identical to [PR] test: pin preflight escape-hatch × local-refusal edges + calibration boundary (#3977) #4009; drops out automatically on rebase once [PR] test: pin preflight escape-hatch × local-refusal edges + calibration boundary (#3977) #4009 merges.
  2. refactor: extract size-evidence ledger facade + land preflight verdict enum (#3977) — the change under review. Review layer 2 only via b7a116f21..HEAD.

What changed

Zero behavior change — how it is proven

Every substitution is provably equivalent:

  • grade mapping preserves every source === "usage" / === "overflow-arm" comparison, including unknown-string sources (they project to estimate, which all old checks treated as non-evidence);
  • hasOverflowEvidence ≡ ¬(old noOverflowEvidence), including the lastInputTokens === undefined edge (limit > 0 past the trigger guard);
  • baselineEvidence.tokens > 0 ≡ session.stats.lastInputTokens > 0;
  • demotion gating matches normalizeUpstreamOrigin's undefined semantics exactly (absent/empty/unparseable origin ⇒ no demotion, same as before), so the log fires on exactly the same inputs.
    Metadata keys are untouched and no persistence format changed (phase-1 compat rule; §7.4 gate 4 holds: no config schema / persistence / wire change). Local verification: typecheck clean + 55 targeted tests green across 11 suites covering every touched path (issue3846 refusal store, issue3918 verdicts, issue3977 pins, preflight-client-abort, issue1933 F2+calibration, issue2313 probe, issue857 image baseline, issue1800 image arbitration, preflight-fail-fast estimate-only note, fix-arm-headroom-clamp, issue1493 outbound payload); full-suite verdict = CI lanes on this head.

查重: 不重复 — this IS migration step 1 of #3977's own plan; the suites above are the behavior pins it must keep green (they do).


Fixes #3977

(孤儿认领:标题本已指向 #3977,补上关闭关键字 —— 第三批清理)

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

查重:不重复 — #4012 本身就是 #3977 迁移计划的第 1 步(纯抽取),检索 open+closed issue 与近期 PR(按失败签名:facade 抽取 / preflight verdict enum / size-evidence ledger)无同主题在途条目。栈关系核对无误:head = 2026-10-20_size-evidence-facade @ 69afd9d,base = #3971 集成分支 2026-10-20_batch-b-fold-budget @ b9f439e(与正文声明一致);commit 1(b7a116f)待核与 #4009 是否逐字节同一提交。

开始独立审核:①核对 commit 1 ≡ #4009;②逐行读 layer-2 diff(b7a116f21..HEAD,即 69afd9d 本体);③对「零行为变化」的四处等价性声明逐一复核(grade 映射 / hasOverflowEvidence≡¬noOverflowEvidence / baseline tokens>0 / F2 降级门控);④本地跑触碰路径的定向套件;⑤CI 状态。完整结论按八问体例随后补发。

awork added 5 commits October 23, 2026 13:05
…facade

Rebase onto post-#4079 master: the refusal store moved by this PR's
refactor commit was the pre-TTL version. Master's #4079 (#3974) added
LOCAL_REFUSAL_TTL_MS (10 min) + the no-at-means-expired filter to
readLocalRefusals; without adopting it here the facade would silently
revert refusals to never-expiring locks. Verbatim adoption of the
master implementation (comments included).
The #3146 forward-once and #3846 refusal-closure log lines gained a
/#4185 suffix when #4185 extended the fresh-session escape to identified
zero-evidence sessions (merged to master after this pin's base b9f439e).
Behavior of the pinned anonymous-zero-baseline path is unchanged — every
other assertion in both tests passed; only the two exact-substring pins
were stale. Also align the P-FRESH negative test title with its 502
assertion (the title said 413).
Comment-only accuracy fix: post-#4079 master has no dead-end cooldown
mechanism left (knob + config key + exit site all gone), so the contract
comments must not present cooldown/dead-end-cooldown as live exit kinds.
Step 2 decides whether the members stay for ledger mapping or drop.
@ranxianglei
ranxianglei force-pushed the 2026-10-20_size-evidence-facade branch from 69afd9d to 629098e Compare October 23, 2026 05:13
@ranxianglei
ranxianglei changed the base branch from 2026-10-20_batch-b-fold-budget to master October 23, 2026 05:13
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

审核结论:layer-2 抽取本身成立(零行为变化逐项复核通过),但分支基线已失效——我已代为 rebase 到当前 master、补上三个标注 commit 并把 PR base 改回 master。 新 head 629098e6b,CI 正在跑,全量判定以 CI 为准。

独立审核做了什么(不复述 issue 结论)

① 原 issue 方向关:#3977 的根因判断我认可——知识+策略焊死在 preflight if-chain 里,估算与硬证据共用一个无类型数字(#1839 estimate-as-fact / #3146 unknown-as-estimate / #3663 mixed rulers 是同一病的三个症状);step 1 只做「证据平面 + 出口契约」的纯抽取,不碰决策,切法正确。

② 逐行读 layer-2 diff(src/size-evidence.ts 156 行 / src/preflight-verdict.ts 51 行 / src/server.ts net −59):

  • 等价性声明四条全部复核成立(可达状态域内):grade 映射对 source==="usage"/"overflow-arm" 的比较逐一对应,未知串→estimate 与原处理一致;hasOverflowEvidence ≡ ¬noOverflowEvidence(De Morgan + trigger guard 保证 limit>0);tokens>0 ≡ lastInputTokens>0;F2 降级门控与 normalizeUpstreamOrigin 的 undefined 语义精确对齐(absent/empty/unparseable ⇒ 不降级),降级日志行的数值与掩码 origin 逐字节同构。唯一理论分叉角:lastInputTokens===undefined && !hasProcessed 时旧代码 undefined===0→estimateOnly=false、新代码 0===0→true——不可达:persist.ts:2610 水合时 Math.max(0, … ?? 0)、zeroStats() 默认 0,该字段运行时恒为 number。
  • 「verbatim move」机械核验通过:refusal store 三函数+注释与 server.ts 原块逐字节一致,仅加 export(跨模块必需)。
  • §7.4 gate 4 成立:metadata key 未动、无持久化格式变更、无 wire/配置面变更;两个新文件一个纯函数投影、一个纯类型契约(step 1 无运行时接线),风险面收敛。
  • 本地验证:原 head typecheck clean + 12 个定向套件 58/58 绿;rebase 后 head typecheck clean + 13 个定向套件(含 413 Deadlock: When an authenticated session exceeds the reservation window with zero collapsibles, the #3146 forwarding | 413 死锁:带身份会话超预留窗口且零可折叠时,#3146 转发门因 anonymous 条件不触发,会话从首条消息起永久不可用 #4185)64/64 绿。

审核中发现的问题(已当场修复,均为无决策依赖项)

  1. 基线失效(主要问题):声明的 base 2026-10-20_batch-b-fold-budget @ b9f439e 早已整体并入 master,其后 master 走了数周——包括 413 Deadlock: When an authenticated session exceeds the reservation window with zero collapsibles, the #3146 forwarding | 413 死锁:带身份会话超预留窗口且零可折叠时,#3146 转发门因 anonymous 条件不触发,会话从首条消息起永久不可用 #4185(identified-fresh escape,改 preflight 区+重命名日志串)和 Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079(删除 [Bug] Codex 额度中断后恢复长会话,preflight SSE 摘要为空并持续 502 #726 dead-end cooldown + 给 [Bug][preflight] Local 413 is forgotten when the baseline becomes an estimate, reopening oversized probes #3846 refusal 记录加 10 分钟 TTL)。后果有二:(a) ci.yml 只在 base=master 时跑核心矩阵,所以原 head 上 17 个 check-run 全是 e2e-skip/gate,核心测试矩阵根本没跑过——正文「full-suite verdict = CI lanes」当时是空话;(b) 若按原样合并,refusal store 会静默回退成永不过期锁,直接回归 Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079/The context window suddenly hit its limit and threw an error. Starting a new session didn't help either. dsh | 上下文突然满了报错 新会话也没用 dsh #3974 修掉的 bug。
    处置:rebase 到 master(唯一冲突 hunk = refusal store 块,取删除侧)+ 三个标注 commit:
  2. 行为披露(第 4 条政策):本 PR 自身仍零行为变化;TTL 不是本 PR 引入的行为,是 master 既有行为在 rebase 中的正确承接——特此说明防止误读为漂移。
  3. step 2 遗留清单(不在本 PR 范围,记下不拆片):(a) src/preflight.ts:1900 还有一份同款 baseline-floor 规则的第三拷贝(kernel loop 侧),goal A「单一权威」要闭环必须把它也路由进 facade;(b) PreflightVerdict.cooldown 成员的去留;(c) Root fix: server-side size-evidence ledger + preflight verdict state machine (fold-budget/eligibility B-class family) #3977 计划的 step 4(learnFromOutcome/overflow-400)领地已被 master 上的 [PR] fix(#3900): overflow 400s teach the calibration ring — the estimator learns from rejections, not only successes #4093/[BUG] acp-proxy upstream HTTP 400: Request with 1,198,269 tokens exceeds the model's 1,048,576 token limit, consistently | [BUG] acp-proxy upstream HTTP 400:请求 1,198,269 tokens 超过模型上限 1,048,576,一直复现——是插件压缩未生效,还是 DSH 的问题? #3900(overflow 400s teach the calibration ring)部分消费,step 4 开工前先对账。

结构化八问

  1. 是什么问题:Root fix: server-side size-evidence ledger + preflight verdict state machine (fold-budget/eligibility B-class family) #3977 根治迁移第 1 步——把尺寸证据权威和 preflight 出口状态机从 ~700 行 if-chain 里抽出来,判断逻辑保持逐字节等价。
  2. 什么原因导致的(为何需要这步):估算与硬证据长期共用一个无类型数字,每个出口各自读 raw stats 字符串判级,知识+策略耦合,任何一处改判级都要翻遍 if-chain。
  3. 影响范围与严重程度:纯内部重构,本步零外部影响;真实风险窗口是分支陈旧(rebase 前无法过全量 CI、合并即回归 Context Window Overflow Issue Summary: Raw Requests Sent Directly to Upstream Rejected + Local Intercept Cooldown Lockin | 上下文超窗问题汇总:请求裸冲上游被拒 + 本地拦截冷却锁死会话(统一分析入口) #4079)——已消除。
  4. 怎么修复的:facade 做「分级证据记录 + 纯投影」(readBaselineEvidence/baselineFloor/hasOverflowEvidence),server 只消费投影结果;verdict union 落地为类型契约、运行接线留到 step 2。
  5. 是否有回归问题:审过的既有行为——F2 降级门控与日志、probe 条件、noOverflowEvidence、estimateOnly 注记、refusal store 读写语义——逐项保持;高危模式(阈值/时序/输出格式漂移、fail-fast 变吞错)均未命中;唯一理论分叉角不可达(水合保证,见上)。
  6. 是否破坏缓存:不涉及——metadata key 未动,无持久化格式变更,wire 零改动。
  7. 是否改了设计方向:有意为之且属计划内——新增两个模块作为证据平面与出口契约的家;数据流本体 step 2 才动。
  8. 是否引入了新的配置:不涉及。

收工判定

可进入 owner 合并评审,待新 head CI 绿。合并顺序建议 #4009 先行(step 0 在前),两者内容现已逐字节一致,#4009 先合后 #4012 的两个 pin commit 在下一次 rebase 直接 drop;反序亦可机械处理。CI 红了叫我定向排查。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

(ai: vllm-qwen/qwen3.8-27b)

CI 状态补报:新 head 629098e6b 的 run 已正常触发(核心矩阵这次会跑——base 已是 master),但截至现在全部 job 处于 queued,且仓库近 40 个 workflow run 里 27 个排队、0 个 in-flight——是 runner 池整体饱和(其他 PR 把队列占满了),不是本 PR 的问题。本地验证(typecheck + 13 个定向套件 64/64)已绿;CI 出结果后我会跟进:红了定向排查,绿了报一句收尾。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(ai: zhipuai-lb/glm-5.3)

收尾清理:issue #3977 的修复已随合并 PR 落地。关单;误判请 reopen。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Root fix: server-side size-evidence ledger + preflight verdict state machine (fold-budget/eligibility B-class family)

1 participant