T-C4Q0-intersect-registry
Status: closed/done · Impact: medium · Complexity: small
Implement index() over labeled pattern-sets — throwing on a duplicate id,
retaining registration order — and Registry.applicableTo(scope) /
matching(path) returning the applicable ids in registration order, so the
“which guidelines/standards apply to this scope” query (DR-0014) works.
The registry surface and its fixtures exist as stubs from T-FGMJ; the path
API it builds on is implemented by T-IRYT.
| Location | Role today |
|---|---|
plugin/lib/intersect/registry.ts | Registry surface — throwing stubs. |
plugin/lib/intersect/index.ts | The path-API primitives it builds on. |
plugin/lib/intersect/fixtures/registry.cases.json | Registry spec, all pending. |
Proposed
Section titled “Proposed”index(entries) compiles each entry once, throws on a duplicate id, and keeps
entry order; applicableTo(scope) returns the ids whose set overlaps scope,
matching(path) the ids whose set matches a concrete path — both in registration
order. Registry fixtures are active and green.
Approach
Section titled “Approach”index(entries, opts): iterate entries in order; reject a duplicateidwith a clearErrornaming the id; compile each entry’spatternsto aMatcher(via the path API’scompile); store{ id, matcher }in order.applicableTo(scope): for each entry in order, keep itsidiff its matcher intersectsscope.matching(path): for each entry in order, keep itsidiff its matcher matchespath.- Expose
entriesas a readonly, ordered view. - Flip
registry.cases.jsonto active.
Files to touch
Section titled “Files to touch”| Location | Kind | Change |
|---|---|---|
plugin/lib/intersect/registry.ts | modify | Implement index / Registry. |
plugin/lib/intersect/fixtures/registry.cases.json | modify | Activate. |
Acceptance criteria
Section titled “Acceptance criteria”- AC-1: All
registry.cases.jsoncases pass;bun test plugin/lib/intersectis green. - AC-2: Registering the same
idtwice throws, and the error message contains the offending id. - AC-3: A fixture that registers entries in a deliberately non-alphabetical order asserts that
applicableToandmatchingreturn ids in registration order, not sorted. - AC-4:
registry.tsimports only from the path API (./index), not the fs layer;bunx tsc --noEmitpasses.
Out of scope
Section titled “Out of scope”- The filesystem layer —
T-ZAZO. - Precedence resolution (picking a winner): the registry returns ordered ids; the caller applies precedence, per PR-0002-intersect boundary.
Dependencies
Section titled “Dependencies”- Requires the implemented path API from
T-IRYT.
Discovery context
Section titled “Discovery context”- Motivated by DR-0014; the registry section of
D-4FRD-intersect-apilayered-api.md.
Depends on
Section titled “Depends on”T-IRYT