Skip to content

In-tab kernel: prove an app with no server, work kept by address, Firefox and WebKit - #196

Closed
humuhumu33 wants to merge 19 commits into
mainfrom
feat/in-tab-kernel-phase3
Closed

humuhumu33 wants to merge 19 commits into
mainfrom
feat/in-tab-kernel-phase3

Conversation

@humuhumu33

Copy link
Copy Markdown
Contributor

What this adds

Follow-up to #174. Everything is a prototype under v2/in-tab-kernel/; no published build reads it and the studio still calls the hosted verifier. Start with v2/in-tab-kernel/REPORT.md.

  • An app's guarantees proved with no server and no elaborator (live/). studio/proof/PrismLive already proves regionCheck sound for every app. So an app's proof is two fixed terms: Eq.refl true for the checker evaluated on the app's rules, and regionCheck_sound applied to it. live/emit.mjs writes them, with the rules as kernel data; Lean's kernel judges the result.
  • Work done once per address (web/worker.mjs). A verdict is kept under the addresses of the kernel, the library and the suffix; the kernel's memory with the library resident is kept under the kernel's and the library's. A read is believed only if it names the addresses asked for and, for the image, re-derives to its own. Anything else is a miss, and a miss does the work in full.
  • Firefox and WebKit (web/engines.mjs), through Playwright.
  • Two measurements: what restoring a memory image saves (snapshot-probe.mjs), and which arithmetic theorems Lean accepts without proof search (prover/closed-forms.py).

Evidence

Proving an app in the kernel, WebAssembly under Node on one loaded desktop (evidence/live.json):

Result
Library: regionCheck_sound and all it rests on 6.57 MB, 1.05 MB gzip
Writing an app's proof, no Lean 1 to 5 ms
Parking-fee: 3 rules, 1 guarantee accepted in 18 ms, 64 MB
A guarantee the rules break; rules edited to break a guarantee both refused
Verdant: 35 rules, 15 guarantees accepted in 2.6 s, 191 MB

The proofs Lean wrote for the same two apps are judged in the same time and rest on the same axioms, propext and Quot.sound.

Kept by address, 7 runs (evidence/browser.json, evidence/engines.json). The engines ran while other builds loaded the machine; compare within a column.

Chromium 156 Firefox 153 WebKit 26.5
Open by reading the library 1.54 s 11.6 s 3.0 s
Open from the kept image 0.30 s 0.37 s 0.70 s
The same project again 0.5 to 1.2 ms 2 ms 14 to 16 ms
Agreement with native Lean, each of four ways 14 of 14 14 of 14 14 of 14
Faults refused 6 of 6 6 of 6 4 of 4; 2 not run

The faults include an image with one byte changed and a kept verdict rewritten to another suffix's; both end in the work being done in full.

What a reviewer should know

  • live/ has run under Node only. No browser has run it, and nothing in the studio uses it.
  • The app's theorem is not tied to what the app runs. It is about PrismLive.Kernel.judge on the data emit.mjs writes. That the data is what the app's rule module decides with is not proved.
  • Large apps are seconds, not milliseconds, and 191 MB. The obligations are separable; judging them one at a time is not built.
  • Coverage: regionCheck refuses a rule that compares two fields.
  • The store is the origin's own. A script of the origin that writes a whole, self-consistent record is believed, as it could replace the worker. Reuse is not evidence to anyone else.
  • Opened from the image the kernel holds 117 MB against 77.
  • The image is not the same bytes twice: two builds differ in about 140 of 80.5 million bytes, unexplained. It is made by the origin, not shipped by address.
  • Addresses are SHA-256, not κ: BLAKE3 inside the module is not built.
  • WebKit here is Safari's engine built for Windows. No Safari and no phone has run any of this.
  • The kernel's address changed (the loader exports its memory; loadLibrary reports its two times), and evidence/library-binding.json is rebound to it.
  • just vv was not run locally; nothing outside v2/ changes.

🤖 Generated with Claude Code

humuhumu33 and others added 19 commits November 14, 2026 08:59
web/engines.mjs runs web/bench.html through Playwright with no isolation
headers. Firefox 153 and WebKit 26.5 each give Lean's verdict on all 14
inputs and refuse all four address faults. WebKit matches Chromium;
Firefox is about three times slower at every step, with its slowest
project near the 500 ms budget.

WebKit here is Safari's engine built for Windows, and the phone row is
a viewport and user agent only. No phone has run this.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… library

Reading the 25.7 MB library is about 80% of opening the kernel (read
~800 ms, enter ~200 ms natively). snapshot-probe.mjs takes the kernel's
memory once the library is resident and restores it into a fresh
instance: 35 ms under Node, and the restored kernel gives the same
verdict as one that read the library on all 14 inputs.

The image is 80.5 MB, about 10 MB compressed, against 4.07 MB for the
library. Two builds of it differ in about 140 bytes, not yet explained.
A probe only: no dist, binding or worker uses the image.

The loader now exports its memory, and loadLibrary reports its two
times, so the kernel's address changes; evidence/library-binding.json is
for the earlier build.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The worker keeps a verdict under the addresses of the kernel, the
library and the suffix, and the kernel's memory with the library
resident under the kernel's and the library's. A read is believed only
if it names the addresses asked for and, for the image, re-derives to
its own; anything else is a miss, and a miss does the work in full.

In Chromium a later open takes 0.30 s from the image against 1.54 s by
reading the library, and a project met before answers in 0.5 to 1.2 ms.
Firefox: 0.37 s against 11.6 s. Each engine agrees with native Lean on
all 14 inputs each of four ways, and refuses every fault planted,
among them an altered image and a kept verdict under another name.

Opened from the image the kernel holds 117 MB against 77. The store is
the origin's own and is not evidence to anyone else.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… proof search

closed-forms.py retries each theorem LexLean renders as simp, split and
omega with rfl, with rfl after splitting records, and with decide. On
the two sample projects: of 5 such theorems, 2 pass with rfl and 3 need
search; 2 more are rfl as written. A measurement of what a prover with
no elaborator would have to cover, not a proof used anywhere.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ator

studio/proof/PrismLive already proves regionCheck sound for every app.
So an app's proof is two fixed terms: Eq.refl true for the checker
evaluated on the app's rules, and regionCheck_sound applied to it.
live/emit.mjs writes them, with the rules as kernel data, as a suffix of
a library that holds the checker and its proof; Lean's kernel judges it.

Under Node: the library is 6.57 MB (1.05 MB gzip); a proof is written
in 1 to 5 ms; parking-fee is accepted in 18 ms; a guarantee the rules
break, and rules edited to break a guarantee, are refused; Verdant, 35
rules and 15 guarantees, is accepted in 2.6 s at 191 MB.

A probe: no browser has run it, nothing in the studio uses it, and the
data written is not tied to what the app's rule module runs.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
proofsOf writes a suffix per guarantee, each whole in itself;
regionCheck_sound holds for a list of one. Verdant's 15 are each
accepted, in 0.15 to 1.2 s at 111 MB, in a run where the whole proof
took 5.6 s at 191 MB. The total work is the same; a guarantee's verdict
then depends only on the rules, the bounds and itself.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
On Verdant the proof makes 312 obligations and 5,485 box subtractions.
278 obligations have an empty region; the other 34 are distinct and
need 98 subtractions of boxes that touch their region. The kernel
judges those in 0.65 to 0.85 s against 1.6 to 2.2 s for the checker as
it is. Three reshapings of the checker did not help; a one-pass version
was far worse.

Measurements only: no soundness theorem takes the touching boxes as
given yet.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
live/Certified.lean proves certCheck_sound: for one guarantee, the proof
names which earlier rules to subtract at each rule and may point at a
fact already proved. Neither is trusted; a wrong name can only make the
check fail, and every fact is a hypothesis to be discharged. It rests
on propext and Quot.sound, as regionCheck_sound does, and is built
beside studio/proof, which is unchanged.

Verdant, one guarantee at a time in the WebAssembly kernel: 2.5 s in
all at 77 MB, against 5.1 s at 111 MB through regionCheck_sound. A
guarantee the rules break and a proof missing a rule it needs are both
refused.

The facts are not used yet: taking an obligation from an earlier proof
needs the kernel's environment to keep that proof.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
check_keep leaves an accepted suffix resident, so later proofs can name its
theorems. Keeping only the subtractions (reuse.mjs) did not help: the kernel
spends its time on the checker's small evaluations, redone per guarantee.

