Skip to content

Prove rule apps in the tab with Lean's kernel, no server - #227

Merged
afflom merged 5 commits into
mainfrom
claude/project-thread-gg9zlu
Nov 15, 2026
Merged

afflom merged 5 commits into
mainfrom
claude/project-thread-gg9zlu

Conversation

@afflom

@afflom afflom commented Nov 15, 2026

Copy link
Copy Markdown
Member

Requested by Alex · project thread

Step 3 of the publish-without-GitHub plan. When you approve a rule app, Lean now proves its guarantees in the browser tab, and no server takes part. Before this, the rules went to mcp.uor.foundation.

What changes

  • The proof is about what the published app runs. studio/proof/PrismLive/Regions.lean now holds RuleJudge's definitions (ruleOpHolds, ruleCondsHold, ruleSpan, rulesEnd, ruleOutcome, ruleInBounds, WorkProtocol.word) exactly as LexLean writes them in Lean. It proves ruleJudge_sound: if wordsCheck holds on an app's words, then ruleOutcome never gives an in-bounds request an answer that breaks the guarantee. It rests on propext and Quot.sound only. This closes the gap In-tab kernel: prove an app with no server, work kept by address, Firefox and WebKit #196 left open (its theorem was about PrismLive.Kernel.judge, not what the app runs). Rules with is not are split into "below" and "above" boxes, and the first-match answer stays the same (judge_expand). So every rule ruleWords can publish is covered.
  • Proving in the tab (studio/shell/prism.js prove):
    • It uses In-tab kernel: prove an app with no server, work kept by address, Firefox and WebKit #196's Lean kernel wasm and loader, unchanged (same SHA-256), plus a library re-exported from studio/proof: 7.7 MB, 1.2 MB gzipped. All three are shipped gzipped under shell/kernel/lean/. manifest.json pins them by SHA-256, and so does the binding that records that this kernel judged this library whole.
    • A worker started from prism.js's own source writes one suffix per guarantee: the app's words, the guarantee, wordsCheck … = true := Eq.refl true, and ruleJudge_sound applied to it. Lean's kernel judges the suffix.
    • The Forge kernel guest gives the verdict (InTabKernel, FA-86) from the addresses the tab derived. The proof record names the kernel, library, statement and bundle addresses.
  • prism.ruleWordsOf now builds the words for both the proof and the published holo (host.js ruleWords calls it), so both use the same bytes.
  • Stateful apps (LexLean modules) are still proved through proveFiles on the hosted verifier. Proving those needs an elaborator, which this PR does not touch.

CI (studio.yml), each step keyed by its inputs

  • Every RuleJudge definition copied into Regions.lean must equal the output of lexlean build, line for line, in the locked SDK image. The cache key covers the five modules that build reads, the lexicons, lexlean.lock, prismpm.lock and Regions.lean. Path filters now include those files.
  • The shipped library must be studio/proof's lean4export export, byte for byte. The pinned wasm kernel then runs check_whole on it again, and the result must match the binding. The exporter is cached by its commit and the toolchain.
  • The axiom gate expects 3 theorems, not 2.

Checks run locally

  • lake build in studio/proof: all three theorems depend on [propext, Quot.sound].
  • Both CI steps above were run as written, including a negative: changing one copied definition makes the step fail and name the definition.
  • Chromium, through Playwright, on the shell served statically:
    • The parking example proves from a cold start in 1.0 s.
    • An app whose rule uses is not proves.
    • A false guarantee is refused ("Lean's kernel refused INV-9").
    • The kernel guest's verdict is proved.
  • node --test tools/*.test.mjs has the same failures as main (4 tests that already fail there), and no new ones. I updated the tests that read proveRules (they now pass kernelReady) and removed the hosted rule-proof reuse tests.
  • xtask audit-prism: non-Prism code drops from 476,891 to 476,208 lines. audit-reuse passes.
  • audit-bootstrap needs the SDK container; CI runs it.

What a reviewer should know

  • The Lean kernel's loader is emscripten output (62 KB, from In-tab kernel: prove an app with no server, work kept by address, Firefox and WebKit #196's build). It is shipped as a gzipped, pinned build artifact, like the wasm and the library. It is not tracked as a .mjs. It is generated code, not code anyone writes by hand. Rebuilding the wasm in CI (emsdk plus Lean's C++) is not done here: the binding check proves these bytes judge this library, not that they come from Lean's source.
  • The copied RuleJudge definitions call two runtime functions, LexLeanRuntime.index and multiply. Regions.lean states them the way LexLean's runtime states them for lists of numbers (listIndex, *). Lean cannot import the runtime directly, because lexlean verify deletes its .olean.server files (upstream request 2 in v2/serverless-prove/UPSTREAM.md). Once LexLean publishes them, the copy becomes an import.
  • The ratchet is paid by deleting the v2/in-tab-check scripts and crate. That was the experiment of running LexLean's check in the tab with a patched LexLean, which no build reads. Its REPORT.md stays and points at commit d2a1a71.
  • The service worker now precaches about 1.7 MB more (the three gzipped files), so a later proof also works offline.
  • Coordination with In-tab kernel: prove an app with no server, work kept by address, Firefox and WebKit #196 (humuhumu33): this PR builds on its kernel wasm, loader, writer and worker design, and takes the regionCheck route instead of its zones library. That route covers everything ruleWords publishes, now including is not. In-tab kernel: prove an app with no server, work kept by address, Firefox and WebKit #196's fact reuse, image snapshot and zones remain available to extend this.

Generated by Claude Code

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
…pps moved in-tab

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3MM6ryyrahRTAs9z3M
@afflom
afflom merged commit e69291f into main Nov 15, 2026
7 checks passed
afflom pushed a commit that referenced this pull request Nov 16, 2026
The idea box goes from idea to running app without leaving the browser.
The app's data form (lexlean/semantic-module/2) is now read in the tab by
semanticData(), held to LexLean 0.4's own output by digest on seven
fixtures and to the hosted service's guests reading. The chat turn no
longer opens a hosted session, so a Build turn shows no hosted-source
dialog and sends nothing to mcp.uor.foundation. The browser suites now
assert that no hosted dialog opens and no request reaches the service.

Checking and proving a stateful app still uses the hosted elaborator, and
only when the person approves the app; rule apps prove in the tab (#227).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Asa3LdusN9UGDiUFDM7bZ
afflom added a commit that referenced this pull request Nov 16, 2026
…#228)

The idea box goes from idea to running app without leaving the browser.
The app's data form (lexlean/semantic-module/2) is now read in the tab by
semanticData(), held to LexLean 0.4's own output by digest on seven
fixtures and to the hosted service's guests reading. The chat turn no
longer opens a hosted session, so a Build turn shows no hosted-source
dialog and sends nothing to mcp.uor.foundation. The browser suites now
assert that no hosted dialog opens and no request reaches the service.

Checking and proving a stateful app still uses the hosted elaborator, and
only when the person approves the app; rule apps prove in the tab (#227).


Claude-Session: https://claude.ai/code/session_013Asa3LdusN9UGDiUFDM7bZ

Co-authored-by: Claude <noreply@anthropic.com>
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.

2 participants