Context
Discovered while fixing #237 (the consolidation-package import cycle). Not
in that issue's blast radius (no test, build, or lint step #237's fix
triggers checks these numbers — confirmed no active pre-commit hook or CI
job enforces file/method size in this repo today), so deferred here per
coding-standards.md §14.3 rather than folded into that PR.
Finding 1 — method-length debt in the headless-authoring worker family
mcp_server/handlers/consolidation/{drain_operations,cycle_orchestration}.py
have several methods well over the §4.2 50-line cap (measured on the
pre-#237 tree, i.e. before that fix's small sentinel-resolution additions):
drain_operations.py::drain_one ~85 lines
drain_operations.py::drain_all_gaps_on_page ~130 lines
drain_operations.py::drain_missing_anchors ~90 lines
cycle_orchestration.py::run_headless_authoring_cycle ~175 lines (incl. 2 nested coroutines)
These were already over the cap before #237 touched these files (that PR
added ~5 lines of sentinel-resolution logic to each, not the underlying
size). Fowler catalog fixes: Extract Function on drain_all_gaps_on_page's
per-gap fill loop and run_headless_authoring_cycle's two nested
coroutines (drain_anchor_bounded/drain_page_bounded could become
module-level functions taking sem/budget as explicit parameters).
Finding 2 — CLAUDE.md vs CONTRIBUTING.md disagree on the numbers
CLAUDE.md § Code Style: "300 lines max per file; 40 lines max per
method. Enforced by the craftsmanship-checker pre-commit hook."
CONTRIBUTING.md § Definition of Done (or similar): "§4.1 File ≤500
lines, §4.2 function ≤50 lines" — citing coding-standards.md's actual
§4 numbers.
- No
craftsmanship-checker pre-commit hook is actually installed
(.git/hooks/ has only the standard *.sample files), and no CI job
greps for file/method line counts.
Before splitting the functions in Finding 1, resolve which number is
authoritative (500/50, matching coding-standards.md and CONTRIBUTING.md,
or a locally-tightened 300/40) and fix whichever doc is stale, so the next
split targets the real threshold instead of guessing.
Acceptance criteria
- CLAUDE.md and CONTRIBUTING.md agree on the file/method size limits (fix
whichever is stale, or add an ADR if 300/40 is an intentional
local tightening — coding-standards.md §10 requires the exception be
written down).
- If 500/50 is confirmed as the real limit and today's methods are
already compliant, close as not-a-bug. If 300/40 (or the confirmed
real number) is violated, split drain_all_gaps_on_page and
run_headless_authoring_cycle via Extract Function, existing suite
passing unchanged (tests_py/handlers/test_headless_authoring_throttle.py
- tests_py/handlers/consolidation/test_import_cycle_237.py cover the
patchability contract these files carry — any refactor must preserve
monkeypatch.setattr(headless_authoring, ...) observability, see those
files' module docstrings).
Context
Discovered while fixing #237 (the consolidation-package import cycle). Not
in that issue's blast radius (no test, build, or lint step #237's fix
triggers checks these numbers — confirmed no active pre-commit hook or CI
job enforces file/method size in this repo today), so deferred here per
coding-standards.md §14.3 rather than folded into that PR.
Finding 1 — method-length debt in the headless-authoring worker family
mcp_server/handlers/consolidation/{drain_operations,cycle_orchestration}.pyhave several methods well over the §4.2 50-line cap (measured on the
pre-#237 tree, i.e. before that fix's small sentinel-resolution additions):
These were already over the cap before #237 touched these files (that PR
added ~5 lines of sentinel-resolution logic to each, not the underlying
size). Fowler catalog fixes:
Extract Functionondrain_all_gaps_on_page'sper-gap fill loop and
run_headless_authoring_cycle's two nestedcoroutines (
drain_anchor_bounded/drain_page_boundedcould becomemodule-level functions taking
sem/budgetas explicit parameters).Finding 2 — CLAUDE.md vs CONTRIBUTING.md disagree on the numbers
CLAUDE.md§ Code Style: "300 lines max per file; 40 lines max permethod. Enforced by the craftsmanship-checker pre-commit hook."
CONTRIBUTING.md§ Definition of Done (or similar): "§4.1 File ≤500lines, §4.2 function ≤50 lines" — citing coding-standards.md's actual
§4 numbers.
craftsmanship-checkerpre-commit hook is actually installed(
.git/hooks/has only the standard*.samplefiles), and no CI jobgreps for file/method line counts.
Before splitting the functions in Finding 1, resolve which number is
authoritative (500/50, matching coding-standards.md and CONTRIBUTING.md,
or a locally-tightened 300/40) and fix whichever doc is stale, so the next
split targets the real threshold instead of guessing.
Acceptance criteria
whichever is stale, or add an ADR if 300/40 is an intentional
local tightening — coding-standards.md §10 requires the exception be
written down).
already compliant, close as not-a-bug. If 300/40 (or the confirmed
real number) is violated, split
drain_all_gaps_on_pageandrun_headless_authoring_cycleviaExtract Function, existing suitepassing unchanged (tests_py/handlers/test_headless_authoring_throttle.py
patchability contract these files carry — any refactor must preserve
monkeypatch.setattr(headless_authoring, ...)observability, see thosefiles' module docstrings).