From b2e77009c55ba0f07bb9ff904d9f2f6cc9ff0ee2 Mon Sep 17 00:00:00 2001 From: Claudomator Agent Date: Mon, 23 Mar 2026 07:12:08 +0000 Subject: feat: Phase 4 — story-aware execution, branch clone, story completion check, deployment status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ContainerRunner: add Store field; clone with --reference when story has a local project path; checkout story branch after clone; push to story branch instead of HEAD - executor.Store interface: add GetStory, ListTasksByStory, UpdateStoryStatus - Pool.handleRunResult: trigger checkStoryCompletion when a story task succeeds - Pool.checkStoryCompletion: transitions story to SHIPPABLE when all tasks done - serve.go: wire Store into each ContainerRunner - stories.go: update createStoryBranch to fetch+checkout from origin/master base; add GET /api/stories/{id}/deployment-status endpoint - server.go: register deployment-status route - Tests: TestPool_CheckStoryCompletion_AllComplete/PartialComplete, TestHandleStoryDeploymentStatus Co-Authored-By: Claude Sonnet 4.6 --- internal/executor/executor.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'internal/executor/executor.go') diff --git a/internal/executor/executor.go b/internal/executor/executor.go index 440294c..22273d9 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -33,6 +33,9 @@ type Store interface { UpdateExecutionChangestats(execID string, stats *task.Changestats) error 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 @@ -399,6 +402,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 @@ -430,6 +436,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() -- cgit v1.2.3