@jesdi/skills 0.0.68 → 0.0.69

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.
@@ -7,11 +7,11 @@ Range: {pr_branch}...{branch}, with the ticket tip at {start_sha}
7
7
  Locked files: {locked}
8
8
  Test-writer report, when the ticket has a test-writer: {writer_report}
9
9
 
10
- Check the diff against the ticket and the spec, then for quality. Check that each criterion has a locked test. Test each suspicion that the ticket names in its Suspicions line.
10
+ Check the diff against the ticket and the spec. Put only an unmet ticket criterion or a regression of a merged ticket's behavior in `findings`; set `basis` to `criterion` or `regression` accordingly; put every other observation in `observations` for final review. A red gate is a finding made by the driver. Check that each criterion has a locked test. Test each suspicion that the ticket names in its Suspicions line.
11
11
  To make a mutation proof for a locked test, break the production line the test protects, run the test, print its failing output, then revert the edit. The end of this prompt names the proofs that this review needs. A test that stays green is a critical finding. Run again each mutation that the test-writer report names in `concerns`.
12
12
  A mutation proof is keyed to its test and its production line: a later round repeats it only when that line changed.
13
13
  In `mutations`, give for each proof the test as `<locked file>::<test name>`, the production file and line, and one failure line copied exactly from the output you printed.
14
- Give each finding a severity (critical, important or minor), the file and line, a title, the evidence, and a kind: `fixture` when a locked test encodes a stale path, format or setup detail; `test` when a test is weak or missing, as a locked test that stays green when you break the line it protects; `code` for anything else. The test-writer corrects each `fixture` finding and each critical or important `test` finding on a locked file, and the fixer gets the rest.
14
+ Give each finding and observation a severity (critical, important or minor), the file and line, a title, the evidence, and a kind: `fixture` when a locked test encodes a stale path, format or setup detail; `test` when a test is weak or missing, as a locked test that stays green when you break the line it protects; `code` for anything else. The test-writer corrects each `fixture` finding and each critical or important `test` finding on a locked file, and the fixer gets the rest.
15
15
  Do not commit and do not dispatch subagents. Leave the tree as you found it.
16
16
 
17
17
  Write one JSON report at {report}. When your sandbox is read-only, give the JSON as your whole final message and the driver saves it there. The report matches this schema:
@@ -24,7 +24,9 @@ Write one JSON report at {report}. When your sandbox is read-only, give the JSON
24
24
  "status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
25
25
  "files": {"type": "array", "items": {"type": "string"}},
26
26
  "concerns": {"type": "array", "items": {"type": "string"}},
27
- "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}}}},
27
+ "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}, "basis": {"enum": ["criterion", "regression"]}}}},
28
+ "observations": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}}}},
29
+ "regressions": {"description": "After a fix: new regressions introduced by that fix. Set basis to criterion when a ticket criterion fails, or regression when merged-ticket behavior fails.", "type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}, "basis": {"enum": ["criterion", "regression"]}}}},
28
30
  "mutations": {"description": "Required in a full review: one proof or more for each locked test file that the end of this prompt names (a locked fixture holds no test and needs none), with `test` as `<locked file>::<test name>`. A review scoped to a fix gives the proofs that it names.", "type": "array", "items": {"type": "object", "required": ["test", "file", "line", "red"], "properties": {"test": {"type": "string", "minLength": 1}, "file": {"type": "string", "minLength": 1}, "line": {"type": "integer"}, "red": {"type": "string", "minLength": 1}}}}
29
31
  }
30
32
  }
@@ -87,6 +87,10 @@ def models_file(tmp_path, **overrides):
87
87
  entries = {role: ["anthropic/claude-opus-5@medium"] for role in ROLES}
88
88
  entries["correctness"] = ["openai/gpt-sol@medium"]
89
89
  entries.update(overrides)
90
+ if len(entries["implementer"]) == 1:
91
+ first = entries["implementer"][0]
92
+ next_entry = "anthropic/claude-opus-5@medium" if first.startswith("openai/") else "openai/gpt-sol@medium"
93
+ entries["implementer"] = [first, next_entry]
90
94
  path = tmp_path / "models.json"
91
95
  path.write_text(json.dumps(entries))
92
96
  return path
@@ -228,6 +232,22 @@ def test_models_file_naming_a_provider_without_its_cli_exits_3(env, tmp_path):
228
232
  assert any("implementer" in l and "codex" in l for l in proc.stdout.splitlines())
229
233
 
230
234
 
235
+ def test_one_implementer_model_is_rejected_before_any_agent(env, tmp_path):
236
+ repo = make_repo(tmp_path / "demo", three())
237
+ models = models_file(tmp_path)
238
+ entries = json.loads(models.read_text())
239
+ entries["implementer"] = ["anthropic/claude-opus-5@medium"]
240
+ models.write_text(json.dumps(entries))
241
+ before = snapshot(repo)
242
+
243
+ proc = drive(env, repo, "--tickets", ".agent/tickets", "--gate", "make check", "--models", str(models),
244
+ "--dry-run")
245
+
246
+ assert proc.returncode == 3, proc.stdout + proc.stderr
247
+ assert "second implementer" in proc.stdout
248
+ assert_untouched(proc, repo, before, tmp_path)
249
+
250
+
231
251
  @pytest.mark.parametrize("link", ["directory", "file"])
232
252
  def test_valid_set_prints_frontier_width_and_dry_run_creates_nothing(env, tmp_path, link):
233
253
  repo = make_repo(tmp_path / "demo", three())
