-
Notifications
You must be signed in to change notification settings - Fork 24
[Gastown] Manual Merge Flow — Container /merge Endpoint + Review Queue Processing (P0) #214
Copy link
Copy link
Closed
Description
Parent: #204 | Phase 1
⚠️ Critical gap: The Rig DO'sstartMergeInContainer()callscontainer.fetch('http://container/merge', ...)but the container control server has no /merge endpoint. This request 404s. The entire polecat→done→merge→closed loop is broken — beads submitted to the review queue sit there permanently.
Goal
When a polecat calls gt_done, process the review queue entry with a simple deterministic merge. No AI reasoning in Phase 1.
Current State
agentDone()in Rig DO works: unhooks bead, submits to review queue, arms alarm ✅processReviewQueue()in alarm handler pops pending entries ✅startMergeInContainer()builds request and calls container ✅- Container has no
/mergeor/git/mergeendpoint ❌ — this is the gap - Merge always fails → entry marked 'failed' → stuck
Implementation
1. Container: POST /git/merge endpoint
Add to control-server.ts:
// POST /git/merge
// Deterministic merge of a polecat branch into the target branch
{
rigId: string,
branch: string, // polecat's branch (e.g., "gt/toast")
targetBranch: string, // e.g., "main"
gitUrl: string // for fetch if needed
}
→ { status: 'merged' | 'conflict', message: string, commitSha?: string }Implementation:
- Ensure repo is cloned/fetched for the rig
- Create a temporary worktree on the target branch
git merge --no-ff <branch>in the worktree- If success: push to remote, clean up worktree, return
merged - If conflict: abort merge, clean up worktree, return
conflictwith details - No AI — purely mechanical
2. Rig DO: Update startMergeInContainer()
Ensure the URL matches the container endpoint (/git/merge not /merge). Pass gitUrl from rig config.
3. Rig DO: Handle merge result
- On
merged: mark review queue entry as 'merged', close the bead - On
conflict: mark entry as 'failed', create escalation bead with conflict details
Flow
- Polecat pushes branch, calls
gt_done agentDone()→ unhook, submit to review queue, arm alarm- Alarm fires →
processReviewQueue()pops entry startMergeInContainer()→POST /git/mergeto container- Container merges and pushes (or reports conflict)
- DO updates review queue entry status
Acceptance Criteria
- Container
POST /git/mergeendpoint implemented - Deterministic merge (no AI) with proper git commands
- Merge success: entry marked 'merged', bead closed, branch pushed
- Merge conflict: entry marked 'failed', escalation bead created
- Rig DO
startMergeInContainer()URL matches container endpoint - End-to-end: polecat calls gt_done → review queue → merge → bead closed
- Git worktree cleanup after merge (success or failure)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels