Skip to content

EMBED-AND-CI-03: Route subtrees with first-match rules

Mapping different globs to different contracts in one config where the first matching rule wins.

Builds on: EMBED-AND-CI-01: Run the corpus in-process

A TypeScript program against the library API; inline comments show the resulting values and behavior.

const config = defineConfig({
rules: [
{ include: ["tasks/**/*.md"], contract: taskContract },
{ include: ["decisions/**/*.md"], contract: decisionContract },
{ include: ["**/*.md"], contract: fallbackContract }, // catch-all, last
],
});
const { findings } = runCorpus(config, { cwd: "docs/planning" });
  • CorpusConfig.rules ordering
  • first-match routing across multiple contracts