Runner: no I/O under the runner lock; retry run settlement

- Run worktree creation happens outside r.mu; the source tree is protected
  from storage maintenance meanwhile and the reservation is re-checked under
  the lock before the run is recorded (a refused tree is discarded).
- getRun/listRuns read the store without r.mu; listRuns finds failed runs
  with an active cleanup agent in one query (partial index) instead of a
  detail read per failed run.
- finishRunState writes the deliverable and walks the run size without the
  lock; FinishRun retries transient failures with backoff (a refused
  transition is final).
- Launch teardown retries a failed read with backoff instead of keeping the
  reservation forever; a kept run that cannot be read at reattach is retried
  and then marked interrupted (stopping its adopted session first).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-03 00:42:25 +00:00
parent ab6b2bb632
commit 2ea7eb9db0
7 changed files with 567 additions and 70 deletions
+3
View File
@@ -190,6 +190,9 @@ func (m *storageManager) apply(ctx context.Context, preview protocol.StorageClea
for _, active := range m.runner.active {
config.ProtectedWorkspaces = append(config.ProtectedWorkspaces, active.workspace)
}
for source := range m.runner.admitting {
config.ProtectedWorkspaces = append(config.ProtectedWorkspaces, source)
}
var tree storageWorktree
found := false
for _, known := range before.Worktrees {