Skip to content

Park, parkSingleNamedLane and switchLaneLocked exceed the 40-line function limit #3265

Open

Description

@mlorentedev

Context

AGENTS.md sets a < 40-line limit per function. Three functions on the named-lane path exceed it:

Function File Lines
Park cli/internal/worktree/done.go:103 92
parkSingleNamedLane cli/internal/worktree/sweep.go:392 54
switchLaneLocked cli/internal/lane/named.go:311 49

Defect

Raised as Finding 3 (Minor) by the independent adversarial review of
HARNESS-186-named-lanes-sticky-personas (specs/HARNESS-186-named-lanes-sticky-personas/review.md),
and deliberately ticketed rather than fixed in that PR: the fix is pure extraction with no
behavioural test pinning the boundary, and the review run that found it took 24 minutes.

The concrete risk is not length for its own sake. Park mixes lease-metadata reading, state
transition, git checkout, and user-facing reporting in one body, which is why the --force gap in
sweep.go went unnoticed (see the separate sweep ticket).

Fix direction

Extract along the existing seams, keeping behaviour identical:

  • Park: lease read / state write / git operation / report as four helpers.
  • parkSingleNamedLane: split the landing decision from the parking action.
  • switchLaneLocked: split lock acquisition and validation from the switch itself.

Do it with a characterisation test first, so the extraction is provably behaviour-preserving.

Acceptance

  • All three functions are under 40 lines.
  • No behavioural change; existing tests pass unchanged.
  • A characterisation test covers each function's outcome before the extraction.

Activity

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

    choreMaintenance / automation / cleanuptech-debt

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions