variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// test/check-repo.mjs -- the repo's rules, enforced. Static scan of
|
|
|
|
|
// git-tracked files; no server needed:
|
|
|
|
|
// node test/check-repo.mjs
|
|
|
|
|
//
|
|
|
|
|
// 1. ASCII bytes everywhere (GM, 2026-11-15). No unicode in any
|
|
|
|
|
// tracked file; gitignored state (runs/, state/, server.json) is
|
|
|
|
|
// per-deployment and exempt. The ENCODING is the problem, never
|
|
|
|
|
// the visual: rendered glyphs travel ASCII-safe (\u escapes in
|
|
|
|
|
// JS, entities in HTML), never verbatim bytes.
|
|
|
|
|
// 2. No text-mutating CSS (GM, 2026-11-15). Rendered text must
|
|
|
|
|
// match authored text: no text-transform (any value, inline
|
|
|
|
|
// styles included), no generated content (content:, ::before and
|
|
|
|
|
// ::after included), no caps font variants. Authored content is
|
|
|
|
|
// fine -- want caps on screen, write caps in the source.
|
|
|
|
|
// 3. No HTML comments in prose or prompt files (GM, 2026-11-14):
|
|
|
|
|
// purpose descriptions live in README, AGENTS, or code comments.
|
|
|
|
|
// gm.md files are exempt -- GM-private, flagged to the GM, never
|
|
|
|
|
// agent-edited.
|
|
|
|
|
// 4. Retired terms stay retired (DICTIONARY rules the terms). The
|
|
|
|
|
// living prose -- README, the root prompts, the packages --
|
|
|
|
|
// never says: the wrap, prelude, paper (the old status), window
|
|
|
|
|
// (the old session; a line naming contwin may gloss it as the
|
|
|
|
|
// context window), turn-0, seed (memory.json is the name).
|
|
|
|
|
// Historical records keep the vocabulary of
|
|
|
|
|
// their day; gm.md is GM-private, flagged never fixed.
|
jsdoc typing round, phases 1-2: tsc as a no-emit checker over plain mjs (checkJs, strict), the shared shapes in server/shapes.mjs (log events as a tagged union, wire messages, manifests, job state, the ctx), all 12 server modules annotated; requireOwner/requireSuperuser as JSDoc assertion functions so the router guarantee narrows without callsite churn; runtime stays zero-dependency (typescript + @types/node as pinned devDeps, node_modules gitignored, QUESTIONS #4 amended: dev tooling exempt); every non-annotation delta audited onto a small intended list (clerk status ?? 1, dead 401 guards, async wraps on enqueue callsites); smoke 105/105 + restart + repo checks green; the clerk and web/ are the next phases
2026-11-15 15:28:56 +00:00
|
|
|
// 5. Zero-dependency runtime (GM, 2026-11-13, amended 2026-11-15):
|
|
|
|
|
// every import is node: builtin or relative -- no runtime deps,
|
|
|
|
|
// no package-manager requirement to run. Dev tooling is exempt
|
|
|
|
|
// (typescript rides devDependencies; nothing imports it).
|
variant round: roll retired, chance is variant literature (strict parse, crypto pick on reception, picked-only rendering, /story variance metric); entity round: /story the whole deliverable, /table the play projection, the slidwin carry (smart contwin cutoff, whole exchanges, housekeeper reads session-minus-tail); dormant-session rework: universal session lifecycle (dormant->live->finished, sessions/<n> storage), move-at-stop, start lint + auto-send rule, rebaseable housekeeping, turn-0 -> carryover.jsonl, seed -> memory.json, draft-only save-package; format house rules enforced by the nine-rule check-repo (ascii bytes, no text-mutating css); smoke 105/105 + restart + reminder + browser pass green, irene hand-migrated to the new layout
2026-11-15 14:35:00 +00:00
|
|
|
// 6. UTC discipline (GM, 2026-11-14): no locale- or timezone-
|
|
|
|
|
// dependent date formatting in code. No time zones, ever.
|
|
|
|
|
// 7. web/ static files never start with "api" -- the server's route
|
|
|
|
|
// guard matches the /api prefix, so web/api.mjs 404s as a bogus
|
|
|
|
|
// API route (bit once, 2026-11-14).
|
|
|
|
|
// 8. The bundle boundary (GM, 2026-11-14): server/bundle.mjs names
|
|
|
|
|
// neither gm.md (never model-facing) nor housekeeper.md (agent
|
|
|
|
|
// prompts never enter the bundle).
|
|
|
|
|
// 9. Seeds carry no date keys (GM, 2026-11-14): no model-facing
|
|
|
|
|
// surface renders a date; story time lives in prose.
|
|
|
|
|
|
|
|
|
|
import { execFileSync } from 'node:child_process';
|
|
|
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
|
|
|
|
|
|
let failures = 0;
|
|
|
|
|
const fail = (msg) => { console.log(`FAIL ${msg}`); failures++; };
|
|
|
|
|
|
|
|
|
|
const files = execFileSync('git', ['ls-files'], { encoding: 'utf8' }).split('\n').filter(Boolean);
|
|
|
|
|
const ROOT_PROMPTS = new Set(['system.md', 'invariants.md', 'handbook.md', 'housekeeper.md', 'reminder.md']);
|
|
|
|
|
const livingProse = (f) =>
|
|
|
|
|
f === 'README.md' || ROOT_PROMPTS.has(f)
|
|
|
|
|
|| (f.startsWith('packages/') && !f.endsWith('gm.md'));
|
|
|
|
|
// the checker's own source names what it bans (the rule patterns and
|
|
|
|
|
// their comments); it is exempt from the rules it defines
|
|
|
|
|
const isSelf = (f) => f === 'test/check-repo.mjs';
|
|
|
|
|
|
|
|
|
|
for (const f of files) {
|
|
|
|
|
const buf = readFileSync(f);
|
|
|
|
|
if (buf.includes(0)) continue; // binary -- no text rules to enforce
|
|
|
|
|
const text = buf.toString('utf8');
|
|
|
|
|
|
|
|
|
|
// rule 1: ascii bytes
|
|
|
|
|
text.split('\n').forEach((line, i) => {
|
|
|
|
|
for (const ch of line) {
|
|
|
|
|
if (ch.charCodeAt(0) > 0x7f) {
|
|
|
|
|
fail(`${f}:${i + 1} non-ascii U+${ch.charCodeAt(0).toString(16).padStart(4, '0')} "${ch}"`);
|
|
|
|
|
break; // one report per line is plenty
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// rule 2: no text-mutating css. text-transform is linted in every
|
|
|
|
|
// code file (it only ever appears as a css property -- inline
|
|
|
|
|
// style attributes included); content: and font-variant are css
|
|
|
|
|
// file checks (content is a common js object key, and the docs
|
|
|
|
|
// discuss the rule by name)
|
|
|
|
|
if (/\.(css|html|mjs|js)$/.test(f) && !isSelf(f)) {
|
|
|
|
|
text.split('\n').forEach((line, i) => {
|
|
|
|
|
if (/text-transform/i.test(line)) {
|
|
|
|
|
fail(`${f}:${i + 1} text-mutating css: text-transform`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (f.endsWith('.css')) {
|
|
|
|
|
const stripped = text.replace(/\/\*[\s\S]*?\*\//g, ''); // comments are prose, not style
|
|
|
|
|
stripped.split('\n').forEach((line, i) => {
|
|
|
|
|
if (/(?<![-\w])content:\s/.test(line)) {
|
|
|
|
|
fail(`${f}:${i + 1} text-mutating css: generated content (${line.trim().slice(0, 60)})`);
|
|
|
|
|
}
|
|
|
|
|
if (/font-variant[^;]*caps/.test(line)) {
|
|
|
|
|
fail(`${f}:${i + 1} text-mutating css: caps font variant`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rule 3: no html comments in prose/prompt files
|
|
|
|
|
if (f.endsWith('.md') && !f.endsWith('gm.md')) {
|
|
|
|
|
text.split('\n').forEach((line, i) => {
|
|
|
|
|
if (line.includes('<!--')) fail(`${f}:${i + 1} html comment in a prose file`);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rule 4: retired terms in living prose
|
|
|
|
|
if (livingProse(f)) {
|
|
|
|
|
text.split('\n').forEach((line, i) => {
|
|
|
|
|
if (/\bthe wrap\b/i.test(line)) fail(`${f}:${i + 1} retired term: "the wrap" (housekeeping)`);
|
|
|
|
|
if (/prelude/i.test(line)) fail(`${f}:${i + 1} retired term: "prelude" (turn-0)`);
|
|
|
|
|
if (/\bpaper\b/i.test(line)) fail(`${f}:${i + 1} retired term: "paper" (status)`);
|
|
|
|
|
// lowercase "window(s)" is the retired session; "Windows" the OS
|
|
|
|
|
// is consumed as-is; a line naming contwin may gloss its meaning
|
|
|
|
|
if (!/contwin/i.test(line) && /\bwindows?\b/.test(line)) {
|
|
|
|
|
fail(`${f}:${i + 1} retired term: "window" (session / contwin)`);
|
|
|
|
|
}
|
|
|
|
|
if (/turn-0/i.test(line)) fail(`${f}:${i + 1} retired term: "turn-0" (the carryover)`);
|
|
|
|
|
if (/\bseed(ed|s|ing)?\b/i.test(line)) fail(`${f}:${i + 1} retired term: "seed" (memory.json -- her starting memories)`);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rule 5: zero-dependency imports
|
|
|
|
|
if (f.endsWith('.mjs')) {
|
|
|
|
|
for (const m of text.matchAll(/from\s+['"]([^'"]+)['"]/g)) {
|
|
|
|
|
const spec = m[1];
|
|
|
|
|
if (!spec.startsWith('node:') && !spec.startsWith('./') && !spec.startsWith('../')) {
|
|
|
|
|
fail(`${f}: non-builtin import "${spec}" -- the stack is zero-dependency`);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rule 6: utc discipline
|
|
|
|
|
if (/\.(mjs|js)$/.test(f) && !isSelf(f)) {
|
|
|
|
|
text.split('\n').forEach((line, i) => {
|
|
|
|
|
if (/toLocale|getTimezoneOffset/.test(line)) {
|
|
|
|
|
fail(`${f}:${i + 1} locale/timezone-dependent formatting (UTC everywhere)`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rule 7: web static naming
|
|
|
|
|
if (f.startsWith('web/') && f.split('/').pop().startsWith('api')) {
|
|
|
|
|
fail(`${f}: a web/ static name starting with "api" 404s as a bogus API route`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rule 8: the bundle boundary
|
|
|
|
|
if (f === 'server/bundle.mjs') {
|
|
|
|
|
text.split('\n').forEach((line, i) => {
|
|
|
|
|
if (/gm\.md|housekeeper\.md/.test(line)) {
|
|
|
|
|
fail(`${f}:${i + 1} the bundle must not name gm.md or housekeeper.md`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// rule 9: dateless memory -- no model-facing surface renders a date;
|
|
|
|
|
// story time lives in prose
|
|
|
|
|
if (f === 'memory.json' || (f.startsWith('packages/') && f.endsWith('memory.json'))) {
|
|
|
|
|
text.split('\n').forEach((line, i) => {
|
|
|
|
|
if (/"[^"]*date[^"]*"\s*:/i.test(line)) {
|
|
|
|
|
fail(`${f}:${i + 1} a memory manifest carries a date key -- story time lives in prose`);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(failures ? `\n${failures} VIOLATIONS` : 'ALL CLEAN');
|
|
|
|
|
process.exit(failures ? 1 : 0);
|