Skip to content

Code health: split annotations/from_model.py (10k lines) per feature family #1929

Closed

Description

@pzfreo

Part of the code-health epic. Evidence pinned to main @ 71b8c94.

Problem

annotations/from_model.py is 10,245 lines. It has about 26 feature render_*/place_* passes (:403 through :9830), 124 top-level definitions, 29 functions with 8 or more parameters, and 273 issue-number references. It is the largest module in the package and the second most-churned (71 commits in 30 days). Its biggest functions are render_step_lengths (766 lines, :6399) and render_slots (534, :403), and 27 of its functions are over 100 lines.

Proposal

The passes already share one contract, render_X(dwg, plan, a, *, ctx, only=None), and orchestrator._PASS_SEQUENCE owns their order. That makes it possible to split the file by feature family into sibling modules under annotations/ without changing behaviour. The families are:

  • slots
  • pockets/pads
  • steps/turned
  • chamfers/fillets
  • threads
  • patterns

Shared helpers go into one annotations/_passes_common.py, or into the existing _common.py where they belong.

Acceptance

  • No module under annotations/ exceeds about 2.5k lines.
  • _PASS_SEQUENCE order and the golden corpus are unchanged.
  • _LAYERS ranks the new modules, and the import-boundary test passes.
  • Do this after or alongside the placement-candidate refactor sub-issue, because the two touch the same closures.

Progress

Activity

  1. added
    tech-debtInternal maintainability or refactoring work
    area:layoutLayout, placement, scale/page, strips, repack
    area:architecturePackage layering and architectural structure
    on Sep 28, 2026
  2. reopened this on Sep 29, 2026
  3. pzfreo commented on Sep 29, 2026

    @pzfreo
    OwnerAuthor

    Reopened because the issue's own acceptance is not met yet. On merged main at 502bbc46, four annotation modules exceed about 2.5k lines: _common.py 2,972, holes.py 2,953, from_model.py 2,926, and leaders.py 2,873 (rg --files ... | xargs wc -l). The reviewed aggregate branch awaiting its single PR gate moves the polygonal family; a separate local envelope extraction brings from_model.py to 2,576, but neither is merged and other annotation modules remain above the issue limit. I will update the count and close this issue only when the acceptance is verified on main.

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

    area:architecturePackage layering and architectural structurearea:layoutLayout, placement, scale/page, strips, repacktech-debtInternal maintainability or refactoring work

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions