0.4.0 — multi-repo discard, zombie sweep, base-branch detect, deltas#1
Merged
Conversation
…eltas
Closes a batch of operational potholes from real-world spawns:
- discard/merge/cancel-force now use per-spawn repo_root (was running git
in orchestrator's default repo, failing in multi-repo workspaces)
- Registry.load() sweeps stale running/queued records into failed with
error.kind="zombie" (state.json residue from crashed processes)
- Worktrees.create runs git fetch origin <base_ref> before branching
(long-lived servers were producing worktrees with stale baselines)
- base_ref auto-detect probes origin/HEAD → main → master → develop
when caller omits it (previously hardcoded to "main")
- implementer default sandbox switched to danger-full-access (the
workspace-write + .git writable_roots workaround still dropped
~15-20% of .git/worktrees/*.lock writes); workspace-write remains
opt-in via magic-codex.toml
- Rust no-fmt guardrail auto-injected when Cargo.toml is present
- AgentRecord.delta captures branch/commit_sha/diff_stat/commits_ahead
post-completion, surfaced separately on status and result so callers
don't need to parse the (truncated) prose last_output
- error.retry_at + error.retry_after_seconds parsed from codex
rate-limit messages ("try again at HH:MM" or "retry after Ns")
- .magic-codex/ idempotently added to repo .gitignore on first spawn
103 tests passing (was 88).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes a batch of operational potholes surfaced by ~50 real spawns across multi-repo workspaces. Most changes are defaults that empirical evidence has already validated; a few are bug fixes for things the test suite never caught because they only manifest across process restarts or in repos with non-
maindefaults.Fixed
discardfailed in multi-repo workspaces. Rangit -C <orchestrator-default-repo>instead of the per-spawnrepo_rootoverride. In HQ-style workspaces where the orchestrator's launch cwd isn't itself a git repo, this exited withfatal: not a git repository. Fix: persistrepo_rooton the agent record and recreate a per-recordWorktreesinstance fordiscard/merge/cancel --force.state.jsonindefinitely (some lasted days). Fix:Registry.load()sweepsrunning/queuedrecords intofailedwitherror.kind = "zombie".origin/<base_ref>. Long-lived servers branched off whatever the local ref pointed at when the worktree was created. Fix: best-effortgit fetch origin <base_ref> --quietbeforeworktree add.base_refdefaulted tomaineven inmaster-default repos. ~40% of real-world repos usemaster; spawns died withfatal: invalid reference: main. Fix: probeorigin/HEAD→main→master→develop.Added
danger-full-access.workspace-writesilently dropped.git/worktrees/*.lockwrites for ~15-20% of spawns even with the 0.3.7 canonicalizedwritable_rootsworkaround. The agent is already isolated to a throwaway worktree branch, so danger-full-access is the smaller blast radius. Override via[roles.implementer] sandbox = "workspace-write"inmagic-codex.toml.Cargo.toml, the orchestrator prepends a hard "DO NOT runcargo fmt" rule todeveloper_instructions. Empirical: zero churn on Rust spawns since this landed (was ~20-30 unrelated files churned per spawn).error.retry_atanderror.retry_after_secondsparsed from "try again at HH:MM" / "retry after Ns" rate-limit messages, resolved to absolute UTC. Callers can sleep precisely instead of polling.AgentRecord.delta— branch / commit_sha / diff_stat / commits_ahead captured post-completion, surfaced separately onstatusandresultso callers don't parse the (truncated) proselast_output.AgentRecord.repo_root— persisted at spawn time. Absent on records created before 0.4.0; those fall back to the orchestrator's defaultrepoRoot..magic-codex/auto-added to repo.gitignoreon first worktree-bearing spawn.Internal
classifyError(message, stderrTail)preserved for legacy callers; newclassifyErrorDetailed(...)returns{ kind, retry_at?, retry_after_seconds? }.AgentErrorKindgains"zombie".WorktreesgainsensureGitignore()anddetectDefaultBranch()(best-effort, never throw).Test plan
npm run typecheck— cleannpm test— 103 tests passing (was 88), stable across 3 consecutive runsnpm run build—plugin/dist/index.jsrebuiltmaster-default repo withoutbase_refand confirm worktree branches offmasterdiscardsucceeds withoutfatal: not a git repositoryfailed/kind=zombieinstead of phantomrunning🤖 Generated with Claude Code