feat(acr,yaml): v5.6 Foundation — load-pattern enumeration + block-seq parser
Foundation chunk of v5.6 "steering-model II" (internal plumbing for B/C;
no command-output change, so --json/--raw/SC-5/6/7 stay byte-stable, count
stays 13).
active-config-reader.mjs:
- deriveLoadPattern(kind,{scoped}) — pure helper mapping each source kind to
loadPattern {always,on-demand,external} + survivesCompaction {yes,no,n/a}
+ derivationConfidence {confirmed,inferred}, traced to the published
loading model (V-rows in docs/v5.5-steering-model-plan.md).
- enumerateRules / enumerateAgents / enumerateOutputStyles — the three
source kinds previously unenumerated (mirror enumerateSkills). Output-style
discovery is direct (not a new file-discovery type) to keep the discovery
surface stable.
- readActiveConfig now exposes rules/agents/outputStyles arrays + totals
counts/subtotals (folded into grandTotal).
yaml-parser.mjs:
- parseSimpleYaml now reads YAML block sequences (paths:\n - a), not just
inline paths:. An empty-valued key with no `- ` items stays null
(backcompat). Resolves a pre-existing RUL false-positive (a block-seq-scoped
rule was misread as unscoped) — fix flows through unchanged RUL code.
Tests +35 (961 -> 996): block-seq parser cases, RUL block-seq regression
(no-misflag + durability-fires), deriveLoadPattern table, three enumerators
(positive+negative). Amended two existing ACR asserts (top-level key shape +
grandTotal sum). self-audit A/A, readmeCheck passed, mismatches []. tests
badge 961+->996+; README testing prose de-staled (635/36 -> 996/56);
CLAUDE.md Foundation note.
B (manifest/tokens render + snapshot regen) and C (CA-OST, count->14)
deferred to their own sessions/GO.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ter3E2JSi1Khgmuf2kady8
This commit is contained in:
parent
d03c3831bd
commit
62d910ed6d
8 changed files with 575 additions and 25 deletions
|
|
@ -151,3 +151,52 @@ describe('RUL — large path-scoped rule lost after compaction (A)', () => {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('RUL — block-sequence-scoped rule is correctly scoped (parser regression)', () => {
|
||||
// A rule scoped with a YAML block sequence:
|
||||
// paths:
|
||||
// - src/**/*.ts
|
||||
// was previously misread as unscoped (the lightweight parser only read inline
|
||||
// `paths:`), so a large one wrongly fired the "unscoped" finding AND silently
|
||||
// skipped the compaction-durability finding. The parser block-sequence fix
|
||||
// flows through unchanged rules-validator code.
|
||||
let tmpRoot;
|
||||
let result;
|
||||
|
||||
async function writeBlockSeqProject(root, ruleBodyLines) {
|
||||
await mkdir(join(root, '.claude', 'rules'), { recursive: true });
|
||||
await mkdir(join(root, 'src'), { recursive: true });
|
||||
await writeFile(join(root, 'src', 'foo.ts'), 'export {};\n', 'utf8');
|
||||
const body = Array.from({ length: ruleBodyLines }, (_, i) => `- rule ${i + 1}`).join('\n');
|
||||
// YAML block-sequence paths: form (the regression target).
|
||||
await writeFile(
|
||||
join(root, '.claude', 'rules', 'scoped-seq.md'),
|
||||
`---\npaths:\n - "src/**/*.ts"\n---\n\n# Scoped rule\n${body}\n`,
|
||||
'utf8',
|
||||
);
|
||||
}
|
||||
|
||||
beforeEach(async () => {
|
||||
resetCounter();
|
||||
tmpRoot = await mkdtemp(join(tmpdir(), 'ca-rul-blockseq-'));
|
||||
await writeBlockSeqProject(tmpRoot, 60);
|
||||
const discovery = await discoverConfigFiles(tmpRoot);
|
||||
result = await scan(tmpRoot, discovery);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
if (tmpRoot) await rm(tmpRoot, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it('does NOT misflag a block-sequence-scoped rule as unscoped', () => {
|
||||
const f = result.findings.find(x => x.scanner === 'RUL' && /unscoped/i.test(x.title || ''));
|
||||
assert.equal(f, undefined,
|
||||
`block-sequence-scoped rule wrongly flagged unscoped; got: ${result.findings.map(x => x.title).join(' | ')}`);
|
||||
});
|
||||
|
||||
it('DOES flag the block-sequence-scoped large rule as lost after compaction (low)', () => {
|
||||
const f = result.findings.find(x => x.scanner === 'RUL' && /compaction/i.test(x.title || ''));
|
||||
assert.ok(f, `expected durability finding; got: ${result.findings.map(x => x.title).join(' | ')}`);
|
||||
assert.equal(f.severity, 'low');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue