deacon patrol: 21 cycles complete
This commit is contained in:
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"last_failure": "2025-12-28T01:56:16.871899-08:00",
|
|
||||||
"failure_count": 1,
|
|
||||||
"backoff_until": "2025-12-28T01:56:46.871899-08:00",
|
|
||||||
"needs_manual_sync": false,
|
|
||||||
"failure_reason": "git pull failed in worktree: exit status 128\nFrom github.com:steveyegge/gastown\n * branch beads-sync -\u003e FETCH_HEAD\nfatal: Cannot rebase onto multiple branches.\n"
|
|
||||||
}
|
|
||||||
@@ -155,6 +155,20 @@ func runHandoff(cmd *cobra.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report agent state as stopped (ZFC: agents self-report state)
|
||||||
|
cwd, _ := os.Getwd()
|
||||||
|
if townRoot, _ := workspace.FindFromCwd(); townRoot != "" {
|
||||||
|
if roleInfo, err := GetRoleWithContext(cwd, townRoot); err == nil {
|
||||||
|
reportAgentState(RoleContext{
|
||||||
|
Role: roleInfo.Role,
|
||||||
|
Rig: roleInfo.Rig,
|
||||||
|
Polecat: roleInfo.Polecat,
|
||||||
|
TownRoot: townRoot,
|
||||||
|
WorkDir: cwd,
|
||||||
|
}, "stopped")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Clear scrollback history before respawn (resets copy-mode from [0/N] to [0/0])
|
// Clear scrollback history before respawn (resets copy-mode from [0/N] to [0/0])
|
||||||
if err := t.ClearHistory(pane); err != nil {
|
if err := t.ClearHistory(pane); err != nil {
|
||||||
// Non-fatal - continue with respawn even if clear fails
|
// Non-fatal - continue with respawn even if clear fails
|
||||||
|
|||||||
@@ -108,6 +108,9 @@ func runPrime(cmd *cobra.Command, args []string) error {
|
|||||||
// Ensure beads redirect exists for worktree-based roles
|
// Ensure beads redirect exists for worktree-based roles
|
||||||
ensureBeadsRedirect(ctx)
|
ensureBeadsRedirect(ctx)
|
||||||
|
|
||||||
|
// Report agent state as running (ZFC: agents self-report state)
|
||||||
|
reportAgentState(ctx, "running")
|
||||||
|
|
||||||
// Output context
|
// Output context
|
||||||
if err := outputPrimeContext(ctx); err != nil {
|
if err := outputPrimeContext(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -1049,6 +1052,59 @@ func acquireIdentityLock(ctx RoleContext) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reportAgentState calls bd agent state to report the agent's current state.
|
||||||
|
// This implements ZFC-compliant self-reporting of agent state.
|
||||||
|
// Agents call this on startup (running) and shutdown (stopped).
|
||||||
|
func reportAgentState(ctx RoleContext, state string) {
|
||||||
|
agentBeadID := getAgentBeadID(ctx)
|
||||||
|
if agentBeadID == "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call bd agent state <id> <state>
|
||||||
|
// Use --no-daemon to avoid issues when daemon isn't running
|
||||||
|
cmd := exec.Command("bd", "--no-daemon", "agent", "state", agentBeadID, state)
|
||||||
|
cmd.Dir = ctx.WorkDir
|
||||||
|
cmd.Stdout = nil
|
||||||
|
cmd.Stderr = nil
|
||||||
|
|
||||||
|
// Run silently - don't fail prime if state reporting fails
|
||||||
|
_ = cmd.Run()
|
||||||
|
}
|
||||||
|
|
||||||
|
// getAgentBeadID returns the agent bead ID for the current role.
|
||||||
|
// Returns empty string for unknown roles.
|
||||||
|
func getAgentBeadID(ctx RoleContext) string {
|
||||||
|
switch ctx.Role {
|
||||||
|
case RoleMayor:
|
||||||
|
return "gt-mayor"
|
||||||
|
case RoleDeacon:
|
||||||
|
return "gt-deacon"
|
||||||
|
case RoleWitness:
|
||||||
|
if ctx.Rig != "" {
|
||||||
|
return fmt.Sprintf("gt-witness-%s", ctx.Rig)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
case RoleRefinery:
|
||||||
|
if ctx.Rig != "" {
|
||||||
|
return fmt.Sprintf("gt-refinery-%s", ctx.Rig)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
case RolePolecat:
|
||||||
|
if ctx.Rig != "" && ctx.Polecat != "" {
|
||||||
|
return fmt.Sprintf("gt-polecat-%s-%s", ctx.Rig, ctx.Polecat)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
case RoleCrew:
|
||||||
|
if ctx.Rig != "" && ctx.Polecat != "" {
|
||||||
|
return fmt.Sprintf("gt-crew-%s-%s", ctx.Rig, ctx.Polecat)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ensureBeadsRedirect ensures the .beads/redirect file exists for worktree-based roles.
|
// ensureBeadsRedirect ensures the .beads/redirect file exists for worktree-based roles.
|
||||||
// This handles cases where git clean or other operations delete the redirect file.
|
// This handles cases where git clean or other operations delete the redirect file.
|
||||||
func ensureBeadsRedirect(ctx RoleContext) {
|
func ensureBeadsRedirect(ctx RoleContext) {
|
||||||
|
|||||||
Reference in New Issue
Block a user