Implement Witness-Refinery protocol handlers (gt-m5w4g.2)
Add internal/protocol/ package with handlers for: - MERGE_READY (witness→refinery): worker done, branch ready - MERGED (refinery→witness): merge succeeded, cleanup ok - MERGE_FAILED (refinery→witness): merge failed, needs rework - REWORK_REQUEST (refinery→witness): rebase needed due to conflicts Package structure: - types.go: Protocol message types and payload structs - messages.go: Message builders and body parsers - handlers.go: Handler interface and registry for dispatch - witness_handlers.go: DefaultWitnessHandler implementation - refinery_handlers.go: DefaultRefineryHandler implementation - protocol_test.go: Comprehensive test coverage Also updated docs/mail-protocol.md with: - MERGE_FAILED and REWORK_REQUEST message type documentation - Merge failure and rebase required flow diagrams - Reference to internal/protocol/ package 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,13 +61,73 @@ Verified: clean git state, issue closed
|
||||
```
|
||||
Branch: <branch>
|
||||
Issue: <issue-id>
|
||||
Polecat: <polecat-name>
|
||||
Rig: <rig>
|
||||
Target: <target-branch>
|
||||
Merged-At: <timestamp>
|
||||
Merge-Commit: <sha>
|
||||
```
|
||||
|
||||
**Trigger**: Refinery sends after successful merge to main.
|
||||
|
||||
**Handler**: Witness completes cleanup wisp, nukes polecat worktree.
|
||||
|
||||
### MERGE_FAILED
|
||||
|
||||
**Route**: Refinery → Witness
|
||||
|
||||
**Purpose**: Notify that merge attempt failed (tests, build, or other non-conflict error).
|
||||
|
||||
**Subject format**: `MERGE_FAILED <polecat-name>`
|
||||
|
||||
**Body format**:
|
||||
```
|
||||
Branch: <branch>
|
||||
Issue: <issue-id>
|
||||
Polecat: <polecat-name>
|
||||
Rig: <rig>
|
||||
Target: <target-branch>
|
||||
Failed-At: <timestamp>
|
||||
Failure-Type: <tests|build|push|other>
|
||||
Error: <error-message>
|
||||
```
|
||||
|
||||
**Trigger**: Refinery sends when merge fails for non-conflict reasons.
|
||||
|
||||
**Handler**: Witness notifies polecat, assigns work back for rework.
|
||||
|
||||
### REWORK_REQUEST
|
||||
|
||||
**Route**: Refinery → Witness
|
||||
|
||||
**Purpose**: Request polecat to rebase branch due to merge conflicts.
|
||||
|
||||
**Subject format**: `REWORK_REQUEST <polecat-name>`
|
||||
|
||||
**Body format**:
|
||||
```
|
||||
Branch: <branch>
|
||||
Issue: <issue-id>
|
||||
Polecat: <polecat-name>
|
||||
Rig: <rig>
|
||||
Target: <target-branch>
|
||||
Requested-At: <timestamp>
|
||||
Conflict-Files: <file1>, <file2>, ...
|
||||
|
||||
Please rebase your changes onto <target-branch>:
|
||||
|
||||
git fetch origin
|
||||
git rebase origin/<target-branch>
|
||||
# Resolve any conflicts
|
||||
git push -f
|
||||
|
||||
The Refinery will retry the merge after rebase is complete.
|
||||
```
|
||||
|
||||
**Trigger**: Refinery sends when merge has conflicts with target branch.
|
||||
|
||||
**Handler**: Witness notifies polecat with rebase instructions.
|
||||
|
||||
### WITNESS_PING
|
||||
|
||||
**Route**: Witness → Deacon (all witnesses send)
|
||||
@@ -184,15 +244,52 @@ Polecat Witness Refinery
|
||||
│ │ MERGE_READY │
|
||||
│ │─────────────────────────>│
|
||||
│ │ │
|
||||
│ │ (merge to main)
|
||||
│ │ (merge attempt)
|
||||
│ │ │
|
||||
│ │ MERGED │
|
||||
│ │ MERGED (success) │
|
||||
│ │<─────────────────────────│
|
||||
│ │ │
|
||||
│ (nuke polecat) │
|
||||
│ │ │
|
||||
```
|
||||
|
||||
### Merge Failure Flow
|
||||
|
||||
```
|
||||
Witness Refinery
|
||||
│ │
|
||||
│ (merge fails)
|
||||
│ │
|
||||
│ MERGE_FAILED │
|
||||
┌──────────────────────────│<─────────────────────────│
|
||||
│ │ │
|
||||
│ (failure notification) │ │
|
||||
│<─────────────────────────│ │
|
||||
│ │ │
|
||||
Polecat (rework needed)
|
||||
```
|
||||
|
||||
### Rebase Required Flow
|
||||
|
||||
```
|
||||
Witness Refinery
|
||||
│ │
|
||||
│ (conflict detected)
|
||||
│ │
|
||||
│ REWORK_REQUEST │
|
||||
┌──────────────────────────│<─────────────────────────│
|
||||
│ │ │
|
||||
│ (rebase instructions) │ │
|
||||
│<─────────────────────────│ │
|
||||
│ │ │
|
||||
Polecat │ │
|
||||
│ │ │
|
||||
│ (rebases, gt done) │ │
|
||||
│─────────────────────────>│ MERGE_READY │
|
||||
│ │─────────────────────────>│
|
||||
│ │ (retry merge)
|
||||
```
|
||||
|
||||
### Second-Order Monitoring
|
||||
|
||||
```
|
||||
@@ -261,3 +358,4 @@ flexible enough for human debugging.
|
||||
- `docs/agent-as-bead.md` - Agent identity and slots
|
||||
- `.beads/formulas/mol-witness-patrol.formula.toml` - Witness handling
|
||||
- `internal/mail/` - Mail routing implementation
|
||||
- `internal/protocol/` - Protocol handlers for Witness-Refinery communication
|
||||
|
||||
Reference in New Issue
Block a user