diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-05 23:03:02 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-05 23:03:02 +0000 |
| commit | f8b5f2580e730a8affbccec8b5bde9b96b1f9fc2 (patch) | |
| tree | 8bee6ccf9f4dff4d705c09c6b6a9e94967c58c4e /internal/executor/claude.go | |
| parent | ed6cb17501bd14ce5ec009f68fba54539cf1a470 (diff) | |
executor: persist log paths at execution create time, not just at end
Add LogPather interface; ClaudeRunner implements it via ExecLogDir().
Pool pre-populates stdout_path/stderr_path/artifact_dir on the execution
record before CreateExecution, so paths are in the DB from the moment
a task starts running.
ClaudeRunner.Run() skips path assignment when already set by the pool.
Also update scripts/debug-execution to derive paths from the known
convention (<data-dir>/executions/<exec-id>/) as a fallback for
historical records that predate this change.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/executor/claude.go')
| -rw-r--r-- | internal/executor/claude.go | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/internal/executor/claude.go b/internal/executor/claude.go index 815c21f..7cbcc6c 100644 --- a/internal/executor/claude.go +++ b/internal/executor/claude.go @@ -27,6 +27,15 @@ type ClaudeRunner struct { APIURL string // base URL of the Claudomator API, passed to subprocesses } +// ExecLogDir returns the log directory for the given execution ID. +// Implements LogPather so the pool can persist paths before execution starts. +func (r *ClaudeRunner) ExecLogDir(execID string) string { + if r.LogDir == "" { + return "" + } + return filepath.Join(r.LogDir, execID) +} + func (r *ClaudeRunner) binaryPath() string { if r.BinaryPath != "" { return r.BinaryPath @@ -46,13 +55,20 @@ func (r *ClaudeRunner) Run(ctx context.Context, t *task.Task, e *storage.Executi } // Setup log directory once; retries overwrite the log files. - logDir := filepath.Join(r.LogDir, e.ID) + // Use pre-set paths if the pool already populated them via LogPather; + // otherwise fall back to computing from LogDir + execID. + logDir := r.ExecLogDir(e.ID) + if logDir == "" { + logDir = e.ID // fallback: use execID as relative dir (tests without LogDir set) + } if err := os.MkdirAll(logDir, 0700); err != nil { return fmt.Errorf("creating log dir: %w", err) } - e.StdoutPath = filepath.Join(logDir, "stdout.log") - e.StderrPath = filepath.Join(logDir, "stderr.log") - e.ArtifactDir = logDir + if e.StdoutPath == "" { + e.StdoutPath = filepath.Join(logDir, "stdout.log") + e.StderrPath = filepath.Join(logDir, "stderr.log") + e.ArtifactDir = logDir + } attempt := 0 return runWithBackoff(ctx, 3, 5*time.Second, func() error { |
