summaryrefslogtreecommitdiff
path: root/internal/executor/executor.go
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-03-24 21:54:31 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-03-24 21:54:31 +0000
commit407fbc8d346b986bf864452c865282aa726272e2 (patch)
tree274aa7861a6e4316c1919e93d944023d60846b44 /internal/executor/executor.go
parente3954992af63440986bd39cce889e9c62e1a6b92 (diff)
parentb2e77009c55ba0f07bb9ff904d9f2f6cc9ff0ee2 (diff)
fix: resolve merge conflict — integrate agent's story-aware ContainerRunner
Agent added: Store on ContainerRunner (direct story/project lookup), --reference clone for speed, explicit story branch push, checkStoryCompletion → SHIPPABLE. My additions: BranchName on Task as fallback when Store is nil, tests updated to match checkout-after-clone approach. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/executor.go')
-rw-r--r--internal/executor/executor.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/internal/executor/executor.go b/internal/executor/executor.go
index 6489060..8dfb196 100644
--- a/internal/executor/executor.go
+++ b/internal/executor/executor.go
@@ -34,6 +34,8 @@ type Store interface {
RecordAgentEvent(e storage.AgentEvent) error
GetProject(id string) (*task.Project, error)
GetStory(id string) (*task.Story, error)
+ ListTasksByStory(storyID string) ([]*task.Task, error)
+ UpdateStoryStatus(id string, status task.StoryState) error
}
// LogPather is an optional interface runners can implement to provide the log
@@ -406,6 +408,9 @@ func (p *Pool) handleRunResult(ctx context.Context, t *task.Task, exec *storage.
}
p.maybeUnblockParent(t.ParentTaskID)
}
+ if t.StoryID != "" {
+ go p.checkStoryCompletion(ctx, t.StoryID)
+ }
}
summary := exec.Summary
@@ -437,6 +442,29 @@ func (p *Pool) handleRunResult(ctx context.Context, t *task.Task, exec *storage.
p.resultCh <- &Result{TaskID: t.ID, Execution: exec, Err: err}
}
+// checkStoryCompletion checks whether all tasks in a story have reached a terminal
+// success state and transitions the story to SHIPPABLE if so.
+func (p *Pool) checkStoryCompletion(ctx context.Context, storyID string) {
+ tasks, err := p.store.ListTasksByStory(storyID)
+ if err != nil {
+ p.logger.Error("checkStoryCompletion: failed to list tasks", "storyID", storyID, "error", err)
+ return
+ }
+ if len(tasks) == 0 {
+ return
+ }
+ for _, t := range tasks {
+ if t.State != task.StateCompleted && t.State != task.StateReady {
+ return // not all tasks done
+ }
+ }
+ if err := p.store.UpdateStoryStatus(storyID, task.StoryShippable); err != nil {
+ p.logger.Error("checkStoryCompletion: failed to update story status", "storyID", storyID, "error", err)
+ return
+ }
+ p.logger.Info("story transitioned to SHIPPABLE", "storyID", storyID)
+}
+
// UndrainingAgent resets the drain state and failure counter for the given agent type.
func (p *Pool) UndrainingAgent(agentType string) {
p.mu.Lock()