@jesdi/skills 0.0.75 → 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 (32) hide show
  1. package/package.json +1 -1
  2. package/skills/implement-spec/README.md +26 -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 +52 -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_report.py +10 -3
  10. package/skills/implement-spec/driver_run.py +17 -13
  11. package/skills/implement-spec/driver_state.py +17 -7
  12. package/skills/implement-spec/driver_summary.py +1 -1
  13. package/skills/implement-spec/prompts/final-fixer.md +1 -1
  14. package/skills/implement-spec/prompts/final-reviewer.md +2 -2
  15. package/skills/implement-spec/prompts/fixer.md +1 -1
  16. package/skills/implement-spec/prompts/implementer.md +1 -1
  17. package/skills/implement-spec/prompts/landing-merge.md +1 -0
  18. package/skills/implement-spec/prompts/landing-red.md +2 -0
  19. package/skills/implement-spec/tests/test_agents.py +2 -2
  20. package/skills/implement-spec/tests/test_amendments.py +1 -1
  21. package/skills/implement-spec/tests/test_cli.py +4 -4
  22. package/skills/implement-spec/tests/test_driver.py +73 -30
  23. package/skills/implement-spec/tests/test_final.py +14 -7
  24. package/skills/implement-spec/tests/test_fixloop.py +172 -21
  25. package/skills/implement-spec/tests/test_landing.py +1 -1
  26. package/skills/implement-spec/tests/test_report.py +2 -2
  27. package/skills/implement-spec/tests/test_review.py +16 -8
  28. package/skills/implement-spec/tests/test_state.py +6 -6
  29. package/skills/implement-spec/tests/test_summary.py +3 -2
  30. package/skills/implement-spec/tests/test_tidy.py +13 -12
  31. package/skills/implement-spec/tests/test_walk.py +52 -35
  32. package/skills-manifest.json +3 -3
@@ -18,7 +18,7 @@ import driver_state
18
18
 
19
19
  from conftest import GIT, ticket
20
20
 
21
- ARGS = ["--gate", "make check", "--dry-run"]
21
+ ARGS = ["--gate", "make check", "--fast-gate", "make check", "--dry-run"]
22
22
 
23
23
 
24
24
  def run(capsys, *args):
@@ -33,11 +33,21 @@ def test_valid_set_prints_the_widest_level(repo, capsys):
33
33
 
34
34
  def test_a_run_without_dry_run_needs_the_spec(repo, capsys):
35
35
  repo(t01=ticket("01"))
36
- assert driver.main(["--gate", "make check"]) == 3
36
+ assert driver.main(["--gate", "make check", "--fast-gate", "make fast"]) == 3
37
37
  assert capsys.readouterr().out == "--spec is required: the spec file the prompts point at\n"
38
38
  assert "ticket/feat%2Fx/01" not in subprocess.run(["git", "branch"], capture_output=True, text=True).stdout
39
39
 
40
40
 
41
+ def test_a_run_without_the_fast_gate_stops_before_any_agent_and_changes_nothing(repo, tmp_path, capsys):
42
+ repo(t01=ticket("01"), t02=ticket("02"), t03=ticket("03"))
43
+ runner = tmp_path.parent / f"{tmp_path.name}-runner"
44
+ runner.write_text(f"#!/bin/sh\ntouch {runner}.ran\n")
45
+ runner.chmod(0o755)
46
+ assert driver.main(["--gate", "make check", "--spec", "spec.md", "--runner", str(runner)]) == 3
47
+ assert capsys.readouterr().out.startswith("--fast-gate is required")
48
+ assert not (tmp_path / ".agent/implement").exists() and not Path(f"{runner}.ran").exists()
49
+
50
+
41
51
  def test_every_environment_and_ticket_error_is_listed_together(repo, capsys):
42
52
  root = repo(t01=ticket("01", "02"), t02=ticket("02", "01"), t03=ticket("03", "09, Nope", touches=""))
43
53
  (root / ".gitignore").write_text("")
@@ -143,7 +153,7 @@ def agents(tmp_path, capsys, body, *args, seam="none — refactor"):
143
153
  runner = tmp_path.parent / f"{tmp_path.name}-runner"
