Skip to content

Embed and Automate: the Runner Library and CI Gates

Each example builds on the one before it — read the ladder in order, or jump to the rung you need. Every shipped artifact is regression-checked against the real CLI and library output.

  1. EMBED-AND-CI-01: Run the corpus in-process — Calling runCorpus once with a defineConfig config and reading back {findings, exitCode}.
  2. EMBED-AND-CI-02: Scope a subtree with cwd and globs — Narrowing a run to part of the tree with runCorpus’s cwd plus programmatic include/exclude.
  3. 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.
  4. EMBED-AND-CI-04: Gate a vitest suite on findings — Asserting on runCorpus’s findings inside a test so corpus drift fails the test run.
  5. EMBED-AND-CI-05: Fail CI on the exit code — Letting the CLI’s nonzero exit on error-level findings fail a CI job with no parsing.
  6. EMBED-AND-CI-06: Pre-commit gate on staged docs — Scoping a validate run to staged markdown in a git hook so commits with errors are blocked.
  7. EMBED-AND-CI-07: Parse JSON findings in a script — Emitting –format json and processing the stable Finding[] shape downstream.
  8. EMBED-AND-CI-08: Surface findings as code scanning — Producing –format sarif and uploading it so findings annotate the exact line on a PR.
  9. EMBED-AND-CI-09: Drift-gate with init –check — Using init –check to verify a tree still conforms to its inferred config as a pre-merge gate.
  10. EMBED-AND-CI-10: Map findings to editor diagnostics — Translating positioned Findings into editor diagnostics via Finding.pos and level.
  11. EMBED-AND-CI-11: Snapshot a stable baseline — Relying on the deterministic (line, col, plane) finding order to snapshot a baseline that diffs cleanly.