@jesdi/skills 0.0.77 → 0.0.79
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.
- package/README.md +3 -2
- package/package.json +1 -1
- package/skills/implement-spec/ARCHITECTURE.md +102 -54
- package/skills/implement-spec/README.md +53 -51
- package/skills/implement-spec/SKILL.md +5 -6
- package/skills/implement-spec/driver.py +67 -153
- package/skills/implement-spec/driver_agents.py +75 -25
- package/skills/implement-spec/driver_decisions.py +92 -199
- package/skills/implement-spec/driver_dispute.py +189 -0
- package/skills/implement-spec/driver_final.py +196 -97
- package/skills/implement-spec/driver_fixloop.py +102 -192
- package/skills/implement-spec/driver_legacy.py +73 -5
- package/skills/implement-spec/driver_locked.py +186 -0
- package/skills/implement-spec/driver_merge.py +3 -48
- package/skills/implement-spec/driver_report.py +84 -64
- package/skills/implement-spec/driver_review.py +12 -119
- package/skills/implement-spec/driver_run.py +167 -130
- package/skills/implement-spec/driver_state.py +11 -9
- package/skills/implement-spec/models.json +0 -2
- package/skills/implement-spec/prompts/arbitration.md +34 -0
- package/skills/implement-spec/prompts/conflict.md +1 -0
- package/skills/implement-spec/prompts/correction.md +7 -4
- package/skills/implement-spec/prompts/elsewhere.md +6 -0
- package/skills/implement-spec/prompts/final-fixer.md +1 -1
- package/skills/implement-spec/prompts/final-lens.md +40 -0
- package/skills/implement-spec/prompts/final-reviewer.md +7 -7
- package/skills/implement-spec/prompts/fixer.md +2 -2
- package/skills/implement-spec/prompts/implementer.md +1 -1
- package/skills/implement-spec/prompts/lens-copy.md +1 -0
- package/skills/implement-spec/prompts/lens-correctness.md +8 -0
- package/skills/implement-spec/prompts/lens-spec.md +2 -0
- package/skills/implement-spec/prompts/lens-structure.md +2 -0
- package/skills/implement-spec/prompts/rebase-conflict.md +1 -0
- package/skills/implement-spec/prompts/rereview.md +0 -1
- package/skills/implement-spec/prompts/rerun.md +1 -1
- package/skills/implement-spec/prompts/reviewer.md +3 -6
- package/skills/implement-spec/prompts/ruled.md +3 -0
- package/skills/implement-spec/prompts/test-writer.md +4 -5
- package/skills/implement-spec/tests/test_agents.py +23 -22
- package/skills/implement-spec/tests/test_amendments.py +6 -48
- package/skills/implement-spec/tests/test_arbitration.py +314 -0
- package/skills/implement-spec/tests/test_cli.py +3 -3
- package/skills/implement-spec/tests/test_decisions.py +251 -374
- package/skills/implement-spec/tests/test_driver.py +22 -50
- package/skills/implement-spec/tests/test_final.py +45 -77
- package/skills/implement-spec/tests/test_fixloop.py +400 -633
- package/skills/implement-spec/tests/test_landing.py +23 -126
- package/skills/implement-spec/tests/test_lenses.py +217 -0
- package/skills/implement-spec/tests/test_merge.py +0 -43
- package/skills/implement-spec/tests/test_models.py +50 -1
- package/skills/implement-spec/tests/test_report.py +9 -23
- package/skills/implement-spec/tests/test_review.py +15 -153
- package/skills/implement-spec/tests/test_review_page.py +7 -3
- package/skills/implement-spec/tests/test_scoped.py +125 -0
- package/skills/implement-spec/tests/test_state.py +8 -3
- package/skills/implement-spec/tests/test_stops.py +43 -61
- package/skills/implement-spec/tests/test_tidy.py +77 -98
- package/skills/implement-spec/tests/test_walk.py +7 -6
- package/skills/review-page/SKILL.md +1 -1
- package/skills/test-prune/SKILL.md +7 -3
- package/skills/test-prune/prune_source.py +48 -0
- package/skills/test-prune/prune_strengthen.py +87 -2
- package/skills/test-prune/tests/test_prune_strengthen.py +93 -0
- package/skills/to-tickets/SKILL.md +1 -1
- package/skills-manifest.json +9 -9
- package/skills/implement-spec/prompts/corrected.md +0 -3
- package/skills/implement-spec/prompts/correctness.md +0 -42
- package/skills/implement-spec/prompts/final-scoped.md +0 -1
- package/skills/implement-spec/prompts/full-review.md +0 -2
- package/skills/implement-spec/prompts/overruled.md +0 -7
- package/skills/implement-spec/prompts/rejected.md +0 -1
- package/skills/implement-spec/prompts/restored-red.md +0 -3
- package/skills/implement-spec/prompts/restored.md +0 -3
- package/skills/implement-spec/prompts/stands.md +0 -2
|
@@ -24,31 +24,32 @@ from pathlib import Path
|
|
|
24
24
|
import driver_agents
|
|
25
25
|
import driver_answers
|
|
26
26
|
import driver_decisions
|
|
27
|
+
import driver_dispute
|
|
27
28
|
import driver_final
|
|
28
29
|
import driver_fixloop
|
|
29
30
|
import driver_gate
|
|
30
31
|
import driver_graph
|
|
31
32
|
import driver_legacy
|
|
33
|
+
import driver_locked
|
|
32
34
|
import driver_merge
|
|
33
|
-
import driver_review
|
|
34
35
|
import driver_review_page
|
|
36
|
+
import driver_run
|
|
35
37
|
import driver_slots
|
|
36
38
|
import driver_state
|
|
37
39
|
import driver_summary
|
|
38
40
|
import driver_tickets
|
|
39
41
|
from driver_names import Names
|
|
40
|
-
from driver_run import FINAL, OUT, Blocked, Halted, Run, during, ledger
|
|
42
|
+
from driver_run import FINAL, OUT, Blocked, Call, Halted, Run, during, ledger, retry_point
|
|
41
43
|
from driver_slots import git
|
|
42
44
|
from driver_tickets import Ticket
|
|
43
45
|
|
|
44
46
|
STATE = OUT / "state.json"
|
|
45
47
|
DECISIONS = OUT / "decisions.json"
|
|
46
48
|
PAGE = Path(".agent/implement-review.html")
|
|
47
|
-
ONLY = ("test-writer", "implementer", "reviewer"
|
|
49
|
+
ONLY = ("test-writer", "implementer", "reviewer") # `--only` is for tests
|
|
48
50
|
# The phase of a ticket while a role runs, and the phase it reaches when the role's report is accepted.
|
|
49
51
|
DURING = {"test-writer": "test-writer", "implementer": "implement"}
|
|
50
52
|
AFTER = {"test-writer": "implement", "implementer": "gate"}
|
|
51
|
-
MERGED_LOCKED = "merged-locked-file" # the question of a landing that changes a locked file of a merged ticket
|
|
52
53
|
|
|
53
54
|
|
|
54
55
|
# ---------------------------------------------------------------- one ticket: the roles
|
|
@@ -75,22 +76,12 @@ def _check_out_ticket(ticket: Ticket, slot_number: int, entry: dict, run: Run) -
|
|
|
75
76
|
return driver_slots.head(slot)
|
|
76
77
|
|
|
77
78
|
|
|
78
|
-
def
|
|
79
|
-
"""The
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def _blocked_report(number: str, run: Run) -> str:
|
|
85
|
-
"""The report of the last `locked-test` stop of the ticket: an implementer's or a fixer's."""
|
|
86
|
-
return _locked_test_stop(number, run).get("evidence", [str(OUT / number / "implementer-0.json")])[0]
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def _overruled(number: str, run: Run) -> list[str]:
|
|
90
|
-
"""The concerns of that report that the operator overruled: what an overrule correction names in
|
|
91
|
-
`not_addressed` (issue #134)."""
|
|
92
|
-
concerns = json.loads(Path(_blocked_report(number, run)).read_text())["concerns"]
|
|
93
|
-
return [concern for concern in concerns if concern.startswith(driver_decisions.CONTRADICTS)]
|
|
79
|
+
def _risk(ticket: Ticket) -> str:
|
|
80
|
+
"""The reviewer's line on the Risk line of the ticket: one more criterion to check."""
|
|
81
|
+
if not ticket.risk:
|
|
82
|
+
return "The ticket names no risk."
|
|
83
|
+
return (f"Check the Risk line of the ticket as one more criterion: {ticket.risk}. A risk that the diff does not "
|
|
84
|
+
"handle is an unmet criterion.")
|
|
94
85
|
|
|
95
86
|
|
|
96
87
|
def _prompt_values(ticket: Ticket, slot: str, run: Run) -> dict[str, str]:
|
|
@@ -99,8 +90,7 @@ def _prompt_values(ticket: Ticket, slot: str, run: Run) -> dict[str, str]:
|
|
|
99
90
|
return {"spec": os.path.relpath(run.args.spec, slot), "seam": ticket.seam, "pr_branch": run.pr,
|
|
100
91
|
"branch": run.names.ticket(ticket.number),
|
|
101
92
|
"ticket": os.path.relpath(Path(run.args.tickets) / ticket.file, slot),
|
|
102
|
-
"
|
|
103
|
-
"blocked_report": os.path.relpath(_blocked_report(ticket.number, run), slot),
|
|
93
|
+
"risk": _risk(ticket), "gate": run.args.fast_gate,
|
|
104
94
|
"writer_report": os.path.relpath(folder / "test-writer-0.json", slot)}
|
|
105
95
|
|
|
106
96
|
|
|
@@ -115,19 +105,19 @@ def _first_notes(number: str, slot_number: int, entry: dict, run: Run, roles: li
|
|
|
115
105
|
return []
|
|
116
106
|
|
|
117
107
|
|
|
118
|
-
def
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
return
|
|
108
|
+
def _run_role(run: Run, call: Call, entry: dict) -> tuple[str, dict]:
|
|
109
|
+
"""Run `call`. Returns (the phase of the ticket after it, the fields its report gives the ticket record). A
|
|
110
|
+
test-writer on a ticket that has locked tests is the correction of a `correct-test` answer: the phase after it is
|
|
111
|
+
the one its question resumes, the implementer or the review before the fixer of that round."""
|
|
112
|
+
questions = run.state.read()["run"]["questions"]
|
|
113
|
+
if call.role == "test-writer" and entry["test_writer_sha"] and (question := driver_dispute.correction(questions,
|
|
114
|
+
call.number)):
|
|
115
|
+
driver_dispute.correct_as_answered(run, call, question)
|
|
116
|
+
return question["resume"]["phase"], {}
|
|
117
|
+
report = driver_dispute.agent(run, call)
|
|
118
|
+
if call.role != "test-writer":
|
|
119
|
+
return AFTER.get(call.role, "review"), {}
|
|
120
|
+
return AFTER["test-writer"], driver_locked.written(entry, report["locked"], driver_slots.head(call.slot))
|
|
131
121
|
|
|
132
122
|
|
|
133
123
|
def _run_roles(ticket: Ticket, slot_number: int, run: Run) -> None:
|
|
@@ -143,25 +133,13 @@ def _run_roles(ticket: Ticket, slot_number: int, run: Run) -> None:
|
|
|
143
133
|
run.state.ticket(number, phase=DURING.get(role, "review"))
|
|
144
134
|
values.update(start_sha=start, gate_record=os.path.relpath(driver_gate.record_path(OUT / number, driver_gate.FAST, start),
|
|
145
135
|
slot))
|
|
146
|
-
check, notes = _role_check(role, number, slot, entry, run, values, notes)
|
|
147
136
|
with during(f"the {role}"):
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
_blocked_report(number, run))
|
|
155
|
-
raise
|
|
156
|
-
for item in report.get("not_addressed", []):
|
|
157
|
-
ledger(f"Ticket {number}: the test-writer correction did not correct {item['finding']}: {item['reason']}.")
|
|
158
|
-
facts = {"tip": driver_slots.head(slot)}
|
|
159
|
-
if role == "test-writer":
|
|
160
|
-
facts.update(driver_review.written(slot, entry, report["locked"], report.get("fixtures", []),
|
|
161
|
-
facts["tip"]))
|
|
162
|
-
values["locked"] = " ".join(facts["locked"])
|
|
163
|
-
run.state.ticket(number, phase=AFTER.get(role, "review"), note="", **facts)
|
|
164
|
-
start, notes = facts["tip"], []
|
|
137
|
+
phase, facts = _run_role(run, Call(role, number, slot, values, notes=notes), entry)
|
|
138
|
+
start, notes = driver_slots.head(slot), []
|
|
139
|
+
entry = run.state.ticket(number, phase=phase, note="", tip=start, **facts)
|
|
140
|
+
values["locked"] = " ".join(entry["locked"])
|
|
141
|
+
if phase != AFTER.get(role, "review"):
|
|
142
|
+
break # the fixer that disputed runs again after the review
|
|
165
143
|
|
|
166
144
|
|
|
167
145
|
# ---------------------------------------------------------------- one ticket: the landing on the PR branch
|
|
@@ -169,32 +147,17 @@ def _run_roles(ticket: Ticket, slot_number: int, run: Run) -> None:
|
|
|
169
147
|
@dataclass
|
|
170
148
|
class _Landing:
|
|
171
149
|
ticket_tip: str
|
|
172
|
-
pr_tip: str # the PR tip
|
|
150
|
+
pr_tip: str # the PR tip the merge was made on
|
|
173
151
|
commit: str # what the PR branch moves to: `pr_tip` (merged already), `ticket_tip` (fast-forward) or a merge
|
|
174
152
|
|
|
175
153
|
|
|
176
|
-
@dataclass
|
|
177
|
-
class _Rulings:
|
|
178
|
-
"""The answers to the `merged-locked-file` questions of the ticket, as its landing applies them."""
|
|
179
|
-
before: str # the ticket tip before the driver put a file back
|
|
180
|
-
paths: dict[str, str] # file -> `restore` or `adopt`
|
|
181
|
-
|
|
182
|
-
def adopted(self) -> list[str]:
|
|
183
|
-
return [path for path, answer in self.paths.items() if answer == "adopt"]
|
|
184
|
-
|
|
185
|
-
|
|
186
154
|
def _resolve_conflict(ticket: Ticket, slot: str, run: Run, tip: str, files: list[str]) -> str:
|
|
187
155
|
"""Run the conflict agent on the merge that is open in the slot. Returns the new ticket tip."""
|
|
188
156
|
number = ticket.number
|
|
189
157
|
values = {**_prompt_values(ticket, slot, run), "start_sha": tip, "pr_sha": run.tip(), "files": " ".join(files)}
|
|
190
158
|
try:
|
|
191
159
|
with during("the conflict agent"):
|
|
192
|
-
run.agent("conflict", number, slot, values)
|
|
193
|
-
# The resolution may not change a locked test of the ticket. Those of the merged tickets are checked
|
|
194
|
-
# when the resolved tip lands.
|
|
195
|
-
changed = driver_review.locked_changes(slot, tip, run.state.read()["tickets"][number]["locked"])
|
|
196
|
-
if changed:
|
|
197
|
-
raise Blocked("; ".join(finding["title"] for finding in changed))
|
|
160
|
+
run.agent(Call("conflict", number, slot, values))
|
|
198
161
|
except (Blocked, Halted):
|
|
199
162
|
driver_merge.abort(slot) # closes the merge when the agent did not commit it
|
|
200
163
|
raise
|
|
@@ -222,90 +185,60 @@ def _merge_commit(ticket: Ticket, slot: str, run: Run, tip: str, may_resolve: bo
|
|
|
222
185
|
return _Landing(tip, pr_tip, commit)
|
|
223
186
|
|
|
224
187
|
|
|
225
|
-
def
|
|
226
|
-
"""
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
question. A file that an `adopt` ruling names is the ticket's own."""
|
|
241
|
-
tickets = run.state.read()["tickets"]
|
|
242
|
-
entry = tickets[number]
|
|
243
|
-
own = {**tickets, number: {**entry, "locked": entry["locked"] + rulings.adopted()}}
|
|
244
|
-
changed, error = driver_merge.refused(own, number, landing.pr_tip, landing.commit)
|
|
245
|
-
if error:
|
|
188
|
+
def _red_landing(number: str, slot: str, run: Run, commit: str, record: str) -> None:
|
|
189
|
+
"""A red full gate on `commit`, the commit that would land: a finding of the fix loop, inside the cap."""
|
|
190
|
+
git(slot, "checkout", "-q", run.names.ticket(number)) # the fixer works on the ticket branch
|
|
191
|
+
driver_fixloop.red_landing(run, number, slot, commit, record)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def _refuse_breach(number: str, run: Run, landing: _Landing) -> None:
|
|
195
|
+
"""The commit that would land leaves every other ticket's locked file as the PR tip has it, but those the ticket
|
|
196
|
+
lists as its own (driver_locked.landing_errors). A change blocks the ticket with one `ticket-blocked` question: its
|
|
197
|
+
`retry` runs the implementer
|
|
198
|
+
again, whose locked-file check names the file until the ticket branch leaves it as the merge base has it."""
|
|
199
|
+
if errors := driver_locked.landing_errors(run.state.read()["tickets"], number, landing.pr_tip, landing.commit):
|
|
200
|
+
error = "; ".join(errors)
|
|
201
|
+
run.ask(number, "ticket-blocked", [f"the landing: {error}"], str(STATE),
|
|
202
|
+
retry_point("implementer", landing.ticket_tip, 0))
|
|
246
203
|
raise Blocked(error)
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
def _red_landing(number: str, slot: str, run: Run, rulings: _Rulings, commit: str, record: str) -> None:
|
|
254
|
-
"""A red full gate on `commit`, the commit that would land. After `restore` or `adopt` rulings, the restore
|
|
255
|
-
commit leaves the ticket branch, and each ruled file is asked again, without the option that was tried. Else it
|
|
256
|
-
is a finding of the fix loop, inside the cap."""
|
|
257
|
-
if not rulings.paths:
|
|
258
|
-
git(slot, "checkout", "-q", run.names.ticket(number)) # the fixer works on the ticket branch
|
|
259
|
-
driver_fixloop.red_landing(run, number, slot, commit, record)
|
|
260
|
-
if run.state.read()["tickets"][number]["tip"] != rulings.before:
|
|
261
|
-
driver_review.restore(slot, run.names.ticket(number), rulings.before)
|
|
262
|
-
run.state.ticket(number, tip=rulings.before)
|
|
263
|
-
ledger(f"Ticket {number}: the merge gate is red after the restore, so the driver took the restore commit "
|
|
264
|
-
f"back: the ticket tip is {rulings.before[:7]} again.")
|
|
265
|
-
run.ask(number, MERGED_LOCKED, list(rulings.paths), record)
|
|
266
|
-
raise Blocked(f"the full gate is red on {commit[:7]}, record {record}")
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
def _checked_landing(ticket: Ticket, slot: str, run: Run, may_resolve: bool, rulings: _Rulings) -> _Landing:
|
|
270
|
-
"""The commit to land, with the locked-file check passed and the full gate green. Call it under the merge lock."""
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def _checked_landing(ticket: Ticket, slot: str, run: Run, may_resolve: bool) -> _Landing:
|
|
207
|
+
"""The commit to land, with the full gate green. Call it under the merge lock."""
|
|
271
208
|
number = ticket.number
|
|
272
209
|
# An earlier try left the slot on its merge commit.
|
|
273
210
|
git(slot, "checkout", "-q", run.names.ticket(number))
|
|
274
211
|
tip = run.state.ticket(number, phase="merge")["tip"]
|
|
275
212
|
landing = _merge_commit(ticket, slot, run, tip, may_resolve)
|
|
276
|
-
|
|
213
|
+
_refuse_breach(number, run, landing)
|
|
277
214
|
if landing.commit != landing.pr_tip:
|
|
278
215
|
# The full gate runs on the commit that lands, a fast-forward as well as a merge commit: a fast green record
|
|
279
216
|
# does not count. When the checkout fails, the slot is on another commit and the gate refuses to run.
|
|
280
217
|
git(slot, "checkout", "-q", "--detach", landing.commit)
|
|
281
218
|
if record := run.red_gate(number, slot, landing.commit, driver_gate.FULL):
|
|
282
|
-
_red_landing(number, slot, run,
|
|
219
|
+
_red_landing(number, slot, run, landing.commit, record)
|
|
283
220
|
return landing
|
|
284
221
|
|
|
285
222
|
|
|
286
|
-
def _land(ticket: Ticket, slot: str, run: Run) ->
|
|
223
|
+
def _land(ticket: Ticket, slot: str, run: Run) -> _Landing:
|
|
287
224
|
"""Move the PR branch to the checked commit. Call it under the merge lock."""
|
|
288
|
-
|
|
289
|
-
landing = _checked_landing(ticket, slot, run, True, rulings)
|
|
225
|
+
landing = _checked_landing(ticket, slot, run, True)
|
|
290
226
|
# git moves the ref only from the tip that the check read, so the check and the move are one step.
|
|
291
227
|
error = driver_merge.land(run.pr, landing.commit, landing.pr_tip)
|
|
292
228
|
if error and run.tip() != landing.pr_tip:
|
|
293
229
|
# Another hand moved the PR branch in between: start again from the new tip, one time, with no conflict agent.
|
|
294
|
-
landing = _checked_landing(ticket, slot, run, False
|
|
230
|
+
landing = _checked_landing(ticket, slot, run, False)
|
|
295
231
|
error = driver_merge.land(run.pr, landing.commit, landing.pr_tip)
|
|
296
232
|
if error:
|
|
297
233
|
raise Blocked(error)
|
|
298
|
-
return landing
|
|
234
|
+
return landing
|
|
299
235
|
|
|
300
236
|
|
|
301
|
-
def _record_landing(state: dict, number: str, landing: _Landing
|
|
237
|
+
def _record_landing(state: dict, number: str, landing: _Landing) -> None:
|
|
302
238
|
"""The ticket is merged, and `landing.commit` is the PR tip its merge made: a later merge of the ticket replaces
|
|
303
|
-
it.
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
new = [path for path in adopted if path not in entry["locked"]]
|
|
307
|
-
entry["locked"] += new
|
|
308
|
-
entry["held"].update(dict.fromkeys(new, landing.ticket_tip))
|
|
239
|
+
it."""
|
|
240
|
+
pr_tip = landing.commit
|
|
241
|
+
state["tickets"][number]["phase"] = "merged"
|
|
309
242
|
earlier = [landed for landed in state["run"]["landed"] if landed[0] != number]
|
|
310
243
|
state["run"]["landed"] = earlier + [[number, pr_tip]]
|
|
311
244
|
|
|
@@ -315,12 +248,9 @@ def _merge(ticket: Ticket, slot: str, run: Run) -> None:
|
|
|
315
248
|
number, branch = ticket.number, run.names.ticket(ticket.number)
|
|
316
249
|
# The merge gate and the conflict agent run under the lock: the commit the gate saw is the one that lands.
|
|
317
250
|
with run.merging, during("the merge"):
|
|
318
|
-
landing
|
|
319
|
-
run.state.update(lambda state: _record_landing(state, number, landing
|
|
251
|
+
landing = _land(ticket, slot, run)
|
|
252
|
+
run.state.update(lambda state: _record_landing(state, number, landing))
|
|
320
253
|
_drop_merged(run.state)
|
|
321
|
-
for path in rulings.adopted():
|
|
322
|
-
ledger(f"Ticket {number}: by the ruling (adopt), the ticket locks {path}, so its change to that locked file of "
|
|
323
|
-
"a merged ticket landed.")
|
|
324
254
|
driver_slots.release(slot) # git deletes no branch that a worktree has checked out
|
|
325
255
|
kept = "" if driver_merge.delete(branch, run.pr) else f"; {branch} is kept"
|
|
326
256
|
if landing.commit == landing.pr_tip:
|
|
@@ -334,22 +264,6 @@ def _merge(ticket: Ticket, slot: str, run: Run) -> None:
|
|
|
334
264
|
|
|
335
265
|
# ---------------------------------------------------------------- one ticket, and the walk of the graph
|
|
336
266
|
|
|
337
|
-
def _block(number: str, run: Run, ledger_line: int) -> None:
|
|
338
|
-
"""Block the ticket and add the questions it asked for, in one write of state.json."""
|
|
339
|
-
ask = run.asks.pop(number, None)
|
|
340
|
-
|
|
341
|
-
def change(state: dict) -> None:
|
|
342
|
-
state["tickets"][number]["phase"] = "blocked"
|
|
343
|
-
if ask:
|
|
344
|
-
state["tickets"][number].update(ask.fields)
|
|
345
|
-
evidence = [ask.report, f"{OUT / 'ledger.md'}:{ledger_line}"]
|
|
346
|
-
driver_decisions.stop(state["run"], ask.kind, number, ask.subjects, evidence)
|
|
347
|
-
|
|
348
|
-
run.state.update(change)
|
|
349
|
-
if ask and ask.subjects:
|
|
350
|
-
ledger(f"Ticket {number}: {driver_decisions.decides(ask.kind, len(ask.subjects))} in {DECISIONS}.")
|
|
351
|
-
|
|
352
|
-
|
|
353
267
|
def _drop_merged(state: driver_state.State) -> None:
|
|
354
268
|
"""Drop the open questions of each merged ticket: a stopped ticket that the operator set to `merge` has them."""
|
|
355
269
|
dropped: list[dict] = []
|
|
@@ -380,7 +294,7 @@ def _run_ticket(ticket: Ticket, slot_number: int, run: Run) -> bool:
|
|
|
380
294
|
except driver_fixloop.Unlanded:
|
|
381
295
|
pass # the merge lock is released and the next fix round has started: its fixer runs now
|
|
382
296
|
except Blocked as blocked:
|
|
383
|
-
|
|
297
|
+
run.block(number, ledger(f"Ticket {number}: BLOCKED at {blocked}."))
|
|
384
298
|
print(f"{ticket.file}: BLOCKED at {blocked}")
|
|
385
299
|
except Halted as halted:
|
|
386
300
|
_halt(run, f"Ticket {number}", str(halted))
|
|
@@ -527,7 +441,7 @@ def _apply_answers(state: driver_state.State, args) -> list[str]:
|
|
|
527
441
|
def change(new: dict) -> None:
|
|
528
442
|
new["run"]["questions"] = questions
|
|
529
443
|
for number, fields in moved.items():
|
|
530
|
-
new
|
|
444
|
+
driver_run.record_of(new, number).update(fields)
|
|
531
445
|
|
|
532
446
|
state.update(change)
|
|
533
447
|
error = _publish_questions(run)
|
|
@@ -688,7 +602,7 @@ def _validated(args: argparse.Namespace) -> tuple[list[Ticket], dict[str, list[s
|
|
|
688
602
|
errors += _worktree_errors(1 in kept.values())
|
|
689
603
|
models, model_errors = driver_agents.load_models(args.models)
|
|
690
604
|
tickets, ticket_errors = driver_tickets.parse(args.tickets)
|
|
691
|
-
errors += model_errors + ticket_errors
|
|
605
|
+
errors += model_errors + ticket_errors
|
|
692
606
|
errors += driver_final.precondition_errors(args.push or args.unattended, args.base)
|
|
693
607
|
for error in errors:
|
|
694
608
|
print(error)
|
|
@@ -15,15 +15,35 @@ import tempfile
|
|
|
15
15
|
import threading
|
|
16
16
|
import time
|
|
17
17
|
from concurrent.futures import ThreadPoolExecutor
|
|
18
|
+
from dataclasses import dataclass
|
|
18
19
|
from pathlib import Path
|
|
19
20
|
|
|
20
21
|
SKILL = Path(__file__).resolve().parent
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class Lens:
|
|
26
|
+
"""A lens of the full final review: a role with no model list, on an entry of the `final-reviewer` list. Its lines
|
|
27
|
+
of the prompt are `prompts/lens-<source>.md`."""
|
|
28
|
+
source: str # the `source` of its findings, and its name in the prompt
|
|
29
|
+
skill: str # the skill that holds its method
|
|
30
|
+
method: str # the file of that skill it follows
|
|
31
|
+
inline: bool # its lines hold the method text, not its path
|
|
32
|
+
other_provider: bool # it runs on another provider than the implementer's first entry
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# In the order a tie of the merge keeps.
|
|
36
|
+
LENSES = {
|
|
37
|
+
"final-spec": Lens("spec", "review-diff", "spec.md", False, False),
|
|
38
|
+
# Inlined: this lens reads from git, and a project-local review-diff sits in an ignored folder (#120).
|
|
39
|
+
"final-correctness": Lens("correctness", "review-diff", "correctness.md", True, True),
|
|
40
|
+
"final-structure": Lens("structure", "deep-quality-review", "SKILL.md", False, False)}
|
|
21
41
|
# Minutes per role.
|
|
22
|
-
TIMEOUTS = {"
|
|
23
|
-
|
|
42
|
+
TIMEOUTS = {"test-writer": 30, "implementer": 90, "reviewer": 45, "fixer": 60, "final-reviewer": 60,
|
|
43
|
+
**dict.fromkeys(LENSES, 60), "conflict": 30, "pr-writer": 20}
|
|
24
44
|
PROVIDERS = {"anthropic": ("claude", ("low", "medium", "high", "xhigh", "max")),
|
|
25
45
|
"openai": ("codex", ("minimal", "low", "medium", "high", "xhigh"))}
|
|
26
|
-
READ_ONLY = ("reviewer", "
|
|
46
|
+
READ_ONLY = ("reviewer", "final-reviewer", *LENSES, "pr-writer")
|
|
27
47
|
PREFLIGHT = "implement-spec preflight: reply with the word OK. Read no file and run no command.\n"
|
|
28
48
|
# The time limit of one preflight call: a CLI that gives no answer in this time fails the preflight.
|
|
29
49
|
PREFLIGHT_MINUTES = 5
|
|
@@ -51,37 +71,67 @@ def _entry_error(role: str, entry: str, first: bool) -> str | None:
|
|
|
51
71
|
return None
|
|
52
72
|
|
|
53
73
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
74
|
+
# Roles of older drivers: a --models file that still names one is told to delete the key.
|
|
75
|
+
REMOVED = ("correctness", "explorer")
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _role_errors(given: dict, known: dict) -> list[str]:
|
|
79
|
+
"""One error per role of the --models file that the skill's models.json does not define."""
|
|
80
|
+
return [f"{role}: the role was removed; delete its key from the --models file" if role in REMOVED else
|
|
81
|
+
f"{role}: unknown role (known: {', '.join(known)})" for role in given if role not in known]
|
|
58
82
|
|
|
59
83
|
|
|
60
84
|
def load_models(path: str | None) -> tuple[dict[str, list[str]], list[str]]:
|
|
61
|
-
"""The skill's default lists with the roles of `path` on top, and every entry error."""
|
|
62
|
-
|
|
85
|
+
"""The skill's default lists with the roles of `path` on top, and every role and entry error."""
|
|
86
|
+
defaults = json.loads((SKILL / "models.json").read_text())
|
|
63
87
|
try:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
found.append("implementer: a second implementer model entry is required for fix round 2")
|
|
70
|
-
if not first["correctness"]:
|
|
71
|
-
found.append(f"correctness: no entry of its list ({', '.join(models['correctness'])}) is on another "
|
|
72
|
-
f"provider than the implementer's first entry {models['implementer'][0]}; the correctness "
|
|
73
|
-
"pass never runs on the implementer's provider")
|
|
88
|
+
given = json.loads(Path(path).read_text()) if path else {}
|
|
89
|
+
models = {**defaults, **given} # a list is a TypeError
|
|
90
|
+
if unknown := _role_errors(given, defaults):
|
|
91
|
+
return {}, unknown
|
|
92
|
+
return models, _entry_errors(models)
|
|
74
93
|
except (OSError, ValueError, AttributeError, LookupError, TypeError) as exc:
|
|
75
94
|
return {}, [f"--models {path}: {exc!r}"]
|
|
76
|
-
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def other_provider_entries(models: dict[str, list[str]]) -> list[str]:
|
|
98
|
+
"""The entries of the `final-reviewer` list on another provider than the implementer's first entry: the correctness
|
|
99
|
+
lens and the scoped review run and rerun only on these."""
|
|
100
|
+
own = split(models["implementer"][0])[0]
|
|
101
|
+
return [entry for entry in models["final-reviewer"] if split(entry)[0] != own]
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def other_provider_entry(models: dict[str, list[str]]) -> str:
|
|
105
|
+
"""The other-provider entry of the `final-reviewer` list, its first one; "" when there is none."""
|
|
106
|
+
return next(iter(other_provider_entries(models)), "")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def lens_entries(models: dict[str, list[str]], role: str) -> list[str]:
|
|
110
|
+
"""The entries a lens of the final review runs on, the first one first, its rerun on the next one."""
|
|
111
|
+
return other_provider_entries(models) if LENSES[role].other_provider else models["final-reviewer"]
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _entry_errors(models: dict[str, list[str]]) -> list[str]:
|
|
115
|
+
"""Every entry error of the merged lists."""
|
|
116
|
+
# The entries whose CLI must be on PATH; entries[0]: an empty list is an error.
|
|
117
|
+
first = {(role, entries[0]) for role, entries in models.items()} | {
|
|
118
|
+
("final-reviewer", other_provider_entry(models))}
|
|
119
|
+
found = [_entry_error(role, entry, (role, entry) in first) for role, entries in models.items() for entry in entries]
|
|
120
|
+
if len(models["implementer"]) < 2:
|
|
121
|
+
found.append("implementer: a second implementer model entry is required for fix round 2")
|
|
122
|
+
if not other_provider_entry(models):
|
|
123
|
+
found.append(f"final-reviewer: no entry of its list ({', '.join(models['final-reviewer'])}) is on another "
|
|
124
|
+
f"provider than the implementer's first entry {models['implementer'][0]}; its other-provider "
|
|
125
|
+
"entry serves the correctness lens of the final review and the scoped review, which never run on "
|
|
126
|
+
"the implementer's provider")
|
|
127
|
+
return [error for error in found if error]
|
|
77
128
|
|
|
78
129
|
|
|
79
130
|
def used_entries(models: dict[str, list[str]]) -> list[str]:
|
|
80
|
-
"""Each entry the driver can start an agent on: the first of each role
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return sorted(set(entries))
|
|
131
|
+
"""Each entry the driver can start an agent on: the first of each role, the other-provider entry and the second
|
|
132
|
+
implementer entry (fix round 2)."""
|
|
133
|
+
firsts = (entries[0] for entries in models.values())
|
|
134
|
+
return sorted({*firsts, other_provider_entry(models), *models["implementer"][1:2]})
|
|
85
135
|
|
|
86
136
|
|
|
87
137
|
def preflight(models: dict[str, list[str]]) -> list[str]:
|