Parent: #204 | Phase 1
⚠️ Critical gap: The Rig DO's startMergeInContainer() calls container.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
/merge or /git/merge endpoint ❌ — 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
conflict with 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/merge to container
- Container merges and pushes (or reports conflict)
- DO updates review queue entry status
Acceptance Criteria
Parent: #204 | Phase 1
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 ✅/mergeor/git/mergeendpoint ❌ — this is the gapImplementation
1. Container:
POST /git/mergeendpointAdd to
control-server.ts:Implementation:
git merge --no-ff <branch>in the worktreemergedconflictwith details2. Rig DO: Update
startMergeInContainer()Ensure the URL matches the container endpoint (
/git/mergenot/merge). PassgitUrlfrom rig config.3. Rig DO: Handle merge result
merged: mark review queue entry as 'merged', close the beadconflict: mark entry as 'failed', create escalation bead with conflict detailsFlow
gt_doneagentDone()→ unhook, submit to review queue, arm alarmprocessReviewQueue()pops entrystartMergeInContainer()→POST /git/mergeto containerAcceptance Criteria
POST /git/mergeendpoint implementedstartMergeInContainer()URL matches container endpoint