@jesdi/skills 0.0.74 → 0.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +1 -1
  2. package/skills/implement-spec/README.md +27 -22
  3. package/skills/implement-spec/SKILL.md +1 -1
  4. package/skills/implement-spec/driver.py +75 -44
  5. package/skills/implement-spec/driver_final.py +60 -34
  6. package/skills/implement-spec/driver_fixloop.py +65 -17
  7. package/skills/implement-spec/driver_gate.py +25 -12
  8. package/skills/implement-spec/driver_legacy.py +19 -7
  9. package/skills/implement-spec/driver_merge.py +20 -2
  10. package/skills/implement-spec/driver_report.py +10 -3
  11. package/skills/implement-spec/driver_run.py +17 -13
  12. package/skills/implement-spec/driver_state.py +17 -7
  13. package/skills/implement-spec/driver_summary.py +1 -1
  14. package/skills/implement-spec/driver_tidy.py +2 -8
  15. package/skills/implement-spec/prompts/final-fixer.md +1 -1
  16. package/skills/implement-spec/prompts/final-reviewer.md +2 -2
  17. package/skills/implement-spec/prompts/fixer.md +1 -1
  18. package/skills/implement-spec/prompts/implementer.md +1 -1
  19. package/skills/implement-spec/prompts/landing-merge.md +1 -0
  20. package/skills/implement-spec/prompts/landing-red.md +2 -0
  21. package/skills/implement-spec/tests/test_agents.py +2 -2
  22. package/skills/implement-spec/tests/test_amendments.py +1 -1
  23. package/skills/implement-spec/tests/test_cli.py +4 -4
  24. package/skills/implement-spec/tests/test_driver.py +73 -30
  25. package/skills/implement-spec/tests/test_final.py +41 -7
  26. package/skills/implement-spec/tests/test_fixloop.py +172 -21
  27. package/skills/implement-spec/tests/test_landing.py +1 -1
  28. package/skills/implement-spec/tests/test_merge.py +8 -0
  29. package/skills/implement-spec/tests/test_report.py +2 -2
  30. package/skills/implement-spec/tests/test_review.py +16 -8
  31. package/skills/implement-spec/tests/test_state.py +6 -6
  32. package/skills/implement-spec/tests/test_summary.py +3 -2
  33. package/skills/implement-spec/tests/test_tidy.py +16 -13
  34. package/skills/implement-spec/tests/test_walk.py +55 -36
  35. package/skills-manifest.json +3 -3
@@ -17,7 +17,7 @@ import driver_run
17
17
  import driver_review
18
18
  import test_review
19
19
  from conftest import GIT
20
- from test_cli import three
20
+ from test_cli import three, ticket
21
21
  from test_final import RUNNER, final, fixer, fn
22
22
  from test_review import FABLE, ONE, OPUS, RISKY, SOL, STUCK, correct, finding, fix, review
23
23
  from test_walk import impl, plan, tw
@@ -30,9 +30,10 @@ class Inside(test_review.Review):
30
30
 
31
31
  def run(self, steps, *extra, parallel="2", watch=False):
32
32
  (self.rig / "plan.json").write_text(json.dumps(steps))
33
- args = ["--tickets", ".agent/tickets", "--gate", self.command.format(gate=self.rig / "gate"), "--spec",
34
- "specs/csv/spec.md", "--models", str(self.models), "--runner", str(self.rig / "run-agent"), "--parallel",
35
- parallel, *extra]
33
+ command = self.command.format(gate=self.rig / "gate")
34
+ args = ["--tickets", ".agent/tickets", "--gate", f"export TIER=full; {command}", "--fast-gate",
35
+ f"export TIER=fast; {command}", "--spec", "specs/csv/spec.md", "--models", str(self.models), "--runner",
36
+ str(self.rig / "run-agent"), "--parallel", parallel, *extra]
36
37
  here = os.getcwd()
37
38
  os.chdir(self.repo)
38
39
  try:
@@ -236,7 +237,7 @@ def test_an_open_finding_survives_the_fixture_correction_of_its_review_and_start
236
237
  assert rig.calls("01", "fixer")[0]["head"] == rig.calls("01", "test-writer")[1]["sha"] # on the corrected tip
237
238
  # No review saw the correction yet, so the review after the round is a full one.
238
239
  assert "re-review" not in rig.prompt("reviewer-1")
239
- assert [gate["commit"] for gate in rig.walk_gates()] == [rig.sha("01", "implementer"), rig.sha("01", "fixer")]
240
+ assert [gate["commit"] for gate in rig.gates("fast")] == [rig.sha("01", "implementer"), rig.sha("01", "fixer")]
240
241
 
241
242
 
242
243
  def test_a_test_finding_on_a_locked_file_gets_the_test_writer_correction_not_a_fix_round(tmp_path):
@@ -536,6 +537,71 @@ def test_the_restore_before_a_correction_is_committed_so_the_next_fixer_and_its_
536
537
  assert "The driver put back these files at their locked versions" in prompt and "tests/test_01.py" in prompt
537
538
 
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
+ def test_the_fast_gate_gets_the_locked_files_of_its_ticket_and_the_full_gate_none(tmp_path):
546
+ """Ticket 02 locks two files and merged ticket 01 locks tests/test_01.py: only 02's files reach its fast gate."""
547
+ writer = tw("02")
548
+ writer["files"]["tests/test_02b.py"] = "def test_x():\n assert 2 == 'x'\n"
549
+ writer["report"]["locked"] += ["tests/test_02b.py"]
550
+ rig = Inside(tmp_path, three()).run(plan(**{"02/test-writer": [writer]}), parallel="1")
551
+ assert rig.code == 0, rig.ledger()
552
+ candidate = rig.sha("02", "implementer")
553
+ assert [gate["locked"] for gate in rig.gates("fast") if gate["commit"] == candidate] == [
554
+ "tests/test_02.py tests/test_02b.py"]
555
+ assert rig.gates("full") and all(gate["locked"] is None for gate in rig.gates("full"))
556
+
557
+
558
+ def test_the_fixer_is_told_the_fast_gate_with_the_locked_files_of_its_ticket(tmp_path):
559
+ writer = tw("02")
560
+ writer["files"]["tests/test_02b.py"] = "def test_x():\n assert 2 == 'x'\n"
561
+ 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
+ rig = Inside(tmp_path, three()).run(plan(**{"02/test-writer": [writer], "02/fixer": [fix("02", 1)],
571
+ "02/reviewer": [proved(review("02", [STUCK])), review("02")]}))
572
+ assert rig.code == 0, rig.ledger()
573
+ (fixer,) = rig.calls("02", "fixer")
574
+ test_review.gate_rule(fixer["prompt"], f"export TIER=fast; {rig.rig / 'gate'}",
575
+ "tests/test_02.py tests/test_02b.py")
576
+ test_review.no_full_gate(rig)
577
+
578
+
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
+ def test_a_locked_path_with_whitespace_is_rejected_once_and_then_blocks(tmp_path):
594
+ spaced = {**tw("01"), "files": {"tests/test 01.py": "def test_x():\n assert 1 == 'x'\n"}}
595
+ spaced["report"] = {**spaced["report"], "files": ["tests/test 01.py"], "locked": ["tests/test 01.py"]}
596
+ rig = Inside(tmp_path).run(plan(**{"01/test-writer": [spaced, spaced]}))
597
+ error = ("locked path 'tests/test 01.py' contains whitespace: the fast gate gets the locked paths separated by "
598
+ "spaces, so rename the file")
599
+ assert blocked(rig) == f"Ticket 01: BLOCKED at the test-writer: {error}."
600
+ first, second = rig.calls("01", "test-writer")
601
+ assert f"The driver rejected the earlier attempt: {error}" in second["prompt"]
602
+ assert not rig.calls("01", "implementer")
603
+
604
+
539
605
  ADAPTED_01 = LOCKED_01 + "# adapted to the interface of 02\n"
540
606
  ADAPTS = impl("02", files={"demo/export.py": "def fn_02():\n return '02'\n", "tests/test_01.py": ADAPTED_01})
541
607
  RESTORE = "implement-spec: restore the locked files before the correction"
@@ -560,7 +626,7 @@ def test_a_restored_locked_file_of_a_merged_ticket_that_fails_with_the_new_code_
560
626
  assert not rig.calls("02", "fixer")
561
627
  (restore,) = [gate["commit"] for gate in rig.gates() if gate["exit"]]
562
628
  first, second = rig.calls("02", "test-writer")[1:]
563
- assert f".agent/implement/02/gate-{restore[:7]}.log" in first["prompt"] and first["head"] == restore
629
+ assert f".agent/implement/02/gate-fast-{restore[:7]}.log" in first["prompt"] and first["head"] == restore
564
630
  assert "the gate is red on the restore commit" in second["prompt"] # the rejection of the first attempt
565
631
  assert on_pr(rig, "tests/test_01.py") == ADAPTED_01 and "tests/test_01.py" in rig.state()["tickets"]["02"]["locked"]
566
632
 
@@ -649,7 +715,7 @@ def test_a_restore_that_turns_the_merge_gate_red_is_taken_back_and_asks_again_wi
649
715
  two = {name: text for name, text in three().items() if not name.startswith("03")} # 02 lands as a fast-forward
650
716
  rig, steps = changed_at_cap(tmp_path, "red", files=two, gate={"subjects": [LANDING_RESTORE]})
651
717
  rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=restore", parallel="1")
652
- assert rig.code == 2 and rig.led("Ticket 02: BLOCKED at the merge: the gate is red on"), rig.ledger()
718
+ assert rig.code == 2 and rig.led("Ticket 02: BLOCKED at the merge: the full gate is red on"), rig.ledger()
653
719
  assert asked(rig) == {f"{MERGED_LOCKED}-2": ["adopt", "redesign"]}
654
720
  question = [q for q in rig.state()["run"]["questions"] if q["answer"] is None][0]
655
721
  assert question["recommended"] == "adopt" and question["evidence"][0].endswith(".log")
@@ -685,7 +751,7 @@ def test_a_fixer_with_nothing_to_change_is_accepted_and_the_same_tip_is_reviewed
685
751
  assert len(rig.calls("01", "fixer")) == 1 and rig.led("fixer ran on", "report accepted")
686
752
  assert rig.state()["tickets"]["01"]["round"] == 1 and rig.state()["tickets"]["01"]["phase"] == "merged"
687
753
  tip = rig.sha("01", "implementer")
688
- assert [gate["commit"] for gate in rig.gates()].count(tip) == 1
754
+ assert [gate["commit"] for gate in rig.gates("fast")].count(tip) == 1
689
755
  again = rig.prompt("reviewer-1")
690
756
  assert f"The fix is {tip}..{tip}" in again and "The fixer of round 1 changed nothing" in again
691
757
  assert ".agent/implement/01/fixer-1.json" in again and "no concern names" not in rig.prompt("fixer-1")
@@ -701,11 +767,11 @@ def test_a_red_gate_on_a_fixer_commit_starts_the_next_round_with_the_record_as_e
701
767
  assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "reviewer", "fixer", "fixer",
702
768
  "reviewer"]
703
769
  first, second = (call["sha"] for call in rig.calls("01", "fixer"))
704
- record = f".agent/implement/01/gate-{first[:7]}.log"
770
+ record = f".agent/implement/01/gate-fast-{first[:7]}.log"
705
771
  (gate,) = json.loads((rig.folder() / "findings-1.json").read_text())
706
772
  assert (gate["source"], gate["severity"], gate["kind"]) == ("gate", "critical", "code")