144
154
  runner.write_text(f"#!/bin/sh\nrole=$1 prompt=$2 report=$3\n{'' if '--only' in args else CLEAN}{body}")
145
155
  runner.chmod(0o755)
146
- code = driver.main(["--gate", "true", "--spec", "spec.md", "--runner", str(runner), *args])
156
+ code = driver.main(["--gate", "true", "--fast-gate", "true", "--spec", "spec.md", "--runner", str(runner), *args])
147
157
  capsys.readouterr()
148
158
  ledger = tmp_path / ".agent/implement/ledger.md"
149
159
  return code, ledger_of(tmp_path)
@@ -180,8 +190,9 @@ def test_accepted_reports_end_the_run_with_exit_0(repo, tmp_path, capsys):
180
190
  tip = walked("--short=7")
181
191
  assert [line.partition(" for ")[0] for line in ledger] == [
182
192
  "Ticket 01: test-writer ran on claude-sonnet-5-5@medium", "Ticket 01: implementer ran on claude-sonnet-5-5@medium",
183
- f"Ticket 01: the gate is green on {tip}, record .agent/implement/01/gate-{tip}.log.",
193
+ f"Ticket 01: the fast gate is green on {tip}, record .agent/implement/01/gate-fast-{tip}.log.",
184
194
  "Ticket 01: reviewer ran on openai/gpt-6-astra@medium",
195
+ f"Ticket 01: the full gate is green on {tip}, record .agent/implement/01/gate-full-{tip}.log.",
185
196
  f"Ticket 01: merged into feat/x as a fast-forward at {tip}."]
186
197
  assert ledger[1].endswith(", cost 0.25 USD: report accepted.")