Linked.lean's linked_sound makes every evaluation a fact about plain data,
kept and named by address, and assembles a guarantee by lemma application
alone. On Verdant an edit to one rule re-judges 9 to 18 of 422 facts and
costs about 0.3 s instead of 2 s. Planted faults are all refused.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The worker's new prove op takes an app as data, writes each statement and
its proof, and has the kernel judge them, keeping facts by address. The
proving loop is one module (live/prove.mjs) shared with the Node test.

web/live.html in Edge, Firefox and WebKit: all 15 of Verdant's guarantees
accepted, first proof 1.1 to 3.6 s, one edited rule 0.16 to 0.76 s, the
broken guarantee refused. Download 1.57 MB gzip.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
With ?proof=tab, approving a rules app proves its guarantees in the tab:
Lean 4.32.1's kernel judges proofs written there from the spec, and the
Forge kernel guest decides the verdict from what the tab derived. Only
its word proved marks the app proved. A spec the tab cannot read as
boxes, or any other answer, goes to the hosted verifier as before, and
publish asks it for an attestation before it builds.

The kernel, the checker library and the proof writer ship in
studio/shell/in-tab, each named by SHA-256 in its manifest. Six Node
tests run the real kernel and guest; a browser check runs the worker in
Edge, Firefox and WebKit; fifteen planted defects are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Tab.lean's tab_sound reads a region as zones: a box and difference
constraints. is not splits a zone, a comparison of two fields adds a
constraint, and a zone is empty when its constraints close to a field
above itself. zonesOf is proved exact; emptiness is proved sound.
Guarantees are assembled from kept facts as before, on propext and
Quot.sound. A number with no maximum is bounded by the largest a
request can carry.

