{"id":4,"owner":"sam","repo":"archie-core","issue_number":58,"title":"Add tests for Prepare's idempotent fast path and git error paths","body":"## Problem\n\n`internal/worktree/worktree_test.go` contains a single test, `TestPrepareCommitPushRoundTrip` (worktree_test.go:51), which only exercises the full happy path: clone → checkout → commit → push → verify remote branch. It never:\n\n1. Calls `Prepare` a second time on the same `(owner, repo, issue)` to verify the existing-worktree short-circuit at `internal/worktree/worktree.go:77-79`:\n ```go\n // Already prepared (daemon cloned before container acquire).\n if st, statErr := os.Stat(filepath.Join(dir, \".git\")); statErr == nil \u0026\u0026 st.IsDir() {\n return dir, branch, nil\n }\n ```\n2. Exercises any git-command failure propagation paths in `git()`, `CommitAll`, `Push`, `ChangedLines`, or `Diff` — e.g. a bad clone URL, an invalid base branch name, or a rejected push.\n\n## Why it matters\n\nThe \"already prepared\" short-circuit is a fragile, filesystem-presence-based idempotency check (it only verifies `.git` exists as a directory, not that the worktree is on the correct branch or otherwise valid). Since it is currently unverified by any test, a regression here (e.g. returning a stale/wrong branch, or failing to detect a corrupt partial clone) would go unnoticed. Similarly, all error-return branches in the git-wrapping methods are untested, so failures in argument construction or error wrapping (`fmt.Errorf(\"git %s: %w\\n%s\", ...)`) could silently break without any test catching it.\n\n## Suggested fix\n\n- Add a case to `TestPrepareCommitPushRoundTrip` (or a new test) that calls `m.Prepare` twice with the same arguments and asserts the second call returns the same `dir`/`branch` without re-cloning (e.g. assert no network/clone call occurs, or that repo state is unchanged).\n- Add table-driven or dedicated tests for failure paths:\n - `Prepare` with a nonexistent base branch or bad clone URL, expecting a non-nil error.\n - `Push` against a URL/remote that rejects the push.\n - `CommitAll`, `ChangedLines`, `Diff` invoked in a directory that is not a valid git repo, expecting errors to propagate correctly.\n","labels":["agent:dead","bug"],"workflow":"","branch":"fix/58-add-tests-for-prepares-idempotent-fast-path-and-git-error-pa"}