Skip to content

Ratchet backlog: 229 file + 607 method size-cap breaches pre-date the new craftsmanship-checker gate (issue #297) #298

Description

@cdeust

Context

Issue #297 wires a real, blocking CI gate (scripts/craftsmanship_checker.py)
enforcing CLAUDE.md's documented-but-previously-unenforced 300-line-file /
40-line-method (signature-to-close) caps. Running it against the full tree
at commit 2590922 (origin/main, 2026-07-30) found a large pre-existing
backlog, measured via git ls-files -- '*.py' + Python ast:

Scanned 1093 tracked .py files, 12109 functions/methods.
FILE breaches (>300 lines):   229
  by top-level dir: mcp_server 121/527, tests_py 74/459, benchmarks 25/63,
  scripts 8/39, video 1/1, fuzz 0/3, _pipeline 0/1
METHOD breaches (>40 lines, signature-to-close): 607
  by top-level dir: mcp_server 401/3424, benchmarks 74/436, tests_py 85/7937,
  scripts 39/235, video 6/20, fuzz 0/11, _pipeline 0/1

Fixing 836 breaches spanning nearly every module in the repo is a
repo-wide refactor an order of magnitude larger than "wire the gate"
(coding-standards.md §15.1: don't mix an unrelated, much-larger root-cause
fix into the gate PR) and would collide with the many other in-flight PRs
already touching these same files.

What issue #297 does instead

Ships a committed, dated ratchet baseline
(scripts/craftsmanship_baseline.json) recording exactly this backlog as
of 2590922. The checker:

  • Fails any NEW breach (a file/function not in the baseline going over cap).
  • Fails any REGRESSION (a baselined item getting even one line longer).
  • Fails a STALE baseline entry (an item fixed or removed must have its
    baseline entry removed in the SAME change that fixes it) — this is what
    makes the ratchet monotonically shrink over time instead of accumulating
    dead entries.
  • Passes a baselined item that stays the same or shrinks (still over cap).

Acceptance criteria for THIS issue (the backlog, not the gate)

  • Reduce scripts/craftsmanship_baseline.json's files and methods
    entries to zero, one PR (or a small number of scoped PRs) at a time,
    each a behavior-preserving Extract-Function/Extract-Module refactor with
    the existing test suite as the proof (passing unchanged) plus new tests
    for any newly-extracted unit, per coding-standards.md §6/§9.
  • Highest-value first: the 20+ largest offenders
    (mcp_server/infrastructure/pg_schema.py at 2482 lines,
    mcp_server/core/wiki_coverage.py at 1444, mcp_server/core/ recall_pipeline.py at 1386, mcp_server/infrastructure/pg_store.py at
    1380, etc. — full list in the checker's --report output) are both the
    biggest readability cost and the largest single chunks of the ratchet.
  • Each landing PR re-runs python scripts/craftsmanship_checker.py --update-baseline and commits the shrunk baseline as part of that PR
    (the checker enforces this: a fixed item left in the baseline fails as
    stale).

Not blocking any other work; this is the backlog issue #297's completion
ledger explicitly defers to, per coding-standards.md §13.4/§14.3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions