Move the engine core into core/, a project of its own (pplus-core)

What programs mean (the languages, translators, Mojo checker and
interpreter, prover, fuzzer, machine model, catalog problems and the Mojo
corpus with godbolt's stored answers) was mixed into the site's tree, so a
change to the prover and a change to a button went through the same gate
and the same docs. This moves all of it under core/, laid out as its own
repository, ready to be extracted with its history and pinned here as a
git submodule.

- core/: src/{engines,services,sync,mojo,exercises,curriculum,common},
  mojo/, syntax/mojo.xml, its tests (with Workspace and workForProblem in
  place of the site's Session), scripts (corpus pipeline, play, the
  exercise and probe starters, engines export/diff), and its docs
  (engines, trust, mojo-corpus, exercises, coverage). Its own pixi.toml,
  package.json, README, AGENTS.md and CI workflow.
- core/tests/boundary.test.mjs: library modules use no DOM, import no
  page widget, and import nothing outside src/.
- core/scripts/cli.mjs: pixi run cli check|run|prove|fuzz|translate.
- core/scripts/dafny.py: Dafny 4.11.0 pinned by version and SHA-256 per
  platform, fetched into .tools/ (pixi run dafny-fetch, pixi run dafny).
- The site imports core only as #core/<path>.js: an import map in
  index.html, "imports" in package.json for node, core's declarations for
  tsc. The site's TypeScript builds core first (npm run build).
- assemble.sh, the Quarto engine copy, the render cache key, check-pages,
  quarto-export and quarto-css read core/dist and core/mojo; quarto-css
  copies core's syntax/mojo.xml into the extension.
- Site tests that covered engines moved to core; the rest keep Session.
- README, AGENTS.md, docs/app.md, docs/deploy.md and the CI workflow
  describe the split (checkout with submodules; core's tests and corpus
  status run against the pinned commit).

Gate: site 110 pass; core 307 pass; corpus status --strict passes.
Manual check: the assembled site opens Bridge (count-base-proved),
Developer and Hardware (count-base) with the editor, the stepper and the
board, and no module errors.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
This commit is contained in:
alexmandClaude committed 2026-10-05 05:43:58 +00:00
1 parent f43bbfe0cf
commit 82e18f7966
1567 files changed
+3670 -981

No files matched your search

+75
View File
@@ -0,0 +1,75 @@
// scripts/mojo/listings.mjs: godbolt's saved answers become x86-64 panes, and the program <-> exercise links hold.
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import { stripHeader, readHeader, findGolden, buildListing, render } from '../scripts/mojo/listings.mjs';
import { forSimulator, simulatorSetup } from '../dist/mojo/att.js';
import { listingFunctions } from '../dist/services/godbolt.js';
import { parseAsm } from '../dist/services/asm.js';
const ROOT = new URL('..', import.meta.url).pathname;
const GOLDEN = ROOT + 'mojo/golden';
const mods = { forSimulator, simulatorSetup, listingFunctions };
test('stripHeader drops what emit_ts.py drops, and says how many lines went', () => {
const text = '# origin: x\n# probe: y\n# mode: both\n\ndef main():\n pass\n';
const { source, dropped } = stripHeader(text);
assert.equal(source, 'def main():\n pass\n');
assert.equal(dropped, 4); // three header lines and the blank one after
assert.equal(stripHeader('# a comment, not a header key\ndef f(): pass').dropped, 0);
});
test('readHeader reads the keys verify.py knows and ignores other comments', () => {
const h = readHeader('# probe: q\n# mode: both\n# args: -O0 --debug-level=line-tables\n# a note\n# expect: pass\ndef main(): pass');
assert.equal(h.mode, 'both');
assert.equal(h.args, '-O0 --debug-level=line-tables');
assert.equal(h.expect, 'pass');
assert.equal(h.note, undefined);
});
test('a golden is used only for the exact source, mode and arguments it answered', () => {
const probe = fs.readFileSync(ROOT + 'mojo/probes/godbolt-line-tables-O0.mojo', 'utf8');
const h = readHeader(probe);
assert.ok(findGolden(GOLDEN, probe, h.mode, h.args ?? ''), 'the committed answer for this probe is found');
assert.equal(findGolden(GOLDEN, probe + ' ', h.mode, h.args ?? ''), null, 'one extra character and the answer no longer applies');
assert.equal(findGolden(GOLDEN, probe, 'run', h.args ?? ''), null, 'a run-mode question is a different question');
});
test('real godbolt answers become x86-64 panes the assembler accepts, with lines that point into the shown source', () => {
let made = 0;
for (const f of fs.readdirSync(ROOT + 'mojo/probes').filter((x) => x.endsWith('.mojo'))) {
const text = fs.readFileSync(ROOT + 'mojo/probes/' + f, 'utf8');
if (!/^# mode: (asm|both)/m.test(text)) continue;
const r = buildListing(text, GOLDEN, mods);
if (r.why) continue; // e.g. built without -O0, so the optimizer inlined every function
made++;
const p = parseAsm(r.asm);
assert.ok(p.ok, `${f}: ${p.diagnostics[0]?.message}`);
assert.match(r.setup, /^#/, `${f}: the setup starts with the comment saying where the arguments arrive`);
const shown = stripHeader(text).source.split('\n').length;
for (const m of r.asm.matchAll(/; mojo line (\d+)/g)) assert.ok(+m[1] >= 1 && +m[1] <= shown, `${f}: line ${m[1]} is outside the ${shown}-line program the pane shows`);
}
assert.ok(made >= 1, 'at least one committed probe has a usable listing; if none does, the corpus lost its assembly');
});
test('a program with no answer, or one that was never asked for a listing, says why instead of inventing one', () => {
assert.match(buildListing('# mode: both\n# args: -O0\ndef main(): print(1)\n', GOLDEN, mods).why, /no godbolt answer/);
assert.match(buildListing('def main(): print(1)\n', GOLDEN, mods).why, /mode: both/);
});
test('render keeps the header and interface, and writes programs in name order', () => {
const out = render({ zeta: { entry: 'z(Int)', asm: 'z:\n ret', setup: '# z', build: '' }, alpha: { entry: 'a(Int)', asm: 'a:\n ret', setup: '# a', build: '-O0' } });
assert.match(out, /export interface MojoListing/);
assert.ok(out.indexOf('"alpha"') < out.indexOf('"zeta"'));
assert.ok(out.endsWith('};\n'));
});
test('every exercise that names a Mojo program has that program in mojo/local/', () => {
const dir = ROOT + 'src/exercises/';
const missing = [];
for (const f of fs.readdirSync(dir).filter((x) => x.endsWith('.ts') && !x.startsWith('_'))) {
const m = /mojoProgram:\s*['"]([^'"]+)['"]/.exec(fs.readFileSync(dir + f, 'utf8'));
if (m && !fs.existsSync(ROOT + `mojo/local/${m[1]}.mojo`)) missing.push(`${f} -> mojo/local/${m[1]}.mojo`);
}
assert.deepEqual(missing, [], 'create the file, or remove `mojoProgram` from the exercise; until then `pixi run play` will not regenerate programs.ts, because the catalog would throw');
});