Skip to content

test: harden theorem lane -- claim-coupling mutation twin + raw-id grounding (#3198) - #3263

Merged
ranxianglei merged 1 commit into
masterfrom
2026-10-15_proof-g4-claimcoupling
Oct 15, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
2026-10-15_proof-g4-claimcoupling

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

References #3198 — proof hardening approved by @ranxianglei («证明补齐需要的,需要确保标签进出全域定理都永远是true»). Pure test/spec change to the existing #2149 route-4 machine-checked theorem lane; zero behavior surface.

What

Two additions closing the two gaps found by the independent SMT campaign in #3198:

  1. proof/spec/t2-claimcoupling.smt2 (new obligation, expected SAT): if live-message ref presentation were gated on reconcile CLAIM state instead of the persistent content-keyed map (assignRefs: an existing byRaw entry always wins), a byte-identical live message could present under DIFFERENT refs across consecutive turns, breaking T1's shared-subterm congruence for its tag bytes even though mid-history bytes never changed. The solver must exhibit the defect (witness shape: turn A takes the map-lookup path → stored number 5; turn B the fresh-allocation path → ≥ cursor 6). Shipped code has no such coupling — this twin proves the theorem WOULD break if it were ever introduced (the lane's own falsifiability discipline: a proof not falsifiable by its known-bad mutations is treated as broken).
  2. [grounding:g4] in tests/cache-theorem.test.ts: pins the previously-unpinned first link of T2's antecedent chain — deriveMessageId determinism + each identity dimension (role/contentType/toolCallId/toolName/text) participating in the hash, and ClusterCounter numbering being pass-stable AND prefix-extension-invariant (later duplicates continue the prefix's count; earlier ids never renumber). Before: g1 pinned the allocator GIVEN ids, t2-host pinned cursor monotonicity — nothing pinned id derivation FROM content.

After this PR, every link of the antecedent chain (content→raw-id stable ∧ raw-id→ref persistent-map-keyed ∧ allocation monotone) carries both grounding AND mutation coverage.

Verification

  • Local: tests/cache-theorem.test.ts 15/15 green (was 13; +1 solver obligation, +1 grounding group) with z3 5.3.0; CI lane pins z3-solver==4.9.1.0 (README documents identical verdicts across builds).
  • npm run typecheck clean.
  • Diff: exactly 3 files — proof/spec/t2-claimcoupling.smt2 (new), tests/cache-theorem.test.ts, proof/README.md (T2 bullet + grounding table row + obligation counts).

No config surface change; no version touch.

@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: 2026-10-15_proof-g4-claimcoupling (0e3f23a)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.3763-pr.3263.4558b84

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-pr3263.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

查重:不重复。 open+closed 全检索(issue+PR,按 theorem / proof / cache-stability / claim-coupling / grounding 多组关键词):机器证明线谱系为 #2149(形式化提案,已关)→ #2159(已合并,Z3 route-4 落地)→ 本 PR;本 PR 补的两个缺口来源是 #3198 内的独立 SMT campaign。没有其他在途 PR/issue 触碰 proof/ 或 tests/cache-theorem.test.ts —— 本 PR 是证明线唯一在途条目。

初审状态:分支基于当前 master(单 commit 0e3f23a88),diff 恰为声明的 3 个文件(proof/spec/t2-claimcoupling.smt2 新增 43 行、tests/cache-theorem.test.ts、proof/README.md,合计 +109/−6);无 src/kernel 源码改动、无配置面、无版本触碰。CI:static-gates 全绿(ubuntu/windows × node 22/24)、e2e hermetic lanes 全绿(kernel-guard/version-guard/config-surface-guard/docs-sync 等)、12 个 test shard 与 Theorem Lane(pinned z3-solver==4.9.1.0)仍在跑。

静态审查已完成大半(spec 命名冲突、grounding 符号与真实代码的对应、既有义务回归清点均过),等 CI 定理 lane 与 test shards 出结果后给结构化八问结论。

@ranxianglei

Copy link
Copy Markdown
Owner Author

🤖 Powered by ework · qwen3.8-27b

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

PR #3263 审核结论(独立审读:全量 diff、SMT 命名空间碰撞检查、g4 断言逐条对照真实 kernel 代码、本地定向测试、CI 全量)。查重:不重复(见前一条回复;谱系 #2149→#2159→本 PR,无其他在途条目触碰 proof/ 或 cache-theorem.test.ts)。

