// tests/kb-update/test-priority-unverified.test.mjs // TDD for carry-forward B (Sesjon 5): a reference file WITHOUT a "Last updated:" // header must land in the 'unverified' priority bucket — not masquerade as // critical-priority noise (the bug: dateless files got effectiveDate 0000-01-01 // AND a path-based priority, so they flooded the critical tier and drowned the // genuinely-stale critical files). // // The decision lives in lag 0 (taxonomy.mjs makePriorityFn, the single source of // truth for priority); report-changes only supplies whether the file carried a // date header. The 'unverified' tier is declared in domain-taxonomy.json. import { test } from 'node:test'; import assert from 'node:assert/strict'; import { loadTaxonomy, makePriorityFn } from '../../scripts/kb-update/lib/taxonomy.mjs'; const tax = loadTaxonomy(); test('dateless file → unverified, NOT its path-based critical priority', () => { const prio = makePriorityFn(tax); const path = 'skills/ms-ai-security/references/cost-optimization/budget.md'; // Same path: dated → critical (path rule), dateless → unverified. assert.equal(prio(path, true), 'critical'); assert.equal(prio(path, false), 'unverified'); // The regression this fixes: dateless must never reach critical. assert.notEqual(prio(path, false), 'critical'); }); test('backward-compat: single-arg call behaves as before (hasDate defaults true)', () => { const prio = makePriorityFn(tax); assert.equal(prio('skills/ms-ai-security/references/cost-optimization/budget.md'), 'critical'); assert.equal(prio('skills/ms-ai-engineering/references/data-engineering/cosmos.md'), 'low'); }); test('dateless overrides every path tier (high/medium/low → unverified)', () => { const prio = makePriorityFn(tax); assert.equal(prio('skills/ms-ai-governance/references/responsible-ai/fairness.md', false), 'unverified'); assert.equal(prio('skills/ms-ai-advisor/references/platforms/copilot-studio.md', false), 'unverified'); assert.equal(prio('skills/ms-ai-engineering/references/data-engineering/cosmos.md', false), 'unverified'); }); test('taxonomy declares the dateless tier in lag 0 (source of truth)', () => { assert.equal(tax.priority.dateless, 'unverified'); });