Add the library page, and pin core with sized types and the library

core 477dffe brings pseudo's sized types (INT8..UINT64, FLOAT32), exact
numerical built-ins, USE IEEE, and USE for pplus-library, its new
submodule: 16 routines checked at every level.

- #/library (src/ui/library.ts): every routine by module with a count
  of how its checks ended; a routine's page shows its pseudo, cases and
  results, every check with its detail, each reference implementation
  with its note, tolerance and source, the Dafny proof and the sources.
- Open in the Bridge: a routine opens as the problem lib:<id>
  (src/core/library.ts), its first case as the call, so it can be
  stepped through; the problem menu names it.
- Library in the site nav; README, docs/app.md and AGENTS.md updated.
- Two Quarto examples expected "X_BAR returned 3" for a FLOAT result;
  core now prints it in its type, 3.0.

Gate: site 113 pass; core 332 pass; library-check no failing check.
Manual check: #/library lists 16 routines with chips; a routine's page
shows numbered pseudo, cases, checks; Open in the Bridge steps through
NeedlemanWunschScore; no console 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 12:19:08 +00:00
1 parent 2bc297644c
commit bd51349967
14 files changed
+280 -13

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
// The library page (#/library, src/ui/library.ts) and a library routine opened in the Bridge (src/core/library.ts):
// every routine of core's registry is listed with its checks, and opens as a problem that runs.
import test from 'node:test';
import assert from 'node:assert/strict';
import { installDocument } from '../dist/quarto/dom.js';
installDocument();
const { parseRoute, routeFor } = await import('../dist/core/state.js');
const { libraryModules, libraryState, checksOf, tally, LIBRARY_PREFIX } = await import('../dist/core/library.js');
const { Session } = await import('../dist/core/session.js');
test('routes: #/library and #/library/<id>, and a routine opens under the problem id lib:<id>', () => {
assert.deepEqual(parseRoute('#/library'), { kind: 'library' });
assert.deepEqual(parseRoute('#/library/md.LennardJones'), { kind: 'library', id: 'md.LennardJones' });
assert.equal(routeFor({ kind: 'library', id: 'md.LennardJones' }), '#/library/md.LennardJones');
assert.deepEqual(parseRoute('#/bridge/p/lib:md.LennardJones'), { kind: 'problem', area: 'bridge', id: 'lib:md.LennardJones' });
assert.equal(libraryState('lib:md.NoSuch'), null);
assert.equal(libraryState('count-base'), null);
});
test('every routine opens in the Bridge with its pseudo and its first case, and runs to that case\'s result', () => {
let n = 0;
for (const m of libraryModules()) for (const r of m.routines) {
n++;
const st = libraryState(`${LIBRARY_PREFIX}${r.id}`);
assert.equal(st.sources.pseudo, r.source);
assert.equal(st.call, r.cases[0].call);
const session = new Session(st, { area: 'bridge' });
const tr = session.trace('pseudo');
assert.equal(tr.error, null, `${r.id}: ${tr.error?.message}`);
assert.equal(tr.output.at(-1), `${r.name} returned ${r.cases[0].result}`, r.id);
// stepping into the routine is the point of opening it: its own lines are in the run
assert.ok(tr.steps.some((s) => s.line > 1 && s.kind !== 'call'), `${r.id}: the run shows none of the routine's lines`);
}
assert.ok(n >= 16);
});
test('the page lists every routine with its checks, and each routine\'s page shows its source, cases, references and checks', async () => {
const { libraryView } = await import('../dist/ui/library.js');
const index = libraryView();
const text = index.textContent;
for (const m of libraryModules()) {
assert.ok(text.includes(m.title), m.title);
for (const r of m.routines) assert.ok(text.includes(r.name), r.id);
}
const r = libraryModules().find((m) => m.name === 'md').routines.find((x) => x.name === 'LennardJones');
const page = libraryView(r.id);
const t = page.textContent;
assert.ok(t.includes('Open in the Bridge'));
assert.ok(t.includes(`USE ${r.id}`));
for (const c of r.cases) assert.ok(t.includes(c.call) && t.includes(c.result), c.call);
for (const ref of r.references) assert.ok(t.includes(`${ref.lang} · ${ref.level}`), `${ref.lang}/${ref.level}`);
assert.equal(page.querySelectorAll('.lib-chip').length >= checksOf(r).length, true);
assert.ok(libraryView('md.NoSuch').textContent.includes('No such routine'));
const t2 = tally(r);
assert.equal(t2.fail, 0);
});