八问:

  1. 是什么问题:标签缓存定理的机器检查证明车道(形式化求解器证明缓存字节稳定性:x-at-interface 建模,TS→C/C++/Rust 编译 / WASM / 汇编路线 #2149/feat: machine-checked cache-stability theorems via Z3 (route 4, #2149) #2159 建立的 T1/T2)有两处完整性缺口——T2 前提链的第一环「内容→raw-id」此前没有任何覆盖(g1 只钉住「给定 id 时的 ref 分配」,t2-host 只钉住游标单调性);且定理缺一个「已知坏变异孪生」来证明:若把存活消息的 ref 呈现与 reconcile 的 claim 状态耦合(而非走持久的内容键 map),定理就会破——而该车道自己的纪律要求「不能被已知坏变异证伪的证明视为坏证明」。
  2. 什么原因导致的:不是代码缺陷,是 feat: machine-checked cache-stability theorems via Z3 (route 4, #2149) #2159 建车道时的覆盖留白:9 个 solver obligation + g1/g2/g3 落地时,content→raw-id 这一环没进 grounding,claim 耦合这类缺陷没有对应的 mutation twin。本 PR 按 A/B experiment: ACP_RENDER_NONE=1 (renderTags=none) eliminates dsh render seams — hit rate 85.6% -> 91.2% #3198 里独立 SMT campaign 找到的两个缺口精确补齐。
  3. 影响范围与严重程度:对用户零影响(零 src/、零 kernel/ 改动,纯 test/spec);影响面仅限证明车道自身。严重度属证明卫生:不补的话,未来这两环上的回归可能悄悄穿过机器检查门禁而不被任何 obligation 抓住。
  4. 怎么修复的:两个相互独立的加法。① 新 proof/spec/t2-claimcoupling.smt2:声明假设耦合规则(claim=false→map 查表得存储号 5;claim=true→从游标 ≥6 新分配),再断言缺陷子句(rA=5 ∧ rB≥6 ∧ rA≠rB),期望 SAT——求解器必须给出反例,即证明该耦合一旦引入定理必破;见证形状(rA=5、rB≥6)由缺陷子句逻辑强制,CI 绿即确认。② [grounding:g4]:直接跑真实 kernel 代码(kernel/src/wire/message-id.ts 的 deriveMessageId/ClusterCounter)——确定性、五个身份维度(role/contentType/toolCallId/toolName/text)各自参与哈希、簇编号 pass 稳定且前缀扩展不变(后到的重复延续前缀计数,早先 id 永不重排)。
  5. 是否有回归问题:无。逐项审过的既有行为:原 9 个 CHECKS 条目逐字节未动;g1–g3 未动;solver harness(runCheck/detectSolver/PY_SHIM/trailer 逻辑)未动;proof/spec 其余文件未动;README 改动纯文档且与代码一致(obligation 数 Nine→Ten、「two T2 mutations」、「four grounding groups」均与实际代码吻合)。config-surface-guard / version-guard / kernel-guard / docs-sync / lane-guard 全绿。
  6. 是否破坏缓存:不涉及(纯 test/spec,无任何运行时路径变更)。
  7. 是否改了设计方向:没有。完全沿用车道既有模式:mutation twin 与既有 fix: archive blocks across omp native compaction instead of silently deactivating them (#395) #421 残差 twin(t2-mutation.smt2)同构(共享 preamble+t2 底座、verdict-only 检查);g4 沿用 g1–g3 导入真实 kernel TS 源码的风格。两点已接受的观察(非阻塞,不建议在本 PR 处理):witness 断言是弱断言(models.length>0,取值打日志不断言)——这是车道的既定纪律(跨 solver 版本 model 序列化脆弱性,注释里有记录),与既有 twin 牙齿相同;H0/H1 字节恒等前缀在 solver 内是装饰性公理——这是车道信任边界的设计(字节→raw-id 这一环在 solver 外由 g4 钉住),自洽。
  8. 是否引入了新的配置:没有。无新 env/config/默认值。

验证记录:

  • 静态:3 文件 +109/−6 全部通读;preamble+t2+t2-claimcoupling 合并上下文无声明名碰撞、无量词,SAT 可平凡构造(CI 绿确认求解器确实答 SAT);g4 每条断言对照 message-id.ts 语义核对(seed 串 role|contentType|toolCallId|toolName|text、sha256 hex slice(0,16)、ClusterCounter 首次裸号/N 次重复 _N 后缀)。
  • 本地定向(head 上跑):node --import tsx --test tests/cache-theorem.test.ts → 5 pass / 1 skip / 0 fail(skip 为 solver 子测试,本机无 z3,按设计跳过;g1–g4 全绿)。
  • CI(权威判定):head 0e3f23a88 上 40/40 check-run 全绿——含钉死 z3-solver==4.9.1.0 的 theorem 车道(「Run theorem lane」步 success ⇒ 10 个 obligation 全部返回预期判决、grounding 组全过)+ 12 个 test shard(ubuntu/windows × node 22/24)+ static-gates + e2e hermetic lanes。

结论:可合入。 CI 全绿、零回归、两个缺口都按车道自身的可证伪纪律闭合。等人合。

@ranxianglei
ranxianglei merged commit 62b86e5 into master Oct 15, 2026
40 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.456-master.62b86e5 (rolling master tag).

npm install -g billion-context@0.0.456-master.62b86e5  # 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.

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.

1 participant