Skip to content

feat(architecture): --forbid FROM->TO architecture rules - #45

Merged
inth3shadows merged 1 commit into
masterfrom
arch-forbid-rules
Sep 27, 2026
Merged

inth3shadows merged 1 commit into
masterfrom
arch-forbid-rules

Conversation

@inth3shadows

Copy link
Copy Markdown
Owner

First slice of turning codeshot's drift-guarded diagrams into enforceable architecture contracts: language-agnostic dependency rules for anything codegraph indexes.

  • --forbid 'FROM->TO', repeatable, --architecture only. A side ending in / is a directory prefix; any other side is one exact file; a leading ./ is stripped.
  • Checked on the per-file edges from aggregateFileEdges, before --group-depth rollup and --max-render, so neither can hide a violation.
  • Each violating edge is printed with its weight and rule (heaviest first). The diagram is still rendered and embedded, then the run exits 1.
  • A malformed rule, or --forbid outside --architecture, is rejected before any codegraph work.
  • Documented in README, USAGE ("Enforcing architecture rules") and TECHNICAL.md.

Live run on this repo (--limit 100): --forbid 'test/->render/' reports test/run.js -> render/callgraph.js (weight 55) and exits 1; --forbid 'render/->test/' is silent.

Local: node test/run.js 188 passed, 0 failed (fork codegraph), including an end-to-end fixture: exit 1 on a violation, the diagram is still written, an exact-file rule fires under --group-depth 1, and exit 0 when clean.

Turns --architecture into an enforceable contract. Each repeatable rule
is FROM->TO, where a side ending in / is a directory and any other side
one exact file. Rules are checked on the per-file edges before
--group-depth and --max-render, so a view choice cannot hide a violation.
Violations are listed on stderr with weight and rule; the diagram is
still written, then the run exits 1.
@inth3shadows
inth3shadows merged commit 8ed73db into master Sep 27, 2026
7 checks passed
@inth3shadows
inth3shadows deleted the arch-forbid-rules branch September 27, 2026 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant