Commit 3d6f4fd
fix(review): address PR #234 review findings
Addresses 4 reviewer reports against PR #234. All findings actioned
except those explicitly out of scope (silent-failure-hunter's "write
to sibling file" alternative — overkill given the tripwire is
non-blocking).
## Critical fixes
1. **Porcelain parser rewrite** (orchestrator/worktree.py)
The substring filter `"M" in status` was too loose (matched
phantom code combinations) and too narrow (missed staged-add `A`,
renames `R`, copies `C`, typechanges `T`). Rename paths in
porcelain v1 use `orig -> new` syntax that the old parser
reported as a single garbage path.
New: explicit `_PORCELAIN_WRITE_CODES` set, `_parse_porcelain_line`
helper that splits rename destinations correctly. Untracked is
handled via the `??` special case; deletions (`D`) are documented
as intentionally NOT surfaced (removing a file isn't a "write").
2. **Tripwire hoisted into execute-incomplete branch**
(orchestrator/iteration.py) The original implementation only ran
`detect_undeclared_writes` on EXECUTE_ANALYZE success. But that's
exactly when undeclared writes matter LEAST — the executor wrote
findings.json and likely declared what it needed. The case that
matters MOST is `_missing_execute_artifacts` (max-turn exhaustion,
subprocess crash) where the executor wrote partial code and never
got to declare it. New `_detect_undeclared_writes_for_iter`
helper runs in both branches; results land in retry_log.jsonl
on incomplete and findings.json on success.
3. **`detect_undeclared_writes` git-failure log: DEBUG → WARNING**
The whole point of the helper is "turn silent loss into an
auditable trail." Swallowing diagnostic failures at DEBUG
re-introduces the silent loss for the failure case. Now logs at
WARNING with returncode + stderr.
4. **`_declared_code_change_paths` YAML failure logged at ERROR**
bundle.yaml is a system boundary; corruption is operator-
actionable. Previously: silent empty-set return. Now: ERROR log
naming the parse error and the bundle path before returning empty.
## Important fixes
5. **`except BaseException` → `except Exception`** in
create_experiment_worktree's extras-cleanup path. BaseException
catches KeyboardInterrupt/SystemExit; we don't want to trigger a
`git worktree remove` subprocess on Ctrl-C.
6. **Existing-path collision in `_link_worktree_extras`** now logs a
loud, explanatory WARNING (was a quiet warn-and-continue) — names
the collision, explains why declaring a tracked path as an extra
is almost certainly a misconfiguration, and tells the operator
how to fix.
7. **`_record_undeclared_writes_in_findings` JSON failure logged at
ERROR** with the undeclared-paths list. Previously: silent return.
Now the operator can recover the list from logs even when
findings.json is corrupt.
8. **Parity: success branch now uses `experiment_id` AND
`experiment_dir` guards**, matching the cleanup path's
`experiment_id` guard. A future refactor that decouples them
won't silently disable the tripwire.
## Test additions (+8 behavioral tests)
- `test_modify_then_stage_flagged` — porcelain MM
- `test_added_staged_file_flagged` — porcelain A
- `test_renamed_file_reports_destination` — rename parser
- `test_deleted_file_not_flagged` — codify the D-skip behavior
- `test_renamed_destination_can_be_declared` — declared-paths
filter survives rename round-trip
- `test_git_failure_logs_warning` — diagnostic failures aren't silent
- `test_malformed_findings_logs_error_with_paths` — recovery info in logs
- `test_corrupted_bundle_logs_error` — bundle corruption is loud
## Test relaxations (review-flagged brittleness)
- `TestWorktreeDisciplineGuidance` no longer asserts the literal
string "Do not `cd` to the parent repo" — anchors on
"Worktree discipline", "worktree_extras", "code_changes" instead.
Editorial prose tweaks won't break the test; the *concepts* still
must be present.
- `test_logs_missing_placeholders_and_context_keys` now matches by
substring (not exact list-repr). A future format swap (JSON,
comma-joined) preserves the diagnostic intent.
## Test plan
- 1175 passed, 1 skipped (was 1167; +8 new). Zero regressions.
- All tests behavioral; real on-disk git repos in tmp_path; caplog
for diagnostic-line assertions.
Refs #228, closes #229 #230 #231 #232 (v1).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b6dfa08 commit 3d6f4fd
4 files changed
Lines changed: 289 additions & 49 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
57 | 69 | | |
58 | 70 | | |
59 | 71 | | |
60 | 72 | | |
61 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
62 | 80 | | |
63 | 81 | | |
64 | 82 | | |
| |||
77 | 95 | | |
78 | 96 | | |
79 | 97 | | |
80 | | - | |
81 | | - | |
82 | | - | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
83 | 107 | | |
84 | 108 | | |
85 | 109 | | |
86 | 110 | | |
87 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
88 | 118 | | |
89 | 119 | | |
90 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
91 | 142 | | |
92 | 143 | | |
93 | 144 | | |
| |||
1048 | 1099 | | |
1049 | 1100 | | |
1050 | 1101 | | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
1051 | 1110 | | |
1052 | 1111 | | |
1053 | 1112 | | |
1054 | 1113 | | |
1055 | 1114 | | |
1056 | 1115 | | |
1057 | 1116 | | |
| 1117 | + | |
1058 | 1118 | | |
1059 | 1119 | | |
1060 | 1120 | | |
| |||
1076 | 1136 | | |
1077 | 1137 | | |
1078 | 1138 | | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1083 | 1143 | | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | 1144 | | |
1091 | 1145 | | |
1092 | 1146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
| 76 | + | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
79 | 82 | | |
80 | 83 | | |
81 | 84 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
102 | 113 | | |
103 | 114 | | |
104 | 115 | | |
| |||
122 | 133 | | |
123 | 134 | | |
124 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
125 | 139 | | |
126 | | - | |
127 | | - | |
128 | | - | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
129 | 147 | | |
130 | 148 | | |
131 | 149 | | |
132 | 150 | | |
133 | 151 | | |
134 | 152 | | |
135 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
136 | 181 | | |
137 | 182 | | |
138 | 183 | | |
139 | 184 | | |
140 | | - | |
| 185 | + | |
141 | 186 | | |
142 | 187 | | |
143 | 188 | | |
144 | | - | |
145 | | - | |
146 | | - | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
147 | 195 | | |
148 | 196 | | |
149 | 197 | | |
| |||
154 | 202 | | |
155 | 203 | | |
156 | 204 | | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
157 | 211 | | |
158 | 212 | | |
159 | 213 | | |
| |||
168 | 222 | | |
169 | 223 | | |
170 | 224 | | |
171 | | - | |
172 | | - | |
173 | | - | |
174 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
175 | 231 | | |
176 | 232 | | |
177 | 233 | | |
178 | 234 | | |
179 | 235 | | |
180 | 236 | | |
181 | | - | |
| 237 | + | |
| 238 | + | |
182 | 239 | | |
183 | | - | |
184 | | - | |
185 | | - | |
186 | | - | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
187 | 249 | | |
188 | 250 | | |
189 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
210 | 210 | | |
211 | 211 | | |
212 | 212 | | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
213 | 216 | | |
214 | 217 | | |
215 | 218 | | |
216 | | - | |
217 | | - | |
218 | 219 | | |
219 | 220 | | |
220 | 221 | | |
| |||
273 | 274 | | |
274 | 275 | | |
275 | 276 | | |
276 | | - | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
277 | 282 | | |
278 | 283 | | |
279 | 284 | | |
280 | 285 | | |
281 | 286 | | |
282 | 287 | | |
283 | 288 | | |
284 | | - | |
285 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
286 | 295 | | |
287 | 296 | | |
288 | 297 | | |
| |||
0 commit comments