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

+112
View File
@@ -0,0 +1,112 @@
// Stage 5: pseudo -> lingo. What is written must read (readSteps accepts it), must read as the same
// routines, must behave like the original once lowered back to pseudo, and writing it again from that
// pseudo must give the same lingo (a fixed point, comments aside). A program with no English form is
// reported as unsupported with a reason; the translator never writes lingo the reader would reject.
import test from 'node:test';
import assert from 'node:assert/strict';
import { programs, stripComments } from './helpers/sync-programs.mjs';
import { studyOf, runPseudo } from '../dist/services/pseudo.js';
import { readLingo, lowerLingo } from '../dist/services/lingo.js';
import { pseudoToLingo } from '../dist/sync/pseudo-to-lingo.js';
globalThis.localStorage = { getItem() { return null; }, setItem() { }, removeItem() { } };
const SUPPORTED_AT_LEAST = 31; // raise as English learns more forms; counted below
const run = (pseudo, call, input) => {
const st = studyOf(pseudo);
assert.ok(st.ok, 'pseudo should study');
const t = runPseudo(st, { call, input, maxSteps: 200000 });
return { out: t.output.map((l) => l.replace(/^\w+ returned /, 'returned ')), err: t.error ? t.error.kind : null };
};
function judge(p) {
if (!studyOf(p.pseudo).ok) return { verdict: 'no-pseudo' };
const r = pseudoToLingo(p.pseudo);
if ('unsupported' in r) return { verdict: 'unsupported', r };
const parsed = readLingo(r.source);
if (!parsed.ok) return { verdict: 'unread', detail: parsed.diagnostics.map((d) => d.message).join(' | '), r };
const low = lowerLingo(parsed, 'pseudo');
if (!low) return { verdict: 'unlowered', r };
return { verdict: 'ok', r, low };
}
const verdicts = new Map();
test('every program: the lingo reads, lowers to pseudo that behaves like the original, and is a fixed point; or the program is reported unsupported', () => {
const problems = [];
let supported = 0;
for (const p of programs()) {
const j = judge(p);
verdicts.set(p.id, j);
if (j.verdict === 'no-pseudo' || j.verdict === 'unsupported') continue;
if (j.verdict !== 'ok') { problems.push(`${p.id}: ${j.verdict}: ${j.detail ?? ''}`); continue; }
supported++;
// same behavior: the call (or the input-driven main) gives the same output and the same kind of stop
const want = run(p.pseudo, p.call, p.input);
let got;
try { got = run(j.low.source, p.call, p.input); } catch (e) { problems.push(`${p.id}: lowered pseudo does not study: ${e.message}`); continue; }
if (JSON.stringify(want) !== JSON.stringify(got)) problems.push(`${p.id}: behavior differs: ${JSON.stringify(want).slice(0, 120)} vs ${JSON.stringify(got).slice(0, 120)}`);
// fixed point
const again = pseudoToLingo(j.low.source);
if ('unsupported' in again) { problems.push(`${p.id}: the lowered pseudo is no longer supported`); continue; }
if (stripComments(again.source) !== stripComments(j.r.source)) problems.push(`${p.id}: not a fixed point`);
}
assert.deepEqual(problems, []);
assert.ok(supported >= SUPPORTED_AT_LEAST, `${supported} programs have English, fewer than ${SUPPORTED_AT_LEAST}`);
});
test('a program with no English form is unsupported with a located reason, not a crash', () => {
let n = 0;
for (const p of programs()) {
const j = verdicts.get(p.id) ?? judge(p);
if (j.verdict !== 'unsupported') continue;
n++;
assert.ok(j.r.unsupported.length > 0, p.id);
for (const d of j.r.unsupported) {
assert.ok(Number.isInteger(d.line) && d.line >= 1, `${p.id}: line`);
assert.ok(d.message.length > 0, p.id);
}
}
assert.ok(n > 0);
});
test('the line map has one entry per output line and points inside the pseudo', () => {
for (const p of programs()) {
const j = verdicts.get(p.id) ?? judge(p);
if (j.verdict !== 'ok') continue;
const lines = j.r.source.replace(/\n$/, '').split('\n');
assert.equal(j.r.map.length, lines.length, p.id);
const n = p.pseudo.split('\n').length;
for (const m of j.r.map) assert.ok(m === null || (Number.isInteger(m) && m >= 1 && m <= n), `${p.id}: ${m}`);
}
});
test('the English is plain: a counting loop and a sum read the way a student would say them', () => {
const r = pseudoToLingo(`FUNCTION SUM_TO(N : INTEGER) RETURNS INTEGER
DECLARE Total : INTEGER
Total <- 0
FOR I <- 1 TO N
Total <- Total + I
NEXT I
RETURN Total
ENDFUNCTION
`);
assert.ok(!('unsupported' in r), JSON.stringify(r));
assert.ok(readLingo(r.source).ok, r.source);
assert.ok(/Total/.test(r.source));
});
test('pseudo that does not parse is unsupported, and records have no English form', () => {
const bad = pseudoToLingo('FUNCTION F(\n');
assert.ok('unsupported' in bad && bad.unsupported.length > 0);
const rec = pseudoToLingo(`RECORD P
X : INTEGER
ENDRECORD
FUNCTION F(A : INTEGER) RETURNS INTEGER
DECLARE R : P
R.X <- A
RETURN R.X
ENDFUNCTION
`);
assert.ok('unsupported' in rec, 'records are left unsupported by design');
});