the packager, reshaped on calibration evidence: the character to lift, no chunks, markdown extraction, one call per job -- plus the roles inventory, staged earlier and verified in its own sitting
The who: a source usually holds several characters, so the request names the character to lift, in the caller's own words (required in character mode, optional in full mode where the seat rules stand unnamed). A named character who is not a woman, or one who never appears in the material, refuses loud: the model answers REFUSED with one line naming who and why, nothing lands (the route cannot gender a name or know who appears; the model can). The mode-split rule lands in the prompt the same round: her voice may run in thought, speech, and writing, the modes may sound different, they are never blended into one averaged voice, and when her thoughts never reach the page nothing is invented -- how her thinking shows, as observable behavior, is the record. The lift-her-not-the-narrator rules ride with it: her voice is only what she herself says or writes, and names are not identity. The calibration program (the developer's design, run on a real book): planted-invariant passages for the voice extraction first, then a full multi-character calibration -- a named side character lifted from a narrator-voiced source, the alias tracking deliberately in-test with no hints on the request. The verdicts, each total. The chunked pipeline silently distilled the wrong woman with every gate green: the chunks where she never appears each filled the her-slot with the narrator, and the blind merge had no way to know, so no chunks, ever -- the full source in one read, and a source that does not fit the spec's contwin refuses before the job starts with the arithmetic and both fixes (compact it, or pick a wider contwin; compaction is the caller's editorial act). Five malformed distillates across the runs were all one disease -- the dropped closing brace of the her-object, one character repairs it every time -- so the distillate is markdown now: formal syntax lives exactly where machinery consumes it (the draft's file sections, the carryover, the memory manifest) and nowhere else. And the pass-count A/B (character mode and full mode, same book, same who, same cut) ruled one call per job: extraction sections then the files in a single output, split at the first file marker, the extraction retained as the audit artifact -- composing with the source in view is what kept the narrator's devices out of her portrait, a property of the shape, not a prompt line. Machinery: the fit check (source chars/4 plus a named 32K-token overhead against the registry's input ceiling; a 413 over it naming the arithmetic, a 400 when the ceiling is unknown, never a guess), the REFUSED prefix checked on every output, distill.md and draft.txt retained per job, the receipt naming the extraction and draft sizes, the mock serving the canned pair concatenated, steps total two. The chunker, the whole knob, the assemble pass, and the JSON refusal shape are all deleted (no-legacy). Huge-source distillation goes to ROADMAP's distant shelf with the folded-sweep design recorded so a future round starts from it; the flake doctrine stands as practiced -- hand-repair, the evidence in the calibration material. The roles inventory rides along as staged: every human and inferencer seat named (the developer, the assistant, the op, a run's GM, the package author, the reader; the player, the housekeeper, the curator, the clerk, the packager), the vocabulary swept, the retired class words lint-banned, "model" kept as the machinery's noun. Verified: typecheck green on both programs, smoke ALL PASS through every reshape (who required, the refusal case, the oversized-source arithmetic, the one-call receipt with its split), check-repo clean, the debug server on the new code over the real state. The developer's red pen on packager.md is the next act: it is the assistant's draft, the exact text every calibration output was produced from, and one edit lands on the survivor.
This commit is contained in:
+113
-1
@@ -45,11 +45,12 @@
|
||||
// Leaves its token + run ids in a temp file for restart-check.mjs.
|
||||
// Clean up afterwards: Remove-Item state/, delete the smoke runs.
|
||||
|
||||
import { readFileSync, writeFileSync, appendFileSync } from 'node:fs';
|
||||
import { readFileSync, writeFileSync, appendFileSync, readdirSync, existsSync } from 'node:fs';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { join, dirname } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { renderView, lintCarryover } from '../server/session.mjs';
|
||||
import { noCloneGate, splitDraft } from '../server/packager.mjs';
|
||||
|
||||
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const BASE = process.env.RP_BASE ?? 'http://127.0.0.1:7350';
|
||||
@@ -699,6 +700,117 @@ ok("the handbook round-trips (the package's own beats the repo default)",
|
||||
r.data.files['handbook.md']?.content?.includes('unique-to-the-fork') === true,
|
||||
JSON.stringify((r.data.files['handbook.md']?.content ?? '').slice(0, 60)));
|
||||
|
||||
// 14d. the packager (developer, 2026-11-19): literature into scaffold
|
||||
// packages. Two modes -- character (her only, over the template base)
|
||||
// and full (character + setting, the cut in the caller's words); the
|
||||
// material rides as tool output; the gates refuse before anything
|
||||
// lands; settings are the caller's, never the model's. The smoke
|
||||
// fixture is original synthetic prose (a desert monastery library) --
|
||||
// never a real source; the mock world serves canned outputs.
|
||||
{
|
||||
const FIXTURE = [
|
||||
'The monastery sat where the salt road ended, a box of yellow stone with one tower, and Sister Vell kept its library the way her order had for two hundred years: by hand, by candle, and by a ledger nobody outside the walls had ever read.',
|
||||
'The books came in with the caravans twice a year, bought by the pound from estate sales in cities the sisters had never seen. A book that arrived damp was dried page by page in the tower, and a book that arrived torn was copied before it was shelved, because the order held that a text exists only while someone can still read it.',
|
||||
'This season the caravan brought eleven crates and one locked case with no manifest, and the caravan master would say only that it was paid through to the monastery and that he had not looked inside, which Sister Vell wrote down in the ledger as a fact about him rather than a fact about the case.',
|
||||
].join('\n\n');
|
||||
const poll = async () => {
|
||||
for (let i = 0; i < 100; i++) {
|
||||
const s = await call('/packager', { token: op });
|
||||
if (s.data.state !== 'running') return s.data;
|
||||
await new Promise((res) => setTimeout(res, 100));
|
||||
}
|
||||
return { state: 'stuck' };
|
||||
};
|
||||
// the gate units, first: a planted overlap refuses, and sections
|
||||
// parse whole (the probe's first-line truncation lesson)
|
||||
ok('the no-clone gate catches a verbatim overlap',
|
||||
noCloneGate(FIXTURE, { 'character.md': `She wrote it down in the ledger as a fact about him rather than a fact about the case, and moved on.` }).clean === false,
|
||||
'a planted 7-word clone passed the gate');
|
||||
ok('the no-clone gate passes clean prose',
|
||||
noCloneGate(FIXTURE, { 'character.md': 'She keeps a private ledger of facts about people, which is a habit and not an accusation, and it has never once been wrong about the weather.' }).clean === true,
|
||||
'clean prose refused');
|
||||
{
|
||||
const secs = splitDraft('=== backdrop.md ===\nline one of the world.\nline two of the world.\n=== character.md ===\nher, entire.');
|
||||
ok('the draft splitter reads whole sections', secs['backdrop.md'] === 'line one of the world.\nline two of the world.' && secs['character.md'] === 'her, entire.',
|
||||
JSON.stringify(secs));
|
||||
}
|
||||
// the validation surface
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'nope', name: 'x', pc: 'y', source: FIXTURE } });
|
||||
ok('a bad mode refuses', r.status === 400, r.data.error ?? '');
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'full', name: 'x', pc: 'y', source: FIXTURE } });
|
||||
ok('full mode requires the cut', r.status === 400 && /cut/.test(r.data.error), r.data.error ?? '');
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'full', name: 'x', pc: 'y', cut: 'at the end', source: '' } });
|
||||
ok('the source is required', r.status === 400 && /source/.test(r.data.error), r.data.error ?? '');
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'character', name: 'x', pc: 'y', source: FIXTURE, spec: { provider: 'mock-a', model: 'nope', effort: 'max' }, who: 'Sister Vell' } });
|
||||
ok('a bad spec refuses', r.status === 400 && /not usable/.test(r.data.error), r.data.error ?? '');
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'character', name: 'x', pc: 'y', source: FIXTURE } });
|
||||
ok('character mode requires who (the character to lift)', r.status === 400 && /who/.test(r.data.error), r.data.error ?? '');
|
||||
// character mode: her only, over the template base
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'character', name: 'Coastal Light', pc: 'Vell', who: 'Sister Vell, the librarian', records: true, source: FIXTURE } });
|
||||
ok('a character packaging starts', r.status === 200 && ['running', 'applied'].includes(r.data.state), JSON.stringify(r.data));
|
||||
const charJob = await poll();
|
||||
ok('the character packaging lands', charJob.state === 'applied' && !!charJob.package?.id, JSON.stringify(charJob));
|
||||
ok('one call: extraction then files in a single output',
|
||||
(charJob.lines?.[0] ?? '').startsWith('packaged:') && /extraction \d+, draft \d+/.test(charJob.lines?.[0] ?? ''),
|
||||
JSON.stringify({ first: charJob.lines?.[0] ?? null }));
|
||||
const charPkg = charJob.package?.id;
|
||||
r = await call('/packages', { token: op });
|
||||
const charEntry = r.data.find((p) => p.name === charPkg);
|
||||
ok('the landed package is a scaffold with the caller\'s settings',
|
||||
!!charEntry && charEntry.scaffold === true && charEntry.display === 'Coastal Light' && charEntry.pc === 'Vell' && charEntry.records === true && charEntry.origin === 'user' && charEntry.ownerName === 'Op',
|
||||
JSON.stringify(charEntry ?? null));
|
||||
r = await call(`/packages/${charPkg}/files`, { token: op });
|
||||
ok('character mode overwrites character.md only (her, distilled)',
|
||||
r.data.files['character.md']?.content?.includes('@PC') === true && r.data.files['character.md'].content.includes('keep the light') === true,
|
||||
JSON.stringify((r.data.files['character.md']?.content ?? '').slice(0, 80)));
|
||||
ok('the template base holds the un-drafted files',
|
||||
r.data.files['backdrop.md']?.content?.trim() === readFileSync(`${ROOT}/packages/template/backdrop.md`, 'utf8').trim()
|
||||
&& r.data.files['carryover.jsonl']?.content?.trim() === readFileSync(`${ROOT}/packages/template/carryover.jsonl`, 'utf8').trim(),
|
||||
'an un-drafted file drifted from the template base');
|
||||
// the refusal: a named character who is not a woman refuses loud,
|
||||
// nothing lands (the mock's cue is the fixture's own caravan master)
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'character', name: 'The Caravan Master', pc: 'x', who: 'the caravan master', source: FIXTURE } });
|
||||
ok('a character packaging starts (the refusal case)', r.status === 200 && ['running', 'rejected'].includes(r.data.state), JSON.stringify(r.data));
|
||||
const refusedJob = await poll();
|
||||
ok('not-a-woman refuses loud, nothing lands',
|
||||
refusedJob.state === 'rejected' && /is a man/.test(refusedJob.reason ?? '') && refusedJob.package === null,
|
||||
JSON.stringify(refusedJob));
|
||||
// the fit check (developer, 2026-11-20): no chunks ever -- the
|
||||
// full source in one read, and an oversized source refuses with
|
||||
// the arithmetic (mock's contwin: 524288 tokens; the threshold is
|
||||
// (contwin - overhead) * 4 chars, so build past it explicitly)
|
||||
let HUGE = FIXTURE;
|
||||
while (HUGE.length < (524288 - 32_000) * 4 + 4096) HUGE += '\n\n' + FIXTURE;
|
||||
r = await call('/packager', { method: 'POST', token: op, body: { mode: 'character', name: 'Too Big', pc: 'Vell', who: 'Sister Vell, the librarian', source: HUGE } });
|
||||
ok('an oversized source refuses with the arithmetic',
|
||||
r.status === 413 && /contwin/.test(r.data.error) && /compact/.test(r.data.error),
|
||||
r.data.error ?? '');
|
||||
// full mode: the whole file set, the cut riding the assemble call
|
||||
r = await call('/packager', { method: 'POST', token: ash, body: { mode: 'full', name: 'The Salt Road', pc: 'Vell', records: false, cut: 'cut where she writes the case into the ledger; the caravan is still in the courtyard', source: FIXTURE } });
|
||||
ok('any user can package (a full packaging starts)', r.status === 200, r.data.error ?? JSON.stringify(r.data));
|
||||
const fullJob = await poll();
|
||||
ok('the full packaging lands', fullJob.state === 'applied' && !!fullJob.package?.id, JSON.stringify(fullJob));
|
||||
const fullPkg = fullJob.package?.id;
|
||||
r = await call(`/packages/${fullPkg}/files`, { token: ash });
|
||||
ok('full mode drafts every file over the base',
|
||||
r.data.files['backdrop.md']?.content?.includes('the point and the harbour') === true
|
||||
&& r.data.files['gm.md']?.content?.includes('non-canon') === true
|
||||
&& r.data.files['memory.json']?.content?.includes('"session": "0"') === true,
|
||||
JSON.stringify(Object.fromEntries(Object.entries(r.data.files).map(([k, v]) => [k, (/** @type {{ content?: string }} */ (v)).content?.slice(0, 40) ?? '']))));
|
||||
ok('the landed gm.md marks the proposals non-canon (full intel, GM-proposed, not truth)',
|
||||
/proposals/i.test(r.data.files['gm.md']?.content ?? '') && /non-canon/i.test(r.data.files['gm.md']?.content ?? ''),
|
||||
(r.data.files['gm.md']?.content ?? '').slice(0, 80));
|
||||
ok('the caller\'s settings landed (never a model output)',
|
||||
JSON.parse(readFileSync(`${ROOT}/state/packages/${fullPkg}/settings.json`, 'utf8')).pc === 'Vell',
|
||||
readFileSync(`${ROOT}/state/packages/${fullPkg}/settings.json`, 'utf8'));
|
||||
// the spent source: derived material retained, the book deleted
|
||||
const workdirs = readdirSync(`${ROOT}/state/packager`).sort();
|
||||
const last = `${ROOT}/state/packager/${workdirs[workdirs.length - 1]}`;
|
||||
ok('the source is deleted after the run (derived material retained)',
|
||||
!existsSync(`${last}/source.txt`) && existsSync(`${last}/draft.txt`),
|
||||
`${workdirs[workdirs.length - 1]}: ${readdirSync(last).join(', ')}`);
|
||||
}
|
||||
|
||||
// 15. op revokes ash -- identity destroyed, data stays
|
||||
r = await call(`/users/${ashId}/revoke`, { method: 'POST', token: op, body: {} });
|
||||
ok('revoke ash', r.status === 200, r.data.error ?? '');
|
||||
|
||||
Reference in New Issue
Block a user