@jesdi/skills 0.0.86 → 0.0.88
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/package.json +1 -1
- package/skills/implement-spec/ARCHITECTURE.md +33 -14
- package/skills/implement-spec/README.md +30 -15
- package/skills/implement-spec/SKILL.md +1 -1
- package/skills/implement-spec/driver.py +3 -2
- package/skills/implement-spec/driver_agents.py +93 -32
- package/skills/implement-spec/driver_decisions.py +3 -2
- package/skills/implement-spec/driver_dispute.py +82 -57
- package/skills/implement-spec/driver_fixloop.py +18 -21
- package/skills/implement-spec/driver_legacy.py +31 -2
- package/skills/implement-spec/driver_report.py +13 -3
- package/skills/implement-spec/driver_run.py +23 -13
- package/skills/implement-spec/driver_state.py +9 -8
- package/skills/implement-spec/driver_summary.py +8 -1
- package/skills/implement-spec/prompts/correction.md +1 -0
- package/skills/implement-spec/prompts/reviewer.md +3 -3
- package/skills/implement-spec/prompts/ruled.md +1 -1
- package/skills/implement-spec/tests/conftest.py +2 -0
- package/skills/implement-spec/tests/test_agents.py +56 -5
- package/skills/implement-spec/tests/test_arbitration.py +104 -11
- package/skills/implement-spec/tests/test_decisions.py +7 -5
- package/skills/implement-spec/tests/test_driver.py +2 -1
- package/skills/implement-spec/tests/test_fixloop.py +3 -3
- package/skills/implement-spec/tests/test_legacy.py +27 -0
- package/skills/implement-spec/tests/test_lenses.py +10 -5
- package/skills/implement-spec/tests/test_models.py +74 -0
- package/skills/implement-spec/tests/test_state.py +1 -1
- package/skills/implement-spec/tests/test_summary.py +8 -0
- package/skills/test-weigh-in/dashboard.html +70 -17
- package/skills/test-weigh-in/tests/browser_driver.py +46 -5
- package/skills/test-weigh-in/tests/layout_page.py +7 -3
- package/skills/test-weigh-in/tests/overlap_page.py +3 -0
- package/skills/test-weigh-in/tests/rules_fixture.py +1 -1
- package/skills/test-weigh-in/tests/test_coverage_run.py +5 -1
- package/skills/test-weigh-in/tests/test_dashboard_layout.py +50 -9
- package/skills/test-weigh-in/tests/test_score.py +53 -2
- package/skills/test-weigh-in/weigh.py +2 -2
- package/skills/test-weigh-in/weigh_coverage.py +22 -2
- package/skills/test-weigh-in/weigh_dashboard.py +51 -10
- package/skills/test-weigh-in/weigh_score.py +6 -3
- package/skills/test-weigh-in/weigh_smells.py +3 -2
- package/skills-manifest.json +3 -3
|
@@ -192,14 +192,16 @@ def test_help_lists_the_timeout_flag_and_default_minutes():
|
|
|
192
192
|
|
|
193
193
|
|
|
194
194
|
@pytest.mark.parametrize("entry", ["openai/gpt-sol@medium"])
|
|
195
|
-
def
|
|
195
|
+
def test_openai_implementer_launches_codex_exec_with_full_access_so_it_can_commit(env, entry):
|
|
196
|
+
# workspace-write keeps .git read-only, even with --add-dir on the git directory: git commit fails there.
|
|
196
197
|
w = World(env, refactor=True, implementer=[entry, entry]) # the rerun after no report is on the next entry
|
|
197
198
|
w.run(runner=False)
|
|
198
199
|
argv = launches(w.tmp, "codex")[0]
|
|
199
200
|
assert argv[0] == "exec" and "--ephemeral" not in argv
|
|
200
201
|
assert value_after(argv, "--model", "-m") == "gpt-sol"
|
|
201
202
|
assert any("model_reasoning_effort" in a and "medium" in a for a in argv)
|
|
202
|
-
assert value_after(argv, "--sandbox", "-s") == "
|
|
203
|
+
assert value_after(argv, "--sandbox", "-s") == "danger-full-access"
|
|
204
|
+
assert "--json" in argv, "the log carries the token usage that prices the run"
|
|
203
205
|
assert not launches(w.tmp, "claude")
|
|
204
206
|
|
|
205
207
|
|
|
@@ -210,6 +212,7 @@ def test_the_reviewer_launches_codex_exec_read_only(env):
|
|
|
210
212
|
assert argv[0] == "exec" and "--ephemeral" not in argv
|
|
211
213
|
assert value_after(argv, "--sandbox", "-s") == "read-only"
|
|
212
214
|
assert value_after(argv, "--model", "-m") == "gpt-sol"
|
|
215
|
+
assert "--json" in argv
|
|
213
216
|
|
|
214
217
|
|
|
215
218
|
@pytest.mark.parametrize("writes", ["file", "message"])
|
|
@@ -339,16 +342,18 @@ def test_a_model_the_account_cannot_use_is_skipped_and_its_roles_go_on_with_thei
|
|
|
339
342
|
|
|
340
343
|
|
|
341
344
|
def test_a_cli_that_fails_with_no_report_stops_the_run_with_exit_4_and_the_same_command_resumes(env):
|
|
345
|
+
"""Stop and ask: the first CLI failure stops the run, with no rerun on another entry of the list."""
|
|
342
346
|
w = World(env, refactor=True)
|
|
343
|
-
plan = {"implementer": [{"stderr": REFUSED + "\n", "exit": 1}
|
|
347
|
+
plan = {"implementer": [{"stderr": REFUSED + "\n", "exit": 1}, impl()]}
|
|
344
348
|
proc = w.run(plan)
|
|
349
|
+
assert len(w.calls("implementer")) == 1, "no rerun after a CLI failure"
|
|
345
350
|
assert proc.returncode == 4, proc.stdout + proc.stderr
|
|
346
|
-
assert f"implement-spec: the run stopped: the implementer on
|
|
351
|
+
assert f"implement-spec: the run stopped: the implementer on anthropic/claude-opus-5@medium exited 1 with no " \
|
|
347
352
|
f"report: {REFUSED}" in proc.stdout.splitlines(), proc.stdout
|
|
348
353
|
assert "BLOCKED" not in w.ledger() and "Ticket 01: the run stops and the phase stays for the next run: the implementer" in w.ledger()
|
|
349
354
|
assert json.loads((w.repo / ".agent/implement/state.json").read_text())["tickets"]["01"]["phase"] == "implement"
|
|
350
355
|
ok(w.run(plan))
|
|
351
|
-
assert len(w.calls("implementer")) ==
|
|
356
|
+
assert len(w.calls("implementer")) == 2
|
|
352
357
|
|
|
353
358
|
|
|
354
359
|
def test_finished_status_reruns_the_implementer_once_with_the_error_appended(env):
|
|
@@ -452,3 +457,49 @@ def test_log_next_to_report_and_ledger_records_role_entry_duration_and_cost(env)
|
|
|
452
457
|
assert "OUT-MARK" in log and "ERR-MARK" in log and (folder / "implementer-0.json").exists()
|
|
453
458
|
(line,) = [l for l in w.ledger().splitlines() if "implementer" in l and "claude-opus-5@medium" in l]
|
|
454
459
|
assert re.search(r"\d+(\.\d+)?s\b", line) and "0.4242" in line, line
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
def turn(used, cached, out):
|
|
463
|
+
return json.dumps({"type": "turn.completed", "usage": {"input_tokens": used, "cached_input_tokens": cached,
|
|
464
|
+
"output_tokens": out, "reasoning_output_tokens": 0}})
|
|
465
|
+
|
|
466
|
+
|
|
467
|
+
def test_a_codex_agent_is_priced_from_its_token_usage_at_the_list_price_of_its_model(env):
|
|
468
|
+
astra = "openai/gpt-6-astra@medium"
|
|
469
|
+
w = World(env, refactor=True, implementer=[astra])
|
|
470
|
+
# Two turns: 1.2M input of which 0.4M cached, 10k output. At 10 / 1 / 50 USD per million: 8 + 0.4 + 0.5.
|
|
471
|
+
ok(w.run({"implementer": [impl(stdout=turn(700_000, 300_000, 4_000) + "\n" + turn(500_000, 100_000, 6_000) + "\n")]}))
|
|
472
|
+
(line,) = [l for l in w.ledger().splitlines() if "implementer ran on" in l]
|
|
473
|
+
assert f"implementer ran on {astra} for " in line and ", cost 8.9 USD: report accepted." in line, line
|
|
474
|
+
(agent,) = [a for a in json.loads((w.repo / ".agent/implement/state.json").read_text())["run"]["agents"]
|
|
475
|
+
if a["role"] == "implementer"]
|
|
476
|
+
assert agent["cost"] == 8.9
|
|
477
|
+
assert agent["tokens"] == {"input": 1_200_000, "cached_input": 400_000, "output": 10_000}
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
def test_a_codex_model_with_no_list_price_keeps_its_tokens_and_the_ledger_says_it_is_not_priced(env):
|
|
481
|
+
w = World(env, refactor=True, implementer=["openai/gpt-sol@medium"])
|
|
482
|
+
ok(w.run({"implementer": [impl(stdout=turn(1_000, 200, 30) + "\n")]}))
|
|
483
|
+
(line,) = [l for l in w.ledger().splitlines() if "implementer ran on" in l]
|
|
484
|
+
assert ", 1000 input tokens (200 cached) and 30 output tokens, not priced: report accepted." in line, line
|
|
485
|
+
(agent,) = [a for a in json.loads((w.repo / ".agent/implement/state.json").read_text())["run"]["agents"]
|
|
486
|
+
if a["role"] == "implementer"]
|
|
487
|
+
assert agent["cost"] is None and agent["tokens"] == {"input": 1_000, "cached_input": 200, "output": 30}
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
@pytest.mark.parametrize("line", ['{"type": "error", "message": "You\'ve hit your usage limit."}',
|
|
491
|
+
'{"type": "turn.failed", "error": {"message": "You\'ve hit your usage limit."}}'])
|
|
492
|
+
def test_the_last_words_of_a_codex_json_log_are_its_error_message(tmp_path, line):
|
|
493
|
+
sys.path.insert(0, str(SKILL))
|
|
494
|
+
import driver_agents
|
|
495
|
+
log = tmp_path / "agent.log"
|
|
496
|
+
log.write_text('{"type": "thread.started"}\n' + line + "\n")
|
|
497
|
+
assert driver_agents.last_words(log) == "You've hit your usage limit."
|
|
498
|
+
|
|
499
|
+
|
|
500
|
+
def test_a_turn_with_no_usage_counts_no_token(tmp_path):
|
|
501
|
+
sys.path.insert(0, str(SKILL))
|
|
502
|
+
import driver_agents
|
|
503
|
+
log = tmp_path / "agent.log"
|
|
504
|
+
log.write_text('{"type": "turn.completed"}\n' + turn(10, 4, 2) + "\n")
|
|
505
|
+
assert driver_agents.tokens(log) == {"input": 10, "cached_input": 4, "output": 2}
|
|
@@ -73,9 +73,9 @@ def test_a_test_ruled_wrong_gets_one_correction_with_the_ruling_then_the_impleme
|
|
|
73
73
|
assert ".agent/implement/01/ruled-1.json" in fixed["prompt"] and again["head"] == fixed["sha"]
|
|
74
74
|
assert "R3 says single quotes" in again["prompt"]
|
|
75
75
|
entry = rig.state()["tickets"]["01"]
|
|
76
|
-
assert entry["disputes"][
|
|
77
|
-
assert entry["corrected"] == {
|
|
78
|
-
|
|
76
|
+
assert entry["disputes"][TEST]["ruling"] == "test-wrong" and entry["test_writer_sha"] == fixed["sha"]
|
|
77
|
+
assert entry["corrected"] == {TEST: {"test": TEST, "requirement": "R3", "reason": "R3 says single quotes"}}
|
|
78
|
+
assert entry["settled"] == 1
|
|
79
79
|
assert rig.led("the reviewer ruled test-wrong on the locked test tests/test_01.py::test_x, R3")
|
|
80
80
|
|
|
81
81
|
|
|
@@ -116,7 +116,7 @@ def test_a_dispute_on_another_locked_file_is_arbitrated_too(tmp_path):
|
|
|
116
116
|
ruling("code-wrong", "R4 says y is a column", f"{OTHER}::test_y", "R4"),
|
|
117
117
|
review("01")]})
|
|
118
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"]) == {
|
|
119
|
+
assert len(arbitrations(rig)) == 2 and set(rig.state()["tickets"]["01"]["disputes"]) == {TEST, f"{OTHER}::test_y"}
|
|
120
120
|
assert (rig.folder() / "arbitration-2.json").exists()
|
|
121
121
|
|
|
122
122
|
|
|
@@ -149,7 +149,9 @@ def test_the_summary_keeps_its_table_and_counts_an_arbitration_as_a_reviewer_age
|
|
|
149
149
|
rows = (rig.repo / ".agent/implement/summary.md").read_text().split("| Measure | Value |\n|---|---|\n")[1]
|
|
150
150
|
names = re.findall(r"^\| (.+?) \|", rows, re.M)
|
|
151
151
|
assert {f"wall time, {role}" for role in ("test-writer", "implementer", "reviewer", "fixer")} < set(names), rows
|
|
152
|
-
|
|
152
|
+
# Most fake agents report no cost, so they are counted as not priced.
|
|
153
|
+
assert names[-4:] == ["fix rounds per ticket", "human stops", "cost", "agents not priced"], rows
|
|
154
|
+
assert re.search(r"^\| cost \| \d+\.\d\d USD \|$", rows, re.M), rows
|
|
153
155
|
for row in ("| fast gates run | 2 |", "| full gates run | 1 |", "| agents, reviewer on anthropic/claude-opus-5@medium | 3 |",
|
|
154
156
|
"| fix rounds per ticket | 01: 1, 02: 0 |", "| human stops | 1 |"):
|
|
155
157
|
assert row in rows, rows
|
|
@@ -180,7 +182,7 @@ def test_a_second_dispute_on_the_same_test_asks_spec_ambiguous_with_both_reading
|
|
|
180
182
|
|
|
181
183
|
|
|
182
184
|
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")
|
|
185
|
+
stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
|
|
184
186
|
rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")], "01/test-writer": [tw("01"), correction()],
|
|
185
187
|
"01/reviewer": [ruling("test-wrong", "R3 says single quotes"), review("01", [stale])]})
|
|
186
188
|
assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
|
|
@@ -190,7 +192,7 @@ def test_after_a_correction_a_review_finding_on_the_test_asks_spec_ambiguous(tmp
|
|
|
190
192
|
|
|
191
193
|
|
|
192
194
|
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")
|
|
195
|
+
stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
|
|
194
196
|
rig = run(tmp_path, {"01/test-writer": [tw("01"), correction()],
|
|
195
197
|
"01/reviewer": [review("01", [stale, STUCK]), ruling("test-wrong", "R3 says single quotes")],
|
|
196
198
|
"01/fixer": [disputes(role="fixer")]})
|
|
@@ -201,18 +203,109 @@ def test_a_test_ruled_wrong_that_a_review_corrected_before_asks_spec_ambiguous(t
|
|
|
201
203
|
|
|
202
204
|
|
|
203
205
|
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")
|
|
206
|
+
stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
|
|
205
207
|
steps = plan(**{"01/test-writer": [tw("01"), correction()],
|
|
206
208
|
"01/reviewer": [review("01", [stale, STUCK]), ruling("test-wrong", "R3 says single quotes"),
|
|
207
209
|
review("01", [STUCK]), ruling("test-wrong", "R3 says single quotes")],
|
|
208
210
|
"01/fixer": [disputes(role="fixer"), disputes(role="fixer")]})
|
|
209
211
|
rig = Inside(tmp_path, ONE).run(steps)
|
|
210
|
-
assert rig.state()["tickets"]["01"]["disputes"][
|
|
212
|
+
assert rig.state()["tickets"]["01"]["disputes"][TEST]["ruling"] == "test-wrong", rig.ledger()
|
|
211
213
|
rig.run(steps, "--answer", f"{AMBIGUOUS}=keep-test")
|
|
212
214
|
assert rig.code == 2 and len(arbitrations(rig)) == 1, rig.ledger()
|
|
213
215
|
assert [q["id"] for q in asked(rig)] == ["01-spec-ambiguous-2"]
|
|
214
216
|
|
|
215
217
|
|
|
218
|
+
# ---------------------------------------------------------------- per test, not per file
|
|
219
|
+
|
|
220
|
+
TEST_Y = "tests/test_01.py::test_y"
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
def test_a_dispute_of_another_test_in_a_corrected_file_is_arbitrated_and_corrected_with_no_question(tmp_path):
|
|
224
|
+
"""The cv-tailoring run asked 02-spec-ambiguous-1 here: test_x was corrected, then test_y of its file disputed."""
|
|
225
|
+
rig = run(tmp_path, {"01/implementer": [disputes(), disputes((TEST_Y, "a dict has no .body")), impl("01")],
|
|
226
|
+
"01/test-writer": [tw("01"), correction(), correction(CORRECTED + "def test_y():\n pass\n")],
|
|
227
|
+
"01/reviewer": [ruling("test-wrong", "R3 says single quotes"),
|
|
228
|
+
ruling("test-wrong", "a dict has no .body", TEST_Y, "R5"), review("01")]})
|
|
229
|
+
assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
|
|
230
|
+
assert roles(rig) == ["test-writer", "implementer", "arbitration", "test-writer", "implementer", "arbitration",
|
|
231
|
+
"test-writer", "implementer", "reviewer"]
|
|
232
|
+
entry = rig.state()["tickets"]["01"]
|
|
233
|
+
assert set(entry["disputes"]) == set(entry["corrected"]) == {TEST, TEST_Y}
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
WEAK_Y = {**finding("WEAK", "critical", kind="test", file="tests/test_01.py"), "test": TEST_Y}
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
@pytest.mark.parametrize("found", [finding("MISSING", "critical", kind="test", file="tests/test_01.py"), WEAK_Y],
|
|
240
|
+
ids=["missing-test", "another-test"])
|
|
241
|
+
def test_a_review_finding_after_a_correction_of_another_test_gets_a_correction_with_no_question(tmp_path, found):
|
|
242
|
+
"""The cv-tailoring run asked 01-spec-ambiguous-2 here: a review asked for missing tests in a corrected file."""
|
|
243
|
+
rig = run(tmp_path, {"01/implementer": [disputes(), impl("01")],
|
|
244
|
+
"01/test-writer": [tw("01"), correction(), correction(CORRECTED + "def test_z():\n pass\n")],
|
|
245
|
+
"01/reviewer": [ruling("test-wrong", "R3 says single quotes"), review("01", [found]),
|
|
246
|
+
review("01")]})
|
|
247
|
+
assert rig.code == 0 and not rig.state()["run"]["questions"], rig.ledger()
|
|
248
|
+
assert roles(rig) == ["test-writer", "implementer", "arbitration", "test-writer", "implementer", "reviewer",
|
|
249
|
+
"test-writer", "reviewer"]
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def missing(n):
|
|
253
|
+
"""A review finding that asks for the missing test `n` of tests/test_01.py."""
|
|
254
|
+
return finding(f"MISSING-{n}", "critical", kind="test", file="tests/test_01.py")
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def test_the_ticket_asks_spec_ambiguous_once_its_locked_tests_were_settled_three_times(tmp_path):
|
|
258
|
+
"""A test added is never corrected twice, so a cap bounds the review that keeps asking for one more."""
|
|
259
|
+
steps = {"01/test-writer": [tw("01"), *[correction(f"# added {n}\n") for n in range(1, 4)]],
|
|
260
|
+
"01/reviewer": [review("01", [missing(n)]) for n in range(1, 5)] + [review("01")]}
|
|
261
|
+
rig = run(tmp_path, steps)
|
|
262
|
+
assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 4, rig.ledger()
|
|
263
|
+
(question,) = asked(rig)
|
|
264
|
+
assert question["id"] == AMBIGUOUS and "3 times" in question["subject"] and "MISSING-4" in question["subject"]
|
|
265
|
+
assert rig.state()["tickets"]["01"]["settled"] == 3
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def test_disputes_of_new_tests_reach_the_cap_too_and_the_next_one_asks_with_no_arbitration(tmp_path):
|
|
269
|
+
names = ["test_x", "test_y", "test_z", "test_w"]
|
|
270
|
+
rig = run(tmp_path, {"01/implementer": [disputes((f"tests/test_01.py::{name}", "no")) for name in names],
|
|
271
|
+
"01/reviewer": [ruling("code-wrong", "R3 holds", f"tests/test_01.py::{name}")
|
|
272
|
+
for name in names[:3]]})
|
|
273
|
+
assert rig.code == 2 and len(arbitrations(rig)) == 3, rig.ledger()
|
|
274
|
+
(question,) = asked(rig)
|
|
275
|
+
assert "tests/test_01.py::test_w" in question["subject"] and "3 times" in question["subject"]
|
|
276
|
+
assert rig.state()["tickets"]["01"]["settled"] == 3
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def test_a_missing_test_asked_for_again_after_its_correction_asks_spec_ambiguous(tmp_path):
|
|
280
|
+
rig = run(tmp_path, {"01/test-writer": [tw("01"), correction("# added\n")],
|
|
281
|
+
"01/reviewer": [review("01", [missing(1)])] * 2})
|
|
282
|
+
assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
|
|
283
|
+
(question,) = asked(rig)
|
|
284
|
+
subject = question["subject"]
|
|
285
|
+
assert "the first reading: MISSING-1" in subject and "the second reading: MISSING-1" in subject
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
def test_a_fixture_finding_that_names_no_test_is_corrected_once_per_file(tmp_path):
|
|
289
|
+
stale = finding("STALE", kind="fixture", file="tests/test_01.py")
|
|
290
|
+
rig = run(tmp_path, {"01/test-writer": [tw("01"), correction("# fixed\n")],
|
|
291
|
+
"01/reviewer": [review("01", [stale])] * 2})
|
|
292
|
+
assert rig.code == 2 and len(rig.calls("01", "test-writer")) == 2, rig.ledger()
|
|
293
|
+
assert [q["id"] for q in asked(rig)] == [AMBIGUOUS]
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def test_keep_test_on_a_missing_test_closes_that_request_only(tmp_path):
|
|
297
|
+
steps = plan(**{"01/test-writer": [tw("01"), *[correction(f"# added {n}\n") for n in range(1, 4)]],
|
|
298
|
+
"01/reviewer": [review("01", [missing(n)]) for n in range(1, 5)] +
|
|
299
|
+
[review("01", [missing(4), WEAK_Y])]})
|
|
300
|
+
rig = Inside(tmp_path, ONE).run(steps)
|
|
301
|
+
assert [q["id"] for q in asked(rig)] == [AMBIGUOUS], rig.ledger()
|
|
302
|
+
rig.run(steps, "--answer", f"{AMBIGUOUS}=keep-test")
|
|
303
|
+
assert rig.code == 2 and rig.led("MISSING-4", "closed as it is by the ruling (keep-test)"), rig.ledger()
|
|
304
|
+
(question,) = asked(rig)
|
|
305
|
+
assert question["id"] == "01-spec-ambiguous-2" and "WEAK" in question["subject"]
|
|
306
|
+
assert "MISSING-4" not in question["subject"]
|
|
307
|
+
|
|
308
|
+
|
|
216
309
|
# ---------------------------------------------------------------- the answers
|
|
217
310
|
|
|
218
311
|
def test_keep_test_runs_the_implementer_again_and_keeps_the_record(tmp_path):
|
|
@@ -241,7 +334,7 @@ def test_correct_test_corrects_to_the_second_reading_then_the_implementer_runs_a
|
|
|
241
334
|
assert wanted["evidence"] == "correct the test to the second reading: the example in R3 uses '"
|
|
242
335
|
assert rig.calls("01", "implementer")[2]["head"] == fixed["sha"]
|
|
243
336
|
assert [q["id"] for q in asked(rig)] == ["01-spec-ambiguous-2"]
|
|
244
|
-
assert set(rig.state()["tickets"]["01"]["disputes"]) == {
|
|
337
|
+
assert set(rig.state()["tickets"]["01"]["disputes"]) == {TEST}
|
|
245
338
|
|
|
246
339
|
|
|
247
340
|
def test_correct_test_after_a_fixer_s_dispute_runs_the_fixer_of_that_round_again_after_the_correction(tmp_path):
|
|
@@ -269,7 +362,7 @@ def test_edit_spec_keeps_the_ticket_blocked_with_the_ruling_and_runs_no_agent(tm
|
|
|
269
362
|
|
|
270
363
|
|
|
271
364
|
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")
|
|
365
|
+
stale = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": TEST}
|
|
273
366
|
steps = plan(**{"01/test-writer": [tw("01"), correction()], "01/fixer": [fix("01", 1)],
|
|
274
367
|
"01/reviewer": [review("01", [stale]), review("01", [stale]), review("01", [stale, STUCK]),
|
|
275
368
|
review("01")]})
|
|
@@ -10,6 +10,7 @@ import driver_answers
|
|
|
10
10
|
import driver_decisions
|
|
11
11
|
import driver_report
|
|
12
12
|
import driver_review_page
|
|
13
|
+
import driver_state
|
|
13
14
|
from test_cli import git, ticket
|
|
14
15
|
from test_fixloop import Inside, inside # noqa: F401 (the autouse fixture puts the rig's CLIs on PATH)
|
|
15
16
|
from test_tidy import Inside as Pushing, tools # noqa: F401 (an unattended run pushes: the rig with an origin and a fake gh)
|
|
@@ -141,7 +142,7 @@ def as_schema_3(rig, **question):
|
|
|
141
142
|
"""Make the run of `rig` one that a schema 3 driver left, its one question changed by `question`."""
|
|
142
143
|
path = rig.repo / ".agent/implement/state.json"
|
|
143
144
|
state = json.loads(path.read_text())
|
|
144
|
-
assert state["run"]["schema"] ==
|
|
145
|
+
assert state["run"]["schema"] == driver_state.SCHEMA, "a new run writes the current schema"
|
|
145
146
|
state["run"]["schema"] = 3
|
|
146
147
|
state["run"]["questions"][0].update(question)
|
|
147
148
|
path.write_text(json.dumps(state))
|
|
@@ -167,7 +168,7 @@ def test_an_older_run_keeps_the_ruling_of_an_answered_question_of_a_removed_kind
|
|
|
167
168
|
state["tickets"]["01"]["phase"] = "implement" # what the older driver's `retry` did
|
|
168
169
|
(rig.repo / ".agent/implement/state.json").write_text(json.dumps(state))
|
|
169
170
|
rig.run(run, *UNATTENDED)
|
|
170
|
-
assert rig.code == 0 and rig.state()["run"]["schema"] ==
|
|
171
|
+
assert rig.code == 0 and rig.state()["run"]["schema"] == driver_state.SCHEMA, rig.ledger()
|
|
171
172
|
sentence = f"Ruling: 01 review runs again (retry): the implementer: it reported BLOCKED: {STOP}." # the older driver's
|
|
172
173
|
assert f"## Rulings\n\n- {sentence}\n" in rig.prs()[0]["body"]
|
|
173
174
|
assert rig.state()["run"]["questions"][0]["ruling"] == sentence
|
|
@@ -230,9 +231,10 @@ def test_only_an_implementer_or_a_fixer_blocked_on_the_contradiction_concern_dis
|
|
|
230
231
|
f"{contra} test_01.py::test_x[a]: R3", f"{contra} b::c", contra]}
|
|
231
232
|
locked = ["tests/test_01.py", "src/test_01.py", "tests/b"]
|
|
232
233
|
assert driver_report.disputes("fixer", report, locked) == [
|
|
233
|
-
("tests/test_01.py", "tests/test_01.py::test_x", "why"
|
|
234
|
-
("tests/b", "b::c", ""), ("", "", "")]
|
|
235
|
-
assert driver_report.disputes("fixer", report, locked[:1])[1] == (
|
|
234
|
+
("tests/test_01.py", "tests/test_01.py::test_x", "why", "tests/test_01.py::test_x"),
|
|
235
|
+
("", "test_01.py::test_x[a]", "R3", "::test_x"), ("tests/b", "b::c", "", "tests/b::c"), ("", "", "", "")]
|
|
236
|
+
assert driver_report.disputes("fixer", report, locked[:1])[1] == (
|
|
237
|
+
"tests/test_01.py", "test_01.py::test_x[a]", "R3", "tests/test_01.py::test_x")
|
|
236
238
|
assert driver_report.disputes("reviewer", report, locked) == []
|
|
237
239
|
assert driver_report.disputes("implementer", {**report, "status": "DONE"}, locked) == []
|
|
238
240
|
assert driver_report.disputes("implementer", {}, locked) == [], "a rejected report is no report"
|
|
@@ -343,7 +343,8 @@ def test_a_timeout_for_an_unknown_role_is_a_usage_error(repo):
|
|
|
343
343
|
|
|
344
344
|
def test_command_lines_per_provider():
|
|
345
345
|
assert driver_agents.command("implementer", "openai/gpt-sol@high", "r.json") == [
|
|
346
|
-
"codex", "exec", "--model", "gpt-sol", "-c", 'model_reasoning_effort="high"', "--sandbox",
|
|
346
|
+
"codex", "exec", "--json", "--model", "gpt-sol", "-c", 'model_reasoning_effort="high"', "--sandbox",
|
|
347
|
+
"danger-full-access"]
|
|
347
348
|
assert driver_agents.command("reviewer", "openai/gpt-sol@high", "r.json")[-4:] == [
|
|
348
349
|
"--sandbox", "read-only", "-o", "r.json.last"]
|
|
349
350
|
assert driver_agents.command("reviewer", "opus@low", "r.json")[:6] == [
|
|
@@ -132,7 +132,7 @@ def test_capped_regression_is_carried_through_the_final_fix_batch(tmp_path):
|
|
|
132
132
|
|
|
133
133
|
# ---------------------------------------------------------------- the locked files
|
|
134
134
|
|
|
135
|
-
STALE = finding("STALE", kind="fixture", file="tests/test_01.py")
|
|
135
|
+
STALE = {**finding("STALE", kind="fixture", file="tests/test_01.py"), "test": "tests/test_01.py::test_x"}
|
|
136
136
|
AMBIGUOUS_1 = "01-spec-ambiguous-1"
|
|
137
137
|
|
|
138
138
|
|
|
@@ -154,8 +154,8 @@ def test_a_locked_test_finding_that_comes_back_after_its_correction_asks_spec_am
|
|
|
154
154
|
"01/reviewer": [review("01", [STALE])] * 2 + [review("01")]})
|
|
155
155
|
rig = Inside(tmp_path).run(steps)
|
|
156
156
|
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
157
|
-
assert rig.led("BLOCKED at the review: the spec reads two ways on a locked test: tests/test_01.py: the
|
|
158
|
-
"reading: STALE: STALE; the second reading: STALE: STALE.")
|
|
157
|
+
assert rig.led("BLOCKED at the review: the spec reads two ways on a locked test: tests/test_01.py::test_x: the "
|
|
158
|
+
"first reading: STALE: STALE; the second reading: STALE: STALE.")
|
|
159
159
|
assert asked(rig) == {AMBIGUOUS_1: ["keep-test", "correct-test", "edit-spec"]}
|
|
160
160
|
(question,) = rig.state()["run"]["questions"]
|
|
161
161
|
assert question["recommended"] == "" and question["evidence"][0] == ".agent/implement/01/spec-ambiguous-1.json"
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""The names of a run, and the take-over of a run that an older driver started (driver_names, driver_legacy)."""
|
|
2
|
+
import json
|
|
2
3
|
import subprocess
|
|
3
4
|
|
|
5
|
+
import driver_dispute
|
|
4
6
|
import driver_legacy
|
|
5
7
|
import driver_state
|
|
6
8
|
from conftest import GIT
|
|
@@ -137,3 +139,28 @@ def test_the_lock_of_an_older_driver_is_shared_by_newer_drivers_and_excludes_an_
|
|
|
137
139
|
f"a driver of an older version runs in this repository: it holds the lock {tmp_path / 'implement-spec.lock'}. "
|
|
138
140
|
"Wait until it ends, then run the driver again."))
|
|
139
141
|
older.close()
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def test_resume_keys_the_rulings_and_corrections_of_a_schema_4_run_by_their_test(repo, tmp_path):
|
|
145
|
+
"""Schema 4 keyed them by the locked file; each record names its test, so the key moves to that test. A review
|
|
146
|
+
correction recorded only its file and is keyed by it, as a fixture finding that names no test is. The evidence
|
|
147
|
+
of each `spec-ambiguous` question of the ticket gets the key of its file's record, which `keep-test` closes."""
|
|
148
|
+
state, _, _ = older_run(repo, tmp_path)
|
|
149
|
+
ruled = {"test": "test_01.py::test_x[a]", "requirement": "R3", "ruling": "test-wrong", "reason": "r"}
|
|
150
|
+
by_file = {"test": "tests/test_02.py", "requirement": "", "reason": "STALE"}
|
|
151
|
+
evidence = tmp_path / ".agent/implement/01/spec-ambiguous-1.json"
|
|
152
|
+
evidence.parent.mkdir(parents=True, exist_ok=True)
|
|
153
|
+
evidence.write_text(json.dumps([{"file": "tests/test_01.py", "title": "t"}, {"file": "tests/test_02.py"}]))
|
|
154
|
+
question = {"ticket": "01", "kind": "spec-ambiguous", "answer": "keep-test", "evidence": [str(evidence)],
|
|
155
|
+
"subject": "s"}
|
|
156
|
+
gone = {**question, "evidence": [str(tmp_path / "gone.json")]}
|
|
157
|
+
edit(state, {"disputes": {"tests/test_01.py": ruled},
|
|
158
|
+
"corrected": {"tests/test_01.py": ruled, "tests/test_02.py": by_file}}, questions=[question, gone])
|
|
159
|
+
assert resume(state, tmp_path)[0] == []
|
|
160
|
+
entry = state.read()["tickets"]["01"]
|
|
161
|
+
assert entry["disputes"] == {"tests/test_01.py::test_x": ruled}
|
|
162
|
+
assert entry["corrected"] == {"tests/test_01.py::test_x": ruled, "tests/test_02.py": by_file}
|
|
163
|
+
assert entry["settled"] == 2 # one per record of schema 4: each was an arbitration or a correction
|
|
164
|
+
assert [one["key"] for one in json.loads(evidence.read_text())] == ["tests/test_01.py::test_x", "tests/test_02.py"]
|
|
165
|
+
assert driver_dispute.kept(state.read()["run"]["questions"][:1], "01") == {"tests/test_01.py::test_x",
|
|
166
|
+
"tests/test_02.py"}
|
|
@@ -109,12 +109,17 @@ def test_the_review_coverage_names_only_what_ran_so_an_undone_fallback_is_not_cl
|
|
|
109
109
|
|
|
110
110
|
# ---------------------------------------------------------------- input validation
|
|
111
111
|
|
|
112
|
-
def
|
|
112
|
+
def test_a_final_reviewer_list_with_no_entry_on_another_provider_runs_every_review_on_it_and_says_so(
|
|
113
|
+
tmp_path, monkeypatch):
|
|
114
|
+
"""Another provider for correctness is a preference: a config on one provider runs, and the ledger says so."""
|
|
115
|
+
monkeypatch.setattr(driver, "_preflight", lambda args, models: driver._checked(models))
|
|
116
|
+
monkeypatch.setattr(driver_agents, "_failures", lambda entries: {})
|
|
113
117
|
rig = rig_of(tmp_path, models={"implementer": [SONNET], "final-reviewer": [OPUS]}).run(plan())
|
|
114
|
-
assert rig.code ==
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
+
assert rig.code == 0, rig.out
|
|
119
|
+
said = (f"No final-reviewer entry is on another provider than {SONNET}: the correctness lens and the scoped review "
|
|
120
|
+
f"run on {OPUS}, the implementer's provider.")
|
|
121
|
+
assert rig.out.splitlines()[0] == said and rig.ledger()[0] == said
|
|
122
|
+
assert rig.led("End of run: final-correctness ran on", OPUS)
|
|
118
123
|
|
|
119
124
|
|
|
120
125
|
def test_without_the_deep_quality_review_skill_the_run_exits_3_before_any_agent(tmp_path, monkeypatch):
|
|
@@ -5,6 +5,7 @@ skill's models.json does not define stops the run before the preflight and befor
|
|
|
5
5
|
import json
|
|
6
6
|
import re
|
|
7
7
|
import subprocess
|
|
8
|
+
import sys
|
|
8
9
|
|
|
9
10
|
import pytest
|
|
10
11
|
|
|
@@ -94,3 +95,76 @@ def test_only_correctness_exits_3_as_an_unknown_role(env, tmp_path):
|
|
|
94
95
|
def test_the_skill_has_no_correctness_or_explorer_role():
|
|
95
96
|
assert not {"correctness", "explorer"} & models().keys()
|
|
96
97
|
assert not (SKILL / "prompts/correctness.md").exists()
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
# ---------------------------------------------------------------- the provider config files
|
|
101
|
+
|
|
102
|
+
OPUS, ASTRA, SOL = "claude-opus-5-5@medium", "openai/gpt-6-astra@medium", "openai/gpt-6.1-sol@medium"
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@pytest.fixture
|
|
106
|
+
def layers(tmp_path, monkeypatch):
|
|
107
|
+
"""A home config folder and a worktree; returns a writer of (the home file, the repo file)."""
|
|
108
|
+
sys.path.insert(0, str(SKILL))
|
|
109
|
+
import driver_agents
|
|
110
|
+
monkeypatch.setattr(driver_agents.shutil, "which", lambda cli: cli)
|
|
111
|
+
monkeypatch.setenv("XDG_CONFIG_HOME", str(tmp_path / "config"))
|
|
112
|
+
monkeypatch.chdir(tmp_path)
|
|
113
|
+
home, repo = tmp_path / "config/implement-spec/models.json", tmp_path / ".implement-spec/models.json"
|
|
114
|
+
|
|
115
|
+
def write(path, roles):
|
|
116
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
117
|
+
path.write_text(json.dumps(roles))
|
|
118
|
+
return path
|
|
119
|
+
return driver_agents, lambda roles: write(home, roles), lambda roles: write(repo, roles), tmp_path
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_the_home_file_replaces_the_lists_it_names_and_keeps_the_rest(layers):
|
|
123
|
+
driver_agents, home, _, _ = layers
|
|
124
|
+
home({"reviewer": [OPUS]})
|
|
125
|
+
loaded, errors = driver_agents.load_models(None)
|
|
126
|
+
assert errors == [] and loaded["reviewer"] == [OPUS] and loaded["implementer"] == models()["implementer"]
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def test_the_repo_file_wins_over_the_home_file_and_the_models_flag_wins_over_both(layers):
|
|
130
|
+
driver_agents, home, repo, tmp = layers
|
|
131
|
+
home({"reviewer": [OPUS], "fixer": [OPUS]})
|
|
132
|
+
repo({"reviewer": [ASTRA]})
|
|
133
|
+
loaded, errors = driver_agents.load_models(None)
|
|
134
|
+
assert errors == [] and loaded["reviewer"] == [ASTRA] and loaded["fixer"] == [OPUS]
|
|
135
|
+
flag = tmp / "flag.json"
|
|
136
|
+
flag.write_text(json.dumps({"reviewer": [SOL]}))
|
|
137
|
+
loaded, errors = driver_agents.load_models(str(flag))
|
|
138
|
+
assert errors == [] and loaded["reviewer"] == [SOL] and loaded["fixer"] == [OPUS]
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_an_error_in_a_config_file_names_that_file(layers):
|
|
142
|
+
driver_agents, home, repo, tmp = layers
|
|
143
|
+
home({"correctness": [OPUS]})
|
|
144
|
+
repo({"planner": [OPUS]})
|
|
145
|
+
_, errors = driver_agents.load_models(None)
|
|
146
|
+
assert errors[0] == f"correctness: the role was removed; delete its key from {tmp}/config/implement-spec/models.json"
|
|
147
|
+
assert errors[1].startswith("planner: unknown role (known: ") and errors[1].endswith(
|
|
148
|
+
"); delete its key from .implement-spec/models.json"), errors
|
|
149
|
+
(tmp / ".implement-spec/models.json").write_text("{not json")
|
|
150
|
+
_, errors = driver_agents.load_models(None)
|
|
151
|
+
assert errors[1].startswith(".implement-spec/models.json: JSONDecodeError("), errors
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_a_removed_role_in_the_repo_file_exits_3_naming_the_file_before_the_preflight(env, tmp_path):
|
|
155
|
+
repo = make_repo(tmp_path / "demo", three())
|
|
156
|
+
(repo / ".implement-spec").mkdir()
|
|
157
|
+
(repo / ".implement-spec/models.json").write_text(json.dumps({"correctness": [ASTRA]}))
|
|
158
|
+
proc = drive(env, repo, *RUNS)
|
|
159
|
+
assert proc.returncode == 3, proc.stdout + proc.stderr
|
|
160
|
+
assert ("correctness: the role was removed; delete its key from .implement-spec/models.json"
|
|
161
|
+
in proc.stdout.splitlines()), proc.stdout
|
|
162
|
+
assert not (tmp_path / "launched").exists(), "no preflight and no agent"
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
@pytest.mark.parametrize("content", ['{"reviewer": "openai/gpt-6-astra@medium"}', '{"reviewer": [1]}', "[]"])
|
|
166
|
+
def test_a_config_file_of_the_wrong_shape_is_an_error_naming_the_file(layers, content):
|
|
167
|
+
driver_agents, _, repo, _ = layers
|
|
168
|
+
repo({}).write_text(content)
|
|
169
|
+
_, errors = driver_agents.load_models(None)
|
|
170
|
+
assert len(errors) == 1 and errors[0].startswith(".implement-spec/models.json: "), errors
|
|
@@ -42,7 +42,7 @@ def test_start_keeps_a_recorded_run_and_adds_only_the_new_tickets(tmp_path):
|
|
|
42
42
|
assert again["tickets"]["01"]["phase"] == "merged" and again["tickets"]["01"]["landing"] is None
|
|
43
43
|
assert again["tickets"]["02"] == {
|
|
44
44
|
"phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": {"fast": [], "full": []}, "slot": None,
|
|
45
|
-
"note": "", "landing": None, "disputes": {}, "corrected": {}}
|
|
45
|
+
"note": "", "landing": None, "disputes": {}, "corrected": {}, "settled": 0}
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def test_verified_trusts_a_tip_only_while_it_is_on_the_ticket_branch(repo, tmp_path):
|
|
@@ -27,3 +27,11 @@ Ticket 03 is not merged: its phase is blocked.
|
|
|
27
27
|
| human stops | 1 |
|
|
28
28
|
| cost | 1.75 USD |
|
|
29
29
|
"""
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_an_agent_with_no_price_is_counted_apart_from_the_cost():
|
|
33
|
+
agents = [{"role": "reviewer", "entry": "openai/gpt-x@low", "seconds": 1, "cost": None},
|
|
34
|
+
{"role": "implementer", "entry": "opus@medium", "seconds": 1, "cost": 0.5}]
|
|
35
|
+
state = {"run": {"pr_branch": "feat/csv", "gates": {"fast": 0, "full": 0}, "stops": 0, "final": driver_state._final(),
|
|
36
|
+
"agents": agents}, "tickets": {}}
|
|
37
|
+
assert driver_summary.render(state).endswith("| cost | 0.50 USD |\n| agents not priced | 1 |\n")
|