Commit Graph

2 Commits

Author SHA1 Message Date
drew 0bc734c020 style: ruff format the controller-state-machine branch (288 files)
Applies `ruff format` to the accumulated formatting debt on this branch.
Formatting-only — no behavioral changes. Required for CI/lint's format
gate (`nox -s format -- --check`), which the branch was failing on 288
tracked files that drifted from ruff's canonical style.

In-progress WIP files are intentionally excluded so this commit stays a
clean formatting-only diff.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-20 00:09:17 -04:00
drew f3b10a5e72 refactor(auto-agents): rename review clone/diff substrate for implementer parity
Phase 0 of the implementer-parity plan: rename the formerly review-only
pre-clone + diff-fetch helpers so the implementer dispatcher can share
them in upcoming phases without forking the substrate or hauling
review-specific naming into a different work-group registry.

Renames (git rename-detected):
- tools/_review_clone.py    -> tools/_pr_clone.py
- tools/_review_diff.py     -> tools/_pr_diff.py

Extractions (new shared modules):
- tools/_pr_prompt.py            UNTRUSTED-CONTENT marker helpers
                                 (fence_markers, redact_marker,
                                 wrap_untrusted_section) for Phase 2
                                 pre-fetch consumers.
- tools/_commit_lint.py          lint_commit_message + CONVENTIONAL_TYPES
                                 + _bot_committer_email so both
                                 self-validation CLIs reuse one lint.
- tools/_validate_cli_common.py  DiffResult / DiffErrorKind /
                                 diff_from_worktree /
                                 commit_from_worktree / _excerpt_*
                                 / resolve_base_ref / emit_error so
                                 implementer_validate (Phase 1) does
                                 not duplicate ~280 lines of CLI
                                 plumbing.

Slim:
- tools/_review_validate_helpers.py shrinks 499 -> 223 lines and now
  owns only review-specific validate_position_in_diff +
  draft_strict_checks. Re-exports the moved helpers so existing test
  monkeypatches (helpers.diff_from_worktree, helpers.subprocess) keep
  working without churn.

API surface change:
- prepare_pr_worktree(cfg, n, sha, *, kind="review") -- back-compat
  default; implementer dispatcher passes kind="implementer" in Phase 3.
- _worktree_base / _is_preclone_disabled now consult per-kind env
  vars (REVIEW_DISPATCHER_WORKTREE_BASE vs.
  IMPLEMENTER_DISPATCHER_WORKTREE_BASE; matching DISABLE_PRECLONE
  toggles). Mirror is shared per repo regardless of kind.
- WorktreeHandle gains a `kind` field (defaulted) so cleanup paths
  can discriminate.

Bug fix discovered along the way:
- _validate_cli_common.emit_error froze stream=sys.stdout at
  function-definition time, which made pytest's capsys invisible to
  the JSON error output. Now resolves sys.stdout at call time.

Tests:
- New tests/auto_agents/test_shared_substrate.py (14 tests) covers:
  every public symbol the legacy modules exposed, helper-re-export
  identity preservation, per-kind worktree-base + disable-toggle
  semantics, the kind back-compat default, and the new _pr_prompt
  fence/redact helpers. Also guards against the deleted
  _review_clone.py / _review_diff.py reappearing on disk.
- All 24 importing call-sites updated; full reviewer test suite
  remains green (637 passed, 3 skipped).
- `git grep '_review_clone\|_review_diff' tools/` returns zero
  matches, the plan's Phase 0 exit criterion.

Sets up Phase 1 (implementer-helpers skill), Phase 2 (pre-fetch
parity), and Phase 3 (pre-cloned implementer worktrees) with no
shared reviewer-only code paths.

ISSUES CLOSED: #N/A

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 13:25:35 -04:00