@@ -341,45 +341,7 @@ def test_a_locked_file_keeps_its_old_reference_until_a_test_writer_lists_it(repo
341
341
  assert [f["title"].split(":")[0] for f in driver_review.locked_findings(".", lost)] == ["locked file check failed"]
342
342
 
343
343
 
344
- # ---------------------------------------------------------------- open findings after round 4
345
-
346
- def test_round_4_findings_wait_for_every_answer_before_the_ticket_merges(tmp_path, capsys):
347
- rig = Inside(tmp_path, ONE)
348
- bad = review("01", [finding("STUCK-A", line=98), finding("STUCK-B", line=99)])
349
- rig.run(plan(**{"01/reviewer": [bad] * 5, "01/fixer": [fix("01", n) for n in (1, 2, 3, 4)]}))
350
- out = capsys.readouterr().out
351
- one, two = rig.state()["run"]["questions"]
352
- assert rig.code == 1 and (one["id"], two["id"]) == ("01-finding-1", "01-finding-2") and one["stop"] == two["stop"]
353
- assert one["subject"] == "STUCK-A (demo/export.py:98)" and one["evidence"][0] == ".agent/implement/01/findings-4.json"
354
- assert (rig.repo / one["evidence"][0]).exists() and "Question 01-finding-2: " in out and "split (recommended)" in out
355
-
356
- write_answers(rig, {"01-finding-1": "accept", "01-finding-1.note": "known limit", "01-finding-2.note": "?"})
357
- rig.run({})
358
- assert rig.code == 1 and rig.state()["tickets"]["01"]["phase"] == "blocked"
359
- assert rig.led("Ruling: 01 finding closed as it is (accept): STUCK-A (demo/export.py:98). Note of the operator: known limit")
360
- assert [q["id"] for q in decisions(rig)["questions"]] == ["01-finding-2"]
361
- # The file was written for the two questions: for the one that is left it is stale.
362
- rig.run({})
363
- assert rig.code == 1 and len(rig.led("Ruling")) == 1 and rig.led("is ignored: its revision")
364
- rig.run({}, "--answer", "01-finding-2=accept")
365
- assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged" and len(rig.calls("01", "fixer")) == 4
366
-
367
-
368
- def test_a_test_finding_after_round_4_is_a_question_and_accepting_every_question_merges(tmp_path):
369
- """Issue 84: after round 4 no test-writer correction runs. Its red locked tests would make `accept` a lie."""
370
- locks = {**tw("01"), "files": {"tests/test_01.py": "# red lock\n"}, "commit": "test: 01 lock"}
371
- rig = Inside(tmp_path, ONE, gate={"subjects": ["test: 01 lock"]})
372
- vacuous = finding("VACUOUS", "critical", kind="test", file="tests/test_01.py", line=1)
373
- last = review("01", [finding("STUCK"), vacuous])
374
- rig.run(plan(**{"01/test-writer": [tw("01"), locks], "01/reviewer": [review("01", [finding("STUCK")])] * 4 + [last],
375
- "01/fixer": [fix("01", n) for n in (1, 2, 3, 4)]}))
376
- assert rig.code == 1 and len(rig.calls("01", "test-writer")) == 1
377
- assert [q["subject"] for q in rig.state()["run"]["questions"]] == ["STUCK (demo/export.py:99)",
378
- "VACUOUS (tests/test_01.py:1)"]
379
- rig.run({}, "--answer", "01-finding-1=accept", "--answer", "01-finding-2=accept")
380
- assert rig.code == 0, rig.ledger()
381
- assert rig.state()["tickets"]["01"]["phase"] == "merged"
382
-
344
+ # ---------------------------------------------------------------- legacy finding-question decisions
383
345
 
384
346
  def test_one_answer_that_keeps_the_ticket_blocked_wins_over_an_accept():
385
347
  one = asked("finding", subject="A")
@@ -82,6 +82,7 @@ def test_models_file_checks_the_first_entry_of_each_role(repo, capsys, tmp_path,
82
82
  assert run(capsys, "--models", str(models)) == (
83
83
  3, "implementer: codex is not on PATH (model entry openai/gpt-sol@medium)\n"
84
84
  "fixer: model entry other/x@low names an unknown provider (known: anthropic, openai)\n"
85
+ "implementer: a second implementer model entry is required for fix round 2\n"
85
86
  "correctness: no entry of its list (openai/gpt-sol@medium) is on another provider than the implementer's "
86
87
  "first entry openai/gpt-sol@medium; the correctness pass never runs on the implementer's provider\n")
87
88
  # Requirement 2 names the first entry only: a later implementer entry whose CLI is missing is no error. For the
@@ -961,6 +962,7 @@ def test_the_preflight_asks_each_used_entry_once_and_names_each_cli_that_fails(t
961
962
  monkeypatch.setenv("PATH", f"{bin_dir}{os.pathsep}{os.environ['PATH']}")
962
963
  monkeypatch.setattr(driver_agents, "PREFLIGHT_MINUTES", 0.02)
963
964
  models, _ = driver_agents.load_models(None)
965
+ models["implementer"][1] = "openai/gpt-6.1-sol@medium"
964
966
  models["reviewer"] = ["openai/gpt-astra@medium"]
965
967
  assert driver_agents.used_entries(models) == ["claude-opus-5-5@medium", "claude-sonnet-5-5@medium",
966
968
  "openai/gpt-6-astra@medium", "openai/gpt-6.1-sol@medium",
@@ -34,7 +34,7 @@ import pytest
34
34
  from test_cli import SKILL, git, ticket
35
35
  from test_review import FABLE, HOOKED, ONE, OPUS, Review, finding, gate_rule, review
36
36
  from test_stops import UNATTENDED, decisions, stage
37
- from test_walk import impl, plan, tw
37
+ from test_walk import fix, impl, plan, tw
38
38
 
39
39
  SCOPED = HOOKED.replace('("reviewer", "correctness")', '("reviewer", "correctness", "final-reviewer")')
40
40
  RUNNER = SCOPED.replace(
@@ -297,6 +297,59 @@ def test_two_findings_make_one_fixer_batch_of_fix_commits_on_top_of_the_unchange
297
297
  assert ref(fixed.repo, "feat/csv~2") == reviewed
298
298
 
299
299
 
300
+ def test_green_ticket_carries_cap_finding_into_required_final_fix(tmp_path):
301
+ rig = Final(tmp_path, THREE, {"implementer": [OPUS, FABLE]})
302
+ recurring = review("02", [{**finding("MERGED-QUOTING-REGRESSION"), "basis": "regression"}])
303
+ scoped = final()
304
+ scoped["report"]["resolved_must_fix"] = ["MERGED-QUOTING-REGRESSION (demo/export.py:99)"]
305
+ batch = fixer(fn("02"), "restore quoting", ticket_of="02")
306
+ batch["report"]["addressed_must_fix"] = ["MERGED-QUOTING-REGRESSION (demo/export.py:99)"]
307
+ steps = plan(**{"02/reviewer": [recurring] * 3, "02/fixer": [fix("02", 1), fix("02", 2)],
308
+ "final/final-reviewer": [final(), scoped], "final/fixer": [batch]})
309
+
310
+ rig.run(steps)
311
+
312
+ assert rig.code == 0, rig.output()
313
+ assert rig.state()["tickets"]["02"]["phase"] == "merged"
314
+ assert not rig.state()["run"]["questions"]
315
+ assert "MERGED-QUOTING-REGRESSION" in rig.final_calls("fixer")[0]["prompt"]
316
+ assert len(rig.final_calls("fixer")) == 1
317
+
318
+
319
+ def test_unresolved_must_fix_cannot_be_accepted_or_published(tmp_path):
320
+ rig = Final(tmp_path, THREE, {"implementer": [OPUS, FABLE]})
321
+ recurring = review("02", [{**finding("MERGED-QUOTING-REGRESSION"), "basis": "regression"}])
322
+ batch = fixer(fn("02"), "attempt quoting fix", ticket_of="02")
323
+ batch["report"]["addressed_must_fix"] = ["MERGED-QUOTING-REGRESSION (demo/export.py:99)"]
324
+ steps = plan(**{"02/reviewer": [recurring] * 3, "02/fixer": [fix("02", 1), fix("02", 2)],
325
+ "final/final-reviewer": [final(), final(finding("MERGED-QUOTING-REGRESSION"))],
326
+ "final/fixer": [batch]})
327
+
328
+ rig.run(steps)
329
+
330
+ assert rig.code == 1, rig.output()
331
+ assert not rig.state()["run"]["questions"]
332
+ assert [item["title"] for item in rig.state()["run"]["final"]["open"]] == ["MERGED-QUOTING-REGRESSION"]
333
+ assert not rig.pushes() and not rig.prs()
334
+ rig.run(steps)
335
+ assert rig.code == 1 and len(rig.final_calls("fixer")) == 1
336
+ assert not rig.pushes() and not rig.prs()
337
+
338
+
339
+ def test_final_fix_batch_rejects_an_unaddressed_must_fix(tmp_path):
340
+ rig = Final(tmp_path, THREE, {"implementer": [OPUS, FABLE]})
341
+ recurring = review("02", [{**finding("MERGED-QUOTING-REGRESSION"), "basis": "regression"}])
342
+ steps = plan(**{"02/reviewer": [recurring] * 3, "02/fixer": [fix("02", 1), fix("02", 2)],
343
+ "final/final-reviewer": [final()],
344
+ "final/fixer": [fixer(fn("02"), "attempt quoting fix", ticket_of="02")]})
345
+
346
+ rig.run(steps)
347
+
348
+ assert rig.code == 1, rig.output()
349
+ assert not rig.pushes() and not rig.prs()
350
+ assert any("addressed_must_fix: missing MERGED-QUOTING-REGRESSION (demo/export.py:99)" in line for line in rig.ledger())
351
+
352
+
300
353
  def test_the_fixer_of_the_final_review_gets_the_gate_command_and_runs_it_before_it_reports(fixed):
301
354
  (batch,) = fixed.final_calls("fixer")
302
355
  gate_rule(batch["prompt"], str(fixed.rig / "gate"))
@@ -18,6 +18,7 @@ import driver_review
18
18
  import test_review
19
19
  from conftest import GIT
20
20
  from test_cli import three
21
+ from test_final import RUNNER, final, fixer, fn
21
22
  from test_review import FABLE, ONE, OPUS, RISKY, SOL, STUCK, correct, finding, fix, review
22
23
  from test_walk import impl, plan, tw
23
24
 
@@ -89,6 +90,24 @@ def test_a_risky_ticket_gets_both_agents_and_one_merged_findings_file(tmp_path):
89
90
  assert json.loads((rig.folder("02") / "findings-1.json").read_text()) == []
90
91
 
91
92
 
93
+ def test_capped_regression_is_carried_through_the_final_fix_batch(tmp_path):
94
+ rig = Inside(tmp_path, RISKY)
95
+ (rig.rig / "run-agent").write_text(RUNNER)
96
+ regression = {**finding("QUOTING-REGRESSION"), "basis": "regression"}
97
+ scoped = final()
98
+ scoped["report"]["resolved_must_fix"] = ["QUOTING-REGRESSION (demo/export.py:99)"]
99
+ batch = fixer(fn("02"), "restore quoted fields", ticket_of="02")
100
+ batch["report"]["addressed_must_fix"] = ["QUOTING-REGRESSION (demo/export.py:99)"]
101
+
102
+ rig.run(plan(**{"02/reviewer": [review("02", [regression])] * 3,
103
+ "02/fixer": [fix("02", 1), fix("02", 2)],
104
+ "final/final-reviewer": [final(), scoped], "final/fixer": [batch]}))
105
+
106
+ assert rig.code == 0, rig.ledger()
107
+ assert [item["title"] for item in rig.state()["run"]["final"]["must_fix"]] == ["QUOTING-REGRESSION"]
108
+ assert "QUOTING-REGRESSION" in rig.prompt("fixer-1", "final")
109
+
110
+
92
111
  def test_correctness_entry_is_the_first_of_another_provider_than_the_implementers():
93
112
  models = {"implementer": ["opus@medium"], "correctness": ["opus@high", "openai/a@low", "openai/b@low"]}
94
113
  assert driver_agents.correctness_entry(models) == "openai/a@low"
@@ -113,7 +132,7 @@ def test_a_changed_locked_file_is_fixed_before_a_fixture_finding_is_corrected(tm
113
132
  rig = Inside(tmp_path)
114
133
  locked = tw("01")["files"]
115
134
  cheat = impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n", "tests/test_01.py": "# edited\n"})
116
- stale = finding("STALE", "minor", kind="fixture", file="tests/test_01.py")
135
+ stale = finding("STALE", "important", kind="fixture", file="tests/test_01.py")
117
136
  correction = {**tw("01"), "files": {"tests/test_01.py": "# corrected\n"}, "commit": "test: 01 fixture fix"}
118
137
  rig.run(plan(**{"01/implementer": [cheat], "01/test-writer": [tw("01"), correction],
119
138
  "01/reviewer": [review("01", [stale]), review("01", [stale]), review("01")],
@@ -330,15 +349,15 @@ def test_a_fixer_that_reports_a_wrong_locked_test_opens_the_locked_test_question
330
349
 
331
350
  def test_the_fix_rounds_count_from_0_after_an_overruled_test(tmp_path):
332
351
  stuck = review("01", [STUCK])
333
- steps = plan(**{"01/reviewer": [stuck] * 5 + [review("01")],
334
- "01/fixer": [fix("01", 1), fix("01", 2), fix("01", 3), fixer_stops(), fix("01", 5)],
352
+ steps = plan(**{"01/reviewer": [stuck, stuck, review("01")],
353
+ "01/fixer": [fixer_stops(), fix("01", 1)],
335
354
  "01/test-writer": [tw("01"), OVERRULED], "01/implementer": [impl("01"), AGAIN]})
336
355
  rig = Inside(tmp_path).run(steps)
337
- assert rig.code == 2 and rig.state()["tickets"]["01"]["round"] == 4, rig.ledger()
356
+ assert rig.code == 2 and rig.state()["tickets"]["01"]["round"] == 1, rig.ledger()
338
357
  rig.run(steps, "--answer", "01-locked-test-1=overrule-test")
339
- # The corrected tests are a new contract: the first finding on them gets a fix round, not the round-4 stop.
358
+ # The corrected tests are a new contract: the first finding on them gets a fresh fix round.
340
359
  assert rig.code == 0, rig.ledger()
341
- assert rig.state()["tickets"]["01"]["round"] == 1 and not rig.led("after round 4")
360
+ assert rig.state()["tickets"]["01"]["round"] == 1 and not rig.led("after round 2")
342
361
 
343
362
 
344
363
  def test_a_fixture_correction_that_is_rejected_asks_the_operator(tmp_path):
@@ -583,21 +602,20 @@ def touches_01(n):
583
602
  "tests/test_01.py": LOCKED_01 + f"# fix {n}\n"})
584
603
 
585
604
 
586
- def changed_at_round_4(tmp_path, name, files=None, gate=None):
587
- """Ticket 02 whose fixer of round 4 changes the locked file of merged ticket 01: the review after it finds the
588
- change, and with no round left it is a `finding` question, which the operator accepts."""
589
- steps = plan(**{"02/reviewer": [review("02", [STUCK])] * 4 + [review("02")],
590
- "02/fixer": [fix("02", 1), fix("02", 2), fix("02", 3), touches_01(4)]})
605
+ def changed_at_cap(tmp_path, name, files=None, gate=None):
606
+ """Ticket 02 changes a merged ticket's locked file in its second fix. The finding is carried to the final
607
+ must-fix list, while the landing still requires a ruling about that file."""
608
+ steps = plan(**{"02/reviewer": [review("02", [STUCK])] * 2 + [review("02")],
609
+ "02/fixer": [fix("02", 1), touches_01(2)]})
591
610
  rig = Inside(under(tmp_path, name), files or three(), gate=gate).run(steps, parallel="1")
592
- assert rig.code == 1 and asked(rig) == {"02-finding-1": ["accept", "split", "redesign"]}, rig.ledger()
593
- assert rig.state()["run"]["questions"][0]["subject"].startswith("the ticket changed the locked file of a merged ticket")
594
- return rig.run(steps, "--answer", "02-finding-1=accept", parallel="1"), steps
611
+ assert rig.code == 2 and asked(rig) == {f"{MERGED_LOCKED}-1": ["restore", "adopt", "redesign"]}, rig.ledger()
612
+ return rig, steps
595
613
 
596
614
 
597
615
  def test_an_accepted_change_to_a_merged_ticket_locked_file_asks_at_the_landing_and_restore_lands_it(tmp_path):
598
616
  """Issue #116, comment 1: `accept` sent the ticket to its landing, which the landing check refused with no
599
617
  question, so no answer could merge it."""
600
- rig, steps = changed_at_round_4(tmp_path, "restore")
618
+ rig, steps = changed_at_cap(tmp_path, "restore")
601
619
  assert rig.code == 2 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
602
620
  assert rig.led("Ticket 02: BLOCKED at the merge: locked file changed: tests/test_01.py.")
603
621
  assert asked(rig) == {f"{MERGED_LOCKED}-1": ["restore", "adopt", "redesign"]}
@@ -611,15 +629,15 @@ def test_an_accepted_change_to_a_merged_ticket_locked_file_asks_at_the_landing_a
611
629
 
612
630
 
613
631
  def test_adopt_lands_the_change_to_the_merged_ticket_locked_file_and_the_ticket_locks_it(tmp_path):
614
- rig, steps = changed_at_round_4(tmp_path, "adopt")
632
+ rig, steps = changed_at_cap(tmp_path, "adopt")
615
633
  rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=adopt", parallel="1")
616
634
  assert rig.code == 0, rig.ledger()
617
- assert on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 4\n"
635
+ assert on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 2\n"
618
636
  assert "tests/test_01.py" in rig.state()["tickets"]["02"]["locked"] and rig.led("by the ruling (adopt)")
619
637
 
620
638
 
621
639
  def test_redesign_keeps_the_ticket_blocked_at_its_landing(tmp_path):
622
- rig, steps = changed_at_round_4(tmp_path, "redesign")
640
+ rig, steps = changed_at_cap(tmp_path, "redesign")
623
641
  rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=redesign", parallel="1")
624
642
  assert rig.code == 1 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
625
643
  assert on_pr(rig, "tests/test_01.py") == LOCKED_01 and not asked(rig)
@@ -629,7 +647,7 @@ def test_a_restore_that_turns_the_merge_gate_red_is_taken_back_and_asks_again_wi
629
647
  """The ticket's code needs its change to the file: the restore commit leaves the ticket branch and the question
630
648
  comes back with the options left, so the stop still has an answer."""
631
649
  two = {name: text for name, text in three().items() if not name.startswith("03")} # 02 lands as a fast-forward
632
- rig, steps = changed_at_round_4(tmp_path, "red", files=two, gate={"subjects": [LANDING_RESTORE]})
650
+ rig, steps = changed_at_cap(tmp_path, "red", files=two, gate={"subjects": [LANDING_RESTORE]})
633
651
  rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=restore", parallel="1")
634
652
  assert rig.code == 2 and rig.led("Ticket 02: BLOCKED at the merge: the gate is red on"), rig.ledger()
635
653
  assert asked(rig) == {f"{MERGED_LOCKED}-2": ["adopt", "redesign"]}
@@ -638,18 +656,18 @@ def test_a_restore_that_turns_the_merge_gate_red_is_taken_back_and_asks_again_wi
638
656
  fixer = rig.calls("02", "fixer")[-1]["sha"]
639
657
  assert rig.state()["tickets"]["02"]["tip"] == fixer and on_pr(rig, "tests/test_01.py") == LOCKED_01
640
658
  rig.run(steps, "--answer", f"{MERGED_LOCKED}-2=adopt", parallel="1")
641
- assert rig.code == 0 and on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 4\n", rig.ledger()
659
+ assert rig.code == 0 and on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 2\n", rig.ledger()
642
660
 
643
661
 
644
662
  # ---------------------------------------------------------------- the rounds
645
663
 
646
- def test_four_rounds_then_blocked_with_the_escalation_at_round_3(tmp_path):
664
+ def test_two_rounds_then_blocked_with_the_escalation_at_round_2(tmp_path):
647
665
  rig = Inside(tmp_path, three(), {"implementer": [OPUS, FABLE]})
648
- rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 5, "01/fixer": [fix("01", n) for n in (1, 2, 3, 4)]}))
649
- assert rig.code == 1 and rig.state()["tickets"]["01"]["round"] == 4
650
- assert rig.led("BLOCKED at the review: after round 4 these findings are open: STUCK (demo/export.py:99).")
651
- assert rig.ledger().count(f"Ticket 01 round 3: escalated to {FABLE}.") == 1
652
- assert [len(rig.led("fixer ran on", entry)) for entry in (OPUS, FABLE)] == [2, 2]
666
+ rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 3, "01/fixer": [fix("01", n) for n in (1, 2)]}))
667
+ assert rig.code == 1 and rig.state()["tickets"]["01"]["round"] == 2
668
+ assert rig.led("BLOCKED at the review: after round 2 these findings are open: STUCK (demo/export.py:99).")
669
+ assert rig.ledger().count(f"Ticket 01 round 2: escalated to {FABLE}.") == 1
670
+ assert [len(rig.led("fixer ran on", entry)) for entry in (OPUS, FABLE)] == [1, 1]
653
671
  tips = [rig.sha("01", "implementer")] + [call["sha"] for call in rig.calls("01", "fixer")]
654
672
  assert [gate["commit"] for gate in rig.gates() if gate["branch"] == "ticket/feat%2Fcsv/01"] == tips
655
673
  assert rig.state()["tickets"]["01"]["tip"] == tips[-1] and not rig.calls("02")
@@ -779,26 +797,24 @@ def test_a_gate_that_exits_with_any_other_code_is_red_without_running_again(tmp_
779
797
  assert record.count("exit: ") == 1 and f"\nexit: {exit}\nafter: clean\n" in record
780
798
 
781
799
 
782
- def test_a_red_gate_on_the_fixer_commit_of_round_4_blocks_the_ticket(tmp_path):
783
- rig = Inside(tmp_path, gate={"subjects": ["fix: 01 round 4"]})
784
- rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 4, "01/fixer": [fix("01", n) for n in (1, 2, 3, 4)]}))
800
+ def test_a_red_gate_on_the_fixer_commit_of_round_2_blocks_the_ticket(tmp_path):
801
+ rig = Inside(tmp_path, gate={"subjects": ["fix: 01 round 2"]})
802
+ rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 2, "01/fixer": [fix("01", n) for n in (1, 2)]}))
785
803
  last = rig.calls("01", "fixer")[-1]["sha"]
