Repository navigation
Deduplicate CLI checks, waits and diagnostics - #1876
Conversation
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>
There was a problem hiding this comment.
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.
| if sha or closed: | ||
| return sha | ||
| detail = MERGIFY_DEQUEUE_HINT | ||
| if report is not None: |
There was a problem hiding this comment.
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).
| 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] |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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)).
| return 3 | ||
| pr, readiness, kicked = waited | ||
| assert readiness is not None | ||
| _prequeue_size_budget(wt, config, pr, readiness) |
There was a problem hiding this comment.
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.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
Refs #575
Reduce
src/loopzero/cli.pyby 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.pysuite against base51d679a1and 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-botwith what you need.Review
Validation
Recorded for
6eb5386545d0uv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0