Lands Gosalyn's round 3 candidate,a2c72ac95(commit candidate, basec771a36f4), approved by Webby (29979, rev 2731). 21 paths: the new packages/library (src, tests, fixtures, package.json, README), scripts/stack-copy.sh (packages/library/src in COPY_PATHS), packages/cli/tests/stack-copy.test.mjs, scripts/mosaic and agents/gosalyn/work/queue-212/BUILD.md. The 21-path patch-id, ea84d3e35470, equals the candidate's. Evidence: Gosalyn's slot run on round 3: 20 files 451 pass, 0 fail; test-queue 28/0 (gosalyn-0086). Landing gate (Sage, 08:51-09:03Z, base4ced5e63d) on a tree that also held row 197's 32 paths: GATE_PASSED, node tests 981 pass 0 fail (library 39, cli 681, control-board 38, harness 16, webui 51, plus the scripts/test-*.sh node suites), selftests 429 passed 0 failed. Row 212 lands alone (mos-1162); row 197 waits for an r6 after its lane proof stopped. No 212 path changed betweenc771a36f4and this commit's parent. `queue review verify-commit 212` -> ok row 212 round 3:a2c72ac95matches the commit candidate (21 paths).
83 lines
5.9 KiB
JavaScript
83 lines
5.9 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { checkMapping, classify, LibraryError } from '../src/index.mjs';
|
|
import { mapping, mappingEntry } from './helpers.mjs';
|
|
|
|
const refuses = (change, code, pattern) => assert.throws(() => checkMapping(change(mappingEntry())),
|
|
e => e instanceof LibraryError && e.code === code && (!pattern || pattern.test(e.message)));
|
|
|
|
test('the fixture mapping checks and comes back frozen', () => {
|
|
const m = mapping();
|
|
assert.equal(m.universes.harbor.playground[0], 'Book One/Playground/');
|
|
assert.ok(Object.isFrozen(m.universes.harbor.books));
|
|
assert.throws(() => { m.types.Extra = 'place'; });
|
|
});
|
|
|
|
test('a playground prefix outside its universe books refuses library-playground-outside-book', () => {
|
|
refuses(e => { e.universes.harbor.playground = ['Second World/Playground/']; return e; }, 'library-playground-outside-book');
|
|
refuses(e => { e.universes.harbor.playground = ['Elsewhere/']; return e; }, 'library-playground-outside-book');
|
|
// The whole book as its playground would leave no canon: not inside the book.
|
|
refuses(e => { e.universes.harbor.playground = ['Book One/']; return e; }, 'library-playground-outside-book');
|
|
});
|
|
|
|
test('no playground prefix holds another, and no book folder holds another', () => {
|
|
refuses(e => { e.universes.harbor.playground = ['Book One/Playground/', 'Book One/Playground/Deep/']; return e; },
|
|
'library-mapping-invalid', /holds playground/);
|
|
refuses(e => { e.universes.second.books = ['Second World', 'Book One/Part Two']; return e; }, 'library-mapping-invalid', /holds book folder/);
|
|
refuses(e => { e.universes.second.books = ['Book One']; return e; }, 'library-mapping-invalid', /in two universes/);
|
|
});
|
|
|
|
test('shape refusals: kind, remote, branch, unknown keys, types, manuscript, folder names', () => {
|
|
refuses(e => ({ ...e, kind: 'code' }), 'library-mapping-invalid', /kind/);
|
|
refuses(e => ({ ...e, remote: 'http://git.example.invalid/x.git' }), 'library-mapping-invalid', /https/);
|
|
refuses(e => ({ ...e, remote: 'https://user:[email protected]/x.git' }), 'library-mapping-invalid', /credentials/);
|
|
refuses(e => ({ ...e, remote: '[email protected]:x.git' }), 'library-mapping-invalid', /https/);
|
|
refuses(e => ({ ...e, branch: 'main..x' }), 'library-mapping-invalid', /branch/);
|
|
refuses(e => ({ ...e, root: '/tmp' }), 'library-mapping-invalid', /unknown key "root"/);
|
|
refuses(e => { e.universes.harbor.extra = 1; return e; }, 'library-mapping-invalid', /unknown key/);
|
|
refuses(e => { e.types.Characters = 'villain'; return e; }, 'library-mapping-invalid', /types.Characters/);
|
|
refuses(e => { e.types['A/B'] = 'place'; return e; }, 'library-mapping-invalid', /one folder name/);
|
|
refuses(e => ({ ...e, manuscript: ['Characters'] }), 'library-mapping-invalid', /also a type folder/);
|
|
refuses(e => { e.universes.harbor.books = ['../Book One']; return e; }, 'library-mapping-invalid', /folder path/);
|
|
refuses(e => ({ ...e, vaultPrefix: 'a/b' }), 'library-mapping-invalid', /vaultPrefix/);
|
|
refuses(e => ({ ...e, universes: {} }), 'library-mapping-invalid', /at least one universe/);
|
|
refuses(e => { e.universes['bad id'] = e.universes.second; delete e.universes.second; return e; }, 'library-mapping-invalid', /plain id/);
|
|
});
|
|
|
|
test('a hybrid universe is a shape the query code can take (1.4), with sources that must exist', () => {
|
|
const hybrid = e => { e.universes.cross = { kind: 'hybrid', name: 'Crossover', sources: ['harbor', 'second'], books: ['Crossover'],
|
|
constraints: [{ exclude: 'second/Characters' }, { pin: { entity: 'Book One/Characters/Mara Vell.md', field: 'eyes', value: 'grey' } }],
|
|
notes: 'Set after book one.' }; return e; };
|
|
const m = checkMapping(hybrid(mappingEntry()));
|
|
assert.deepEqual(m.universes.cross.sources, ['harbor', 'second']);
|
|
refuses(e => { hybrid(e); e.universes.cross.sources = ['harbor', 'nowhere']; return e; }, 'library-mapping-invalid', /non-hybrid universe/);
|
|
refuses(e => { hybrid(e); e.universes.cross.sources = ['harbor']; return e; }, 'library-mapping-invalid', /two or more/);
|
|
refuses(e => { hybrid(e); e.universes.cross.constraints = [{ exclude: 'x', pin: {} }]; return e; }, 'library-mapping-invalid', /exactly one/);
|
|
});
|
|
|
|
test('a caller-supplied fail receives the code, as business file loading will pass it (C2-04)', () => {
|
|
const seen = [];
|
|
const fail = (code, message) => { seen.push(code); throw new Error(message); };
|
|
const entry = mappingEntry();
|
|
entry.universes.harbor.playground = ['Elsewhere/'];
|
|
assert.throws(() => checkMapping(entry, 'businesses/acme.json projects.books', { fail }), /businesses\/acme.json projects.books/);
|
|
assert.deepEqual(seen, ['library-playground-outside-book']);
|
|
});
|
|
|
|
test('scope comes from the path alone (design 1.2)', () => {
|
|
const m = mapping();
|
|
assert.deepEqual(classify(m, 'Book One/Characters/Mara Vell.md'),
|
|
{ scope: 'canon', universe: 'harbor', book: 'Book One', type: 'character', folder: 'Characters' });
|
|
assert.deepEqual(classify(m, 'Book One/Chapters/Chapter 01.md'),
|
|
{ scope: 'canon', universe: 'harbor', book: 'Book One', type: 'manuscript', folder: 'Chapters' });
|
|
assert.deepEqual(classify(m, 'Book One/Playground/What If.md'),
|
|
{ scope: 'playground', universe: 'harbor', book: 'Book One', type: null, folder: null });
|
|
assert.deepEqual(classify(m, 'Book One/Playground/Characters/New.md'),
|
|
{ scope: 'playground', universe: 'harbor', book: 'Book One', type: 'character', folder: 'Characters' });
|
|
assert.deepEqual(classify(m, 'Book One/Notes.md'), { scope: 'canon', universe: 'harbor', book: 'Book One', type: null, folder: null });
|
|
assert.equal(classify(m, 'Second World/Chapters/01.md').universe, 'second');
|
|
for (const path of ['Inbox Note.md', 'Book One/Board.canvas', 'Book One/Playground/Sketch.canvas', 'Book One/Board.base',
|
|
'Book One/cover.png', 'Book One/Upper.MD', 'Book Onex/a.md', 'book one/a.md', 'Elsewhere/Book One/a.md'])
|
|
assert.deepEqual(classify(m, path), { scope: 'unmapped' }, path);
|
|
});
|