From 76df39670d8ba25276eaa1fa07bcc05d0bbfee8a Mon Sep 17 00:00:00 2001 From: Kjell Tore Guttormsen Date: Fri, 17 Jul 2026 03:43:04 +0200 Subject: [PATCH] =?UTF-8?q?feat(ms-ai-architect):=20RX-HDR=20oppl=C3=B8st?= =?UTF-8?q?=20=E2=86=92=20permanent=20R7-ustempelbar=20audit-signal=20(pre?= =?UTF-8?q?miss=2010=E2=86=922)=20[skip-docs]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Premiss-verifisering mot ground truth (simulert R7-stempler insertVerifiedFields over 327 non-advisor-filer): RX-HDR-populasjonen kollapser fra påstått 10 til 2. De 9 'base-felt forbi 500B'-filene er falske positiver — stempleren setter Verified øverst, uavhengig av hvor Status/Category ligger. Kun 2 filer er ekte ustempelbare (gpt5-gpt41-pricing-models, entra-agent-id-zero-trust): headere med fete **Status:**- prosahaler (175B/199B) der begge stempler (Verified + Verified by, judge-v3.1) ikke får plass i 500B. Feltomstokking løser dem ikke — verdi-slanking kreves (utenfor RX-HDRs scope), så de folder inn i R7s eksisterende 'header-slanking kreves'-flagg-sti. audit-corpus-headers.mjs: ny ren isStampable() kjører R7s ekte stempler med fast representativ probe (dato + judge-v3.1); per-fil 'stampable' + aggregat 'unstampable' + FLAG-liste. Gjør populasjonen permanent så den ikke stille kan vokse (gap-disiplin). +2 tester (dense→ustempelbar, clean→stampable). Suite 924→926 exit 0. --- scripts/kb-update/audit-corpus-headers.mjs | 30 ++++++++++++++++++ .../test-audit-corpus-headers.test.mjs | 31 +++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/scripts/kb-update/audit-corpus-headers.mjs b/scripts/kb-update/audit-corpus-headers.mjs index e838a60..fe1fe37 100644 --- a/scripts/kb-update/audit-corpus-headers.mjs +++ b/scripts/kb-update/audit-corpus-headers.mjs @@ -16,6 +16,7 @@ import { readdirSync, readFileSync, existsSync, realpathSync } from 'node:fs'; import { join, relative, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; import { atomicWriteJson } from './lib/atomic-write.mjs'; +import { insertVerifiedFields } from './lib/transform.mjs'; const __dirname = dirname(fileURLToPath(import.meta.url)); const PLUGIN_ROOT = join(__dirname, '..', '..'); @@ -78,6 +79,27 @@ const RE_FOOTER_META = // RE_FOOTER_META captures ("sist verifisert", "verifisert") is on the whitelist. const FOOTER_LABEL_LAST_UPDATED = 'sist oppdatert'; +// ── RX-HDR (dissolved → permanent audit signal): R7-unstampability ────────── +// RX-HDR was replanned as a 10-file header-slanking unit; premiss-verification collapsed +// the population to 1 — the only real class is a header so byte-dense that BOTH R7 stamps +// (**Verified:** + **Verified by:**) cannot fit inside the 500-byte window. insertVerifiedFields +// throws exactly there ("header-slanking required"), so the ground-truth test is to run the +// real stamper and catch the throw. Field-reorder cannot fix such a file (its meta lines carry +// fat prose tails needing a VALUE-slim — out of scope), so it folds into R7's existing +// "header-slanking kreves" flag path. This signal keeps the population from silently growing. +// A fixed representative stamp (deterministic; matches R7's byte-length: YYYY-MM-DD + judge-v3.1). +const STAMP_PROBE = { verified: '2026-01-01', verified_by: 'judge-v3.1' }; + +/** True iff R7's insertVerifiedFields can stamp this content within the 500-byte window. Pure. */ +function isStampable(content) { + try { + insertVerifiedFields(content, STAMP_PROBE); + return true; + } catch { + return false; + } +} + /** * Footer date-conflict for one file's full content. Returns null when there is no header * Last-updated date, no last-updated-equivalent footer, or all such footers agree on the @@ -130,6 +152,7 @@ function auditContent(content) { verified, plainVerified: RE_PLAIN_VERIFIED.test(head), footerConflict, + stampable: isStampable(content), }; } @@ -153,6 +176,7 @@ export function auditHeaders(paths, readFile = (p) => readFileSync(p, 'utf8')) { verifiedDuplicate: 0, plainVerifiedPipe: 0, footerConflicts: 0, + unstampable: 0, missingTitle: 0, missingStatus: 0, missingEnglishLastUpdated: 0, @@ -180,6 +204,7 @@ export function auditHeaders(paths, readFile = (p) => readFileSync(p, 'utf8')) { } if (r.plainVerified) aggregate.plainVerifiedPipe++; if (r.footerConflict) aggregate.footerConflicts++; + if (!r.stampable) aggregate.unstampable++; if (!r.title) aggregate.missingTitle++; if (!r.status) aggregate.missingStatus++; if (!r.lastUpdatedEnglish) aggregate.missingEnglishLastUpdated++; @@ -238,6 +263,11 @@ function main(argv) { if (!r.footerConflict) continue; console.log(` FLAG ${relative(PLUGIN_ROOT, abs)} — header ${r.footerConflict.headerLastUpdated} vs footer ${r.footerConflict.footerDates.join(', ')}`); } + console.log(` R7-unstampable (both stamps land past 500B → header-slanking kreves, R7 flag path): ${a.unstampable}`); + for (const [abs, r] of Object.entries(report.files)) { + if (r.stampable !== false) continue; + console.log(` FLAG ${relative(PLUGIN_ROOT, abs)} — insertVerifiedFields would throw (value-slim required)`); + } console.log(` Missing English Last updated: ${a.missingEnglishLastUpdated}`); console.log(` Missing Status: ${a.missingStatus}`); console.log(` Missing title: ${a.missingTitle}`); diff --git a/tests/kb-update/test-audit-corpus-headers.test.mjs b/tests/kb-update/test-audit-corpus-headers.test.mjs index 46b663c..6e4f459 100644 --- a/tests/kb-update/test-audit-corpus-headers.test.mjs +++ b/tests/kb-update/test-audit-corpus-headers.test.mjs @@ -228,3 +228,34 @@ test('auditHeaders — footer conflict needs BOTH a header date and a norsk foot assert.equal(r.files['b.md'].footerConflict, null); assert.equal(r.aggregate.footerConflicts, 0); }); + +// ── RX-HDR (dissolved → permanent audit signal): R7-unstampable detection ─── +// RX-HDR was replanned as a 10-file header-slanking unit. Premiss-verification against +// ground truth (simulating the real R7 stamper insertVerifiedFields over all 327 non- +// advisor files, 2026-07-17) collapsed the population to 1: only headers so byte-dense +// that BOTH stamps (**Verified:** + **Verified by:**) cannot fit inside the 500-byte +// window are truly "passing-men-ustempelbar". Field-reordering alone cannot fix such a +// file (its meta lines carry fat prose tails — a VALUE-slim is required, out of RX-HDR's +// scope), so the unit dissolved into R7's existing "header-slanking kreves" flag path. +// This signal makes the population permanent so it can never silently grow: the audit +// runs the exact stamper R7 uses (representative stamp date + judge-v3.1) and flags any +// file it would reject. [[gap-discipline-must-close]] — the lint signal IS the mechanism. + +// A header so dense that inserting Verified + Verified by lands past 500B — the +// gpt5-gpt41-pricing-models.md shape (a ~175B **Status:** prose tail). `---` sits at +// byte 500, so the two stamps (~53B) cannot fit however the meta lines are ordered. +const UNSTAMPABLE = + '# T\n\n**Last updated:** 2026-06\n**Status:** ' + 'GA '.repeat(140).trim() + + '\n**Category:** x\n**Type:** reference\n\n---\n\n## A\n\ntekst\n'; + +test('auditHeaders — a header too dense for R7 to stamp within 500B is flagged unstampable', () => { + const r = auditHeaders(['u.md'], reader({ 'u.md': UNSTAMPABLE })); + assert.equal(r.files['u.md'].stampable, false, 'dense header is not R7-stampable'); + assert.equal(r.aggregate.unstampable, 1); +}); + +test('auditHeaders — a conformant header is stampable and not counted unstampable', () => { + const r = auditHeaders(['f.md'], reader({ 'f.md': CLEAN })); + assert.equal(r.files['f.md'].stampable, true, 'clean header is R7-stampable'); + assert.equal(r.aggregate.unstampable, 0); +});