diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-23 06:50:10 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-23 06:50:10 +0000 |
| commit | bc62c3545bbcf3f9ccc508cdc43ce9ffdb5dfad0 (patch) | |
| tree | e8ca80b85d63d695707bc27fd0cdda0cfbcb6fac /internal | |
| parent | 2c8ec3e53a0f4c6f2d16e94a95fcdce706717091 (diff) | |
feat: populate RepositoryURL from project registry in executor (ADR-007)
- Add GetProject to Store interface used by executor
- Resolve RepositoryURL from project registry when task.RepositoryURL is empty
- Call SeedProjects at server startup so the project registry is populated
- Add GetProject stub to minimalMockStore in executor tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/cli/serve.go | 5 | ||||
| -rw-r--r-- | internal/executor/executor.go | 15 | ||||
| -rw-r--r-- | internal/executor/executor_test.go | 1 |
3 files changed, 21 insertions, 0 deletions
diff --git a/internal/cli/serve.go b/internal/cli/serve.go index e7b6b71..3850ca9 100644 --- a/internal/cli/serve.go +++ b/internal/cli/serve.go @@ -118,6 +118,11 @@ func serve(addr string) error { if cfg.GeminiBinaryPath != "" { pool.Classifier = &executor.Classifier{GeminiBinaryPath: cfg.GeminiBinaryPath} } + + if err := store.SeedProjects(); err != nil { + logger.Error("failed to seed projects", "error", err) + } + pool.RecoverStaleRunning(context.Background()) pool.RecoverStaleQueued(context.Background()) pool.RecoverStaleBlocked() diff --git a/internal/executor/executor.go b/internal/executor/executor.go index 972c254..440294c 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -32,6 +32,7 @@ type Store interface { UpdateTaskAgent(id string, agent task.AgentConfig) error UpdateExecutionChangestats(execID string, stats *task.Changestats) error RecordAgentEvent(e storage.AgentEvent) error + GetProject(id string) (*task.Project, error) } // LogPather is an optional interface runners can implement to provide the log @@ -268,6 +269,13 @@ func (p *Pool) executeResume(ctx context.Context, t *task.Task, exec *storage.Ex p.mu.Unlock() }() + // Populate RepositoryURL from Project registry if missing (ADR-007). + if t.RepositoryURL == "" && t.Project != "" { + if proj, err := p.store.GetProject(t.Project); err == nil && proj.RemoteURL != "" { + t.RepositoryURL = proj.RemoteURL + } + } + err = runner.Run(ctx, t, exec) exec.EndTime = time.Now().UTC() @@ -701,6 +709,13 @@ func (p *Pool) execute(ctx context.Context, t *task.Task) { priorExecs, priorErr := p.store.ListExecutions(t.ID) t = withFailureHistory(t, priorExecs, priorErr) + // Populate RepositoryURL from Project registry if missing (ADR-007). + if t.RepositoryURL == "" && t.Project != "" { + if proj, err := p.store.GetProject(t.Project); err == nil && proj.RemoteURL != "" { + t.RepositoryURL = proj.RemoteURL + } + } + // Run the task. err = runner.Run(ctx, t, exec) exec.EndTime = time.Now().UTC() diff --git a/internal/executor/executor_test.go b/internal/executor/executor_test.go index 9dfd860..1f4e92f 100644 --- a/internal/executor/executor_test.go +++ b/internal/executor/executor_test.go @@ -1057,6 +1057,7 @@ func (m *minimalMockStore) UpdateExecutionChangestats(execID string, stats *task return nil } func (m *minimalMockStore) RecordAgentEvent(_ storage.AgentEvent) error { return nil } +func (m *minimalMockStore) GetProject(_ string) (*task.Project, error) { return nil, nil } func (m *minimalMockStore) lastStateUpdate() (string, task.State, bool) { m.mu.Lock() |
