Skip to content

[PR] verif judges batch 2: view-latch / anthropic / google / conflict-watch / snapshot-render + engine soundness fixes — finds #4052 | verif 判官第二批 + 引擎健全性修复 - #4071

Merged
ranxianglei merged 8 commits into
masterfrom
verif/extend-modules
Oct 21, 2026
Merged

ranxianglei merged 8 commits into
masterfrom
verif/extend-modules

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

续 #3853(已合并的 MVP)。这条分支(verif/extend-modules)是后续扩展批次,共 6 个提交,之前只有里程碑评论贴在 #3853 下、没带动代码 —— 本 PR 把它们正式提出来。与当前 master 合并无冲突(已验 merge-tree clean)。

内容

6 个新判官(harness),全部走真代码翻译 + 反例回放锁(README 五条反作弊规则):

判官 防什么 结果
view-latch discipline (#3989) 静默轮渲染可见引用纪律 UNSAT(证无)
wire anthropic round-trip 同角色消息对顺序+载荷保持 UNSAT ×4
wire google rebuild-stability 交替追加字节稳定 / 同侧 tool-result 合并 UNSAT
conflict-watch J1/J2 (#2709/#3806) dsh 原生压缩见证见证纪律 + 横幅分级 边界 749/750 钉死
snapshot-render(回放半区) #3812 lone-dup / GHOST 形态 真代码回放绿
snapshot-render(符号半区) 尾内容保留 / anchor 在位 C1a UNSAT;C1b SAT = 真 bug #4052

新真 bug:#4052(判官自己挖出,已建 issue + 回放确认) —— 客户端最新消息与一条已被摘要覆盖的旧行(角色+类型+文本)相同时,sig 兜底把新消息绑到 covered 行,anchor 吞掉内容,模型视图丢失用户刚说的话。C1b 是回归钉:修复前 SAT、修复后翻 UNSAT(可用来验收 #4057)。

引擎健全性修复(每条都有 <30 行最小复现,修错会让判官双向说谎——既漏报真 bug 也虚报):

  • 闭包写回:调用前捕获 env + 跳过未触碰键(否则旧快照清掉调用方新绑定)
  • switch:块体展平、空 case 标签不落穿、break 只退 switch
  • 幽灵迭代剪枝(maxConcreteLeaf)、jsAnd/jsOr 短路真值、optional-call 接收者守卫
  • return undefined 是真值不是未写槽(undefUnder 标签;=== 不能把它折成 const)
  • Map/Set 数组别名(writeArrayAlias:m.get(k).push(v) 要穿过 map 可见)
  • mergeBranch 三路合并 / execSeq rest-on-copy / 循环 break 清位
  • symFields both-arm 合并丢写守卫(g:=true + else 臂退化;3 消息形状必现)
  • 符号 break 后迭代照跑(for-of 守卫方向反了;for/while 同漏)

测试

VERIF_PYTHON=… node --import tsx --test tests/verif-*.test.ts → 29/29 全绿(guard 2 / smoke 3 / 4 个定向 ×2 / generic / induction ×2 / view-latch ×2 / conflict-watch ×4 / anthropic ×3 / google ×3 / snapshot-render ×2)。tsc 干净(pi-subagents/mysql 噪声为既有)。无求解器环境自动跳过,不阻塞 CI。

按仓库规则由人审人并,bot 只提交。

ework-agent added 7 commits October 20, 2026 23:06
Symbolic: applyViewLatch through the real translator with fully-free
texts/ids/refs/latch bytes; Q1 UNSAT — on a quiet turn the latched bytes
replay verbatim for ANY input values (empty-id, CCR-placeholder and
BLOCKED-ref domains pinned as documented unlatchable classes). Prefix
guard witnesses surfaced a real engine bug: Term.prefixOf/suffixOf
emitted SMT-LIB arguments swapped ((str.prefixof s t) means s is a
prefix of t) — fixed to JS receiver.startsWith semantics.

Q2 (fresh pass-through) kept as diagnostic only: nested loop+branch
array-slot merges still admit ghost arms (false SAT); the concrete
matrix pins the property on real code — quiet replay / arrival latch /
fold reset / steady-state no-churn. Gap documented in README.

17/17 verif tests green.
Two real soundness defects, both found by the view-latch pass-through
property refusing to go UNSAT:

1. Symbolic-key read fan first layer used iteVal: merging an obj/arr
   entry with its null neutral LOST the nullUnder tag, so prev?.[ref]
   with a key MISS still handed out the entry (truthy + phantom field
   reads). fanLayer now uses iteStrict; member() gates every field read
   of a nullUnder object by ¬nullUnder.

2. mergeVal array one-arm slots collapsed via undef-loses: a branch's
   pushed value became unconditionally reachable (ghost arm). One-arm
   slots now use guardedNeutral(cond, v) — the value carries its branch
   guard inside.

Domain note: distinct raw ids hold distinct numeric refs in real byRaw
states — pinned r1≠r2 (same-ref-different-id is unreachable; the
equal-ref witness was CORRECT latch semantics, not a bug).

Q2 (fresh messages pass their own transform output through) is now
asserted and UNSAT; README known-gap section replaced with the fix
record. 17/17 green.
…te-back fixes

Engine (verif/symbolic.ts):
- invokeCallback write-back must read the PRE-CALL env value before any
  target write: when target0 IS env.vars, its own set(k, v) made later
  targets' skip check see the updated map and skip the caller frame —
  the caller's stale copy then won the next iteration merge and the
  closure's push was lost (flush() pattern: out.len 1 instead of 2).
- switch clauses start from a COMMON pre-switch base frame (copying the
  accumulated frame let later arms see earlier arms' pushes — iteration
  merges fused two arms' objects into field-union ghosts); empty case
  labels are grouping, not fallthrough (openai.ts system/developer).
- callback and inline-call PARAMETER BINDING restored (arrows now bind
  Identifier params + ArrayBindingPattern elements, later defaults may
  read earlier params).
- Object.keys/entries/values over concrete fields + symbolic-key
  bindings (fan read); string slice folds known-string/const-start
  slices (keeps JSON.parse(raw.slice(raw.indexOf('{'))) concrete).
- member() on null/undefined reads as undef; typeof/Array.isArray
  const answers on non-num/undef.

Harness tests/verif-wire-anthropic-roundtrip.test.ts (#3848 phase 2):
parse+rebuild over the real anthropic codec with symbolic block types
and payloads. Same-role pairs: first/second rebuilt block must carry
block 1/2's type+payload (UNSAT-asserted); thinking keeps its own
message after a same-role group (cross-message order, UNSAT-asserted);
real-code replay baseline pins both directions.

Suite 20/20.
Engine bug (ret null with zero degradations): a break/continue inside a
loop left breakCond set on the RunState when the loop handler returned —
the flag was never consumed. execSeq then treated post-loop statements
as unreachable (stopCond === "true" skips the rest-on-copy path), so the
function's final return never executed in any state. A break terminates
only its own loop: all three loop kinds (for/while/for-of) now clear
breakCond/continueCond on the hard-exit path. Found by the google
normalize probe (findIndex + for-let + break silently swallowed the
function's return value).

tests/verif-wire-google-rebuild-stability.test.ts (#3938/#3939⑥ wire
byte-stability on the google adapter, rebuild direction):
- alternating append (user text → assistant text): earlier contents
  byte-identical, UNSAT for any violation;
- same-side tool-result append: merged content keeps the text part
  byte-identical (normalizeGoogleUserPartOrder movable-text contract),
  UNSAT;
- real-code replay baseline.

Suite: 23/23.
…g) + engine fixes

Engine fixes found by the judge work:
- named module-level function references as array-method callbacks
  (filter(isSuspectedEvent) degraded before; cbNode resolver + widened
  guards for filter/find/findIndex/some/every/forEach/map)
- SMT-LIB string literals: escape ALL non-printable-ASCII as unicode;
  cvc5 rejects printable Unicode bytes ('Non-printable character') —
  advice strings carry em-dashes/middle dots
- String(number) holes are now constrained digit-only via str.in_re
  (str.+ (re.range "0" "9")) asserted in smt2Of AFTER declare-funs —
  uninterpreted count strings could otherwise model as containing any
  substring and fake contains() violations on every count-bearing line
- module-level truthy(): inline and-fold (no andFold in module scope);
  typeof base as plain ternary

J1 (dshNativeCompactionWitness): shrinking-history discipline — firing
without shrinkage (inc >= 0.75*known) is UNSAT for arbitrary PA/REF/INC/
KN; landing shapes (#2709 320/771, 427/875) SAT; gates UNSAT; missing
fingerprint (fold-reconcile site) SAT. Replay: all calibration shapes +
749/750 boundary + #3806 restart shapes.

J2 (formatConflictSection): the one-compressor command requires
confirmed ACTIVE foreign evidence — no-foreign UNSAT, all-stale UNSAT
over arbitrary kinds (6-value ConflictKind domain) and ages; non-vacuity
SAT. Replay: #3806 unannounced-only → 'not confirmed', #2709 inferred →
'do not go hunting', fresh foreign → command, stale → none, neutral
sibling → stand-down. 27/27 verif tests green.
…ss fixes

Engine fixes (both found by judges turning red, both minimized to <30-line
repros, both would over-admit violations AND lose real writes):

1. symFields both-arm merge erased write guards. An entry present on both
   arms of a merge with the SAME write guard (created in an earlier loop
   iteration, copied unchanged) got g:=const-true and its else-arm degraded
   to a neutral value — the pre-write binding vanished. refs.ts 3-message
   shape reproduced it (2 messages correct, 3 broken): y's guarded write
   survived y's iteration merge but z's iteration saw the entry on both
   sides and clobbered the guard. Fix: the merge-level condition goes into
   the VALUE only (ite(cond, va, vb)); .g keeps the disjunction
   (cond∧ga)∨(¬cond∧gb). No double-count: the read fan tests key∧g and g
   already carries cond. Cured the generic-append Q2 over-admission
   (#3945 family) while keeping #3805 green.

2. Loop iterations after a symbolic break kept running. for-of conjoined
   the accumulated breakCond ITSELF into the next iteration's guard
   (guard = len>k ∧ breakCond) — inverted: iteration k+1 runs only when NO
   break happened. for/while had the same hole (unconditional merge under
   the bare loop condition). snapshot-render chain repro: the bySig
   candidate pick loop (`first idx < cursor`, break on hit) returned the
   SECOND candidate after breaking on the first — joinRow off by one,
   clientJoin over-admitted, the judge saw tails vanish. Fix: all three
   loop kinds gate subsequent iterations by ¬break-so-far.

Judge (tests/verif-snapshot-render.test.ts):
- replay half: maybeSnapshotView on real JS (success shape / #3812
  lone-dup seam-too-short / GHOST block-unanchored).
- symbolic half: buildView translated from src/server/snapshot-render.ts
  with JSON-template row parsing kept symbolic (zero degradations).
  C1 (collision-free tail content preserved) UNSAT; C2 anchor presence
  UNSAT.
- C1b pins bug #4052: tail message whose (role|ct|text) equals a COVERED
  row's sig-binds to that row and the anchor swallows the content —
  replayed on real code (view loses the newest user message). SAT today,
  must flip to UNSAT when fixed.

Suite: 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, replay 1 counted within).
@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: verif/extend-modules (241688b)

Option A — Install this exact build (recommended)

npm install -g billion-context@0.0.4852-pr.4071.fa98799

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

Install instructions are refreshed on each push.

@ranxianglei
ranxianglei merged commit 022395d into master Oct 21, 2026
9 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.697-master.022395d (rolling master tag).

npm install -g billion-context@0.0.697-master.022395d  # 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