Skip to content

Commit 4794a5c

Browse files
wesbillmanCarl
andauthored
ci: relax file-size ceilings by surface (#6485)
## Summary - raise Desktop Rust's differential file-size ceiling from 1,000 to 1,500 lines - raise Desktop frontend and Mobile ceilings from 1,000 to 1,200 lines - keep Web at 1,000 lines and preserve the existing no-growth ratchet above each ceiling ## Why The flat 1,000-line limit is forcing mechanical trimming in Desktop and Mobile even for small cohesive changes. Surface-specific ceilings relieve that pressure without granting Web or every authored component a blanket 2,000-line budget. ## Testing - `just file-size-check` - `cd desktop && pnpm exec biome check scripts/check-file-sizes.mjs` - `node --check mobile/scripts/check-file-sizes.mjs` - `git diff HEAD^ --check` Signed-off-by: Wes <[email protected]> Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
1 parent b270437 commit 4794a5c

33 files changed

Lines changed: 368 additions & 132 deletions

‎AGENTS.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,13 @@ The mobile app lives in `mobile/` — a Flutter app using Riverpod + Hooks.
674674
over raw `Theme.of(context)` calls.
675675
- **Keep widgets small and composable.** One public widget per file; push
676676
private sub-widgets (`_Foo`) into sibling `part` files under a
677-
`<page>/` folder rather than growing the page file. Hard ceiling:
678-
**1000 lines/file**, enforced across Desktop, Web, and Mobile by the
677+
`<page>/` folder rather than growing the page file. Mobile's hard ceiling is
678+
**1200 lines/file**, enforced with the other surface-specific limits by the
679679
repository-level `just file-size-check` gate (`just check`, CI, and every
680-
pre-push). If the guard trips, **split the file — never bump the limit or add
681-
an override to slip under it.**
680+
pre-push). If an individual file trips the guard, **split the file — never
681+
bump a surface limit or add an override merely to admit that file.**
682+
Deliberate repository-wide policy revisions must update the enforced rules,
683+
tests, and guidance together.
682684
- Feature modules must not import from other feature modules — only from
683685
`shared/`.
684686
- Use `Grid` tokens for spacing, `Radii` for border radius.
Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,21 @@
1+
import { realpathSync } from "node:fs";
12
import path from "node:path";
23
import { fileURLToPath } from "node:url";
34
import { runFileSizeCheck } from "../../scripts/check-file-sizes-core.mjs";
5+
import { rules } from "./file-size-policy.mjs";
46

5-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
6-
const projectRoot = path.resolve(__dirname, "..");
7+
const scriptPath = realpathSync(fileURLToPath(import.meta.url));
8+
const projectRoot = path.resolve(path.dirname(scriptPath), "..");
79

