fix(docs): the trekbrief pass branch names no Brief Quality, and the stats rows span their blocks

Operator decision 21 (12.10).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-13 19:16:51 +02:00
commit 5b94952be9
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
3 changed files with 47 additions and 15 deletions

View file

@ -2079,17 +2079,49 @@ function schemaRow(id) {
}
// The Phase 9 line_ref was measured, then more prose landed above Phase 9 and
// nothing re-measured it. Pinned to the span it names: heading to closing fence.
test('the trekexecute Phase 9 row\'s line_ref spans the Phase 9 heading to the end of its stdin block', () => {
const ref = schemaRow('trekexecute-stats (Phase 9 record)')[4];
const m = ref.match(/^trekexecute\.md:(\d+)-(\d+)$/);
assert.ok(m, `line_ref "${ref}" is not trekexecute.md:A-B`);
const lines = read('commands/trekexecute.md').split('\n');
const heading = lines.findIndex((l) => /^## Phase 9\b/.test(l)) + 1;
const append = lines.findIndex((l) => /^\s*node \$\{CLAUDE_PLUGIN_ROOT\}\/lib\/stats\/stats-append\.mjs trekexecute\b/.test(l)) + 1;
const fence = lines.findIndex((l, i) => i >= append && l.trim() === '```') + 1;
assert.ok(heading > 0 && append > heading && fence > append, 'Phase 9 heading, stats-append line and closing fence');
assert.equal(ref, `trekexecute.md:${heading}-${fence}`);
// nothing re-measured it. The same drift hit the other command stats rows.
// Each row is pinned to the span it names: its phase heading to the closing
// fence of its stats-append stdin block. The trekreview anchor is the full
// "## Phase 8 — Validate output" so the Phase 8.5 / 8.7 headings never match.
const STATS_ROWS = [
{ id: 'trekbrief-stats', cmd: 'trekbrief', heading: /^## Phase 7\b(?!\.)/ },
{ id: 'trekplan-stats', cmd: 'trekplan', heading: /^## Phase 12\b(?!\.)/ },
{ id: 'trekreview-stats', cmd: 'trekreview', heading: /^## Phase 8 — Validate output/ },
{ id: 'trekexecute-stats (Phase 9 record)', cmd: 'trekexecute', heading: /^## Phase 9\b(?!\.)/ },
];
for (const { id, cmd, heading: headingRe } of STATS_ROWS) {
test(`the ${id} row's line_ref spans its phase heading to the end of its stats-append stdin block`, () => {
const ref = schemaRow(id)[4];
const m = ref.match(new RegExp(`^${cmd}\\.md:(\\d+)-(\\d+)$`));
assert.ok(m, `line_ref "${ref}" is not ${cmd}.md:A-B`);
const lines = read(`commands/${cmd}.md`).split('\n');
const headings = lines.map((l, i) => (headingRe.test(l) ? i : -1)).filter((i) => i >= 0);
assert.equal(headings.length, 1, `exactly one heading in commands/${cmd}.md matches ${headingRe}`);
const heading = headings[0] + 1;
const appendRe = new RegExp(`^\\s*node \\$\\{CLAUDE_PLUGIN_ROOT\\}/lib/stats/stats-append\\.mjs ${cmd}\\b`);
const append = lines.findIndex((l, i) => i >= heading && appendRe.test(l)) + 1;
const nextPhase = lines.findIndex((l, i) => i >= heading && /^## Phase /.test(l)) + 1;
assert.ok(append > heading, `a stats-append line follows the heading in commands/${cmd}.md`);
assert.ok(nextPhase === 0 || append < nextPhase, `the stats-append line sits inside the phase (line ${append}, next phase at ${nextPhase})`);
const fence = lines.findIndex((l, i) => i >= append && l.trim() === '```') + 1;
assert.ok(fence > append, 'the stats-append block has a closing fence');
assert.equal(ref, `${cmd}.md:${heading}-${fence}`);
});
}
// A `## Brief Quality` section belongs to the exhausted and force-stopped
// branches only; the passed-gate branch must not tell the model to write one.
test('trekbrief: the passed-gate branch names no `## Brief Quality`, the exhausted branch still does', () => {
const text = read('commands/trekbrief.md');
const passStart = text.indexOf('**If gate passes:**');
const passEnd = text.indexOf('**If gate fails AND iteration count < the class cap:**');
assert.ok(passStart >= 0 && passEnd > passStart, 'passed-gate branch markers');
assert.ok(!text.slice(passStart, passEnd).includes('## Brief Quality'), 'the passed-gate branch names `## Brief Quality`');
const exStart = text.indexOf('**If gate fails AND iteration count == the class cap (loop exhausted):**');
const exEnd = text.indexOf('### Step 4f', exStart);
assert.ok(exStart > passEnd && exEnd > exStart, 'exhausted branch markers');
assert.ok(text.slice(exStart, exEnd).includes('## Brief Quality'), 'the exhausted branch must still name `## Brief Quality`');
});
test('the autonomy-events row\'s line_ref spans emit() in event-emit.mjs', () => {