Skip to content

test(arch): add import-boundary and file-size gates (#1228) - #1246

Open
HugoXK wants to merge 1 commit into
mainfrom
feat/1228-arch-boundaries
Open

HugoXK wants to merge 1 commit into
mainfrom
feat/1228-arch-boundaries

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 23, 2026

Copy link
Copy Markdown
Owner

Written-by: HugoXK

Fixes #1228

What changed

  • scripts/lib/arch-boundaries.mjs (pure): parses static, side-effect and dynamic imports, resolves relative targets, and applies four runtime import rules:
    • a view may import db row types but not the store;
    • the store must not import app, a view or a job;
    • a job must not import a view;
    • a view may import only src/jobs/continuity.ts and src/jobs/automationHealth.ts from the job layer.
      Type-only imports are erased at build time and are allowed across a boundary.
  • scripts/lib/arch-boundaries.mjs also ratchets file size: a new source file is at most 1,200 lines, and a grandfathered file may not grow.
  • scripts/arch-boundaries.mjs is the CLI; it reads the tree, not a diff. npm run arch:check runs it.
  • scripts/lib/arch-grandfather.json records the five files above 1,200 lines at the sizes measured on v0.5.0: app.ts 7,471, db.ts 8,722, jobs/service.ts 5,518, repos/github.ts 1,335, views/pages.ts 6,234. An entry must be deleted once its file is at or below 1,200 lines.
  • test/archBoundaries.test.ts covers the four rules, type-only imports, unresolved/external imports, the line number of a multi-line import, the size ratchet, and the real tree.
  • npm run arch:check is a step in the existing lint CI job. It is not a new required check, so ci-ok's job list and the aggregate script are unchanged; the same test also runs in test, which runs on every diff.
  • docs/code-standards.md records the rules and the ratchet.

Ran:

  • npx tsx --test test/archBoundaries.test.ts — 10 pass, 0 fail
  • npm run arch:check — arch: 174 files, 699 imports, 5 grandfathered
  • npm run lint — 11 baseline warnings, unchanged
  • npm run typecheck — pass
  • npm run build — pass
  • npm test — 3328 pass / 9 fail. The same 9 fail on the untouched v0.5.0 tree in a second worktree: deployAutomation (5), gateBaseTree (1), nginxCheck (2), securityHeaders (1). They are macOS host/tool failures, not this diff.

Not run:

  • Docker image and the Playwright visual matrix; this change has no runtime, route, view or asset change.
  • A green npm run check on this macOS host is blocked by the same 9 pre-existing failures; lint, typecheck and build pass before them.

Risks

Docs updated: docs/code-standards.md — Architecture boundaries.

@HugoXK-bot HugoXK-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: REQUEST_CHANGES at 8ca3856
Blocker: ci.yml:141-142 puts npm run arch:check inside the required lint job. scripts/lib/gate-compare.mjs (compareGate, base blob 7ca41bba) compares every key of every required job, steps included, so the publisher's ci-ok (137504400176) refuses with "required job lint differs from the base tree"; by its own DOOR no PASS and no ci-workflow-change label can turn that green, so this red is permanent at this head and independent of review-gate.
Reproduced: compareGate from base a09997f6 returns ok:false with exactly that refusal for this head's ci.yml, and ok:true once the step moves to its own job.
Fix: give the gate its own job under jobs: (a new job passes the comparator) or drop the hunk — test/archBoundaries.test.ts:90-93 already runs scripts/arch-boundaries.mjs inside required test (24), which passed here. Issue #1228 asks for "a CI job in ci.yml" plus "green ci-ok"; a step in lint delivers neither.
Checks at this head: 31 latest check-runs — ci-ok (publisher) and pre-verdict review-gate red, 6 conditional skips, every other check success; the rest of the diff read consistent (scripts/lib/arch-boundaries.mjs:16-46 rules, :162-195 size ratchet).
Not run: the PR's suites locally (no checkout on this host); the ruling rests on the live head, its check-runs and the base-tree comparator.
Written-by: HugoXK-bot

This branch has not been deployed

No deployments
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.

test(arch): add import-boundary and file-size gates with a grandfathered list

2 participants