fix: remove vestigial state.json files from agent directories
Agent directories (witness/, refinery/, mayor/) contained state.json files with last_active timestamps that were never updated, making them stale and misleading. This change removes: - initAgentStates function that created vestigial state.json files - AgentState type and related Load/Save functions from config package - MayorStateValidCheck from doctor checks - requesting_* lifecycle verification (dead code - flags were never set) - FileStateJSON constant and MayorStatePath function Kept intact: - daemon/state.json (actively used for daemon runtime state) - crew/<name>/state.json (operational CrewWorker metadata) - Agent state tracking via beads (the ZFC-compliant approach) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,6 @@ Workspace checks:
|
||||
- rigs-registry-exists Check mayor/rigs.json exists (fixable)
|
||||
- rigs-registry-valid Check registered rigs exist (fixable)
|
||||
- mayor-exists Check mayor/ directory structure
|
||||
- mayor-state-valid Check mayor/state.json is valid (fixable)
|
||||
|
||||
Infrastructure checks:
|
||||
- daemon Check if daemon is running (fixable)
|
||||
|
||||
@@ -171,17 +171,6 @@ func runInstall(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
fmt.Printf(" ✓ Created mayor/rigs.json\n")
|
||||
|
||||
// Create mayor state.json
|
||||
mayorState := &config.AgentState{
|
||||
Role: "mayor",
|
||||
LastActive: time.Now(),
|
||||
}
|
||||
statePath := filepath.Join(mayorDir, "state.json")
|
||||
if err := config.SaveAgentState(statePath, mayorState); err != nil {
|
||||
return fmt.Errorf("writing mayor state: %w", err)
|
||||
}
|
||||
fmt.Printf(" ✓ Created mayor/state.json\n")
|
||||
|
||||
// Create Mayor CLAUDE.md at HQ root (Mayor runs from there)
|
||||
if err := createMayorCLAUDEmd(absPath, absPath); err != nil {
|
||||
fmt.Printf(" %s Could not create CLAUDE.md: %v\n", style.Dim.Render("⚠"), err)
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -61,22 +60,6 @@ func TestInstallCreatesCorrectStructure(t *testing.T) {
|
||||
t.Errorf("rigs.json should be empty, got %d rigs", len(rigsConfig.Rigs))
|
||||
}
|
||||
|
||||
// Verify mayor/state.json
|
||||
statePath := filepath.Join(hqPath, "mayor", "state.json")
|
||||
assertFileExists(t, statePath, "mayor/state.json")
|
||||
|
||||
stateData, err := os.ReadFile(statePath)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to read state.json: %v", err)
|
||||
}
|
||||
var state map[string]interface{}
|
||||
if err := json.Unmarshal(stateData, &state); err != nil {
|
||||
t.Fatalf("failed to parse state.json: %v", err)
|
||||
}
|
||||
if state["role"] != "mayor" {
|
||||
t.Errorf("state.json role = %q, want %q", state["role"], "mayor")
|
||||
}
|
||||
|
||||
// Verify CLAUDE.md exists
|
||||
claudePath := filepath.Join(hqPath, "CLAUDE.md")
|
||||
assertFileExists(t, claudePath, "CLAUDE.md")
|
||||
|
||||
@@ -542,17 +542,20 @@ func TestRigAddCreatesAgentDirs(t *testing.T) {
|
||||
|
||||
rigPath := filepath.Join(townRoot, "agenttest")
|
||||
|
||||
// Verify agent state files exist
|
||||
expectedStateFiles := []string{
|
||||
"witness/state.json",
|
||||
"refinery/state.json",
|
||||
"mayor/state.json",
|
||||
// Verify agent directories exist (state.json files are no longer created)
|
||||
expectedDirs := []string{
|
||||
"witness",
|
||||
"refinery",
|
||||
"mayor",
|
||||
}
|
||||
|
||||
for _, stateFile := range expectedStateFiles {
|
||||
path := filepath.Join(rigPath, stateFile)
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
t.Errorf("expected state file %s to exist: %v", stateFile, err)
|
||||
for _, dir := range expectedDirs {
|
||||
path := filepath.Join(rigPath, dir)
|
||||
info, err := os.Stat(path)
|
||||
if err != nil {
|
||||
t.Errorf("expected directory %s to exist: %v", dir, err)
|
||||
} else if !info.IsDir() {
|
||||
t.Errorf("expected %s to be a directory", dir)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user