707
- assert gate["title"] == f"the gate is red on {first[:7]}" and record in gate["evidence"]
708
- assert rig.led(f"Ticket 01: critical finding of kind code from the gate at {record}:0: the gate is red on {first[:7]}.")
773
+ assert gate["title"] == f"the fast gate is red on {first[:7]}" and record in gate["evidence"]
774
+ 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]}.")
709
775
  assert "findings-1.json" in rig.prompt("fixer-2") and rig.state()["tickets"]["01"]["round"] == 2
710
776
  # No review saw the red tip: the re-review covers both fixes, and the proof that round 1 made due stays due.
711
777
  again = rig.prompt("reviewer-2")
@@ -719,15 +785,100 @@ def test_a_red_gate_on_the_implementer_commit_starts_fix_round_1_with_the_record
719
785
  assert rig.code == 0, rig.ledger()
720
786
  assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "fixer", "reviewer"]
721
787
  tip = rig.sha("01", "implementer")
722
- record = f".agent/implement/01/gate-{tip[:7]}.log"
788
+ record = f".agent/implement/01/gate-fast-{tip[:7]}.log"
723
789
  (gate,) = json.loads((rig.folder() / "findings-0.json").read_text())
724
790
  assert (gate["source"], gate["severity"], gate["kind"]) == ("gate", "critical", "code")
725
- assert gate["title"] == f"the gate is red on {tip[:7]}" and record in gate["evidence"]
791
+ assert gate["title"] == f"the fast gate is red on {tip[:7]}" and record in gate["evidence"]
726
792
  assert "findings-0.json" in rig.prompt("fixer-1") and rig.state()["tickets"]["01"]["phase"] == "merged"
727
793
  assert "The fix is" not in rig.prompt("reviewer-1") # no review saw the implementer commit: a full review
728
794
  assert [gate["commit"] for gate in rig.gates()].count(tip) == 1 and not rig.led("killed by signal")
729
795
 
730
796
 
797
+ # ---------------------------------------------------------------- a red full gate at landing
798
+
799
+ def full_red(rig, commit):
800
+ """The exit of each full gate that the rig's gate logged on `commit`."""
801
+ return [gate["exit"] for gate in rig.gates("full") if gate["commit"] == commit]
802
+
803
+
804
+ def test_a_red_full_gate_at_landing_starts_round_1_and_the_fix_gets_a_fast_gate_a_re_review_and_a_full_gate(tmp_path):
805
+ rig = Inside(tmp_path, gate={"full": {"subjects": ["feat: 01 rows"]}})
806
+ rig.run(plan(**{"01/fixer": [fix("01", 1)]}))
807
+ assert rig.code == 0, rig.ledger()
808
+ assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "reviewer", "fixer", "reviewer"]
809
+ tip, fixed = rig.sha("01", "implementer"), rig.sha("01", "fixer")
810
+ record = f".agent/implement/01/gate-full-{tip[:7]}.log"
811
+ assert full_red(rig, tip) == [1] and full_red(rig, fixed) == [0]
812
+ assert [gate["commit"] for gate in rig.gates("fast")] == [tip, fixed]
813
+ # The PR branch did not move to the red tip: the fixer started with the PR branch at the spec commit.
814
+ fixer_call = rig.calls("01", "fixer")[0]
815
+ assert "feat: 01 rows" not in fixer_call["pr_log"] and fixer_call["branch"] == "ticket/feat%2Fcsv/01"
816
+ *review_findings, gate = json.loads((rig.folder() / "findings-0.json").read_text())
817
+ assert (gate["source"], gate["severity"], gate["kind"], gate["file"]) == ("gate", "critical", "code", record)
818
+ assert gate["title"] == f"the full gate is red on {tip[:7]}"
819
+ assert rig.led(f"Ticket 01: the full gate is red on {tip[:7]} at the landing, so feat/csv does not move and fix "
820
+ "round 1 starts.")
821
+ prompt = rig.prompt("fixer-1")
822
+ assert "findings-0.json" in prompt and record in prompt and "not on ticket/feat%2Fcsv/01" not in prompt
823
+ assert f"The fix is {tip}..{fixed}" in rig.prompt("reviewer-1")
824
+ entry = rig.state()["tickets"]["01"]
825
+ assert (entry["round"], entry["phase"], entry["landing"]) == (1, "merged", None)
826
+
827
+
828
+ def test_a_red_full_gate_on_a_merge_commit_sends_the_fixer_to_the_ticket_branch_with_the_merge_commit(tmp_path):
829
+ files = {"01-export-rows.md": ticket("01", "Export rows"),
830
+ "02-quote-fields.md": ticket("02", "Quote fields", touches="`demo/other.py: g`")}
831
+ rig = Inside(tmp_path, files, gate={"full": {"subjects": ["feat: 02 rows"]}})
832
+ rig.run(plan(**{"02/implementer": [impl("02", "demo/other.py", wait_pr_moves=True)],
833
+ "02/fixer": [fix("02", 1, files={"demo/other.py": "x = 1\n"})]}))
834
+ assert rig.code == 0, "\n".join(rig.ledger())
835
+ tip = rig.sha("02", "implementer")
836
+ (merge,) = [gate["commit"] for gate in rig.gates("full") if gate["exit"]]
837
+ assert merge != tip and tip not in [gate["commit"] for gate in rig.gates("full")]
838
+ fixer_call = rig.calls("02", "fixer")[0]
839
+ assert (fixer_call["branch"], fixer_call["head"]) == ("ticket/feat%2Fcsv/02", tip)
840
+ prompt = rig.prompt("fixer-1", "02")
841
+ assert f"{merge[:7]} is not on ticket/feat%2Fcsv/02: it is the merge commit" in prompt
842
+ assert f"implement/02/gate-full-{merge[:7]}.log" in prompt and "git merge --no-commit --no-ff feat/csv" in prompt
843
+ assert rig.state()["tickets"]["02"]["phase"] == "merged"
844
+
845
+
846
+ def test_a_red_full_gate_at_landing_after_round_2_blocks_the_ticket_and_its_dependent(tmp_path):
847
+ rig = Inside(tmp_path, three(), gate={"full": {"subjects": ["fix: 01 round 2"]}})
848
+ rig.run(plan(**{"01/reviewer": [review("01", [STUCK]), review("01", [STUCK]), review("01")],
849
+ "01/fixer": [fix("01", n) for n in (1, 2)]}))
850
+ (red,) = [gate["commit"] for gate in rig.gates("full") if gate["exit"]] # 03 may land first: then a merge commit
851
+ assert f"BLOCKED at the merge: the full gate is red on {red[:7]}" in blocked(rig), rig.ledger()
852
+ assert len(rig.calls("01", "fixer")) == 2 and rig.state()["tickets"]["01"]["round"] == 2
853
+ assert "fix: 01 round 2" not in rig.pr_subjects() and "Ticket 01: merged" not in "".join(rig.ledger())
854
+ assert not rig.calls("02") and rig.state()["tickets"]["02"]["phase"] == "pending"
855
+ assert rig.state()["tickets"]["03"]["phase"] == "merged"
856
+
857
+
858
+ def test_a_run_stopped_after_a_red_full_gate_at_landing_resumes_with_the_fixer(tmp_path, monkeypatch):
859
+ rig = Inside(tmp_path, gate={"full": {"subjects": ["feat: 01 rows"]}})
860
+ real = driver_fixloop.red_landing
861
+
862
+ def stop(*args):
863
+ try:
864
+ real(*args)
865
+ except driver_fixloop.Unlanded:
866
+ raise driver_run.Halted("stopped right after the red landing") from None
867
+
868
+ monkeypatch.setattr(driver_fixloop, "red_landing", stop)
869
+ steps = plan(**{"01/fixer": [fix("01", 1)]})
870
+ rig.run(steps)
871
+ assert rig.code == 4 and not rig.calls("01", "fixer"), rig.ledger()
872
+ entry, tip = rig.state()["tickets"]["01"], rig.sha("01", "implementer")
873
+ assert (entry["phase"], entry["round"], entry["landing"]) == ("fix", 1, tip)
874
+ monkeypatch.setattr(driver_fixloop, "red_landing", real)
875
+ rig.run(steps)
876
+ assert rig.code == 0, rig.ledger()
877
+ roles = [call["role"] for call in rig.calls("01")]
878
+ assert roles == ["test-writer", "implementer", "reviewer", "fixer", "reviewer"]
879
+ assert full_red(rig, tip) == [1] and rig.state()["tickets"]["01"]["round"] == 1
880
+
881
+
731
882
  def killed(rig, subject, times, end="os.kill(os.getpid(), signal.SIGTERM)"):
