refactor: split opencode runtime and tests #17

Merged
masi merged 2 commits from refactor/split-opencode-modules into main 2026-09-01 03:35:19 +00:00
Contributor

Summary

  • reduce pilot/review/opencode.py to a 674-line compatibility and orchestration seam
  • split workspace preparation, lens configuration, lens execution, runtime, and synthesis into focused modules
  • split the 957-line opencode test monolith into workspace, lenses, and response test suites
  • update architecture and webhook documentation to match the current module layout
  • preserve compatibility exports and existing monkeypatch seams

Verification

  • python3 -m compileall -q pilot tests
  • python3 -m pytest tests/pilot -q
  • 516 tests passed
  • git diff --check passed
## Summary - reduce pilot/review/opencode.py to a 674-line compatibility and orchestration seam - split workspace preparation, lens configuration, lens execution, runtime, and synthesis into focused modules - split the 957-line opencode test monolith into workspace, lenses, and response test suites - update architecture and webhook documentation to match the current module layout - preserve compatibility exports and existing monkeypatch seams ## Verification - python3 -m compileall -q pilot tests - python3 -m pytest tests/pilot -q - 516 tests passed - git diff --check passed
masi added 1 commit 2026-09-01 03:13:01 +00:00
pragent-bot bot reviewed 2026-09-01 03:20:30 +00:00
pragent-bot bot left a comment

🤖 AI Review · pragent pilot · headroom/MiniMax-M2.7 · f485d9fa · Merge confidence: 4/5 🟢

PR-Agent pilot on this repo. Comments are LLM-generated; treat as suggestions, not mandates.

Summary of Changes

  • Splits opencode.py workspace preparation into pilot/review/opencode_workspace.py (archive fetch, tar extraction, sanitization, brief rendering, factory drop)
  • Splits lens configuration into pilot/review/opencode_lens_config.py (ReviewerSpec dataclass, config parsing, reviewer resolution) — includes duplicate dead functions
  • Splits finding synthesis into pilot/review/opencode_synthesis.py (normalize, deduplicate, cap, tone-strip, summary field synthesis)
  • Splits lens execution into pilot/review/opencode_lenses.py and pilot/review/opencode_runtime.py (isolated subprocess, environment allow-listing, warm-up)

Key Risks & Concerns

  • Duplicate _coerce_str/_coerce_int definitions in opencode_lens_config.py shadow the first definitions with identical implementations — dead code and a merge artifact that should be removed
  • opencode.py imports many symbols from submodules that are unused in the module body and may be retained only for backward-compatibility re-exports — should be made explicit with all to avoid confusing future readers
  • opencode_synthesis.py imports concurrent.futures and dataclasses but never uses them — vestigial imports from the original monolith not cleaned up in the refactor

Findings Overview

1 inline comment(s); 1 total.

