config-audit/tests/scanners/lint-default-output.test.mjs
Kjell Tore Guttormsen 8216fb4175 test(snapshots): make byte/snapshot tests hermetic + re-seed baseline
The COL collision-scanner and the CLAUDE.md cascade resolve ~/.claude from
process.env.HOME (active-config-reader). Snapshot/byte CLIs were spawned with
the developer's real HOME, so they picked up installed plugins/skills and the
user CLAUDE.md — making the v5.0.0 + default-output snapshots machine- and
time-dependent. They were seeded 2026-05-01 with COL=1 (a real ~/.claude skill
collision) and drifted to COL=0 after the polyrepo split: 26 pre-existing
failures unrelated to Batch 1.

Fix (test-only, no production change):
- tests/helpers/hermetic-home.mjs — empty temp HOME, mirroring the pattern
  collision.test.mjs already uses for the COL unit test.
- 7 harnesses spawn CLIs (or call lint()) under the hermetic HOME, so output
  depends only on committed fixtures. Determinism verified across runs.
- Re-seeded all snapshots under hermetic HOME via SEED_SNAPSHOT/UPDATE_SNAPSHOT
  (added a SEED guard to the frozen v5.0.0 byte tests). Snapshots now reflect
  the fixture alone (COL=0, fixture-only activeConfig counts).
- Also re-seeded the unused env-aware snapshots (manifest/whats-active/
  plugin-health), which had baked dozens of real ~/.claude skill/plugin names
  into the committed repo — privacy cleanup.

Full suite: 812/812 green, stable across 3 runs.
2026-06-18 12:26:00 +02:00

27 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { resolve, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { lint } from '../lint-default-output.mjs';
import { withHermeticHome } from '../helpers/hermetic-home.mjs';
const __dirname = dirname(fileURLToPath(import.meta.url));
const REPO = resolve(__dirname, '../..');
const FIXTURE = resolve(REPO, 'tests/fixtures/marketplace-medium');
describe('SC-3 forbidden-words lint (default-output)', () => {
it('produces no tier1 or tier3 violations across the 6 prose CLIs', async () => {
// lint() spawns the prose CLIs inheriting process.env; HOME isolation keeps
// the COL collision scanner off the developer's real ~/.claude.
const { failures, warnings } = await withHermeticHome(() => lint(FIXTURE));
const failureSummary = failures
.map((f) => `[${f.cli}] tier${f.tier} "${f.word}" × ${f.count}`)
.join('\n ');
assert.equal(
failures.length,
0,
`SC-3 violations found:\n ${failureSummary}\n` +
`(${warnings.length} tier-2 warnings — informational only)`,
);
});
});