732
883
  """The rig's gate, ended by `end` (SIGTERM by default) on its first `times` runs on the commit with `subject`, as a
733
884
  `pkill -f` of another slot ends it (issue 101). A killed run logs nothing into `<rig>/gates/`."""
@@ -765,10 +916,10 @@ def test_a_gate_killed_by_a_signal_runs_once_more_and_its_green_second_run_count
765
916
  assert rig.code == 0, rig.ledger()
766
917
  tip = rig.sha("01", "implementer")
767
918
  assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "reviewer"]
768
- assert rig.led("killed by signal") == [f"Ticket 01: the gate of {tip[:7]} was killed by signal 15 and runs again."]
769
- assert rig.led(f"Ticket 01: the gate is green on {tip[:7]}") and not rig.led("finding of kind")
919
+ assert rig.led("killed by signal") == [f"Ticket 01: the fast gate of {tip[:7]} was killed by signal 15 and runs again."]
920
+ assert rig.led(f"Ticket 01: the fast gate is green on {tip[:7]}") and not rig.led("finding of kind")
770
921
  assert json.loads((rig.folder() / "findings-0.json").read_text()) == [] # the review's, with no gate finding
771
- record = (rig.folder() / f"gate-{tip[:7]}.log").read_text()
922
+ record = (rig.folder() / f"gate-fast-{tip[:7]}.log").read_text()
772
923
  assert record.count("exit: ") == 1 and "\nexit: 0\nafter: clean\n" in record # the second run overwrote it
773
924
 
774
925
 
@@ -781,8 +932,8 @@ def test_a_gate_killed_by_a_signal_twice_is_red(tmp_path, command, code):
781
932
  assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "fixer", "reviewer"]
782
933
  assert len(rig.led("killed by signal")) == 1 and tip not in [gate["commit"] for gate in rig.gates()]
783
934
  (gate,) = json.loads((rig.folder() / "findings-0.json").read_text())
784
- assert gate["title"] == f"the gate is red on {tip[:7]}"
785
- assert f"\nexit: {code}\nafter: clean\n" in (rig.folder() / f"gate-{tip[:7]}.log").read_text()
935
+ assert gate["title"] == f"the fast gate is red on {tip[:7]}"
936
+ assert f"\nexit: {code}\nafter: clean\n" in (rig.folder() / f"gate-fast-{tip[:7]}.log").read_text()
786
937
 
787
938
 
788
939
  @pytest.mark.parametrize("exit", [1, 142]) # 142 is 128+SIGALRM: a signal, but not one that kills a gate from outside
@@ -793,7 +944,7 @@ def test_a_gate_that_exits_with_any_other_code_is_red_without_running_again(tmp_
793
944
  tip = rig.sha("01", "implementer")
794
945
  assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "fixer", "reviewer"]
795
946
  assert not rig.led("killed by signal") and tip not in [gate["commit"] for gate in rig.gates()]
796
- record = (rig.folder() / f"gate-{tip[:7]}.log").read_text()
947
+ record = (rig.folder() / f"gate-fast-{tip[:7]}.log").read_text()
797
948
  assert record.count("exit: ") == 1 and f"\nexit: {exit}\nafter: clean\n" in record
798
949
 
799
950
 
@@ -801,7 +952,7 @@ def test_a_red_gate_on_the_fixer_commit_of_round_2_blocks_the_ticket(tmp_path):
801
952
  rig = Inside(tmp_path, gate={"subjects": ["fix: 01 round 2"]})
802
953
  rig.run(plan(**{"01/reviewer": [review("01", [STUCK])] * 2, "01/fixer": [fix("01", n) for n in (1, 2)]}))
803
954
  last = rig.calls("01", "fixer")[-1]["sha"]
804
- assert f"BLOCKED at the gate: the gate is red on {last[:7]}" in blocked(rig)
955
+ assert f"BLOCKED at the gate: the fast gate is red on {last[:7]}" in blocked(rig)
805
956
  assert len(rig.calls("01", "reviewer")) == 2 and not (rig.folder() / "findings-2.json").exists()
806
957
 
807
958
 
@@ -959,7 +1110,7 @@ def test_a_reviewer_that_writes_the_shared_git_config_gets_it_restored_and_runs_
959
1110
  assert line.endswith("the driver restored the shared git config and runs the review again.")
960
1111
  tip, prompt = rig.sha("01", "implementer"), rig.prompt("reviewer-0")
961
1112
  assert len(rig.calls("01", "reviewer")) == 2 and rig.tip() == tip
962
- assert f".agent/implement/01/gate-{tip[:7]}.log" in prompt and "never write with `git config`" in prompt
1113
+ assert f".agent/implement/01/gate-fast-{tip[:7]}.log" in prompt and "never write with `git config`" in prompt
963
1114
 
964
1115
 
965
1116
  def test_a_branch_entry_that_another_worktree_writes_during_the_review_is_no_rule_break_and_stays(tmp_path):
@@ -281,7 +281,7 @@ def pair(tmp_path):
281
281
  def start(rig, steps, *extra):
282
282
  """The driver of `rig` in the background: `Rig.run` returns only when the driver ended."""
283
283
  (rig.rig / "plan.json").write_text(json.dumps(steps))