786
804
  assert f"BLOCKED at the gate: the gate is red on {last[:7]}" in blocked(rig)
787
- assert len(rig.calls("01", "reviewer")) == 4 and not (rig.folder() / "findings-4.json").exists()
805
+ assert len(rig.calls("01", "reviewer")) == 2 and not (rig.folder() / "findings-2.json").exists()
788
806
 
789
807
 
790
- def test_round_3_stays_on_its_entry_when_the_implementer_has_no_next_entry(tmp_path):
808
+ def test_one_implementer_entry_is_invalid_before_agents_start(tmp_path):
791
809
  rig = Inside(tmp_path, ONE, {"implementer": [OPUS]})
792
- rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 3 + [review("01")], "01/fixer": [fix("01", n) for n in (1, 2, 3)]}))
793
- assert rig.code == 0, rig.ledger()
794
- assert rig.led(f"Ticket 01 round 3: the implementer has no next entry, so the round stays on {OPUS}.")
795
- assert len(rig.led("fixer ran on", OPUS)) == 3
810
+ rig.models.write_text(json.dumps({**json.loads(rig.models.read_text()), "implementer": [OPUS]}))
811
+ rig.run(plan())
812
+ assert rig.code == 3 and not rig.calls()
796
813
 
797
814
 
798
815
  def test_the_escalation_takes_the_next_entry_of_the_list():
