fix(ms-ai-architect): Enhet 3b — dedup dual-**Dato:** i 5 mlops-genaiops-filer (Created-relabel/drop, git-verifisert) [skip-docs]

Løser dual-header der filer bærer BÅDE **Dato:** (opprettelse) OG **Last updated:**
(endring). Ground truth 2026-07-16 + git first-commit-map (2026-04-08 for alle 5):

- 4 distinkte (**Dato:** 2026-02-04, FØR git first-commit → ekte opprettelsesdato):
  relabel **Dato:** → **Created:**, verdi byte-bevart (norsk→engelsk label-rename).
- 1 identisk (mlops-security-access-control: **Dato:**=**Last updated:**=2026-06-19,
  ETTER git first-commit → metadata-artefakt, ikke ekte opprettelsesdato): drop redundant
  **Dato:**. Relabel ville påstått falsk opprettelsesdato — drop er sannferdig.

Ny ren primitiv dropRedundantBoldField (kaster uten identisk-verdi bevis-felt),
gjenbrukt relabelHeaderDialect m/ CREATED_MAP. Manifest-drevet dedup-dato.mjs med
hard per-fil-invariant FØR skriv (relabel: 1 linje, kun label-token; drop: net -1,
Last updated bevart), atomicWriteSync, idempotent. Ingen validator håndhever lukket
feltliste → **Created:** er additiv/konform.

+15 tester (dropRedundantBoldField, CREATED_MAP-relabel, applyOp, manifest, 2 corpus-
guards) + oppdatert stale Enhet-2 carve-out-guard til post-3b-sannhet. Suite 910/910
exit 0. validate-plugin 250 PASS/0 FAIL. Datoløse dual-**Dato:**-filer 5→0.
This commit is contained in:
Kjell Tore Guttormsen 2026-07-16 20:38:24 +02:00
commit f094e242d1
9 changed files with 394 additions and 10 deletions

View file

@ -500,6 +500,52 @@ export function dropRedundantPlainField(content, label) {
return lines.join('\n');
}
/**
* Remove a bold header field `**<dropLabel>:** <value>` that is provably redundant with a
* DIFFERENT bold field `**<proofLabel>:** <value>` carrying the IDENTICAL value (Enhet 3b dedup
* primitive for the dual-**Dato:** mlops-genaiops file whose creation date equals its last-updated
* date). The sibling of dropRedundantPlainField, but across two distinct bold labels rather than a
* plain/bold pair. Refuses to guess: if no proof field exists, or the two values differ, it THROWS
* (that is a human decision relabeling `**Dato:**``**Created:**` there would assert a creation
* date the file never truly had). No-op if the drop line is absent (idempotent). Operates in the
* header region only (`headerEndIndex`); body including any `**<dropLabel>:**` template line is
* byte-identical.
*
* @param {string} content full existing file content
* @param {string} dropLabel the label to remove, WITHOUT decoration, e.g. 'Dato'
* @param {string} proofLabel the label whose identical value proves redundancy, e.g. 'Last updated'
* @returns {string} content with the redundant bold line removed, or unchanged
* @throws if either label is blank, no proof field proves redundancy, or the values differ
*/
export function dropRedundantBoldField(content, dropLabel, proofLabel) {
const s = String(content ?? '');
const dl = String(dropLabel ?? '').trim();
const pl = String(proofLabel ?? '').trim();
if (dl === '') throw new Error('dropRedundantBoldField: dropLabel is required');
if (pl === '') throw new Error('dropRedundantBoldField: proofLabel is required');
const escD = dl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const escP = pl.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
const dropRe = new RegExp('^\\s*\\*\\*' + escD + ':\\*\\*\\s*(\\S.*?)\\s*$', 'i');
const proofRe = new RegExp('^\\s*\\*\\*' + escP + ':\\*\\*\\s*(\\S.*?)\\s*$', 'i');
const lines = s.split('\n');
const end = headerEndIndex(lines);
let dropIdx = -1;
let dropVal = null;
let proofVal = null;
for (let i = 0; i < end; i++) {
const dm = dropRe.exec(lines[i]);
if (dm && dropIdx === -1) { dropIdx = i; dropVal = dm[1]; }
const pm = proofRe.exec(lines[i]);
if (pm && proofVal === null) proofVal = pm[1];
}
if (dropIdx === -1) return s; // nothing to drop (idempotent)
if (proofVal === null) throw new Error(`dropRedundantBoldField: no bold **${pl}:** to prove **${dl}:** '${dropVal}' redundant`);
if (proofVal !== dropVal) throw new Error(`dropRedundantBoldField: **${dl}:** '${dropVal}' ≠ **${pl}:** '${proofVal}' — not redundant, human decision`);
lines.splice(dropIdx, 1);
return lines.join('\n');
}
/**
* Surgically insert-or-update ONLY the `**Verified:**` and `**Verified by:**` header lines
* on an EXISTING KB file the R7R10 born-verified STAMP primitive. Unlike composeKbFile