8-
const MAX_LINES = 1000;
9-
10-
const rules = [
11-
{ root: "src-tauri/src", extensions: new Set([".rs"]), maxLines: MAX_LINES },
12-
// Workspace member crates. Without this the ratchet's only Rust root is
13-
// `src-tauri/src`, and a crate under `src-tauri/crates/` is born outside the
14-
// repo's one size discipline -- silently, since the check still exits 0.
15-
{
16-
root: "src-tauri/crates",
17-
extensions: new Set([".rs"]),
18-
maxLines: MAX_LINES,
19-
},
20-
{
21-
root: "src/app",
22-
extensions: new Set([".ts", ".tsx"]),
23-
maxLines: MAX_LINES,
24-
},
25-
{
26-
root: "src/features",
27-
extensions: new Set([".ts", ".tsx"]),
28-
maxLines: MAX_LINES,
29-
},
30-
{
31-
root: "src/shared/api",
32-
extensions: new Set([".ts", ".tsx"]),
33-
maxLines: MAX_LINES,
34-
},
35-
{
36-
root: "src/shared/context",
37-
extensions: new Set([".ts", ".tsx"]),
38-
maxLines: MAX_LINES,
39-
},
40-
{
41-
root: "src/shared/lib",
42-
extensions: new Set([".ts", ".tsx"]),
43-
maxLines: MAX_LINES,
44-
},
45-
{
46-
root: "src/shared/ui",
47-
extensions: new Set([".ts", ".tsx"]),
48-
maxLines: MAX_LINES,
49-
},
50-
{
51-
root: "src/shared/styles",
52-
extensions: new Set([".css"]),
53-
maxLines: MAX_LINES,
54-
},
55-
];
56-
57-
await runFileSizeCheck({
10+
export const policy = {
5811
projectRoot,
5912
rules,
6013
label: "Desktop",
61-
});
14+
};
15+
16+
if (
17+
process.argv[1] &&
18+
realpathSync(path.resolve(process.argv[1])) === scriptPath
19+
) {
20+
await runFileSizeCheck(policy);
21+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
const DESKTOP_FRONTEND_MAX_LINES = 1200;
2+
const DESKTOP_RUST_MAX_LINES = 1500;
3+
4+
export const rules = [
5+
{
6+
root: "src-tauri/src",
7+
extensions: new Set([".rs"]),
8+
maxLines: DESKTOP_RUST_MAX_LINES,
9+
},
10+
// Workspace member crates. Without this the ratchet's only Rust root is
11+
// `src-tauri/src`, and a crate under `src-tauri/crates/` is born outside the
12+
// repo's one size discipline -- silently, since the check still exits 0.
13+
{
14+
root: "src-tauri/crates",
15+
extensions: new Set([".rs"]),
16+
maxLines: DESKTOP_RUST_MAX_LINES,
17+
},
18+
{
19+
root: "src/app",
20+
extensions: new Set([".ts", ".tsx"]),
21+
maxLines: DESKTOP_FRONTEND_MAX_LINES,
22+
},
23+
{
24+
root: "src/features",
25+
extensions: new Set([".ts", ".tsx"]),
26+
maxLines: DESKTOP_FRONTEND_MAX_LINES,
27+
},
28+
{
29+
root: "src/shared/api",
30+
extensions: new Set([".ts", ".tsx"]),
31+
maxLines: DESKTOP_FRONTEND_MAX_LINES,
32+
},
33+
{
34+
root: "src/shared/context",
35+
extensions: new Set([".ts", ".tsx"]),
36+
maxLines: DESKTOP_FRONTEND_MAX_LINES,
37+
},
38+
{
39+
root: "src/shared/lib",
40+
extensions: new Set([".ts", ".tsx"]),
41+
maxLines: DESKTOP_FRONTEND_MAX_LINES,
42+
},
43+
{
44+
root: "src/shared/ui",
45+
extensions: new Set([".ts", ".tsx"]),
46+
maxLines: DESKTOP_FRONTEND_MAX_LINES,
47+
},
48+
{
49+
root: "src/shared/styles",
50+
extensions: new Set([".css"]),
51+
maxLines: DESKTOP_FRONTEND_MAX_LINES,
52+
},
53+
];

‎desktop/src-tauri/src/archive/metric_store.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! via [`AgentMetricIndexRow::from_payload`].
1010
//!
1111
//! Kept in a sibling file (not `store.rs`) to keep that file under the
12-
//! 1000-line gate, per the existing `pipeline.rs` precedent.
12+
//! 1500-line gate, per the existing `pipeline.rs` precedent.
1313
1414
use rusqlite::{params, Connection, OptionalExtension};
1515

‎desktop/src-tauri/src/archive/mod_agent_metric_tests.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Kind-44200 (NIP-AM agent turn metric) archive and `get_agent_usage_series`
22
//! integration tests for `archive/mod.rs`.
33
//!
4-
//! Kept in a sibling file so `mod_tests.rs` stays under the 1000-line gate;
4+
//! Kept in a sibling file so `mod_tests.rs` stays under the 1500-line gate;
55
//! `#[path]`-included from there so the shared fixtures (`in_memory`,
66
//! `add_sub`, `candidate`, `make_observer_frame`, `run_batch_sync_with_keys`)
77
//! stay private to `mod_tests`.

‎desktop/src-tauri/src/archive/mod_tests.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Unit and integration tests for `archive/mod.rs`.
22
//!
3-
//! Kept in a sibling file so `mod.rs` stays under the 1000-line gate;
3+
//! Kept in a sibling file so `mod.rs` stays under the 1500-line gate;
44
//! `#[path]`-included from there.
55
66
use super::pipeline::BucketWithResult;
@@ -622,7 +622,7 @@ fn test_commit_archive_rolls_back_when_scope_write_would_fail() {
622622
}
623623

624624
// Kind-44200 agent-turn-metric coverage lives in a sibling file to keep this
625-
// one under the 1000-line gate; nested here (not in `mod.rs`) so it inherits
625+
// one under the 1500-line gate; nested here (not in `mod.rs`) so it inherits
626626
// the shared fixtures above through `use super::*`.
627627
#[path = "mod_agent_metric_tests.rs"]
628628
mod agent_metric;

‎desktop/src-tauri/src/archive/pipeline.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Archive pipeline — three-phase plan/query/commit split.
22
//!
3-
//! Separated from `mod.rs` to keep that file under the 1000-line gate.
3+
//! Separated from `mod.rs` to keep that file under the 1500-line gate.
44
//!
55
//! # Send-safety
66
//!

‎desktop/src-tauri/src/archive/retention.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//! Phase-2 prune scan, the get/set accessors for the observer window, and the
1111
//! PRAGMA-based size readout. The prune worker itself lands in Phase 2.
1212
//!
13-
//! Kept in a sibling file (not `store.rs`) to respect the 1000-line gate, per
13+
//! Kept in a sibling file (not `store.rs`) to respect the 1500-line gate, per
1414
//! the existing `metric_store.rs` / `pipeline.rs` / `store_migrations.rs`
1515
//! precedent.
1616

‎desktop/src-tauri/src/archive/retention_tests.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Behavior tests for the observer-retention setting, the size readout, and the
22
//! M4 migration.
33
//!
4-
//! Kept in a sibling file so `retention.rs` stays under the 1000-line gate;
4+
//! Kept in a sibling file so `retention.rs` stays under the 1500-line gate;
55
//! `#[path]`-included from there. `super::*` brings the retention API (and its
66
//! `rusqlite::{params, Connection}` imports) into scope; `super::super::store`
77
//! reaches the neighbouring subscription mutators and the base `SCHEMA`.

‎desktop/src-tauri/src/archive/store_migration_tests.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Migration tests for `archive/store.rs` — M1: harness column.
22
//!
3-
//! Kept in a sibling file so `store_tests.rs` stays under the 1000-line gate;
3+
//! Kept in a sibling file so `store_tests.rs` stays under the 1500-line gate;
44
//! `#[path]`-included from `store.rs`.
55
66
use super::*;

0 commit comments

Comments
 (0)