autoforge-cli 0.1.0a0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- autoforge/__init__.py +5 -0
- autoforge/agent_worktree.py +653 -0
- autoforge/certificate.py +495 -0
- autoforge/child_env.py +871 -0
- autoforge/claims.py +726 -0
- autoforge/claude_stream.py +501 -0
- autoforge/cli.py +2884 -0
- autoforge/config.py +2178 -0
- autoforge/config_fingerprint.py +374 -0
- autoforge/doctor.py +1551 -0
- autoforge/doctor_sandbox.py +691 -0
- autoforge/effect_ops.py +1272 -0
- autoforge/effects.py +3210 -0
- autoforge/engine.py +16637 -0
- autoforge/epic_commands.py +1486 -0
- autoforge/epic_graph.py +852 -0
- autoforge/errors.py +536 -0
- autoforge/evidence.py +1722 -0
- autoforge/executor.py +1601 -0
- autoforge/executor_duplex.py +985 -0
- autoforge/executor_supervised.py +144 -0
- autoforge/git_transport.py +970 -0
- autoforge/github.py +3402 -0
- autoforge/interaction.py +1027 -0
- autoforge/local_workspace.py +1253 -0
- autoforge/locking.py +1050 -0
- autoforge/loop_detect.py +660 -0
- autoforge/loop_guard.py +404 -0
- autoforge/materialize.py +722 -0
- autoforge/ownership.py +240 -0
- autoforge/pi_rpc.py +713 -0
- autoforge/premerge.py +181 -0
- autoforge/profiles.py +106 -0
- autoforge/progress.py +392 -0
- autoforge/prompts/__init__.py +173 -0
- autoforge/prompts/acceptance_actions.md +39 -0
- autoforge/prompts/analyze_execute.md +128 -0
- autoforge/prompts/common.md +132 -0
- autoforge/prompts/correction.md +12 -0
- autoforge/prompts/fix.md +252 -0
- autoforge/prompts/local_analyze_execute.md +69 -0
- autoforge/prompts/local_common.md +149 -0
- autoforge/prompts/local_fix.md +96 -0
- autoforge/prompts/local_review.md +103 -0
- autoforge/prompts/operator_acceptance.md +61 -0
- autoforge/prompts/replan_reexecute.md +991 -0
- autoforge/prompts/review.md +312 -0
- autoforge/prompts/update_epic.md +120 -0
- autoforge/prompts/update_epic_rerequest.md +85 -0
- autoforge/prompts/validation_evidence.md +26 -0
- autoforge/prompts/validation_failure.md +22 -0
- autoforge/prompts/worktree_state.md +45 -0
- autoforge/providers.py +2893 -0
- autoforge/read_context.py +389 -0
- autoforge/redaction.py +408 -0
- autoforge/replan.py +208 -0
- autoforge/replan_txn.py +1930 -0
- autoforge/result_parser.py +2234 -0
- autoforge/roadmap.py +151 -0
- autoforge/run_contract.py +408 -0
- autoforge/run_namespace.py +839 -0
- autoforge/runlog.py +764 -0
- autoforge/safefs.py +1717 -0
- autoforge/sandbox.py +1313 -0
- autoforge/sandbox_bwrap.py +815 -0
- autoforge/sandbox_pin.py +170 -0
- autoforge/sandbox_policy.py +1107 -0
- autoforge/scheduler.py +1143 -0
- autoforge/scheduler_state.py +2316 -0
- autoforge/scheduler_stop.py +421 -0
- autoforge/sdk_policy.py +988 -0
- autoforge/state.py +2417 -0
- autoforge/transitions.py +388 -0
- autoforge/validation.py +324 -0
- autoforge/worker.py +568 -0
- autoforge_cli-0.1.0a0.dist-info/METADATA +525 -0
- autoforge_cli-0.1.0a0.dist-info/RECORD +81 -0
- autoforge_cli-0.1.0a0.dist-info/WHEEL +5 -0
- autoforge_cli-0.1.0a0.dist-info/entry_points.txt +2 -0
- autoforge_cli-0.1.0a0.dist-info/licenses/LICENSE +21 -0
- autoforge_cli-0.1.0a0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,991 @@
|
|
|
1
|
+
# AutoForge: ESCALATED REPLAN / REEXECUTE
|
|
2
|
+
|
|
3
|
+
你正在执行 AutoForge 的高级恢复流程:
|
|
4
|
+
|
|
5
|
+
`REPLAN_REEXECUTE`
|
|
6
|
+
|
|
7
|
+
这是一个异常升级路径,不是普通的 FIX phase。
|
|
8
|
+
|
|
9
|
+
当前 issue 已经经历了过多次:
|
|
10
|
+
|
|
11
|
+
`REVIEW → FIX → REVIEW`
|
|
12
|
+
|
|
13
|
+
循环。
|
|
14
|
+
|
|
15
|
+
这说明当前实现可能已经出现:
|
|
16
|
+
|
|
17
|
+
* local optimization
|
|
18
|
+
* architectural anchoring
|
|
19
|
+
* patch accumulation
|
|
20
|
+
* contradictory fixes
|
|
21
|
+
* reviewer/fixer oscillation
|
|
22
|
+
* implementation drift
|
|
23
|
+
* complexity accretion
|
|
24
|
+
* symptom fixing instead of root-cause fixing
|
|
25
|
+
|
|
26
|
+
因此:
|
|
27
|
+
|
|
28
|
+
**不要继续修补当前 PR。**
|
|
29
|
+
|
|
30
|
+
你的任务是:
|
|
31
|
+
|
|
32
|
+
1. 对失败历史做独立复盘
|
|
33
|
+
2. 重新理解 issue
|
|
34
|
+
3. 从头重新设计解决方案
|
|
35
|
+
4. 放弃旧 implementation branch
|
|
36
|
+
5. 基于最新 default branch 建立全新的实现
|
|
37
|
+
6. 避免旧 PR 曾经出现过的所有已知问题
|
|
38
|
+
7. 在本 worktree 的 detached `HEAD` 上提交新的实现,并给出 replacement PR 的
|
|
39
|
+
title 和 body;push 与创建 replacement PR 由 controller 完成(section 20)
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
# 1. Context
|
|
44
|
+
|
|
45
|
+
Repository:
|
|
46
|
+
|
|
47
|
+
`{{REPOSITORY}}`
|
|
48
|
+
|
|
49
|
+
EPIC:
|
|
50
|
+
|
|
51
|
+
`{{EPIC_URL}}`
|
|
52
|
+
|
|
53
|
+
Issue:
|
|
54
|
+
|
|
55
|
+
`{{ISSUE_URL}}`
|
|
56
|
+
|
|
57
|
+
Previous PR:
|
|
58
|
+
|
|
59
|
+
`{{PREVIOUS_PR_URL}}`
|
|
60
|
+
|
|
61
|
+
Previous branch:
|
|
62
|
+
|
|
63
|
+
`{{PREVIOUS_BRANCH}}`
|
|
64
|
+
|
|
65
|
+
Previous PR reviewed rounds:
|
|
66
|
+
|
|
67
|
+
`{{REVIEW_ROUND}}`
|
|
68
|
+
|
|
69
|
+
Previous PR HEAD:
|
|
70
|
+
|
|
71
|
+
`{{PREVIOUS_HEAD_SHA}}`
|
|
72
|
+
|
|
73
|
+
Default branch:
|
|
74
|
+
|
|
75
|
+
`{{DEFAULT_BRANCH}}`
|
|
76
|
+
|
|
77
|
+
Default branch head (the base the replacement must be built on, already
|
|
78
|
+
fetched into the object store this worktree shares):
|
|
79
|
+
|
|
80
|
+
`{{BASE_SHA}}`
|
|
81
|
+
|
|
82
|
+
Replacement branch the controller will push your commit to (derived by the
|
|
83
|
+
controller; yours to read about, not to create):
|
|
84
|
+
|
|
85
|
+
`{{REPLACEMENT_BRANCH}}`
|
|
86
|
+
|
|
87
|
+
Escalation reason:
|
|
88
|
+
|
|
89
|
+
`{{ESCALATION_REASON}}`
|
|
90
|
+
|
|
91
|
+
Replan transaction ID (controller-generated; see section 20):
|
|
92
|
+
|
|
93
|
+
`{{REPLAN_TRANSACTION_ID}}`
|
|
94
|
+
|
|
95
|
+
Historical review findings:
|
|
96
|
+
|
|
97
|
+
~~~~untrusted
|
|
98
|
+
{{HISTORICAL_FINDINGS}}
|
|
99
|
+
~~~~
|
|
100
|
+
|
|
101
|
+
Historical observations:
|
|
102
|
+
|
|
103
|
+
~~~~untrusted
|
|
104
|
+
{{HISTORICAL_OBSERVATIONS}}
|
|
105
|
+
~~~~
|
|
106
|
+
|
|
107
|
+
Historical verification failures:
|
|
108
|
+
|
|
109
|
+
~~~~untrusted
|
|
110
|
+
{{HISTORICAL_VERIFICATION_FAILURES}}
|
|
111
|
+
~~~~
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
# 2. Why this escalation happened
|
|
116
|
+
|
|
117
|
+
AutoForge has determined that continuing the existing implementation is no longer efficient or sufficiently reliable.
|
|
118
|
+
|
|
119
|
+
Typical trigger:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
review_round >= configured threshold
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
For example:
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
review_round >= 20
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
with additional strong evidence such as:
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
the last 3 review rounds each contained fewer than 3 findings
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
while still failing to reach a stable clean review.
|
|
138
|
+
|
|
139
|
+
The failures at this point usually do not come from one large missing feature.
|
|
140
|
+
|
|
141
|
+
More often the implementation has accumulated structural inconsistencies where each small correction exposes another small problem.
|
|
142
|
+
|
|
143
|
+
Do not interpret the small number of recent findings as evidence that another patch is necessarily the best approach.
|
|
144
|
+
|
|
145
|
+
The purpose of this phase is to break that cycle.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
# 3. Primary principle
|
|
150
|
+
|
|
151
|
+
The most important rule for this task is:
|
|
152
|
+
|
|
153
|
+
> Learn from the previous PR's failures, but do not inherit the previous PR's solution.
|
|
154
|
+
|
|
155
|
+
You MUST distinguish:
|
|
156
|
+
|
|
157
|
+
## Knowledge that MUST be retained
|
|
158
|
+
|
|
159
|
+
Retain factual knowledge such as:
|
|
160
|
+
|
|
161
|
+
* issue requirements
|
|
162
|
+
* acceptance criteria
|
|
163
|
+
* repository constraints
|
|
164
|
+
* AGENTS.md requirements
|
|
165
|
+
* CLAUDE.md requirements
|
|
166
|
+
* API contracts
|
|
167
|
+
* compatibility requirements
|
|
168
|
+
* discovered edge cases
|
|
169
|
+
* test expectations
|
|
170
|
+
* confirmed failure modes
|
|
171
|
+
* review findings
|
|
172
|
+
* standards violations
|
|
173
|
+
* security concerns
|
|
174
|
+
* concurrency concerns
|
|
175
|
+
* validation requirements
|
|
176
|
+
* behavioral requirements
|
|
177
|
+
* regression risks
|
|
178
|
+
* verification failures
|
|
179
|
+
* follow-up constraints
|
|
180
|
+
* reasons previous review rounds rejected behavior
|
|
181
|
+
|
|
182
|
+
These become constraints for the new implementation.
|
|
183
|
+
|
|
184
|
+
## Implementation choices that MUST NOT be inherited by default
|
|
185
|
+
|
|
186
|
+
Do NOT treat the previous PR's implementation as the baseline solution.
|
|
187
|
+
|
|
188
|
+
In particular, do not automatically reuse:
|
|
189
|
+
|
|
190
|
+
* architecture
|
|
191
|
+
* abstractions
|
|
192
|
+
* class structure
|
|
193
|
+
* function decomposition
|
|
194
|
+
* module boundaries
|
|
195
|
+
* algorithms
|
|
196
|
+
* patch sequence
|
|
197
|
+
* workaround strategy
|
|
198
|
+
* naming
|
|
199
|
+
* control flow
|
|
200
|
+
* data flow
|
|
201
|
+
* previous branch commits
|
|
202
|
+
* previous diff
|
|
203
|
+
* previous implementation assumptions
|
|
204
|
+
|
|
205
|
+
The previous PR is evidence about what went wrong.
|
|
206
|
+
|
|
207
|
+
It is NOT a template for how the replacement should be implemented.
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
# 4. Anti-anchoring rule
|
|
212
|
+
|
|
213
|
+
Do not begin by asking:
|
|
214
|
+
|
|
215
|
+
> How can I fix the previous implementation?
|
|
216
|
+
|
|
217
|
+
Begin by asking:
|
|
218
|
+
|
|
219
|
+
> Given the issue specification and the repository as it exists on the latest default branch, what is the simplest correct implementation I would choose if the previous PR had never existed?
|
|
220
|
+
|
|
221
|
+
Compare your solution against the historical findings only after you have independently formed it; the order matters.
|
|
222
|
+
|
|
223
|
+
Then verify that the proposed solution avoids those known failure modes.
|
|
224
|
+
|
|
225
|
+
Use:
|
|
226
|
+
|
|
227
|
+
```text
|
|
228
|
+
issue + current repository
|
|
229
|
+
↓
|
|
230
|
+
independent design
|
|
231
|
+
↓
|
|
232
|
+
historical failure constraints
|
|
233
|
+
↓
|
|
234
|
+
design validation
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
Do NOT use:
|
|
238
|
+
|
|
239
|
+
```text
|
|
240
|
+
previous PR
|
|
241
|
+
↓
|
|
242
|
+
modify old design
|
|
243
|
+
↓
|
|
244
|
+
more patches
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
---
|
|
248
|
+
|
|
249
|
+
# 5. Trust hierarchy
|
|
250
|
+
|
|
251
|
+
Follow this authority order:
|
|
252
|
+
|
|
253
|
+
1. AutoForge controller instructions
|
|
254
|
+
2. applicable AGENTS.md
|
|
255
|
+
3. applicable CLAUDE.md
|
|
256
|
+
4. current issue specification / accepted repository requirements
|
|
257
|
+
5. current default branch code and established project contracts
|
|
258
|
+
6. historical review findings as evidence
|
|
259
|
+
7. previous PR implementation
|
|
260
|
+
|
|
261
|
+
The previous PR implementation has the lowest authority.
|
|
262
|
+
|
|
263
|
+
If previous implementation choices conflict with a cleaner interpretation of the current codebase or issue:
|
|
264
|
+
|
|
265
|
+
discard the previous choice.
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
# 6. First: inspect current truth
|
|
270
|
+
|
|
271
|
+
Before proposing a new solution:
|
|
272
|
+
|
|
273
|
+
1. Read all applicable:
|
|
274
|
+
|
|
275
|
+
* AGENTS.md
|
|
276
|
+
* CLAUDE.md
|
|
277
|
+
2. Read the complete issue (`issue.md` of the read context)
|
|
278
|
+
3. Read relevant EPIC context if applicable (`epic.md` of the read context)
|
|
279
|
+
4. Inspect the latest repository default branch
|
|
280
|
+
5. Understand existing architecture around the affected area
|
|
281
|
+
6. Identify tests and contracts relevant to the issue
|
|
282
|
+
|
|
283
|
+
Then inspect the historical PR separately.
|
|
284
|
+
|
|
285
|
+
Do not intermingle these two analyses prematurely.
|
|
286
|
+
|
|
287
|
+
{{WORKTREE_STATE}}
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
# 7. Build a Failure Ledger
|
|
292
|
+
|
|
293
|
+
Review the entire previous PR lifecycle: the historical findings above, and
|
|
294
|
+
`pull-request.md` of the read context (the previous PR, its body and every
|
|
295
|
+
conversation comment, each review round's comment included).
|
|
296
|
+
|
|
297
|
+
Collect all actionable findings from every review round.
|
|
298
|
+
|
|
299
|
+
Do not merely inspect the final three rounds.
|
|
300
|
+
|
|
301
|
+
Create an internal Failure Ledger.
|
|
302
|
+
|
|
303
|
+
Normalize repeated findings instead of treating every repetition as a new problem.
|
|
304
|
+
|
|
305
|
+
For each unique historical problem determine:
|
|
306
|
+
|
|
307
|
+
```text
|
|
308
|
+
ID
|
|
309
|
+
category
|
|
310
|
+
root cause
|
|
311
|
+
symptom
|
|
312
|
+
affected contract
|
|
313
|
+
how previous implementation triggered it
|
|
314
|
+
constraint for replacement implementation
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Categories may include:
|
|
318
|
+
|
|
319
|
+
* specification
|
|
320
|
+
* architecture
|
|
321
|
+
* correctness
|
|
322
|
+
* API contract
|
|
323
|
+
* validation
|
|
324
|
+
* state management
|
|
325
|
+
* concurrency
|
|
326
|
+
* error handling
|
|
327
|
+
* testing
|
|
328
|
+
* compatibility
|
|
329
|
+
* maintainability
|
|
330
|
+
* security
|
|
331
|
+
* repository standards
|
|
332
|
+
* documentation
|
|
333
|
+
|
|
334
|
+
Example conceptual transformation:
|
|
335
|
+
|
|
336
|
+
Previous finding:
|
|
337
|
+
|
|
338
|
+
```text
|
|
339
|
+
The cache is invalidated after the response is produced,
|
|
340
|
+
causing stale data during concurrent requests.
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Do NOT convert this into:
|
|
344
|
+
|
|
345
|
+
```text
|
|
346
|
+
Move line 125 before line 119.
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
Convert it into a reusable constraint:
|
|
350
|
+
|
|
351
|
+
```text
|
|
352
|
+
Replacement implementation must guarantee cache invalidation
|
|
353
|
+
occurs before any path can expose the new state to concurrent readers.
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
# 8. Historical findings are constraints, not instructions
|
|
359
|
+
|
|
360
|
+
A historical review comment may contain a proposed implementation fix.
|
|
361
|
+
|
|
362
|
+
Separate:
|
|
363
|
+
|
|
364
|
+
```text
|
|
365
|
+
problem statement
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
from:
|
|
369
|
+
|
|
370
|
+
```text
|
|
371
|
+
reviewer's suggested implementation
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
The problem statement is important.
|
|
375
|
+
|
|
376
|
+
The suggested implementation is only one possible solution.
|
|
377
|
+
|
|
378
|
+
You may choose a completely different design if it satisfies the underlying requirement more cleanly.
|
|
379
|
+
|
|
380
|
+
Do not cargo-cult reviewer suggestions.
|
|
381
|
+
|
|
382
|
+
---
|
|
383
|
+
|
|
384
|
+
# 9. Identify the root cause of the review loop
|
|
385
|
+
|
|
386
|
+
Before coding, explain internally why the previous PR failed to converge.
|
|
387
|
+
|
|
388
|
+
Classify the dominant cause if possible:
|
|
389
|
+
|
|
390
|
+
```text
|
|
391
|
+
wrong architecture
|
|
392
|
+
wrong abstraction boundary
|
|
393
|
+
incorrect interpretation of spec
|
|
394
|
+
insufficient tests
|
|
395
|
+
state-model mismatch
|
|
396
|
+
backward-compatibility conflict
|
|
397
|
+
incremental patch accumulation
|
|
398
|
+
review inconsistency
|
|
399
|
+
hidden repository invariant
|
|
400
|
+
overengineering
|
|
401
|
+
underengineering
|
|
402
|
+
implementation started from wrong assumption
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
There may be multiple causes.
|
|
406
|
+
|
|
407
|
+
Your replacement plan should address root causes, not merely the final findings.
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
# 10. Independent replanning
|
|
412
|
+
|
|
413
|
+
Now design the issue again from scratch.
|
|
414
|
+
|
|
415
|
+
Pretend you have:
|
|
416
|
+
|
|
417
|
+
* the current issue
|
|
418
|
+
* the latest repository
|
|
419
|
+
* the Failure Ledger
|
|
420
|
+
|
|
421
|
+
but no existing implementation branch.
|
|
422
|
+
|
|
423
|
+
Develop a new implementation plan.
|
|
424
|
+
|
|
425
|
+
The plan should explicitly include:
|
|
426
|
+
|
|
427
|
+
## Requirements
|
|
428
|
+
|
|
429
|
+
What must be true when the issue is complete?
|
|
430
|
+
|
|
431
|
+
## Repository invariants
|
|
432
|
+
|
|
433
|
+
What existing behavior must remain unchanged?
|
|
434
|
+
|
|
435
|
+
## Design
|
|
436
|
+
|
|
437
|
+
What is the simplest robust architecture?
|
|
438
|
+
|
|
439
|
+
## Files / components
|
|
440
|
+
|
|
441
|
+
What should change?
|
|
442
|
+
|
|
443
|
+
## Tests
|
|
444
|
+
|
|
445
|
+
What proves the implementation?
|
|
446
|
+
|
|
447
|
+
## Historical failure prevention
|
|
448
|
+
|
|
449
|
+
For every Failure Ledger category:
|
|
450
|
+
|
|
451
|
+
explain how the new design avoids it.
|
|
452
|
+
|
|
453
|
+
Do not produce a plan whose structure is simply the previous PR with modifications.
|
|
454
|
+
|
|
455
|
+
---
|
|
456
|
+
|
|
457
|
+
# 11. Prefer simplification
|
|
458
|
+
|
|
459
|
+
A replacement implementation should generally reduce accumulated complexity.
|
|
460
|
+
|
|
461
|
+
Look for opportunities to:
|
|
462
|
+
|
|
463
|
+
* remove unnecessary abstraction
|
|
464
|
+
* use existing project patterns
|
|
465
|
+
* reduce state transitions
|
|
466
|
+
* reduce duplicated logic
|
|
467
|
+
* centralize invariants
|
|
468
|
+
* make invalid states unrepresentable
|
|
469
|
+
* simplify ownership
|
|
470
|
+
* simplify data flow
|
|
471
|
+
* write stronger tests around contracts
|
|
472
|
+
|
|
473
|
+
Do not perform unrelated refactoring.
|
|
474
|
+
|
|
475
|
+
The goal is not:
|
|
476
|
+
|
|
477
|
+
> redesign the entire subsystem
|
|
478
|
+
|
|
479
|
+
The goal is:
|
|
480
|
+
|
|
481
|
+
> find the cleanest implementation of this issue without being trapped by the previous implementation.
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
# 12. Validate the new design before implementation
|
|
486
|
+
|
|
487
|
+
Before touching the replacement branch, mentally test the new design against:
|
|
488
|
+
|
|
489
|
+
1. original issue requirements
|
|
490
|
+
2. AGENTS.md
|
|
491
|
+
3. CLAUDE.md
|
|
492
|
+
4. repository conventions
|
|
493
|
+
5. every unique historical finding
|
|
494
|
+
6. known verification failures
|
|
495
|
+
7. compatibility requirements
|
|
496
|
+
8. important edge cases
|
|
497
|
+
|
|
498
|
+
If the proposed design would recreate a historical failure:
|
|
499
|
+
|
|
500
|
+
change the design before coding.
|
|
501
|
+
|
|
502
|
+
Do not knowingly reproduce an old failure and plan to patch it later.
|
|
503
|
+
|
|
504
|
+
---
|
|
505
|
+
|
|
506
|
+
# 13. Preserve useful evidence before dropping old work
|
|
507
|
+
|
|
508
|
+
Before abandoning the previous implementation, make sure the information required for auditing has been preserved through GitHub and AutoForge state.
|
|
509
|
+
|
|
510
|
+
The previous PR should remain available as historical evidence.
|
|
511
|
+
|
|
512
|
+
Do NOT destroy GitHub history.
|
|
513
|
+
|
|
514
|
+
The controller, not you, owns the previous PR's lifecycle. The controller
|
|
515
|
+
closes it without merging once the replacement is verified. You must not
|
|
516
|
+
close, mark, comment on, or otherwise modify the previous PR:
|
|
517
|
+
|
|
518
|
+
* Do not run `gh pr close` on the previous PR.
|
|
519
|
+
* Do not run `gh pr comment`, `gh pr edit`, or any other command that marks
|
|
520
|
+
it as superseded.
|
|
521
|
+
* Do not post the "being superseded" explanation yourself; the controller
|
|
522
|
+
posts the supersession link when it closes the PR.
|
|
523
|
+
|
|
524
|
+
Describe the linkage only inside the replacement PR body (section 21).
|
|
525
|
+
|
|
526
|
+
Do not merge the old PR. Never merge a pull request.
|
|
527
|
+
|
|
528
|
+
---
|
|
529
|
+
|
|
530
|
+
# 14. Drop the old local implementation
|
|
531
|
+
|
|
532
|
+
After historical evidence has been captured:
|
|
533
|
+
|
|
534
|
+
stop using the old implementation branch.
|
|
535
|
+
|
|
536
|
+
Do not:
|
|
537
|
+
|
|
538
|
+
* continue committing to it
|
|
539
|
+
* rebase it into the new implementation
|
|
540
|
+
* merge it into the new implementation
|
|
541
|
+
* cherry-pick its implementation commits
|
|
542
|
+
* copy its diff wholesale
|
|
543
|
+
|
|
544
|
+
Do not touch the old local branch or any worktree other than the one you
|
|
545
|
+
were launched in. Local branches and the other worktrees are operator-owned:
|
|
546
|
+
the operator's checkout, uncommitted work, and existing branches must be left
|
|
547
|
+
exactly as found.
|
|
548
|
+
|
|
549
|
+
* Do not run `git branch -D`, `git branch -d`, `git push --delete`, or any
|
|
550
|
+
equivalent that deletes the previous branch.
|
|
551
|
+
* Do not run `git worktree add`, `git worktree remove`, `git worktree move`,
|
|
552
|
+
`git worktree prune`, or otherwise create, clean up, move, or delete any
|
|
553
|
+
worktree (yours included: the controller owns its lifecycle).
|
|
554
|
+
* Do not delete unrelated branches, unrelated worktrees, or uncommitted user
|
|
555
|
+
work.
|
|
556
|
+
|
|
557
|
+
Do not create any branch either: you work on a detached `HEAD` (section 15),
|
|
558
|
+
and the controller pushes your commit to the replacement branch it derived.
|
|
559
|
+
|
|
560
|
+
Leave the old local branch alone and report it.
|
|
561
|
+
|
|
562
|
+
Safety is more important than cleanup.
|
|
563
|
+
|
|
564
|
+
---
|
|
565
|
+
|
|
566
|
+
# 15. Start from fresh default branch
|
|
567
|
+
|
|
568
|
+
The controller already read the head of `{{DEFAULT_BRANCH}}` and fetched it
|
|
569
|
+
into the object store this worktree shares. Do not fetch, pull or push, and
|
|
570
|
+
run no other command that contacts the git remote.
|
|
571
|
+
|
|
572
|
+
The replacement implementation must originate from exactly:
|
|
573
|
+
|
|
574
|
+
```text
|
|
575
|
+
{{BASE_SHA}}
|
|
576
|
+
```
|
|
577
|
+
|
|
578
|
+
Run `git checkout --detach {{BASE_SHA}}` and stay on the detached `HEAD`: do
|
|
579
|
+
not create, check out or rename a local branch (`git checkout -b`,
|
|
580
|
+
`git switch -c`, `git branch`), and do not reset the worktree to anything
|
|
581
|
+
that does not descend from `{{BASE_SHA}}`.
|
|
582
|
+
|
|
583
|
+
You choose no branch name. The controller pushes the commit you report to
|
|
584
|
+
`{{REPLACEMENT_BRANCH}}`, a branch it derives from the issue and the replan
|
|
585
|
+
transaction id, after checking that the branch does not exist yet. A branch
|
|
586
|
+
or a replacement PR for this transaction that the controller did not create
|
|
587
|
+
from its own journal stops the run: it is never adopted.
|
|
588
|
+
|
|
589
|
+
Before it pushes anything, the controller runs its configured validation
|
|
590
|
+
commands (`validation.commands`, when any are configured) against the exact
|
|
591
|
+
commit you report, each in a fresh export of its tree. If one does not pass,
|
|
592
|
+
the replacement is refused, as a `tests_passed: false` result is, and
|
|
593
|
+
nothing is pushed or created.
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
# 16. No code inheritance rule
|
|
598
|
+
|
|
599
|
+
Do not cherry-pick previous implementation commits.
|
|
600
|
+
|
|
601
|
+
Do not automatically copy previous changed files.
|
|
602
|
+
|
|
603
|
+
Do not use the old diff as a checklist of code changes.
|
|
604
|
+
|
|
605
|
+
It is acceptable for the final replacement implementation to contain code similar to the previous PR when:
|
|
606
|
+
|
|
607
|
+
* the same implementation is independently justified by the current repository,
|
|
608
|
+
* it is clearly the simplest correct implementation,
|
|
609
|
+
* and it does not recreate historical failures.
|
|
610
|
+
|
|
611
|
+
Similarity by itself is not forbidden.
|
|
612
|
+
|
|
613
|
+
**Anchoring is forbidden.**
|
|
614
|
+
|
|
615
|
+
---
|
|
616
|
+
|
|
617
|
+
# 17. Implement from the new plan
|
|
618
|
+
|
|
619
|
+
Now execute the independently developed implementation plan.
|
|
620
|
+
|
|
621
|
+
Follow normal repository development discipline:
|
|
622
|
+
|
|
623
|
+
* make focused changes
|
|
624
|
+
* preserve scope
|
|
625
|
+
* write/update tests
|
|
626
|
+
* run relevant tests
|
|
627
|
+
* run lint
|
|
628
|
+
* run type checks
|
|
629
|
+
* run build where applicable
|
|
630
|
+
* verify important edge cases
|
|
631
|
+
|
|
632
|
+
Fix failures before returning the result.
|
|
633
|
+
|
|
634
|
+
Commit locally on the detached `HEAD`, with clear messages referencing
|
|
635
|
+
`#{{ISSUE_NUMBER}}`. A commit message must not use a closing keyword
|
|
636
|
+
(`close`, `fix`, `resolve` in any form) followed by any issue other than
|
|
637
|
+
`#{{ISSUE_NUMBER}}`, and must contain nothing shaped like a credential: the
|
|
638
|
+
controller reads every commit it would publish and asks you to correct the
|
|
639
|
+
result otherwise. Leave the working tree clean.
|
|
640
|
+
|
|
641
|
+
Read the commit to report with `git rev-parse HEAD`. It must differ from
|
|
642
|
+
`{{BASE_SHA}}` (you must have committed something) and descend from it.
|
|
643
|
+
|
|
644
|
+
Do not lower standards simply because this is a recovery attempt.
|
|
645
|
+
|
|
646
|
+
---
|
|
647
|
+
|
|
648
|
+
# 18. Historical regression verification
|
|
649
|
+
|
|
650
|
+
Before declaring implementation complete, explicitly validate the replacement against every unique historical actionable issue.
|
|
651
|
+
|
|
652
|
+
Maintain a conceptual matrix:
|
|
653
|
+
|
|
654
|
+
| Historical problem | Replacement prevention | Verification |
|
|
655
|
+
| ------------------ | ---------------------- | ------------ |
|
|
656
|
+
|
|
657
|
+
Every previous actionable finding must result in one of:
|
|
658
|
+
|
|
659
|
+
```text
|
|
660
|
+
prevented_by_design
|
|
661
|
+
covered_by_test
|
|
662
|
+
not_applicable_to_new_design
|
|
663
|
+
resolved_by_repository_change
|
|
664
|
+
```
|
|
665
|
+
|
|
666
|
+
If marked:
|
|
667
|
+
|
|
668
|
+
```text
|
|
669
|
+
not_applicable_to_new_design
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
be able to explain why.
|
|
673
|
+
|
|
674
|
+
Do not silently omit old findings.
|
|
675
|
+
|
|
676
|
+
---
|
|
677
|
+
|
|
678
|
+
# 19. Do not overfit to previous reviewers
|
|
679
|
+
|
|
680
|
+
Historical findings tell you what was wrong.
|
|
681
|
+
|
|
682
|
+
They do not define the complete specification.
|
|
683
|
+
|
|
684
|
+
Do not create bizarre code solely to satisfy literal wording of old review comments if doing so makes the implementation worse.
|
|
685
|
+
|
|
686
|
+
The hierarchy remains:
|
|
687
|
+
|
|
688
|
+
```text
|
|
689
|
+
issue / repository contracts
|
|
690
|
+
>
|
|
691
|
+
root problem represented by finding
|
|
692
|
+
>
|
|
693
|
+
suggested fix in old review
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
---
|
|
697
|
+
|
|
698
|
+
# 20. Replacement PR
|
|
699
|
+
|
|
700
|
+
You publish nothing. The replacement's two GitHub writes belong to the
|
|
701
|
+
controller, and it journals both before either is sent:
|
|
702
|
+
|
|
703
|
+
1. it pushes the exact commit you report to `{{REPLACEMENT_BRANCH}}`,
|
|
704
|
+
compared against "absent";
|
|
705
|
+
2. it creates the replacement PR from `{{REPLACEMENT_BRANCH}}` onto
|
|
706
|
+
`{{DEFAULT_BRANCH}}`, with your title and with your body followed by its
|
|
707
|
+
own `Closes #{{ISSUE_NUMBER}}` line, the issue's implementation marker and
|
|
708
|
+
the replan transaction marker for transaction `{{REPLAN_TRANSACTION_ID}}`,
|
|
709
|
+
which it renders from your `CONTROL_RESULT` counts.
|
|
710
|
+
|
|
711
|
+
So do not push, and do not create, edit or comment on any pull request or
|
|
712
|
+
issue (no `gh pr create`, no `gh pr edit`). Do not write `Closes #<n>`, the
|
|
713
|
+
implementation marker or the transaction marker anywhere: the controller adds
|
|
714
|
+
them, and a PR carrying this transaction's marker that it did not create is
|
|
715
|
+
refused, never adopted.
|
|
716
|
+
|
|
717
|
+
The PR title is one line of at most {{MAX_PR_TITLE_CHARS}} characters. The PR
|
|
718
|
+
body is Markdown of at most {{MAX_PR_BODY_CHARS}} characters, and must:
|
|
719
|
+
|
|
720
|
+
* clearly identify itself as a fresh reimplementation
|
|
721
|
+
* link the superseded PR
|
|
722
|
+
* explain why reimplementation was chosen
|
|
723
|
+
* summarize the independent architecture
|
|
724
|
+
* summarize verification
|
|
725
|
+
* explain how historical failure categories were prevented
|
|
726
|
+
|
|
727
|
+
Do not reproduce dozens of historical comments in the PR body.
|
|
728
|
+
|
|
729
|
+
Summarize them by root-cause category.
|
|
730
|
+
|
|
731
|
+
## What published text may contain
|
|
732
|
+
|
|
733
|
+
`pr_title` and `pr_body` are published on GitHub as you return them. Either
|
|
734
|
+
is rejected, and you are asked to correct it, when it contains:
|
|
735
|
+
|
|
736
|
+
- an HTML comment opening a controller marker (`<!-- ai-` or
|
|
737
|
+
`<!-- autoforge-`, in any spacing or case);
|
|
738
|
+
- anything shaped like a credential (a token, a key, an authorization
|
|
739
|
+
header, a URL with a password);
|
|
740
|
+
- a closing keyword followed by an issue reference (`Closes #12`,
|
|
741
|
+
`fixes owner/repo#3`, `Resolves GH-4`), even inside code: GitHub would
|
|
742
|
+
act on it, and the controller links this issue itself;
|
|
743
|
+
- an `@` that would mention a user or team outside a code span or a fenced
|
|
744
|
+
block. Put such tokens in a code span (`` `@name` ``).
|
|
745
|
+
|
|
746
|
+
## The counts the transaction marker attests
|
|
747
|
+
|
|
748
|
+
The controller identifies the replacement PR by the transaction marker it
|
|
749
|
+
renders, never by shape, and treats that marker as the authoritative
|
|
750
|
+
attestation when it binds the PR, before it closes the superseded PR, and
|
|
751
|
+
after a crash. It renders the marker from your result:
|
|
752
|
+
|
|
753
|
+
* `execution_attempt` must be exactly `{{EXECUTION_ATTEMPT}}`.
|
|
754
|
+
* `historical_findings_considered` must be the real number of historical
|
|
755
|
+
actionable findings you analysed, and must be at least
|
|
756
|
+
`{{HISTORICAL_FINDING_COUNT}}`, the count the controller preserved. If you
|
|
757
|
+
cannot honestly account for all of them, return the blocked result in
|
|
758
|
+
section 27 instead of lowering the number.
|
|
759
|
+
* `unique_failure_constraints` must be the deduplicated count and must not
|
|
760
|
+
exceed `historical_findings_considered`.
|
|
761
|
+
* `verification.tests_passed` must be your real verification outcome. `false`
|
|
762
|
+
means the controller refuses the replacement before anything is pushed; it
|
|
763
|
+
never means "close the old PR anyway".
|
|
764
|
+
|
|
765
|
+
---
|
|
766
|
+
|
|
767
|
+
# 21. Replacement PR description
|
|
768
|
+
|
|
769
|
+
Include a section similar to:
|
|
770
|
+
|
|
771
|
+
```markdown
|
|
772
|
+
## Fresh Reimplementation
|
|
773
|
+
|
|
774
|
+
This PR replaces <previous PR> after the previous implementation failed
|
|
775
|
+
to converge through repeated review/remediation cycles.
|
|
776
|
+
|
|
777
|
+
The implementation was rebuilt from the current default branch rather
|
|
778
|
+
than continued from the previous implementation.
|
|
779
|
+
|
|
780
|
+
Historical review findings were used as failure constraints, not as an
|
|
781
|
+
implementation template.
|
|
782
|
+
|
|
783
|
+
## Root Causes Addressed
|
|
784
|
+
|
|
785
|
+
...
|
|
786
|
+
|
|
787
|
+
## Historical Failure Prevention
|
|
788
|
+
|
|
789
|
+
...
|
|
790
|
+
|
|
791
|
+
## Verification
|
|
792
|
+
|
|
793
|
+
...
|
|
794
|
+
```
|
|
795
|
+
|
|
796
|
+
Adapt to repository conventions.
|
|
797
|
+
|
|
798
|
+
---
|
|
799
|
+
|
|
800
|
+
# 22. Previous PR disposition
|
|
801
|
+
|
|
802
|
+
Once the controller has created and verified the replacement PR:
|
|
803
|
+
|
|
804
|
+
the controller, not you, closes the previous PR without merging it and posts
|
|
805
|
+
the supersession link. Do not run `gh pr close` or otherwise close the previous
|
|
806
|
+
PR.
|
|
807
|
+
|
|
808
|
+
Link:
|
|
809
|
+
|
|
810
|
+
```text
|
|
811
|
+
previous PR → replacement PR
|
|
812
|
+
replacement PR → previous PR
|
|
813
|
+
```
|
|
814
|
+
|
|
815
|
+
Do not close the underlying issue.
|
|
816
|
+
|
|
817
|
+
The original issue remains active until the replacement implementation is successfully completed and merged through the normal workflow.
|
|
818
|
+
|
|
819
|
+
---
|
|
820
|
+
|
|
821
|
+
# 23. Review history reset semantics
|
|
822
|
+
|
|
823
|
+
This is a fresh implementation attempt.
|
|
824
|
+
|
|
825
|
+
The replacement PR should begin a fresh review sequence.
|
|
826
|
+
|
|
827
|
+
Therefore:
|
|
828
|
+
|
|
829
|
+
```text
|
|
830
|
+
replacement review_round = 1
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
Do NOT continue:
|
|
834
|
+
|
|
835
|
+
```text
|
|
836
|
+
21 → 22 → 23
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
on the replacement PR.
|
|
840
|
+
|
|
841
|
+
However, AutoForge should separately retain escalation metadata such as:
|
|
842
|
+
|
|
843
|
+
```text
|
|
844
|
+
execution_attempt
|
|
845
|
+
previous_pr_url
|
|
846
|
+
previous_review_round_count
|
|
847
|
+
escalation_count
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
so historical failure information is not lost.
|
|
851
|
+
|
|
852
|
+
---
|
|
853
|
+
|
|
854
|
+
# 24. Do not reset escalation history completely
|
|
855
|
+
|
|
856
|
+
A fresh implementation does not mean AutoForge should forget the issue has already failed to converge once.
|
|
857
|
+
|
|
858
|
+
The controller should retain something equivalent to:
|
|
859
|
+
|
|
860
|
+
```json
|
|
861
|
+
{
|
|
862
|
+
"execution_attempt": 2,
|
|
863
|
+
"escalation_count": 1,
|
|
864
|
+
"superseded_prs": [
|
|
865
|
+
"https://github.com/..."
|
|
866
|
+
]
|
|
867
|
+
}
|
|
868
|
+
```
|
|
869
|
+
|
|
870
|
+
This prevents endless:
|
|
871
|
+
|
|
872
|
+
```text
|
|
873
|
+
20 reviews
|
|
874
|
+
→ reset
|
|
875
|
+
→ 20 reviews
|
|
876
|
+
→ reset
|
|
877
|
+
→ 20 reviews
|
|
878
|
+
→ ...
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
A repeated escalation should eventually require stronger intervention or human review according to controller policy.
|
|
882
|
+
|
|
883
|
+
---
|
|
884
|
+
|
|
885
|
+
# 25. Escalation loop protection
|
|
886
|
+
|
|
887
|
+
The controller owns and enforces the replan limit. Do not attempt to infer or
|
|
888
|
+
enforce that limit yourself. If a trustworthy fresh implementation cannot be
|
|
889
|
+
produced, return the blocked result below rather than fabricating success.
|
|
890
|
+
|
|
891
|
+
---
|
|
892
|
+
|
|
893
|
+
# 26. CONTROL_RESULT
|
|
894
|
+
|
|
895
|
+
After committing and verifying the replacement implementation, stdout must end with exactly one:
|
|
896
|
+
|
|
897
|
+
```text
|
|
898
|
+
<<<CONTROL_RESULT>>>
|
|
899
|
+
{
|
|
900
|
+
"phase": "REPLAN_REEXECUTE",
|
|
901
|
+
"status": "success",
|
|
902
|
+
"issue_url": "{{ISSUE_URL}}",
|
|
903
|
+
"previous_pr_url": "{{PREVIOUS_PR_URL}}",
|
|
904
|
+
"previous_branch": "{{PREVIOUS_BRANCH}}",
|
|
905
|
+
"previous_head_sha": "{{PREVIOUS_HEAD_SHA}}",
|
|
906
|
+
"head_sha": "<git rev-parse HEAD in this worktree, 40 hex chars>",
|
|
907
|
+
"execution_attempt": {{EXECUTION_ATTEMPT}},
|
|
908
|
+
"historical_findings_considered": {{HISTORICAL_FINDING_COUNT}},
|
|
909
|
+
"unique_failure_constraints": 2,
|
|
910
|
+
"previous_pr_disposition": "superseded",
|
|
911
|
+
"fresh_review_round": 1,
|
|
912
|
+
"verification": {
|
|
913
|
+
"tests_run": [],
|
|
914
|
+
"tests_passed": true
|
|
915
|
+
},
|
|
916
|
+
"pr_title": "<one-line PR title>",
|
|
917
|
+
"pr_body": "<PR body, Markdown: the sections of section 21>"
|
|
918
|
+
}
|
|
919
|
+
<<<END_CONTROL_RESULT>>>
|
|
920
|
+
```
|
|
921
|
+
|
|
922
|
+
Use actual values.
|
|
923
|
+
|
|
924
|
+
`head_sha` is a cross-check: the controller reads this worktree's `HEAD`
|
|
925
|
+
itself, and rejects the replacement when `head_sha` differs from it or when
|
|
926
|
+
the commit is `{{BASE_SHA}}` itself or does not descend from it. A `HEAD`
|
|
927
|
+
attached to a local branch is corrected, not published. There is no
|
|
928
|
+
`replacement_pr_url` or `replacement_branch` field: you create no PR and
|
|
929
|
+
choose no branch.
|
|
930
|
+
|
|
931
|
+
`historical_findings_considered` means the number of historical actionable findings actually analyzed.
|
|
932
|
+
|
|
933
|
+
`unique_failure_constraints` means the number after deduplicating/normalizing them into root constraints. It is
|
|
934
|
+
recorded by the controller alongside the superseded PR; report the real number (the `2` above is only an example)
|
|
935
|
+
and never a value greater than `historical_findings_considered`.
|
|
936
|
+
|
|
937
|
+
The controller renders these values into the replan transaction marker on
|
|
938
|
+
the replacement PR (section 20), and compares the marker it reads back from
|
|
939
|
+
GitHub with them; a disagreement rejects the replacement.
|
|
940
|
+
|
|
941
|
+
---
|
|
942
|
+
|
|
943
|
+
# 27. Blocked result
|
|
944
|
+
|
|
945
|
+
If a trustworthy fresh implementation cannot be produced:
|
|
946
|
+
|
|
947
|
+
do not fall back to blindly patching the previous branch.
|
|
948
|
+
|
|
949
|
+
Return:
|
|
950
|
+
|
|
951
|
+
```text
|
|
952
|
+
<<<CONTROL_RESULT>>>
|
|
953
|
+
{
|
|
954
|
+
"phase": "REPLAN_REEXECUTE",
|
|
955
|
+
"status": "blocked",
|
|
956
|
+
"message": "...",
|
|
957
|
+
"issue_url": "{{ISSUE_URL}}",
|
|
958
|
+
"previous_pr_url": "{{PREVIOUS_PR_URL}}",
|
|
959
|
+
"blocking_reason": "...",
|
|
960
|
+
"root_cause_assessment": "...",
|
|
961
|
+
"recommended_human_decision": "..."
|
|
962
|
+
}
|
|
963
|
+
<<<END_CONTROL_RESULT>>>
|
|
964
|
+
```
|
|
965
|
+
|
|
966
|
+
Do not fabricate a successful replacement.
|
|
967
|
+
|
|
968
|
+
---
|
|
969
|
+
|
|
970
|
+
# 28. Final discipline
|
|
971
|
+
|
|
972
|
+
The purpose of this phase is NOT:
|
|
973
|
+
|
|
974
|
+
> make the previous implementation finally pass review.
|
|
975
|
+
|
|
976
|
+
The purpose is:
|
|
977
|
+
|
|
978
|
+
> produce the implementation we should have built if we had known at the start everything we learned from the failed PR.
|
|
979
|
+
|
|
980
|
+
Retain lessons.
|
|
981
|
+
|
|
982
|
+
Discard implementation anchoring.
|
|
983
|
+
|
|
984
|
+
Re-derive the solution from:
|
|
985
|
+
|
|
986
|
+
* current issue
|
|
987
|
+
* current repository
|
|
988
|
+
* current standards
|
|
989
|
+
* accumulated failure knowledge
|
|
990
|
+
|
|
991
|
+
and execute it cleanly from the fresh default branch head.
|