Commit 2c3045d
authored
feat(boundaries): config-driven boundary-violations recipe (#72)
* feat(boundaries): config-driven boundary-violations recipe + .codemap/config sweep
Ships the next cadence pick from the roadmap (research note § 1.5).
- New `boundaries: [{name, from_glob, to_glob, action?}]` field on the Zod
user-config schema; `action` defaults to `"deny"`.
- New `boundary_rules` table (STRICT, WITHOUT ROWID) with CHECK constraint on
action. Schema bump 8 → 9.
- New `reconcileBoundaryRules` helper in src/db.ts; called from
`runCodemapIndex` after `createSchema` so the table tracks resolved config
exactly (config = single source of truth, table = denormalised lookup).
- New runtime accessor `getBoundaryRules`.
- Bundled `boundary-violations.{sql,md}` recipe joining `dependencies` ×
`boundary_rules` via SQLite GLOB. Recipe rows alias `from_path` to
`file_path` so `--format sarif` / `annotations` light up automatically.
- `codemap.config.example.json` gains a sample boundary.
Lockstep + sweep:
- docs/architecture.md § Schema gains `boundary_rules` subsection.
- docs/glossary.md adds boundaries / boundary_rules / boundary-violations.
- docs/roadmap.md drops the now-shipped backlog item per Rule 2.
- README + agent rule + skill (templates/ + .agents/) document the shape.
- Stale `codemap.config.ts` references swept across the codebase to
`.codemap/config.{ts,js,json}` per the post-D11 layout (all docs, agent
surfaces, JSDoc, CLI help). Historical changesets and the legacy-migration
mention in src/config.ts intentionally preserved.
Tests:
- src/application/boundary-rules.test.ts: schema, reconciler idempotency,
CHECK constraint, recipe SQL against synthetic dependency graph.
- src/config.test.ts: default-`[]`, default action filling, unknown action
rejection.
Verification: bun run check (798 tests + golden scenarios) passes.
* fix(boundaries): address PR #72 fact-checked review feedback
Verified each CodeRabbit thread; applied real bugs (T3, T4) and tightened
config-path wording (T1, T2).
- T3 (MAJOR bug): full-rebuild path called `reconcileBoundaryRules` BEFORE
`indexFiles`, but `indexFiles` runs `dropAll` internally on full rebuild,
wiping the just-reconciled `boundary_rules`. Moved the reconciler into a
`try/finally` around the existing branching so rules are written AFTER
every code path returns. Regression test (`survives a full rebuild
(reconciler runs after dropAll)`) confirms the fix.
- T4: SQLite `GLOB *` is NOT filesystem-aware — it matches `/` like any
other character. The recipe `.md` claim that `src/ui/*` "matches one
level only" was wrong. Rewrote the GLOB section: documented that `*`
crosses `/`, gave the `[^/]*` recipe for single-segment matches, and
clarified there is no `**` in SQLite.
- T1: `docs/plans/c9-plugin-layer.md` Q2 broadened from `.codemap/config.ts`
to `.codemap/config.{ts,js,json}` to match the supported variants.
- T2: `src/api.ts` `configFile` JSDoc broadened from `.ts | .json` to
`.codemap/config.{ts,js,json}` so JS callers aren't misled.
* fix(boundaries): atomic reconcile + sync schema version doc to 9
Two more fact-checked CodeRabbit points from PR #72:
- T6: `reconcileBoundaryRules` was DELETE-then-INSERT without transactional
protection. Zod doesn't dedupe `name`, but the schema's `name TEXT PRIMARY
KEY` does — a duplicate would throw mid-loop, leaving the table partially
populated (DELETE already ran). Wrapped the body in a SAVEPOINT so the
prior good state is preserved on any insert failure. SAVEPOINT works
inside or outside an open transaction, so callers don't need to
coordinate. New regression test `rolls back on duplicate name —
preserves prior good state (atomic)` confirms the prior row survives.
- T5: `docs/architecture.md` § Schema header still read **8**. Bumped to
**9** to match `SCHEMA_VERSION` (the `boundary_rules` row was added in
the same PR but the version line was missed).1 parent edee493 commit 2c3045d
25 files changed
Lines changed: 694 additions & 178 deletions
File tree
- .agents
- rules
- skills/codemap
- .changeset
- docs
- plans
- src
- application
- cli
- templates
- agents
- rules
- skills/codemap
- recipes
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
510 | 511 | | |
511 | 512 | | |
512 | 513 | | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
517 | | - | |
518 | | - | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
| |||
128 | 132 | | |
129 | 133 | | |
130 | 134 | | |
131 | | - | |
| 135 | + | |
132 | 136 | | |
133 | 137 | | |
134 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
0 commit comments