Make this repository the engines' home; the course copies from here
Whether the engines' changes went back to the course or the course took them from here was an open question (docs/engines.md). Soundness fixes to the prover cannot wait for a round trip through a repository with no engine tests, so this repository now owns the engines. - pixi run engines-export <course>/static builds and writes every engine module into the course's static/js/: JavaScript modules as written, TypeScript ones (logic, solver, vcgen) as built, without source maps. - pixi run engines-diff now shows what the course has not taken yet, comparing the file the course would receive with its copy. Both scripts share the list of modules in scripts/engines-files.mjs. - docs/engines.md describes the ownership, the prover's three modules and its number model, the soundness tests and the bugs found so far, the changes the course receives with the next export, and how to export. - AGENTS.md gains a hard rule: never let the prover call something proved that a run breaks, with how to add a soundness regression first. - docs/app.md's Known limits no longer sends engine fixes upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FgvbRdoEheAHqsRmr2WuKZ
This commit is contained in:
8 files changed
+151
-42
No files matched your search
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Copy this repository's language engines into a checkout of the course site.
|
||||
*
|
||||
* pixi run engines-export ../course/static
|
||||
*
|
||||
* This repository owns the engines (docs/engines.md); the course copies from
|
||||
* here. <static> is the course repository's static/ directory. For each
|
||||
* engine directory (pseudo, asm86, shared) every module goes to
|
||||
* <static>/js/<directory>/: a JavaScript module as written in src/engines/,
|
||||
* a TypeScript one (logic, solver, vcgen) as built into dist/engines/, which
|
||||
* is plain ES-module JavaScript the course's pages can import unchanged.
|
||||
* Source maps are not copied. Prints what it wrote, and changes nothing else
|
||||
* in the course. Review the course's diff before committing it there.
|
||||
*/
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { engineModules } from './engines-files.mjs';
|
||||
|
||||
const ROOT = fileURLToPath(new URL('..', import.meta.url));
|
||||
const dir = process.argv[2];
|
||||
if (!dir || !fs.existsSync(path.join(dir, 'js'))) {
|
||||
console.error('usage: pixi run engines-export <the course repository\'s static/ directory>');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
let wrote = 0, same = 0, added = 0;
|
||||
for (const m of engineModules(ROOT)) {
|
||||
if (!fs.existsSync(m.ours)) {
|
||||
console.error(`${m.label}: ${path.relative(ROOT, m.ours)} is missing; run pixi run build first`);
|
||||
process.exit(1);
|
||||
}
|
||||
const target = path.join(dir, 'js', m.dir, m.file);
|
||||
const text = fs.readFileSync(m.ours, 'utf8').replace(/\n\/\/# sourceMappingURL=.*\n?$/, '\n');
|
||||
const before = fs.existsSync(target) ? fs.readFileSync(target, 'utf8') : null;
|
||||
if (before === text) { same++; continue; }
|
||||
fs.mkdirSync(path.dirname(target), { recursive: true });
|
||||
fs.writeFileSync(target, text);
|
||||
if (before === null) { added++; console.log(`added js/${m.dir}/${m.file}${m.built ? ' (built from TypeScript)' : ''}`); }
|
||||
else { wrote++; console.log(`updated js/${m.dir}/${m.file}${m.built ? ' (built from TypeScript)' : ''}`); }
|
||||
}
|
||||
console.log(`\n${wrote} updated, ${added} added, ${same} already the same`);
|
||||
Reference in new issue
Block a user