Repository navigation
chore: add architecture boundary guard to CI - #234
Conversation
dirac-run
left a comment
There was a problem hiding this comment.
Blocking for architecture enforcement on head 76d20e8: this PR adds check:arch, but neither a CI workflow nor ci:check-all runs it. #238 used the script manually, which is useful but does not stop future boundary/cycle violations from merging. Please wire the architecture check into a required CI check. Also, check_any_ratchet returns success when it cannot find a merge base; fail explicitly or provide a reliable base in CI so the ratchet cannot silently turn off. No tests/builds were independently run in this review.
- scripts/check-architecture.sh: 10 checks ratcheting known debt (task->controller, vscode-in-core, leaf violations, tool seal, taxonomy split, numeric ||, env scatter, webview escape, new 'as any') - baseline file: violations fail only when NEW, so guard is green today and tracks debt shrinkage - wired as npm run check:arch
- add dependency-cruiser@18.2.0 as devDependency with native --ignore-known baseline - .dependency-cruiser.js: configure rules for task<->controller, vscode in core, leaf services/integrations, tool seal, webview boundary, and circular dependencies - scripts/check-architecture.sh: hybrid runner combining depcruise for module graph + AST/regex for code smells (|| 0, env scatter, any ratchet) - zero false-positives from strings/comments, respects tsconfig path mappings
Review findings from the smells pass: the 5MB pretty-printed dependency-cruiser baseline is now compacted (3MB single line) and --write-baseline keeps it compact; the tool-taxonomy check also catches same-line re-exports of the guarded tool-set identifiers, closing a smuggling path around shared/tools.ts.
Regenerated .dependency-cruiser-known-violations.json via check-architecture.sh --write-baseline. Adds 4 no-circular entries that current master introduced: cycles through UserToolLoader/ToolDiscoveryService/hook-factory/AuthController. These are pre-existing on master; breaking them is tracked separately and is out of scope for this branch.
…ailure Addresses review on dirac-run#234: adds .github/workflows/architecture.yml (npm ci, protos, check:arch on PRs and master), replaces path-keyed cycle baselining with an SCC partition check (new cyclic member or SCC merge fails), makes check_any_ratchet exit 2 without a merge base, and re-freezes baselines on current master (472 modules / 11 SCCs).
76d20e8 to
0bf8c5f
Compare
|
Thanks for the review. I've pushed The guard now runs in CI. New
One further change, found while rebasing. The original cycle baseline was keyed by dependency-cruiser's exact cycle paths, and later master commits alone made it report 24 "new" Baselines are re-frozen on |
PR 0: Architecture Boundary Guard, SCC Cycle Gate, and CI Workflow
Branch:
fork/chore/arch-guard-script->dirac-run/dirac:masterCommits: 5 commits on current master
95edfe36(head0bf8c5fd)Type:
chore/ CI infrastructureSummary
Adds automated architecture enforcement that runs in CI on every pull request and on pushes to
master: layering violations, new import cycles, scattered tool-taxonomy definitions, numeric||defaults, directprocess.envreads in core, and newanys. Existing debt is frozen in baselines; only new instances fail.Architecture
Why cycles are gated by SCC partition, not by path
The first version of this PR froze dependency-cruiser's
no-circularviolations, which are keyed by the exact module path of each cycle. With a median cycle length of 16 modules, almost any edit on master reroutes some cycle, so previously known cycles resurfaced as "new". Against later master commits, the old guard reported 24 newno-circularerrors, none of them a genuinely new cycle.The gate now computes strongly-connected components (iterative Tarjan) over the resolved module graph and freezes which modules belong to which cyclic SCC. It fails when:
import "./index"tosrc/core/api/ApiConfigurationError.tsfails withNEW cyclic-SCC member(s): + src/core/api/ApiConfigurationError.ts), orimport "../core/api"tosrc/shared/api.tsfails with anSCC MERGEjoining the 47-module and 406-module SCCs).Known limitation: a new import between two modules that are already in the same SCC changes neither membership nor the partition, so it is not detected. With a 406-module SCC this gap is real. The gate stops cycles from spreading; it does not stop them from getting denser. Closing that gap needs an edge-level ratchet within SCCs, which is out of scope here.
Maintenance: a PR that renames or moves a file inside a cyclic SCC must re-freeze with
bash scripts/check-architecture.sh --write-baseline, and the baseline diff shows the move.Changes
.github/workflows/architecture.yml(new): Node 22,fetch-depth: 0(needed for theanyratchet's merge base),npm ci,npm run protos(generated sources are gitignored),npm run check:arch. Informational until a maintainer makes it a required check.scripts/check-arch-graph.mjs(new): SCC partition gate plus a boundary-violation comparison keyed byrule|from|to. Exits 0 (pass), 1 (new violation), 2 (bad input).--write-baselinewritesscripts/architecture-cycle-sccs.txt(deterministic, sorted) and.dependency-cruiser-known-violations.json(boundary rules only).scripts/check-architecture.sh:check-arch-graph.mjs.check_any_ratchetfails loudly with exit 2 when no merge base withorigin/masterexists, where it used to silently pass. The driver loop no longer swallows that status.check_env_centralizedis line-level, so a file already in the baseline can no longer add newprocess.envreads unnoticed.--only <check_id>option runs a single syntax check..dependency-cruiser.js: rules forbidding upward imports fromsrc/services/andsrc/integrations/, task↔controller edges outside host seams, and cross-tool imports.src/generatedis excluded, because it is gitignored and results used to depend on whethernpm run protoshad run.package.json:check:archscript and adependency-cruiserdev dependency.Test Plan
npm run check:archexits 0 on the rebased branch (graph OK: 472 modules in 11 cyclic SCCs, all boundary violations known; all four syntax checks pass).src/,cli/src/orwebview-ui/src/relative to master, so the frozen graph is master's graph.origin/master,check-architecture.sh --only check_any_ratchetexits 2 withcheck_any_ratchet requires a merge base with origin/master. In CI, set fetch-depth: 0.--only check_no_numeric_or_defaultand--only check_env_centralizedexit 0.npm run lintpasses.