Commit 7ef6458
feat(v1): add capture_patch/resolve_head git utils for SWE tasksets (#2054)
* feat(v1): add capture_patch/resolve_head git utils for SWE tasksets
Upstreams the patch-capture helper duplicated across the research-environments
SWE tasksets (research-environments#674): capture_patch snapshots the agent's
cumulative diff into trace.info["patch"] at finalize time (2 MB cap with
patch_truncated; failures record patch_error instead of failing the rollout;
index always reset; add/diff exit codes both surfaced), and resolve_head
records the pre-agent SHA at setup so agent commits stay inside the diff.
Exported from verifiers.v1 so tasksets import one canonical implementation.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(v1): fail patch capture when git reset fails
The reset's exit status was discarded, so a reset failure after a clean add
and diff (e.g. ENOSPC rewriting .git/index) recorded a successful patch
while leaving the tree staged for later scoring to trip on. Every mutating
step now reports: capture fails with the first failing of add, reset, or
diff. Covered by a git-shim test that fails only reset.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* chore(v1): remove the full diff file once the capped copy exists
The unbounded /tmp/vf_agent_patch_full is only needed until head produces
the capped copy; delete it inside the capture sequence so it never outlives
the runtime.run call — on the subprocess runtime those paths are the host's
/tmp. The capped file (<=2MB+1) is read back by capture_patch after the
command returns, so it cannot be removed in-sequence.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(v1): surface head failures in patch capture
head was the last unchecked step in the capture sequence: the redirect
truncates the capped file before head runs, so a failed head (ENOSPC, I/O
error) could read back as a silently empty patch with exit 0. Fold head's
exit code into the precedence chain (add > reset > diff > head) so every
step reports, and cover it with a head-shim test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix(v1): per-invocation temp paths and cleanup for patch capture
Fixed /tmp names let concurrent rollouts on shared-filesystem runtimes
(subprocess) read each other's patches between the write and the read —
silent cross-rollout contamination — and let an agent pre-create the
predictable path as a FIFO so the shell redirect blocks the rollout
forever. Suffix both paths with a host-generated nonce per invocation,
pre-remove the targets before the redirect opens, and best-effort remove
both files after the read since unique names no longer overwrite each
other. Covered by a path-uniqueness + cleanup test.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* chore(v1): remove patch capture test file
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 01ee452 commit 7ef6458
2 files changed
Lines changed: 122 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
| |||
260 | 265 | | |
261 | 266 | | |
262 | 267 | | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
263 | 272 | | |
264 | 273 | | |
265 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
0 commit comments