fix(diagnose): place step 4's edits in a worktree #195

Merged
claudiomaradonna merged 1 commit from fix/diagnose-check-worktree into main 2026-11-05 08:58:29 +01:00
Collaborator

Why

An agent can run diagnose on a failing test that is no regression,
for instance when an execute-plan task meets a failure of unknown
cause. In that case no step opens a scratch worktree: step 2 opens one
only for an agreed reproduction, and step 3 only for a bisect. When the
agent then tests a hypothesis by editing code, such as adding a log
line or reverting a hunk, step 4 does not say where to edit. The agent
is left with the main checkout or the task's own worktree. Step 5, the
Overview, and the workflow page all remove a scratch worktree that was
never opened. Fixes #194.

Two alternatives were set aside. Opening the worktree in step 1 would
add a worktree to diagnoses that only read. Making step 5 conditional
on its own would leave step 4's edits with no place to go.

What changed

Step 4 now runs a check that changes files in the scratch worktree, and
opens one from open-worktree when none is open, as step 3 already
does for a bisect. A check that only reads does not need a worktree.
The Overview and step 5 remove a scratch worktree only when one was
opened.

On the workflow page, the "Reads and writes" line says the skill
changes code only in a scratch worktree it removes at the end, and the
chart's last node reads "Remove any scratch worktree".

How to verify

Read .agents/skills/diagnose/SKILL.md on the branch as an agent with
a failing test that is no regression. Steps 2 and 3 open nothing. Step
4 sends an edit for a hypothesis to a scratch worktree it opens, and
step 5 removes it. A diagnosis whose checks only read reaches step 5
with nothing to remove. On main, step 4 names no place for the edit,
and step 5 removes a worktree that does not exist.

On the tip, bash tests/verify-agent-config.sh,
bash tests/check-work-folder.sh, .agents/hooks/shellcheck.sh repo,
prettier --check '**/*.md', scripts/verify-agent-config.sh, and
git diff --check main all pass. No test checks this prose. The
behavioral evals were not run, since each run is billed.

https://claude.ai/code/session_012CBsgjdkRDt2uVUmT7bj64

## Why An agent can run `diagnose` on a failing test that is no regression, for instance when an `execute-plan` task meets a failure of unknown cause. In that case no step opens a scratch worktree: step 2 opens one only for an agreed reproduction, and step 3 only for a bisect. When the agent then tests a hypothesis by editing code, such as adding a log line or reverting a hunk, step 4 does not say where to edit. The agent is left with the main checkout or the task's own worktree. Step 5, the Overview, and the workflow page all remove a scratch worktree that was never opened. Fixes #194. Two alternatives were set aside. Opening the worktree in step 1 would add a worktree to diagnoses that only read. Making step 5 conditional on its own would leave step 4's edits with no place to go. ## What changed Step 4 now runs a check that changes files in the scratch worktree, and opens one from `open-worktree` when none is open, as step 3 already does for a bisect. A check that only reads does not need a worktree. The Overview and step 5 remove a scratch worktree only when one was opened. On the workflow page, the "Reads and writes" line says the skill changes code only in a scratch worktree it removes at the end, and the chart's last node reads "Remove any scratch worktree". ## How to verify Read `.agents/skills/diagnose/SKILL.md` on the branch as an agent with a failing test that is no regression. Steps 2 and 3 open nothing. Step 4 sends an edit for a hypothesis to a scratch worktree it opens, and step 5 removes it. A diagnosis whose checks only read reaches step 5 with nothing to remove. On `main`, step 4 names no place for the edit, and step 5 removes a worktree that does not exist. On the tip, `bash tests/verify-agent-config.sh`, `bash tests/check-work-folder.sh`, `.agents/hooks/shellcheck.sh repo`, `prettier --check '**/*.md'`, `scripts/verify-agent-config.sh`, and `git diff --check main` all pass. No test checks this prose. The behavioral evals were not run, since each run is billed. https://claude.ai/code/session_012CBsgjdkRDt2uVUmT7bj64
fix(diagnose): place step 4's edits in a worktree
All checks were successful
Maintenance / checks (pull_request) Successful in 4m3s
Maintenance / checks (push) Successful in 3m47s
1641a72e93
When a failing test is the reproduction and the failure is no
regression, no step opened a scratch worktree, so a check that edits
code had no stated place, and step 5 removed a worktree that did not
exist. Step 4 now runs such a check in the scratch worktree, opened
when none is open, and the removal applies when one was opened.

Fixes #194

Claude-Session: https://claude.ai/code/session_012CBsgjdkRDt2uVUmT7bj64
claudiomaradonna deleted branch fix/diagnose-check-worktree 2026-11-05 08:58:35 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
claudiomaradonna/agent-foundry!195
No description provided.