Live Demo: Rules Catalog
These are real entries from IntentWeave’s own .iw/rules.yaml —
the same file that powers iw intent check in this repo’s CI. Two structural rules
enforce package layer isolation (import graph); three behavioral rules use inline
Mermaid sequence diagrams to assert the CARI build pipeline calls its stages in order.
Violation counts and the sample evidence below are from the most recent iw intent check --domain all run.
arch-core-is-foundation ✓ clean @intentweave/core is the foundation layer. It must not import from any higher-level package (analyzer, index, cli, server-core, server-open). A violation creates a dependency cycle that makes the platform un-treeshakeable and prevents independent use of core types.
| Pattern | Scope |
|---|---|
@intentweave/analyzer | packages/core/** |
@intentweave/index | packages/core/** |
@intentweave/cli | packages/core/** |
@intentweave/server-core | packages/core/** |
@intentweave/server-open | packages/core/** |
arch-no-upward-index ✓ clean @intentweave/index (CARI Evidence Engine) must not import from @intentweave/cli. The index is a library layer below the CLI. An upward import would create a cycle and prevent use of @intentweave/index in contexts outside the CLI (MCP servers, plugins, CI scripts).
| Pattern | Scope |
|---|---|
@intentweave/cli | packages/index/src/** |
bdd-build-pipeline-required-stages
⚠ 1 violation The CARI build pipeline (buildFromPaths in facade.ts) must run all four required stages in order: AST extraction (runAxStage), IDF scoring (computeIdf), annotation matching (annotate), and SQLite write (buildIndex). Skipping any stage breaks the index: - No runAxStage: no symbols, no call graph, empty index - No computeIdf: all terms score equally, annotations are noisy - No annotate: doc mentions never linked to code symbols - No buildIndex: pipeline runs but nothing is persisted Verified via Phase 4 call graph (0.95 confidence / error) when call data is present; falls back to import graph (0.70 / warn) otherwise.
bdd-writer-complete-pipeline
⚠ 4 violations The index writer (buildIndex in writer.ts) must run its full write sequence on every build: schema init, symbols, annotations, imports, and the Phase 4 call graph. Critical invariants: - initSchema first: missing tables corrupt subsequent writes - writeSymbols: foundation for all CARI queries - writeAnnotations: without them, retrieve/connections return nothing - writeCalls: Phase 4 behavioral checks require call edges (must_call) Verified via Phase 4 call graph (0.95 confidence / error) when call data is present; falls back to import graph (0.70 / warn) otherwise.
bdd-rules-check-db-lifecycle ✓ clean The intent check entry-point (rulesCheck in queries/rulesCheck.ts) must open the SQLite database via openIndex() before calling rulesCheckFromDb(). openIndex() configures WAL mode, busy_timeout, and read pragmas. Bypassing it risks reading a locked DB or leaving WAL files open. Verified via Phase 4 call graph (0.95 confidence) when call data is present; falls back to import graph check (0.70) otherwise.
How This Works
Section titled “How This Works”- Structural rules (
type: import_pattern) are checked against the import graph CARI already builds duringiw index build— zero LLM calls, sub-second. - Behavioral rules express intent as an inline Mermaid
sequenceDiagram. CARI parses it with a zero-dependency regex extractor (no@mermaid-js/parser, no DOM) and checks each edge against thesymbol_callstable (Phase 4 call graph, 0.95 confidence) — or falls back to the import graph (0.70 confidence, warn) when call-graph data isn’t available yet. - Every violation carries a
detailstring that names the exact caller/callee pair and file — the same evidence surfaced iniw intent check, the Insights Book’s Rules Catalog chapter, and thecari_rules_checkMCP tool.
# .iw/rules.yaml — behavioral rule, checked via the call graph- id: bdd-writer-complete-pipeline domain: behavioral severity: high mode: error source: type: mermaid_inline mermaid: | sequenceDiagram buildIndex->>initSchema: create tables if not exist buildIndex->>writeSymbols: persist extracted code symbols buildIndex->>writeAnnotations: persist doc-to-symbol annotation links buildIndex->>writeImports: persist import graph edges buildIndex->>writeCalls: persist call graph edges (Phase 4) forbidden: []# Reproduce this locally, on your own rules.yamliw intent check --domain all --format jsonSee the full Semantic Rule Checking reference for every rule type, or the Insights Book for the complete catalog of all 15 rules in this repo, with filters by domain and severity.