Severity Location Finding
🟡 [MEDIUM] pilot/review/opencode_lens_config.py:58 _coerce_str is defined twice in this module — lines 29-30 and lines 58-59. The second definition shadows the first with an identical implementation. Same applies to _coerce_int at lines 33-38 and 62-67. This is a merge artifact that leaves dead code and could confuse future maintainers about which definition is authoritative.
🔋 AI Usage & Run Details
  • Model / Engine: headroom/MiniMax-M2.7 · opencode · 14 steps · 442.0s
  • Total Tokens: 147,095 (147.1K) in / 9,003 (9.0K) out (0 reasoning, cache 720,285 (720.3K) read / 72,391 (72.4K) write, 948,774 (948.8K) total)
  • Actual: $0.00 (headroom/MiniMax-M2.7 — free tier)
  • Scope: Whole-repo checkout at head sha (agent can read any file + run linters, not just the diff) — input tokens include files read beyond the diff. Per-comment output is attributed (one model pass produces all findings; output split by each finding's body weight).
🤖 **AI Review** · pragent pilot · headroom/MiniMax-M2.7 · `f485d9fa` · Merge confidence: 4/5 🟢 > PR-Agent pilot on this repo. Comments are LLM-generated; treat as suggestions, not mandates. ### Summary of Changes - Splits opencode.py workspace preparation into pilot/review/opencode_workspace.py (archive fetch, tar extraction, sanitization, brief rendering, factory drop) - Splits lens configuration into pilot/review/opencode_lens_config.py (ReviewerSpec dataclass, config parsing, reviewer resolution) — includes duplicate dead functions - Splits finding synthesis into pilot/review/opencode_synthesis.py (normalize, deduplicate, cap, tone-strip, summary field synthesis) - Splits lens execution into pilot/review/opencode_lenses.py and pilot/review/opencode_runtime.py (isolated subprocess, environment allow-listing, warm-up) ### Key Risks & Concerns - Duplicate _coerce_str/_coerce_int definitions in opencode_lens_config.py shadow the first definitions with identical implementations — dead code and a merge artifact that should be removed - opencode.py imports many symbols from submodules that are unused in the module body and may be retained only for backward-compatibility re-exports — should be made explicit with __all__ to avoid confusing future readers - opencode_synthesis.py imports concurrent.futures and dataclasses but never uses them — vestigial imports from the original monolith not cleaned up in the refactor ### Findings Overview _1 inline comment(s); 1 total._ | Severity | Location | Finding | |---|---|---| | 🟡 [MEDIUM] | `pilot/review/opencode_lens_config.py:58` | _coerce_str is defined twice in this module — lines 29-30 and lines 58-59. The second definition shadows the first with an identical implementation. Same applies to _coerce_int at lines 33-38 and 62-67. This is a merge artifact that leaves dead code and could confuse future maintainers about which definition is authoritative. | <details> <summary>🔋 AI Usage & Run Details</summary> - **Model / Engine**: `headroom/MiniMax-M2.7` · opencode · 14 steps · 442.0s - **Total Tokens**: 147,095 (147.1K) in / 9,003 (9.0K) out (0 reasoning, cache 720,285 (720.3K) read / 72,391 (72.4K) write, 948,774 (948.8K) total) - **Actual**: $0.00 (headroom/MiniMax-M2.7 — free tier) - **Scope**: Whole-repo checkout at head sha (agent can read any file + run linters, not just the diff) — input tokens include files read beyond the diff. Per-comment output is *attributed* (one model pass produces all findings; output split by each finding's body weight). </details> <!-- pragent:sha=f485d9faf98e4a443cfd4b4fd37272202e0469d7 -->
@@ -0,0 +55,4 @@
]
def _coerce_str(v, default: str = "") -> str:

🟡 [MEDIUM] _coerce_str is defined twice in this module — lines 29-30 and lines 58-59. The second definition shadows the first with an identical implementation. Same applies to _coerce_int at lines 33-38 and 62-67. This is a merge artifact that leaves dead code and could confuse future maintainers about which definition is authoritative.

Fix: Remove the duplicate definitions at lines 58-67; keep the first definitions at lines 29-38.

def _coerce_str(v, default: str = "") -> str:
    return str(v).strip() if isinstance(v, (str, int, float)) else default


def _coerce_int(v, default: int, lo: int, hi: int) -> int:
    try:
        n = int(v)
    except (TypeError, ValueError):
        return default
    return max(lo, min(hi, n))

🪙 ~9,003 (9.0K) tok (100% · attributed output)

