Refinery processes MERGE_READY and sends MERGED (gt-7uhts)

Updated mol-refinery-patrol formula with:
- MERGE_READY handling in inbox-check (parse branch/issue/polecat)
- Mail-based queue instead of git branch scanning
- MERGED mail sent to Witness after successful merge
- Flow diagram showing Witness→Refinery→Witness mail protocol
- Bumped formula version to 2

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-28 09:58:22 -08:00
parent 600c468a9b
commit ae8539d7e0
+118 -48
View File
@@ -3,41 +3,103 @@ Merge queue processor patrol loop.
The Refinery is the Engineer in the engine room. You process polecat branches, merging them to main one at a time with sequential rebasing. The Refinery is the Engineer in the engine room. You process polecat branches, merging them to main one at a time with sequential rebasing.
**The Scotty Test**: Before proceeding past any failure, ask yourself: \"Would Scotty walk past a warp core leak because it existed before his shift?\"""" **The Scotty Test**: Before proceeding past any failure, ask yourself: "Would Scotty walk past a warp core leak because it existed before his shift?"
## Merge Flow
The Refinery receives MERGE_READY mail from Witnesses when polecats complete work:
```
Witness Refinery Git
│ │ │
│ MERGE_READY │ │
│─────────────────────────>│ │
│ │ │
│ (verify branch) │
│ │ fetch & rebase │
│ │──────────────────────────>│
│ │ │
│ (run tests) │
│ │ │
│ (if pass) │
│ │ merge & push │
│ │──────────────────────────>│
│ │ │
│ MERGED │ │
│<─────────────────────────│ │
│ │ │
```
After successful merge, Refinery sends MERGED mail back to Witness so it can
complete cleanup (nuke the polecat worktree)."""
formula = "mol-refinery-patrol" formula = "mol-refinery-patrol"
version = 1 version = 2
[[steps]] [[steps]]
id = "inbox-check"
title = "Check refinery mail"
description = """ description = """
Check mail for MR submissions, escalations, messages. Check mail for MERGE_READY submissions, escalations, and messages.
```bash ```bash
gt mail inbox gt mail inbox
# Process any urgent items
``` ```
Handle shutdown requests, escalations, and status queries.""" For each message:
id = "inbox-check"
title = "Check refinery mail"
[[steps]] **MERGE_READY**:
description = """ A polecat's work is ready for merge. Extract details and track for processing.
Fetch remote and identify polecat branches waiting.
```bash ```bash
git fetch origin # Parse MERGE_READY message body:
git branch -r | grep polecat # Branch: <branch>
gt refinery queue <rig> # Issue: <issue-id>
``` # Polecat: <polecat-name>
# Verified: clean git state, issue closed
If queue empty, skip to context-check step. Track branch list for this cycle.""" # Track in your merge queue for this patrol cycle:
id = "queue-scan" # - Branch name
needs = ["inbox-check"] # - Issue ID
title = "Scan merge queue" # - Polecat name (for MERGED response)
```
Mark as read. The work will be processed in queue-scan/process-branch.
**PATROL: Wake up**:
Witness detected MRs waiting but refinery idle. Acknowledge and proceed.
**HELP / Blocked**:
Assess and respond. If you can't help, escalate to Mayor.
**HANDOFF**:
Read predecessor context. Check for in-flight merges."""
[[steps]] [[steps]]
id = "queue-scan"
title = "Scan merge queue"
needs = ["inbox-check"]
description = """ description = """
Pick next branch. Rebase on current main. Review the queue built from MERGE_READY messages in inbox-check.
```bash
# For each queued merge request, verify the branch exists:
git fetch origin
git branch -r | grep <branch>
```
If queue empty, skip to context-check step.
If branch doesn't exist for a queued item:
- Mail witness: Branch not found, cannot merge
- Remove from queue
Track verified branch list for this cycle."""
[[steps]]
id = "process-branch"
title = "Process next branch"
needs = ["queue-scan"]
description = """
Pick next branch from queue. Rebase on current main.
```bash ```bash
git checkout -b temp origin/<polecat-branch> git checkout -b temp origin/<polecat-branch>
@@ -46,13 +108,13 @@ git rebase origin/main
If rebase conflicts and unresolvable: If rebase conflicts and unresolvable:
- git rebase --abort - git rebase --abort
- Notify polecat to fix and resubmit - Notify polecat/witness to fix and resubmit
- Skip to loop-check for next branch""" - Skip to loop-check for next branch"""
id = "process-branch"
needs = ["queue-scan"]
title = "Process next branch"
[[steps]] [[steps]]
id = "run-tests"
title = "Run test suite"
needs = ["process-branch"]
description = """ description = """
Run the test suite. Run the test suite.
@@ -61,11 +123,11 @@ go test ./...
``` ```
Track results: pass count, fail count, specific failures.""" Track results: pass count, fail count, specific failures."""
id = "run-tests"
needs = ["process-branch"]
title = "Run test suite"
[[steps]] [[steps]]
id = "handle-failures"
title = "Handle test failures"
needs = ["run-tests"]
description = """ description = """
**VERIFICATION GATE**: This step enforces the Beads Promise. **VERIFICATION GATE**: This step enforces the Beads Promise.
@@ -75,23 +137,23 @@ If tests FAILED:
1. Diagnose: Is this a branch regression or pre-existing on main? 1. Diagnose: Is this a branch regression or pre-existing on main?
2. If branch caused it: 2. If branch caused it:
- Abort merge - Abort merge
- Notify polecat: \"Tests failing. Please fix and resubmit.\" - Notify polecat: "Tests failing. Please fix and resubmit."
- Skip to loop-check - Skip to loop-check
3. If pre-existing on main: 3. If pre-existing on main:
- Option A: Fix it yourself (you're the Engineer!) - Option A: Fix it yourself (you're the Engineer!)
- Option B: File a bead: bd create --type=bug --priority=1 --title=\"...\" - Option B: File a bead: bd create --type=bug --priority=1 --title="..."
**GATE REQUIREMENT**: You CANNOT proceed to merge-push without: **GATE REQUIREMENT**: You CANNOT proceed to merge-push without:
- Tests passing, OR - Tests passing, OR
- Fix committed, OR - Fix committed, OR
- Bead filed for the failure - Bead filed for the failure
This is non-negotiable. Never disavow. Never \"note and proceed.\"""" This is non-negotiable. Never disavow. Never "note and proceed." """
id = "handle-failures"
needs = ["run-tests"]
title = "Handle test failures"
[[steps]] [[steps]]
id = "merge-push"
title = "Merge and push to main"
needs = ["handle-failures"]
description = """ description = """
Merge to main and push immediately. Merge to main and push immediately.
@@ -100,15 +162,25 @@ git checkout main
git merge --ff-only temp git merge --ff-only temp
git push origin main git push origin main
git branch -d temp git branch -d temp
git branch -D <polecat-branch> # Local delete (branches never go to origin) git push origin --delete <polecat-branch> # Delete remote polecat branch
``` ```
**CRITICAL**: After successful merge, send MERGED mail to Witness:
```bash
gt mail send <rig>/witness -s "MERGED <polecat-name>" -m "Branch: <branch>
Issue: <issue-id>
Merged-At: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
```
This signals the Witness to complete cleanup (nuke polecat worktree).
Main has moved. Any remaining branches need rebasing on new baseline.""" Main has moved. Any remaining branches need rebasing on new baseline."""
id = "merge-push"
needs = ["handle-failures"]
title = "Merge and push to main"
[[steps]] [[steps]]
id = "loop-check"
title = "Check for more work"
needs = ["merge-push"]
description = """ description = """
More branches to process? More branches to process?
@@ -116,27 +188,28 @@ If yes: Return to process-branch with next branch.
If no: Continue to generate-summary. If no: Continue to generate-summary.
Track: branches processed, branches skipped (with reasons).""" Track: branches processed, branches skipped (with reasons)."""
id = "loop-check"
needs = ["merge-push"]
title = "Check for more work"
[[steps]] [[steps]]
id = "generate-summary"
title = "Generate handoff summary"
needs = ["loop-check"]
description = """ description = """
Summarize this patrol cycle. Summarize this patrol cycle.
Include: Include:
- Branches processed (count, names) - Branches processed (count, names)
- MERGED mails sent
- Test results (pass/fail) - Test results (pass/fail)
- Issues filed (if any) - Issues filed (if any)
- Branches skipped (with reasons) - Branches skipped (with reasons)
- Any escalations sent - Any escalations sent
This becomes the digest when the patrol is squashed.""" This becomes the digest when the patrol is squashed."""
id = "generate-summary"
needs = ["loop-check"]
title = "Generate handoff summary"
[[steps]] [[steps]]
id = "context-check"
title = "Check own context limit"
needs = ["generate-summary"]
description = """ description = """
Check own context usage. Check own context usage.
@@ -146,11 +219,11 @@ If context is HIGH (>80%):
If context is LOW: If context is LOW:
- Can continue processing""" - Can continue processing"""
id = "context-check"
needs = ["generate-summary"]
title = "Check own context limit"
[[steps]] [[steps]]
id = "burn-or-loop"
title = "Burn and respawn or loop"
needs = ["context-check"]
description = """ description = """
End of patrol cycle decision. End of patrol cycle decision.
@@ -161,6 +234,3 @@ If queue non-empty AND context LOW:
If queue empty OR context HIGH: If queue empty OR context HIGH:
- Burn wisp with summary digest - Burn wisp with summary digest
- Exit (daemon will respawn if needed)""" - Exit (daemon will respawn if needed)"""
id = "burn-or-loop"
needs = ["context-check"]
title = "Burn and respawn or loop"