284
- args = ["--tickets", ".agent/tickets", "--gate", str(rig.rig / "gate"), "--spec", "specs/csv/spec.md",
284
+ args = ["--tickets", ".agent/tickets", "--gate", f"TIER=full {rig.rig / 'gate'}", "--fast-gate", f"TIER=fast {rig.rig / 'gate'}", "--spec", "specs/csv/spec.md",
285
285
  "--models", str(rig.models), "--runner", str(rig.rig / "run-agent"), "--parallel", "2", *extra]
286
286
  return subprocess.Popen(["sh", str(RUN), *args], cwd=rig.repo, env=rig.env, text=True, stdout=subprocess.PIPE,
287
287
  stderr=subprocess.STDOUT, start_new_session=True)
@@ -142,3 +142,11 @@ def test_begin_opens_the_conflicting_merge_on_a_machine_with_no_git_identity(rep
142
142
  monkeypatch.setenv("GIT_CONFIG_NOSYSTEM", "1")
143
143
  monkeypatch.delenv("GIT_CONFIG_COUNT")
144
144
  assert driver_merge.begin(".", pr_tip) == ["a.txt"]
145
+
146
+
147
+ def test_unsigned_lists_the_commits_origin_lacks_only_when_commit_gpgsign_is_on(repo, monkeypatch):
148
+ repo()
149
+ tip = sh("git", "rev-parse", "--short", "HEAD")
150
+ assert driver_merge.unsigned("HEAD") == []
151
+ monkeypatch.setenv("GIT_CONFIG_VALUE_2", "true") # the fixture's commit.gpgsign
152
+ assert driver_merge.unsigned("HEAD") == [tip]
@@ -155,8 +155,8 @@ def test_a_fixer_with_nothing_to_change_reports_no_commit_and_a_reason_per_findi
155
155
  assert check("fixer", fixer(status="DONE_WITH_CONCERNS", concerns=reasons), **fix) == []
156
156
  assert check("fixer", fixer(concerns=reasons[:1]), **fix) == [
157
157
  "no commit, and no concern names the finding LOOSE: give each finding a concern that says why it needs no change"]
158
- assert check("fixer", fixer(concerns=reasons), **fix, red=True) == [
159
- f"no commit, and the gate is red on {shas['impl'][:7]}: a fix of a red gate is a commit"]
158
+ assert check("fixer", fixer(concerns=reasons), **fix, red=f"the fast gate is red on {shas['impl'][:7]}") == [
159
+ f"no commit, and the fast gate is red on {shas['impl'][:7]}: a fix of a red gate is a commit"]
160
160
  # A commit that predates the fixer is still refused, and a commit it made is in `commits`.
161
161
  assert check("fixer", fixer(commits=[shas["impl"]], concerns=reasons), **fix)
162
162
  assert check("fixer", fixer(concerns=reasons), **{**fix, "start": shas["tests"]}) == [
@@ -136,7 +136,7 @@ def test_an_installed_skill_without_review_diff_fails_clearly_before_any_agent(t
136
136
  copy = tmp_path / "installed/skills/implement-spec"
137
137
  shutil.copytree(SKILL, copy, ignore=shutil.ignore_patterns("__pycache__", ".pytest_cache", "test_*"))
138
138
  (rig.rig / "plan.json").write_text(json.dumps(plan()))
139
- args = ["--tickets", ".agent/tickets", "--gate", str(rig.rig / "gate"), "--spec", "specs/csv/spec.md",
139
+ args = ["--tickets", ".agent/tickets", "--gate", f"TIER=full {rig.rig / 'gate'}", "--fast-gate", f"TIER=fast {rig.rig / 'gate'}", "--spec", "specs/csv/spec.md",
140
140
  "--models", str(rig.models), "--runner", str(rig.rig / "run-agent")]
141
141
  proc = subprocess.run(["sh", str(copy / "run.sh"), *args], cwd=rig.repo, env=rig.env, text=True,
142
142
  capture_output=True, timeout=120)
@@ -272,28 +272,36 @@ def test_round_2_starts_a_fresh_implementer_on_the_next_model(escalated):
272
272
 
273
273
  def test_each_round_ends_with_one_gate_record_and_a_re_review_scoped_to_the_fix(escalated):
274
274
  tips = [escalated.sha("01", "implementer")] + [c["sha"] for c in escalated.calls("01", "fixer")]
275
- commits = [g["commit"] for g in escalated.gates()]
275
+ commits = [g["commit"] for g in escalated.gates("fast")]
276
276
  assert len(tips) == 3 and all(commits.count(t) == 1 for t in tips), commits
277
- assert all((escalated.folder() / f"gate-{t[:7]}.log").exists() for t in tips)
277
+ assert all((escalated.folder() / f"gate-fast-{t[:7]}.log").exists() for t in tips)
278
278
  reviews = escalated.calls("01", "reviewer")
279
279
  assert len(reviews) == 3
280
280
  for k in (1, 2):
281
281
  assert tips[k - 1][:7] in reviews[k]["prompt"] and tips[k][:7] in reviews[k]["prompt"], k
282
282
 
283
283
 
284
- def gate_rule(prompt, gate):
285
- """The line of `prompt` that gives the gate command; it must say to run it before the report."""
284
+ def gate_rule(prompt, gate, locked):
285
+ """The line of `prompt` that gives the fast gate command; it must say to run it, with the locked files, before
286
+ the report."""
286
287
  (line,) = [l for l in prompt.splitlines() if f"`{gate}`" in l]
287
288
  assert "IMPLEMENT_SPEC_BASE=feat/csv" in line and "Before you report DONE" in line, line
289
+ assert f"IMPLEMENT_SPEC_LOCKED='{locked}'" in line, line
288
290
  return line
289
291
 
290
292
 
291
- def test_the_implementer_and_each_fixer_get_the_gate_command_and_run_it_before_they_report(escalated):
292
- gate = str(escalated.rig / "gate")
293
+ def no_full_gate(rig):
294
+ """No prompt of any agent of the run names the full gate command: only that command sets TIER=full."""
295
+ assert rig.calls() and not [call["role"] for call in rig.calls() if "TIER=full" in call["prompt"]]
296
+
297
+
298
+ def test_the_implementer_and_each_fixer_get_the_fast_gate_command_and_run_it_before_they_report(escalated):
299
+ gate = f"TIER=fast {escalated.rig / 'gate'}"
293
300
  agents = escalated.calls("01", "implementer") + escalated.calls("01", "fixer")
294
301
  assert len(agents) == 3, "the implementer and the fixers of rounds 1 and 2 (the next model)"
295
302
  for call in agents:
296
- gate_rule(call["prompt"], gate)
303
+ gate_rule(call["prompt"], gate, "tests/test_01.py")
304
+ no_full_gate(escalated)
297
305
 
298
306
 
299
307
  def test_reports_are_named_by_role_and_round(escalated):
@@ -14,16 +14,16 @@ def test_updates_from_many_threads_are_all_kept_and_no_scratch_file_stays(tmp_pa
14
14
 
15
15
  def work(number):
16
16
  for step in range(40):
17
- state.update(lambda s: s["run"].update(gates=s["run"]["gates"] + 1))
18
- state.update(lambda s: s["tickets"][number]["green_gates"].append(step))
17
+ state.update(lambda s: s["run"]["gates"].update(full=s["run"]["gates"]["full"] + 1))
18
+ state.update(lambda s: s["tickets"][number]["green_gates"]["fast"].append(step))
19
19
  state.ticket(number, round=step)
20
20
 
21
21
  threads = [threading.Thread(target=work, args=(number,)) for number in numbers]
22
22
  [thread.start() for thread in threads]
23
23
  [thread.join() for thread in threads]
24
24
  final = json.loads(state.path.read_text())
25
- assert final["run"]["gates"] == 320
26
- assert all(final["tickets"][n]["green_gates"] == list(range(40)) and final["tickets"][n]["round"] == 39 for n in numbers)
25
+ assert final["run"]["gates"] == {"fast": 0, "full": 320}
26
+ assert all(final["tickets"][n]["green_gates"]["fast"] == list(range(40)) and final["tickets"][n]["round"] == 39 for n in numbers)
27
27
  assert [p.name for p in state.path.parent.iterdir()] == ["state.json"]
28
28
 
29
29
 
@@ -36,8 +36,8 @@ def test_start_keeps_a_recorded_run_and_adds_only_the_new_tickets(tmp_path):
36
36
  assert (again["run"]["revision"], again["run"]["pr_branch"]) == (revision, "feat/x")
37
37
  assert again["tickets"]["01"]["phase"] == "merged" and again["tickets"]["01"]["fixtures"] == []
38
38
  assert again["tickets"]["02"] == {
39
- "phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": [], "slot": None,
40
- "note": "", "held": {}, "rejected": {}, "fixtures": []}
39
+ "phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": {"fast": [], "full": []}, "slot": None,
40
+ "note": "", "held": {}, "rejected": {}, "fixtures": [], "landing": None}
41
41
 
42
42
 
43
43
  def test_verified_trusts_a_tip_only_while_it_is_on_the_ticket_branch(repo, tmp_path):
@@ -6,7 +6,7 @@ import driver_summary
6
6
  def test_render_counts_gates_agents_time_rounds_stops_and_cost():
7
7
  ticket = lambda phase, rounds: {"phase": phase, "round": rounds}
8
8
  agent = lambda role, entry, seconds, cost: {"role": role, "entry": entry, "seconds": seconds, "cost": cost}
9
- state = {"run": {"pr_branch": "feat/csv", "gates": 4, "stops": 1, "final": driver_state._final(),
9
+ state = {"run": {"pr_branch": "feat/csv", "gates": {"fast": 3, "full": 4}, "stops": 1, "final": driver_state._final(),
10
10
  "agents": [agent("test-writer", "sonnet@medium", 2.0, 0.25), agent("implementer", "opus@medium", 3.5, 0.5),
11
11
  agent("implementer", "opus@medium", 1.25, 0), agent("implementer", "fable@high", 1, 1.0)]},
12
12
  "tickets": {"01": ticket("merged", 1), "02": ticket("pending", 0), "03": ticket("blocked", 0)}}
@@ -16,7 +16,8 @@ Ticket 03 is not merged: its phase is blocked.
16
16
 
17
17
  | Measure | Value |
18
18
  |---|---|
19
- | gates run | 4 |
19
+ | fast gates run | 3 |
20
+ | full gates run | 4 |
20
21
  | agents, test-writer on sonnet@medium | 1 |
21
22
  | agents, implementer on opus@medium | 2 |
22
23
  | agents, implementer on fable@high | 1 |
@@ -30,7 +30,7 @@ class Inside(test_final.Final):
30
30
 
31
31
  def run(self, steps, *extra, parallel="2", watch=False):
32
32
  (self.rig / "plan.json").write_text(json.dumps(steps))
33
- args = ["--tickets", ".agent/tickets", "--gate", str(self.rig / "gate"), "--spec", "specs/csv/spec.md",
33
+ args = ["--tickets", ".agent/tickets", "--gate", f"TIER=full {self.rig / 'gate'}", "--fast-gate", f"TIER=fast {self.rig / 'gate'}", "--spec", "specs/csv/spec.md",
34
34
  "--models", str(self.models), "--runner", str(self.rig / "run-agent"), "--parallel", parallel, *extra]
35
35
  here, out = os.getcwd(), io.StringIO()
36
36
  os.chdir(self.repo)
@@ -52,9 +52,11 @@ class Inside(test_final.Final):
52
52
 
53
53
  @pytest.fixture(autouse=True)
54
54
  def tools(monkeypatch, tmp_path):
55
- """The fake `gh` of the rig is on PATH, and no git call of an agent opens an editor."""
55
+ """The fake `gh` of the rig is on PATH, no git call of an agent opens an editor, and the driver signs no commit."""
56
56
  monkeypatch.setenv("PATH", f"{tmp_path / 'bin'}{os.pathsep}{os.environ['PATH']}")
57
57
  monkeypatch.setenv("GIT_EDITOR", "true")
58
+ for name, value in (("GIT_CONFIG_COUNT", "1"), ("GIT_CONFIG_KEY_0", "commit.gpgsign"), ("GIT_CONFIG_VALUE_0", "false")):
59
+ monkeypatch.setenv(name, value)
58
60
 
59
61
 
60
62
  def stray(rig, text="by hand"):
@@ -80,7 +82,7 @@ def test_a_local_run_stops_before_the_push_and_a_push_rerun_pushes_and_opens_the
80
82
  assert len(rig.commits(rig.start, rig.recovery())) == 6
81
83
  assert ref(rig.repo, "feat/csv^{tree}") == ref(rig.repo, "refs/implement-spec/feat%2Fcsv/recovery^{tree}")
82
84
  assert rig.led("Recovery point: feat/csv was at " + rig.recovery(), ref(rig.repo, "feat/csv^{tree}"))
83
- assert rig.led("End of run: final-reviewer ran on", FABLE) and rig.led("End of run: the gate is green on " + tip[:7])
85
+ assert rig.led("End of run: final-reviewer ran on", FABLE) and rig.led("End of run: the full gate is green on " + tip[:7])
84
86
  assert {nn: e["tip"] for nn, e in rig.state()["tickets"].items()} == {nn: r["sha"] for nn, r in zip(order, rows)}
85
87
  assert f"The final review covers feat/csv up to {tip[:7]}. Nothing is pushed." in rig.out
86
88
  assert git(rig.repo, "symbolic-ref", "--short", "HEAD").strip() == "feat/csv" and git(rig.repo, "status", "--short") == ""
@@ -304,9 +306,10 @@ def test_a_red_gate_on_the_tidied_tip_stops_before_the_final_review(tmp_path):
304
306
  rig = Inside(tmp_path, ONE, gate={"red": ["feat/csv"]})
305
307
  rig.run(plan(), *UNATTENDED)
306
308
  assert rig.code == 1 and not rig.final_calls("final-reviewer") and rig.pushes() == [], rig.out
307
- assert rig.led("End of run: BLOCKED at the gate: the gate is red on " + rig.branch()[:7])
309
+ assert rig.led("End of run: BLOCKED at the gate: the full gate is red on " + rig.branch()[:7])
308
310
  assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["final"]}
309
- assert rig.state()["run"]["gates"] == 2 and "| gates run | 2 |" in rig.out
311
+ # The fast gate of the ticket tip, the full gate of its fast-forward, and the full gate of the tidied tip.
312
+ assert rig.state()["run"]["gates"] == {"fast": 1, "full": 2} and "| full gates run | 2 |" in rig.out
310
313
 
311
314
 
312
315
  # ---------------------------------------------------------------- the triage after the second round
@@ -377,7 +380,7 @@ def test_a_base_that_moved_with_no_conflict_is_rebased_onto_with_no_agent_and_on
377
380
  order = rig.order()
378
381
  assert [r["subject"] for r in rows] == [f"feat({nn}): {TITLES[nn]}" for nn in order] and order[2] == "02"
379
382
  assert ref(rig.repo, "feat/csv~3") == base and git(rig.repo, "show", "feat/csv:docs.md") == "base docs\n"
380
- assert [p.name for p in (rig.repo / ".agent/implement/final").glob("gate-*.log")] == [f"gate-{rig.branch()[:7]}.log"]
383
+ assert [p.name for p in (rig.repo / ".agent/implement/final").glob("gate-*.log")] == [f"gate-full-{rig.branch()[:7]}.log"]
381
384
  assert rig.final()["commits"] == {nn: row["sha"] for nn, row in zip(order, rows)}
382
385
  assert rig.final()["onto"] == base and f"Range: {base}..{rig.branch()}\n" in rig.final_calls("final-reviewer")[0]["prompt"]
383
386
  assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"] and stage(rig) == {"stage": "implement", "status": "done"}
@@ -397,7 +400,7 @@ def test_a_resolved_rebase_keeps_the_ticket_messages_and_gates_the_rebased_tip_a
397
400
  (line,) = rig.led("Rebase: the conflict agent resolved the conflict with main in demo/cli.py at ")
398
401
  rebased = line.rstrip(".").split()[-1]
399
402
  records = sorted(p.name for p in (rig.repo / ".agent/implement/final").glob("gate-*.log"))
400
- assert records == sorted([f"gate-{rebased}.log", f"gate-{rig.branch()[:7]}.log"]) and rebased != rig.branch()[:7]
403
+ assert records == sorted([f"gate-full-{rebased}.log", f"gate-full-{rig.branch()[:7]}.log"]) and rebased != rig.branch()[:7]
401
404
  assert ref(rig.repo, f"{rebased}^{{tree}}") == ref(rig.repo, "feat/csv^{tree}")
402
405
 
403
406
 
@@ -429,11 +432,11 @@ def test_a_conflict_agent_that_gives_up_leaves_no_rebase_open(tmp_path):
429
432
 
430
433
 
431
434
  def test_a_red_gate_after_the_rebase_leaves_the_branch_unrewritten(tmp_path):
432
- rig = Inside(tmp_path, ONE, gate={"red": ["HEAD"]}) # red on a detached commit: the rebased tip
435
+ rig = Inside(tmp_path, ONE, gate={"unbranched": True}) # red on a commit that no branch holds: the rebased tip
433
436
  rig.move_base({"demo/export.py": "def export_csv():\n return 'base'\n"})
434
437
  rig.run(plan(**{"final/conflict": [{**RESOLVE, "files": {"demo/export.py": "x = 1\n"}}]}))
435
438
  assert rig.code == 1 and rig.branch() == rig.recovery(), rig.out
436
- assert rig.led("End of run: BLOCKED at the rewrite: the gate after the rebase: the gate is red on ")
439
+ assert rig.led("End of run: BLOCKED at the rewrite: the gate after the rebase: the full gate is red on ")
437
440
 
438
441
 
439
442
  def test_a_base_that_holds_a_ticket_commit_already_leaves_the_branch_unrewritten(tmp_path):
@@ -509,12 +512,12 @@ def test_a_reviewed_tip_with_no_green_gate_record_is_not_pushed(tmp_path):
509
512
  rig = Inside(tmp_path, ONE)
510
513
  rig.run(plan())
511
514
  state = rig.state()
512
- state["run"]["final"]["green_gates"] = []
515
+ state["run"]["final"]["green_gates"] = {"fast": [], "full": []}
513
516
  (rig.repo / ".agent/implement/state.json").write_text(json.dumps(state))
514
517
  rig.run(plan(), "--push")
515
518
  assert rig.code == 1 and rig.pushes() == [] and not rig.prs(), rig.out
516
519
  assert rig.led(f"End of run: BLOCKED at the reviewed tip {rig.branch()[:7]} is not the tip of feat/csv with a green "
517
- "gate record: nothing is pushed.")
520
+ "full gate record: nothing is pushed.")
518
521
 
519
522
 
520
523
  def test_the_rerun_command_drops_the_answers_and_the_pr_title_falls_back_to_the_branch():
@@ -576,7 +579,7 @@ def test_without_an_origin_the_run_ends_reviewed_and_a_push_is_refused_at_the_st
576
579
  assert rig.led("BLOCKED") == [
577
580
  "End of run: BLOCKED at the end of run tidied feat/csv when the repository had no origin remote, so it is on "
578
581
  "no base branch of origin: nothing is pushed."]
579
- fresh = {"pr_branch": "feat/x", "gates": 0, "stops": 0, "agents": [], "final": driver_state._final()}
582
+ fresh = {"pr_branch": "feat/x", "gates": {"fast": 0, "full": 0}, "stops": 0, "agents": [], "final": driver_state._final()}
580
583
  assert driver_summary.render({"run": fresh, "tickets": {}}).startswith("0 of 0 tickets are merged into feat/x.\n\n| Measure")
581
584
 
582
585
 
@@ -603,7 +606,7 @@ def test_a_history_that_origin_already_has_is_not_rebased_and_not_tidied(tmp_pat
603
606
  assert [r["subject"] for r in rig.commits(published)] == ["test: 01 red", "feat: 01 rows"], "no tidy"
604
607
  assert ref(rig.repo, "feat/csv~2") == published and not rig.recovery(), "no rebase, so no recovery point"
605
608
  assert len(rig.led("End of run: origin has commits of feat/csv, so its history is kept as it is: no tidy and no rebase")) == 1
606
- assert len(rig.final_calls("final-reviewer")) == 1 and rig.led("End of run: the gate is green on " + rig.branch()[:7])
609
+ assert len(rig.final_calls("final-reviewer")) == 1 and rig.led("End of run: the full gate is green on " + rig.branch()[:7])
607
610
  assert rig.pushes()[-1] == f"refs/heads/feat/csv {rig.branch()}" and ref(rig.origin, "refs/heads/feat/csv") == rig.branch()
608
611
  assert f"- 01: {rig.branch()[:7]} Export rows" in rig.prs()[0]["body"] and stage(rig)["status"] == "done"
609
612