fix(trekexecute): run_seen is kept in progress.json and reported on every path

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kjell Tore Guttormsen 2026-10-26 17:05:43 +01:00
commit 33ef2c1b3a
Signed by: ktg
SSH key fingerprint: SHA256:JakMjO6FTBBzN0Bhfj9saOoEjaFxlSdYuZQQpM/lF9Q
4 changed files with 70 additions and 2 deletions

View file

@ -33,6 +33,9 @@
// `auto_result: manual`.
// K2 /trekbrief's Step 6a "Cancel — do manual" row runs Phase 7 with
// `auto_result: cancelled`, like the sentence after the table.
// E14 /trekexecute keeps `run_seen` in the progress file (template, field
// table, Phase 7) and Phase 8 reads it from there, so the resume and
// multi-session paths report it; Handover 5 lists it as optional.
// E17a The two /trekresearch wave 2 sentences on outbound queries are pinned
// exactly (red under the E17a mutation).
// E17b The deep-research adapter says where wave 2's contrarian findings merge.
@ -357,6 +360,61 @@ test('[DJ2] the high-effort loop names the model for a turn that spawns', () =>
assert.doesNotMatch(loop, /model: "opus"/, 'the per-turn protocol pins a spawn to model: "opus"');
});
// --- E14 ---------------------------------------------------------------------------
/** The progress-file template of /trekexecute's Phase 3, parsed as JSON. */
function progressTemplate() {
const block = between('commands/trekexecute.md', '### Progress file schema', '**The step-loop fields');
const m = block.match(/```json\n([\s\S]*?)\n```/);
assert.ok(m, 'the Progress file schema section holds no ```json block');
return JSON.parse(m[1]);
}
test('[E14] the progress template carries run_seen', () => {
const tpl = progressTemplate();
assert.ok(Object.prototype.hasOwnProperty.call(tpl, 'run_seen'),
'the progress template has no top-level run_seen field');
assert.equal(tpl.run_seen, null, `the progress template's run_seen is not null: ${JSON.stringify(tpl.run_seen)}`);
assert.ok(!Object.prototype.hasOwnProperty.call(tpl.steps['1'], 'run_seen'),
'run_seen sits in the per-step record, not at the top level');
});
test('[E14] the field table describes run_seen', () => {
const table = between('commands/trekexecute.md', '**The step-loop fields', '**The coupling fields');
const rows = table.split('\n').filter((l) => l.startsWith('| `run_seen` |'));
assert.equal(rows.length, 1, `the step-loop field table must hold exactly one run_seen row; found ${rows.length}`);
const cells = rows[0].split(' | ');
assert.match(cells[1], /^Phase 7$/, `the run_seen row is not written in Phase 7: ${rows[0]}`);
assert.match(rows[0], /Claude Code's (built-in )?`run`/, `the run_seen row does not say it is what Claude Code's run showed: ${rows[0]}`);
assert.match(rows[0], /`null` = not run/, `the run_seen row does not say null = not run: ${rows[0]}`);
});
test('[E14] Phase 8 reads run_seen from progress.json', () => {
const p7 = between('commands/trekexecute.md', '### End to end — "run the thing"', '### Architecture rules (K5)');
const rec = sentencesWith(p7, 'Record `run_seen`');
assert.equal(rec.length, 1, `Phase 7 must hold one "Record \`run_seen\`" sentence; found ${rec.length}`);
assert.match(rec[0], /\bin the progress file\b|\bto the progress file\b|`progress\.json`/,
`Phase 7 records run_seen without writing it to the progress file: ${rec[0]}`);
const p8 = between('commands/trekexecute.md', '## Phase 8 — Final report', '## Phase 9 — Stats tracking');
const hits = sentencesWith(p8, '`run_seen`');
const ok = hits.find((s) => /\bread\b|\breads\b/.test(s)
&& /progress file|`progress\.json`/.test(s)
&& /\*\*Seen with `run`:\*\*/.test(s)
&& /summary/.test(s)
&& /resume/.test(s) && /multi-session/.test(s));
assert.ok(ok, `no Phase 8 sentence says the Seen with run line and the summary's run_seen are read from the progress file, so the resume and multi-session paths report it: ${hits.join(' | ')}`);
});
test('[E14] Handover 5 lists run_seen as optional', () => {
const h5 = between('docs/HANDOVER-CONTRACTS.md', '## Handover 5 ', '## Handover 6 ');
const rows = h5.split('\n').filter((l) => l.startsWith('| `run_seen` |'));
assert.equal(rows.length, 1, `Handover 5 must hold exactly one run_seen row; found ${rows.length}`);
const cells = rows[0].split(' | ');
assert.equal(cells[2], 'optional', `the run_seen row's Required cell is not "optional": ${rows[0]}`);
assert.match(rows[0], /additive/, `the run_seen row does not say the field is additive: ${rows[0]}`);
assert.match(rows[0], /Phase 7/, `the run_seen row does not say Phase 7 records it: ${rows[0]}`);
});
// --- E17a / E17b / Da / E18a / Db --------------------------------------------------
// E17a, E18a and Db are already right at be0b631; their tests are proven red
// under the E17a, E18a and Db entries of tests/fix-round-4-5b-mutations.mjs.