Skip to content

chore(architecture): warn when oversized source files grow - #2556

Merged
vastsa merged 1 commit into
mainfrom
chore/architecture-ratchet
Nov 24, 2026
Merged

vastsa merged 1 commit into
mainfrom
chore/architecture-ratchet

Conversation

@vastsa

@vastsa vastsa commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Why

scripts/check-architecture.mjs only capped electron/main/index.ts, app-store.ts, and newly added TS files. Existing God Modules kept growing with no signal (last 90 days: runtime.ts 9190→10218, rpc/mod.rs 10365→11739, sessions.rs 8521→9408). The AGENTS.md/CLAUDE.md hotspot list named modules that were already split (ChatTranscript.tsx is 1 line; plugins.rs/db.rs/providers.rs/plans.rs are <100).

What

  • scripts/architecture-growth.mjs (pure rules) + architecture-growth.test.mjs: a production TS/TSX file >800 LOC or Rust file >1000 LOC must not grow past its size at the merge base. Tests, fixtures, E2E, .d.ts, i18n locales, and changelog catalogs are excluded; new files stay under the existing new-file rules; allowlist.json gains an optional reasoned growth exemption.
  • check-architecture.mjs reports growth as a GitHub ::warning annotation. Non-blocking by default; ARCHITECTURE_STRICT_GROWTH=1 makes it fail.
  • CI runs the new unit tests.
  • AGENTS.md / CLAUDE.md hotspot list updated to the modules actually growing; Policy-Sync bumped to 2026-11-24.1. Architecture README, repo-structure spec, and ADR-0235 synced.

Why warning-only

Replaying the last 40 merges on main, 20 would have tripped the rule, including +2-line fixes. A hard gate would disrupt the current contribution flow, so it starts as a visible signal.

Compatibility

No product code, runtime behavior, contracts, or existing failure conditions change. Existing checks keep their exit behavior.

Validation

  • node --test scripts/architecture-growth.test.mjs: 6/6 pass
  • node scripts/check-architecture.mjs --base origin/main: passes, 0 growth
  • Probe (+1 line to runtime.ts): warning + annotation, exit 0; with ARCHITECTURE_STRICT_GROWTH=1, exit 1
  • Unavailable base: falls back as before, passes
  • pnpm check:agent-policy, check:pr-base, biome lint on changed scripts: pass

The architecture checker only limited two facade files and newly added
TypeScript files, so existing God Modules such as the agent runtime,
host-core RPC dispatch, and session service kept growing unnoticed. The
documented hotspot list also pointed at modules that were already split.

The checker now compares every production TS/TSX file above 800 LOC
and Rust file above 1000 LOC with its size at the merge base and reports
growth as a CI warning annotation. Replaying the last 40 merges showed
a hard gate would block about half of all pull requests, so failing is
opt-in through ARCHITECTURE_STRICT_GROWTH=1. Tests, fixtures, locales,
and changelog catalogs are excluded.

The AGENTS.md / CLAUDE.md hotspot list now names the modules that are
actually growing.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying pi-desktop with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4e4c404
Status: ✅  Deploy successful!
Preview URL: https://fd88d2b3.pi-desktop.pages.dev
Branch Preview URL: https://chore-architecture-ratchet.pi-desktop.pages.dev

View logs

@vastsa
vastsa merged commit 9213ba2 into main Nov 24, 2026
7 checks passed
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