🟡 [MEDIUM] _coerce_str is defined twice in this module — lines 29-30 and lines 58-59. The second definition shadows the first with an identical implementation. Same applies to _coerce_int at lines 33-38 and 62-67. This is a merge artifact that leaves dead code and could confuse future maintainers about which definition is authoritative. **Fix:** Remove the duplicate definitions at lines 58-67; keep the first definitions at lines 29-38. ```suggestion def _coerce_str(v, default: str = "") -> str: return str(v).strip() if isinstance(v, (str, int, float)) else default def _coerce_int(v, default: int, lo: int, hi: int) -> int: try: n = int(v) except (TypeError, ValueError): return default return max(lo, min(hi, n)) ``` 🪙 ~9,003 (9.0K) tok (100% · attributed output)
masi marked this conversation as resolved
masi added 1 commit 2026-09-01 03:27:55 +00:00
pragent-bot bot reviewed 2026-09-01 03:33:44 +00:00
pragent-bot bot left a comment

🤖 AI Review · pragent pilot · headroom/MiniMax-M2.7 · e6cb7d01 · Merge confidence: 5/5 🟢

PR-Agent pilot on this repo. Comments are LLM-generated; treat as suggestions, not mandates.

Summary of Changes

  • Split pilot/review/opencode.py (957 lines) into opencode_workspace.py, opencode_lens_config.py, opencode_lenses.py, opencode_synthesis.py, and opencode_runtime.py — preserving all exports via a compatibility seam
  • Added backward-compatibility shim at pilot/opencode_review.py that redirects to the new module path
  • Split the opencode test monolith into opencode_lenses_test.py and opencode_response_test.py focused suites
  • Updated architecture.md, pilot/README-webhook.md, and pilot/README.md to reflect the new module layout

Key Risks & Concerns

None identified.

🔋 AI Usage & Run Details
  • Model / Engine: headroom/MiniMax-M2.7 · opencode · 12 steps · 328.5s
  • Total Tokens: 46,039 (46.0K) in / 6,158 (6.2K) out (0 reasoning, cache 461,186 (461.2K) read / 57,269 (57.3K) write, 570,652 (570.7K) total)
  • Actual: $0.00 (headroom/MiniMax-M2.7 — free tier)
  • Scope: Whole-repo checkout at head sha (agent can read any file + run linters, not just the diff) — input tokens include files read beyond the diff. Per-comment output is attributed (one model pass produces all findings; output split by each finding's body weight).
🤖 **AI Review** · pragent pilot · headroom/MiniMax-M2.7 · `e6cb7d01` · Merge confidence: 5/5 🟢 > PR-Agent pilot on this repo. Comments are LLM-generated; treat as suggestions, not mandates. ### Summary of Changes - Split pilot/review/opencode.py (957 lines) into opencode_workspace.py, opencode_lens_config.py, opencode_lenses.py, opencode_synthesis.py, and opencode_runtime.py — preserving all exports via a compatibility seam - Added backward-compatibility shim at pilot/opencode_review.py that redirects to the new module path - Split the opencode test monolith into opencode_lenses_test.py and opencode_response_test.py focused suites - Updated architecture.md, pilot/README-webhook.md, and pilot/README.md to reflect the new module layout ### Key Risks & Concerns _None identified._ <details> <summary>🔋 AI Usage & Run Details</summary> - **Model / Engine**: `headroom/MiniMax-M2.7` · opencode · 12 steps · 328.5s - **Total Tokens**: 46,039 (46.0K) in / 6,158 (6.2K) out (0 reasoning, cache 461,186 (461.2K) read / 57,269 (57.3K) write, 570,652 (570.7K) total) - **Actual**: $0.00 (headroom/MiniMax-M2.7 — free tier) - **Scope**: Whole-repo checkout at head sha (agent can read any file + run linters, not just the diff) — input tokens include files read beyond the diff. Per-comment output is *attributed* (one model pass produces all findings; output split by each finding's body weight). </details> <!-- pragent:sha=e6cb7d01a648d45fbd13d9d5e2a6b8db9fdf4525 -->
masi merged commit a202bd3598 into main 2026-09-01 03:35:19 +00:00
masi deleted branch refactor/split-opencode-modules 2026-09-01 03:35:21 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: gitea_admin/pragent#17