Repository navigation
Proofs
Stuart Jackson edited this page Nov 22, 2026
·
8 revisions
Code here is proved, not only tested: every decision is a small TypeScript function annotated with LemmaScript, translated to Dafny, and proved to match a hand-written model of how the marketplace must behave. This is the platform's way of working, taken from atlas, and the direction for all SimpleApps development.
Sources:
-
LemmaScript (
lsc, kept on its latest release, 0.6.11 here; on each upgrade re-check atlas's gap list and runpnpm proofs): TypeScript to Dafny, the//@annotations,.dfy.genvs.dfy -
Dafny reference: the language and verifier (
dafny verify, 4.11 here) - atlas (
clones/atlas):.claude/rules/proofs.mdfor the rules,models/PROCESS.mdfor the process, andmodels/LSC-GAPS.mdfor where lsc's translation differs from JavaScript. Read the gaps list before using a construct for the first time
| Piece | Path | What it is |
|---|---|---|
| Model | models/Marketplace.dfy |
Hand-written Dafny: what each rule means (CalVer, skill keys and names, the description limit, the token budget, connector URLs), with lemmas about shipped values. Written before the code |
| Proved code | scripts/rules.ts |
Each rule as a pure function with //@ verify and //@ ensures, listed in LemmaScript-files.txt
|
| Generated Dafny |
scripts/rules.dfy.gen, scripts/rules.dfy
|
lsc writes .dfy.gen; .dfy is the same plus hand proof steps, additions only
|
| Link | models/links/scripts-rules.dfy |
<function>MatchesModel lemmas: the code decides exactly what the model says |
| Runtime pin | scripts/rules.test.ts |
Each rule agrees with the regex it replaced on thousands of generated inputs, so the proof is about the code that actually runs |
| Shell | scripts/validate.ts |
Reads files and reports; calls the proved rules for every decision about a value |
lemmascript.json sets JavaScript string semantics (UTF-16 code units), as atlas does, so the proofs count characters the way the code does.
-
Code is TypeScript. LemmaScript proves only TypeScript, so all code in this repo MUST be TypeScript (
.ts, or.tsxin a mod): no Python, and no new JavaScript. Scripts run with Node's type stripping (node scripts/validate.ts), so there is no build step. The only exceptions are tool configs that their tools load as JavaScript (eslint.config.mjs,prettier.config.mjs) andscripts/check-banned-strings.sh, a shell wrapper aroundgit grepwith no decisions of its own. -
Model first. A new rule starts in
models/Marketplace.dfy, then the code, then the link. -
Every decision is proved. File reading, JSON, regex,
await, and classes stay in thin unproved shells that only call proved functions (lsc can't translate them; atlasmodels/LSC-GAPS.md). -
No escapes. Hand-written Dafny (the model, links, and additions to a generated
.dfy) MUST NOT useassume,{:axiom},{:verify false},{:trusted}, orexpect.scripts/validate.tsfails one. - Tests still pin the runtime at 100% coverage: a proof is about the Dafny translation, and a test shows JavaScript agrees.
- After changing a proved
.ts:pnpm exec lsc regen --backend=dafny scripts/<file>.ts, then re-add any hand proof steps.
| Command | Does |
|---|---|
pnpm proofs |
lsc check (regenerate, check additions-only, verify the code), then dafny verify the model and links |
pnpm quality |
Includes the escape check and the runtime pins |
pnpm proofs MUST pass before /submit (Deployment#submit). Like atlas, it is not in CI or the hooks: it needs Dafny installed locally (brew install dafny).
- The status line mod's decisions (meter colours, cache ages, wrapping): next, by pulling them out of
hooks/register.tsxinto proved functions (Mods). -
scripts/check-banned-strings.sh: shell;git grepdoes the matching.