From c7fabbab0b5e616e6e55ac35f1a43b249704c690 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:40:55 +0000 Subject: [PATCH 1/7] build-set: one compact conformance suite per set, and no template leftovers The template's audit-prism ratchet refuses net growth in non-Prism code, and build-set wrote one Rust suite per app, each repeating the same four helpers: a fresh seven-app instance added 8 files and 510 lines and failed it. A set now writes one crates/conformance/tests/.rs: one helper that pins a declaration's text, and one table line per claim, expanded by a macro into a test named for its ID. Each test asserts what the old ones did. Per-app suites a set no longer writes are removed. Three leftovers of the template's example app also go: its Contract entrypoint stays out of app/lexlean.toml, its TC-01 register row is dropped with its scenario and test, and the prism.qual and prism.sec lexicons the facet modules use are declared even when lexlean.toml already lists other sources. site/app.json's promise comes from the set's optional 'promise' member, or its title and purpose, instead of the template's. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3Ns5C7CRWRVtEQBxEq --- builder/set.mjs | 71 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 7 deletions(-) diff --git a/builder/set.mjs b/builder/set.mjs index 66ce4ce..be25bbf 100644 --- a/builder/set.mjs +++ b/builder/set.mjs @@ -425,6 +425,7 @@ function scenarios(suite, purpose, claims) { function siteJson(set, router, claims) { const app = JSON.parse(TEMPLATE['site/app.json']); + app.promise = set.promise ?? { headline: set.title, detail: set.purpose }; const url = `https://github.com/${set.repository}`; const [owner, repo] = set.repository.split('/'); const props = claims.filter((c) => c.kind === 'property'); @@ -446,7 +447,7 @@ function siteJson(set, router, claims) { claim: props.map((c) => `${c.id}: ${c.statement.replace(/^The app/, `the ${c.app} app`)}.`).join(' '), proposition: { name: 'dispatch', text: router.apps.map((m) => `${m.spec.name} request := ${m.module}.judge request`).join('\n'), plain: set.purpose }, theorems: props.map((c) => ({ name: c.theorem, statement: `no request meets ${c.breaks}: ${c.statement.replace(/^The app/, `the ${c.app} app`)}`, how: 'Proved by linear arithmetic, checked by the Lean kernel by prismpm verify in CI', where: `app/src/${c.proofs}.lex.tex` })), - pinned: props.map((c) => ({ name: c.test, what: `${c.id}'s condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.`, where: `crates/conformance/tests/${c.suite}.rs` })), + pinned: props.map((c) => ({ name: c.test, what: `${c.id}'s condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.`, where: `crates/conformance/tests/${setSuiteOf(set)}.rs` })), attestations: { proof: { id: 'not recorded: the proof ran in the SDK image, not on the UOR MCP server', url: `${url}/actions/workflows/bootstrap.yml` }, build: { id: 'printed by prismpm verify in every pages run', url: `${url}/actions/workflows/pages.yml` }, @@ -510,9 +511,10 @@ export async function buildSet(input, prompts, { lastModified, current = () => u // lexlean.toml: the set's modules, and every other entrypoint the project already has. const ownedSrc = Object.keys(files).filter((p) => p.startsWith('app/src/') && !p.startsWith('app/src/Foundation/') && !p.startsWith('app/src/Production/')); const before = current('app/lexlean.toml') ?? ''; - const kept = [...(/^entrypoints = \[(.*)\]$/m.exec(before)?.[1] ?? '').matchAll(/"([^"]+)"/g)].map((x) => x[1]).filter((e) => !ownedSrc.includes(`app/${e}`) && current(`app/${e}`) !== undefined); + const kept = [...(/^entrypoints = \[(.*)\]$/m.exec(before)?.[1] ?? '').matchAll(/"([^"]+)"/g)].map((x) => x[1]).filter((e) => !ownedSrc.includes(`app/${e}`) && !(host ? [] : TEMPLATE_EXAMPLE).includes(`app/${e}`) && current(`app/${e}`) !== undefined); const entrypoints = [...new Set([...ownedSrc.map((p) => p.slice('app/'.length)), ...kept])].sort(); - const lexicons = before.includes('[[lexicon_source]]') ? before.slice(before.indexOf('[[lexicon_source]]'), before.indexOf('[limits]')).replace(/\n*$/, '\n\n') : [['lexlean.std.nat', 'builtin'], ...['prism.arch', 'prism.qual', 'prism.sec'].map((p) => [p, 'path'])].map(([p, k]) => (k === 'builtin' ? `[[lexicon_source]]\npackage = "${p}"\nkind = "builtin"\n` : `[[lexicon_source]]\npackage = "${p}"\nkind = "path"\npath = "language/${p}"\n`)).join('\n') + '\n'; + const declared = (text) => text + ['prism.arch', 'prism.qual', 'prism.sec'].filter((p) => !text.includes(`package = "${p}"`)).map((p) => `[[lexicon_source]]\npackage = "${p}"\nkind = "path"\npath = "language/${p}"\n\n`).join(''); + const lexicons = before.includes('[[lexicon_source]]') ? declared(before.slice(before.indexOf('[[lexicon_source]]'), before.indexOf('[limits]')).replace(/\n*$/, '\n\n')) : [['lexlean.std.nat', 'builtin'], ...['prism.arch', 'prism.qual', 'prism.sec'].map((p) => [p, 'path'])].map(([p, k]) => (k === 'builtin' ? `[[lexicon_source]]\npackage = "${p}"\nkind = "builtin"\n` : `[[lexicon_source]]\npackage = "${p}"\nkind = "path"\npath = "language/${p}"\n`)).join('\n') + '\n'; if (host) { const missing = ['prism.arch', 'prism.qual', 'prism.sec'].filter((p) => !before.includes(`package = "${p}"`)).map((p) => `[[lexicon_source]]\npackage = "${p}"\nkind = "path"\npath = "language/${p}"\n\n`).join(''); app('lexlean.toml', before.replace(/^entrypoints = \[.*\]$/m, `entrypoints = [${entrypoints.map((e) => `"${e}"`).join(', ')}]`).replace('[limits]', `${missing}[limits]`)); @@ -549,7 +551,6 @@ export async function buildSet(input, prompts, { lastModified, current = () => u claims.push(...own); if (own.length) { files[`features/suites/${suite}.feature`] = scenarios(suite, m.spec.purpose, own); - files[`crates/conformance/tests/${suite}.rs`] = rustTests({ suite, proofs: m.proofs }, own); } } const setPrefix = pascal(set.name).replace(/[a-z0-9]/g, ''); @@ -560,11 +561,67 @@ export async function buildSet(input, prompts, { lastModified, current = () => u if ([...prefixes.values()].includes(setPrefix)) throw new SpecError(`The set's prefix ${setPrefix} is also an app's; rename the set.`, 'name'); claims.push(...facets); files[`features/suites/${setSuite}.feature`] = scenarios(setSuite, set.purpose, facets); - files[`crates/conformance/tests/${setSuite}.rs`] = rustTests({ suite: setSuite }, facets); - const owned = new Set([setSuite, ...models.map((m) => m.suite)]); + files[`crates/conformance/tests/${setSuite}.rs`] = setRustTests(setSuite, claims); + // The template's example app (suite `contract`) is replaced, so its register row goes with it. + const owned = new Set([setSuite, ...models.map((m) => m.suite), ...(host ? [] : ['contract'])]); files['model/ids.toml'] = idsToml(current('model/ids.toml') ?? TEMPLATE['model/ids.toml'], owned, claims); if (!host) files['site/app.json'] = siteJson(set, router, claims); - return { files, remove: [...TEMPLATE_EXAMPLE, 'app/prompt.json'], set, models, router, claims }; + const perApp = models.map((m) => `crates/conformance/tests/${m.suite}.rs`).filter((p) => !(p in files)); + return { files, remove: [...TEMPLATE_EXAMPLE, 'app/prompt.json', ...perApp], set, models, router, claims }; +} + +const setSuiteOf = (set) => suiteOf({ name: set.name }); + +/** + * `crates/conformance/tests/.rs`: one test per claim of the whole set, in + * one file, in the layout `cargo fmt` gives it. Each test pins what its theorem + * is about (a property's condition and that no request meets it; a facet + * theorem's statement and that `decide` proves it), so a weakened statement + * that still verifies fails the gate. One table line per claim keeps the + * generated Rust small, as the template's only-Prism ratchet asks. + */ +export function setRustTests(suite, claims) { + const lit = (s) => JSON.stringify(s); + const rows = claims.map((c) => + c.kind === 'property' + ? ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}\n ${c.test}: ${lit(c.proofs)}, ${lit(c.breaks)} => ${lit(`body: ${c.condition}`)}, ${lit(c.theorem)} => ${lit(`statement: ((${c.breaks} request) = false),`)};` + : ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}\n ${c.test}: ${lit(c.module)}, ${lit(c.theorem)} => ${lit(`statement: ${c.holds},`)}, ${lit(c.theorem)} => "proof: decide{}";`, + ); + return [ + `//! The \`${suite}\` suite: one test per claim of the prompt set, each named for its ID.`, + '//!', + '//! Written by the Prism-DevRel builder from the prompt set. The theorems are', + '//! checked by the Lean kernel when `just vv` runs `prismpm verify` on `app/`.', + '//! What these tests hold fixed is what each theorem is about, so a weakened', + '//! statement that still verifies fails the gate.', + '', + '/// The top-level declaration `name` of `app/src/.lex.tex` contains `needle`.', + 'fn pins(module: &str, name: &str, needle: &str) {', + ' let root = env!("CARGO_MANIFEST_DIR");', + ' let path = format!("{root}/../../app/src/{module}.lex.tex");', + ' let model = std::fs::read_to_string(path).expect("the module");', + ' let start = model', + ' .find(&format!("\\n name: {name},\\n"))', + ' .unwrap_or_else(|| panic!("{name} is not declared"));', + ' let end = model[start..].find("\\n}\\n").expect("closed");', + ' let found = &model[start..start + end];', + ' assert!(found.contains(needle), "{name}: {needle}\\n{found}");', + '}', + '', + 'macro_rules! claims {', + ' ($($test:ident: $module:literal $(, $name:literal => $needle:literal)+;)*) => {$(', + ' #[test]', + ' fn $test() {', + ' $(pins($module, $name, $needle);)+', + ' }', + ' )*};', + '}', + '', + 'claims! {', + ...rows, + '}', + '', + ].join('\n'); } export { describeConditions }; From 168b9eba3db1b82247350c11714e00b1eb04a385 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:42:48 +0000 Subject: [PATCH 2/7] build-set: write each claim's test as its own #[test] line The template's honesty gate reads test names from a '#[test]' line and the 'fn' line after it, so tests a macro expands are invisible to it. Each claim is now one '#[test]' and one 'fn' line in a #[rustfmt::skip] module, still 75 counted lines for a seven-app set against the 82 of the template example it replaces. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3Ns5C7CRWRVtEQBxEq --- builder/set.mjs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/builder/set.mjs b/builder/set.mjs index be25bbf..680362d 100644 --- a/builder/set.mjs +++ b/builder/set.mjs @@ -574,26 +574,33 @@ const setSuiteOf = (set) => suiteOf({ name: set.name }); /** * `crates/conformance/tests/.rs`: one test per claim of the whole set, in - * one file, in the layout `cargo fmt` gives it. Each test pins what its theorem + * one file: a helper `cargo fmt` lays out, then the tests, one line each, in a + * `#[rustfmt::skip]` module. Each test pins what its theorem * is about (a property's condition and that no request meets it; a facet * theorem's statement and that `decide` proves it), so a weakened statement - * that still verifies fails the gate. One table line per claim keeps the - * generated Rust small, as the template's only-Prism ratchet asks. + * that still verifies fails the gate. One line per claim keeps the generated + * Rust small, as the template's only-Prism ratchet asks. */ export function setRustTests(suite, claims) { const lit = (s) => JSON.stringify(s); - const rows = claims.map((c) => + const pins = (c) => c.kind === 'property' - ? ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}\n ${c.test}: ${lit(c.proofs)}, ${lit(c.breaks)} => ${lit(`body: ${c.condition}`)}, ${lit(c.theorem)} => ${lit(`statement: ((${c.breaks} request) = false),`)};` - : ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}\n ${c.test}: ${lit(c.module)}, ${lit(c.theorem)} => ${lit(`statement: ${c.holds},`)}, ${lit(c.theorem)} => "proof: decide{}";`, - ); + ? [[c.proofs, c.breaks, `body: ${c.condition}`], [c.proofs, c.theorem, `statement: ((${c.breaks} request) = false),`]] + : [[c.module, c.theorem, `statement: ${c.holds},`], [c.module, c.theorem, 'proof: decide{}']]; + // The repository's honesty gate reads each test's name from a `#[test]` line and the `fn` line after it. + const rows = claims.flatMap((c) => [ + ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}`, + ' #[test]', + ` fn ${c.test}() { ${pins(c).map((p) => `pins(${p.map(lit).join(', ')});`).join(' ')} }`, + ]); return [ `//! The \`${suite}\` suite: one test per claim of the prompt set, each named for its ID.`, '//!', '//! Written by the Prism-DevRel builder from the prompt set. The theorems are', '//! checked by the Lean kernel when `just vv` runs `prismpm verify` on `app/`.', '//! What these tests hold fixed is what each theorem is about, so a weakened', - '//! statement that still verifies fails the gate.', + '//! statement that still verifies fails the gate. One line per claim keeps the', + '//! generated Rust small, as the template\'s only-Prism ratchet asks.', '', '/// The top-level declaration `name` of `app/src/.lex.tex` contains `needle`.', 'fn pins(module: &str, name: &str, needle: &str) {', @@ -608,16 +615,10 @@ export function setRustTests(suite, claims) { ' assert!(found.contains(needle), "{name}: {needle}\\n{found}");', '}', '', - 'macro_rules! claims {', - ' ($($test:ident: $module:literal $(, $name:literal => $needle:literal)+;)*) => {$(', - ' #[test]', - ' fn $test() {', - ' $(pins($module, $name, $needle);)+', - ' }', - ' )*};', - '}', + '#[rustfmt::skip]', + 'mod claims {', + ' use super::pins;', '', - 'claims! {', ...rows, '}', '', From 3fa9a7d2c2c5dff8f3917412231e84f601f89b62 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:50:09 +0000 Subject: [PATCH 3/7] builder: one compact rustTests for an app and a set The single-app and set builders now share the compact suite writer, so the old per-app generator goes and the builder shrinks (81 lines out, 54 in), as the only-Prism ratchet asks. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3Ns5C7CRWRVtEQBxEq --- builder/build.mjs | 116 +++++++++++++++++----------------------------- builder/set.mjs | 55 +--------------------- 2 files changed, 43 insertions(+), 128 deletions(-) diff --git a/builder/build.mjs b/builder/build.mjs index 79dcdf4..ca97a5e 100644 --- a/builder/build.mjs +++ b/builder/build.mjs @@ -52,7 +52,6 @@ function allClaims(m) { } const tomlString = (text) => JSON.stringify(text); -const rustString = (text) => `"${text.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`; function idsToml(m, claims) { const current = TEMPLATE['model/ids.toml']; @@ -69,86 +68,55 @@ function scenarios(m, claims) { return `${text.replace(/\n$/, '')}${facet.join('')}\n`; } -/** `crates/conformance/tests/.rs`, in the layout `cargo fmt` gives it. */ -export function rustTests(m, claims) { - const props = claims.filter((c) => c.kind === 'property'); - const facets = claims.filter((c) => c.kind === 'facet'); - const helpers = [ - 'use std::path::PathBuf;', - '', - 'fn root() -> PathBuf {', - ' PathBuf::from(env!("CARGO_MANIFEST_DIR"))', - ' .ancestors()', - ' .nth(2)', - ' .expect("crates/conformance is two below the root")', - ' .to_path_buf()', - '}', +/** + * `crates/conformance/tests/.rs`: one test per claim, of one app or a whole + * set, in one file: a helper `cargo fmt` lays out, then the tests, one line each, in a + * `#[rustfmt::skip]` module. Each test pins what its theorem + * is about (a property's condition and that no request meets it; a facet + * theorem's statement and that `decide` proves it), so a weakened statement + * that still verifies fails the gate. One line per claim keeps the generated + * Rust small, as the template's only-Prism ratchet asks. + */ +export function rustTests(suite, claims, proofs) { + const lit = (s) => JSON.stringify(s); + const pins = (c) => + c.kind === 'property' + ? [[c.proofs ?? proofs, c.breaks, `body: ${c.condition}`], [c.proofs ?? proofs, c.theorem, `statement: ((${c.breaks} request) = false),`]] + : [[c.module, c.theorem, `statement: ${c.holds},`], [c.module, c.theorem, 'proof: decide{}']]; + // The repository's honesty gate reads each test's name from a `#[test]` line and the `fn` line after it. + const rows = claims.flatMap((c) => [ + ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}`, + ' #[test]', + ` fn ${c.test}() { ${pins(c).map((p) => `pins(${p.map(lit).join(', ')});`).join(' ')} }`, + ]); + return [ + `//! The \`${suite}\` suite: one test per claim, each named for its ID.`, + '//!', + '//! Written by the Prism-DevRel builder from the prompts. The theorems are', + '//! checked by the Lean kernel when `just vv` runs `prismpm verify` on `app/`.', + '//! What these tests hold fixed is what each theorem is about, so a weakened', + '//! statement that still verifies fails the gate. One line per claim keeps the', + '//! generated Rust small, as the template\'s only-Prism ratchet asks.', '', - '/// The body of the top-level declaration named `name`, up to its closing brace.', - "fn declaration<'a>(model: &'a str, name: &str) -> &'a str {", + '/// The top-level declaration `name` of `app/src/.lex.tex` contains `needle`.', + 'fn pins(module: &str, name: &str, needle: &str) {', + ' let root = env!("CARGO_MANIFEST_DIR");', + ' let path = format!("{root}/../../app/src/{module}.lex.tex");', + ' let model = std::fs::read_to_string(path).expect("the module");', ' let start = model', ' .find(&format!("\\n name: {name},\\n"))', ' .unwrap_or_else(|| panic!("{name} is not declared"));', - ' let end = model[start..]', - ' .find("\\n}\\n")', - ' .unwrap_or_else(|| panic!("{name} is not closed"));', - ' &model[start..start + end]', + ' let end = model[start..].find("\\n}\\n").expect("closed");', + ' let found = &model[start..start + end];', + ' assert!(found.contains(needle), "{name}: {needle}\\n{found}");', '}', '', - 'fn module(path: &str) -> String {', - ' std::fs::read_to_string(root().join(path)).expect("the module")', - '}', - ]; - if (props.length) - helpers.push( - '', - '/// The condition no request may meet, and the theorem that says none does.', - 'fn pinned(breaks: &str, condition: &str, theorem: &str) {', - ` let model = module(${rustString(`app/src/${m.proofs}.lex.tex`)});`, - ' let found = declaration(&model, breaks);', - ' assert!(', - ' found.contains(condition),', - ' "the condition of {breaks} changed:\\n{found}"', - ' );', - ' let holds = declaration(&model, theorem);', - ' let statement = format!("statement: (({breaks} request) = false),");', - ' assert!(', - ' holds.contains(&statement),', - ' "{theorem} must state that no request meets {breaks}:\\n{holds}"', - ' );', - '}', - ); - if (facets.length) - helpers.push( + '#[rustfmt::skip]', + 'mod claims {', + ' use super::pins;', '', - '/// A facet theorem: proved by `decide`, about exactly this predicate.', - 'fn holds(path: &str, theorem: &str, statement: &str) {', - ' let model = module(path);', - ' let found = declaration(&model, theorem);', - ' assert!(', - ' found.contains(&format!("statement: {statement},")),', - ' "{theorem} must state {statement}:\\n{found}"', - ' );', - ' assert!(', - ' found.contains("proof: decide{}"),', - ' "{theorem} is proved by decide"', - ' );', + ...rows, '}', - ); - const tests = [ - ...props.map((c) => ['', `/// \`${c.id}\`: ${c.statement}`, '#[test]', `fn ${c.test}() {`, ' pinned(', ` ${rustString(c.breaks)},`, ` ${rustString(`body: ${c.condition}`)},`, ` ${rustString(c.theorem)},`, ' );', '}'].join('\n')), - ...facets.map((c) => ['', `/// \`${c.id}\`: ${c.statement}`, '#[test]', `fn ${c.test}() {`, ' holds(', ` ${rustString(`app/src/${c.module}.lex.tex`)},`, ` ${rustString(c.theorem)},`, ` ${rustString(c.holds)},`, ' );', '}'].join('\n')), - ]; - return [ - `//! The \`${m.suite}\` suite: one test per scenario in \`features/suites/${m.suite}.feature\`.`, - '//!', - '//! Written by the Prism-DevRel builder from the app\'s prompt. The theorems are', - '//! checked by the Lean kernel when `just vv` runs `prismpm verify` on `app/`.', - '//! What these tests hold fixed is what each theorem is about, so a weakened', - '//! statement that still verifies fails the gate.', - '', - ...helpers, - ...tests, '', ].join('\n'); } @@ -219,7 +187,7 @@ export async function buildApp(input, { lastModified } = {}) { const claims = allClaims(m); files['model/ids.toml'] = idsToml(m, claims); files[`features/suites/${m.suite}.feature`] = scenarios(m, claims); - files[`crates/conformance/tests/${m.suite}.rs`] = rustTests(m, claims); + files[`crates/conformance/tests/${m.suite}.rs`] = rustTests(m.suite, claims, m.proofs); files['CONFORMANCE.md'] = conformance(m, claims); files['site/app.json'] = appJson(m.spec, TEMPLATE['site/app.json'], { repository: m.prompt.repository ?? `OWNER/prism-${m.spec.name}` }); files[`openspec/specs/${m.spec.name}/spec.md`] = renderSpecDocument(m.spec, {}); diff --git a/builder/set.mjs b/builder/set.mjs index 680362d..cee3ba1 100644 --- a/builder/set.mjs +++ b/builder/set.mjs @@ -561,7 +561,7 @@ export async function buildSet(input, prompts, { lastModified, current = () => u if ([...prefixes.values()].includes(setPrefix)) throw new SpecError(`The set's prefix ${setPrefix} is also an app's; rename the set.`, 'name'); claims.push(...facets); files[`features/suites/${setSuite}.feature`] = scenarios(setSuite, set.purpose, facets); - files[`crates/conformance/tests/${setSuite}.rs`] = setRustTests(setSuite, claims); + files[`crates/conformance/tests/${setSuite}.rs`] = rustTests(setSuite, claims); // The template's example app (suite `contract`) is replaced, so its register row goes with it. const owned = new Set([setSuite, ...models.map((m) => m.suite), ...(host ? [] : ['contract'])]); files['model/ids.toml'] = idsToml(current('model/ids.toml') ?? TEMPLATE['model/ids.toml'], owned, claims); @@ -572,57 +572,4 @@ export async function buildSet(input, prompts, { lastModified, current = () => u const setSuiteOf = (set) => suiteOf({ name: set.name }); -/** - * `crates/conformance/tests/.rs`: one test per claim of the whole set, in - * one file: a helper `cargo fmt` lays out, then the tests, one line each, in a - * `#[rustfmt::skip]` module. Each test pins what its theorem - * is about (a property's condition and that no request meets it; a facet - * theorem's statement and that `decide` proves it), so a weakened statement - * that still verifies fails the gate. One line per claim keeps the generated - * Rust small, as the template's only-Prism ratchet asks. - */ -export function setRustTests(suite, claims) { - const lit = (s) => JSON.stringify(s); - const pins = (c) => - c.kind === 'property' - ? [[c.proofs, c.breaks, `body: ${c.condition}`], [c.proofs, c.theorem, `statement: ((${c.breaks} request) = false),`]] - : [[c.module, c.theorem, `statement: ${c.holds},`], [c.module, c.theorem, 'proof: decide{}']]; - // The repository's honesty gate reads each test's name from a `#[test]` line and the `fn` line after it. - const rows = claims.flatMap((c) => [ - ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}`, - ' #[test]', - ` fn ${c.test}() { ${pins(c).map((p) => `pins(${p.map(lit).join(', ')});`).join(' ')} }`, - ]); - return [ - `//! The \`${suite}\` suite: one test per claim of the prompt set, each named for its ID.`, - '//!', - '//! Written by the Prism-DevRel builder from the prompt set. The theorems are', - '//! checked by the Lean kernel when `just vv` runs `prismpm verify` on `app/`.', - '//! What these tests hold fixed is what each theorem is about, so a weakened', - '//! statement that still verifies fails the gate. One line per claim keeps the', - '//! generated Rust small, as the template\'s only-Prism ratchet asks.', - '', - '/// The top-level declaration `name` of `app/src/.lex.tex` contains `needle`.', - 'fn pins(module: &str, name: &str, needle: &str) {', - ' let root = env!("CARGO_MANIFEST_DIR");', - ' let path = format!("{root}/../../app/src/{module}.lex.tex");', - ' let model = std::fs::read_to_string(path).expect("the module");', - ' let start = model', - ' .find(&format!("\\n name: {name},\\n"))', - ' .unwrap_or_else(|| panic!("{name} is not declared"));', - ' let end = model[start..].find("\\n}\\n").expect("closed");', - ' let found = &model[start..start + end];', - ' assert!(found.contains(needle), "{name}: {needle}\\n{found}");', - '}', - '', - '#[rustfmt::skip]', - 'mod claims {', - ' use super::pins;', - '', - ...rows, - '}', - '', - ].join('\n'); -} - export { describeConditions }; From 5b7d288e154fa819bade4d925a32554cd53a8c1f Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 01:52:03 +0000 Subject: [PATCH 4/7] build-set: keep a fresh instance's set suite in the template's contract.rs The template's only-Prism ratchet refuses any new non-Prism file, so the set's compact suite replaces the template example's test file instead of adding one, and any earlier per-app or per-set test file is removed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3Ns5C7CRWRVtEQBxEq --- builder/set.mjs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/builder/set.mjs b/builder/set.mjs index cee3ba1..6e9eab8 100644 --- a/builder/set.mjs +++ b/builder/set.mjs @@ -447,7 +447,7 @@ function siteJson(set, router, claims) { claim: props.map((c) => `${c.id}: ${c.statement.replace(/^The app/, `the ${c.app} app`)}.`).join(' '), proposition: { name: 'dispatch', text: router.apps.map((m) => `${m.spec.name} request := ${m.module}.judge request`).join('\n'), plain: set.purpose }, theorems: props.map((c) => ({ name: c.theorem, statement: `no request meets ${c.breaks}: ${c.statement.replace(/^The app/, `the ${c.app} app`)}`, how: 'Proved by linear arithmetic, checked by the Lean kernel by prismpm verify in CI', where: `app/src/${c.proofs}.lex.tex` })), - pinned: props.map((c) => ({ name: c.test, what: `${c.id}'s condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.`, where: `crates/conformance/tests/${setSuiteOf(set)}.rs` })), + pinned: props.map((c) => ({ name: c.test, what: `${c.id}'s condition and the theorem that no request meets it. A string-matching test, not a theorem: a planted defect fails it.`, where: SET_TESTS })), attestations: { proof: { id: 'not recorded: the proof ran in the SDK image, not on the UOR MCP server', url: `${url}/actions/workflows/bootstrap.yml` }, build: { id: 'printed by prismpm verify in every pages run', url: `${url}/actions/workflows/pages.yml` }, @@ -561,15 +561,16 @@ export async function buildSet(input, prompts, { lastModified, current = () => u if ([...prefixes.values()].includes(setPrefix)) throw new SpecError(`The set's prefix ${setPrefix} is also an app's; rename the set.`, 'name'); claims.push(...facets); files[`features/suites/${setSuite}.feature`] = scenarios(setSuite, set.purpose, facets); - files[`crates/conformance/tests/${setSuite}.rs`] = rustTests(setSuite, claims); + // A new test file is new non-Prism code, so a fresh instance keeps the set's suite in the template's. + files[host ? `crates/conformance/tests/${setSuite}.rs` : SET_TESTS] = rustTests(setSuite, claims); // The template's example app (suite `contract`) is replaced, so its register row goes with it. const owned = new Set([setSuite, ...models.map((m) => m.suite), ...(host ? [] : ['contract'])]); files['model/ids.toml'] = idsToml(current('model/ids.toml') ?? TEMPLATE['model/ids.toml'], owned, claims); if (!host) files['site/app.json'] = siteJson(set, router, claims); - const perApp = models.map((m) => `crates/conformance/tests/${m.suite}.rs`).filter((p) => !(p in files)); - return { files, remove: [...TEMPLATE_EXAMPLE, 'app/prompt.json', ...perApp], set, models, router, claims }; + const perApp = [setSuite, ...models.map((m) => m.suite)].map((s) => `crates/conformance/tests/${s}.rs`); + return { files, remove: [...TEMPLATE_EXAMPLE, 'app/prompt.json', ...perApp].filter((p) => !(p in files)), set, models, router, claims }; } -const setSuiteOf = (set) => suiteOf({ name: set.name }); +const SET_TESTS = 'crates/conformance/tests/contract.rs'; export { describeConditions }; From 4da7c3a743a357098e74fd9a1d31cbffc4e61d0d Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 02:00:16 +0000 Subject: [PATCH 5/7] build-set: a shorter pins helper, called through super Four fewer generated lines per suite, so a model with more claims still shrinks the instance's non-Prism code. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3Ns5C7CRWRVtEQBxEq --- builder/build.mjs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/builder/build.mjs b/builder/build.mjs index ca97a5e..995efc7 100644 --- a/builder/build.mjs +++ b/builder/build.mjs @@ -87,7 +87,7 @@ export function rustTests(suite, claims, proofs) { const rows = claims.flatMap((c) => [ ` // ${c.id}: ${c.statement.replace(/\s+/g, ' ')}`, ' #[test]', - ` fn ${c.test}() { ${pins(c).map((p) => `pins(${p.map(lit).join(', ')});`).join(' ')} }`, + ` fn ${c.test}() { ${pins(c).map((p) => `super::pins(${p.map(lit).join(', ')});`).join(' ')} }`, ]); return [ `//! The \`${suite}\` suite: one test per claim, each named for its ID.`, @@ -100,20 +100,15 @@ export function rustTests(suite, claims, proofs) { '', '/// The top-level declaration `name` of `app/src/.lex.tex` contains `needle`.', 'fn pins(module: &str, name: &str, needle: &str) {', - ' let root = env!("CARGO_MANIFEST_DIR");', - ' let path = format!("{root}/../../app/src/{module}.lex.tex");', + ' let path = format!("{}/../../app/src/{module}.lex.tex", env!("CARGO_MANIFEST_DIR"));', ' let model = std::fs::read_to_string(path).expect("the module");', - ' let start = model', - ' .find(&format!("\\n name: {name},\\n"))', - ' .unwrap_or_else(|| panic!("{name} is not declared"));', - ' let end = model[start..].find("\\n}\\n").expect("closed");', - ' let found = &model[start..start + end];', + ' let at = model.find(&format!("\\n name: {name},\\n")).expect(name);', + ' let found = &model[at..at + model[at..].find("\\n}\\n").expect("closed")];', ' assert!(found.contains(needle), "{name}: {needle}\\n{found}");', '}', '', '#[rustfmt::skip]', 'mod claims {', - ' use super::pins;', '', ...rows, '}', From 12827a5d95847e1a67eda8b32aca8d02716bdc86 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 02:01:48 +0000 Subject: [PATCH 6/7] build-set: the pins helper reads from the package directory cargo test runs in Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3Ns5C7CRWRVtEQBxEq --- builder/build.mjs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/builder/build.mjs b/builder/build.mjs index 995efc7..62f9f9d 100644 --- a/builder/build.mjs +++ b/builder/build.mjs @@ -100,10 +100,9 @@ export function rustTests(suite, claims, proofs) { '', '/// The top-level declaration `name` of `app/src/.lex.tex` contains `needle`.', 'fn pins(module: &str, name: &str, needle: &str) {', - ' let path = format!("{}/../../app/src/{module}.lex.tex", env!("CARGO_MANIFEST_DIR"));', - ' let model = std::fs::read_to_string(path).expect("the module");', - ' let at = model.find(&format!("\\n name: {name},\\n")).expect(name);', - ' let found = &model[at..at + model[at..].find("\\n}\\n").expect("closed")];', + ' let model = std::fs::read_to_string(format!("../../app/src/{module}.lex.tex")).unwrap();', + ' let found = &model[model.find(&format!("\\n name: {name},\\n")).expect(name)..];', + ' let found = &found[..found.find("\\n}\\n").expect("closed")];', ' assert!(found.contains(needle), "{name}: {needle}\\n{found}");', '}', '', From b0d89a9dddba53135e9e2bb6e259abdbead81223 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 15 Nov 2026 02:47:13 +0000 Subject: [PATCH 7/7] build-set: a set ships no Design module until prismpm verify regenerates its design/ files With the merged OPM and UML views, prismpm verify's second regeneration does not reproduce the design/ files build emits, so verify refuses with PP5004. Removing Design (and its Compliance import and obligation) makes the set's app verify. The single-app build keeps its Design module. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_013Asa3Ns5C7CRWRVtEQBxEq --- builder/facets.mjs | 4 ++-- builder/set.mjs | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builder/facets.mjs b/builder/facets.mjs index c488d84..28db632 100644 --- a/builder/facets.mjs +++ b/builder/facets.mjs @@ -251,7 +251,7 @@ export function compliance(m) { | List.cons item rest => (((project item index) =? position) && ((hasEvidence (project item evidence)) && (obligationsEvidenced (position + 1) rest))))`, { parameters: ['position : Nat', 'items : (List Obligation)'], recursive: 'items' }), theorem('everyObligationEvidenced', '((obligationsEvidenced 0 (obligations)) = true)'), ]; - return moduleText({ name: 'Compliance', glossaries: [BOOL, NAT, ARCH], imports: ['Architecture', 'Design', 'Quality', 'Security', ...(m.modules ?? [m.module])], title: 'standards reference', declarations: decls }); + return moduleText({ name: 'Compliance', glossaries: [BOOL, NAT, ARCH], imports: ['Architecture', ...(m.withoutDesign ? [] : ['Design']), 'Quality', 'Security', ...(m.modules ?? [m.module])], title: 'standards reference', declarations: decls }); } /** The facet modules, by path under app/. */ @@ -259,7 +259,7 @@ export function facetModules(m) { return { 'src/Architecture.lex.tex': architecture(m), 'src/Compliance.lex.tex': compliance(m), - 'src/Design.lex.tex': design(m), + ...(m.withoutDesign ? {} : { 'src/Design.lex.tex': design(m) }), 'src/Features.lex.tex': features(m), 'src/Quality.lex.tex': quality(m), 'src/Security.lex.tex': security(m), diff --git a/builder/set.mjs b/builder/set.mjs index 6e9eab8..1764fd2 100644 --- a/builder/set.mjs +++ b/builder/set.mjs @@ -244,7 +244,8 @@ export function mergeModels(set, models) { // ---- Compliance: one obligation per standard and subject, with every app's evidence. const obligations = new Map(); for (const m of models) - for (const o of m.compliance) { + // prismpm verify does not regenerate the design/ files a set's merged views emit (PP5004), so a set ships no Design module yet. + for (const o of m.compliance.filter((x) => x.subject !== 'Design views')) { // The three facet theorems are the set's; every other obligation is an app's, so no evidence list outgrows a list part. const own = !['Architecture description', 'Product quality', 'Application security and risk', 'Control set'].includes(o.subject); const subject = own ? `${m.title}: ${o.subject}` : o.subject; @@ -272,6 +273,7 @@ export function mergeModels(set, models) { security, quality, compliance: [...obligations.values()], + withoutDesign: true, }; } @@ -511,7 +513,7 @@ export async function buildSet(input, prompts, { lastModified, current = () => u // lexlean.toml: the set's modules, and every other entrypoint the project already has. const ownedSrc = Object.keys(files).filter((p) => p.startsWith('app/src/') && !p.startsWith('app/src/Foundation/') && !p.startsWith('app/src/Production/')); const before = current('app/lexlean.toml') ?? ''; - const kept = [...(/^entrypoints = \[(.*)\]$/m.exec(before)?.[1] ?? '').matchAll(/"([^"]+)"/g)].map((x) => x[1]).filter((e) => !ownedSrc.includes(`app/${e}`) && !(host ? [] : TEMPLATE_EXAMPLE).includes(`app/${e}`) && current(`app/${e}`) !== undefined); + const kept = [...(/^entrypoints = \[(.*)\]$/m.exec(before)?.[1] ?? '').matchAll(/"([^"]+)"/g)].map((x) => x[1]).filter((e) => !ownedSrc.includes(`app/${e}`) && !(host ? [] : [...TEMPLATE_EXAMPLE, 'app/src/Design.lex.tex']).includes(`app/${e}`) && current(`app/${e}`) !== undefined); const entrypoints = [...new Set([...ownedSrc.map((p) => p.slice('app/'.length)), ...kept])].sort(); const declared = (text) => text + ['prism.arch', 'prism.qual', 'prism.sec'].filter((p) => !text.includes(`package = "${p}"`)).map((p) => `[[lexicon_source]]\npackage = "${p}"\nkind = "path"\npath = "language/${p}"\n\n`).join(''); const lexicons = before.includes('[[lexicon_source]]') ? declared(before.slice(before.indexOf('[[lexicon_source]]'), before.indexOf('[limits]')).replace(/\n*$/, '\n\n')) : [['lexlean.std.nat', 'builtin'], ...['prism.arch', 'prism.qual', 'prism.sec'].map((p) => [p, 'path'])].map(([p, k]) => (k === 'builtin' ? `[[lexicon_source]]\npackage = "${p}"\nkind = "builtin"\n` : `[[lexicon_source]]\npackage = "${p}"\nkind = "path"\npath = "language/${p}"\n`)).join('\n') + '\n'; @@ -568,7 +570,7 @@ export async function buildSet(input, prompts, { lastModified, current = () => u files['model/ids.toml'] = idsToml(current('model/ids.toml') ?? TEMPLATE['model/ids.toml'], owned, claims); if (!host) files['site/app.json'] = siteJson(set, router, claims); const perApp = [setSuite, ...models.map((m) => m.suite)].map((s) => `crates/conformance/tests/${s}.rs`); - return { files, remove: [...TEMPLATE_EXAMPLE, 'app/prompt.json', ...perApp].filter((p) => !(p in files)), set, models, router, claims }; + return { files, remove: [...TEMPLATE_EXAMPLE, 'app/prompt.json', 'app/src/Design.lex.tex', ...perApp].filter((p) => !(p in files)), set, models, router, claims }; } const SET_TESTS = 'crates/conformance/tests/contract.rs';