diff options
| author | Claudomator Agent <agent@claudomator> | 2026-06-05 09:21:32 +0000 |
|---|---|---|
| committer | Claudomator Agent <agent@claudomator> | 2026-06-05 09:21:32 +0000 |
| commit | 0eb0b79396663c4901597becc6857a4cd795c58e (patch) | |
| tree | 3532c82aa3f7c6deeed03f143d1c360d7cf6cc47 /internal/executor/container.go | |
| parent | fa3ed5220a28f326d443726233c37e1a7df0ced5 (diff) | |
chore: remove stories/checker backend dead code
Remove the dead stories/checker backend tracked as design debt in CLAUDE.md:
- Delete internal/api/stories.go, stories_test.go, elaborate.go
- Delete internal/task/story.go, story_test.go
- Remove story/checker columns from storage schema and all CRUD methods
- Remove checkStoryCompletion, spawnCheckerTask, triggerStoryDeploy,
createValidationTask, checkValidationResult, ShipStory, CheckStoryCompletion
from executor; simplify handleRunResult
- Remove story/checker fields from task.Task (StoryID, AcceptanceCriteria,
CheckerForTaskID, CheckerReport)
- Remove story routes and geminiBinPath from API server
- Move claudeJSONResult/extractJSON from elaborate.go to validate.go
- Rename ensureStoryBranch -> ensureBranch in ContainerRunner
- Fix git identity in bare-repo tests; fix initial-branch to use main
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/container.go')
| -rw-r--r-- | internal/executor/container.go | 73 |
1 files changed, 27 insertions, 46 deletions
diff --git a/internal/executor/container.go b/internal/executor/container.go index a00448c..6179ffc 100644 --- a/internal/executor/container.go +++ b/internal/executor/container.go @@ -29,7 +29,7 @@ type ContainerRunner struct { GeminiBinary string // optional path to gemini binary in container ClaudeConfigDir string // host path to ~/.claude; mounted into container for auth credentials CredentialSyncCmd string // optional path to sync-credentials script for auth-error auto-recovery - Store Store // optional; used to look up stories and projects for story-aware cloning + Store Store // optional; used to look up projects for local-path cloning // Registry mints the per-task MCP token; when set, the agent gets an // mcp-config pointing at the host agent MCP server. Registry *Registry @@ -62,16 +62,16 @@ func (r *ContainerRunner) ExecLogDir(execID string) string { return filepath.Join(r.LogDir, execID) } -// ensureStoryBranch checks whether branchName exists in remoteURL and creates -// it from main if not. Uses localPath as a reference clone for speed if set. -func (r *ContainerRunner) ensureStoryBranch(ctx context.Context, remoteURL, branchName, localPath string) error { +// ensureBranch checks whether branchName exists in remoteURL and creates +// it from main if it does not exist. Uses localPath as a reference clone for speed if set. +func (r *ContainerRunner) ensureBranch(ctx context.Context, remoteURL, branchName, localPath string) error { // Check if branch already exists. out, err := r.command(ctx, "git", "ls-remote", "--heads", remoteURL, branchName).CombinedOutput() if err == nil && len(strings.TrimSpace(string(out))) > 0 { return nil // already exists } - r.Logger.Info("story branch missing, creating from main", "branch", branchName, "remote", remoteURL) + r.Logger.Info("branch missing, creating from main", "branch", branchName, "remote", remoteURL) // Clone into a temp dir so we can create the branch. tmp, err := os.MkdirTemp("", "claudomator-branchsetup-*") @@ -142,38 +142,21 @@ func (r *ContainerRunner) Run(ctx context.Context, t *task.Task, e *storage.Exec } }() - // Resolve story branch and project local path if this is a story task. - var storyBranch string - var storyLocalPath string - if t.StoryID != "" && r.Store != nil { - if story, err := r.Store.GetStory(t.StoryID); err == nil && story != nil { - storyBranch = story.BranchName - if story.ProjectID != "" { - if proj, err := r.Store.GetProject(story.ProjectID); err == nil && proj != nil { - storyLocalPath = proj.LocalPath - } - } - } - } - // For non-story tasks (e.g. CI webhook tasks), also resolve local path from the task's - // project field. This lets the runner clone from the local mirror instead of an HTTPS - // remote that may require credentials not available on the host. - if storyLocalPath == "" && t.Project != "" && r.Store != nil { + // Resolve branch and local path for cloning. + branch := t.BranchName + var localPath string + // Resolve local path from project field to avoid HTTPS auth requirements. + if t.Project != "" && r.Store != nil { if proj, err := r.Store.GetProject(t.Project); err == nil && proj != nil && proj.LocalPath != "" { - storyLocalPath = proj.LocalPath + localPath = proj.LocalPath } } - // Fall back to task-level BranchName (e.g. set explicitly by executor or tests). - if storyBranch == "" { - storyBranch = t.BranchName - } - // 2. Ensure story branch exists in the remote before cloning. - // If the branch is missing (e.g. story approved before fix, or branch push failed), - // create it from main using the project local path as a reference repo. - if storyBranch != "" && !isResume { - if err := r.ensureStoryBranch(ctx, repoURL, storyBranch, storyLocalPath); err != nil { - r.Logger.Warn("ensureStoryBranch failed (will attempt checkout anyway)", "branch", storyBranch, "error", err) + // 2. Ensure branch exists in the remote before cloning. + // If the branch is missing, create it from main using the project local path as a reference repo. + if branch != "" && !isResume { + if err := r.ensureBranch(ctx, repoURL, branch, localPath); err != nil { + r.Logger.Warn("ensureBranch failed (will attempt checkout anyway)", "branch", branch, "error", err) } } @@ -184,21 +167,19 @@ func (r *ContainerRunner) Run(ctx context.Context, t *task.Task, e *storage.Exec return fmt.Errorf("removing workspace before clone: %w", err) } // Prefer the local path as the clone source to avoid HTTPS auth requirements. - // For story tasks the storyLocalPath is also available as a speed reference, - // but we clone from the local path directly since it is already authoritative. cloneSrc := repoURL - if storyLocalPath != "" { - cloneSrc = storyLocalPath + if localPath != "" { + cloneSrc = localPath } r.Logger.Info("cloning repository", "src", cloneSrc, "workspace", workspace) cloneArgs := []string{"clone", cloneSrc, workspace} if out, err := r.command(ctx, "git", cloneArgs...).CombinedOutput(); err != nil { return fmt.Errorf("git clone failed: %w\n%s", err, string(out)) } - if storyBranch != "" { - r.Logger.Info("checking out story branch", "branch", storyBranch) - if out, err := r.command(ctx, "git", "-C", workspace, "checkout", storyBranch).CombinedOutput(); err != nil { - return fmt.Errorf("git checkout story branch %q failed: %w\n%s", storyBranch, err, string(out)) + if branch != "" { + r.Logger.Info("checking out branch", "branch", branch) + if out, err := r.command(ctx, "git", "-C", workspace, "checkout", branch).CombinedOutput(); err != nil { + return fmt.Errorf("git checkout branch %q failed: %w\n%s", branch, err, string(out)) } } if err = os.Chmod(workspace, 0755); err != nil { @@ -241,7 +222,7 @@ func (r *ContainerRunner) Run(ctx context.Context, t *task.Task, e *storage.Exec } // Run container (with auth retry on failure). - runErr := r.runContainer(ctx, t, e, workspace, agentHome, isResume, storyBranch, ch) + runErr := r.runContainer(ctx, t, e, workspace, agentHome, isResume, branch, ch) if runErr != nil && isAuthError(runErr) && r.CredentialSyncCmd != "" { r.Logger.Warn("auth failure detected, syncing credentials and retrying once", "taskID", t.ID) syncOut, syncErr := r.command(ctx, r.CredentialSyncCmd).CombinedOutput() @@ -255,7 +236,7 @@ func (r *ContainerRunner) Run(ctx context.Context, t *task.Task, e *storage.Exec if srcData, readErr := os.ReadFile(filepath.Join(r.ClaudeConfigDir, ".claude.json")); readErr == nil { _ = os.WriteFile(filepath.Join(agentHome, ".claude.json"), srcData, 0644) } - runErr = r.runContainer(ctx, t, e, workspace, agentHome, isResume, storyBranch, ch) + runErr = r.runContainer(ctx, t, e, workspace, agentHome, isResume, branch, ch) } if runErr == nil { @@ -271,7 +252,7 @@ func (r *ContainerRunner) Run(ctx context.Context, t *task.Task, e *storage.Exec // runContainer runs the docker container for the given task and handles log setup, // environment files, instructions, and post-execution git operations. -func (r *ContainerRunner) runContainer(ctx context.Context, t *task.Task, e *storage.Execution, workspace, agentHome string, isResume bool, storyBranch string, ch AgentChannel) error { +func (r *ContainerRunner) runContainer(ctx context.Context, t *task.Task, e *storage.Execution, workspace, agentHome string, isResume bool, branch string, ch AgentChannel) error { repoURL := t.RepositoryURL image := t.Agent.ContainerImage @@ -426,8 +407,8 @@ func (r *ContainerRunner) runContainer(ctx context.Context, t *task.Task, e *sto if hasCommits { pushRef := "HEAD" - if storyBranch != "" { - pushRef = storyBranch + if branch != "" { + pushRef = branch } r.Logger.Info("pushing changes back to remote", "url", repoURL, "ref", pushRef) if out, err := r.command(ctx, "git", "-C", workspace, "push", "origin", pushRef).CombinedOutput(); err != nil { |
