Skip to content

Deduplicate CLI checks, waits and diagnostics - #1876

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

mergify[bot] merged 2 commits into
mainfrom
lean178/575-cli-source-cut

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Refs #575

Reduce src/loopzero/cli.py by 31 lines with zero test changes. Share readiness wait setup, consolidate error output, use lookup-enforced PR states, and remove the single-use Mergify departure formatter while preserving messages, check timing and receipt behavior. Reviewed the listed open PR hunks before editing. Merged #1841’s timestamp changes, resolving only the import overlap.

Coverage on the same tests/test_cli.py suite against base 51d679a1 and the cut before the import-only resolution: both passed. Executed statements were 1,202/1,299 before and 1,187/1,280 after. Branches were 454/532 before and 446/522 after. Every previously covered unchanged statement, and every previously covered branch with unchanged endpoints, remained covered. The merged head measures −31 source and zero test lines.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, 6eb5386, approve

Validation

Recorded for 6eb5386545d0

  • 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

eowca and others added 2 commits November 26, 2026 13:18
Architecture-Review: unchanged; the cut preserves command output, receipt handling, safety checks and read and write ordering.
Co-Authored-By: Codex <noreply@openai.com>
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 6eb5386545d0a299f37dbcff88d5aa28a63dd9f9, 63.5s: approve (0 critical, 0 important, 4 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
if sha or closed:
return sha
detail = MERGIFY_DEQUEUE_HINT
if report is not None:

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 _mergify_departure_hint makes _mergify_departure longer and harder to read

The removed helper was a small pure function: it took a report and a base and returned a hint. Its logic now sits inside _mergify_departure behind nested if/else branches. The output is the same: the None, base_conflict, checks and guidance paths all build identical strings. But the change saves only a few lines, and lookup/landing control flow is now mixed with message formatting in one function. Smallest fix: keep the helper and recover the lines somewhere else, or keep only the early-return change (if sha or closed: return sha).

Comment thread src/loopzero/cli.py
if isinstance(exc, runners.RunnerUsageLimit):
fix = "\nFix: wait for the limit to reset or switch this reviewer's account."
return lines[0], detail + fix, _FALLBACK_REASONS[1]
return lines[0], detail + "\nFix: wait for the limit to reset or switch this reviewer's account.", _FALLBACK_REASONS[1]

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: Lines were joined past the 100-column limit to save line count

In _review_failure (the RunnerUsageLimit return), _save_review (the write_local_state call) and _verify_wait_snapshot (latest = config if args is None else ...), statements are merged into lines of roughly 115–135 characters. pyproject.toml sets line-length = 100. E501 is not enabled, so lint still passes. Still, this cuts line count without removing any duplication, and it makes these lines harder to read. Smallest fix: keep the original multi-line forms and take the line savings from real deduplication.

Comment thread src/loopzero/cli.py
prefix = task[:task_first.start()] if task_first else task
content = existing[first.start():] if first else ""
content = existing[first.start():] if (first := pattern.search(existing)) else ""
prefix = task[:first.start()] if (first := pattern.search(task)) else task

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: The walrus reuses first for two different searches

first is first set to the match in existing and is then rebound to the match in task on the next line. The result is correct because each conditional expression is evaluated before the next assignment. But a reader can easily confuse the two, and swapping the lines or reading first later would silently use the wrong match. Smallest fix: use separate names, e.g. (task_first := pattern.search(task)).

Comment thread src/loopzero/cli.py
return 3
pr, readiness, kicked = waited
assert readiness is not None
_prequeue_size_budget(wt, config, pr, readiness)

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: Removing assert readiness is not None drops type narrowing in cmd_ready

_wait_with_deadline is annotated to return Readiness | None as the second tuple element. The removed asserts were what narrowed readiness before _prequeue_size_budget and _readiness_messages. The runtime behavior is unchanged, because allow_merged is False here and the readiness is never None. However, docs/CODE-HEALTH.md recommends a type checker (ty/basedpyright), and that checker would now report an Optional-member access. Also, if a future caller passes allow_merged, the failure would become an AttributeError, which _run does not catch, rather than a clear assertion failure. Consider keeping one assert after the wait block.

@eowca
eowca marked this pull request as ready for review November 26, 2026 12:28
@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 98538be at 12:33 UTC

5 min in the queue, 3 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 12:28 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1883
  • ✅ Merged 12:33 · 98538be · 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 98538be 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-cut branch November 26, 2026 12: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