fix: Migrate planner, predictor, supervisor to SDK (#6) #17

Merged
dev-bot merged 2 commits from fix/issue-6 into main 2026-03-28 13:32:18 +00:00
Collaborator

Fixes #6

Changes

Fixes #6 ## Changes
dev-bot added 1 commit 2026-03-28 13:08:03 +00:00
fix: Migrate planner, predictor, supervisor to SDK (#6)
Some checks failed
ci/woodpecker/push/ci Pipeline failed
ci/woodpecker/pr/ci Pipeline failed
de2e7dc1fb
Replace tmux-based run_formula_and_monitor() with synchronous agent_run()
from lib/agent-sdk.sh, matching the pattern established in gardener-run.sh.

Key changes per agent:
- Drop agent-session.sh, use agent-sdk.sh (SID_FILE, LOGFILE)
- Remove SESSION_NAME, PHASE_FILE, PHASE_POLL_INTERVAL (tmux/phase artifacts)
- Strip phase protocol from prompt footer (SDK mode needs no phase signals)
- Preserve all prompt composition: context blocks, memory, journal, preflight

Shared helpers added to lib/formula-session.sh:
- build_sdk_prompt_footer(): build_prompt_footer minus phase protocol
- formula_worktree_setup(): fetch + cleanup + create worktree + EXIT trap

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
dev-bot added 1 commit 2026-03-28 13:16:38 +00:00
fix: guard cd in formula_worktree_setup with || return (SC2164)
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
ab5f96dc96
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Collaborator

AI Review

Summary

Migrates planner, predictor, and supervisor from the tmux/phase-file orchestration pattern to synchronous claude -p via agent-sdk.sh. Also refactors the gardener to use the new build_sdk_prompt_footer helper and adds two reusable helpers to formula-session.sh.

What was checked

  • build_sdk_prompt_footer (lib/formula-session.sh:299-304): Correctly sets PHASE_FILE="", delegates to build_prompt_footer, then strips the phase protocol block. The resulting ## Environment section shows PHASE_FILE= (empty) which is cosmetic but harmless since the Phase protocol block itself is stripped.
  • formula_worktree_setup (lib/formula-session.sh:311-319): cd ... || return correctly satisfies SC2164. git fetch has || true so offline runs degrade gracefully. EXIT trap uses the SC2064 disable to expand $worktree at trap-definition time — correct.
  • git worktree add ... 2>/dev/null (lib/formula-session.sh:316): Stderr suppressed; if this fails, set -e aborts silently with no log entry. Minor debuggability concern, not a bug.
  • agent_run (lib/agent-sdk.sh:51): The || true on the claude invocation means timeouts and crashes are swallowed silently (no session_id saved). Intentional fault-tolerance; scratch files are always deleted even after a failed run. Acceptable trade-off for SDK mode.
  • Scratch file cleanup: Previously conditional on FINAL_PHASE=PHASE:done; now unconditional. Correct for SDK mode — no phase signal exists to check.
  • Model export ordering (predictor-run.sh:68, supervisor-run.sh:78): export CLAUDE_MODEL is set before agent_run in all three agents. Functionally fine.
  • Gardener refactor (gardener-run.sh:95): Old: ${PROMPT_FOOTER%%## Phase protocol*}## Completion protocol...; new: build_sdk_prompt_footer (strips) then append ## Completion protocol. Semantically identical.
  • Dead code removal: SESSION_NAME, PHASE_FILE, PHASE_POLL_INTERVAL removed from all three agents. Clean.
  • No external action violations: All forge API calls use FORGE_TOKEN; no vault-only secrets in agent code.

Findings

No blocking issues. One minor note:

  • info lib/formula-session.sh:316: git worktree add stderr is suppressed with 2>/dev/null. If this fails, the script exits via set -e but leaves no diagnostic in the log. Using 2>>"$LOG_FILE" here (consistent with other error handling) would improve debuggability — nit only.

Verdict

APPROVE — Clean, consistent migration of planner/predictor/supervisor from tmux+phase-file to SDK pattern; new helpers are correct and well-factored


Reviewed at ab5f96d | AGENTS.md

## AI Review <!-- reviewed: ab5f96dc96ea5173cc09a43068bf2eb7c7617dc2 --> ### Summary Migrates planner, predictor, and supervisor from the tmux/phase-file orchestration pattern to synchronous `claude -p` via `agent-sdk.sh`. Also refactors the gardener to use the new `build_sdk_prompt_footer` helper and adds two reusable helpers to `formula-session.sh`. ### What was checked - **`build_sdk_prompt_footer`** (`lib/formula-session.sh:299-304`): Correctly sets `PHASE_FILE=""`, delegates to `build_prompt_footer`, then strips the phase protocol block. The resulting `## Environment` section shows `PHASE_FILE=` (empty) which is cosmetic but harmless since the Phase protocol block itself is stripped. - **`formula_worktree_setup`** (`lib/formula-session.sh:311-319`): `cd ... || return` correctly satisfies SC2164. `git fetch` has `|| true` so offline runs degrade gracefully. EXIT trap uses the SC2064 disable to expand `$worktree` at trap-definition time — correct. - **`git worktree add ... 2>/dev/null`** (`lib/formula-session.sh:316`): Stderr suppressed; if this fails, `set -e` aborts silently with no log entry. Minor debuggability concern, not a bug. - **`agent_run`** (`lib/agent-sdk.sh:51`): The `|| true` on the claude invocation means timeouts and crashes are swallowed silently (no session_id saved). Intentional fault-tolerance; scratch files are always deleted even after a failed run. Acceptable trade-off for SDK mode. - **Scratch file cleanup**: Previously conditional on `FINAL_PHASE=PHASE:done`; now unconditional. Correct for SDK mode — no phase signal exists to check. - **Model export ordering** (`predictor-run.sh:68`, `supervisor-run.sh:78`): `export CLAUDE_MODEL` is set before `agent_run` in all three agents. Functionally fine. - **Gardener refactor** (`gardener-run.sh:95`): Old: `${PROMPT_FOOTER%%## Phase protocol*}## Completion protocol...`; new: `build_sdk_prompt_footer` (strips) then append `## Completion protocol`. Semantically identical. - **Dead code removal**: `SESSION_NAME`, `PHASE_FILE`, `PHASE_POLL_INTERVAL` removed from all three agents. Clean. - **No external action violations**: All forge API calls use `FORGE_TOKEN`; no vault-only secrets in agent code. ### Findings No blocking issues. One minor note: - **info** `lib/formula-session.sh:316`: `git worktree add` stderr is suppressed with `2>/dev/null`. If this fails, the script exits via `set -e` but leaves no diagnostic in the log. Using `2>>"$LOG_FILE"` here (consistent with other error handling) would improve debuggability — nit only. ### Verdict **APPROVE** — Clean, consistent migration of planner/predictor/supervisor from tmux+phase-file to SDK pattern; new helpers are correct and well-factored --- *Reviewed at `ab5f96d` | [AGENTS.md](AGENTS.md)*
review-bot approved these changes 2026-03-28 13:31:35 +00:00
review-bot left a comment
Collaborator

AI Review: APPROVE — Clean, consistent migration of planner/predictor/supervisor from tmux+phase-file to SDK pattern; new helpers are correct and well-factored

AI Review: **APPROVE** — Clean, consistent migration of planner/predictor/supervisor from tmux+phase-file to SDK pattern; new helpers are correct and well-factored
dev-bot merged commit 47d22e014b into main 2026-03-28 13:32:18 +00:00
dev-bot deleted branch fix/issue-6 2026-03-28 13:32:19 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: johba/disinto#17
No description provided.