Skip to content

chore(ci): ratcheting file-size guard + RC cut checklist#1040

Open
branarakic wants to merge 1 commit into
mainfrom
chore/file-size-guard
Open

chore(ci): ratcheting file-size guard + RC cut checklist#1040
branarakic wants to merge 1 commit into
mainfrom
chore/file-size-guard

Conversation

@branarakic

Copy link
Copy Markdown
Contributor

What

Adds an automated file-size guard to CI plus a manual RC cut checklist to the release process — two low-cost delivery guardrails aimed at the regression/churn pattern seen across v10 rc.8 → rc.15.

File-size guard (automated)

  • scripts/audit-file-size.mjs fails the build if any new packages/*/src .ts/.tsx file exceeds 800 lines, or if one of the 72 existing oversized files grows past its budget. One-way ratchet: files may shrink, never grow.
  • Generated typechain/ bindings, dist/, .d.ts, and tests are excluded. Budgets live in scripts/file-size-baseline.json (regenerate with pnpm check:file-size --write).
  • Wired into the existing build job next to audit-create-random / audit-dial-protocol, with a node --test suite (19 tests). Zero new dependencies, ~300 ms.

RC cut checklist (manual)

  • RELEASE_PROCESS.md §11: a copy-pasteable stabilization gate (soak window, regression-test-per-fix, review hygiene, version/ABI alignment) to run before tagging each RC.

Why

Across rc.8 → rc.15 the top churn hotspots were the largest files — dkg-agent.ts (2,069 lines) was edited in 1 of every 6 commits — and the rc.15 "mixin split" relocated bulk into new 3,000-line files rather than shrinking it. fix: outnumbered feat: ~4:1. This guard makes "no new god-files, and existing ones only shrink" a build-enforced invariant.

Verification

  • pnpm check:file-size green on this branch (618 source files scanned, 72 budgeted).
  • node --test scripts/audit-file-size.test.mjs → 19/19 pass.
  • Negative test: a planted 801-line file fails with exit 1.
  • Baseline regenerated against main (the rc-branch baseline didn't match — main splits PanelRight differently), so it reflects this PR's base.

Notes

  • No production code changed — CI/tooling/docs only.
  • The checklist is intentionally not automated yet; a follow-up could turn its machine-decidable items into a release-preflight job.

🤖 Generated with Claude Code

Cap hand-written source file size with a one-way ratchet: any NEW
packages/*/src file may not exceed 800 lines, and the 72 existing
oversized files may shrink but never grow. Generated typechain
bindings, dist output, .d.ts, and test files are excluded.

Motivated by the v10 rc.8 -> rc.15 history, where the top churn
hotspots were also the largest files: dkg-agent.ts (2,069 lines) was
edited in 1 of every 6 commits, and the rc.15 "mixin split" relocated
its bulk into new 3,000-line files instead of shrinking the surface.
A filename-agnostic, ratcheting guard catches that whole class.

Runs as a zero-dependency audit in the existing build job, next to
audit-create-random / audit-dial-protocol, with a companion
`node --test` suite. Per-file budgets are regenerated with
`pnpm check:file-size --write`.

- scripts/audit-file-size.mjs        the guard (+ --write to re-baseline)
- scripts/audit-file-size.test.mjs   19 unit tests over the pure helpers
- scripts/file-size-baseline.json    budgets for the 72 current large files
- package.json                       pnpm check:file-size
- .github/workflows/ci.yml           two new build-job steps
- RELEASE_PROCESS.md                 §11 RC cut checklist (manual gate)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
function writeBaseline(measured) {
const files = {};
for (const { path: relPath, lines } of measured) {
if (lines > DEFAULT_MAX_LINES) files[relPath] = budgetForSize(lines);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 Bug: --write rebuilds the baseline from the current file sizes, so an already-baselined file that grew will get a larger budget the next time someone regenerates the JSON. That breaks the core "ratchet only down" guarantee and makes budget increases a one-command change. Preserve existing entries and only lower them when a file shrinks; if upward rebases are ever allowed, gate them behind an explicit opt-in path.

if (!p.includes('/src/')) return false;
if (!SOURCE_EXTENSIONS.has(path.posix.extname(p))) return false;
if (p.endsWith('.d.ts')) return false;
if (/\.(test|spec)\.tsx?$/.test(p)) return false;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Issue: this only excludes tests by filename suffix, so common layouts like packages/foo/src/__tests__/x.ts or src/tests/x.ts will still be treated as production source and can fail the cap unexpectedly. The script header says test files are excluded, so the matcher should also skip test directories and the test suite should cover those cases.

Comment thread RELEASE_PROCESS.md

- [ ] Package versions aligned for the channel (§3): `package.json`,
`packages/cli/package.json`, `packages/evm-module/package.json`,
`packages/mcp-server/package.json`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Issue: this checklist references packages/mcp-server/package.json, but this repo's MCP package is packages/mcp-dkg/package.json. As written, release verification will skip the actual package that needs version alignment. Update this path here to the real package.

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