AI Agents SDE Task Viewer
      • Context
      • Plan
      • Prd
  1. Home
  2. AgentSDE
  3. agent-core
  4. gh-275
  5. plan
  6. plan.md
plan.md(2.9 KB)· Apr 3, 2026· 2 min read
  • Summary
  • Files
  • Steps
  • Verification
  • Risks

Plan: Compound Phase Merged-PR Guard & Docs-Only Validation#

Summary#

Add a pre-compound guard in PhaseRouterService that blocks compound execution until task.prNumber is confirmed merged via the GitHub API, and add post-compound diff validation in PhaseRouterService that rejects compound output touching src/ or test/ files (retry once, then BLOCKED:PERSISTENT).

Files#

FileActionDescription
src/github/github.service.tsmodifyAdd isPrMerged(owner, repo, prNumber) method
src/github/github.service.spec.tsmodifyAdd tests for isPrMerged
src/phase-router/phase-router.service.tsmodifyAdd pre-compound merged-PR guard and post-compound diff validation
src/phase-router/phase-router.service.spec.tsmodifyAdd tests for compound guards (null prNumber, PR not merged, diff validation)
src/internal-adapter/internal-adapter.service.tsmodifyAdd compound-specific advancement logic in advanceAndEnqueue — only enqueue compound when PR is merged

Steps#

  1. Add isPrMerged to GitHubService — call GET /repos/{owner}/{repo}/pulls/{prNumber} and return data.merged === true. Handle 404 as false.
  2. Add merged-PR guard in PhaseRouterService.executePhase — before executing compound, check task.prNumber. If null, signal BLOCKED:PERSISTENT with "compound reached with no PR on record". If set, call isPrMerged; if not merged, signal BLOCKED:TRANSIENT with "PR not yet merged".
  3. Add post-compound diff validation in PhaseRouterService.executePhase — after compound completes, run git diff --name-only origin/master...HEAD in the worktree. If any path starts with src/ or test/, set a retry flag. On first violation, re-invoke compound with an explicit docs-only constraint env var. On second violation, signal BLOCKED:PERSISTENT.
  4. Update advanceAndEnqueue in InternalAdapterService — when advancing from deliver to compound, check that task.prNumber is set before enqueuing (fail-fast guard, complementing the runtime check in step 2).
  5. Write unit tests — cover: (a) isPrMerged happy/404, (b) compound blocked on null prNumber, (c) compound blocked on open PR, (d) compound proceeds on merged PR, (e) diff validation retry and persistent block.

Verification#

  • npm run test passes with new tests covering all compound guard paths
  • npm run lint passes with zero warnings
  • Manual trace: deliver_completed → compound enqueue only fires when prNumber is merged

Risks#

  • Race condition: PR merge webhook and compound advancement could race. Mitigation: the runtime guard in executePhase is the authoritative check; the advanceAndEnqueue guard is a fail-fast optimization.
  • Compound worktree: compound currently has no worktree (not in WORKTREE_PHASES). The diff validation needs access to the git state — will use the artefacts repo or PROJECT_ROOT env var instead.
ContextPrd