The shipped fixtures that went to the hosted verifier (RSVP's
party > seats, the parking fee's is not) now prove in the tab, and the
data proved answers all 168 sampled requests as the rules do. Verdant
proves in 1.3 s first and 0.3 to 0.6 s after an edit. Eight planted
defects are refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Approval asks one prover, the tab, and the rules are proved only on the
Prism guest's word proved; any other answer leaves them checked with
its reason. The switch and the hosted fallback are gone. A proof is
committed only when its answer is in, so an approval cancelled while
the tab proves is rolled back.

Publish hands the build the attestation the rules carry, none for a
proof made in the tab, and the renderer's axiom sets; the published
repository proves its model again in its own CI with the locked SDK,
as before. The four published apps read record exactly those sets.
Rules over the SDK's limit of 24 are proved and not published.

FA-87 now claims only the proof in the tab. Seven planted defects are
refused; the suites that stubbed the hosted prover for rules stub the
tab. Stateful apps still use the hosted verifier.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Approving in the studio from this branch showed the tab's proof message
claiming facts judged before when every fact was new. The suite now
checks both forms. The studio run (approve twice, publish without
GitHub, RSVP's comparison of fields; no request outside the page) is
recorded with how the local site was made.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
proveRules now asks inTab.proveInTab (FA-89). This check rebuilds the
host's rules functions with a fixed scope, which had only the hosted
prover, so the lane stopped at it. The stand-in answers and then
commits, as the client does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main registered FA-87 for the Prism R4 route meanwhile, so the in-tab
capabilities are FA-88 (a rules app proved in the tab), FA-89 (every
rule a spec can state) and FA-90 (no hosted verifier for rules apps).
Main's front-end trace (PM-02) asks every register ID to belong to a
back-end feature: the three join Proof, beside FA-86, and the facets
are projected again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main registered FA-88 for the Prism id meanwhile, so the in-tab
capabilities are FA-89 (a rules app proved in the tab), FA-90 (every
rule a spec can state) and FA-91 (no hosted verifier for rules apps),
under the Proof feature. The facets are projected again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
afflom added a commit that referenced this pull request Nov 15, 2026
* Prove rule apps in the tab with Lean's kernel, no server

A rule app's guarantees are now proved in the browser tab. Lean's kernel,
compiled to WebAssembly (the kernel from #196), runs in a worker with a
library exported from studio/proof resident, and judges one suffix per
guarantee. The Forge kernel guest gives the verdict (InTabKernel). Nothing
is sent to mcp.uor.foundation for a rule app any more.

The theorem is about what the published app runs. Regions.lean now holds
RuleJudge's definitions exactly as LexLean writes them in Lean, and proves
ruleJudge_sound: if wordsCheck holds on an app's words, ruleOutcome answers
no in-bounds request that breaks the guarantee. `is not` conditions in
rules are split into below/above boxes, with the first match unchanged.
Axioms: propext, Quot.sound.

CI checks, each keyed by its inputs:
- every copied RuleJudge definition equals `lexlean build` output (SDK)
- the shipped library is studio/proof's export, byte for byte
- the pinned kernel judges the library whole (the binding)

To pay the Prism-only ratchet, the hosted rule-proof wrapper goes, and
so do the v2/in-tab-check scripts (their report stays). Non-Prism lines
shrink by 683.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MM6ryyrahRTAs9z3M

* conformance: live-lexlean requires the axioms of all three theorems

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MM6ryyrahRTAs9z3M

* conformance: proof-reuse oracle counts the 12 tests left after rule apps moved in-tab

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MM6ryyrahRTAs9z3M

* studio: the generation patch fixture hands proveRules the kernel it now proves on

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MM6ryyrahRTAs9z3M

* studio: the large-module check asserts the 24-rule proving cap is gone

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MM6ryyrahRTAs9z3M

---------

Co-authored-by: Claude <noreply@anthropic.com>
@humuhumu33

Copy link
Copy Markdown
Contributor Author

@afflom, a proposal for landing in-browser proving under audit-prism (#214), before I rework this PR.

What this PR does today. Approving a rules app proves its guarantees in the tab. Lean 4.32.1's own kernel, compiled to WebAssembly, judges proofs written there from the spec, and the Forge kernel guest gives the verdict (FA-86). No request leaves the page, and publishing needs no hosted attestation. In the studio a rules app proves in 0.3 to 1.1 s, against 2 to 4 minutes on the hosted verifier. Every check passes except acceptance: audit-prism refuses 43 new non-Prism files and 3,551 lines.

What I propose, so the result is Prism wherever it can be.

  1. The proof writer becomes LexLean, compiled into the kernel guest, as IdeaReader is in feat(kernel): Foundry's own reader, compiled with Prism, reads an idea into the app notation #218. That covers reading a spec, the zone arithmetic, and writing each fact and each guarantee's proof as kernel input. It is about 600 lines of JavaScript today. Two model changes come with it: the application's responseMaximum rises from 4,096 bytes (one guarantee's proof is about 40 KB), and the writer declares its own name entries, so the guest needs no copy of the library's tables.
  2. One narrow audit change: a lock for the verifier. The Lean kernel (lean-kernel.wasm), the loader Emscripten generates for it, and the checker library are built from Lean's pinned source (f054605, 4.32.1) by v2/in-tab-kernel/build-wasm.sh, not written by hand. I propose an in-tab.lock beside frame.lock and identity/stitch.lock in PRISM_LOCKS. It would name that source and each output's SHA-256, so the files are bound byte for byte and any drift is counted. Only the 2-line loader is JavaScript; the wasm and the library are not counted.
  3. The worker glue joins the existing kernel worker in studio/shell/kernel.js (about 150 lines). The growth is offset by deleting what this PR makes dead: the hosted prover for rules apps in prism.js, and the measurement scripts and prototypes in v2/in-tab-kernel that nothing ships.
  4. The tests become guest acceptance vectors and LexLean theorems where they can, as feat(kernel): Foundry's own reader, compiled with Prism, reads an idea into the app notation #218 does. What stays JavaScript joins existing test files, offset by the same deletions.

What I'm asking. Would you accept item 2, and the shape overall? It is the one change to the audit itself; everything else stays within the ratchet. If you'd rather not admit a lock for the verifier, I'd like to know what form you would accept for the WebAssembly loader, since the tab can't run Lean's kernel without one.

@humuhumu33

Copy link
Copy Markdown
Contributor Author

Closing this as superseded. #227 shipped in-tab proving on main with this PR's Lean kernel build, byte for byte (lean-kernel.wasm 4b48480b…), in a shape that fits audit-prism, and it proves the theorem about what the published app runs, which this PR only checked on samples.

Two cases this PR proved still fail on the live site:

@humuhumu33 humuhumu33 closed this Nov 16, 2026
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