Metadata
| Status | done |
|---|---|
| Assigned | agent-949 |
| Agent identity | f51439356729d112a6c404803d88015d5b44832c6c584c62b96732b63c2b0c7e |
| Model | claude:opus |
| Created | 2026-04-28T21:28:43.315945945+00:00 |
| Started | 2026-04-28T21:51:37.815280290+00:00 |
| Completed | 2026-04-28T22:27:30.718892684+00:00 |
| Tags | eval-scheduled |
| Eval score | 0.86 |
| └ blocking impact | 0.88 |
| └ completeness | 0.95 |
| └ constraint fidelity | 0.85 |
| └ coordination overhead | 0.80 |
| └ correctness | 0.92 |
| └ downstream usability | 0.85 |
| └ efficiency | 0.83 |
| └ intent fidelity | 0.87 |
| └ style adherence | 0.91 |
Description
Description
wg done silently drops staged-uncommitted changes in agent worktrees. When the worktree branch has 0 commits ahead of main but uncommitted/staged tracked files, the worktree-merge codepath returns WorktreeMergeResult::NoCommits and proceeds to mark the task done — losing the agent's work and cleaning up the worktree without surfacing any warning.
This was originally suspected to be a codex-handler-specific bug ("codex handler doesn't commit/merge like claude does"). It is not. The code path runs for every executor; claude tasks just usually escape it because their agent guide tells the agent to commit before wg done. Diagnostic doc: docs/codex-handler-merge-bug.md.
Source task that surfaced this: verify-agents-md (cycle iter 1/3, 2026-04-28).
Concrete repro: .wg/agents/agent-933/output.log — codex agent for create-agents-md ran git add AGENTS.md && wg done, saw zero error output, AGENTS.md never landed on main.
Code locations
src/commands/done.rs:280-294—commit_count == 0short-circuit returnsNoCommitswithout checking the working tree state.src/commands/done.rs:2113-2117—NoCommitsis treated identically toNotInWorktree, no warning emitted.wg showworktree block displaysMerged to main: trueeven when the merge silently no-opped — flag is not gated on actualMergedresult.
Suggested fix (conservative)
In attempt_worktree_merge, before the commit_count == 0 short-circuit, run git status --porcelain in the worktree. If there are staged or modified tracked files (entries that are not ?? untracked), refuse wg done with an actionable error:
Worktree has uncommitted changes (file1, file2). Run `git commit` in the worktree
before `wg done`, or pass `--abandon-uncommitted` to discard them explicitly.
Plus:
- Fix the
wg show"Merged to main: true" lie — must reflect actualMergedoutcome. - Add a
[merge] No commits on branch X — nothing to mergelog line for the genuine NoCommits case so the agent at least sees what happened.
Validation
-
Failing test written first (TDD):
tests/integration_done_uncommitted.rs— agent worktree with staged-but-uncommitted tracked file, callswg done, expect non-zero exit + actionable error message + task NOT marked done. - Implementation makes the test pass.
-
wg showno longer reportsMerged to main: truewhen the branch has 0 commits ahead. -
Existing
tests/integration_done_*.rsstill pass (no regressions on the happy path or NoCommits-after-genuine-merge case at done.rs:374). - cargo build + cargo test pass.
-
Add a smoke scenario
tests/smoke/scenarios/wg_done_refuses_uncommitted_worktree.shthat stages a file, runswg done, and asserts (a) exit code != 0, (b) error mentions the file, (c) the file is NOT on main, (d) the task is NOT done. List this task id inowners.
Depends on
Required by
- (none)
Log
- 2026-04-28T21:39:44.427631061+00:00 Lightweight assignment: agent=Careful Programmer (f5143935), exec_mode=full, context_scope=task, reason=Careful Programmer is ideal for correctness-critical bug fix preventing silent data loss; requires comprehensive testing, Rust implementation, and careful validation.
- 2026-04-28T21:39:45.597629835+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-28T21:39:53.147476451+00:00 Starting work: investigating done.rs worktree merge logic for silent drop bug
- 2026-04-28T21:51:30.854702305+00:00 Task unclaimed: agent 'agent-944' (PID 563901) process exited
- 2026-04-28T21:51:37.815285750+00:00 Spawned by coordinator --executor claude --model opus
- 2026-04-28T22:16:22.685088395+00:00 Implementation complete. Added staged-uncommitted check to attempt_worktree_merge, gated wg show merged_to_main on uncommitted_files==0, added NoCommits log line, added smoke scenario, fixed env-leak in detect_worktree by validating WG_PROJECT_ROOT matches dir.parent(). All 3 new TDD tests pass, smoke gate tests pass, cycle detection 169/171 (2 pre-existing). Cargo build clean.
- 2026-04-28T22:17:28.962761429+00:00 Committed: 7c6df8515 — pushed to remote (origin/wg/agent-944/wg-done-silent)
- 2026-04-28T22:23:28.465153080+00:00 Merged main into branch (resolved smoke manifest conflict — kept both new scenarios). Pushed: 31056ff27
- 2026-04-28T22:27:30.718896071+00:00 Task pending eval (agent reported done; awaiting `.evaluate-*` to score)
- 2026-04-28T22:29:54.175309859+00:00 PendingEval → Done (evaluator passed; downstream unblocks)