@jesdi/skills 0.0.76 → 0.0.78

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.
Files changed (75) hide show
  1. package/README.md +5 -0
  2. package/package.json +2 -1
  3. package/skills/implement-spec/ARCHITECTURE.md +102 -54
  4. package/skills/implement-spec/README.md +53 -51
  5. package/skills/implement-spec/SKILL.md +5 -6
  6. package/skills/implement-spec/driver.py +67 -153
  7. package/skills/implement-spec/driver_agents.py +75 -25
  8. package/skills/implement-spec/driver_decisions.py +92 -199
  9. package/skills/implement-spec/driver_dispute.py +189 -0
  10. package/skills/implement-spec/driver_final.py +196 -97
  11. package/skills/implement-spec/driver_fixloop.py +102 -192
  12. package/skills/implement-spec/driver_legacy.py +73 -5
  13. package/skills/implement-spec/driver_locked.py +186 -0
  14. package/skills/implement-spec/driver_merge.py +3 -48
  15. package/skills/implement-spec/driver_report.py +84 -64
  16. package/skills/implement-spec/driver_review.py +12 -119
  17. package/skills/implement-spec/driver_run.py +167 -130
  18. package/skills/implement-spec/driver_state.py +11 -9
  19. package/skills/implement-spec/models.json +0 -2
  20. package/skills/implement-spec/prompts/arbitration.md +34 -0
  21. package/skills/implement-spec/prompts/conflict.md +1 -0
  22. package/skills/implement-spec/prompts/correction.md +7 -4
  23. package/skills/implement-spec/prompts/elsewhere.md +6 -0
  24. package/skills/implement-spec/prompts/final-fixer.md +1 -1
  25. package/skills/implement-spec/prompts/final-lens.md +40 -0
  26. package/skills/implement-spec/prompts/final-reviewer.md +7 -7
  27. package/skills/implement-spec/prompts/fixer.md +2 -2
  28. package/skills/implement-spec/prompts/implementer.md +1 -1
  29. package/skills/implement-spec/prompts/lens-copy.md +1 -0
  30. package/skills/implement-spec/prompts/lens-correctness.md +8 -0
  31. package/skills/implement-spec/prompts/lens-spec.md +2 -0
  32. package/skills/implement-spec/prompts/lens-structure.md +2 -0
  33. package/skills/implement-spec/prompts/rebase-conflict.md +1 -0
  34. package/skills/implement-spec/prompts/rereview.md +0 -1
  35. package/skills/implement-spec/prompts/rerun.md +1 -1
  36. package/skills/implement-spec/prompts/reviewer.md +3 -6
  37. package/skills/implement-spec/prompts/ruled.md +3 -0
  38. package/skills/implement-spec/prompts/test-writer.md +4 -5
  39. package/skills/implement-spec/tests/test_agents.py +23 -22
  40. package/skills/implement-spec/tests/test_amendments.py +6 -48
  41. package/skills/implement-spec/tests/test_arbitration.py +314 -0
  42. package/skills/implement-spec/tests/test_cli.py +3 -3
  43. package/skills/implement-spec/tests/test_decisions.py +251 -374
  44. package/skills/implement-spec/tests/test_driver.py +22 -50
  45. package/skills/implement-spec/tests/test_final.py +45 -77
  46. package/skills/implement-spec/tests/test_fixloop.py +400 -633
  47. package/skills/implement-spec/tests/test_landing.py +23 -126
  48. package/skills/implement-spec/tests/test_lenses.py +217 -0
  49. package/skills/implement-spec/tests/test_merge.py +0 -43
  50. package/skills/implement-spec/tests/test_models.py +50 -1
  51. package/skills/implement-spec/tests/test_report.py +9 -23
  52. package/skills/implement-spec/tests/test_review.py +15 -153
  53. package/skills/implement-spec/tests/test_review_page.py +7 -3
  54. package/skills/implement-spec/tests/test_scoped.py +125 -0
  55. package/skills/implement-spec/tests/test_state.py +8 -3
  56. package/skills/implement-spec/tests/test_stops.py +43 -61
  57. package/skills/implement-spec/tests/test_tidy.py +77 -98
  58. package/skills/implement-spec/tests/test_walk.py +7 -6
  59. package/skills/review-page/SKILL.md +1 -1
  60. package/skills/test-prune/SKILL.md +10 -4
  61. package/skills/test-prune/prune.py +5 -4
  62. package/skills/test-prune/prune_repo.py +5 -0
  63. package/skills/test-prune/prune_strengthen.py +36 -5
  64. package/skills/test-prune/tests/test_prune_strengthen.py +144 -0
  65. package/skills/to-tickets/SKILL.md +1 -1
  66. package/skills-manifest.json +9 -9
  67. package/skills/implement-spec/prompts/corrected.md +0 -3
  68. package/skills/implement-spec/prompts/correctness.md +0 -42
  69. package/skills/implement-spec/prompts/final-scoped.md +0 -1
  70. package/skills/implement-spec/prompts/full-review.md +0 -2
  71. package/skills/implement-spec/prompts/overruled.md +0 -7
  72. package/skills/implement-spec/prompts/rejected.md +0 -1
  73. package/skills/implement-spec/prompts/restored-red.md +0 -3
  74. package/skills/implement-spec/prompts/restored.md +0 -3
  75. package/skills/implement-spec/prompts/stands.md +0 -2