187
198
  assert branches() == ["feat/x"] and "nothing to commit" in subprocess.run(
@@ -214,7 +225,7 @@ def test_an_agent_that_writes_no_report_is_rerun_once_then_blocks(repo, tmp_path
214
225
  def test_a_field_of_another_role_is_ignored(repo, tmp_path, capsys, extra):
215
226
  repo()
216
227
  code, ledger = agents(tmp_path, capsys, f"{COMMIT}fields='\"green\": [], {extra}'\n{REPORT}")
217
- assert code == 0 and len(ledger) == 4 and ledger[0].endswith("report accepted.")
228
+ assert code == 0 and len(ledger) == 5 and ledger[0].endswith("report accepted.")
218
229
 
219
230
 
220
231
  @pytest.mark.parametrize("status", ["BLOCKED", "NEEDS_CONTEXT"])
@@ -359,9 +370,11 @@ WORK = """nn=$(basename "$(dirname "$report")"); fields='"green": ["1 passed"]'
359
370
  echo "$role $nn" >> "${FILE:-work-$nn.txt}"; git add -A; git commit -q -m "$role $nn"
360
371
  echo "$nn $PWD" >> "$0.calls"
361
372
  """
362
- # Ticket 01 waits until ticket 02 has its branch, so both start from the same PR tip.
363
- TOGETHER = """[ "$nn" != 01 ] || until git rev-parse -q --verify refs/heads/ticket/feat%2Fx/02 > /dev/null; do sleep 0.02; done\n"""
373
+ # The implementer of ticket 01 waits until ticket 02 has its branch, so both start from the same PR tip.
374
+ TOGETHER = """[ "$nn" != 01 ] || [ $role != implementer ] || until git rev-parse -q --verify refs/heads/ticket/feat%2Fx/02 > /dev/null; do sleep 0.02; done\n"""
364
375
  REFACTOR = {"seam": "none — refactor"}
376
+ # A fixer's report names its ticket: with WORK, each fix round is one commit.
377
+ FIXES = """[ $role != fixer ] || fields="$fields, \\"ticket\\": \\"$nn\\""\n"""
365
378
  # A fixer that cannot make the red gate green: the ticket blocks at fix round 1.
366
379
  GIVE_UP = """[ $role != fixer ] || { printf '{"status": "BLOCKED", "commits": [], "files": [], "concerns": ["the gate stays red"], "green": [], "ticket": "01"}' > "$report"; exit 0; }\n"""
367
380
  GAVE_UP = "Ticket 01: BLOCKED at fix round 1: the fixer reported BLOCKED: the gate stays red."
@@ -373,7 +386,7 @@ def walk(tmp_path, capsys, body, *args, gate="true"):
373
386
  runner = tmp_path.parent / f"{tmp_path.name}-runner"
374
387
  runner.write_text(f"#!/bin/sh\nrole=$1 prompt=$2 report=$3\n{CLEAN}{body}")
375
388
  runner.chmod(0o755)
376
- code = driver.main(["--gate", gate, "--spec", "spec.md", "--runner", str(runner), *args])
389
+ code = driver.main(["--gate", gate, "--fast-gate", gate, "--spec", "spec.md", "--runner", str(runner), *args])
377
390
  return code, ledger_of(tmp_path), capsys.readouterr().out
378
391
 
379
392
 
@@ -397,8 +410,10 @@ def test_two_tickets_run_in_two_slots_and_the_second_merge_is_a_gated_merge_comm
397
410
  calls = dict(line.split() for line in Path(f"{tmp_path}-runner.calls").read_text().splitlines())
398
411
  assert calls == {"01": str(tmp_path.resolve()), "02": str((tmp_path / ".agent/worktrees/slot-2").resolve())}
399
412
  assert len(out_of("git", "rev-list", "--parents", "-n1", walked()).split()) == 3 # a merge commit
400
- # Each ticket tip and the merge commit; the fourth gate is that of the end of run, on the tidied tip.
401
- assert len([line for line in ledger if "the gate is green" in line]) == 3 and "| gates run | 4 |" in out
413
+ # A fast gate on each ticket tip, a full gate on the fast-forward and on the merge commit; the fifth gate is the
414
+ # full gate of the end of run, on the tidied tip.
415
+ assert len([line for line in ledger if "gate is green" in line]) == 4
416
+ assert "| fast gates run | 2 |" in out and "| full gates run | 3 |" in out
402
417
  assert [line for line in ledger if "merged into feat/x as a merge commit" in line]
403
418
  assert {entry["phase"] for entry in state_of(tmp_path)["tickets"].values()} == {"merged"}
404
419
  assert branches() == ["feat/x"] and out_of("git", "status", "--porcelain") == ""
@@ -423,8 +438,9 @@ def test_a_merge_conflict_goes_to_the_conflict_agent_once_and_its_commit_is_gate
423
438
  (line,) = [line for line in ledger if "the conflict agent resolved the merge conflict in work.txt at " in line]
424
439
  number, tip = line[7:9], walked()
425
440
  assert line.endswith(f" at {tip[:7]}.") and len(out_of("git", "rev-list", "--parents", "-n1", tip).split()) == 3
426
- assert f"Ticket {number}: the gate is green on {tip[:7]}, record .agent/implement/{number}/gate-{tip[:7]}.log." in ledger
427
- assert "| gates run | 4 |" in out and "| agents, conflict on claude-opus-5-5@medium | 1 |" in out
441
+ assert (f"Ticket {number}: the full gate is green on {tip[:7]}, record .agent/implement/{number}/gate-full-{tip[:7]}.log."
442
+ in ledger)
443
+ assert "| fast gates run | 2 |" in out and "| full gates run | 3 |" in out and "| agents, conflict on claude-opus-5-5@medium | 1 |" in out
428
444
  assert dict(state_of(tmp_path)["run"]["landed"])[number] == tip
429
445
  prompt = (tmp_path / f".agent/implement/{number}/conflict-0.prompt.md").read_text()
430
446
  assert "Files in conflict: work.txt\n" in prompt and prompt.rstrip().endswith("one ref store.")
@@ -466,22 +482,25 @@ def test_a_red_gate_is_a_finding_and_the_ticket_it_blocks_never_starts(repo, tmp
466
482
  tip = out_of("git", "rev-parse", "--short=7", "ticket/feat%2Fx/01")
467
483
  assert code == 2 and ledger[-2:] == [GAVE_UP, ASKED], out
468
484
  assert ledger[1] == (f"Ticket 01: critical finding of kind code from the gate at "
469
- f".agent/implement/01/gate-{tip}.log:0: the gate is red on {tip}.")
470
- record = (tmp_path / f".agent/implement/01/gate-{tip}.log").read_text()
485
+ f".agent/implement/01/gate-fast-{tip}.log:0: the fast gate is red on {tip}.")
486
+ record = (tmp_path / f".agent/implement/01/gate-fast-{tip}.log").read_text()
471
487
  assert "status: clean\n" in record and "CHECK-OUTPUT\n\nexit: 1\nafter: clean\nend: " in record
472
- assert "Ticket 02 is not merged: its phase is pending." in out and "| gates run | 1 |" in out
488
+ assert "Ticket 02 is not merged: its phase is pending." in out and "| fast gates run | 1 |" in out
489
+ assert "| full gates run | 0 |" in out
473
490
  assert out_of("git", "symbolic-ref", "--short", "HEAD") == "feat/x"
474
491
  assert walk(tmp_path, capsys, "exit 9\n")[0] == 2 # a BLOCKED ticket stays BLOCKED on a rerun
475
492
 
476
493
 
477
- def test_a_red_merge_gate_blocks_the_ticket_and_the_pr_branch_does_not_move(repo, tmp_path, capsys):
494
+ def test_a_merge_gate_red_after_round_2_blocks_the_ticket_and_the_pr_branch_does_not_move(repo, tmp_path, capsys):
478
495
  two(repo)
479
- gate = 'test "$(git rev-parse --abbrev-ref HEAD)" != HEAD' # red on a detached commit: the merge commit
480
- code, ledger, out = walk(tmp_path, capsys, WORK + TOGETHER + REPORT, gate=gate)
496
+ gate = '[ -z "$(git rev-parse -q --verify HEAD^2)" ]' # red on each merge commit
497
+ code, ledger, out = walk(tmp_path, capsys, WORK + FIXES + TOGETHER + REPORT, gate=gate)
481
498
  assert code == 1, out
482
499
  (line,) = [line for line in ledger if "BLOCKED" in line]
483
- assert "BLOCKED at the merge: the gate is red on " in line
500
+ assert "BLOCKED at the merge: the full gate is red on " in line
484
501
  assert len(out_of("git", "rev-list", "--parents", "-n1", "feat/x").split()) == 2 # no merge commit landed
502
+ # Red full gates at landing start rounds 1 and 2; the third blocks, with no third round.
503
+ assert [line.split()[-2] for line in ledger if "at the landing, so feat/x does not move" in line] == ["1", "2"]
485
504
  assert len(branches()) == 2 and out_of("git", "status", "--porcelain") == ""
486
505
 
487
506
 
@@ -537,12 +556,31 @@ def test_a_resumed_ticket_with_a_settled_gate_merges_without_a_gate_or_an_agent(
537
556
  entry = blocked_then_edited(repo, tmp_path, capsys, phase="merge")
538
557
  tip = entry["tip"]
539
558
  state = state_of(tmp_path)
540
- state["tickets"]["01"]["green_gates"] = [tip]
559
+ state["tickets"]["01"]["green_gates"] = {"fast": [tip], "full": [tip]}
541
560
  (tmp_path / ".agent/implement/state.json").write_text(json.dumps(state))
542
561
  # A gate on the ticket branch is still red, so a second gate for the settled commit would block the ticket. The
543
562
  # one new gate is that of the end of run, on the PR branch.
544
563
  code, ledger, out = walk(tmp_path, capsys, "exit 9\n", gate='[ "$(git rev-parse --abbrev-ref HEAD)" != ticket/feat%2Fx/01 ]')
545
- assert code == 0 and walked() == tip and "| gates run | 2 |" in out
564
+ # The fast gate of the blocked run, and the full gate of the end of run: the landing finds the green full record.
565
+ assert code == 0 and walked() == tip and "| fast gates run | 1 |" in out and "| full gates run | 1 |" in out
566
+ assert not (tmp_path / f".agent/implement/01/gate-full-{tip[:7]}.log").exists()
567
+
568
+
569
+ def test_a_run_of_a_driver_with_untiered_gates_resumes_with_its_greens_as_full_gates(repo, tmp_path, capsys):
570
+ """Schema 2 had one gate, the full one: its green list and its count become the full tier on resume."""
571
+ tip = blocked_then_edited(repo, tmp_path, capsys, phase="merge")["tip"]
572
+ state = state_of(tmp_path)
573
+ state["run"].update(schema=2, gates=4)
574
+ state["run"]["final"]["green_gates"] = []
575
+ for entry in state["tickets"].values():
576
+ entry["green_gates"] = [tip]
577
+ (tmp_path / ".agent/implement/state.json").write_text(json.dumps(state))
578
+ full = tmp_path / f".agent/implement/01/gate-full-{tip[:7]}.log"
579
+ code, ledger, out = walk(tmp_path, capsys, "exit 9\n", gate='[ "$(git rev-parse --abbrev-ref HEAD)" != ticket/feat%2Fx/01 ]')
580
+ after = state_of(tmp_path)
581
+ assert code == 0 and walked() == tip and not full.exists(), out # the fast-forward ran no gate
582
+ assert after["run"]["schema"] == 3 and after["tickets"]["01"]["green_gates"] == {"fast": [], "full": [tip]}
583
+ assert after["run"]["gates"] == {"fast": 0, "full": 5} # the four of the older run and the end of run
546
584
 
547
585
 
548
586
  def as_older_driver(tmp_path, *numbers):
@@ -801,7 +839,9 @@ def test_a_pr_branch_that_another_hand_moves_during_the_merge_gate_starts_the_la
801
839
  subjects = out_of("git", "log", "--format=%s", walked()).splitlines()
802
840
  assert "other" in subjects and {"implementer 01", "implementer 02"} <= set(subjects)
803
841
  assert len([line for line in ledger if "merged into feat/x as a merge commit" in line]) == 1
804
- assert "| gates run | 5 |" in out # two ticket tips, the stale merge commit, the new one, the end of run
842
+ # A fast gate on each ticket tip; a full gate on the fast-forward, the stale merge commit, the new one and at the
843
+ # end of run.
844
+ assert "| fast gates run | 2 |" in out and "| full gates run | 4 |" in out
805
845
 
806
846
 
807
847
  # Ticket 09, review round 1 (m1, Codex 6): the restart has a bound, and only a stale ref starts it.
@@ -819,7 +859,8 @@ def test_a_pr_branch_that_moves_at_each_merge_gate_blocks_the_ticket_after_the_s
819
859
  code, ledger, out = walk(tmp_path, capsys, WORK + TOGETHER + REPORT, gate=MERGE_GATE + MOVE)
820
860
  assert code == 1, out
821
861
  assert "BLOCKED at the merge: " in merge_blocked(ledger) and "feat/x" in merge_blocked(ledger)
822
- assert "| gates run | 4 |" in out # two ticket tips and two merge commits: the landing is tried two times
862
+ # Two ticket tips fast; the fast-forward and two merge commits full: the landing is tried two times.
863
+ assert "| fast gates run | 2 |" in out and "| full gates run | 3 |" in out
823
864
  assert out_of("git", "log", "--format=%s", "feat/x").splitlines().count("other") == 2
824
865
 
825
866
 
@@ -827,9 +868,10 @@ def test_a_red_merge_gate_does_not_start_the_landing_again_when_the_pr_branch_mo
827
868
  two(repo)
828
869
  mark = tmp_path.parent / f"{tmp_path.name}-red"
829
870
  gate = MERGE_GATE + f'[ -e {mark} ] || {{ touch {mark}; {MOVE}; exit 1; }}'
830
- code, ledger, out = walk(tmp_path, capsys, WORK + TOGETHER + REPORT, gate=gate)
831
- assert code == 1 and "BLOCKED at the merge: the gate is red on " in merge_blocked(ledger), out
832
- assert "| gates run | 3 |" in out
871
+ code, ledger, out = walk(tmp_path, capsys, WORK + FIXES + TOGETHER + REPORT, gate=gate)
872
+ assert code == 0 and not [line for line in ledger if "BLOCKED" in line], out
873
+ # The red gate starts fix round 1, not a second landing; the fix lands at the next landing.
874
+ assert len([line for line in ledger if "at the landing, so feat/x does not move and fix round 1 starts" in line]) == 1
833
875
 
834
876
 
835
877
  def test_a_conflict_on_the_second_try_blocks_the_ticket_with_no_conflict_agent(repo, tmp_path, capsys):
@@ -845,7 +887,8 @@ def test_a_conflict_on_the_second_try_blocks_the_ticket_with_no_conflict_agent(r
845
887
  code, ledger, out = walk(tmp_path, capsys, WORK + TOGETHER + REPORT, gate=gate)
846
888
  assert code == 1 and mark.exists(), out
847
889
  assert "BLOCKED at the merge: the merge into the PR branch conflicts in work-0" in merge_blocked(ledger)
848
- assert not [line for line in ledger if "conflict ran on" in line] and "| gates run | 3 |" in out
890
+ assert not [line for line in ledger if "conflict ran on" in line]
891
+ assert "| fast gates run | 2 |" in out and "| full gates run | 2 |" in out
849
892
 
850
893
 
851
894
  def test_the_landing_check_runs_while_the_ticket_holds_the_merge_lock(repo, tmp_path, capsys, monkeypatch):
@@ -876,9 +919,9 @@ def test_a_merge_commit_the_slot_cannot_check_out_is_not_gated_and_does_not_land
876
919
  code, ledger, out = walk(tmp_path, capsys, WORK + TOGETHER + REPORT, gate=gate)
877
920
  assert code == 1, out
878
921
  (line,) = [line for line in ledger if "BLOCKED" in line]
879
- assert "BLOCKED at the merge: the slot is at " in line and "the gate did not run" in line
922
+ assert "BLOCKED at the merge: the slot is at " in line and "the full gate did not run" in line
880
923
  assert len(out_of("git", "rev-list", "--parents", "-n1", "feat/x").split()) == 2 # no merge commit landed
881
- assert "| gates run | 2 |" in out
924
+ assert "| fast gates run | 2 |" in out and "| full gates run | 1 |" in out # the full one: the fast-forward
882
925
 
883
926
 
884
927
  @pytest.mark.parametrize("gate, after", [
@@ -891,7 +934,7 @@ def test_a_gate_that_changes_the_tree_or_moves_head_is_red(repo, tmp_path, capsy
891
934
  assert code == 2 and "from the gate at .agent/implement/01/gate-" in ledger[-4] and ledger[-2:] == [GAVE_UP, ASKED], out
892
935
  record = next((tmp_path / ".agent/implement/01").glob("gate-*.log")).read_text()
893
936
  assert "\nexit: 0\n" in record and after in record
894
- assert state_of(tmp_path)["tickets"]["01"]["green_gates"] == []
937
+ assert state_of(tmp_path)["tickets"]["01"]["green_gates"] == {"fast": [], "full": []}
895
938
  assert "by-the-gate" not in out_of("git", "log", "--format=%s", "feat/x")
896
939
 
897
940
 
@@ -35,7 +35,7 @@ from types import SimpleNamespace
35
35
  import pytest
36
36
 
37
37
  from test_cli import SKILL, git, ticket
38
- from test_review import FABLE, HOOKED, ONE, OPUS, Review, finding, gate_rule, review
38
+ from test_review import FABLE, HOOKED, ONE, OPUS, Review, finding, gate_rule, no_full_gate, review
39
39
  from test_stops import UNATTENDED, decisions, stage
40
40
  from test_walk import fix, impl, plan, tw
41
41
 
@@ -233,12 +233,12 @@ def test_seven_commits_in_merge_order_are_tidied_into_three_ticket_commits_with_
233
233
  def test_one_gate_record_exists_for_the_tidied_tip_and_the_final_reviewer_is_pointed_at_it(story):
234
234
  rig, tip = story.rig, story.local.tip
235
235
  records = sorted((rig.repo / ".agent/implement/final").glob("gate-*.log"))
236
- assert [p.name for p in records] == [f"gate-{tip[:7]}.log"], records
236
+ assert [p.name for p in records] == [f"gate-full-{tip[:7]}.log"], records
237
237
  assert "GATE-OUTPUT-MARK" in records[0].read_text() and tip[:7] in records[0].read_text()
238
238
  (gate,) = [g for g in rig.gates() if g["commit"] == tip]
239
239
  first = rig.final_calls("final-reviewer")[0]
240
240
  assert gate["t0"] < first["t0"], "the gate runs before the final review"
241
- assert f"final/gate-{tip[:7]}.log" in first["prompt"]
241
+ assert f"final/gate-full-{tip[:7]}.log" in first["prompt"]
242
242
 
243
243
 
244
244
  def test_the_final_reviewer_runs_on_the_first_model_entry_pointed_at_review_diff_minors_and_rulings(story):
@@ -353,9 +353,16 @@ def test_final_fix_batch_rejects_an_unaddressed_must_fix(tmp_path):
353
353
  assert any("addressed_must_fix: missing MERGED-QUOTING-REGRESSION (demo/export.py:99)" in line for line in rig.ledger())
354
354
 
355
355
 
356
- def test_the_fixer_of_the_final_review_gets_the_gate_command_and_runs_it_before_it_reports(fixed):
356
+ def test_the_fixer_of_the_final_review_gets_the_fast_gate_with_every_merged_locked_file(fixed):
357
357
  (batch,) = fixed.final_calls("fixer")
358
- gate_rule(batch["prompt"], str(fixed.rig / "gate"))
358
+ gate_rule(batch["prompt"], f"TIER=fast {fixed.rig / 'gate'}", "tests/test_01.py tests/test_02.py tests/test_03.py")
359
+ no_full_gate(fixed)
360
+
361
+
362
+ def test_the_final_reviewer_reads_the_full_record_of_the_reviewed_tip_and_runs_no_gate(fixed):
363
+ for call in fixed.final_calls("final-reviewer"):
364
+ assert f"final/gate-full-{call['head'][:7]}.log" in call["prompt"]
365
+ assert "Do not run a gate yourself." in call["prompt"] and "run the gate yourself" not in call["prompt"]
359
366
 
360
367
 
361
368
  def test_a_scoped_review_covers_the_range_after_the_reviewed_tip_and_one_gate_runs_on_the_new_tip(fixed):
@@ -364,7 +371,7 @@ def test_a_scoped_review_covers_the_range_after_the_reviewed_tip_and_one_gate_ru
364
371
  assert reviewed[:7] in scoped["prompt"] and tip[:7] in scoped["prompt"]
365
372
  assert len([g for g in fixed.gates() if g["commit"] == tip]) == 1
366
373
  records = sorted(p.name for p in (fixed.repo / ".agent/implement/final").glob("gate-*.log"))
367
- assert records == sorted({f"gate-{reviewed[:7]}.log", f"gate-{tip[:7]}.log"})
374
+ assert records == sorted({f"gate-full-{reviewed[:7]}.log", f"gate-full-{tip[:7]}.log"})
368
375
  assert len(fixed.final_calls("final-reviewer")) == 2 and all(stop_lines(fixed.out))
369
376
 
370
377
 
@@ -572,7 +579,7 @@ def pushed_run(tmp_path, monkeypatch, steps, risk_in, gh_fails=False):
572
579
  shutil.copy(PR_RISK / module, where / "pr-risk" / module)
573
580
  env = {**rig.env, "HOME": str(home), "CLAUDE_CONFIG_DIR": str(claude)}
574
581
  (rig.rig / "plan.json").write_text(json.dumps(steps))
575
- args = ["--tickets", ".agent/tickets", "--gate", str(rig.rig / "gate"), "--spec", "specs/csv/spec.md",
582
+ args = ["--tickets", ".agent/tickets", "--gate", f"TIER=full {rig.rig / 'gate'}", "--fast-gate", f"TIER=fast {rig.rig / 'gate'}", "--spec", "specs/csv/spec.md",
576
583
  "--models", str(rig.models), "--runner", str(rig.rig / "run-agent"), "--push"]
577
584
  rig.rerun = lambda: _rerun(rig, ["sh", str(skills / "implement-spec/run.sh"), *args], env)
578
585
  rig.rerun()
@@ -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)