Commit Graph
3 Commits
Author SHA1 Message Date
FastheiandClaude Opus 4.8 c38b5fd80d fix(agent/git): seed baseline commit for empty repos so results push back (#73)
Binding an empty repo (no commits) made `git clone` land an unborn HEAD with no
`origin/main`. `add_task_worktree` / `create_result_branch` then fell back to
base_ref=HEAD, and `git worktree add ... HEAD` failed with "invalid reference:
HEAD". The agent silently degraded to "executing on repo root without git push",
so the result branch never reached the remote.

Fix: after clone (and after refreshing an existing checkout), detect an empty
repo via `git rev-parse --verify HEAD` and plant one empty baseline commit on the
configured base branch. Worktree/branch creation and push then work normally and
the result branch is created on the (previously empty) remote.

Adds scripts/test-git-empty-repo.py covering the empty-repo path; existing
scripts/test-git-workflow.py still passes (no regression). Verified end-to-end
against a real empty GitHub repo: result branch pushed successfully.

Impact: Swarm agent git layer only (agent/git_operations.py). No change to
Manager<->Swarm contract, callbacks, billing, secret_ref, or audit.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 22:35:27 +08:00
gongzhiyongandClaude Opus 4.8 62d6fdf78c fix(agent): per-task git worktree so concurrent tasks each get an isolated repo copy
取代上一版 Option B(执行器共用仓库根 + 串行 1 任务)。每个任务从本 agent 自己的 clone
切出独立 git worktree(完整仓库内容 + 独立分支/索引),执行器在其中读写真实源码,
任务级 GitOperations 在该 worktree 提交/推送结果分支,完成后回收 worktree。

- 单 agent 可并发多任务(MAX_CONCURRENT_TASKS 恢复 4),互不共用 checkout/index
- worktree 置于仓外 /tmp/agent-worktrees(AGENT_WORKTREE_BASE 可配),主 checkout 不受污染
- _git_admin_lock 仅串行 worktree add/remove 等共享 .git plumbing,任务执行仍并行
- 跨 agent 隔离不变:每个 agent 仍各自 clone 一份(各自 pod)
- 根治 "Empty workspace: no files detected"(worktree 自带仓库文件,已端到端验证)

GitOperations 新增 add_task_worktree / remove_task_worktree。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 05:01:25 +08:00
Songhaoz666 d0fa193f79 Initial commit 2026-06-08 17:32:34 +08:00