@@ -0,0 +1,314 @@
1
+ """A disputed locked test: the reviewer's arbitration, one correction, and the `spec-ambiguous` question (spec
2
+ requirements 3 to 6). In process, on the rig of test_fixloop, so coverage sees the driver."""
3
+ import json
4
+ import re
5
+
6
+ import pytest
7
+
8
+ from test_cli import ticket
9
+ from test_fixloop import Inside, inside # noqa: F401 (the autouse fixture puts the rig's CLIs on PATH)
10
+ from test_review import ONE, STUCK, finding, fix, review
11
+ from test_walk import COST, impl, plan, tw
12
+
13
+ TEST = "tests/test_01.py::test_x"
14
+ SINGLE = "the spec quotes with '"
15
+ CORRECTED = "def test_x():\n assert '01' == '01'\n"
16
+ AMBIGUOUS = "01-spec-ambiguous-1"
17
+ OTHER = "tests/test_01b.py"
18
+ SECOND = {"02-quote-fields.md": ticket("02", "Quote fields", touches="`demo/other.py: g`")}
19
+
20
+
21
+ def disputes(*concerns, role="implementer"):
22
+ """A BLOCKED report of `role` that disputes each concern, `(<test>, <reason>)`."""
23
+ report = {"status": "BLOCKED", "commits": [], "files": [], "green": [],
24
+ "concerns": [f"locked test contradicts spec: {test}: {reason}" for test, reason in concerns or
25
+ [(TEST, SINGLE)]]}
26
+ return {"report": {**report, **({"ticket": "01"} if role == "fixer" else {})}}
27
+
28
+
29
+ def ruling(verdict, reason, test=TEST, requirement="R3"):
30
+ """An arbitration report with one ruling."""
31
+ return {"report": {"status": "DONE", "files": [], "concerns": [],
32
+ "rulings": [{"test": test, "requirement": requirement, "ruling": verdict, "reason": reason}]}}
33
+
34
+
35
+ def correction(text=CORRECTED, path="tests/test_01.py"):
36
+ step = tw("01")
37
+ step["files"] = {path: text}
38
+ step["report"] = {**step["report"], "files": [path], "locked": [path]}
39
+ return {**step, "commit": "test: 01 corrected"}
40
+
41
+
42
+ def arbitrations(rig):
43
+ return [call for call in rig.calls("01", "reviewer") if call["prompt"].startswith("# Arbitration")]
44
+
45
+
46
+ def roles(rig):
47
+ """The roles of ticket 01 in order, an arbitration as `arbitration`."""
48
+ return ["arbitration" if call["prompt"].startswith("# Arbitration") else call["role"] for call in rig.calls("01")]
49
+
50
+
51
+ def asked(rig):
52
+ return [q for q in rig.state()["run"]["questions"] if q["answer"] is None]
53
+
54
+
55
+ def run(tmp_path, steps, files=ONE, **models):
56
+ return Inside(tmp_path, files, models=models or None).run(plan(**steps))
57
+
58
+
59
+ # ---------------------------------------------------------------- the ruling
60
+
61
+ def test_a_test_ruled_wrong_gets_one_correction_with_the_ruling_then_the_implementer_runs_again(tmp_path):
62
+ rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")], "01/test-writer": [tw("01"), correction()],
63
+ "01/reviewer": [ruling("test-wrong", "R3 says single quotes"), review("01")]})
64
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
65
+ assert roles(rig) == ["test-writer", "implementer", "arbitration", "test-writer", "implementer", "reviewer"]
66
+ assert not rig.state()["run"]["questions"] and rig.state()["tickets"]["01"]["round"] == 0
67
+ (arbitration,) = arbitrations(rig)
68
+ assert f"- {TEST}: {SINGLE}" in arbitration["prompt"]
69
+ assert ".agent/implement/01/implementer-0.json" in arbitration["prompt"]
70
+ (ruled,) = json.loads((rig.folder() / "ruled-1.json").read_text())
71
+ assert (ruled["file"], ruled["kind"], ruled["evidence"]) == ("tests/test_01.py", "ruling", "R3 says single quotes")
72
+ fixed, again = rig.calls("01", "test-writer")[1], rig.calls("01", "implementer")[1]
73
+ assert ".agent/implement/01/ruled-1.json" in fixed["prompt"] and again["head"] == fixed["sha"]
74
+ assert "R3 says single quotes" in again["prompt"]
75
+ entry = rig.state()["tickets"]["01"]
76
+ assert entry["disputes"]["tests/test_01.py"]["ruling"] == "test-wrong" and entry["test_writer_sha"] == fixed["sha"]
77
+ assert entry["corrected"] == {"tests/test_01.py": {"test": TEST, "requirement": "R3",
78
+ "reason": "R3 says single quotes"}}
79
+ assert rig.led("the reviewer ruled test-wrong on the locked test tests/test_01.py::test_x, R3")
80
+
81
+
82
+ def test_a_test_ruled_right_sends_the_implementer_back_with_the_ruling_and_no_correction(tmp_path):
83
+ rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")],
84
+ "01/reviewer": [ruling("code-wrong", "R3 says double quotes"), review("01")]})
85
+ assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
86
+ assert roles(rig) == ["test-writer", "implementer", "arbitration", "implementer", "reviewer"]
87
+ assert "R3 says double quotes" in rig.calls("01", "implementer")[1]["prompt"]
88
+ assert rig.state()["tickets"]["01"]["corrected"] == {}
89
+
90
+
91
+ def test_a_fixer_of_round_2_that_disputes_runs_again_in_round_2_after_the_correction(tmp_path):
92
+ stuck = review("01", [STUCK])
93
+ rig = run(tmp_path, {"01/reviewer": [stuck, stuck, ruling("test-wrong", "R3 says single quotes"), review("01")],
94
+ "01/fixer": [fix("01", 1), disputes(role="fixer"), fix("01", 2)],
95
+ "01/test-writer": [tw("01"), correction()]})
96
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
97
+ assert roles(rig) == ["test-writer", "implementer", "reviewer", "fixer", "reviewer", "fixer", "arbitration",
98
+ "test-writer", "fixer", "reviewer"]
99
+ assert rig.state()["tickets"]["01"]["round"] == 2 and not rig.led("round 3")
100
+ assert rig.calls("01", "fixer")[2]["head"] == rig.calls("01", "test-writer")[1]["sha"]
101
+ assert "fixer-2.json" in rig.calls("01", "fixer")[2]["prompt"]
102
+ assert [agent["entry"] for agent in rig.state()["run"]["agents"] if agent["role"] == "fixer"][1:] == [
103
+ "openai/gpt-sol@medium"] * 2
104
+ # No review saw the correction, so the review after the fix is a full one.
105
+ assert "re-review" not in rig.prompt("reviewer-2")
106
+
107
+
108
+ def test_a_dispute_on_another_locked_file_is_arbitrated_too(tmp_path):
109
+ two = tw("01")
110
+ two["files"][OTHER] = "def test_y():\n assert 1 == 'y'\n"
111
+ two["report"] = {**two["report"], "locked": ["tests/test_01.py", OTHER], "files": ["tests/test_01.py", OTHER]}
112
+ rig = run(tmp_path, {"01/test-writer": [two],
113
+ "01/implementer": [disputes(), disputes((f"{OTHER}::test_y", "y is not a column")),
114
+ impl("01")],
115
+ "01/reviewer": [ruling("code-wrong", "R3 says double quotes"),
116
+ ruling("code-wrong", "R4 says y is a column", f"{OTHER}::test_y", "R4"),
117
+ review("01")]})
118
+ assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
119
+ assert len(arbitrations(rig)) == 2 and set(rig.state()["tickets"]["01"]["disputes"]) == {"tests/test_01.py", OTHER}
120
+ assert (rig.folder() / "arbitration-2.json").exists()
121
+
122
+
123
+ def test_a_dispute_that_names_no_locked_file_is_rejected_and_runs_again_on_the_second_entry(tmp_path):
124
+ rig = run(tmp_path, {"01/implementer": [disputes(("tests/test_99.py::test_z", "z")), impl("01")]})
125
+ assert rig.code == 0 and not arbitrations(rig), rig.ledger()
126
+ first, second = rig.led("Ticket 01: implementer ran on")
127
+ assert "the dispute of tests/test_99.py::test_z names no locked file of the ticket" in first
128
+ assert second.endswith("report accepted.") and "names no locked file" in rig.calls("01", "implementer")[1]["prompt"]
129
+ assert [agent["entry"] for agent in rig.state()["run"]["agents"] if agent["role"] == "implementer"] == [
130
+ "anthropic/claude-opus-5@medium", "openai/gpt-sol@medium"]
131
+
132
+
133
+ def test_a_dispute_with_uncommitted_work_is_rejected(tmp_path):
134
+ dirty = {**disputes(), "files": {"demo/export.py": "half = 1\n"}}
135
+ rig = run(tmp_path, {"01/implementer": [dirty, impl("01")]})
136
+ assert rig.code == 0 and not arbitrations(rig), rig.ledger()
137
+ assert "a dispute leaves no uncommitted change" in rig.led("Ticket 01: implementer ran on")[0]
138
+
139
+
140
+ def test_the_summary_keeps_its_table_and_counts_an_arbitration_as_a_reviewer_agent(tmp_path):
141
+ """Ticket 01: a dispute, its arbitration, a fix round, then the landing; ticket 02 stops twice, so the end of
142
+ run, and its full gate, wait."""
143
+ stuck = {"report": {"status": "BLOCKED", "commits": [], "files": [], "concerns": ["no column order"], "green": []}}
144
+ rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")], "02/implementer": [stuck, stuck],
145
+ "01/reviewer": [ruling("code-wrong", "R3 says double quotes"), review("01", [STUCK]),
146
+ review("01")],
147
+ "01/fixer": [fix("01", 1)]}, files={**ONE, **SECOND})
148
+ assert rig.code == 2, rig.ledger()
149
+ rows = (rig.repo / ".agent/implement/summary.md").read_text().split("| Measure | Value |\n|---|---|\n")[1]
150
+ names = re.findall(r"^\| (.+?) \|", rows, re.M)
151
+ assert {f"wall time, {role}" for role in ("test-writer", "implementer", "reviewer", "fixer")} < set(names), rows
152
+ assert names[-3:] == ["fix rounds per ticket", "human stops", "cost"] and rows.endswith(" USD |\n"), rows
153
+ for row in ("| fast gates run | 2 |", "| full gates run | 1 |", "| agents, reviewer on anthropic/claude-opus-5@medium | 3 |",
154
+ "| fix rounds per ticket | 01: 1, 02: 0 |", "| human stops | 1 |"):
155
+ assert row in rows, rows
156
+
157
+
158
+ # ---------------------------------------------------------------- a second dispute or correction: spec-ambiguous
159
+
160
+ def ambiguous(tmp_path, second=TEST, then=()):
161
+ """Ticket 01 after a `code-wrong` ruling and a second dispute on `second`."""
162
+ rig = run(tmp_path, {"01/implementer": [disputes(), disputes((second, "the example in R3 uses '")), *then],
163
+ "01/reviewer": [ruling("code-wrong", "R3 says double quotes"), review("01")]})
164
+ return rig
165
+
166
+
167
+ @pytest.mark.parametrize("second", [TEST, "test_01.py::test_x[single]"])
168
+ def test_a_second_dispute_on_the_same_test_asks_spec_ambiguous_with_both_readings(tmp_path, second):
169
+ rig = ambiguous(tmp_path, second)
170
+ assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
171
+ assert len(arbitrations(rig)) == 1, "no second arbitration"
172
+ (question,) = asked(rig)
173
+ assert question["id"] == AMBIGUOUS and question["recommended"] == ""
174
+ assert [option["id"] for option in question["options"]] == ["keep-test", "correct-test", "edit-spec"]
175
+ for part in (second, "R3", "R3 says double quotes", "the example in R3 uses '"):
176
+ assert part in question["subject"], part
177
+ page = (rig.repo / ".agent/implement-review.html").read_text()
178
+ (block,) = re.findall(rf'data-q="{AMBIGUOUS}">(.*?)</textarea>', page, re.S)
179
+ assert "chip rec" not in block, "no option is recommended"
180
+
181
+
182
+ def test_after_a_correction_a_review_finding_on_the_test_asks_spec_ambiguous(tmp_path):
183
+ stale = finding("STALE", kind="fixture", file="tests/test_01.py")
184
+ rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")], "01/test-writer": [tw("01"), correction()],
185
+ "01/reviewer": [ruling("test-wrong", "R3 says single quotes"), review("01", [stale])]})
186
+ assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
187
+ (question,) = asked(rig)
188
+ assert question["id"] == AMBIGUOUS and "R3 says single quotes" in question["subject"]
189
+ assert "STALE" in question["subject"] and TEST in question["subject"]
190
+
191
+
192
+ def test_a_test_ruled_wrong_that_a_review_corrected_before_asks_spec_ambiguous(tmp_path):
193
+ stale = finding("STALE", kind="fixture", file="tests/test_01.py")
194
+ rig = run(tmp_path, {"01/test-writer": [tw("01"), correction()],
195
+ "01/reviewer": [review("01", [stale, STUCK]), ruling("test-wrong", "R3 says single quotes")],
196
+ "01/fixer": [disputes(role="fixer")]})
197
+ assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
198
+ (question,) = asked(rig)
199
+ assert "STALE" in question["subject"] and "R3 says single quotes" in question["subject"]
200
+ assert question["resume"]["phase"] == "review" and rig.state()["tickets"]["01"]["round"] == 0
201
+
202
+
203
+ def test_a_ruling_that_asks_spec_ambiguous_is_kept_so_a_dispute_after_keep_test_is_not_arbitrated_again(tmp_path):
204
+ stale = finding("STALE", kind="fixture", file="tests/test_01.py")
205
+ steps = plan(**{"01/test-writer": [tw("01"), correction()],
206
+ "01/reviewer": [review("01", [stale, STUCK]), ruling("test-wrong", "R3 says single quotes"),
207
+ review("01", [STUCK]), ruling("test-wrong", "R3 says single quotes")],
208
+ "01/fixer": [disputes(role="fixer"), disputes(role="fixer")]})
209
+ rig = Inside(tmp_path, ONE).run(steps)
210
+ assert rig.state()["tickets"]["01"]["disputes"]["tests/test_01.py"]["ruling"] == "test-wrong", rig.ledger()
211
+ rig.run(steps, "--answer", f"{AMBIGUOUS}=keep-test")
212
+ assert rig.code == 2 and len(arbitrations(rig)) == 1, rig.ledger()
213
+ assert [q["id"] for q in asked(rig)] == ["01-spec-ambiguous-2"]
214
+
215
+
216
+ # ---------------------------------------------------------------- the answers
217
+
218
+ def test_keep_test_runs_the_implementer_again_and_keeps_the_record(tmp_path):
219
+ rig = ambiguous(tmp_path, then=(disputes(), impl("01")))
220
+ before = rig.state()["tickets"]["01"]["disputes"]
221
+ rig.run(plan(**{"01/implementer": [disputes(), disputes(), disputes(), impl("01")],
222
+ "01/reviewer": [ruling("code-wrong", "R3 says double quotes"), review("01")]}),
223
+ "--answer", f"{AMBIGUOUS}=keep-test")
224
+ assert rig.code == 2 and rig.led(f"Ruling: 01 locked test stands (keep-test): {TEST}"), rig.ledger()
225
+ assert len(rig.calls("01", "implementer")) == 3 and "R3 says double quotes" in rig.calls("01", "implementer")[2]["prompt"]
226
+ assert [q["id"] for q in asked(rig)] == ["01-spec-ambiguous-2"] and len(arbitrations(rig)) == 1
227
+ assert rig.state()["tickets"]["01"]["disputes"] == before
228
+
229
+
230
+ def test_correct_test_corrects_to_the_second_reading_then_the_implementer_runs_and_the_record_stays(tmp_path):
231
+ second = disputes((TEST, "the example in R3 uses '"))
232
+ steps = {"01/implementer": [disputes(), second, disputes()], "01/test-writer": [tw("01"), correction()],
233
+ "01/reviewer": [ruling("code-wrong", "R3 says double quotes"), review("01")]}
234
+ rig = run(tmp_path, steps)
235
+ rig.run(plan(**steps), "--answer", f"{AMBIGUOUS}=correct-test")
236
+ assert rig.code == 2, rig.ledger()
237
+ assert roles(rig)[-2:] == ["test-writer", "implementer"] and len(arbitrations(rig)) == 1
238
+ fixed = rig.calls("01", "test-writer")[1]
239
+ assert ".agent/implement/01/spec-ambiguous-1.json" in fixed["prompt"]
240
+ (wanted,) = json.loads((rig.folder() / "spec-ambiguous-1.json").read_text())
241
+ assert wanted["evidence"] == "correct the test to the second reading: the example in R3 uses '"
242
+ assert rig.calls("01", "implementer")[2]["head"] == fixed["sha"]
243
+ assert [q["id"] for q in asked(rig)] == ["01-spec-ambiguous-2"]
244
+ assert set(rig.state()["tickets"]["01"]["disputes"]) == {"tests/test_01.py"}
245
+
246
+
247
+ def test_correct_test_after_a_fixer_s_dispute_runs_the_fixer_of_that_round_again_after_the_correction(tmp_path):
248
+ stuck = review("01", [STUCK])
249
+ steps = plan(**{"01/fixer": [disputes(role="fixer"), disputes(role="fixer"), fix("01", 1)],
250
+ "01/test-writer": [tw("01"), correction()],
251
+ "01/reviewer": [stuck, ruling("code-wrong", "R3 says double quotes"), stuck, review("01")]})
252
+ rig = Inside(tmp_path, ONE).run(steps)
253
+ assert rig.code == 2 and [q["id"] for q in asked(rig)] == [AMBIGUOUS], rig.ledger()
254
+ rig.run(steps, "--answer", f"{AMBIGUOUS}=correct-test")
255
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
256
+ assert roles(rig)[-4:] == ["test-writer", "reviewer", "fixer", "reviewer"]
257
+ assert len(rig.calls("01", "implementer")) == 1 and rig.state()["tickets"]["01"]["round"] == 1
258
+ assert "fixer-1.json" in rig.calls("01", "fixer")[2]["prompt"]
259
+
260
+
261
+ def test_edit_spec_keeps_the_ticket_blocked_with_the_ruling_and_runs_no_agent(tmp_path):
262
+ rig = ambiguous(tmp_path)
263
+ seen, before = len(rig.calls("01")), rig.state()["tickets"]["01"]
264
+ rig.run(plan(), "--answer", f"{AMBIGUOUS}=edit-spec")
265
+ assert rig.code == 1 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
266
+ assert rig.led("Ruling: 01 stays BLOCKED for an edit of the spec (edit-spec)") and len(rig.calls("01")) == seen
267
+ after = rig.state()["tickets"]["01"]
268
+ assert (after["disputes"], after["corrected"]) == (before["disputes"], before["corrected"])
269
+
270
+
271
+ def test_keep_test_on_a_review_finding_closes_it_and_the_ticket_goes_on(tmp_path):
272
+ stale = finding("STALE", kind="fixture", file="tests/test_01.py")
273
+ steps = plan(**{"01/test-writer": [tw("01"), correction()], "01/fixer": [fix("01", 1)],
274
+ "01/reviewer": [review("01", [stale]), review("01", [stale]), review("01", [stale, STUCK]),
275
+ review("01")]})
276
+ rig = Inside(tmp_path, ONE).run(steps)
277
+ assert rig.code == 2 and [q["id"] for q in asked(rig)] == [AMBIGUOUS], rig.ledger()
278
+ rig.run(steps, "--answer", f"{AMBIGUOUS}=keep-test")
279
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
280
+ assert roles(rig) == ["test-writer", "implementer", "reviewer", "test-writer", "reviewer", "reviewer", "fixer",
281
+ "reviewer"]
282
+ assert rig.led("STALE", "closed as it is by the ruling (keep-test)")
283
+
284
+
285
+ # ---------------------------------------------------------------- a correction that fails
286
+
287
+ def test_an_arbitration_correction_rejected_twice_asks_ticket_blocked_and_retry_starts_from_before_it(tmp_path):
288
+ spill = {**correction(), "files": {"tests/test_01.py": CORRECTED, "demo/export.py": "spill = 1\n"}}
289
+ steps = plan(**{"01/implementer": [disputes(), disputes(), impl("01")],
290
+ "01/test-writer": [tw("01"), spill, spill, correction()],
291
+ "01/reviewer": [ruling("test-wrong", "R3 says single quotes"),
292
+ ruling("test-wrong", "R3 says single quotes"), review("01")]})
293
+ rig = Inside(tmp_path, ONE).run(steps)
294
+ assert rig.code == 2, rig.ledger()
295
+ (question,) = asked(rig)
296
+ assert question["kind"] == "ticket-blocked" and question["resume"]["phase"] == "implement"
297
+ assert "its commits also change demo/export.py" in question["subject"]
298
+ start = rig.calls("01", "test-writer")[1]["head"]
299
+ assert rig.state()["tickets"]["01"]["tip"] == start and rig.state()["tickets"]["01"]["disputes"] == {}
300
+ rig.run(steps, "--answer", f"{question['id']}=retry")
301
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
302
+ assert rig.calls("01", "implementer")[1]["head"] == start and len(arbitrations(rig)) == 2
303
+
304
+
305
+ def test_an_implementer_with_nothing_to_change_after_the_correction_is_accepted(tmp_path):
306
+ """Issue 123: the correction made the locked test green, so the implementer has nothing to change."""
307
+ idle = {"report": {"status": "DONE_WITH_CONCERNS", "commits": [], "files": [], "green": ["1 passed"],
308
+ "concerns": ["the correction made the locked tests green: the start needs no change"]}}
309
+ green = {**correction(), "stdout": "FAILED tests/test_01.py::test_x - AttributeError\n" + COST}
310
+ rig = run(tmp_path, {"01/implementer": [disputes(), idle], "01/test-writer": [tw("01"), green],
311
+ "01/reviewer": [ruling("test-wrong", "R3 says single quotes"), review("01")]})
312
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
313
+ fixed = rig.calls("01", "test-writer")[1]["sha"]
314
+ assert fixed in [gate["commit"] for gate in rig.gates()] and rig.calls("01", "reviewer")[1]["head"] == fixed
@@ -13,8 +13,7 @@ RUN = SKILL / "run.sh"
13
13
  GIT = ["git", "-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false"]
14
14
  TOOLS = ("sh", "uname", "dirname", "readlink", "git", "env", "mktemp", "curl", "tar", "gzip", "mv", "rm", "mkdir",
15
15
  "sha256sum", "shasum", "cat", "chmod", "ln", "date", "basename")
16
- ROLES = ("explorer", "test-writer", "implementer", "reviewer", "correctness", "fixer", "final-reviewer", "conflict",
17
- "pr-writer")
16
+ ROLES = ("test-writer", "implementer", "reviewer", "fixer", "final-reviewer", "conflict", "pr-writer")
18
17
  NONE = "None (can start immediately)"
19
18
 
20
19
 
@@ -85,7 +84,8 @@ def env(tmp_path):
85
84
 
86
85
  def models_file(tmp_path, **overrides):
87
86
  entries = {role: ["anthropic/claude-opus-5@medium"] for role in ROLES}
88
- entries["correctness"] = ["openai/gpt-sol@medium"]
87
+ # The correctness lens of the final review runs on another provider than the first implementer entry.
88
+ entries["final-reviewer"] = ["anthropic/claude-opus-5@medium", "openai/gpt-sol@medium"]
89
89
  entries.update(overrides)
90
90
  if len(entries["implementer"]) == 1:
91
91
  first = entries["implementer"][0]