Files
msd-core/tests/inventory-headings-countfree.test.cjs
sim 6128f73003 test(#3090): normalize the whole reason line, not just the category token
The allow-test-rule gate keys on identity, and the identity it records is
everything after the colon on the annotation line — not the category token.
Ten annotations carried the canonical category plus a trailing justification
on the same line, so the recorded identity was a prose blob, and where the
prose wrapped it was a sentence fragment: `source-text-is-the-product — the
workflow .md content IS`.

Seven of those ten are ones this branch already rewrote. That pass renamed the
token and left the prose, which is the same error this wave exists to correct,
one level down: the label was fixed without checking what the machine reads.

Justifications move to the following comment line, which the scanner ignores
because it lacks the token. No annotation gains or loses an issue reference, so
no exemption changes compliance status; the allowlist goes 161 to 159 as two
files' duplicate identities collapse.

git-base-branch.test.cjs carried the token twice — once as the real annotation,
once echoed in docblock prose that the line scanner parsed as a second
exemption with a truncated identity. The echo is reworded to drop the literal
token.

intel.test.cjs:1360 was cut off mid-clause with an issue ref appended after the
break; its sentence is restored and the ref kept on the annotation line so it
stays compliant.

Every remaining non-canonical identity is an ESLint RuleTester fixture inside a
`code:` template literal, which the line scanner cannot tell apart from an
annotation. Those two stay grandfathered.

Refs #3057

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-05 18:28:04 -04:00

35 lines
1.3 KiB
JavaScript

// allow-test-rule: source-text-is-the-product
// INVENTORY.md heading format is the shipped doc surface being locked
'use strict';
/**
* Guards that docs/INVENTORY.md does NOT contain "(N shipped)" count
* scalars in section headings. Hard counts in shared-line headings cause
* silent undercount when two branches each add a module (DEFECT.INVENTORY-MERGE-UNDERCOUNT).
*
* Regression-must-fail-first: run this BEFORE removing the counts to confirm
* it catches the bad heading format, then after removal to confirm it passes.
*/
const { test } = require('node:test');
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const ROOT = path.resolve(__dirname, '..');
const INVENTORY_PATH = path.join(ROOT, 'docs', 'INVENTORY.md');
test('docs/INVENTORY.md has no "(N shipped)" count scalars in headings', () => {
const content = fs.readFileSync(INVENTORY_PATH, 'utf8');
const offenders = content
.split(/\r?\n/)
.filter((line) => /^##\s+.+\(\d+\s+shipped\)/.test(line));
assert.ok(
offenders.length === 0,
'docs/INVENTORY.md still has hard-count headings (DEFECT.INVENTORY-MERGE-UNDERCOUNT).\n' +
'Remove the "(N shipped)" parenthetical from each:\n' +
offenders.map((l) => ' ' + l).join('\n'),
);
});