799
816
  models = {"implementer": ["a@low", "openai/b@low", "c@low"]}
800
- assert [driver_fixloop.entry(models, n) for n in (1, 2, 3, 4)] == ["a@low", "a@low", "openai/b@low", "openai/b@low"]
801
- assert driver_fixloop.entry({"implementer": ["a@low"]}, 3) == "a@low"
817
+ assert [driver_fixloop.entry(models, n) for n in (1, 2)] == ["a@low", "openai/b@low"]
802
818
 
803
819
 
804
820
  def test_a_fixer_that_does_not_finish_blocks_the_ticket_in_its_round(tmp_path):
@@ -831,8 +847,10 @@ def test_a_full_review_after_a_correction_names_each_locked_file_that_needs_a_pr
831
847
  vacuous = finding("VACUOUS", "critical", kind="test", file="tests/test_01.py")
832
848
  correction = {**first, "files": {"tests/test_01.py": "# stronger\n"}, "commit": "test: 01 stronger test"}
833
849
  correction["report"] = {**first["report"], "files": ["tests/test_01.py"], "locked": ["tests/test_01.py"]}
850
+ regression = review("01", lines=())
851
+ regression["report"]["regressions"] = [vacuous]
834
852
  rig = Inside(tmp_path).run(plan(**{"01/test-writer": [first, correction], "01/fixer": [fix("01", 1)],
835
- "01/reviewer": [both([STUCK]), review("01", [vacuous], lines=()), both()]}))
853
+ "01/reviewer": [both([STUCK]), regression, both()]}))
836
854
  assert rig.code == 0, rig.ledger()
