Skip to content

Deduplicate CLI readiness and command plumbing - #1921

Merged
mergify[bot] merged 3 commits into
mainfrom
lean178/575-cli-source-dedupe
Nov 26, 2026
Merged

mergify[bot] merged 3 commits into
mainfrom
lean178/575-cli-source-dedupe

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Context and goal

  • Goal: Free 20 counted source lines for pending work while preserving CLI behavior.
  • Problem: The source budget is nearly full, and queued PRs need more space than is available.
  • Context: cli.py repeats the receipt-backed mark-ready sequence and carries private wait defaults that neither command uses. This change shares that sequence and simplifies the existing control flow.

Refs #575

Acceptance

  • Remove at least 20 counted Python source lines from src/loopzero/cli.py and leave tests untouched.
  • Preserve CLI output, exit codes, options and help text.
  • Compare statement and branch coverage using the same focused CLI tests before and after.

Notes

Base

main @ 20fa3f2
Base: 20fa3f2

Validation

Recorded for 0ecf0893f700

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0
  • All 662 focused CLI tests passed on the original test set from 1cb9945c. Coverage.py statement counts went from 1,223/1,317 to 1,211/1,303 and branch counts went from 451/528 to 447/524. The patch removed covered statements and branches. Every previously covered statement and branch still present remained covered. The untested pre-expired-deadline path is unchanged and now shares the timeout tail.

Review

  • primary, claude, 0ecf089, approve

eowca and others added 3 commits November 26, 2026 15:04
Architecture-Review: unchanged; command entry points, trusted configuration, review locking, and readiness policy retain their existing boundaries.
Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

loopzero primary review by claude on 0ecf0893f70055b981e89e039f95d76d4f5462df, 38.2s: approve (0 critical, 0 important, 3 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread src/loopzero/cli.py


def _context(args: argparse.Namespace, *, pin_checks: bool = False) -> tuple[Path, Config]:
def _context(args: argparse.Namespace, *, pin_checks: bool = True) -> tuple[Path, Config]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: pin_checks on _context is now a dead parameter

Every caller of _context now uses the default pin_checks=True (lines 612, 680, 767, 1313, 1754). The only explicit argument is pin_checks=True at line 1842, which the task says sits in a reserved hunk. No caller passes False, so the keyword can never change behavior. Flipping its default to True keeps an option nobody uses. Once #1907/#1780 land and line 1842 is free, drop the parameter and pass pin_checks=True straight to _load_config. That is smaller and removes the misleading option.

Comment thread src/loopzero/cli.py
markers = _pr_markers(reviews, head, publishers, repo=config.repo, number=pr.number)
if _review_cap_spent(markers) and all(marker.head != head for marker in markers):
exhausted = _review_cap_reason(config, pr, head, reviews, markers, publishers)
if _conflict_delta_base(config, pr, head, reviews, markers, publishers):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Inlining _review_cap_reason and _readiness_precheck makes _readiness bigger

The behavior is the same. The precheck short-circuit order and the cap message text both match the originals. However, _readiness was already the most branch-heavy readiness function, and it now also carries the nested conflict-delta message branch and the walrus precheck. Inlining helpers mainly to save lines moves complexity into a hotspot that several pending PRs touch. This is acceptable given the budget goal. If a later pass has room, restoring the cap-message helper would keep _readiness easier to follow.

Comment thread src/loopzero/cli.py
git_dir = _git(wt, "rev-parse", "--absolute-git-dir", paths=True)
fd = os.open(git_dir, os.O_RDONLY | os.O_DIRECTORY)
try:
with ExitStack() as cleanup:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: ExitStack used only to replace a try/finally

ExitStack with a single callback(os.close, fd) behaves the same as the old try/finally (it is registered right after os.open succeeds). It is a less familiar idiom for one resource, and ExitStack.__exit__ is typed to return bool, so a static checker would report a missing return in locked. None is configured now. This is fine, but a short comment, or the plain try/finally if line budget allows, would read more clearly.

@eowca
eowca marked this pull request as ready for review November 26, 2026 14:27
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as 739305b at 14:33 UTC

6 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 14:28 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1936
  • ✅ Merged 14:33 · 739305b · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 26, 2026
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit 739305b into main Nov 26, 2026
18 checks passed
@mergify mergify Bot removed the queued label Nov 26, 2026
@eowca
eowca deleted the lean178/575-cli-source-dedupe branch November 26, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant