Skip to content

headless-authoring worker family: methods exceed 50-line cap (§4.2), CLAUDE.md size-limit text drifted from CONTRIBUTING.md #276

Description

@cdeust

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

  1. 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).
  2. 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).

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