837
855
  order = [call["role"] for call in rig.calls("01")]
838
856
  assert order == ["test-writer", "implementer", "reviewer", "fixer", "reviewer", "test-writer", "reviewer"]
@@ -1072,7 +1090,7 @@ def test_a_re_review_names_only_the_proofs_the_fix_made_due(tmp_path):
1072
1090
  assert "no proof is due): demo/export.py:12 demo/export.py:30\n" in rig.prompt("reviewer-1")
1073
1091
  assert "no proof is due): demo/export.py:30\n" in rig.prompt("reviewer-2")
1074
1092
  old, new = rig.sha("01", "implementer"), rig.calls("01", "fixer")[0]["sha"]
1075
- assert f"The fix is {old}..{new}: review only the lines it changed" in rig.prompt("reviewer-1")
1093
+ assert f"The fix is {old}..{new}: check only whether your own critical or important findings" in rig.prompt("reviewer-1")
1076
1094
 
1077
1095
 
1078
1096
  def test_a_proof_follows_its_line_through_inserts_and_deletes(tmp_path):
@@ -8,7 +8,7 @@ import pytest
8
8
  from test_cli import RUN, SKILL, drive, env, make_repo, three # noqa: F401 (env is a fixture)
9
9
 
10
10
  STANDARD = {
11
- "implementer": ["claude-sonnet-5-5@medium", "openai/gpt-6.1-sol@medium"],
11
+ "implementer": ["claude-sonnet-5-5@medium", "claude-opus-5-5@medium"],
12
12
  "test-writer": ["claude-sonnet-5-5@medium", "openai/gpt-6.1-sol@medium"],
13
13
  "reviewer": ["openai/gpt-6-astra@medium", "claude-opus-5-5@medium"],
14
14
  "final-reviewer": ["openai/gpt-6-astra@medium", "claude-opus-5-5@medium"],
@@ -5,8 +5,8 @@ reviewer, correctness, fixer, conflict and a second test-writer call; a role it
5
5
 
6
6
  Interface choices (ticket 04):
7
7
  - the runner replaces the CLI, so a model entry is observed in the ledger: the line of a call names its role and entry.
8
- - a fix round runs the role `fixer` (report `fixer-<round>.json`) on the implementer's model list: entry 0 in rounds
9
- 1-2, entry 1 in rounds 3-4. `state.json` `round` counts fix rounds only. The review that follows round K writes
8
+ - a fix round runs the role `fixer` (report `fixer-<round>.json`) on the implementer's model list: entry 0 in round
9
+ 1, entry 1 in round 2. `state.json` `round` counts fix rounds only. The review that follows round K writes
10
10
  `reviewer-K.json` (the first review `reviewer-0.json`); a correctness pass writes `correctness-K.json`.
11
11
  - `mutations[].test` is `<locked file>::test_x`; a re-review prompt names each mutation proof to repeat as
12
12
  `<file>:<line>`, with the line number it has at the new tip.
@@ -164,6 +164,90 @@ def test_a_review_with_only_minor_findings_passes_and_writes_them_to_the_ledger(
164
164
  assert plain.led("M-ONE", "minor") and plain.led("M-TWO", "minor")
165
165
 
166
166
 
167
+ def test_unrelated_important_observation_waits_for_final_review(tmp_path):
168
+ rig = Review(tmp_path)
169
+ step = review("01")
170
+ step["report"]["observations"] = [finding("DUPLICATED-HELPER")]
171
+
172
+ rig.run(plan(**{"01/reviewer": [step]}))
173
+
174
+ assert rig.code == 0, rig.output()
175
+ assert not rig.calls("01", "fixer")
176
+ assert rig.state()["tickets"]["01"]["phase"] == "merged"
177
+ assert "DUPLICATED-HELPER" in rig.calls("final", "final-reviewer")[0]["prompt"]
178
+
179
+
180
+ def test_rereview_defers_newly_noticed_issue_outside_its_open_findings(tmp_path):
181
+ rig = Review(tmp_path)
182
+ steps = plan(**{"01/reviewer": [review("01", [finding("HEADER-MISSING")]),
183
+ review("01", [finding("PREEXISTING-NAME")])],
184
+ "01/fixer": [fix("01", 1)]})
185
+
186
+ rig.run(steps)
187
+
188
+ assert rig.code == 0, rig.output()
189
+ assert len(rig.calls("01", "fixer")) == 1
190
+ assert "PREEXISTING-NAME" in rig.calls("final", "final-reviewer")[0]["prompt"]
191
+
192
+
193
+ def test_rereview_can_open_a_regression_introduced_by_the_fix(tmp_path):
194
+ rig = Review(tmp_path)
195
+ after_first = review("01")
196
+ after_first["report"]["regressions"] = [finding("QUOTING-BROKEN")]
197
+ steps = plan(**{"01/reviewer": [review("01", [finding("HEADER-MISSING")]), after_first, review("01")],
198
+ "01/fixer": [fix("01", 1), fix("01", 2)]})
199
+
200
+ rig.run(steps)
201
+
202
+ assert rig.code == 0, rig.output()
203
+ assert len(rig.calls("01", "fixer")) == 2
204
+ assert "findings-1.json" in rig.calls("01", "fixer")[1]["prompt"]
205
+ assert "QUOTING-BROKEN" in (rig.folder() / "findings-1.json").read_text()
206
+
207
+
208
+ def test_unmet_criterion_blocks_after_two_fixes_while_independent_ticket_continues(tmp_path):
209
+ rig = Review(tmp_path, three(), {"implementer": [OPUS, FABLE]})
210
+ steps = plan(**{"01/reviewer": [review("01", [finding("HEADER-MISSING")])] * 3,
211
+ "01/fixer": [fix("01", 1), fix("01", 2)]})
212
+
213
+ rig.run(steps)
214
+
215
+ assert rig.code == 1, rig.output()
216
+ assert rig.state()["tickets"]["01"]["phase"] == "blocked"
217
+ assert rig.state()["tickets"]["03"]["phase"] == "merged"
218
+ assert len(rig.calls("01", "fixer")) == 2
219
+ assert rig.led("fixer", FABLE)
220
+ assert not rig.state()["run"]["questions"]
221
+
222
+
223
+ def test_new_criterion_failure_caused_by_first_fix_blocks_at_cap(tmp_path):
224
+ rig = Review(tmp_path, models={"implementer": [OPUS, FABLE]})
225
+ after_first = review("01")
226
+ after_first["report"]["regressions"] = [{**finding("FOOTER-MISSING"), "basis": "criterion"}]
227
+ steps = plan(**{"01/reviewer": [review("01", [finding("HEADER-MISSING")]), after_first,
228
+ review("01", [finding("FOOTER-MISSING")])],
229
+ "01/fixer": [fix("01", 1), fix("01", 2)]})
230
+
231
+ rig.run(steps)
232
+
233
+ assert rig.code == 1, rig.output()
234
+ assert rig.state()["tickets"]["01"]["phase"] == "blocked"
235
+ assert not rig.state()["run"]["final"]["must_fix"]
236
+
237
+
238
+ def test_red_gate_after_second_fix_blocks_the_ticket(tmp_path):
239
+ rig = Review(tmp_path, models={"implementer": [OPUS, FABLE]}, gate={"subjects": ["fix: 01 round 2"]})
240
+ steps = plan(**{"01/reviewer": [review("01", [finding("HEADER-MISSING")])] * 2,
241
+ "01/fixer": [fix("01", 1), fix("01", 2)]})
242
+
243
+ rig.run(steps)
244
+
245
+ assert rig.code == 1, rig.output()
246
+ assert rig.state()["tickets"]["01"]["phase"] == "blocked"
247
+ assert len(rig.calls("01", "fixer")) == 2
248
+ assert any(record["exit"] == 1 for record in rig.gates())
249
+
250
+
167
251
  # ---------------------------------------------------------------- fix loop
168
252
 
169
253
  STUCK = finding("STUCK")
@@ -171,29 +255,29 @@ STUCK = finding("STUCK")
171
255
 
172
256
  @pytest.fixture(scope="module")
173
257
  def escalated(tmp_path_factory):
174
- """One important finding survives the re-reviews after rounds 1 and 2; round 3 is clean."""
258
+ """One important finding survives round 1; round 2 on the next model closes it."""
175
259
  rig = Review(tmp_path_factory.mktemp("esc"), ONE, {"implementer": [OPUS, FABLE]})
176
260
  bad = review("01", [STUCK])
177
- return rig.run(plan(**{"01/reviewer": [bad, bad, bad, review("01")],
178
- "01/fixer": [fix("01", n) for n in (1, 2, 3)]}))
261
+ return rig.run(plan(**{"01/reviewer": [bad, bad, review("01")],
262
+ "01/fixer": [fix("01", n) for n in (1, 2)]}))
179
263
 
180
264
 
181
- def test_round_3_starts_a_fresh_implementer_on_the_next_model(escalated):
265
+ def test_round_2_starts_a_fresh_implementer_on_the_next_model(escalated):
182
266
  assert escalated.code == 0, escalated.output()
183
- assert escalated.led("01 round 3: escalated to claude-fable-5-1@high")
184
- assert not escalated.led("round 1: escalated") and not escalated.led("round 2: escalated")
185
- assert len(escalated.led("fixer", OPUS)) == 2 and len(escalated.led("fixer", FABLE)) == 1
186
- assert escalated.state()["tickets"]["01"]["round"] == 3
267
+ assert escalated.led("01 round 2: escalated to claude-fable-5-1@high")
268
+ assert not escalated.led("round 1: escalated")
269
+ assert len(escalated.led("fixer", OPUS)) == 1 and len(escalated.led("fixer", FABLE)) == 1
270
+ assert escalated.state()["tickets"]["01"]["round"] == 2
187
271
 
188
272
 
189
273
  def test_each_round_ends_with_one_gate_record_and_a_re_review_scoped_to_the_fix(escalated):
190
274
  tips = [escalated.sha("01", "implementer")] + [c["sha"] for c in escalated.calls("01", "fixer")]
191
275
  commits = [g["commit"] for g in escalated.gates()]
192
- assert len(tips) == 4 and all(commits.count(t) == 1 for t in tips), commits
276
+ assert len(tips) == 3 and all(commits.count(t) == 1 for t in tips), commits
193
277
  assert all((escalated.folder() / f"gate-{t[:7]}.log").exists() for t in tips)
194
278
  reviews = escalated.calls("01", "reviewer")
195
- assert len(reviews) == 4
196
- for k in (1, 2, 3):
279
+ assert len(reviews) == 3
280
+ for k in (1, 2):
197
281
  assert tips[k - 1][:7] in reviews[k]["prompt"] and tips[k][:7] in reviews[k]["prompt"], k
198
282
 
199
283
 
@@ -207,28 +291,28 @@ def gate_rule(prompt, gate):
207
291
  def test_the_implementer_and_each_fixer_get_the_gate_command_and_run_it_before_they_report(escalated):
208
292
  gate = str(escalated.rig / "gate")
209
293
  agents = escalated.calls("01", "implementer") + escalated.calls("01", "fixer")
210
- assert len(agents) == 4, "the implementer and the fixers of rounds 1, 2 and 3 (the next model)"
294
+ assert len(agents) == 3, "the implementer and the fixers of rounds 1 and 2 (the next model)"
211
295
  for call in agents:
212
296
  gate_rule(call["prompt"], gate)
213
297
 
214
298
 
215
299
  def test_reports_are_named_by_role_and_round(escalated):
216
- for name in ("reviewer-0", "reviewer-1", "reviewer-2", "reviewer-3", "fixer-1", "fixer-2", "fixer-3"):
300
+ for name in ("reviewer-0", "reviewer-1", "reviewer-2", "fixer-1", "fixer-2"):
217
301
  assert (escalated.folder() / f"{name}.json").exists(), name
218
302
 
219
303
 
220
304
  @pytest.fixture(scope="module")
221
305
  def capped(tmp_path_factory):
222
- """The three-ticket default; 01's reviewer keeps the same finding through round 4."""
306
+ """The three-ticket default; 01's reviewer keeps the same criterion finding through round 2."""
223
307
  rig = Review(tmp_path_factory.mktemp("cap"), three(), {"implementer": [OPUS, FABLE]})
224
- return rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 5,
225
- "01/fixer": [fix("01", n) for n in (1, 2, 3, 4)]}))
308
+ return rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 3,
309
+ "01/fixer": [fix("01", n) for n in (1, 2)]}))
226
310
 
227
311
 
228
- def test_a_finding_open_after_round_4_blocks_the_ticket_and_the_run_goes_on(capped):
312
+ def test_a_criterion_open_after_round_2_blocks_the_ticket_and_the_run_goes_on(capped):
229
313
  assert capped.code == 1, capped.output()
230
314
  assert capped.led("01", "BLOCKED", "STUCK")
231
- assert len(capped.calls("01", "fixer")) == 4 and len(capped.calls("01", "reviewer")) == 5
315
+ assert len(capped.calls("01", "fixer")) == 2 and len(capped.calls("01", "reviewer")) == 3
232
316
  assert not capped.calls("02"), "02 is blocked by 01"
233
317
  assert capped.state()["tickets"]["01"]["phase"] == "blocked"
234
318
  assert capped.state()["tickets"]["03"]["phase"] == "merged" and "feat: 03 rows" in capped.pr_subjects()