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.Dim.Render(fmt.Sprintf("gt session at %s/%s", rigName, polecatName)))
|
||||
|
||||
// TODO: Proper solution requires Witness/Deacon to monitor polecat startup
|
||||
// and detect when Claude is ready using AI intelligence. See gt-polecat-ready issue.
|
||||
// For now, use a fixed delay - SessionStart hook runs gt prime which tells polecat
|
||||
// to check mail, but we also send an explicit instruction as backup.
|
||||
sessionName := sessMgr.SessionName(polecatName)
|
||||
time.Sleep(5 * time.Second)
|
||||
// Notify Witness about the spawn - Witness will monitor startup and nudge when ready
|
||||
witnessAddr := fmt.Sprintf("%s/witness", rigName)
|
||||
spawnNotification := &mail.Message{
|
||||
To: witnessAddr,
|
||||
From: "mayor/",
|
||||
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
|
||||
workInstruction := "Check your inbox with `gt mail inbox` and begin working on your assigned issue."
|
||||
if err := t.SendKeys(sessionName, workInstruction); err != nil {
|
||||
fmt.Printf(" %s\n", style.Dim.Render(fmt.Sprintf("Warning: could not send work instruction: %v", err)))
|
||||
Polecat: %s
|
||||
Issue: %s
|
||||
Session: %s
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Periodically check polecat health:
|
||||
|
||||
Reference in New Issue
Block a user