diff --git a/pkg/agentic/actions.go b/pkg/agentic/actions.go index 6f6bd6b..463896b 100644 --- a/pkg/agentic/actions.go +++ b/pkg/agentic/actions.go @@ -192,7 +192,7 @@ func (s *PrepSubsystem) handleQA(ctx context.Context, opts core.Options) core.Re if st, err := ReadStatus(wsDir); err == nil { st.Status = "failed" st.Question = "QA check failed — build or tests did not pass" - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) } } // Emit QA result for observability (monitor picks this up) diff --git a/pkg/agentic/auto_pr.go b/pkg/agentic/auto_pr.go index 51f3cf4..29991b8 100644 --- a/pkg/agentic/auto_pr.go +++ b/pkg/agentic/auto_pr.go @@ -45,7 +45,7 @@ func (s *PrepSubsystem) autoCreatePR(wsDir string) { if !process.RunIn(ctx, repoDir, "git", "push", forgeRemote, st.Branch).OK { if st2, err := ReadStatus(wsDir); err == nil { st2.Question = "PR push failed" - writeStatus(wsDir, st2) + writeStatusResult(wsDir, st2) } return } @@ -61,7 +61,7 @@ func (s *PrepSubsystem) autoCreatePR(wsDir string) { if err != nil { if st2, err := ReadStatus(wsDir); err == nil { st2.Question = core.Sprintf("PR creation failed: %v", err) - writeStatus(wsDir, st2) + writeStatusResult(wsDir, st2) } return } @@ -69,7 +69,7 @@ func (s *PrepSubsystem) autoCreatePR(wsDir string) { // Update status with PR URL if st2, err := ReadStatus(wsDir); err == nil { st2.PRURL = prURL - writeStatus(wsDir, st2) + writeStatusResult(wsDir, st2) } } diff --git a/pkg/agentic/dispatch.go b/pkg/agentic/dispatch.go index 0a16405..d208606 100644 --- a/pkg/agentic/dispatch.go +++ b/pkg/agentic/dispatch.go @@ -358,7 +358,7 @@ func (s *PrepSubsystem) onAgentComplete(agent, wsDir, outputFile string, exitCod st.Status = finalStatus st.PID = 0 st.Question = question - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) s.TrackWorkspace(WorkspaceName(wsDir), st) } @@ -580,7 +580,7 @@ func (s *PrepSubsystem) dispatch(ctx context.Context, req *mcp.CallToolRequest, StartedAt: time.Now(), Runs: 0, } - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) if runnerSvc, ok := core.ServiceFor[workspaceTracker](s.Core(), "runner"); ok { runnerSvc.TrackWorkspace(WorkspaceName(wsDir), st) } @@ -612,7 +612,7 @@ func (s *PrepSubsystem) dispatch(ctx context.Context, req *mcp.CallToolRequest, StartedAt: time.Now(), Runs: 1, } - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) // Track in runner's registry (runner owns workspace state) if s.ServiceRuntime != nil { if runnerSvc, ok := core.ServiceFor[workspaceTracker](s.Core(), "runner"); ok { diff --git a/pkg/agentic/handlers.go b/pkg/agentic/handlers.go index 88be7a9..06ca30b 100644 --- a/pkg/agentic/handlers.go +++ b/pkg/agentic/handlers.go @@ -41,7 +41,7 @@ func (s *PrepSubsystem) HandleIPCEvents(c *core.Core, msg core.Message) core.Res if st, serr := ReadStatus(wsDir); serr == nil { st.PID = pid st.ProcessID = processID - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) if runnerSvc, ok := core.ServiceFor[workspaceTracker](c, "runner"); ok { runnerSvc.TrackWorkspace(WorkspaceName(wsDir), st) } diff --git a/pkg/agentic/plan.go b/pkg/agentic/plan.go index a705d49..7a299f8 100644 --- a/pkg/agentic/plan.go +++ b/pkg/agentic/plan.go @@ -13,7 +13,7 @@ import ( // Plan represents an implementation plan for agent work. // // plan := &Plan{ID: "id-1-a3f2b1", Title: "Migrate Core", Status: "draft", Objective: "..."} -// writePlan(PlansRoot(), plan) +// r := writePlanResult(PlansRoot(), plan) type Plan struct { ID string `json:"id"` Title string `json:"title"` diff --git a/pkg/agentic/pr.go b/pkg/agentic/pr.go index 5747094..3e36ecc 100644 --- a/pkg/agentic/pr.go +++ b/pkg/agentic/pr.go @@ -124,7 +124,7 @@ func (s *PrepSubsystem) createPR(ctx context.Context, _ *mcp.CallToolRequest, in // Update status with PR URL st.PRURL = prURL - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) // Comment on issue if tracked if st.Issue > 0 { diff --git a/pkg/agentic/queue.go b/pkg/agentic/queue.go index 3ac3f66..7d5e1ee 100644 --- a/pkg/agentic/queue.go +++ b/pkg/agentic/queue.go @@ -363,7 +363,7 @@ func (s *PrepSubsystem) drainOne() bool { st.PID = pid st.ProcessID = processID st.Runs++ - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) s.TrackWorkspace(WorkspaceName(wsDir), st) return true diff --git a/pkg/agentic/resume.go b/pkg/agentic/resume.go index 5042409..77b0a95 100644 --- a/pkg/agentic/resume.go +++ b/pkg/agentic/resume.go @@ -105,7 +105,7 @@ func (s *PrepSubsystem) resume(ctx context.Context, _ *mcp.CallToolRequest, inpu st.ProcessID = processID st.Runs++ st.Question = "" - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) return nil, ResumeOutput{ Success: true, diff --git a/pkg/agentic/status.go b/pkg/agentic/status.go index c789674..a213e34 100644 --- a/pkg/agentic/status.go +++ b/pkg/agentic/status.go @@ -26,8 +26,8 @@ import ( // WorkspaceStatus represents the current state of an agent workspace. // -// st, err := ReadStatus(wsDir) -// if err == nil && st.Status == "completed" { autoCreatePR(wsDir) } +// r := ReadStatusResult(wsDir) +// if r.OK && r.Value.(*WorkspaceStatus).Status == "completed" { autoCreatePR(wsDir) } type WorkspaceStatus struct { Status string `json:"status"` // running, completed, blocked, failed Agent string `json:"agent"` // gemini, claude, codex @@ -212,7 +212,7 @@ func (s *PrepSubsystem) status(ctx context.Context, _ *mcp.CallToolRequest, inpu st.Status = "completed" } } - writeStatus(wsDir, st) + writeStatusResult(wsDir, st) } } diff --git a/pkg/agentic/verify.go b/pkg/agentic/verify.go index 6615bf1..b6ee261 100644 --- a/pkg/agentic/verify.go +++ b/pkg/agentic/verify.go @@ -37,7 +37,7 @@ func (s *PrepSubsystem) autoVerifyAndMerge(wsDir string) { markMerged := func() { if st2, err := ReadStatus(wsDir); err == nil { st2.Status = "merged" - writeStatus(wsDir, st2) + writeStatusResult(wsDir, st2) } } @@ -63,7 +63,7 @@ func (s *PrepSubsystem) autoVerifyAndMerge(wsDir string) { if st2, err := ReadStatus(wsDir); err == nil { st2.Question = "Flagged for review — auto-merge failed after retry" - writeStatus(wsDir, st2) + writeStatusResult(wsDir, st2) } }