refactor(#1170): remove hand-maintained INVENTORY count scalars (#1179)

* refactor(#1170): remove hand-maintained INVENTORY count scalars

The `(N shipped)` heading counts in docs/INVENTORY.md were absolute
scalars that collided silently on merge: two branches each bumping the
same integer to N+1 produced a clean git merge whose value the merged
filesystem (N+2) contradicted, hard-failing inventory-counts.test.cjs on
the CI merge commit across all platforms (DEFECT.INVENTORY-MERGE-UNDERCOUNT).

- Strip the six `(N shipped)` heading counts + the two prose footnote
  counts; repoint the intro to INVENTORY-MANIFEST.json as the registry.
- Drop the decorative `generated` date from the manifest + its
  strip-before-compare branch in gen-inventory-manifest.cjs (it conflicted
  on cross-day merges and is read by nothing).
- Delete inventory-counts.test.cjs (scalar-vs-disk gate, the collision
  source); its drift protection is subsumed by the merge-safe set-membership
  test inventory-manifest-sync.test.cjs, which stays as the sole gate.
- Add inventory-headings-countfree.test.cjs guard (fails if a count is
  re-added to a heading).
- Fix already-broken count-bearing cross-doc anchors to stable count-free
  slugs in ARCHITECTURE.md + multi-agent-orchestration.md.
- Retire the now-impossible DEFECT.INVENTORY-MERGE-UNDERCOUNT + obsolete
  RULESET.DOC-CONSISTENCY in CONTEXT.md; de-count DEFECT.INVENTORY-DRIFT;
  correct stale MANIFEST-CANONICAL-KEY (all six families canonical).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore(#1170): backfill changeset PR number (#1179)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-13 21:30:03 -04:00
committed by GitHub
parent b10e56818b
commit ae8bb707bc
9 changed files with 61 additions and 97 deletions

View File

@@ -1,64 +0,0 @@
// allow-test-rule: source-text-is-the-product
// Workflow .md / agent .md / command .md / reference .md files — their text
// IS what the runtime loads. Testing text content tests the deployed contract.
// Per CONTRIBUTING.md exception matrix.
'use strict';
/**
* Locks docs/INVENTORY.md's "(N shipped)" headline counts against the
* filesystem for each of the six families. INVENTORY.md is the
* authoritative roster — if a surface ships, its row must exist here
* and the headline count must match ls.
*
* Both sides are computed at test runtime — no hardcoded numbers.
*
* Related: docs readiness refresh, lane-12 recommendation.
*/
const { describe, 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_MD = path.join(ROOT, 'docs', 'INVENTORY.md');
const INVENTORY = fs.readFileSync(INVENTORY_MD, 'utf8');
const FAMILIES = [
{ label: 'Agents', dir: 'agents', filter: (f) => /^gsd-.*\.md$/.test(f) },
{ label: 'Commands', dir: 'commands/gsd', filter: (f) => f.endsWith('.md') },
{ label: 'Workflows', dir: 'gsd-core/workflows', filter: (f) => f.endsWith('.md') },
{ label: 'References', dir: 'gsd-core/references', filter: (f) => f.endsWith('.md') },
{ label: 'CLI Modules', dir: 'gsd-core/bin/lib', filter: (f) => f.endsWith('.cjs') },
{ label: 'Hooks', dir: 'hooks', filter: (f) => /\.(js|sh)$/.test(f) },
];
function headlineCount(label) {
const re = new RegExp(`^##\\s+${label}\\s+\\((\\d+)\\s+shipped\\)`, 'm');
const m = INVENTORY.match(re);
assert.ok(m, `docs/INVENTORY.md is missing the "## ${label} (N shipped)" header`);
return parseInt(m[1], 10);
}
function fsCount(relDir, filter) {
return fs
.readdirSync(path.join(ROOT, relDir))
.filter((name) => fs.statSync(path.join(ROOT, relDir, name)).isFile())
.filter(filter)
.length;
}
describe('docs/INVENTORY.md headline counts match the filesystem', () => {
for (const { label, dir, filter } of FAMILIES) {
test(`"${label} (N shipped)" matches ${dir}/`, () => {
const documented = headlineCount(label);
const actual = fsCount(dir, filter);
assert.strictEqual(
documented,
actual,
`docs/INVENTORY.md "${label} (${documented} shipped)" disagrees with ${dir}/ file count (${actual}) — update the headline and the row list`,
);
});
}
});

View File

@@ -0,0 +1,33 @@
// allow-test-rule: runtime-contract-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('\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'),
);
});