Skip to content

[PR] verif module kickoff: sub-language guard for kernel decision core + TS→z3 symbolic executor MVP + counterexample replay | verif 模块起步:kernel 决策核的子语言守卫 + TS→z3 符号执行器 MVP + 反例回放锁(#3848) - #3853

Merged
ranxianglei merged 15 commits into
masterfrom
verif/symbolic-core
Oct 20, 2026

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

一句话

给 Tier A 的十个 kernel 决策核文件上"子语言守卫"(写进翻译器证不了的语法,CI 直接红),并交付符号执行器 MVP:把真代码翻译成 z3 约束跑出第一个端到端证明,求解器反例必须回放真代码复现才算数。

内容

1. 子语言守卫(独立有效,立刻起作用)

  • verif/subset-guard.ts + verif/guarded-files.ts + verif/exceptions.ts
  • 允许清单制:不认识的内置函数/方法/导入一律违规(异步、生成器、类继承、eval、环境读写、任意逃逸闭包、非白名单方法……)
  • tests/verif-subset-guard.test.ts 进 CI(tests/*.test.ts 自动收集);负控制用例证明守卫真的会抓
  • 例外必须显式登记(文件+规则+函数+理由),过期例外也红(清单是受审计的库存)
  • 当前 Tier A 全绿:8 条例外 + 1 个排除函数(如 compress.ts 的 Date.now createdAt 戳、tokenize 的可选 BPE 探测),每条带理由

2. 符号执行器 MVP(真代码,不是模型)

  • verif/symbolic.ts:tsc AST → z3;if 用 ITE 值合并不枚举路径;模块常量从源文件真实收集
  • 首个证明(refs.ts indexToRef 越界行为):
    • 界内 [1, 9,999,999] 无 throw → UNSAT ✅
    • 界外 witness 由求解器给出 → 回放真实编译函数确认抛 RangeError ✅
    • 漂移对照:故意写错的规格边界 → witness 在真代码上不复现 → REPLAY MISMATCH 被抓 ✅
  • verif/replay.ts:回放锁——被验证的始终是真代码,翻译器只是镜头,镜头歪了当场暴露

3. 建模决定(诚实清单,见 verif/README.md)

  • 数字 = z3 Int(受保护算术全是整数下标/阈值;浮点阈值进范围前需定标或 Real 排序)
  • padStart 等字符串渲染暂为 any(不影响当前控制流性质);regex→re. 理论、组合子内联是下一步

风险与成本

  • z3-solver(wasm)进 devDependencies,CI 各 OS 腿都会跑两个新测试(秒级)
  • 不改任何生产代码;守卫只约束这十个文件,其他代码不受影响

后续(按 #3848 路线)

数组组合子内联 → 符号消息序列;正则字面量 → z3 re.;padStart/int→str 精确化;然后逐个打靶 #3676/#3691/#3769/#3805。

守卫:对 Tier A 十个 kernel 文件做 AST 允许清单检查,白名单外语法让
tests/verif-subset-guard.test.ts 直接红;例外必须显式登记且过期即红。
现状:全绿(8 条显式例外 + 1 个显式排除函数,均带理由)。

符号执行器 MVP:翻译真代码(refs.ts indexToRef)到 z3,证明界内无
throw(UNSAT)、界外 witness 回放真代码复现;含规格漂移对照(错边界
witness 在真代码上不复现 → REPLAY MISMATCH)。

z3-solver 为 devDependency;CI 的 tests/*.test.ts 自动收集机制直接纳管
这两个测试文件。
@ranxianglei ranxianglei changed the title verif 模块起步:kernel 决策核的子语言守卫 + TS→z3 符号执行器 MVP + 反例回放锁(#3848) [PR] verif module kickoff: sub-language guard for kernel decision core + TS→z3 symbolic executor MVP + counterexample replay | verif 模块起步:kernel 决策核的子语言守卫 + TS→z3 符号执行器 MVP + 反例回放锁(#3848) Oct 19, 2026
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重: 不重复。检索了 open+closed 的 issue 与 PR,无既有 verif/子语言守卫/符号执行条目。相关但不同道:proof/(README:#2149 route-4「模型规格」道——定理证在契约模型上,靠 grounding 测试钉住代码)与本单是互补关系;本单正是 proof/README.md 里点名「另开 issue 跟踪」的 route 1–3(真代码编译进 symex 前端,消除 grounding gap),路线即 #3848。#3853 是 #3848 的起步交付(守卫 + 符号执行器 MVP + 回放锁),不开新条目。

标签: scope/kernel + p3(保留已有 pr)。理由:对象是 kernel 决策核的验证基建;功能建设非缺陷不打 bug;无用户可见故障面 → p3。

开工顺序:① 通读 Tier A 十文件盘点语法面 → ② 子语言守卫(允许清单制 + 例外登记 + 负控制,独立有效)→ ③ z3-solver 进 devDependencies,symbolic.ts(tsc AST→z3,if 用 ITE 值合并)+ replay.ts(反例回放锁)→ ④ indexToRef 三证明(界内 UNSAT / 界外 witness 回放 RangeError / 漂移对照 REPLAY MISMATCH)→ ⑤ verif/README.md 建模决定诚实清单。不改任何生产代码。完成后开 PR(Closes #3853)并回贴链接。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

**PR: #3861 本 issue,#3848 路线第一步)。分支 2026-10-19_verif-module-kickoff,单 commit,11 文件 +1499/-3。本地定向验证:typecheck 干净,29/29 通过(guard 23 + symbolic 6);全量回归看远端 CI。

结构化八问

  1. 是什么问题:kernel 决策核的验证基建缺口——[design] Pin cache stability with two outbound invariants: no-fold ⇒ exit only appends a tail; fold ⇒ bytes before the f | [design] 用两条出站不变量定死缓存稳定:无折叠=出口只多尾部,有折叠=折叠点前字节不动(证明式断言 + 属性/SMT 搜索分层) #3842 否决人工建模后,「对真代码做求解器级验证」的路线没有任何工具落地:没有防「翻译不了的东西写进范围」的守卫,没有翻译器,也没有防翻译器漂移的机制。
  2. 什么原因导致的:纯基建缺失,不是 bug。Build a TS→SMT Symbolic Executor for the Decision Core: Real-Code Solving for Counterexamples + Counterexample Replay Ag | 给决策核造 TS→SMT 符号执行器:真代码求解找反例+反例回放防漂移+子语言守卫 #3848 定了四件套路线,本 PR 交付第 1、2、4 件(守卫、符号执行器 MVP、反例回放锁);第 3 件(不变量 oracle)与四个远期靶子(Reconstruction after the granularity split still modifies forwarded wire bytes under both edge shapes (follow-up to #365 | 拆分粒度后重建在两种边缘形状下仍会改动转发 wire 字节(#3658 后续,仅缓存代价) #3676/[cache] Emergency truncation oscillates full↔clipped history at 95% usage, causing 15% hits without folds #3691/[Bug] MCP failed compression record rotation prematurely rewrites the history prefix, triggering expensive cache recompu | [Bug] MCP 失败压缩记录轮换提前改写历史前缀,触发大额缓存重算 #3769/[cache][kernel] Ref migration during durable carrier replacement rewrites sent history, causing a prefix cache seam | [cache][kernel] durable 载体替换时 ref 迁移改写已发送历史,导致前缀缓存接缝 #3805)是后续。
  3. 影响范围与严重程度:纯增量开发工具,零生产代码改动。守卫只约束清单里十个 Tier A 文件(当前库存全绿);CI 各 OS 腿多跑两个秒级测试文件;z3-solver(wasm)进 devDependencies。对用户无影响。
  4. 怎么修复的:
    • 守卫(verif/subset-guard.ts 等):AST 允许清单扫描,fail-closed——未识别内置/方法/导入、async、生成器、类继承、装饰器、eval 族、环境读写、逃逸闭包一律红。双向红:未登记违规红、过期例外(不再匹配任何活违规)也红、排除指向不存在的函数也红、活违规数≠例外数也红。负控制 19 条合成用例逐条证明守卫真的会抓 + 全允许面正控制保持绿。当前库存:4 条例外 + 1 个排除函数,每条带理由(Date.now createdAt 戳、console.warn 配置告警、process.env.ACP_REASONING_KEEP 开关、protectedFn 纯谓词传递;排除 createBpeTokenizer 可选 BPE 探测含 1–3 行 createRequire 绑定)。
    • 符号执行器(verif/symbolic.ts):tsc AST → z3(Int 域),DAW 值合并——路径数与 if 数线性,不枚举路径;模块常量从源文件真实收集(MIN_INDEX/MAX_INDEX/REF_WIDTH 全部读自 refs.ts)。首个证明(indexToRef):界内 [1, 9999999] 无 throw → UNSAT;界外 witness 由求解器给出 → 回放真实编译函数确认抛 RangeError;漂移对照——故意把 MAX_INDEX 改成 9999998 的歪镜头产出 phantom witness,真代码不复现 → REPLAY MISMATCH 当场被抓。
    • 回放锁(verif/replay.ts):被验证的始终是真代码,翻译器只是镜头,镜头歪了当场暴露。未建模形状(循环/switch/除模/字符串/正则/组合子/跨函数调用)大声抛 UnsupportedShape,静默近似被设计禁止。
  5. 是否有回归问题:无生产改动,逐项过既有行为——package.json 只加一个 devDep;tsconfig include 只加 verif/**;tests 自动收集只增不改;kernel/ 未触碰(守卫只读 kernel 源码,不写)。守卫本身对十个真实文件 + 20 个合成用例双向验证过。
  6. 是否破坏缓存:不涉及(不碰会话/缓存/更新/持久化任何路径)。
  7. 是否改了设计方向:不转向,是 Build a TS→SMT Symbolic Executor for the Decision Core: Real-Code Solving for Counterexamples + Counterexample Replay Ag | 给决策核造 TS→SMT 符号执行器:真代码求解找反例+反例回放防漂移+子语言守卫 #3848 已定路线的落地。一处与 issue 估计的诚实偏差要报:例外库存是 4 条而不是 8 条——实现的规则粒度更粗(对象字面量成员闭包、参数默认箭头算允许位置而非例外),登记的偏差更少是更强的状态;验收标准(Tier A 全绿 + 每个偏差显式带理由)按更小的数成立。建模决定诚实清单在 verif/README.md(Int 域、isInteger 空真、整数 round/floor/ceil 恒等、字符串渲染 opaque、JS truthiness = x≠0)。
  8. 是否引入了新的配置:无。z3-solver 是 devDependency,不是用户可见配置;无新 env/config/CLI flag。

判定:可合入(等 CI)。合入后守卫立刻生效——之后任何人往这十个文件里写翻译不了的语法,CI 直接红;symex MVP 就绪,下一步按 #3848 路线打组合子内联和四个靶子。

…p oscillation

Engine fixes (verif/symbolic.ts):
- constant-folding Bool combinators (orFold/andFold/notFold): z3's
  .or/.and do NOT fold '(or false false)' — the printed-form checks in
  execSeq/execStmt misread unsimplified terms as possibly-taken
  break/continue, so real returns executed on rest-on-copy states and
  vanished (slw2 repro). All control-flow Bool merges now fold.
- String(number): uninterpreted __numstr with 1..19 length bound
  (was {kind:any}, degrading padStart in refs.ts).
- dead-iteration pruning: for-loops stop when the condition folds
  false; for-of clamps slots to known concrete length. Dead unrolls
  polluted live state with OOB degradations and any-values.
- assignments routed before evalBinary dispatch (x= / x+= previously
  evaluated but never stored); execSeq makes rest-on-copy recursive.

verif/solve.ts: out-of-process SMT runner (cvc5 via python preferred —
in-process z3 WASM OOMs at 2GB on two-turn formulas; override with
VERIF_SOLVER_CMD / VERIF_PYTHON), sexp get-value parser, parseNum.

tests/verif-bug3691-oscillation.test.ts (#3691, no-cheat per #3848):
symbolic phase proves the clip can fire at the gate meter (SAT witness
via cvc5) and is UNSAT below the gate; replay phase runs the witness
through the REAL truncateLargeToolOutputs across two turns — same
resent history yields different outbound bytes (the cache seam);
threshold=1.0 mitigation pinned stable. Skips when no solver is
installed.
@ranxianglei

Copy link
Copy Markdown
Owner Author

里程碑 1/4:求解器已自己找到 #3691(紧急截断震荡)。

  • 引擎修完 4 个真 bug:z3 布尔项不折叠 (or false false) 导致真 return 在 rest-on-copy 状态里蒸发;String(number) 语义;x+= 从未写回;for 死迭代污染。
  • 新增 verif/solve.ts:进程外求解器(cvc5 优先,z3 WASM 在两轮公式上 2GB OOM;可用 VERIF_SOLVER_CMD/VERIF_PYTHON 覆盖)。
  • tests/verif-bug3691-oscillation.test.ts:符号阶段证明门限处截断可触发(SAT 见证 len=4001/tok=1900)、门限下 UNSAT(翻译不会凭空造截断);回放阶段用真代码跑两轮——同一重发历史出站字节不同(缓存接缝);threshold=1 缓解被钉住稳定。无求解器环境自动 skip。
  • smoke 3/3 + guard 2/2 + 3691 2/2 全绿,tsc 干净。

接下来:#3769(隐藏已消费 KEEP_LAST_ORPHANED=2)。

#3769

terms.ts: string-backed SMT2 Term DAG (op/sort/kids/const tag) with
memoized FNV-1a structural hash; smt2Of emits shared subterms as
top-level define-funs (SMT-LIB let bindings are PARALLEL — cvc5
rejects sibling references; define-funs are sequential and legal).
Replaces z3-solver at build time entirely: no more WASM heap blowups
(the 2GB ArrayBuffer cap killed in-process solving).

symbolic.ts engine fixes:
- shared dedup accumulators (assumptions/degradations cloned+re-merged
  per branch copy previously tripled per loop iteration → 12.6M-entry
  arrays → OOM);
- Term.hash()-keyed dedupe (toString on a shared DAG is exponential);
- constBool() for all control-flow literal checks;
- jsAnd exact-truthiness merge (bool,str mixed values collapsed to
  any before);
- NonNullExpression, statement-level destructuring, JSON.parse of
  concrete strings, for-of over Set-models;
- member() missing-field → undef (not any);
- Set/Map add/set: membership as a symbolic predicate, slot-write at
  the SYMBOLIC length. Physical appends were unsound when a previous
  guarded add may or may not have consumed its slot — the phantom
  entry then collided with real ids and the solver manufactured false
  hides. Slot-writing keyed on len is correct in every model.

tests/verif-bug3769-orphan-window.test.ts (#3769, no-cheat per #3848):
two executions of the REAL hideConsumedCompressCalls over an
append-only history; the invariant 'visible stays visible under
append-only growth' is violated by the KEEP_LAST_ORPHANED=2 window —
solver witness: tn3=compress (bare-name orphan). Negative control
(non-compress appends) UNSAT; replay on real code hides exactly the
oldest pair (hidden=2). Counter-test pins stability for text appends.

9/9 verif tests green (3691 2/2, 3769 2/2, smoke 3/3, guard 2/2).
@ranxianglei

Copy link
Copy Markdown
Owner Author

里程碑 2/4:求解器自己找到 #3769(失败压缩轮换的孤儿窗口)。

  • 引擎换成字符串 DAG Term 门面(verif/terms.ts),彻底甩掉 z3-solver WASM 的 2GB 堆上限;共享子项用顶层 define-fun 发射(SMT-LIB 的 let 绑定是并行作用域,cvc5 拒绝兄弟引用)。
  • 修了两个真正的引擎可靠性 bug:①分支拷贝曾把 assumptions/degradations 整表复制再合并 → 每循环迭代 ×3 → 千万条目 OOM;②Set/Map 的 add 用物理尾追加,在'前面的守卫 add 可能执行也可能没执行'时槽位歧义,幻影条目和真实 id 相撞,求解器凭空造出假隐藏 —— 改为按符号长度槽位写入,所有模型下都正确。
  • tests/verif-bug3769-orphan-window.test.ts:真代码两次执行 + 通用不变量『只增不删的历史里,可见的必须保持可见』;求解器见证 tn3=compress(裸名孤儿路径);非压缩追加的反例控制 UNSAT;真代码回放恰好隐藏最老一对(hidden=2)。
  • verif 全家 9/9 绿(3691 2/2 + 3769 2/2 + smoke 3/3 + guard 2/2)。

接下来 #3676(openai wire 重建重排)。

awork added 2 commits October 20, 2026 13:59
Three entries (async-mutex, tslib, z3-solver) were resolved against a
local-only registry (127.0.0.1:4873), so npm install on this branch failed
with ECONNREFUSED on any other machine, including CI. Same tarballs and
integrity hashes via registry.npmjs.org (verified by a clean install).
Native z3 prints 'unsat' and THEN exits 1 because the trailing (get-value)
fails with 'model is not available'. The exit-code-first check discarded the
verdict, so in z3-binary-only environments every UNSAT became 'no solver
available' (and the negative controls skipped silently). Parse stdout first;
the exit code stays diagnostic only.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

里程碑 2 已在分支上核实(fd2b91636),本地全量跑过:verif 9/9 全绿、0 skip(guard 2/2 + smoke 3/3 + 3691 2/2 + 3769 2/2),tsc 干净。之前 3691 符号阶段在我环境里会 skip(z3 WASM 堆上限后回退 z3 二进制又超时),装好 cvc5 后见证 len/tok 正常解出、回放翻转复现。

顺手修了两个小问题(已作为独立标注 commit 推到 verif/symbolic-core):

  1. fix: point package-lock resolved URLs at the public registry(28c491c52)——lockfile 里有 3 条(async-mutex / tslib / z3-solver)resolved 指向 127.0.0.1:4873(本地私有 registry)。后果:这台机器之外任何人(含 GitHub CI)npm install 直接 ECONNREFUSED。已改写为 registry.npmjs.org,同 tarball、integrity 不变(本地干净安装验证过)。
  2. fix(verif): trust solver stdout over the exit code(7f3431666)——原生 z3 先打印 unsat 再因尾部 (get-value) 报 "model is not available" 而 exit 1;solve.ts 旧逻辑先看退出码,把已打印的判决丢掉,z3-binary-only 环境下所有 UNSAT 都变成 "no solver available",负控制静默 skip(我环境实测命中)。现在 stdout 判决优先,退出码仅作诊断。

开始里程碑 3/4:#3676(openai wire 重建重排)——先读 issue 与涉事代码,再按同一套「求解器找触发条件 + 真代码回放钉住一般不变量」的打法做 H3 harness。

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: verif/symbolic-core (0ed60e1)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4713-pr.3853.bb1c74b

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Option B — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr3853.tgz
npm install -g package

Install instructions are refreshed on each push.

… wire reorder

Engine (verif/symbolic.ts):
- switch with JS entry semantics + dead-clause pruning (enter folds
  false → clause body never executes; folds true → applied in-frame;
  symbolic → mergeBranch; per-clause breakCond consumed — break exits
  the switch, not the enclosing loop).
- mergeBranch normalizes provably-false thrown/breakCond/continueCond
  back to null: for-of loop guards did 'andFold(len>k, st.breakCond ??
  true)' — a const-false TERM is not nullish, so every iteration after
  any branch merge was silently dropped (minis t6/t7/t8).
- writeLValue: recursive lvalue store (identifier / property / element
  slot-write / non-null unwrap) replacing the single-level assignment
  path; compound assigns via applyBinop.
- alias-scan after property writes: 'const host = msgs.find(...);
  host.parts = [...]' must be visible through the containing array —
  JS reference semantics.
- ArrayBindingPattern positional destructure in bindForVar (for-of
  entries() pairs); array .entries() support.
- dead-branch pruning for if/ternary (const-folded conditions execute
  only the live arm — eager execution forced untranslatable code in
  never-taken branches to blow up translation).

tests/verif-bug3676-wire-reorder.test.ts (#3676): round-trip the REAL
openaiToCore + coreToOpenai on a symbolic wire [file, text] user
message; solver finds [text, file] rebuilt order (SAT), [text, file]
input stays stable (UNSAT negative control); replay on real code
asserts the flip. All 10 verif tests green.
@ranxianglei

Copy link
Copy Markdown
Owner Author

里程碑 3/4:求解器自己找到 #3676(openai wire 重建重排)。

  • 引擎:switch 按 JS 进入语义重写 + 死子句剪枝(折叠为假的子句体不再执行);mergeBranch 把可证为假的 break/continue/throw 归一化回 null(此前 for-of 循环守卫被常假 TERM 弄丢,任何分支合并后的迭代都被静默丢弃);writeLValue 递归左值存储 + 别名扫描( 的引用写回必须对容器可见)。
  • tests/verif-bug3676-wire-reorder.test.ts:真代码 openaiToCore + coreToOpenai 往返;符号 wire [file, text] 用户消息 → 求解器判 SAT(重建出 [text, file] 翻转);反例控制 [text, file] 输入 UNSAT(该方向本来就稳);真代码回放断言翻转确实发生。
  • 全部 10 个 verif 测试绿。

最后 #3805(durable 载体 ref 迁移丢标签)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

(更正上条被吞的一段:别名扫描解决的是——const host = msgs.find(...); host.parts = [...] 这种"从数组里找到的对象再改字段",必须对数组容器可见,否则重建时 file part 丢失。)

… literal

The new wire-reorder test pointed FILE at /home/dog/tmp/bili-verif — the
author's checkout. Every other environment (CI included) fails with EACCES
before any translation happens. Resolve it from import.meta.dirname like the
other verif tests do. 10/10 verif green after the change.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

M3 验证:拉下来本地跑,先 9/10,修了一处可移植性小 bug 后 10/10 全绿。

…te dead replay scaffolding

The new verif/ module shipped 17 exports nobody references outside their
own file. Per the gate's own remedy: the three DEAD helpers in replay.ts
(isReplayMismatch, witnessValue, describeMismatch) plus the ReplayMismatch
interface they form are deleted — no harness or test uses them yet, and
the SymVal import existed only for witnessValue. The 13 INTERNAL_ONLY
types/functions keep their declarations but lose the leading export;
callers use them structurally through the exported entry points. No
behavior change, no waivers added.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

CI 红已修:unused-exports 门禁在本 PR 新增的 verif/ 模块上抓到 17 个没人用的导出,已按门禁自带的两条出路处理并推回分支(35b355991,等新 head 的 CI)。

八问

  1. 是什么问题:本 PR 新增的 verif/ 模块有 17 个导出符号在仓库里没有任何外部引用,被 scripts/check-unused-exports.mjs(unused-exports job)拦下,PR CI 红。
  2. 什么原因导致的:MVP 写码时导出先行——13 个类型/函数只在声明文件内部使用(INTERNAL_ONLY);replay.ts 里的 3 个助手函数(isReplayMismatch、witnessValue、describeMismatch)连同它们构成的 ReplayMismatch 接口全仓零引用(DEAD),属于还没接线的脚手架。
  3. 影响范围与严重程度:纯新模块内部卫生问题,零运行时行为影响、无外部用户面,唯一后果是挡住本 PR 合并。
  4. 怎么修复的:按门禁自身给出的处置——DEAD 的直接删声明(4 个符号 + 只为 witnessValue 存在的 SymVal import);INTERNAL_ONLY 的去掉 export 保留声明(ExcludedFunction、SolveResult、ViolationCode/Violation/GuardResult/CheckInput、TranslationUnsupported/Str/InterpreterOptions/TranslateInput、Sort/bindMethods/Smt2Out)。调用方全部通过导出的入口函数结构化使用这些类型,不受可见性收窄影响。未加任何 waiver,不扩大门禁的口子。
  5. 是否有回归问题:无。删掉的符号经门禁自身的文本计数 + 独立 grep 双重确认全仓零引用;去 export 不改行为。级联风险查过:SymVal 去掉 replay.ts 的引用后仍被 tests/verif-bug3769-orphan-window.test.ts(inline import(...) 类型)引用,不会下一轮再红。本地重跑门禁:✓ clean(4 waived 均为既有豁免)。
  6. 是否破坏缓存:不涉及。
  7. 是否改了设计方向:没有。回放锁的 mismatch 机制(mismatch 类型 + 描述 + witness 提取)等反例管线真正产出 mismatch 时再作为有真实调用方的 API 加回;parseIntWitness/replayThrows 两个被测试实际使用的导出原样保留。
  8. 是否引入了新的配置:没有。

收工判定:小修已闭环,等新 head 的 unused-exports job 转绿即可;若还有其他 job 红了再说。

…B string literals; Real-sorted floor/ceil

- SMT string printing: quotes double (""), control chars \u{...} —
  JSON's \" escape is ILLEGAL in SMT-LIB 2.6 and cvc5 rejected the
  file ('Illegal string character').
- Math.floor/ceil/round/trunc return Real-sorted values (ToInt alone
  left Int/Real mixed ITE branches: 'Branches of the ITE must have
  comparable type').
- regexAnchor now walks concat nodes in BOTH shapes (facade app2 with
  kid0 = fn-name literal, or op 'str.++'/'concat' kids) and collects
  the const head even when symbolic pieces (escapeRegex of a symbolic
  ref) follow — before, the anchor was dropped and the ownTagRe strip
  degraded to any.
- tests/verif-bug3805-durable-ref-migration.test.ts (#3805, no-cheat
  per #3848): symbolic phase runs the REAL assignRefs + renderVisible
 Refs twice (turn A: protected durable carrier; turn B: newer carrier
  wins protection). Solver witness: d1 ∧ d2 → rendered bytes differ
  (SAT); durable classifier false on the append → UNSAT (the
  invariant — append-only history must keep sent bytes stable — is
  the judge). Replay on real code: byRaw.u1 flips BLOCKED → numeric
  and the already-sent message gains an <acp tag prefix mid-history.
- instrumentation removed (rep/esc/call/new traces); 12/12 verif
  tests green.
@ranxianglei

Copy link
Copy Markdown
Owner Author

里程碑 4/4:求解器自己找到 #3805(durable 载体保护解除时中段重贴标签)。四个目标 bug 全部达成。

  • 修了三个硬阻塞:①SMT 字符串字面量必须用 "" 转义引号(JSON 的 \" 在 SMT-LIB 2.6 里非法,cvc5 直接拒收);②Math.floor/ceil/round/trunc 返回 Int 型,和 Real 混出『ITE 分支类型不可比』;③regexAnchor 现在两种 concat DAG 形状都能走,符号片(escapeRegex(符号 ref))之后仍能取到常量头部锚点。
  • tests/verif-bug3805-durable-ref-migration.test.ts:真代码 assignRefs + renderVisibleRefs 跑两轮(A 轮 durable 载体受保护;B 轮更新的载体夺走保护)。求解器见证:d1∧d2 → 已发送字节变化(SAT);非 durable 追加 → UNSAT(判官是『只增不删的历史,已发送字节必须稳定』这条不变量,不是剧本形状)。真代码回放:byRaw.u1 从 BLOCKED 翻成数字 ref,已发送消息中段长出 <acp 标签前缀。
  • 含 owner 两笔修正(unused-export gate、H3 测试路径从测试文件解析)rebase 后:verif 全家 12/12 绿(3676 1/1 + 3691 2/2 + 3769 2/2 + 3805 2/2 + smoke 3/3 + guard 2/2),tsc 干净。

#3848 的验收线『四个已知 bug 求解器自己找出来,反例在真代码上回放』到此全部完成。后续可以讨论:把四个 harness 的不变量(I1/I2 家族)接进 #3842 的判官层。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到里程碑 4/4。CI 状态同步:新 head a1dd0006(H4 harness + SMT-LIB 字符串字面量 + Real-sorted floor/ceil)的 checks 正在跑(多数 queued、build-artifact in_progress)。之前红的 unused-exports 我已在新 head 上本地重跑门禁脚本确认仍然干净(✓ clean,4 waived 均为既有豁免),H4 提交没有引入新的未用导出。后续若有 job 转红会自动再触发我处理(本 PR 还剩 1 次自动修复机会);目前无需动作。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

这条是里程碑 2/4(#3769)评论的重复投递——已在上一轮回复里确认过(M2 本地复验 9/9 全绿,随后按路线进入 #3676)。

当前进度:#3676 已由你侧的 M3 交付(wire-reorder 测试在分支上),我正在做最后一步 #3805(durable 载体 ref 迁移丢标签) 的 H4 harness。引擎侧发现并正在修一个真实缺陷:map.byRef[text] 这类符号键对象查找旧实现会把「键未命中」折叠成幻影命中(iteVal 的 undef-collapse),直接翻转 if (!map[k]) 的控制流——#3805 的迁移门 prev === BLOCKED_REF && !protectedNow 恰好踩在这个语义上,不修它符号阶段就是错的。修法:未命中保留为带 nullUnder 标签的值(JS truthiness 尊重该标签),外加 delete 语句支持与循环内 return 的路径门控(tailGate)。修完会先跑全部既有 verif 测试确认无回归,再上 #3805 的 SAT/UNSAT + 真代码回放。

ework-agent added 2 commits October 20, 2026 17:14
… round 2

The generic append-only harness (arbitrary symbolic inputs over
assignRefs + renderVisibleRefs) exposed two soundness holes in the
symbolic-key record model:

1. one-arm merges used iteVal(cond, v, undef) — the undef-loses rule
   silently dropped the write's path guard, so a dead-path write
   (e.g. a skipped iteration's map.byRaw[id] = ref) entered the read
   fan unconditionally. With two equal string ids the dead write
   shadowed the live binding and the solver manufactured flips the
   real code cannot produce (real replay with duplicate ids is
   stable).

2. concrete-field one-arm merges had the same hole (fields.set(key, va)
   unguarded).

Fix: symFields entries are now {g: Bool, v} — the write guard
accumulates through branch merges (andFold) and the read fan tests
(key = idx) AND g, so a dead write falls through to older bindings
(last-write-wins only when the write actually executed). Concrete
one-arm fields merge into an in-domain neutral (/0/false or
nullUnder for containers). Symbolic-key delete now drops
structurally-matching symFields entries.

Also: solve.ts parseValues handles quoted SMT strings with spaces
(and  escapes) — multi-value get-value replies were silently
truncated to the first value.

12/12 suite green (3676/3691/3769/3805 + smoke + guard).
… re-tag

tests/verif-generic-append-stability.test.ts: 3 fully-symbolic messages
(free ids/roles/contentTypes/texts, free per-message protection bools)
over the REAL assignRefs + renderVisibleRefs, two turns, append-only
growth — the scenario harnesses' known shapes are NOT baked in.

Queries:
- Q1 SAT: violation reachable (the #3805 protection-drop lift re-emerges
  generically — the scenario harness was not needed to find it).
- Q2 SAT (NEW BUG, found by the solver under arbitrary inputs): m3 may
  reuse m1's raw id while being UNPROTECTED. The BLOCKED binding is
  per-id but protection is per-message (latest carrier wins), so the
  colliding message's refs.ts:99 delete + fresh alloc re-tags m1's
  already-sent bytes — with NO protection drop anywhere. Real-code
  replay: A renders m1 verbatim (BLOCKED), B renders it tagged
  '<acp ...>m00002</acp>' — mid-history cache seam.
- Q3 UNSAT: with pairwise-distinct ids AND no protection drop, no
  violation remains within bounds (bounded absence).

Engine fixes that made the model faithful enough for this:
- read-fan first layer keeps its key-match guard (iteVal into the
  in-domain neutral instead of {undef}; the undef-loses merge rule was
  handing out values for keys that never matched — phantom reads).
- port identity matching in the harness (obj SymVals carry no .t).
- solve.ts parseValues: quoted strings with spaces (multi-value
  get-value replies were truncated).

13/13 verif tests green.
@ranxianglei

Copy link
Copy Markdown
Owner Author

里程碑:通用输入 harness 上线,求解器在任意输入下自动发现了新 bug #3945(重复 id 改写已发送字节)。

…e literal

The new H4 harness hardcoded /home/dog/tmp/bili-verif/... for refs.ts and
render-refs.ts, so both subtests EACCES-fail on any other machine (CI
included). Resolve them from import.meta.url exactly like the generic
harness already does. Verif suite 13/13 green locally after the fix.
@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

收到里程碑。通用输入 harness 的方向对——不变量当判官、场景退居其次,#3945(id 碰撞改写已发送字节)正是这种形状才能逮到的东西。

我在本地把 verif/symbolic-core 拉到 06eef5e6a 验证了一遍,发现并修了一处:

H4 测试写死了机器路径:tests/verif-bug3805-durable-ref-migration.test.ts:54-55 的 REFS/RREFS 是 /home/dog/tmp/bili-verif/kernel/src/...,在非本机(包括 CI)上两个子测试直接 EACCES 挂掉——和上次 H3 修的是同一类问题(6d3f4db)。已按 generic harness 的既有写法改成从 import.meta.url 解析,单独 commit c48272e 推到分支了。

修后本地状态:tsc 干净,verif 全家 13/13 绿、0 skip(guard 2 + smoke 3 + 3691 2 + 3769 2 + 3676 1 + 3805 2 + generic 1)。

另外说明一下我这边的状态:我之前在本地起草的 H4 版本(具体场景 + 自研引擎扩展:动态键存储池、循环返回尾门等)被你的提交超车了,已全部丢弃未推——你们的路径守卫式符号键写入覆盖了同一片机制,现有测试集下我那些补丁没有独立价值。实验留档在会话工作区 .tmp/,如果后续靶子(#3676 之外的 Tier B 函数)踩到同类引擎缺口可以翻出来对照。

接下来分支上的事就剩 CI 确认 c48272e 这条腿,以及 #3945 本身的修复立项(那是它的自己的 lane,不在这个 PR 里做)。

…e count

tests/verif-induction-append-stability.test.ts replaces bounded-N scans
for the append-only property with an induction over the append step:

- The prefix is abstracted to its observable effect: one symbolic
  binding (id_p -> r_p) in an otherwise-free map state. No 1..n loop,
  no per-message unroll — the formula is independent of message count.
- Step (UNSAT, machine-checked): running the REAL translated
  assignRefs([m], M) cannot alter the observed binding when m's raw id
  is distinct — for ANY prefix state, reachable or not (weaker premise
  than a reachability characterization, so the conclusion only gets
  stronger; characterizing reachable states is the part we skip).
- Collision case (SAT, pinned): without the distinctness constraint the
  step breaks exactly at the id-collision shape — issue #3945 is this
  induction's honest failure case.
- Render side: renderVisibleRefs renders each message independently
  (messages.map(renderMessage)) and bytes are a pure function of
  (message fields, byRaw binding, token meter) — the binding is the
  only channel append can act through, and the step closes it.
- Randomized real-code anchor (60 runs): locality of assignRefs on the
  implementation itself.

Side condition, stated not hidden: raw-id collisions (#3945) and fold
events (different judge) remain outside this claim.

15/15 verif tests green.
@ranxianglei

Copy link
Copy Markdown
Owner Author

归纳判官上线:任意消息数的 append-only 稳定性,公式大小与消息数无关。

边界如实声明:raw id 撞车(#3945)和折叠事件(另一个判官)不在本命题内。15/15 绿。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

两件事一起回:

1. 别名扫描那段更正(上条被吞的补发):收到,和实现一致——writeLValue 的 PropertyAccess 分支在重建对象后扫 frame.vars,凡数组元素/对象字段按引用同一持有旧值的容器都换成新值(verif/symbolic.ts ~L1435)。host = msgs.find(...); host.parts = [...] 这类"从容器里取出再改字段"的路径就是靠它保持对容器可见的,否则重建时 part 丢失。现有套件(含 3676 往返对)覆盖了会暴露它的场景。

2. 归纳判官里程碑已本地验证:拉到 ebe5948b4,tsc 干净,verif 全家 15/15 绿、0 skip,和你报的一致——新增两条都过了:

  • ok 9 归纳步 UNSAT(id 不重复时任意前缀状态下观察绑定不可动);
  • ok 10 真代码随机抽查锚点(60 轮)。

"公式大小与消息数无关"这个性质是这套路线里最有价值的进展:之前每个 harness 都是 O(场景) 的,归纳把它变成 O(1) 命题 + 一次性机器检验。边界声明也清楚(raw id 撞车 = #3945 自己的 lane;折叠事件另立判官),没有越界声称全量证无。

本地无新发现需要修;分支上待办仍是 CI 确认这一串提交。#3945 的修复建议尽快立项(它现在是通用 harness 和归纳判官共同指认的真 bug,且改写的是已发送字节,严重度不低)。

ework-agent and others added 2 commits October 20, 2026 17:51
- verif/README.md was stale (MVP-era: numbers=Int, padStart=any, the four
  bugs listed as future work). Rewritten to current state: component
  table (terms.ts DAG facade, solve.ts out-of-process cvc5-first),
  per-test-layer table (guard/smoke/4 directed harnesses/generic
  arbitrary-input/induction judge), the five no-cheat rules, honest
  modeling list (Real numbers, registered degradations, anchored-regex
  approximation, bounded-N vs induction), found-bugs list (#3691 #3769
  #3676 #3805 #3935 #3945), extension how-to.
- AGENTS.md rule 14: touching guarded files requires the subset guard +
  relevant verif solver tests; new syntax needs translator support
  first; exceptions are audited inventory; new harnesses follow the
  README no-cheat rules; solver-found bugs go to issues with regression
  pins.
@ranxianglei
ranxianglei merged commit 303ec47 into master Oct 20, 2026
38 of 43 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.655-master.303ec47 (rolling master tag).

npm install -g billion-context@0.0.655-master.303ec47  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

zypNB123 added a commit to zypNB123/billion-context that referenced this pull request Oct 20, 2026
ranxianglei#3853 landed three solver-backed verif tests without the availability gate the
other verif suites carry, so on a runner with neither cvc5 nor z3 they fail
instead of skipping - `no solver available (set VERIF_SOLVER_CMD /
VERIF_PYTHON)`. That contradicts the module's own contract (AGENTS.md rule 14:
an environment without a solver must skip, never go red) and it is what turned
every `test` leg red on this head, on ubuntu and windows alike.

Adds the same probe-then-skip the sibling suites use (verif-bug3769,
verif-generic-append-stability, verif-symbolic-smoke) to bug3676, bug3691 and
the induction step. With a solver present nothing changes; without one the
three cases report skipped and the rest of the suite still runs.

Verified locally: the 8 verif files report 5 pass / 10 skipped / 0 fail with no
solver on PATH, and the probe returns null as expected.
zypNB123 added a commit to zypNB123/billion-context that referenced this pull request Oct 20, 2026
ranxianglei#3853 landed three solver-backed verif tests without the availability gate the
other verif suites carry, so on a runner with neither cvc5 nor z3 they fail
instead of skipping - `no solver available (set VERIF_SOLVER_CMD /
VERIF_PYTHON)`. That contradicts the module's own contract (AGENTS.md rule 14:
an environment without a solver must skip, never go red) and it is what turned
every `test` leg red on this head, on ubuntu and windows alike.

Adds the same probe-then-skip the sibling suites use (verif-bug3769,
verif-generic-append-stability, verif-symbolic-smoke) to bug3676, bug3691 and
the induction step. With a solver present nothing changes; without one the
three cases report skipped and the rest of the suite still runs.

Verified locally: the 8 verif files report 5 pass / 10 skipped / 0 fail with no
solver on PATH, and the probe returns null as expected.
Zhishulo pushed a commit to Zhishulo/billion-context that referenced this pull request Oct 20, 2026
ranxianglei#3853 landed three solver-backed verif tests without the availability gate the
other verif suites carry, so on a runner with neither cvc5 nor z3 they fail
instead of skipping - `no solver available (set VERIF_SOLVER_CMD /
VERIF_PYTHON)`. That contradicts the module's own contract (AGENTS.md rule 14:
an environment without a solver must skip, never go red) and it is what turned
every `test` leg red on this head, on ubuntu and windows alike.

Adds the same probe-then-skip the sibling suites use (verif-bug3769,
verif-generic-append-stability, verif-symbolic-smoke) to bug3676, bug3691 and
the induction step. With a solver present nothing changes; without one the
three cases report skipped and the rest of the suite still runs.

Verified locally: the 8 verif files report 5 pass / 10 skipped / 0 fail with no
solver on PATH, and the probe returns null as expected.
@ranxianglei

Copy link
Copy Markdown
Owner Author

阶段 1 落地:锁存纪律判官(#3989 ⑤的验证面)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

跟进:Q2 的假 SAT 不是"已知缺口"了——挖出来是两个真正的引擎可靠性 bug,已修,Q2 现在 UNSAT ✓。

  1. 符号键读扇出丢 nullUnder: 键未命中时,条目值与 null 中性值用 iteVal 合并 → nullUnder 标签丢失 → 假真值 + 字段幻读( miss 也交出 latch 条目)。修:fanLayer 改 iteStrict + member() 对 nullUnder 对象的字段读取全部加 ¬nullUnder 门。
  2. 数组单臂槽位幻影臂:mergeVal 数组合并时,只有一臂有的槽位走 undef-loses 折叠 → 分支值无条件可达(求解器可以在分支未执行时取它)。修:单臂槽位改 guardedNeutral(分支守卫写进值里)。

顺带钉了一个域事实:不同 raw id 在真实 byRaw 状态里持有不同数字 ref(等 ref 见证是正确的锁存语义,不是 bug),域约束 r1≠r2 已注释。

verif 全家 17/17 绿(含新断言的 Q2)。README 的"已知缺口"改成了修复记录。继续阶段 2(wire 适配器 round-trip 挖掘)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

更正上一条被 shell 吞掉的两处代码:o?.k与 prev?.[ref](view-latch 里的实际调用点)。其余内容不变。

@ranxianglei

Copy link
Copy Markdown
Owner Author

阶段 2 起步:anthropic wire 编解码器上了往返顺序判官,顺带又修了 4 个真引擎 bug。

  • 闭包写回顺序 bug(最隐蔽):写回循环先写 target0(env 自身),后续 target 的跳过判断读到了刚被更新的 map,把调用方帧跳过了——调用方的过期副本在下一轮合并里反过来赢,闭包的 push 丢失。修法:任何 target 写入前先取调用前快照值。
  • switch 分支基座:各 case 从共同的前置基座拷贝出发,不再从累积帧拷贝——否则后面的 case 看见前面 case 的 push,迭代合并把两个 case 的对象融成字段并集幽灵;空 case 标签是分组不是 fallthrough。
  • 回调参数绑定 + Object.keys/entries/values + 已知字符串 slice 折叠恢复/补齐(参数不绑定则箭头回调里所有参数标识符 unbound;slice 不折叠则 JSON.parse(raw.slice(raw.indexOf(brace))) 失去常量性)。

新判官 tests/verif-wire-anthropic-roundtrip.test.ts:真代码 parse+rebuild,同角色块对的首/次块必须保持类型+载荷(UNSAT 断言);thinking 在同角色组后保持独立消息(跨消息顺序,UNSAT);真代码回放基线。anthropic 侧暂未发现 openai 式的 [file,text] 翻转——它的 parse 保序、rebuild 按核心序发射,结构上对称。

全家 20/20 绿(4 个定向 + generic + induction + view-latch + anthropic 3 + smoke 3 + guard 2)。

@ranxianglei

Copy link
Copy Markdown
Owner Author

里程碑:google wire 适配器判官上线,顺手修了一个『静默吞返回值』引擎 bug。

引擎 bug(break 标志泄漏):for 循环里 break 后,循环把 breakCond=true 留在状态上直接返回——execSeq 由此认为循环后的语句『不可达』,函数最后的 return 在所有路径上都没执行过:结果 ret null 且 degradations 为空(零线索)。break 只终止自己的循环;三种循环(for/while/for-of)现在在硬退出路径清掉标志。google normalize 的探针(findIndex + for-let + break)暴露的。

google 判官(tests/verif-wire-google-rebuild-stability.test.ts),重建方向、无哈希无正则:

全家 23/23 绿。

@ranxianglei

Copy link
Copy Markdown
Owner Author

冲突判官落地(第 6 个模块,27/27 绿):

引擎顺带修了三件事:具名函数当回调(filter(isSuspectedEvent) 之前直接降级)、SMT 字符串非 ASCII 转义(cvc5 拒收引号外的 em-dash)、String(number) 空洞限定纯数字(否则未解释的计数字符串可以建模成包含任意子串,把 contains() 判官骗红)。

接下来按顺序做 snapshot-render。

@ranxianglei

Copy link
Copy Markdown
Owner Author

snapshot-render 判官落地 + 引擎两处健全性修复 + 新 bug #4052(b9e7b7c)

新发现(真 bug,已建 issue):#4052 — 快照渲染里,客户端最新消息如果(角色+类型+文本)恰好和一条已被摘要覆盖的旧行相同,这条新消息会从视图里整条消失:sig 兜底(role|contentType|text,不含 id)把新消息绑到 covered 行上,anchor 替换该行,tail 循环又从 clientJoin 之后才开始。判官 C1 查询给出反例,真代码回放确认(view = [("", ""), ("acp_summary_b1","")],新消息的 "D" 没了)。与 #3812 同族但后果更重:模型看不见用户刚说的话。判据已钉住:C1b 在修复前 SAT、修复后应翻 UNSAT。

引擎修复 1:symFields both-arm 合并丢写守卫。两边都有的表项(早先迭代创建、守卫相同)被合并成 g:=true 且 else 臂退化成中性值——写入前的旧绑定直接丢失。refs.ts 三消息形状复现(两条正确、三条出错):y 的带守卫写入在 z 迭代合并时守卫被清。修法:合并级条件只进 value(ite(cond,va,vb)),.g 保留 (cond∧ga)∨(¬cond∧gb);读 fan 测 key∧g,g 已含 cond,无双重计数。治好 generic-append Q2 的过准入(#3945 家族),#3805 保持绿。

引擎修复 2:符号 break 后的迭代照跑。for-of 把累计 breakCond 原样并入下一迭代守卫(guard = len>k ∧ breakCond)——方向反了:迭代 k+1 应在"没 break 过"时才跑;for/while 同样漏。snapshot-render 链路复现:bySig 候选挑选循环(首个 idx<cursor 即 break)在第一条命中后 break,引擎却继续跑第二条并覆盖 hit——joinRow 偏一、clientJoin 过准入。修法:三类循环的后续迭代都以 ¬break-so-far 门控。

判官结构:回放半区(maybeSnapshotView 真跑:成功形态 / #3812 lone-dup seam-too-short / GHOST block-unanchored)+ 符号半区(buildView 零降级翻译,JSON 模板行解析保持符号)。C1 无碰撞尾内容保留 UNSAT、C2 anchor 在位 UNSAT。

套件 29/29 全绿(guard 2 / smoke 3 / 3691 2 / 3769 2 / 3676 2 / 3805 2 / generic 1 / induction 2 / view-latch 2 / conflict-watch 4 / anthropic 3 / google 3 / snapshot-render 2)。累计 4 个定向复现 + generic/induction 任意输入扫描 + 6 个新判官;verif 引擎 bug 本轮修 2 个,均以 <30 行最小复现钉死。

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant