@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
|
@@ -16,10 +16,9 @@ import driver_report
|
|
|
16
16
|
import driver_run
|
|
17
17
|
import driver_review
|
|
18
18
|
import test_review
|
|
19
|
-
from conftest import GIT
|
|
20
19
|
from test_cli import three, ticket
|
|
21
20
|
from test_final import RUNNER, final, fixer, fn
|
|
22
|
-
from test_review import FABLE, ONE, OPUS, RISKY,
|
|
21
|
+
from test_review import FABLE, ONE, OPUS, RISKY, STUCK, finding, fix, review
|
|
23
22
|
from test_walk import impl, plan, tw
|
|
24
23
|
|
|
25
24
|
|
|
@@ -62,33 +61,55 @@ def under(tmp_path, name):
|
|
|
62
61
|
return tmp_path / name
|
|
63
62
|
|
|
64
63
|
|
|
65
|
-
def blocked(rig, nn="01"):
|
|
64
|
+
def blocked(rig, nn="01", code=1):
|
|
65
|
+
"""The one BLOCKED line of the ticket; `code` 2: a rerun that was rejected too asked `ticket-blocked`."""
|
|
66
66
|
(line,) = rig.led(nn, "BLOCKED")
|
|
67
|
-
assert rig.code ==
|
|
67
|
+
assert rig.code == code and rig.state()["tickets"][nn]["phase"] == "blocked"
|
|
68
68
|
return line
|
|
69
69
|
|
|
70
70
|
|
|
71
71
|
# ---------------------------------------------------------------- who reviews
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
LEDGER = "two runs at once can both write the ledger"
|
|
74
|
+
INTERLEAVE = {**finding("concurrent writes interleave ledger lines", "critical"), "basis": "criterion"}
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def ledger_tickets():
|
|
78
|
+
"""Ticket 01 with a Risk line, 02 after it with none, and 03 independent of both."""
|
|
79
|
+
return three(**{"01-export-rows.md": ticket("01", "Export rows", risk=LEDGER),
|
|
80
|
+
"02-quote-fields.md": ticket("02", "Quote fields", "01")})
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def test_a_risky_ticket_and_a_plain_one_are_each_reviewed_by_the_reviewer_alone(tmp_path):
|
|
84
|
+
rig = Inside(tmp_path, ledger_tickets()).run(plan())
|
|
77
85
|
assert rig.code == 0, rig.ledger()
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
assert ".
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
assert
|
|
86
|
+
for nn in ("01", "02"):
|
|
87
|
+
assert [call["role"] for call in rig.calls(nn) if call["role"] not in ("test-writer", "implementer")] == [
|
|
88
|
+
"reviewer"], nn
|
|
89
|
+
assert not list(rig.folder(nn).glob("correctness*")), nn
|
|
90
|
+
risky = rig.prompt("reviewer-0", "01")
|
|
91
|
+
assert f"Check the Risk line of the ticket as one more criterion: {LEDGER}." in risky
|
|
92
|
+
assert "names no risk" not in risky
|
|
93
|
+
assert "The ticket names no risk." in rig.prompt("reviewer-0", "02")
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def test_an_unhandled_risk_is_a_criterion_finding_that_starts_fix_round_1(tmp_path):
|
|
97
|
+
rig = Inside(tmp_path, ledger_tickets())
|
|
98
|
+
rig.run(plan(**{"01/reviewer": [review("01", [INTERLEAVE])], "01/fixer": [fix("01", 1)]}))
|
|
99
|
+
assert rig.code == 0, rig.ledger()
|
|
100
|
+
(found,) = json.loads((rig.folder("01") / "findings-0.json").read_text())
|
|
101
|
+
assert (found["title"], found["basis"], found["source"]) == (INTERLEAVE["title"], "criterion", "reviewer")
|
|
102
|
+
assert len(rig.calls("01", "fixer")) == 1 and ".agent/implement/01/findings-0.json" in rig.prompt("fixer-1", "01")
|
|
103
|
+
assert rig.led("critical finding of kind code from the reviewer", INTERLEAVE["title"])
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
def test_an_unhandled_risk_at_the_cap_blocks_the_ticket_and_an_independent_one_goes_on(tmp_path):
|
|
107
|
+
rig = Inside(tmp_path, ledger_tickets())
|
|
108
|
+
rig.run(plan(**{"01/reviewer": [review("01", [INTERLEAVE])] * 3, "01/fixer": [fix("01", n) for n in (1, 2)]}))
|
|
109
|
+
assert rig.code == 1 and rig.state()["tickets"]["01"]["round"] == 2, rig.ledger()
|
|
110
|
+
assert rig.led("BLOCKED at the review: after round 2 these findings are open: concurrent writes interleave")
|
|
111
|
+
assert rig.state()["tickets"]["01"]["phase"] == "blocked" and not rig.calls("02")
|
|
112
|
+
assert rig.state()["tickets"]["03"]["phase"] == "merged"
|
|
92
113
|
|
|
93
114
|
|
|
94
115
|
def test_capped_regression_is_carried_through_the_final_fix_batch(tmp_path):
|
|
@@ -102,68 +123,17 @@ def test_capped_regression_is_carried_through_the_final_fix_batch(tmp_path):
|
|
|
102
123
|
|
|
103
124
|
rig.run(plan(**{"02/reviewer": [review("02", [regression])] * 3,
|
|
104
125
|
"02/fixer": [fix("02", 1), fix("02", 2)],
|
|
105
|
-
"final/final-reviewer": [
|
|
126
|
+
"final/final-reviewer": [scoped], "final/fixer": [batch]}))
|
|
106
127
|
|
|
107
128
|
assert rig.code == 0, rig.ledger()
|
|
108
129
|
assert [item["title"] for item in rig.state()["run"]["final"]["must_fix"]] == ["QUOTING-REGRESSION"]
|
|
109
130
|
assert "QUOTING-REGRESSION" in rig.prompt("fixer-1", "final")
|
|
110
131
|
|
|
111
132
|
|
|
112
|
-
def test_correctness_entry_is_the_first_of_another_provider_than_the_implementers():
|
|
113
|
-
models = {"implementer": ["opus@medium"], "correctness": ["opus@high", "openai/a@low", "openai/b@low"]}
|
|
114
|
-
assert driver_agents.correctness_entry(models) == "openai/a@low"
|
|
115
|
-
assert driver_agents.correctness_entry({**models, "implementer": ["openai/x@low", "opus@low"]}) == "opus@high"
|
|
116
|
-
assert driver_agents.correctness_entry({**models, "correctness": ["opus@high", "claude-fable-5@low"]}) == ""
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def test_a_set_with_a_risk_ticket_needs_review_diff_and_a_set_without_one_does_not(tmp_path, monkeypatch, capsys):
|
|
120
|
-
monkeypatch.setattr(driver_review, "CORRECTNESS", tmp_path / "skills/review-diff/correctness.md")
|
|
121
|
-
rig = Inside(tmp_path, three()).run(plan())
|
|
122
|
-
assert rig.code == 3 and not rig.calls() and not (rig.repo / ".agent/implement").exists()
|
|
123
|
-
out = capsys.readouterr().out
|
|
124
|
-
assert f"{tmp_path}/skills/review-diff/correctness.md is missing: ticket 02 has a Risk line" in out
|
|
125
|
-
assert "install the review-diff skill next to implement-spec" in out
|
|
126
|
-
plain = Inside(under(tmp_path, "plain"), ONE).run(plan())
|
|
127
|
-
assert plain.code == 0 and plain.state()["tickets"]["01"]["phase"] == "merged"
|
|
128
|
-
|
|
129
|
-
|
|
130
133
|
# ---------------------------------------------------------------- the locked files
|
|
131
134
|
|
|
132
|
-
def test_a_changed_locked_file_is_fixed_before_a_fixture_finding_is_corrected(tmp_path):
|
|
133
|
-
rig = Inside(tmp_path)
|
|
134
|
-
locked = tw("01")["files"]
|
|
135
|
-
cheat = impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n", "tests/test_01.py": "# edited\n"})
|
|
136
|
-
stale = finding("STALE", "important", kind="fixture", file="tests/test_01.py")
|
|
137
|
-
correction = {**tw("01"), "files": {"tests/test_01.py": "# corrected\n"}, "commit": "test: 01 fixture fix"}
|
|
138
|
-
rig.run(plan(**{"01/implementer": [cheat], "01/test-writer": [tw("01"), correction],
|
|
139
|
-
"01/reviewer": [review("01", [stale]), review("01", [stale]), review("01")],
|
|
140
|
-
"01/fixer": [fix("01", 1, files={**locked, "demo/export.py": "x = 1\n"})]}))
|
|
141
|
-
assert rig.code == 0, rig.ledger()
|
|
142
|
-
(line,) = rig.led("locked file changed: tests/test_01.py")
|
|
143
|
-
assert line == ("Ticket 01: critical finding of kind code from the driver at tests/test_01.py:1: "
|
|
144
|
-
"locked file changed: tests/test_01.py.")
|
|
145
|
-
order = [call["role"] for call in rig.calls("01")]
|
|
146
|
-
assert order == ["test-writer", "implementer", "reviewer", "fixer", "reviewer", "test-writer", "reviewer"]
|
|
147
|
-
(first,) = [f for f in json.loads((rig.folder() / "findings-0.json").read_text()) if f["source"] == "driver"]
|
|
148
|
-
assert first["evidence"] == f"git diff {rig.sha('01', 'test-writer')}..HEAD -- tests/test_01.py"
|
|
149
|
-
assert f"its content at {rig.sha('01', 'test-writer')}." in rig.prompt("fixer-1")
|
|
150
|
-
# The correction is the new reference of the locked-file check, and it is outside the rounds.
|
|
151
|
-
entry = rig.state()["tickets"]["01"]
|
|
152
|
-
assert (entry["round"], entry["test_writer_sha"]) == (1, rig.calls("01", "test-writer")[1]["sha"])
|
|
153
|
-
assert entry["locked"] == ["tests/test_01.py"] and (rig.folder() / "test-writer-2.json").exists()
|
|
154
|
-
assert rig.led("fixture correction in tests/test_01.py, outside the fix rounds: STALE: STALE.")
|
|
155
|
-
assert "This call is a correction of the locked tests" in rig.prompt("test-writer-2") and "findings-1.json" in rig.prompt("test-writer-2")
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
def test_a_locked_file_check_that_git_cannot_make_is_a_finding(tmp_path):
|
|
159
|
-
rig = Inside(tmp_path)
|
|
160
|
-
assert driver_review.locked_changes(str(rig.repo), None, []) == []
|
|
161
|
-
(found,) = driver_review.locked_changes(str(rig.repo), "0" * 40, ["tests/test_01.py"])
|
|
162
|
-
assert found["severity"] == "critical" and found["title"].startswith("locked file check failed: ")
|
|
163
|
-
|
|
164
|
-
|
|
165
135
|
STALE = finding("STALE", kind="fixture", file="tests/test_01.py")
|
|
166
|
-
|
|
136
|
+
AMBIGUOUS_1 = "01-spec-ambiguous-1"
|
|
167
137
|
|
|
168
138
|
|
|
169
139
|
def corrections(n):
|
|
@@ -177,54 +147,27 @@ def asked(rig):
|
|
|
177
147
|
return {q["id"]: [o["id"] for o in q["options"]] for q in rig.state()["run"]["questions"] if q["answer"] is None}
|
|
178
148
|
|
|
179
149
|
|
|
180
|
-
def
|
|
150
|
+
def test_a_locked_test_finding_that_comes_back_after_its_correction_asks_spec_ambiguous(tmp_path):
|
|
181
151
|
# Issue #107: the ticket was BLOCKED with no question, so only an edit of state.json could resume it.
|
|
182
152
|
steps = plan(**{"01/test-writer": [tw("01"), *corrections(2)],
|
|
183
|
-
"01/
|
|
153
|
+
"01/implementer": [impl("01"), impl("01", text="def fn_01():\n return 'again'\n")],
|
|
154
|
+
"01/reviewer": [review("01", [STALE])] * 2 + [review("01")]})
|
|
184
155
|
rig = Inside(tmp_path).run(steps)
|
|
185
156
|
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
186
|
-
assert rig.led("BLOCKED at the review:
|
|
187
|
-
|
|
157
|
+
assert rig.led("BLOCKED at the review: the spec reads two ways on a locked test: tests/test_01.py: the first "
|
|
158
|
+
"reading: STALE: STALE; the second reading: STALE: STALE.")
|
|
159
|
+
assert asked(rig) == {AMBIGUOUS_1: ["keep-test", "correct-test", "edit-spec"]}
|
|
188
160
|
(question,) = rig.state()["run"]["questions"]
|
|
189
|
-
assert question["recommended"] == "
|
|
190
|
-
rig.run(steps, "--answer", f"{
|
|
161
|
+
assert question["recommended"] == "" and question["evidence"][0] == ".agent/implement/01/spec-ambiguous-1.json"
|
|
162
|
+
rig.run(steps, "--answer", f"{AMBIGUOUS_1}=correct-test")
|
|
191
163
|
assert rig.code == 0, rig.ledger()
|
|
192
164
|
order = [call["role"] for call in rig.calls("01")]
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
assert rig.led("Ruling: 01 locked
|
|
165
|
+
# The question came from a review: after the correction, the review runs again.
|
|
166
|
+
assert order == ["test-writer", "implementer", "reviewer", "test-writer", "reviewer", "test-writer", "reviewer"]
|
|
167
|
+
assert rig.led("Ruling: 01 locked test is corrected to the second reading (correct-test)")
|
|
196
168
|
assert rig.state()["tickets"]["01"]["phase"] == "merged"
|
|
197
169
|
|
|
198
170
|
|
|
199
|
-
def test_an_accepted_locked_test_finding_lets_the_ticket_go_on_to_its_fix_rounds(tmp_path):
|
|
200
|
-
steps = plan(**{"01/test-writer": [tw("01"), *corrections(1)], "01/fixer": [fix("01", 1)],
|
|
201
|
-
"01/reviewer": [review("01", [STALE]), review("01", [STALE]), review("01", [STALE, STUCK]),
|
|
202
|
-
review("01", [STALE])]})
|
|
203
|
-
rig = Inside(tmp_path).run(steps)
|
|
204
|
-
assert rig.code == 2 and list(asked(rig)) == [AGAIN_1], rig.ledger()
|
|
205
|
-
rig.run(steps, "--answer", f"{AGAIN_1}=accept")
|
|
206
|
-
assert rig.code == 0, rig.ledger()
|
|
207
|
-
order = [call["role"] for call in rig.calls("01")]
|
|
208
|
-
assert order == ["test-writer", "implementer", "reviewer", "test-writer", "reviewer", "reviewer", "fixer",
|
|
209
|
-
"reviewer"]
|
|
210
|
-
assert rig.state()["tickets"]["01"]["round"] == 1
|
|
211
|
-
assert rig.led("STALE", "closed as it is by the ruling")
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
def test_the_extra_corrections_are_bounded_and_redesign_keeps_the_ticket_blocked(tmp_path):
|
|
215
|
-
steps = plan(**{"01/test-writer": [tw("01"), *corrections(3)], "01/reviewer": [review("01", [STALE])] * 6})
|
|
216
|
-
rig = Inside(tmp_path).run(steps)
|
|
217
|
-
for n in (1, 2):
|
|
218
|
-
assert asked(rig) == {f"01-locked-test-again-{n}": ["correct-again", "accept", "redesign"]}, rig.ledger()
|
|
219
|
-
rig.run(steps, "--answer", f"01-locked-test-again-{n}=correct-again")
|
|
220
|
-
# Two extra corrections did not close it: a third one is not offered.
|
|
221
|
-
assert asked(rig) == {"01-locked-test-again-3": ["accept", "redesign"]}, rig.ledger()
|
|
222
|
-
assert len(rig.calls("01", "test-writer")) == 4
|
|
223
|
-
rig.run(steps, "--answer", "01-locked-test-again-3=redesign")
|
|
224
|
-
assert rig.code == 1 and rig.state()["tickets"]["01"]["phase"] == "blocked" and asked(rig) == {}
|
|
225
|
-
assert rig.led("Ruling: 01 stays BLOCKED, the design changes first (redesign): STALE.")
|
|
226
|
-
|
|
227
|
-
|
|
228
171
|
def test_an_open_finding_survives_the_fixture_correction_of_its_review_and_starts_the_fix_round(tmp_path):
|
|
229
172
|
stale = finding("STALE", kind="fixture", file="tests/test_01.py")
|
|
230
173
|
correction = {**tw("01"), "files": {"tests/test_01.py": "# corrected\n"}, "commit": "test: 01 fixture fix"}
|
|
@@ -241,7 +184,7 @@ def test_an_open_finding_survives_the_fixture_correction_of_its_review_and_start
|
|
|
241
184
|
|
|
242
185
|
|
|
243
186
|
def test_a_test_finding_on_a_locked_file_gets_the_test_writer_correction_not_a_fix_round(tmp_path):
|
|
244
|
-
# A
|
|
187
|
+
# A weak locked test: the fixer may not edit the locked file, so a fix round could never close it.
|
|
245
188
|
vacuous = finding("VACUOUS", "critical", kind="test", file="tests/test_01.py")
|
|
246
189
|
correction = {**tw("01"), "files": {"tests/test_01.py": "# stronger\n"}, "commit": "test: 01 stronger test"}
|
|
247
190
|
rig = Inside(tmp_path).run(plan(**{"01/test-writer": [tw("01"), correction],
|
|
@@ -323,75 +266,101 @@ def test_a_test_writer_that_lists_test_node_ids_in_locked_locks_their_files(tmp_
|
|
|
323
266
|
assert rig.state()["tickets"]["01"]["locked"] == ["tests/test_01.py"]
|
|
324
267
|
|
|
325
268
|
|
|
326
|
-
|
|
327
|
-
OVERRULED = {**tw("01"), "files": {"tests/test_01.py": "def test_x():\n assert '01' == '01'\n"},
|
|
328
|
-
"commit": "test: 01 overruled"}
|
|
329
|
-
AGAIN = impl("01", text="def fn_01():\n return 'again'\n")
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
def fixer_stops():
|
|
333
|
-
return {"report": {"status": "BLOCKED", "commits": [], "files": [], "concerns": [CONTRA], "green": [], "ticket": "01"}}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
def test_a_fixer_that_reports_a_wrong_locked_test_opens_the_locked_test_question(tmp_path):
|
|
337
|
-
steps = plan(**{"01/reviewer": [review("01", [STUCK]), review("01")], "01/fixer": [fixer_stops()],
|
|
338
|
-
"01/test-writer": [tw("01"), OVERRULED], "01/implementer": [impl("01"), AGAIN]})
|
|
339
|
-
rig = Inside(tmp_path).run(steps)
|
|
340
|
-
assert rig.code == 2, rig.ledger()
|
|
341
|
-
(asked,) = rig.state()["run"]["questions"]
|
|
342
|
-
assert (asked["id"], asked["evidence"][0]) == ("01-locked-test-1", ".agent/implement/01/fixer-1.json")
|
|
343
|
-
rig.run(steps, "--answer", "01-locked-test-1=overrule-test")
|
|
344
|
-
assert rig.code == 0, rig.ledger()
|
|
345
|
-
order = [call["role"] for call in rig.calls("01")]
|
|
346
|
-
assert order == ["test-writer", "implementer", "reviewer", "fixer", "test-writer", "implementer", "reviewer"]
|
|
347
|
-
# The correction reads the concerns of the fixer that stopped, not those of the implementer.
|
|
348
|
-
assert "01/fixer-1.json" in rig.prompt("test-writer-0") and "implementer-0.json" not in rig.prompt("test-writer-0")
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
def test_the_fix_rounds_count_from_0_after_an_overruled_test(tmp_path):
|
|
352
|
-
stuck = review("01", [STUCK])
|
|
353
|
-
steps = plan(**{"01/reviewer": [stuck, stuck, review("01")],
|
|
354
|
-
"01/fixer": [fixer_stops(), fix("01", 1)],
|
|
355
|
-
"01/test-writer": [tw("01"), OVERRULED], "01/implementer": [impl("01"), AGAIN]})
|
|
356
|
-
rig = Inside(tmp_path).run(steps)
|
|
357
|
-
assert rig.code == 2 and rig.state()["tickets"]["01"]["round"] == 1, rig.ledger()
|
|
358
|
-
rig.run(steps, "--answer", "01-locked-test-1=overrule-test")
|
|
359
|
-
# The corrected tests are a new contract: the first finding on them gets a fresh fix round.
|
|
360
|
-
assert rig.code == 0, rig.ledger()
|
|
361
|
-
assert rig.state()["tickets"]["01"]["round"] == 1 and not rig.led("after round 2")
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
def test_a_fixture_correction_that_is_rejected_asks_the_operator(tmp_path):
|
|
269
|
+
def test_a_fixture_correction_that_is_rejected_twice_asks_ticket_blocked_and_retry_reviews_again(tmp_path):
|
|
365
270
|
# Issue #107: a correction the driver rejects (for one, a change to a file it does not list) was a dead end too.
|
|
366
271
|
steps = plan(**{"01/test-writer": [tw("01"), {}, {}, *corrections(1)],
|
|
367
272
|
"01/reviewer": [review("01", [STALE])] * 2 + [review("01")]})
|
|
368
273
|
rig = Inside(tmp_path).run(steps)
|
|
369
|
-
assert rig.code == 2 and list(asked(rig)) == [
|
|
274
|
+
assert rig.code == 2 and list(asked(rig)) == ["01-ticket-blocked-1"], rig.ledger()
|
|
370
275
|
assert rig.led("BLOCKED at the test-writer correction: report .agent/implement/01/test-writer-1.json is not")
|
|
371
|
-
rig.
|
|
276
|
+
assert rig.state()["run"]["questions"][0]["resume"]["phase"] == "review"
|
|
277
|
+
rig.run(steps, "--answer", "01-ticket-blocked-1=retry")
|
|
372
278
|
assert rig.code == 0 and len(rig.calls("01", "test-writer")) == 4, rig.ledger()
|
|
279
|
+
assert [call["role"] for call in rig.calls("01")][-3:] == ["reviewer", "test-writer", "reviewer"]
|
|
373
280
|
|
|
374
281
|
|
|
375
|
-
# ----------------------------------------------------------------
|
|
282
|
+
# ---------------------------------------------------------------- one locked-file rule
|
|
376
283
|
|
|
377
284
|
WEAK = "def test_x():\n assert True\n"
|
|
378
285
|
LOCKED_01 = tw("01")["files"]["tests/test_01.py"]
|
|
379
286
|
CHEAT = impl("02", files={"demo/export.py": "def fn_02():\n return '02'\n", "tests/test_01.py": WEAK})
|
|
287
|
+
SONNET, OPUS_5_5 = "claude-sonnet-5-5@medium", "claude-opus-5-5@medium"
|
|
288
|
+
TWO = {"implementer": [SONNET, OPUS_5_5], "test-writer": [SONNET, OPUS_5_5], "conflict": [OPUS_5_5, SONNET]}
|
|
289
|
+
CHANGED_01 = "locked file changed: tests/test_01.py"
|
|
380
290
|
|
|
381
291
|
|
|
382
292
|
def on_pr(rig, path):
|
|
383
293
|
return subprocess.run(["git", "-C", str(rig.repo), "show", f"feat/csv:{path}"], capture_output=True, text=True).stdout
|
|
384
294
|
|
|
385
295
|
|
|
386
|
-
def
|
|
387
|
-
""
|
|
388
|
-
|
|
389
|
-
|
|
296
|
+
def entries(rig, nn, role):
|
|
297
|
+
return [agent["entry"] for agent in rig.state()["run"]["agents"] if (agent["ticket"], agent["role"]) == (nn, role)]
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def attempts(rig, nn, role):
|
|
301
|
+
"""The ledger line of each attempt of `role` on ticket `nn`."""
|
|
302
|
+
return rig.led(f"Ticket {nn}: {role} ran on")
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def breaks_01(**changes):
|
|
306
|
+
"""An implementer of 01 whose commit changes its own locked file."""
|
|
307
|
+
return impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n", "tests/test_01.py": WEAK}, **changes)
|
|
308
|
+
|
|
309
|
+
|
|
310
|
+
IDLE = {"report": {"status": "DONE_WITH_CONCERNS", "commits": [], "files": [], "concerns": ["the start meets the ticket"],
|
|
311
|
+
"green": []}}
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def test_an_implementer_that_changes_its_locked_file_is_rejected_and_runs_again_on_its_second_entry(tmp_path):
|
|
315
|
+
puts_back = impl("01", files={"demo/export.py": "def fn_01():\n return 'one'\n", "tests/test_01.py": LOCKED_01})
|
|
316
|
+
rig = Inside(tmp_path, models=TWO).run(plan(**{"01/implementer": [breaks_01(), puts_back]}))
|
|
317
|
+
assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
|
|
318
|
+
first, second = attempts(rig, "01", "implementer")
|
|
319
|
+
assert CHANGED_01 in first and second.endswith("report accepted.")
|
|
320
|
+
assert entries(rig, "01", "implementer") == [SONNET, OPUS_5_5]
|
|
321
|
+
assert CHANGED_01 in rig.calls("01", "implementer")[1]["prompt"] and on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
def breached(tmp_path):
|
|
325
|
+
"""Ticket 01 blocked after its implementer and the rerun both left tests/test_01.py changed."""
|
|
326
|
+
run = plan(**{"01/implementer": [breaks_01(), IDLE, IDLE, IDLE]})
|
|
327
|
+
return Inside(tmp_path, models=TWO).run(run), run
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
def test_a_rerun_that_leaves_the_locked_file_changed_blocks_the_ticket_with_one_ticket_blocked_question(tmp_path):
|
|
331
|
+
rig, _ = breached(tmp_path)
|
|
332
|
+
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
333
|
+
(question,) = rig.state()["run"]["questions"]
|
|
334
|
+
assert question["kind"] == "ticket-blocked" and CHANGED_01 in question["subject"]
|
|
335
|
+
assert all(CHANGED_01 in line for line in attempts(rig, "01", "implementer"))
|
|
336
|
+
assert entries(rig, "01", "implementer") == [SONNET, OPUS_5_5] and "feat: 01 rows" not in rig.pr_subjects()
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
def test_a_breach_on_the_tip_survives_a_retry_whose_implementer_commits_nothing(tmp_path):
|
|
340
|
+
rig, run = breached(tmp_path)
|
|
341
|
+
rig.run(run, "--answer", "01-ticket-blocked-1=retry")
|
|
342
|
+
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
343
|
+
third = attempts(rig, "01", "implementer")[2]
|
|
344
|
+
assert rig.calls("01", "implementer")[2]["sha"] == "" and CHANGED_01 in third
|
|
345
|
+
assert [q["id"] for q in rig.state()["run"]["questions"] if q["answer"] is None] == ["01-ticket-blocked-2"]
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def test_a_fixer_that_changes_the_locked_file_of_a_merged_ticket_is_rejected_and_runs_again(tmp_path):
|
|
349
|
+
weakens = fix("02", 1, files={"demo/export.py": "def fn_02():\n return 'fix1'\n", "tests/test_01.py": WEAK})
|
|
350
|
+
puts_back = fix("02", 1, files={"demo/export.py": "def fn_02():\n return 'fix2'\n", "tests/test_01.py": LOCKED_01})
|
|
351
|
+
rig = Inside(tmp_path, three()).run(plan(**{"02/reviewer": [review("02", [STUCK]), review("02")],
|
|
352
|
+
"02/fixer": [weakens, puts_back]}))
|
|
353
|
+
assert rig.code == 0 and rig.state()["tickets"]["02"]["phase"] == "merged", rig.ledger()
|
|
354
|
+
first, second = attempts(rig, "02", "fixer")
|
|
355
|
+
assert CHANGED_01 in first and second.endswith("report accepted.")
|
|
356
|
+
assert on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
def test_an_implementer_that_changes_only_its_code_is_accepted_with_no_locked_file_line(tmp_path):
|
|
360
|
+
rig = Inside(tmp_path).run(plan())
|
|
390
361
|
assert rig.code == 0, rig.ledger()
|
|
391
|
-
|
|
392
|
-
assert
|
|
393
|
-
assert len(rig.calls("02", "test-writer")) == 1 and not rig.calls("02", "fixer")
|
|
394
|
-
assert on_pr(rig, "tests/test_01.py") == LOCKED_01 and "feat: 02 rows" in rig.pr_subjects()
|
|
362
|
+
(only,) = attempts(rig, "01", "implementer")
|
|
363
|
+
assert only.endswith("report accepted.") and not rig.led("locked file")
|
|
395
364
|
|
|
396
365
|
|
|
397
366
|
def extends(text, listed):
|
|
@@ -401,102 +370,144 @@ def extends(text, listed):
|
|
|
401
370
|
return writer
|
|
402
371
|
|
|
403
372
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
373
|
+
MORE_01 = LOCKED_01 + "\n\ndef test_y():\n assert 02 == 'y'\n"
|
|
374
|
+
UNLISTED = "tests/test_01.py is a locked file of another ticket, and `locked` does not list it"
|
|
375
|
+
|
|
376
|
+
|
|
377
|
+
def test_a_listed_change_to_a_merged_ticket_locked_file_is_in_the_reviewer_prompt_and_lands(tmp_path):
|
|
378
|
+
rig = Inside(tmp_path, three()).run(plan(**{"02/test-writer": [extends(MORE_01, True)]}))
|
|
379
|
+
assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
|
|
380
|
+
prompt = rig.prompt("reviewer-0", "02")
|
|
381
|
+
assert "diff --git a/tests/test_01.py b/tests/test_01.py" in prompt and "+def test_y():" in prompt
|
|
382
|
+
assert on_pr(rig, "tests/test_01.py") == MORE_01 and not rig.led("locked file changed")
|
|
409
383
|
assert rig.state()["tickets"]["02"]["locked"] == ["tests/test_02.py", "tests/test_01.py"]
|
|
410
|
-
# What the test-writer of 02 wrote is locked for the implementer of 02: the check of its own review finds it.
|
|
411
|
-
again = Inside(under(tmp_path, "cheat"), three()).run(
|
|
412
|
-
plan(**{"02/test-writer": [extends(more, True)], "02/implementer": [CHEAT], "02/fixer": [{}, {}]}))
|
|
413
|
-
assert again.led("Ticket 02:", "locked file changed") == [
|
|
414
|
-
"Ticket 02: critical finding of kind code from the driver at tests/test_01.py:1: locked file changed: tests/test_01.py."]
|
|
415
|
-
assert on_pr(again, "tests/test_01.py") == LOCKED_01
|
|
416
|
-
# An unlisted change is a report violation: one rerun with the error, then BLOCKED before any implementer.
|
|
417
|
-
unlisted = Inside(under(tmp_path, "unlisted"), three()).run(plan(**{"02/test-writer": [extends(more, False)] * 2}))
|
|
418
|
-
error = ("tests/test_01.py is a locked file of a merged ticket, and `locked` does not list it: list it in "
|
|
419
|
-
"`locked`, or leave the file as it was")
|
|
420
|
-
assert blocked(unlisted, "02") == f"Ticket 02: BLOCKED at the test-writer: {error}."
|
|
421
|
-
first, second = unlisted.calls("02", "test-writer")
|
|
422
|
-
assert f"The driver rejected the earlier attempt: {error}" in second["prompt"]
|
|
423
|
-
assert not unlisted.calls("02", "implementer") and on_pr(unlisted, "tests/test_01.py") == LOCKED_01
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
def test_a_refactor_ticket_may_not_change_a_locked_test_of_a_merged_ticket(tmp_path):
|
|
427
|
-
"""It has no test-writer and no locked file of its own: the review finds the change, and the restore closes it."""
|
|
428
|
-
files = three(**{"02-quote-fields.md": test_review.ticket("02", "Quote fields", "01", seam="none — refactor", criteria=())})
|
|
429
|
-
rig = Inside(tmp_path, files).run(plan(**{"02/implementer": [CHEAT]}))
|
|
430
|
-
assert rig.code == 0 and not rig.calls("02", "test-writer"), rig.ledger()
|
|
431
|
-
assert rig.led("Ticket 02:", "the restore closes it") and on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
432
|
-
clean = Inside(under(tmp_path, "clean"), files).run(plan())
|
|
433
|
-
assert clean.code == 0 and not clean.led("locked file changed"), clean.ledger()
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
# A correction is a test-writer: a file that it lists is its ticket's own. It must start from the locked version.
|
|
437
|
-
# The edit has no context lines, so it applies to the file whatever version the tree holds.
|
|
438
|
-
APPEND = "--- a/tests/test_01.py\n+++ b/tests/test_01.py\n@@ -2,0 +3 @@\n+# corrected\n"
|
|
439
|
-
CORRECTED_01 = LOCKED_01 + "# corrected\n"
|
|
440
|
-
RESTORED_01 = ("Ticket 02: tests/test_01.py was not the locked version at the correction: the driver restored it in a "
|
|
441
|
-
"commit, so the correction starts from the locked version.")
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
def appending(tmp_path, **changes):
|
|
445
|
-
"""A correction of 02 that appends a line to tests/test_01.py as the tree holds it, and lists it."""
|
|
446
|
-
(tmp_path / "append.patch").write_text(APPEND)
|
|
447
|
-
step = {**tw("02"), "git": [["apply", "--unidiff-zero", str(tmp_path / "append.patch")]], "commit": "test: 02 corrected", **changes}
|
|
448
|
-
step["report"] = {**step["report"], "locked": ["tests/test_02.py", "tests/test_01.py"]}
|
|
449
|
-
return step
|
|
450
384
|
|
|
451
385
|
|
|
452
|
-
def
|
|
453
|
-
"""
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
386
|
+
def test_an_implementer_that_puts_its_own_locked_file_back_to_the_pr_tip_is_rejected(tmp_path):
|
|
387
|
+
"""02's test-writer extends and locks 01's file; the PR tip still holds the version before it."""
|
|
388
|
+
reverts = impl("02", files={"demo/export.py": "def fn_02():\n return '02'\n", "tests/test_01.py": LOCKED_01})
|
|
389
|
+
rig = Inside(tmp_path, three()).run(plan(**{"02/test-writer": [extends(MORE_01, True)],
|
|
390
|
+
"02/implementer": [reverts, reverts]}))
|
|
391
|
+
assert rig.code == 2 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
392
|
+
assert all(CHANGED_01 in line for line in attempts(rig, "02", "implementer"))
|
|
393
|
+
assert on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
457
394
|
|
|
458
395
|
|
|
459
|
-
def
|
|
460
|
-
"""
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
assert
|
|
467
|
-
rig.run(steps, "--answer", "02-locked-test-1=overrule-test")
|
|
468
|
-
assert on_pr(rig, "tests/test_01.py") == CORRECTED_01, rig.ledger()
|
|
469
|
-
assert rig.led("Ticket 02:", "restored") == [RESTORED_01] and rig.code == 0
|
|
396
|
+
def test_an_implementer_that_makes_its_own_locked_file_executable_is_rejected(tmp_path):
|
|
397
|
+
"""The text of tests/test_01.py stays as the test-writer left it; its mode becomes 100755."""
|
|
398
|
+
chmods = impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n"},
|
|
399
|
+
git=[["update-index", "--chmod=+x", "tests/test_01.py"], ["checkout-index", "-f", "tests/test_01.py"]])
|
|
400
|
+
rig = Inside(tmp_path, models=TWO).run(plan(**{"01/implementer": [chmods, IDLE]}))
|
|
401
|
+
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
402
|
+
assert all(CHANGED_01 in line for line in attempts(rig, "01", "implementer"))
|
|
403
|
+
assert "feat: 01 rows" not in rig.pr_subjects()
|
|
470
404
|
|
|
471
405
|
|
|
472
|
-
def
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
406
|
+
def test_an_unlisted_change_to_a_merged_ticket_locked_file_is_rejected_and_the_test_writer_runs_on_its_second_entry(tmp_path):
|
|
407
|
+
puts_back = {**extends(LOCKED_01, False), "commit": "test: 02 red again"}
|
|
408
|
+
rig = Inside(tmp_path, three(), models=TWO).run(plan(**{"02/test-writer": [extends(MORE_01, False), puts_back]}))
|
|
409
|
+
assert rig.code == 0 and rig.state()["tickets"]["02"]["phase"] == "merged", rig.ledger()
|
|
410
|
+
first, _ = attempts(rig, "02", "test-writer")
|
|
411
|
+
assert UNLISTED in first and entries(rig, "02", "test-writer") == [SONNET, OPUS_5_5]
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
def test_an_unlisted_change_to_the_locked_file_of_an_unmerged_ticket_is_rejected(tmp_path):
|
|
415
|
+
"""01 and 02 run side by side: 02's test-writer ends after 01's test-writer, and 01 merges after it."""
|
|
416
|
+
files = {name: text for name, text in three().items() if not name.startswith("03")}
|
|
417
|
+
files["02-quote-fields.md"] = test_review.ticket("02", "Quote fields", touches="`demo/other.py: g`")
|
|
418
|
+
rig = Inside(tmp_path, files, models=TWO).run(plan(**{
|
|
419
|
+
"01/implementer": [{**impl("01"), "touch": ["w1"]}], "01/reviewer": [{"wait": ["t2"]}],
|
|
420
|
+
"02/test-writer": [{**extends(MORE_01, False), "wait": ["w1"]},
|
|
421
|
+
{**tw("02"), "touch": ["t2"], "git": [["rm", "-q", "tests/test_01.py"]], "commit": "test: 02 again"}],
|
|
422
|
+
"02/implementer": [impl("02", "demo/other.py")]}))
|
|
423
|
+
assert rig.code == 0, rig.ledger()
|
|
424
|
+
first, _ = attempts(rig, "02", "test-writer")
|
|
425
|
+
assert UNLISTED in first and rig.calls("02", "test-writer")[0]["t1"] < rig.calls("01", "reviewer")[0]["t1"]
|
|
426
|
+
|
|
427
|
+
|
|
428
|
+
def on_base(rig, path, text):
|
|
429
|
+
"""Commit `path` on the PR branch before the run."""
|
|
430
|
+
(rig.repo / path).parent.mkdir(parents=True, exist_ok=True)
|
|
431
|
+
(rig.repo / path).write_text(text)
|
|
432
|
+
subprocess.run(["git", "-C", str(rig.repo), "add", path], check=True)
|
|
433
|
+
subprocess.run(["git", "-C", str(rig.repo), "-c", "user.name=t", "-c", "user.email=t@example.com", "commit", "-q",
|
|
434
|
+
"-m", f"add {path}"], check=True)
|
|
435
|
+
|
|
436
|
+
|
|
437
|
+
LEDGER_BASE = "".join(f"def test_{n}():\n assert {n}\n\n\n" for n in range(6))
|
|
438
|
+
LEDGER_01 = LEDGER_BASE.replace("assert 0", "assert 0 == 0") # 01 changes the top of the file
|
|
439
|
+
LEDGER_03 = LEDGER_BASE.replace("assert 5", "assert 5 == 5") # 03 locks the bottom
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
def landed_late(tmp_path):
|
|
443
|
+
"""01's implementer changes tests/test_ledger.py before any ticket locks it; 03's test-writer then changes another
|
|
444
|
+
part of it, lists it in `locked`, and 03 merges while 01 is in review: the merge of 01 is clean."""
|
|
445
|
+
rig = Inside(tmp_path, {k: v for k, v in three().items() if not k.startswith("02")})
|
|
446
|
+
on_base(rig, "tests/test_ledger.py", LEDGER_BASE)
|
|
447
|
+
writer = tw("03")
|
|
448
|
+
writer["files"]["tests/test_ledger.py"] = LEDGER_03
|
|
449
|
+
writer["report"]["locked"] += ["tests/test_ledger.py"]
|
|
450
|
+
rig.steps = plan(**{"01/implementer": [impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n",
|
|
451
|
+
"tests/test_ledger.py": LEDGER_01})],
|
|
452
|
+
"01/reviewer": [{"touch": ["r1"], "wait_pr_moves": True}],
|
|
453
|
+
"03/test-writer": [{**writer, "wait": ["r1"]}]})
|
|
454
|
+
return rig.run(rig.steps)
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
def test_landing_refuses_a_change_to_a_file_another_ticket_locked_later(tmp_path):
|
|
458
|
+
rig = landed_late(tmp_path)
|
|
459
|
+
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
460
|
+
assert rig.tip() == rig.sha("03", "implementer") and on_pr(rig, "tests/test_ledger.py") == LEDGER_03
|
|
461
|
+
(question,) = rig.state()["run"]["questions"]
|
|
462
|
+
assert question["kind"] == "ticket-blocked" and "tests/test_ledger.py" in question["subject"]
|
|
463
|
+
assert question["resume"]["phase"] == "implement"
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
def test_a_retry_of_a_refused_landing_runs_the_implementer_and_lands_once_it_puts_the_file_back(tmp_path):
|
|
467
|
+
rig = landed_late(tmp_path)
|
|
468
|
+
back = impl("01", files={"tests/test_ledger.py": LEDGER_BASE}, commit="fix: 01 ledger back")
|
|
469
|
+
rig.steps["01/implementer"].append(back)
|
|
470
|
+
rig.run(rig.steps, "--answer", "01-ticket-blocked-1=retry")
|
|
471
|
+
assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
|
|
472
|
+
assert on_pr(rig, "tests/test_ledger.py") == LEDGER_03
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
def test_a_correction_runs_with_no_restore_commit_and_no_gate_before_it(tmp_path):
|
|
476
|
+
stale = finding("STALE", kind="fixture", file="tests/test_01.py")
|
|
477
|
+
correction = {**tw("01"), "files": {"tests/test_01.py": "# corrected\n"}, "commit": "test: 01 fixture fix"}
|
|
478
|
+
rig = Inside(tmp_path).run(plan(**{"01/test-writer": [tw("01"), correction],
|
|
479
|
+
"01/reviewer": [review("01", [stale]), review("01")]}))
|
|
480
|
+
assert rig.code == 0, rig.ledger()
|
|
481
|
+
log = rig.calls("01", "reviewer")[1]["log"] # the subjects of the tip the review after the correction read
|
|
482
|
+
assert "restore" not in log and "test: 01 fixture fix" in log
|
|
483
|
+
corrected = rig.calls("01", "test-writer")[1]
|
|
484
|
+
assert [gate["commit"] for gate in rig.gates("fast")] == [rig.sha("01", "implementer"), corrected["sha"]]
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
def test_a_refactor_ticket_that_changes_a_locked_test_of_a_merged_ticket_is_rejected(tmp_path):
|
|
488
|
+
files = three(**{"02-quote-fields.md": test_review.ticket("02", "Quote fields", "01", seam="none — refactor", criteria=())})
|
|
489
|
+
rig = Inside(tmp_path, files).run(plan(**{"02/implementer": [CHEAT, CHEAT]}))
|
|
490
|
+
assert rig.code == 2 and not rig.calls("02", "test-writer"), rig.ledger()
|
|
491
|
+
assert all(CHANGED_01 in line for line in attempts(rig, "02", "implementer"))
|
|
492
|
+
assert on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
480
493
|
|
|
481
494
|
|
|
482
495
|
def test_a_finding_in_the_locked_file_of_a_merged_ticket_goes_to_the_correction_not_the_fixer(tmp_path):
|
|
483
|
-
"""Issue #116: ticket 02 must change the locked file of merged ticket 01. The
|
|
484
|
-
|
|
485
|
-
the forbidden way, so the correction makes it and lists the file."""
|
|
496
|
+
"""Issue #116: ticket 02 must change the locked file of merged ticket 01. The review reports the missing change
|
|
497
|
+
there: a fixer may not make it, so the correction makes it and lists the file."""
|
|
486
498
|
missing = finding("MISSING", file="tests/test_01.py", line=2)
|
|
487
|
-
correction =
|
|
488
|
-
correction["report"]["
|
|
499
|
+
correction = {**tw("02"), "files": {"tests/test_01.py": MORE_01}, "commit": "test: 02 corrected"}
|
|
500
|
+
correction["report"] = {**correction["report"], "locked": ["tests/test_01.py"]}
|
|
489
501
|
rig = Inside(tmp_path, three()).run(plan(**{
|
|
490
|
-
"02/
|
|
491
|
-
"02/reviewer": [review("02"), review("02", [missing]), proves("02", "tests/test_01.py")]}))
|
|
502
|
+
"02/test-writer": [tw("02"), correction], "02/reviewer": [review("02", [missing]), review("02")]}))
|
|
492
503
|
assert rig.code == 0, rig.ledger()
|
|
493
|
-
assert
|
|
504
|
+
assert not rig.calls("02", "fixer")
|
|
494
505
|
assert rig.led("Ticket 02: code correction in tests/test_01.py, outside the fix rounds: MISSING")
|
|
495
|
-
assert on_pr(rig, "tests/test_01.py") ==
|
|
506
|
+
assert on_pr(rig, "tests/test_01.py") == MORE_01
|
|
496
507
|
assert "tests/test_01.py" in rig.state()["tickets"]["02"]["locked"]
|
|
497
508
|
first, corrected = rig.prompt("test-writer-0", "02"), rig.prompt("test-writer-1", "02")
|
|
498
|
-
assert "When the ticket must change a locked file of
|
|
499
|
-
assert "on a locked file of
|
|
509
|
+
assert "When the ticket must change a locked file of another ticket" in first
|
|
510
|
+
assert "on a locked file of another ticket (tests/test_01.py" in corrected
|
|
500
511
|
assert "only this correction may change that file" in corrected
|
|
501
512
|
|
|
502
513
|
|
|
@@ -510,38 +521,12 @@ def test_the_test_writer_checks_fixture_preconditions_and_a_correction_keeps_sha
|
|
|
510
521
|
assert rig.code == 0, rig.ledger()
|
|
511
522
|
first, corrected = rig.prompt("test-writer-0", "02"), rig.prompt("test-writer-1", "02")
|
|
512
523
|
assert "Each fixture sets up exactly the precondition of its scenario" in first
|
|
513
|
-
assert "the locked tests of
|
|
524
|
+
assert "the locked tests of other tickets: tests/test_01.py." in first
|
|
514
525
|
assert "update each shared fake or fixture" not in first
|
|
515
526
|
assert "update each shared fake or fixture that other locked tests use" in corrected
|
|
516
527
|
assert "run each whole file of `locked` and each locked test of merged tickets" in corrected
|
|
517
528
|
|
|
518
529
|
|
|
519
|
-
def test_the_restore_before_a_correction_is_committed_so_the_next_fixer_and_its_gate_find_a_clean_tree(tmp_path):
|
|
520
|
-
"""Issue #86: the correction and the fixer each commit only their own files. The restore of the merged ticket's
|
|
521
|
-
file must not stay in the tree, where the gate of the fixer's commit is `not clean` and burns a round."""
|
|
522
|
-
weak = finding("WEAK", kind="test", file="tests/test_02.py")
|
|
523
|
-
stronger = "def test_x():\n assert '02' == 'x' # stronger\n"
|
|
524
|
-
correction = {**tw("02"), "files": {"tests/test_02.py": stronger}, "commit": "test: 02 stronger",
|
|
525
|
-
"only": ["tests/test_02.py"]}
|
|
526
|
-
rig = Inside(tmp_path, three()).run(plan(**{
|
|
527
|
-
"02/implementer": [CHEAT], "02/test-writer": [tw("02"), correction],
|
|
528
|
-
"02/reviewer": [review("02", [weak, STUCK]), review("02")], "02/fixer": [fix("02", 1, only=["demo/export.py"])]}))
|
|
529
|
-
assert rig.code == 0, rig.ledger()
|
|
530
|
-
assert rig.led("Ticket 02:", "restored") == [RESTORED_01]
|
|
531
|
-
(fixer,) = rig.calls("02", "fixer")
|
|
532
|
-
assert fixer["status"] == "" and fixer["head"] == rig.calls("02", "test-writer")[1]["sha"]
|
|
533
|
-
assert not [gate for gate in rig.folder("02").glob("gate-*.log") if "not clean" in gate.read_text()]
|
|
534
|
-
assert rig.state()["tickets"]["02"]["round"] == 1 and on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
535
|
-
# The correction is told which files the driver put back, so it may update one compatibly when it lists it.
|
|
536
|
-
prompt = rig.prompt("test-writer-1", "02")
|
|
537
|
-
assert "The driver put back these files at their locked versions" in prompt and "tests/test_01.py" in prompt
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
def subject(rig, commit):
|
|
541
|
-
return subprocess.run(["git", "-C", str(rig.repo), "log", "-1", "--format=%s", commit], capture_output=True,
|
|
542
|
-
text=True).stdout.strip()
|
|
543
|
-
|
|
544
|
-
|
|
545
530
|
def test_the_fast_gate_gets_the_locked_files_of_its_ticket_and_the_full_gate_none(tmp_path):
|
|
546
531
|
"""Ticket 02 locks two files and merged ticket 01 locks tests/test_01.py: only 02's files reach its fast gate."""
|
|
547
532
|
writer = tw("02")
|
|
@@ -559,16 +544,8 @@ def test_the_fixer_is_told_the_fast_gate_with_the_locked_files_of_its_ticket(tmp
|
|
|
559
544
|
writer = tw("02")
|
|
560
545
|
writer["files"]["tests/test_02b.py"] = "def test_x():\n assert 2 == 'x'\n"
|
|
561
546
|
writer["report"]["locked"] += ["tests/test_02b.py"]
|
|
562
|
-
proof = dict(test="tests/test_02b.py::test_x", file="demo/export.py", line=1,
|
|
563
|
-
red="FAILED tests/test_02b.py::test_x - AssertionError at demo/export.py:1")
|
|
564
|
-
|
|
565
|
-
def proved(step): # the full review proves each locked test file
|
|
566
|
-
step["report"]["mutations"].append(proof)
|
|
567
|
-
step["stdout"] += proof["red"] + "\n"
|
|
568
|
-
return step
|
|
569
|
-
|
|
570
547
|
rig = Inside(tmp_path, three()).run(plan(**{"02/test-writer": [writer], "02/fixer": [fix("02", 1)],
|
|
571
|
-
"02/reviewer": [
|
|
548
|
+
"02/reviewer": [review("02", [STUCK]), review("02")]}))
|
|
572
549
|
assert rig.code == 0, rig.ledger()
|
|
573
550
|
(fixer,) = rig.calls("02", "fixer")
|
|
574
551
|
test_review.gate_rule(fixer["prompt"], f"export TIER=fast; {rig.rig / 'gate'}",
|
|
@@ -576,61 +553,18 @@ def test_the_fixer_is_told_the_fast_gate_with_the_locked_files_of_its_ticket(tmp
|
|
|
576
553
|
test_review.no_full_gate(rig)
|
|
577
554
|
|
|
578
555
|
|
|
579
|
-
def test_the_restore_commit_gets_the_fast_gate_with_the_locked_files_and_the_restored_ones(tmp_path):
|
|
580
|
-
weak = finding("WEAK", kind="test", file="tests/test_02.py")
|
|
581
|
-
correction = {**tw("02"), "files": {"tests/test_02.py": "def test_x():\n assert '02' == 'x' # stronger\n"},
|
|
582
|
-
"commit": "test: 02 stronger", "only": ["tests/test_02.py"]}
|
|
583
|
-
rig = Inside(tmp_path, three()).run(plan(**{
|
|
584
|
-
"02/implementer": [CHEAT], "02/test-writer": [tw("02"), correction],
|
|
585
|
-
"02/reviewer": [review("02", [weak]), review("02")]}))
|
|
586
|
-
assert rig.code == 0, rig.ledger()
|
|
587
|
-
(restore,) = [gate for gate in rig.gates("fast") if subject(rig, gate["commit"]) == RESTORE]
|
|
588
|
-
assert restore["locked"] == "tests/test_02.py tests/test_01.py"
|
|
589
|
-
assert (rig.folder("02") / f"gate-fast-{restore['commit'][:7]}.log").exists()
|
|
590
|
-
assert not [gate for gate in rig.gates("full") if gate["commit"] == restore["commit"]]
|
|
591
|
-
|
|
592
|
-
|
|
593
556
|
def test_a_locked_path_with_whitespace_is_rejected_once_and_then_blocks(tmp_path):
|
|
594
557
|
spaced = {**tw("01"), "files": {"tests/test 01.py": "def test_x():\n assert 1 == 'x'\n"}}
|
|
595
558
|
spaced["report"] = {**spaced["report"], "files": ["tests/test 01.py"], "locked": ["tests/test 01.py"]}
|
|
596
559
|
rig = Inside(tmp_path).run(plan(**{"01/test-writer": [spaced, spaced]}))
|
|
597
560
|
error = ("locked path 'tests/test 01.py' contains whitespace: the fast gate gets the locked paths separated by "
|
|
598
561
|
"spaces, so rename the file")
|
|
599
|
-
assert blocked(rig) == f"Ticket 01: BLOCKED at the test-writer: {error}."
|
|
562
|
+
assert blocked(rig, code=2) == f"Ticket 01: BLOCKED at the test-writer: {error}."
|
|
600
563
|
first, second = rig.calls("01", "test-writer")
|
|
601
|
-
assert f"The
|
|
564
|
+
assert f"The earlier attempt did not finish the role: {error}" in second["prompt"]
|
|
602
565
|
assert not rig.calls("01", "implementer")
|
|
603
566
|
|
|
604
567
|
|
|
605
|
-
ADAPTED_01 = LOCKED_01 + "# adapted to the interface of 02\n"
|
|
606
|
-
ADAPTS = impl("02", files={"demo/export.py": "def fn_02():\n return '02'\n", "tests/test_01.py": ADAPTED_01})
|
|
607
|
-
RESTORE = "implement-spec: restore the locked files before the correction"
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
def writes(nn, text, subject):
|
|
611
|
-
"""A test-writer correction that writes tests/test_<nn>.py and lists it."""
|
|
612
|
-
return {**tw(nn), "files": {f"tests/test_{nn}.py": text}, "commit": subject}
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
def test_a_restored_locked_file_of_a_merged_ticket_that_fails_with_the_new_code_must_be_updated_by_the_correction(tmp_path):
|
|
616
|
-
"""Issue #90: ticket 02 changes an interface that the locked file of merged ticket 01 uses, and its implementer
|
|
617
|
-
adapts that file. The review finds the change, the driver puts the file back in a commit and gates it: red. The
|
|
618
|
-
correction gets that gate record, and a correction that leaves the file as it is is rejected."""
|
|
619
|
-
leaves = writes("02", "def test_x():\n assert '02' == 'x' # stronger\n", "test: 02 stronger")
|
|
620
|
-
updates = writes("01", ADAPTED_01, "test: 01 adapted to 02")
|
|
621
|
-
updates["report"] = {**updates["report"], "locked": ["tests/test_01.py", "tests/test_02.py"]} # both attempts' files
|
|
622
|
-
rig = Inside(tmp_path, three(), gate={"subjects": [RESTORE]}).run(
|
|
623
|
-
plan(**{"02/implementer": [ADAPTS], "02/test-writer": [tw("02"), leaves, updates]}))
|
|
624
|
-
assert rig.code == 0, rig.ledger()
|
|
625
|
-
assert rig.led("Ticket 02: critical finding of kind fixture from the driver at tests/test_01.py:1")
|
|
626
|
-
assert not rig.calls("02", "fixer")
|
|
627
|
-
(restore,) = [gate["commit"] for gate in rig.gates() if gate["exit"]]
|
|
628
|
-
first, second = rig.calls("02", "test-writer")[1:]
|
|
629
|
-
assert f".agent/implement/02/gate-fast-{restore[:7]}.log" in first["prompt"] and first["head"] == restore
|
|
630
|
-
assert "the gate is red on the restore commit" in second["prompt"] # the rejection of the first attempt
|
|
631
|
-
assert on_pr(rig, "tests/test_01.py") == ADAPTED_01 and "tests/test_01.py" in rig.state()["tickets"]["02"]["locked"]
|
|
632
|
-
|
|
633
|
-
|
|
634
568
|
ACCENT = "tests/tést.py"
|
|
635
569
|
|
|
636
570
|
|
|
@@ -639,92 +573,21 @@ def accented(tmp_path, name, **steps):
|
|
|
639
573
|
writer = tw("01")
|
|
640
574
|
writer["files"][ACCENT] = "def test_y():\n assert 1 == 'y'\n"
|
|
641
575
|
writer["report"]["locked"] += [ACCENT]
|
|
642
|
-
|
|
643
|
-
return Inside(under(tmp_path, name), three()).run(plan(**{"01/test-writer": [writer], "01/reviewer": proofs, **steps}))
|
|
576
|
+
return Inside(under(tmp_path, name), three()).run(plan(**{"01/test-writer": [writer], **steps}))
|
|
644
577
|
|
|
645
578
|
|
|
646
|
-
def
|
|
579
|
+
def test_a_locked_file_with_a_name_that_git_quotes_is_protected_for_its_ticket_and_a_later_one(tmp_path):
|
|
647
580
|
"""Review round 1, I2: the quoted form of the path matched nothing, so no check saw the file."""
|
|
648
581
|
own = impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n", ACCENT: WEAK})
|
|
649
|
-
rig = accented(tmp_path, "
|
|
650
|
-
assert rig.
|
|
651
|
-
assert "BLOCKED at fix round 1" in blocked(rig)
|
|
582
|
+
rig = accented(tmp_path, "own", **{"01/implementer": [own, own]})
|
|
583
|
+
assert rig.code == 2 and all(f"locked file changed: {ACCENT}" in line for line in attempts(rig, "01", "implementer"))
|
|
652
584
|
later = impl("02", files={"demo/export.py": "def fn_02():\n return '02'\n", ACCENT: WEAK})
|
|
653
|
-
rig = accented(tmp_path, "
|
|
585
|
+
rig = accented(tmp_path, "later", **{"02/implementer": [later, later]})
|
|
654
586
|
assert rig.state()["tickets"]["01"]["locked"] == ["tests/test_01.py", ACCENT], rig.ledger()
|
|
655
|
-
assert rig.code ==
|
|
587
|
+
assert rig.code == 2 and all(f"locked file changed: {ACCENT}" in line for line in attempts(rig, "02", "implementer"))
|
|
656
588
|
assert "assert 1 == 'y'" in on_pr(rig, ACCENT)
|
|
657
589
|
|
|
658
590
|
|
|
659
|
-
# ---------------------------------------------------------------- a ticket that must change a merged ticket's locked file
|
|
660
|
-
|
|
661
|
-
MERGED_LOCKED = "02-merged-locked-file"
|
|
662
|
-
LANDING_RESTORE = "implement-spec: restore the locked files of merged tickets before the landing"
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
def touches_01(n):
|
|
666
|
-
"""Fixer `n` of 02, which also changes tests/test_01.py, the locked file of merged ticket 01."""
|
|
667
|
-
return fix("02", n, files={"demo/export.py": f"def fn_02():\n return 'fix{n}'\n",
|
|
668
|
-
"tests/test_01.py": LOCKED_01 + f"# fix {n}\n"})
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
def changed_at_cap(tmp_path, name, files=None, gate=None):
|
|
672
|
-
"""Ticket 02 changes a merged ticket's locked file in its second fix. The finding is carried to the final
|
|
673
|
-
must-fix list, while the landing still requires a ruling about that file."""
|
|
674
|
-
steps = plan(**{"02/reviewer": [review("02", [STUCK])] * 2 + [review("02")],
|
|
675
|
-
"02/fixer": [fix("02", 1), touches_01(2)]})
|
|
676
|
-
rig = Inside(under(tmp_path, name), files or three(), gate=gate).run(steps, parallel="1")
|
|
677
|
-
assert rig.code == 2 and asked(rig) == {f"{MERGED_LOCKED}-1": ["restore", "adopt", "redesign"]}, rig.ledger()
|
|
678
|
-
return rig, steps
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
def test_an_accepted_change_to_a_merged_ticket_locked_file_asks_at_the_landing_and_restore_lands_it(tmp_path):
|
|
682
|
-
"""Issue #116, comment 1: `accept` sent the ticket to its landing, which the landing check refused with no
|
|
683
|
-
question, so no answer could merge it."""
|
|
684
|
-
rig, steps = changed_at_cap(tmp_path, "restore")
|
|
685
|
-
assert rig.code == 2 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
686
|
-
assert rig.led("Ticket 02: BLOCKED at the merge: locked file changed: tests/test_01.py.")
|
|
687
|
-
assert asked(rig) == {f"{MERGED_LOCKED}-1": ["restore", "adopt", "redesign"]}
|
|
688
|
-
question = [q for q in rig.state()["run"]["questions"] if q["answer"] is None][0]
|
|
689
|
-
assert question["recommended"] == "restore" and question["subject"] == "tests/test_01.py"
|
|
690
|
-
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=restore", parallel="1")
|
|
691
|
-
assert rig.code == 0, rig.ledger()
|
|
692
|
-
assert on_pr(rig, "tests/test_01.py") == LOCKED_01 and LANDING_RESTORE in rig.pr_subjects()
|
|
693
|
-
assert rig.led("Ticket 02: by the ruling (restore), the driver put back tests/test_01.py")
|
|
694
|
-
assert rig.state()["tickets"]["02"]["phase"] == "merged"
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
def test_adopt_lands_the_change_to_the_merged_ticket_locked_file_and_the_ticket_locks_it(tmp_path):
|
|
698
|
-
rig, steps = changed_at_cap(tmp_path, "adopt")
|
|
699
|
-
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=adopt", parallel="1")
|
|
700
|
-
assert rig.code == 0, rig.ledger()
|
|
701
|
-
assert on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 2\n"
|
|
702
|
-
assert "tests/test_01.py" in rig.state()["tickets"]["02"]["locked"] and rig.led("by the ruling (adopt)")
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
def test_redesign_keeps_the_ticket_blocked_at_its_landing(tmp_path):
|
|
706
|
-
rig, steps = changed_at_cap(tmp_path, "redesign")
|
|
707
|
-
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=redesign", parallel="1")
|
|
708
|
-
assert rig.code == 1 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
709
|
-
assert on_pr(rig, "tests/test_01.py") == LOCKED_01 and not asked(rig)
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
def test_a_restore_that_turns_the_merge_gate_red_is_taken_back_and_asks_again_without_restore(tmp_path):
|
|
713
|
-
"""The ticket's code needs its change to the file: the restore commit leaves the ticket branch and the question
|
|
714
|
-
comes back with the options left, so the stop still has an answer."""
|
|
715
|
-
two = {name: text for name, text in three().items() if not name.startswith("03")} # 02 lands as a fast-forward
|
|
716
|
-
rig, steps = changed_at_cap(tmp_path, "red", files=two, gate={"subjects": [LANDING_RESTORE]})
|
|
717
|
-
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=restore", parallel="1")
|
|
718
|
-
assert rig.code == 2 and rig.led("Ticket 02: BLOCKED at the merge: the full gate is red on"), rig.ledger()
|
|
719
|
-
assert asked(rig) == {f"{MERGED_LOCKED}-2": ["adopt", "redesign"]}
|
|
720
|
-
question = [q for q in rig.state()["run"]["questions"] if q["answer"] is None][0]
|
|
721
|
-
assert question["recommended"] == "adopt" and question["evidence"][0].endswith(".log")
|
|
722
|
-
fixer = rig.calls("02", "fixer")[-1]["sha"]
|
|
723
|
-
assert rig.state()["tickets"]["02"]["tip"] == fixer and on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
724
|
-
rig.run(steps, "--answer", f"{MERGED_LOCKED}-2=adopt", parallel="1")
|
|
725
|
-
assert rig.code == 0 and on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 2\n", rig.ledger()
|
|
726
|
-
|
|
727
|
-
|
|
728
591
|
# ---------------------------------------------------------------- the rounds
|
|
729
592
|
|
|
730
593
|
def test_two_rounds_then_blocked_with_the_escalation_at_round_2(tmp_path):
|
|
@@ -761,7 +624,7 @@ def test_a_fixer_with_nothing_to_change_is_accepted_and_the_same_tip_is_reviewed
|
|
|
761
624
|
def test_a_red_gate_on_a_fixer_commit_starts_the_next_round_with_the_record_as_evidence(tmp_path):
|
|
762
625
|
"""Issue 64: the gate of a fix round is red. That is a finding for the next round, not a BLOCKED ticket."""
|
|
763
626
|
rig = Inside(tmp_path, gate={"subjects": ["fix: 01 round 1"]})
|
|
764
|
-
rig.run(plan(**{"01/reviewer": [review("01", [STUCK]
|
|
627
|
+
rig.run(plan(**{"01/reviewer": [review("01", [STUCK]), review("01")],
|
|
765
628
|
"01/fixer": [fix("01", 1), fix("01", 2, files={"demo/other.py": "x = 1\n"})]}))
|
|
766
629
|
assert rig.code == 0, rig.ledger()
|
|
767
630
|
assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "reviewer", "fixer", "fixer",
|
|
@@ -773,9 +636,8 @@ def test_a_red_gate_on_a_fixer_commit_starts_the_next_round_with_the_record_as_e
|
|
|
773
636
|
assert gate["title"] == f"the fast gate is red on {first[:7]}" and record in gate["evidence"]
|
|
774
637
|
assert rig.led(f"Ticket 01: critical finding of kind code from the gate at {record}:0: the fast gate is red on {first[:7]}.")
|
|
775
638
|
assert "findings-1.json" in rig.prompt("fixer-2") and rig.state()["tickets"]["01"]["round"] == 2
|
|
776
|
-
# No review saw the red tip: the re-review covers both fixes
|
|
777
|
-
|
|
778
|
-
assert f"The fix is {rig.sha('01', 'implementer')}..{second}" in again and "demo/export.py:2" in again
|
|
639
|
+
# No review saw the red tip: the re-review covers both fixes.
|
|
640
|
+
assert f"The fix is {rig.sha('01', 'implementer')}..{second}" in rig.prompt("reviewer-2")
|
|
779
641
|
|
|
780
642
|
|
|
781
643
|
def test_a_red_gate_on_the_implementer_commit_starts_fix_round_1_with_the_record_as_evidence(tmp_path):
|
|
@@ -968,88 +830,79 @@ def test_the_escalation_takes_the_next_entry_of_the_list():
|
|
|
968
830
|
assert [driver_fixloop.entry(models, n) for n in (1, 2)] == ["a@low", "openai/b@low"]
|
|
969
831
|
|
|
970
832
|
|
|
971
|
-
def
|
|
972
|
-
"""A fixer that reports BLOCKED asks a `fixer-stopped` question: test_decisions covers it."""
|
|
833
|
+
def test_a_fixer_that_does_not_finish_blocks_the_ticket_with_its_round_to_run_again(tmp_path):
|
|
973
834
|
rig = Inside(tmp_path).run(plan(**{"01/reviewer": [review("01", [STUCK])], "01/fixer": [{}, {}]}))
|
|
974
835
|
entry = rig.state()["tickets"]["01"]
|
|
975
|
-
|
|
976
|
-
assert
|
|
836
|
+
assert rig.code == 2 and entry["phase"] == "blocked", rig.ledger()
|
|
837
|
+
assert rig.led("BLOCKED at fix round 1: report .agent/implement/01/fixer-1.json is not")
|
|
838
|
+
assert [q["id"] for q in rig.state()["run"]["questions"]] == ["01-ticket-blocked-1"]
|
|
839
|
+
assert entry["round"] == 0 and entry["tip"] == rig.sha("01", "implementer")
|
|
977
840
|
|
|
978
841
|
|
|
979
842
|
# ---------------------------------------------------------------- the reviewers' reports and the slot
|
|
980
843
|
|
|
981
|
-
|
|
982
|
-
rig = Inside(tmp_path).run(plan(**{"01/reviewer": [review("01", lines=())] * 2}))
|
|
983
|
-
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
984
|
-
assert rig.led("BLOCKED at the review: the reviewer: mutations: no mutation proof for the locked test file "
|
|
985
|
-
"tests/test_01.py.")
|
|
986
|
-
assert [q["id"] for q in rig.state()["run"]["questions"]] == ["01-review-rejected-1"]
|
|
987
|
-
assert "feat: 01 rows" not in rig.pr_subjects()
|
|
844
|
+
MANUAL = "scripts/test_e2e_manual.py"
|
|
988
845
|
|
|
989
846
|
|
|
990
|
-
def
|
|
991
|
-
"""
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
847
|
+
def manual(tmp_path, *writers, reviewer=None):
|
|
848
|
+
"""Ticket 14, whose only locked file is a manual end-to-end script that the gate does not run."""
|
|
849
|
+
rig = Inside(tmp_path, {"14-manual-e2e.md": ticket("14", "Manual e2e")})
|
|
850
|
+
return rig.run(plan(**{"14/test-writer": list(writers), "14/implementer": [impl("14")],
|
|
851
|
+
"14/reviewer": [reviewer or review("14")]}))
|
|
852
|
+
|
|
853
|
+
|
|
854
|
+
def writes_manual(red=f"FAILED {MANUAL}::test_x - AttributeError", **report):
|
|
855
|
+
step = tw("14")
|
|
856
|
+
step["files"] = {MANUAL: "def test_x():\n assert 14 == 'x'\n"}
|
|
857
|
+
step["stdout"] = f"FAILED {MANUAL}::test_x - AttributeError\n"
|
|
858
|
+
step["report"] = {**step["report"], "files": [MANUAL], "locked": [MANUAL],
|
|
859
|
+
"red": [{"test": f"{MANUAL}::test_x", "line": red}], **report}
|
|
860
|
+
return step
|
|
861
|
+
|
|
862
|
+
|
|
863
|
+
def test_a_full_review_with_no_mutation_proof_is_accepted_and_the_ticket_lands(tmp_path):
|
|
864
|
+
rig = manual(tmp_path, writes_manual())
|
|
865
|
+
assert rig.code == 0 and rig.state()["tickets"]["14"]["phase"] == "merged", rig.ledger()
|
|
866
|
+
assert len(rig.calls("14", "reviewer")) == 1 and rig.led("Ticket 14", "reviewer", "report accepted")
|
|
867
|
+
assert not rig.led("no mutation proof") and "feat: 14 rows" in rig.pr_subjects()
|
|
868
|
+
|
|
869
|
+
|
|
870
|
+
def test_a_leftover_mutations_field_whose_red_line_is_not_in_the_log_is_ignored(tmp_path):
|
|
871
|
+
leftover = review("14")
|
|
872
|
+
leftover["report"]["mutations"] = [{"test": "tests/test_csv.py::test_quote", "file": "csv.py", "line": 12,
|
|
873
|
+
"red": "AssertionError"}]
|
|
874
|
+
rig = manual(tmp_path, writes_manual(), reviewer=leftover)
|
|
875
|
+
assert rig.code == 0 and len(rig.calls("14", "reviewer")) == 1, rig.ledger()
|
|
876
|
+
assert not rig.led("red line not found")
|
|
877
|
+
|
|
878
|
+
|
|
879
|
+
def test_a_fixtures_field_is_ignored_and_a_red_line_not_in_the_log_is_still_rejected(tmp_path):
|
|
880
|
+
rig = manual(tmp_path, writes_manual(red="FAILED never printed", fixtures=["gh"]), writes_manual(fixtures=["gh"]))
|
|
1005
881
|
assert rig.code == 0, rig.ledger()
|
|
1006
|
-
|
|
1007
|
-
assert
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
assert
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
assert "fixtures: gh is not in `locked`" in driver_report.validate("test-writer", str(path), context)
|
|
1031
|
-
entry = {"test_writer_sha": None, "locked": ["tests/a.py", "gh", "fake"], "held": {}, "fixtures": ["gh", "fake"]}
|
|
1032
|
-
assert driver_review.written(".", entry, ["gh"], [], "tip")["fixtures"] == ["fake"]
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
def test_the_locked_file_rule_is_for_the_first_review_only(tmp_path):
|
|
1036
|
-
report = dict(status="DONE", commits=[], files=[], concerns=[], findings=[], mutations=[])
|
|
1037
|
-
path = tmp_path / "reviewer-0.json"
|
|
1038
|
-
path.write_text(json.dumps(report))
|
|
1039
|
-
repo = tmp_path / "repo"
|
|
1040
|
-
(repo / "tests").mkdir(parents=True)
|
|
1041
|
-
for name in ("a", "b"):
|
|
1042
|
-
(repo / f"tests/{name}.py").write_text("def test_x():\n pass\n")
|
|
1043
|
-
subprocess.run(["git", "init", "-q", "-b", "main", str(repo)], check=True)
|
|
1044
|
-
subprocess.run(["git", "-C", str(repo), "add", "-A"], check=True)
|
|
1045
|
-
subprocess.run([*GIT, "-C", str(repo), "commit", "-q", "-m", "tests"], check=True)
|
|
1046
|
-
context = {"repo": str(repo), "branch": "main", "start": "HEAD", "log": str(path),
|
|
1047
|
-
"locked": ["tests/a.py", "tests/b.py"]}
|
|
1048
|
-
assert driver_report.validate("reviewer", str(path), context) == []
|
|
1049
|
-
assert driver_report.validate("reviewer", str(path), {**context, "full": True}) == [
|
|
1050
|
-
"mutations: no mutation proof for the locked test file tests/a.py",
|
|
1051
|
-
"mutations: no mutation proof for the locked test file tests/b.py"]
|
|
1052
|
-
assert driver_report.validate("correctness", str(path), context) == []
|
|
882
|
+
first, second = rig.calls("14", "test-writer")
|
|
883
|
+
assert f"red line not found in log: {MANUAL}::test_x: FAILED never printed" in second["prompt"]
|
|
884
|
+
assert "red line not found" not in first["prompt"] and len(rig.calls("14", "test-writer")) == 2
|
|
885
|
+
assert "fixtures" not in rig.state()["tickets"]["14"]
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
def test_no_prompt_of_a_ticket_review_asks_for_a_mutation_proof(tmp_path):
|
|
889
|
+
rig = Inside(tmp_path, three())
|
|
890
|
+
rig.run(plan(**{"01/reviewer": [review("01", [STUCK]), review("01")], "01/fixer": [fix("01", 1)]}))
|
|
891
|
+
assert rig.code == 0 and len(rig.calls("01", "reviewer")) == 2, rig.ledger()
|
|
892
|
+
prompts = [call["prompt"] for nn in ("01", "02") for call in rig.calls(nn, "reviewer")]
|
|
893
|
+
assert len(prompts) == 3 and not [prompt for prompt in prompts if "mutation" in prompt.lower()]
|
|
894
|
+
again = rig.prompt("reviewer-1")
|
|
895
|
+
assert "This is the re-review after fix round 1" in again and "proof" not in again
|
|
896
|
+
assert not [line for line in again.splitlines() if "demo/export.py:" in line]
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
def test_the_test_writer_rewrites_a_test_that_is_green_before_any_implementation(tmp_path):
|
|
900
|
+
rig = Inside(tmp_path, ONE).run(plan())
|
|
901
|
+
assert rig.code == 0, rig.ledger()
|
|
902
|
+
writer, reviewer = rig.prompt("test-writer-0"), rig.prompt("reviewer-0")
|
|
903
|
+
assert "A test that is green before any implementation is not a proof. Rewrite it until it fails.\n" in writer
|
|
904
|
+
assert "mutation" not in writer.lower() and "mutation" not in reviewer.lower()
|
|
905
|
+
assert "Run again" not in reviewer
|
|
1053
906
|
|
|
1054
907
|
|
|
1055
908
|
def test_a_timed_out_read_only_role_is_restored_only_when_no_other_agent_is_in_the_slot(tmp_path):
|
|
@@ -1057,7 +910,7 @@ def test_a_timed_out_read_only_role_is_restored_only_when_no_other_agent_is_in_t
|
|
|
1057
910
|
tip = subprocess.run(["git", "-C", str(rig.repo), "rev-parse", "HEAD"], capture_output=True, text=True).stdout.strip()
|
|
1058
911
|
(rig.repo / "junk.txt").write_text("x\n")
|
|
1059
912
|
context, shared = {"repo": str(rig.repo), "branch": "feat/csv", "start": tip}, lambda: False
|
|
1060
|
-
assert "first revert each edit of the earlier attempt" in driver_run._timeout_lines("
|
|
913
|
+
assert "first revert each edit of the earlier attempt" in driver_run._timeout_lines("reviewer", 45, context, shared)
|
|
1061
914
|
assert (rig.repo / "junk.txt").exists()
|
|
1062
915
|
assert "in the tree: continue from it" in driver_run._timeout_lines("fixer", 60, context, shared) and (rig.repo / "junk.txt").exists()
|
|
1063
916
|
# `--only reviewer`: one agent
|
|
@@ -1232,32 +1085,6 @@ def test_a_reviewer_that_times_out_starts_again_from_the_clean_tip(tmp_path):
|
|
|
1232
1085
|
assert "in the tree" not in second["prompt"] and second["prompt"].rstrip().endswith("one ref store.")
|
|
1233
1086
|
|
|
1234
1087
|
|
|
1235
|
-
# ---------------------------------------------------------------- mutation proofs
|
|
1236
|
-
|
|
1237
|
-
def test_a_re_review_names_only_the_proofs_the_fix_made_due(tmp_path):
|
|
1238
|
-
first = test_review.edit(test_review.LONG, l12="v12 = 'a'", l30="v30 = 'a'")
|
|
1239
|
-
rig = test_review.scoped(tmp_path, (12, 30), [first, test_review.edit(first, l30="v30 = 'b'")], (30,))
|
|
1240
|
-
assert rig.code == 0, rig.ledger()
|
|
1241
|
-
assert "no proof is due): demo/export.py:12 demo/export.py:30\n" in rig.prompt("reviewer-1")
|
|
1242
|
-
assert "no proof is due): demo/export.py:30\n" in rig.prompt("reviewer-2")
|
|
1243
|
-
old, new = rig.sha("01", "implementer"), rig.calls("01", "fixer")[0]["sha"]
|
|
1244
|
-
assert f"The fix is {old}..{new}: check only whether your own critical or important findings" in rig.prompt("reviewer-1")
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
def test_a_proof_follows_its_line_through_inserts_and_deletes(tmp_path):
|
|
1248
|
-
lines = test_review.LONG.splitlines(keepends=True)
|
|
1249
|
-
moved = "".join(lines[:19] + ["i1 = 1\n", "i2 = 2\n"] + lines[19:29] + ["v30 = 'changed'\n"] + lines[30:])
|
|
1250
|
-
rig = test_review.scoped(tmp_path, (12, 30, 35), [moved], (32,))
|
|
1251
|
-
assert rig.code == 0, rig.ledger()
|
|
1252
|
-
assert "no proof is due): demo/export.py:32\n" in rig.prompt("reviewer-1")
|
|
1253
|
-
# (first old line, old count, first new line, new count): lines 3-4 deleted, 10-11 replaced by one line.
|
|
1254
|
-
hunks = [(3, 2, 2, 0), (10, 2, 8, 1), (20, 0, 18, 3)]
|
|
1255
|
-
assert [driver_review._follow(line, hunks) for line in (2, 3, 4, 5, 10, 11, 12, 20, 21)] == [
|
|
1256
|
-
(2, False), (2, True), (2, True), (3, False), (8, True), (8, True), (9, False), (17, False), (21, False)]
|
|
1257
|
-
repo, old, new = str(rig.repo), rig.sha("01", "implementer"), rig.calls("01", "fixer")[0]["sha"]
|
|
1258
|
-
assert driver_review.follow(repo, old, new, {("demo/export.py", 30), ("demo/export.py", 35), ("gone.py", 4)}) == {
|
|
1259
|
-
("demo/export.py", 32): True, ("demo/export.py", 37): False, ("gone.py", 4): False}
|
|
1260
|
-
|
|
1261
1088
|
|
|
1262
1089
|
# ---------------------------------------------------------------- conflict agent
|
|
1263
1090
|
|
|
@@ -1274,43 +1101,80 @@ def test_a_conflict_is_resolved_once_in_the_ticket_slot_and_a_second_one_blocks(
|
|
|
1274
1101
|
assert len(again.calls("01", "conflict")) == 1
|
|
1275
1102
|
|
|
1276
1103
|
|
|
1277
|
-
def conflict(tmp_path, resolve):
|
|
1278
|
-
"""01 and 03 both add demo/cli.py and 03 merges first (as test_review.conflicted); `resolve` is 01's conflict step
|
|
1279
|
-
|
|
1104
|
+
def conflict(tmp_path, resolve, then=None, models=None, base=None, **more):
|
|
1105
|
+
"""01 and 03 both add demo/cli.py and 03 merges first (as test_review.conflicted); `resolve` is 01's conflict step,
|
|
1106
|
+
`then` its rerun (`resolve` again by default), `base` files on the PR branch before the run, `more` other steps."""
|
|
1107
|
+
rig = Inside(tmp_path, {k: v for k, v in three().items() if not k.startswith("02")}, models=models)
|
|
1108
|
+
for path, text in (base or {}).items():
|
|
1109
|
+
on_base(rig, path, text)
|
|
1280
1110
|
one = impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n", "demo/cli.py": test_review.cli("one")})
|
|
1281
|
-
rig.steps = plan(**{"01/test-writer": [{**tw("01"), "touch": ["s1"]}], "01/conflict": [resolve, resolve],
|
|
1111
|
+
rig.steps = plan(**{"01/test-writer": [{**tw("01"), "touch": ["s1"]}], "01/conflict": [resolve, then or resolve],
|
|
1282
1112
|
"03/implementer": [{**impl("03", "demo/cli.py", test_review.cli("three")), "wait": ["s1"]}],
|
|
1283
|
-
"01/implementer": [{**one, "wait_pr_moves": True}]})
|
|
1113
|
+
"01/implementer": [{**one, "wait_pr_moves": True}], **more})
|
|
1284
1114
|
return rig.run(rig.steps)
|
|
1285
1115
|
|
|
1286
1116
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1117
|
+
RESOLVED = {"status": "DONE", "commits": ["$SHA"], "files": ["demo/cli.py"], "concerns": []}
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
def test_a_conflict_resolution_that_changes_its_own_locked_file_is_rejected_twice_and_blocks(tmp_path):
|
|
1289
1121
|
rig = conflict(tmp_path, {"files": {"demo/cli.py": test_review.cli("resolved"), "tests/test_01.py": "# weaker\n"},
|
|
1290
|
-
"commit": "merge: resolve cli", "report":
|
|
1291
|
-
assert
|
|
1292
|
-
|
|
1293
|
-
assert
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
assert rig.
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
assert
|
|
1307
|
-
assert on_pr(rig, "
|
|
1122
|
+
"commit": "merge: resolve cli", "report": RESOLVED})
|
|
1123
|
+
assert rig.code == 2 and all(CHANGED_01 in line for line in attempts(rig, "01", "conflict")), rig.ledger()
|
|
1124
|
+
(question,) = rig.state()["run"]["questions"]
|
|
1125
|
+
assert question["kind"] == "ticket-blocked" and CHANGED_01 in question["subject"]
|
|
1126
|
+
assert len(rig.calls("01", "conflict")) == 2 and rig.tip() == rig.sha("03", "implementer")
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
def test_a_conflict_resolution_that_changes_a_locked_file_of_a_merged_ticket_is_rejected_and_runs_on_its_second_entry(tmp_path):
|
|
1130
|
+
locked_03 = tw("03")["files"]["tests/test_03.py"]
|
|
1131
|
+
weakens = {"files": {"demo/cli.py": test_review.cli("resolved"), "tests/test_03.py": WEAK},
|
|
1132
|
+
"commit": "merge: resolve cli", "report": RESOLVED}
|
|
1133
|
+
puts_back = {"files": {"tests/test_03.py": locked_03}, "commit": "merge: put back tests/test_03.py", "report": RESOLVED}
|
|
1134
|
+
rig = conflict(tmp_path, weakens, puts_back, models=TWO)
|
|
1135
|
+
assert rig.code == 0, rig.ledger()
|
|
1136
|
+
first, second = attempts(rig, "01", "conflict")
|
|
1137
|
+
assert "locked file changed: tests/test_03.py" in first and second.endswith("report accepted.")
|
|
1138
|
+
assert entries(rig, "01", "conflict") == [OPUS_5_5, SONNET] and not rig.state()["run"]["questions"]
|
|
1139
|
+
assert on_pr(rig, "tests/test_03.py") == locked_03 and on_pr(rig, "demo/cli.py") == test_review.cli("resolved")
|
|
1140
|
+
|
|
1141
|
+
|
|
1142
|
+
def shared_01(takes):
|
|
1143
|
+
"""tests/test_01.py is on the PR branch: 01's test-writer changes its top and locks it; 03's test-writer changes its
|
|
1144
|
+
bottom, lists it and merges first. `takes` is the file 01's conflict agent leaves."""
|
|
1145
|
+
own, writer = tw("01"), tw("03")
|
|
1146
|
+
own["files"]["tests/test_01.py"] = LEDGER_01
|
|
1147
|
+
writer["files"]["tests/test_01.py"] = LEDGER_03
|
|
1148
|
+
writer["report"]["locked"] += ["tests/test_01.py"]
|
|
1149
|
+
resolve = {"files": {"demo/cli.py": test_review.cli("resolved"), "tests/test_01.py": takes},
|
|
1150
|
+
"commit": "merge: resolve cli", "report": RESOLVED}
|
|
1151
|
+
return resolve, {"01/test-writer": [{**own, "touch": ["s1"]}], "03/test-writer": [{**writer, "wait": ["s1"]}]}
|
|
1152
|
+
|
|
1153
|
+
|
|
1154
|
+
LEDGER_BOTH = LEDGER_01.replace("assert 5", "assert 5 == 5") # the clean three-way merge of LEDGER_01 and LEDGER_03
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
def test_a_conflict_resolution_that_takes_in_another_ticket_s_listed_change_to_its_own_locked_file_is_accepted(tmp_path):
|
|
1158
|
+
"""The clean three-way merge of 01's version and the PR tip's keeps both test-writers' tests."""
|
|
1159
|
+
resolve, writers = shared_01(LEDGER_BOTH)
|
|
1160
|
+
rig = conflict(tmp_path, resolve, base={"tests/test_01.py": LEDGER_BASE}, **writers)
|
|
1161
|
+
assert rig.code == 0 and not rig.led("locked file changed"), rig.ledger()
|
|
1162
|
+
assert on_pr(rig, "tests/test_01.py") == LEDGER_BOTH
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
def test_a_conflict_resolution_that_takes_the_pr_version_of_its_own_locked_file_is_rejected(tmp_path):
|
|
1166
|
+
"""The PR tip's version drops the change of 01's test-writer."""
|
|
1167
|
+
resolve, writers = shared_01(LEDGER_03)
|
|
1168
|
+
rig = conflict(tmp_path, resolve, base={"tests/test_01.py": LEDGER_BASE}, **writers)
|
|
1169
|
+
assert rig.code == 2 and all(CHANGED_01 in line for line in attempts(rig, "01", "conflict")), rig.ledger()
|
|
1170
|
+
assert on_pr(rig, "tests/test_01.py") == LEDGER_03
|
|
1308
1171
|
|
|
1309
1172
|
|
|
1310
1173
|
def test_a_conflict_agent_that_gives_up_leaves_no_open_merge_in_the_slot(tmp_path):
|
|
1311
1174
|
stuck = {"status": "BLOCKED", "commits": [], "files": [], "concerns": ["both sides are needed"]}
|
|
1312
1175
|
rig = conflict(tmp_path, {"files": {"demo/cli.py": "half\n"}, "report": stuck})
|
|
1313
|
-
assert "BLOCKED at the merge: the conflict agent:
|
|
1176
|
+
assert rig.code == 2 and rig.led("Ticket 01: BLOCKED at the merge: the conflict agent: it reported BLOCKED: both sides are needed.")
|
|
1177
|
+
assert len(rig.calls("01", "conflict")) == 2
|
|
1314
1178
|
git = lambda *args: subprocess.run(["git", "-C", str(rig.repo), *args], capture_output=True, text=True)
|
|
1315
1179
|
assert git("status", "--porcelain").stdout == "" and git("rev-parse", "-q", "--verify", "MERGE_HEAD").returncode
|
|
1316
1180
|
assert git("symbolic-ref", "--short", "HEAD").stdout.strip() == "feat/csv" # slot 1 is free again
|
|
@@ -1327,109 +1191,12 @@ def test_the_templates_of_the_new_roles_hold_a_valid_schema_and_end_with_the_rul
|
|
|
1327
1191
|
|
|
1328
1192
|
|
|
1329
1193
|
def test_no_template_names_the_ledger_and_the_method_of_step_6_is_in_the_reviewer_prompt():
|
|
1330
|
-
# The final
|
|
1194
|
+
# The final review gets the ledger as a pointer (requirement 19); no other prompt names it.
|
|
1195
|
+
final = ("final-reviewer.md", "final-lens.md", "lens-correctness.md")
|
|
1331
1196
|
for path in driver_report.PROMPTS.glob("*.md"):
|
|
1332
|
-
assert ("ledger" in path.read_text().lower()) == (path.name
|
|
1197
|
+
assert ("ledger" in path.read_text().lower()) == (path.name in final), path.name
|
|
1333
1198
|
reviewer = (driver_report.PROMPTS / "reviewer.md").read_text()
|
|
1334
|
-
|
|
1335
|
-
"a later round repeats it only when that line changed.",
|
|
1336
|
-
"Run again each mutation that the test-writer report names in `concerns`."):
|
|
1337
|
-
assert sentence in reviewer, sentence
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
def test_the_correctness_prompt_keeps_the_agent_off_the_tree_the_reviewer_edits():
|
|
1341
|
-
text = (driver_report.PROMPTS / "correctness.md").read_text()
|
|
1342
|
-
assert "Read file content from git at {start_sha}" in text and "never from the working tree" in text
|
|
1343
|
-
assert "run no tests" in text
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
def test_the_correctness_pass_reads_the_untracked_inputs_of_the_driver_from_the_working_tree(tmp_path):
|
|
1347
|
-
"""Issue 66: the ticket and the findings files are in the ignored .agent/, so git at the tip has none of them."""
|
|
1348
|
-
rig = Inside(tmp_path, RISKY, {"correctness": [SOL, OPUS], "implementer": [OPUS]})
|
|
1349
|
-
rig.run(plan(**{"02/correctness": [correct([finding("C-IMPORTANT")])], "02/fixer": [fix("02", 1)]}))
|
|
1350
|
-
assert rig.code == 0, rig.ledger()
|
|
1351
|
-
again = rig.prompt("correctness-1", "02")
|
|
1352
|
-
inputs = (".agent/tickets/02-quote-fields.md", ".agent/implement/02/findings-0.json")
|
|
1353
|
-
assert all(path in again for path in inputs), again
|
|
1354
|
-
tracked = subprocess.run(["git", "-C", str(rig.repo), "ls-files", *inputs], capture_output=True, text=True).stdout
|
|
1355
|
-
assert tracked == ""
|
|
1356
|
-
assert "read the spec, the ticket and the findings file from the working tree" in again
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
def test_the_correctness_prompt_carries_the_checks_of_a_review_diff_in_a_gitignored_directory(tmp_path, monkeypatch):
|
|
1360
|
-
"""Issue #120: a project-local install is ignored, and the pass may read neither the tree nor git for it."""
|
|
1361
|
-
rig = Inside(tmp_path, RISKY, {"correctness": [SOL, OPUS], "implementer": [OPUS]}, ignore=".my-skills/")
|
|
1362
|
-
checks = rig.repo / ".my-skills/review-diff/correctness.md"
|
|
1363
|
-
checks.parent.mkdir(parents=True)
|
|
1364
|
-
checks.write_text("# Correctness reviewer\n\n| Check | Flag |\n|---|---|\n| Ledger | A row booked twice. |\n")
|
|
1365
|
-
monkeypatch.setattr(driver_review, "CORRECTNESS", checks)
|
|
1366
|
-
rig.run(plan())
|
|
1367
|
-
assert rig.code == 0, rig.ledger()
|
|
1368
|
-
ignored = subprocess.run(["git", "-C", str(rig.repo), "check-ignore", "-q", str(checks)])
|
|
1369
|
-
assert ignored.returncode == 0
|
|
1370
|
-
assert "| Ledger | A row booked twice. |" in rig.prompt("correctness-0", "02")
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
STOPPED = "02-review-stopped-1"
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
def stuck(role, status="NEEDS_CONTEXT"):
|
|
1377
|
-
"""A review step whose report stops: BLOCKED or NEEDS_CONTEXT, with no finding."""
|
|
1378
|
-
step = review("02") if role == "reviewer" else correct()
|
|
1379
|
-
step["report"] = {**step["report"], "status": status, "concerns": ["the checks file is absent"]}
|
|
1380
|
-
return step
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
def risky(tmp_path):
|
|
1384
|
-
return Inside(tmp_path, RISKY, {"correctness": [SOL, OPUS], "implementer": [OPUS]})
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
@pytest.mark.parametrize("role", ["reviewer", "correctness"])
|
|
1388
|
-
def test_a_review_that_reports_needs_context_asks_the_operator_and_retry_resumes_it(tmp_path, role):
|
|
1389
|
-
"""Issue #120: a stopped reviewer or correctness pass was a dead end with no question."""
|
|
1390
|
-
steps = plan(**{f"02/{role}": [stuck(role)]})
|
|
1391
|
-
rig = risky(tmp_path)
|
|
1392
|
-
rig.run(steps)
|
|
1393
|
-
assert rig.code == 2 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
1394
|
-
assert rig.led(f"BLOCKED at the review: the {role}: the {role} reported NEEDS_CONTEXT: the checks file is absent.")
|
|
1395
|
-
(question,) = rig.state()["run"]["questions"]
|
|
1396
|
-
assert (question["id"], question["recommended"]) == (STOPPED, "retry")
|
|
1397
|
-
assert [o["id"] for o in question["options"]] == ["retry", "accept", "redesign"]
|
|
1398
|
-
assert question["evidence"][0] == f".agent/implement/02/{role}-0.json"
|
|
1399
|
-
rig.run(steps, "--answer", f"{STOPPED}=retry")
|
|
1400
|
-
assert rig.code == 0 and rig.state()["tickets"]["02"]["phase"] == "merged", rig.ledger()
|
|
1401
|
-
assert len(rig.calls("02", role)) == 2
|
|
1402
|
-
assert rig.led(f"Ruling: 02 review runs again (retry): the {role} reported NEEDS_CONTEXT")
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
def test_an_accepted_review_stop_closes_the_review_with_the_other_reports(tmp_path):
|
|
1406
|
-
steps = plan(**{"02/correctness": [stuck("correctness", "BLOCKED")] * 2,
|
|
1407
|
-
"02/reviewer": [review("02"), review("02", [finding("R-IMPORTANT")]), review("02")],
|
|
1408
|
-
"02/fixer": [fix("02", 1)]})
|
|
1409
|
-
rig = risky(tmp_path)
|
|
1410
|
-
rig.run(steps)
|
|
1411
|
-
assert rig.code == 2, rig.ledger()
|
|
1412
|
-
rig.run(steps, "--answer", f"{STOPPED}=accept")
|
|
1413
|
-
assert rig.code == 0 and rig.state()["tickets"]["02"]["phase"] == "merged", rig.ledger()
|
|
1414
|
-
# The reviewer's finding still gets its fix round; the stopped pass does not stop the ticket again.
|
|
1415
|
-
assert rig.state()["tickets"]["02"]["round"] == 1 and len(rig.calls("02", "correctness")) == 3
|
|
1416
|
-
assert rig.led("the correctness reported BLOCKED: the checks file is absent", "goes on with the other reports")
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
def test_a_review_stop_answered_redesign_keeps_the_ticket_blocked(tmp_path):
|
|
1420
|
-
steps = plan(**{"02/correctness": [stuck("correctness")]})
|
|
1421
|
-
rig = risky(tmp_path)
|
|
1422
|
-
rig.run(steps)
|
|
1423
|
-
assert rig.code == 2, rig.ledger()
|
|
1424
|
-
rig.run(steps, "--answer", f"{STOPPED}=redesign")
|
|
1425
|
-
assert rig.code == 1 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
1426
|
-
assert len(rig.calls("02", "correctness")) == 1
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
def test_the_reviewer_schema_asks_for_one_proof_for_each_locked_test_file_in_the_first_review():
|
|
1430
|
-
"""Issue 66: a first review with no proof for a locked test file costs a rerun."""
|
|
1431
|
-
description = driver_report.schema("reviewer")["properties"]["mutations"]["description"]
|
|
1432
|
-
assert "each locked test file" in description and "`<locked file>::<test name>`" in description
|
|
1199
|
+
assert "Test each suspicion that the ticket names in its Suspicions line." in reviewer
|
|
1433
1200
|
|
|
1434
1201
|
|
|
1435
1202
|
def test_git_identity_is_not_needed_to_open_the_merge_for_the_conflict_agent(tmp_path):
|