fix(ms-ai-architect): RX-KB1 strip stale plain-Verified pipe-tails (87) + audit-deteksjon [skip-docs]

De 87 referansefilene bar en plain-text `| Verified: <dato>`-hale på **Last updated:**-linjen
i 500B-header-vinduet — usynlig for den bold-only kontrakt-stacken (kb-headers.mjs / audit
RE_VERIFIED), og claimet en verifisering judgen aldri gjorde (samme poison-klasse som de 14
bold **Verified:** MCP Spor 1 fjernet). Uhåndtert springer den også dual-Verified-fellen: R7s
insertVerifiedFields ville stemplet en bold-verdi ved siden av den plain → to motstridende
provenance-claims per fil.

- ny driver strip-stale-verified-pipe.mjs: frosset 87-manifest (18 advisor + 45 eng + 8 gov +
  16 sec), pure verdi-bevarende strip (kun ` | Verified: …`-halen; **Last updated:**-dato
  byte-eksakt), hard per-fil-invariant (linjeantall uendret, body byte-identisk, dato bevart),
  idempotent, atomicWriteSync (RX-OPS2 recovery-kontrakt).
- audit-corpus-headers.mjs: ny plain-Verified-deteksjon (RE_PLAIN_VERIFIED + plainVerifiedPipe)
  — gjør M4-blindheten synlig så en stale plain-hale ikke kan gjenoppstå stille (non-advisor scope).
- 87 filer strippet; plain Verified i vinduet 0/389; live-audit plainVerifiedPipe 0.

Mekanisme: +15 tester (12 strip + 3 audit). Suite 875→890 exit 0. validate-plugin.sh 250/0.

Utsatt → RX-KB1b: footer-dato-avvik + label-whitelist (annen dialekt, flag-to-human).
This commit is contained in:
Kjell Tore Guttormsen 2026-07-16 20:04:52 +02:00
commit 712a143e58
91 changed files with 478 additions and 87 deletions

View file

@ -33,6 +33,13 @@ const V_PIPE =
'# T\n\n**Sist oppdatert:** 2026-06-17 | **Verified:** MCP 2026-06-17\n\n---\n\n' +
'## A\n\ntekst\n';
// PLAIN (non-bold) Verified pipe-tail on the **Last updated:** line — the 87-file RX-KB1
// shape. Invisible to the bold-only RE_VERIFIED (verified stays null), which is exactly the
// M4 blindness; the audit must surface it via a SEPARATE plainVerified signal.
const V_PLAIN_PIPE =
'# T\n\n**Last updated:** 2026-06-19 | Verified: MCP 2026-06-19\n\n---\n\n' +
'## A\n\ntekst\n';
// Base-field gap: no **Status:** at all.
const NO_STATUS =
'# T\n\n**Category:** x\n**Last updated:** 2026-06\n\n---\n\n## A\n\ntekst\n';
@ -128,6 +135,28 @@ test('auditHeaders — conformant file raises no flags; aggregate counts add up
assert.equal(r.aggregate.missingTitle, 0);
});
test('auditHeaders — plain (non-bold) Verified pipe-tail is surfaced, though bold RE_VERIFIED is blind to it', () => {
const r = auditHeaders(['p.md'], reader({ 'p.md': V_PLAIN_PIPE }));
const f = r.files['p.md'];
assert.equal(f.verified, null, 'bold-only RE_VERIFIED does not see the plain tail (M4)');
assert.equal(f.plainVerified, true, 'the plain tail IS surfaced by the new signal');
assert.equal(r.aggregate.plainVerifiedPipe, 1);
});
test('auditHeaders — a bold **Verified:** is NOT counted as plainVerified', () => {
// both the header-bold and pipe-bold fixtures must leave plainVerified false
const r = auditHeaders(['a.md', 'd.md'], reader({ 'a.md': V_NONDATE, 'd.md': V_PIPE }));
assert.equal(r.files['a.md'].plainVerified, false);
assert.equal(r.files['d.md'].plainVerified, false);
assert.equal(r.aggregate.plainVerifiedPipe, 0);
});
test('auditHeaders — a clean file with no Verified at all has plainVerified false', () => {
const r = auditHeaders(['f.md'], reader({ 'f.md': CLEAN }));
assert.equal(r.files['f.md'].plainVerified, false);
assert.equal(r.aggregate.plainVerifiedPipe, 0);
});
test('auditHeaders — an unreadable file is reported, not thrown', () => {
const r = auditHeaders(['x.md'], () => { throw new Error('ENOENT'); });
assert.equal(r.files['x.md'].error !== undefined, true);