You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--verdict: safe.ts's group_of picks a group by a def's first later-filled name, not by membership — a dead forward reference to a law crashes -o/--verdict, emits a non-member selector, or (with a name_tt collision) PASSes a book computing a different value #1212
bend fb3.bend; bend fb3.bend --verdict; then kernel oracles on bend fb3.bend -o fb3.bendtt (and --verdict on g4.bend, g2.bend)
What happened
fb3.bend (with a-b.bend beside it):
$ bend fb3.bend --check-only ALL PROOFS CHECK
$ bend fb3.bend False{}
$ bend fb3.bend -o fb3.bendtt exit 0, no out-of-scope lines
$ bend fb3.bend --verdict ALL PROOFS CHECK
Kernel oracles appended to fb3.bendtt:
ora : {main == (.True, ()) : Bool} = {==} -> ALL PROOFS CHECK
ora : {main == (.False, ()) : Bool} = {==} -> In ora: expected: main / observed: (.False, ())
g4.bend:
$ bend g4.bend --check-only ALL PROOFS CHECK
$ bend g4.bend --verdict TypeError: null is not an object (evaluating 'g.k') (exit 1, no FAIL header)
$ bend g4.bend -o g4.bendtt the same TypeError; no file written
g2.bend:
$ bend g2.bend --verdict SOME PROOFS FAIL (MISMATCH)
-o emits use : ∀x0 : Nat -> Nat = λx0 => {(L.group x0 (.d, (.L, ()))) : Nat}
kernel: In use: a label of <L, h>
How a group forms.later(k)
(safe.ts#L942-L945)
lists the defs k's body names that are filled after k. It reads refs (L1074-1089), which walks every
field except s, v and T, so a reference in an erased argument counts. group_of(k) (L947-953) is group_new(later(k)[0] ?? k): the group led by k's first later-filled name, whether or not k is in it.
A live forward call to an unfilled law is rejected by bend2, but a dead one (keep(L(n), n) with keep(-p: Nat, x: Nat)) is not.
Three faces from that.
Crash (g4). A call to the member h queues the item '\t' + L; item_emit (L272-274) rebuilds
the group with group_of(e, L) — a different computation — and L's own dead reference to L2 gives group_new(L2), which is null because nothing names L2 back. group_emit dereferences g.k
(L1014). A TypeError isn't a Scope_Error, so it escapes to main.ts as a raw trace.
Non-member selector (g2).args (L918-921) routes a call through group_call whenever group_of(k) is non-null, without checking membership. d has a dead reference to L, so its call
goes out as L.group with selector .d, which isn't in the enum <L, h>.
Wrong program, PASS (fb3). Same misroute, but the non-member's name a_2d_b.M collides under name_tt with the module's member a-b.M (BendTT name escaping merges distinct constructor labels across module paths #1131), so the label lands inside the enum <a_2d_b.L, a_2d_b.M> and the kernel accepts. main is wired to the module's M (True); the local
def the source names is emitted as a_2d_b.M_ and nothing references it.
Not a proof of Empty: bend2 checks the source at the source's types and the misroute only rewrites
safe.ts's copy, so whichever side reads a type as Empty rejects. But a --verdict PASS here no longer
attests to the source book.
item_emit (L274): rebuild the group from its lead, group_emit(e, group_new(e, k.slice(1)) as Group, cols, n).
args (L919): if (g !== null && g.ms.includes(k as Name)). With both, g2 and g4 PASS and use
becomes λx0 => (d x0).
Alternatively, have refs/later count only live positions, so a dead reference never forms a group
(not tested).
Separately, C3 on #1131 (labels aren't made unique the way def names are) is what turns the misroute
into a silent PASS.
Reproduced the face-3 (value divergence) on HEAD 01875127 (2026-09-29), with a kernel-oracle pin-down. Using your fb3.bend + a-b.bend layout verbatim from the issue.
This machine (Linux, bun 1.4.2, Lean v4.34.0):
$ bend fb3.bend --check-only ALL PROOFS CHECK
$ bend fb3.bend --verdict ALL PROOFS CHECK
$ bend fb3.bend False{} # source reading
Then appending oracle defs to the emitted fb3.bendtt and running the standalone kernel binary directly:
ora : {main == (.True, ()) : Bool} = {==} -> ALL PROOFS CHECK
ora : {main == (.False, ()) : Bool} = {==} -> In ora: / expected: main / observed: (.False, ())
So the verified book (double-green under --verdict) computes True{}, while the .bend source computes False{} — the a_2d_b.M override in main.bend is silently displaced by the library M through the group-merge (group_of picking the group led by the dead forward reference L), exactly as diagnosed.
Two notes on exploitability, in case they help scope the fix:
I could not turn the drift into a false claim through either gate: a claim matching the book ({main() == True{}}) is rejected by bend2's checker (expected : False{} / observed : True{} — bend2 checks the source reading), and a claim matching the source ({main() == False{}}) passes bend2 but the verdict self-confesses the TypeScript/kernel mismatch instead of validating. So today the leak is "a wrong book gets certified", not "a false proposition goes double-green" — the Claim.consistent side of the formalization keeps catching it.
The crash face reproduces too, on the same HEAD: g4.bend verbatim gives --check-only green (ALL PROOFS CHECK) and --verdict the raw TypeError: null is not object (evaluating 'g.k') with no FAIL header — exit path identical to the report.
Appreciate the double check! Agreed, the kernel-oracle is the right way to nail face 3.
Both directions of your note (1) reproduce on 2.0.32 as well.
From my findings it isn't Claim.consistent that catches it. That claim is ¬ Conv bk d.T (Enu []) (bendtt.lean:1529 on 2.0.32, :1532 on HEAD) — no def of a checked book has type<> which never runs on this.
What catches the false claim is the dual-gate structure: bend2 checks the source at the source's reading, safe.ts emits a rewritten book, the kernel checks that book, and the two disagree, so --verdict reports MISMATCH instead of PASS.
The two independent readings fail to agree. Which is also why face 3 gets through in the first place: when the drift is in a value
rather than a type, nothing forces the two readings to be compared at all.
Related: Claim.consistent is narrower than its name suggests. It names Enu [], but safe.ts emits a user Empty as Σx0 : <> -> (Empty.arms x0), which the statement doesn't reach. It was filed separately as #1183.
Activity
test(bend): qualify verifier releases against upstream regression
ci(bend): add cross-version upstream verifier qualification
ci(bend): run upstream verifier qualification in parallel
fix(safe): keep non-members out of mutual groups
quimmedes commentedon Sep 30, 2026
Reproduced the face-3 (value divergence) on HEAD
01875127(2026-09-29), with a kernel-oracle pin-down. Using yourfb3.bend+a-b.bendlayout verbatim from the issue.This machine (Linux, bun 1.4.2, Lean v4.34.0):
Then appending oracle defs to the emitted
fb3.bendttand running the standalone kernel binary directly:So the verified book (double-green under
--verdict) computesTrue{}, while the.bendsource computesFalse{}— thea_2d_b.Moverride inmain.bendis silently displaced by the libraryMthrough the group-merge (group_ofpicking the group led by the dead forward referenceL), exactly as diagnosed.Two notes on exploitability, in case they help scope the fix:
{main() == True{}}) is rejected by bend2's checker (expected : False{} / observed : True{}— bend2 checks the source reading), and a claim matching the source ({main() == False{}}) passes bend2 but the verdict self-confesses the TypeScript/kernel mismatch instead of validating. So today the leak is "a wrong book gets certified", not "a false proposition goes double-green" — theClaim.consistentside of the formalization keeps catching it.g4.bendverbatim gives--check-onlygreen (ALL PROOFS CHECK) and--verdictthe rawTypeError: null is not object (evaluating 'g.k')with no FAIL header — exit path identical to the report.Vacrin commentedon Sep 30, 2026
Appreciate the double check! Agreed, the kernel-oracle is the right way to nail face 3.
Both directions of your note (1) reproduce on 2.0.32 as well.
From my findings it isn't
Claim.consistentthat catches it. That claim is¬ Conv bk d.T (Enu [])(bendtt.lean:1529 on 2.0.32, :1532 on HEAD) — no def of a checked book has type<>which never runs on this.What catches the false claim is the dual-gate structure: bend2 checks the source at the source's reading, safe.ts emits a rewritten book, the kernel checks that book, and the two disagree, so
--verdictreports MISMATCH instead of PASS.The two independent readings fail to agree. Which is also why face 3 gets through in the first place: when the drift is in a value
rather than a type, nothing forces the two readings to be compared at all.
Related:
Claim.consistentis narrower than its name suggests. It namesEnu [], but safe.ts emits a userEmptyasΣx0 : <> -> (Empty.arms x0), which the statement doesn't reach. It was filed separately as #1183.Resolve BendTT recursive groups by membership (#1212) (#1215)