Skip to content

God-file ratchet: freeze growth of 1500+ line product files — generalize the single-file precedent #9838

Closed

Description

@Git-on-my-level

Problem

Oversized files are where this repo's bug chains concentrate, and they are disproportionately expensive for agents (a file that doesn't fit in one read multiplies every navigation and edit). Evidence: the two files at the center of the week's churn are RealtimeHubController.swift (4,949 lines, 121 touches/month) and chat_completions.rs (3,309 lines, 10 commits/week, split tracked in #9836). But they are not outliers — current counts in product source (tests and generated files excluded):

6500 desktop/macos/Desktop/Sources/APIClient.swift
6012 desktop/macos/Desktop/Sources/Providers/ChatProvider.swift
5401 desktop/macos/Desktop/Sources/MainWindow/Pages/TasksPage.swift
4949 desktop/macos/Desktop/Sources/FloatingControlBar/RealtimeHubController.swift
4832 desktop/macos/Desktop/Sources/FloatingControlBar/FloatingControlBarWindow.swift
4430 desktop/macos/Desktop/Sources/MainWindow/Pages/DashboardPage.swift
4129 desktop/macos/Desktop/Sources/Chat/AgentRuntimeProcess.swift
4101 desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift
3355 desktop/macos/Desktop/Sources/Rewind/Core/RewindDatabase.swift
3309 desktop/macos/Backend-Rust/src/routes/chat_completions.rs
3110 backend/routers/transcribe.py   (backend/AGENTS.md still says "2900 LOC")

#9836 fixes exactly one of these retail. Nothing stops the others from growing, or new ones from forming. The repo already ratchets one specific file (check-hub-controller-ratchet.py) — per the shared-boundary rule, two instances of the same guard means the class wants one general mechanism.

Fix: per-file line-count ratchet, one PR

A no-increase ratchet, same family as the existing ratchet scripts:

  • Scope: *.swift, *.rs, *.py product source under desktop/macos/, backend/ — excluding tests, Generated/, *.gen.*/*.g.*, and vendored/venv paths.
  • Rule: a file at or over the threshold (1,500 lines) may not gain lines relative to its committed baseline; files under the threshold may not cross it. Shrinking a file automatically lowers its baseline (ratchet-down on every run that observes a smaller count).
  • Baseline: a checked-in JSON snapshot (current counts), regenerated only downward by the check itself. Raising a baseline requires editing the file in the PR diff — visible, reviewable, and exceptional by construction.
  • Registration: .github/checks-manifest.yaml, both local and ci lanes, diff-scoped (only changed files are evaluated, so the check is fast and only fires when someone actually touches a god file).
  • Absorb the precedent: fold check-hub-controller-ratchet.py's size-related assertions into this check where they overlap, per the single-owner rule (its non-size assertions stay).
  • Failure message names the escape hatches in order of preference: split the file (an over-threshold file you must grow is the trigger to split it — Split chat_completions.rs into routes/chat/ along its real seams — move-only, streaming closure intact #9836 is the worked example), or raise the baseline explicitly in the diff with a one-line justification.

Real instances this check would have flagged (cite them in the manifest entry's reason field — note: the manifest loader consumes id/command/triggers/lanes/reason only, there is no dedicated citation field): #9836's file grew to 3.3k across the PRs that also introduced its bug collisions (#9384/#9638/#9692 all landed inside it); transcribe.py silently outgrew its documented size; RealtimeHubController.swift accumulated to 4.9k across the FC-5 chain.

Proof

  • Check fails on an adversarial diff growing an over-threshold file, passes on a shrinking one, and auto-lowers the baseline after a split.
  • The manifest entry's reason field cites the instances above.
  • Baseline JSON committed with current real counts — the check is green on main at merge.

Cut list

Sizing

One PR: one script (~100 lines), baseline JSON, manifest entry, absorption of the overlapping single-file ratchet.

Activity

  1. added a commit that references this issue on Jul 16, 2026
    e8adfc5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions