spawn: Notify Witness instead of direct nudge
- Remove hacky 5-second delay from spawn - Send SPAWN notification to Witness after starting polecat session - Witness uses AI to monitor polecat startup and nudge when ready - Added SPAWN REQUEST PROCESSING section to Witness template This implements event-driven polecat readiness detection (gt-hb0). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -337,20 +337,31 @@ func runSpawn(cmd *cobra.Command, args []string) error {
|
|||||||
style.Bold.Render("✓"),
|
style.Bold.Render("✓"),
|
||||||
style.Dim.Render(fmt.Sprintf("gt session at %s/%s", rigName, polecatName)))
|
style.Dim.Render(fmt.Sprintf("gt session at %s/%s", rigName, polecatName)))
|
||||||
|
|
||||||
// TODO: Proper solution requires Witness/Deacon to monitor polecat startup
|
// Notify Witness about the spawn - Witness will monitor startup and nudge when ready
|
||||||
// and detect when Claude is ready using AI intelligence. See gt-polecat-ready issue.
|
witnessAddr := fmt.Sprintf("%s/witness", rigName)
|
||||||
// For now, use a fixed delay - SessionStart hook runs gt prime which tells polecat
|
spawnNotification := &mail.Message{
|
||||||
// to check mail, but we also send an explicit instruction as backup.
|
To: witnessAddr,
|
||||||
sessionName := sessMgr.SessionName(polecatName)
|
From: "mayor/",
|
||||||
time.Sleep(5 * time.Second)
|
Subject: fmt.Sprintf("SPAWN: %s starting on %s", polecatName, assignmentID),
|
||||||
|
Body: fmt.Sprintf(`Polecat spawn notification.
|
||||||
|
|
||||||
// Send work instruction - backup in case SessionStart hook doesn't trigger action
|
Polecat: %s
|
||||||
workInstruction := "Check your inbox with `gt mail inbox` and begin working on your assigned issue."
|
Issue: %s
|
||||||
if err := t.SendKeys(sessionName, workInstruction); err != nil {
|
Session: %s
|
||||||
fmt.Printf(" %s\n", style.Dim.Render(fmt.Sprintf("Warning: could not send work instruction: %v", err)))
|
|
||||||
|
Please monitor this polecat's startup. When Claude is ready (you can see the prompt
|
||||||
|
in the tmux session), send a nudge to start working:
|
||||||
|
|
||||||
|
tmux send-keys -t %s "Check your inbox with 'gt mail inbox' and begin working." Enter
|
||||||
|
|
||||||
|
The polecat has a work assignment in its inbox.`, polecatName, assignmentID, sessMgr.SessionName(polecatName), sessMgr.SessionName(polecatName)),
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(" %s\n", style.Dim.Render("Work instruction sent to polecat"))
|
if err := router.Send(spawnNotification); err != nil {
|
||||||
|
fmt.Printf(" %s\n", style.Dim.Render(fmt.Sprintf("Warning: could not notify witness: %v", err)))
|
||||||
|
} else {
|
||||||
|
fmt.Printf(" %s\n", style.Dim.Render("Witness notified to monitor startup"))
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,57 @@ gt mail delete <message-id>
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 🚀 SPAWN REQUEST PROCESSING
|
||||||
|
|
||||||
|
When you receive a message with subject containing "SPAWN:":
|
||||||
|
|
||||||
|
This means a new polecat was just spawned and needs monitoring until it starts working.
|
||||||
|
|
||||||
|
### Step 1: Parse the Spawn Info
|
||||||
|
Extract from the message:
|
||||||
|
- Polecat name
|
||||||
|
- Issue ID
|
||||||
|
- Session name (e.g., `gt-{{ .RigName }}-<polecat>`)
|
||||||
|
|
||||||
|
### Step 2: Monitor Startup
|
||||||
|
Check if Claude is ready by looking at the session:
|
||||||
|
```bash
|
||||||
|
gt session capture {{ .RigName }}/<polecat> -n 20
|
||||||
|
```
|
||||||
|
|
||||||
|
Look for signs Claude is ready:
|
||||||
|
- The Claude Code banner is visible
|
||||||
|
- A prompt line starting with `>` is visible
|
||||||
|
- No "loading" or initialization messages
|
||||||
|
|
||||||
|
### Step 3: Nudge to Start Working
|
||||||
|
Once Claude appears ready, send the work instruction:
|
||||||
|
```bash
|
||||||
|
tmux send-keys -t gt-{{ .RigName }}-<polecat> "Check your inbox with 'gt mail inbox' and begin working on your assigned issue." Enter
|
||||||
|
```
|
||||||
|
|
||||||
|
### Step 4: Verify Work Started
|
||||||
|
After nudging, check the session again:
|
||||||
|
```bash
|
||||||
|
gt session capture {{ .RigName }}/<polecat> -n 30
|
||||||
|
```
|
||||||
|
|
||||||
|
Look for signs the polecat is working:
|
||||||
|
- Running `gt mail inbox`
|
||||||
|
- Reading the work assignment
|
||||||
|
- Starting to work on the issue
|
||||||
|
|
||||||
|
### Step 5: Acknowledge
|
||||||
|
Delete the spawn notification once the polecat is working:
|
||||||
|
```bash
|
||||||
|
gt mail delete <message-id>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note**: If the polecat doesn't respond after 2-3 nudges, it may be stuck.
|
||||||
|
Escalate to Mayor or try restarting the session.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 🔍 HEALTH CHECK PROTOCOL
|
## 🔍 HEALTH CHECK PROTOCOL
|
||||||
|
|
||||||
Periodically check polecat health:
|
Periodically check polecat health:
|
||||||
|
|||||||
Reference in New Issue
Block a user