Commit Graph

2 Commits

Author SHA1 Message Date
drew 355af84fb1 refactor(auto-agents): hard-switch supervisor decommission + implementer parity
Combines the 2026-05-09 hard-switch decommissioning of the LLM
implementation/pr-review supervisors with the Phase 2/3/4/5b
implementer parity work (prefetch + preclone + telemetry + operator-
status comments) and the third/fourth-round critique cleanup.

Removed
- .opencode/agents/implementation-supervisor.md (340 LoC)
- .opencode/agents/pr-review-supervisor.md (348 LoC)
- _dispatch_runtime.assert_no_legacy_supervisor +
  detect_legacy_supervisor_sessions and the SUPERVISOR_TAGS /
  SUPERVISOR_OVERRIDE_ENV plumbing in both dispatchers, along with
  the five supervisor-coexistence tests in test_dispatch_runtime.py
- _watchdog_helpers.parse_truthy_env + watchdog_check.py
  --check-env mode + their dedicated unit tests (the legacy
  DISPATCHERS_RUNNING gate had no callers after the watchdog
  rewrite became unconditional)

Added
- tools/_implementer_prefetch.py — pre-dispatch Forgejo fetches
  (PR/issue body, diff, CI status, comments, reviews, linked
  issues, Epic) per work group
- tools/_implementer_prompt.py — pure-function prompt assembly
  with UNTRUSTED CONTENT fences and shared
  PR_COMPLIANCE_CHECKLIST / OUTPUT_CONTRACT
- tools/_phase4_telemetry.py — extractor + JSONL sink for the
  Phase 4 plan metrics
- tools/_status_comments.py — per-fingerprint operator-status
  comment substrate, namespaced for reviewer + implementer
- _dispatch_runtime.SessionContext dataclass + SIGTERM/SIGINT
  cooperative claim release with synchronous handler
- TestSupervisorAgentsDecommissioned and
  TestAutoAgentsMdIsWatchdogOnly anti-regression lints (glob over
  *supervisor*.md in .opencode/agents/, plus body keyword bans
  and bash allow-list lint)
- pyproject.toml `slow` marker registration for the subprocess
  SIGTERM smoke test
- tests/auto_agents/fixtures/{phase4-acceptance.yaml,
  phase4-session-output-sample.txt}

Rewritten
- .opencode/agents/auto-agents.md from supervisor-fleet manager
  (~545 LoC) to dispatcher heartbeat watchdog (~184 LoC); host
  init system / process manager (systemd / runit / docker) is now
  the explicit restart authority instead of "host-level process
  supervisor"
- AGENTS.md production-launch story (Shells A-D) reflects the
  deterministic-Python orchestration boundary; the bot-identity
  fork-mode paragraph reads from FORGEJO_OWNER / FORGEJO_REPO
  env vars instead of the deleted hard-coded supervisor flags
- tools/launch_fork.sh header documents three host-level entry
  points (dispatchers-launcher.sh, opencode-builder.sh,
  merge_drive.py)
- worker self-descriptions (implementation-worker.md,
  pr-review-worker.md) refer to the dispatcher / merge driver
  instead of the deleted supervisors; session-health-quick-util.md
  and async-agent-util.md treat -SUP-suffixed sessions as
  flag-and-escalate signals

Tests: 1006 passed, 3 skipped, 0 failed under tests/auto_agents/.
Lint: zero new ruff errors on touched files; three pre-existing
errors in tools/_pr_diff.py at lines blamed to 2026-05-07.

Operator note: the only in-process rollback knob for prefetch
issues is IMPLEMENTER_DISPATCHER_PREFETCH=0 (and the matching
IMPLEMENTER_DISPATCHER_PRECLONE=0). Anything beyond that is git
revert of this commit. Residual doc surface in the
auto-agents-system and supervised-workers skill READMEs is
documentation-only; the agent files those READMEs reference no
longer exist.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 16:03:43 -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