@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
@@ -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)
@@ -82,7 +82,7 @@ def test_a_local_run_stops_before_the_push_and_a_push_rerun_pushes_and_opens_the
82
82
  assert len(rig.commits(rig.start, rig.recovery())) == 6
83
83
  assert ref(rig.repo, "feat/csv^{tree}") == ref(rig.repo, "refs/implement-spec/feat%2Fcsv/recovery^{tree}")
84
84
  assert rig.led("Recovery point: feat/csv was at " + rig.recovery(), ref(rig.repo, "feat/csv^{tree}"))
85
- 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])
86
86
  assert {nn: e["tip"] for nn, e in rig.state()["tickets"].items()} == {nn: r["sha"] for nn, r in zip(order, rows)}
87
87
  assert f"The final review covers feat/csv up to {tip[:7]}. Nothing is pushed." in rig.out
88
88
  assert git(rig.repo, "symbolic-ref", "--short", "HEAD").strip() == "feat/csv" and git(rig.repo, "status", "--short") == ""
@@ -306,9 +306,10 @@ def test_a_red_gate_on_the_tidied_tip_stops_before_the_final_review(tmp_path):
306
306
  rig = Inside(tmp_path, ONE, gate={"red": ["feat/csv"]})
307
307
  rig.run(plan(), *UNATTENDED)
308
308
  assert rig.code == 1 and not rig.final_calls("final-reviewer") and rig.pushes() == [], rig.out
309
- 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])
310
310
  assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["final"]}
311
- 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
312
313
 
313
314
 
314
315
  # ---------------------------------------------------------------- the triage after the second round
@@ -379,7 +380,7 @@ def test_a_base_that_moved_with_no_conflict_is_rebased_onto_with_no_agent_and_on
379
380
  order = rig.order()
380
381
  assert [r["subject"] for r in rows] == [f"feat({nn}): {TITLES[nn]}" for nn in order] and order[2] == "02"
381
382
  assert ref(rig.repo, "feat/csv~3") == base and git(rig.repo, "show", "feat/csv:docs.md") == "base docs\n"
382
- 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"]
383
384
  assert rig.final()["commits"] == {nn: row["sha"] for nn, row in zip(order, rows)}
384
385
  assert rig.final()["onto"] == base and f"Range: {base}..{rig.branch()}\n" in rig.final_calls("final-reviewer")[0]["prompt"]
385
386
  assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"] and stage(rig) == {"stage": "implement", "status": "done"}
@@ -399,7 +400,7 @@ def test_a_resolved_rebase_keeps_the_ticket_messages_and_gates_the_rebased_tip_a
399
400
  (line,) = rig.led("Rebase: the conflict agent resolved the conflict with main in demo/cli.py at ")
400
401
  rebased = line.rstrip(".").split()[-1]
401
402
  records = sorted(p.name for p in (rig.repo / ".agent/implement/final").glob("gate-*.log"))
402
- 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]
403
404
  assert ref(rig.repo, f"{rebased}^{{tree}}") == ref(rig.repo, "feat/csv^{tree}")
404
405
 
405
406
 
@@ -431,11 +432,11 @@ def test_a_conflict_agent_that_gives_up_leaves_no_rebase_open(tmp_path):
431
432
 
432
433
 
433
434
  def test_a_red_gate_after_the_rebase_leaves_the_branch_unrewritten(tmp_path):
434
- 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
435
436
  rig.move_base({"demo/export.py": "def export_csv():\n return 'base'\n"})
436
437
  rig.run(plan(**{"final/conflict": [{**RESOLVE, "files": {"demo/export.py": "x = 1\n"}}]}))
437
438
  assert rig.code == 1 and rig.branch() == rig.recovery(), rig.out
438
- 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 ")
439
440
 
440
441
 
441
442
  def test_a_base_that_holds_a_ticket_commit_already_leaves_the_branch_unrewritten(tmp_path):
@@ -511,12 +512,12 @@ def test_a_reviewed_tip_with_no_green_gate_record_is_not_pushed(tmp_path):
511
512
  rig = Inside(tmp_path, ONE)
512
513
  rig.run(plan())
513
514
  state = rig.state()
514
- state["run"]["final"]["green_gates"] = []
515
+ state["run"]["final"]["green_gates"] = {"fast": [], "full": []}
515
516
  (rig.repo / ".agent/implement/state.json").write_text(json.dumps(state))
516
517
  rig.run(plan(), "--push")
517
518
  assert rig.code == 1 and rig.pushes() == [] and not rig.prs(), rig.out
518
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 "
519
- "gate record: nothing is pushed.")
520
+ "full gate record: nothing is pushed.")
520
521
 
521
522
 
522
523
  def test_the_rerun_command_drops_the_answers_and_the_pr_title_falls_back_to_the_branch():
@@ -578,7 +579,7 @@ def test_without_an_origin_the_run_ends_reviewed_and_a_push_is_refused_at_the_st
578
579
  assert rig.led("BLOCKED") == [
579
580
  "End of run: BLOCKED at the end of run tidied feat/csv when the repository had no origin remote, so it is on "
580
581
  "no base branch of origin: nothing is pushed."]
581
- 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()}
582
583
  assert driver_summary.render({"run": fresh, "tickets": {}}).startswith("0 of 0 tickets are merged into feat/x.\n\n| Measure")
583
584
 
584
585
 
@@ -605,7 +606,7 @@ def test_a_history_that_origin_already_has_is_not_rebased_and_not_tidied(tmp_pat
605
606
  assert [r["subject"] for r in rig.commits(published)] == ["test: 01 red", "feat: 01 rows"], "no tidy"
606
607
  assert ref(rig.repo, "feat/csv~2") == published and not rig.recovery(), "no rebase, so no recovery point"
607
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
608
- 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])
609
610
  assert rig.pushes()[-1] == f"refs/heads/feat/csv {rig.branch()}" and ref(rig.origin, "refs/heads/feat/csv") == rig.branch()
610
611
  assert f"- 01: {rig.branch()[:7]} Export rows" in rig.prs()[0]["body"] and stage(rig)["status"] == "done"
611
612
 
@@ -1,15 +1,16 @@
1
1
  """Ticket 03 acceptance tests: walk the graph with slots, gate by the driver, merge, resume.
2
2
 
3
- All through `sh run.sh --runner <script> --parallel N [--prepare <cmd>] --gate <cmd>` on the three-ticket fixture
3
+ All through `sh run.sh --runner <script> --parallel N [--prepare <cmd>] --gate <cmd> --fast-gate <cmd>` on the
4
+ three-ticket fixture
4
5
  repository. The fake runner plays test-writer and implementer per ticket; it logs, per call, its cwd, branch, HEAD,
5
- start and end time into `<rig>/calls/`. The gate is a small script that logs its commit, status, branch and
6
- environment into `<rig>/gates/`. Concurrency is steered with signal files (`touch` / `wait` plan keys), never sleeps.
6
+ start and end time into `<rig>/calls/`. The gate is a small script that logs its tier, commit, status, branch and
7
+ environment into `<rig>/gates/`: both tiers run it, with `TIER=fast` or `TIER=full` in front. Concurrency is steered with signal files (`touch` / `wait` plan keys), never sleeps.
7
8
 
8
9
  Interface choices (ticket 03):
9
- - gate record: `.agent/implement/<NN>/gate-<first 7 hex of the commit>.log`.
10
+ - gate record: `.agent/implement/<NN>/gate-<tier>-<first 7 hex of the commit>.log`.
10
11
  - `summary.md` sits in `.agent/implement/` and its table is repeated on stdout.
11
12
  - `state.json` is `{"tickets": {"NN": {phase, round, tip, test_writer_sha, locked, green_gates, slot}}}`;
12
- `green_gates` holds full SHAs (a dict with a `commit` key is accepted too).
13
+ `green_gates` holds full SHAs per tier: `{"fast": [...], "full": [...]}`.
13
14
 
14
15
  Ticket 08: this fixture has no `origin`, and a run that merges every ticket now ends with the tidy, one gate on the
15
16
  tidied tip and the final review. The history as the walk made it is at `refs/implement-spec/feat%2Fcsv/recovery`: `Rig.walked()` is
@@ -103,9 +104,14 @@ conf = json.loads((rig / "gate.json").read_text())
103
104
  (rig / "gates").mkdir(exist_ok=True)
104
105
  branch = git("rev-parse", "--abbrev-ref", "HEAD")
105
106
  subject = git("log", "-1", "--format=%s")
106
- code = 1 if conf.get("all") or branch in conf.get("red", []) or subject in conf.get("subjects", []) else 0
107
- rec = dict(t0=time.time(), cwd=os.path.realpath(os.getcwd()), commit=git("rev-parse", "HEAD"), branch=branch,
108
- status=git("status", "--short"), base=os.environ.get("IMPLEMENT_SPEC_BASE"),
107
+ unbranched = branch == "HEAD" and not git("for-each-ref", "--points-at", "HEAD", "refs/heads") # a commit that no branch holds
108
+ tiered = conf.get(os.environ.get("TIER"), {{}}) # red on this tier only: the subject of HEAD, or of a merge's ticket side
109
+ merged = git("log", "-1", "--format=%s", "HEAD^2") if git("rev-parse", "-q", "--verify", "HEAD^2") else ""
110
+ code = 1 if (conf.get("all") or branch in conf.get("red", []) or subject in conf.get("subjects", [])
111
+ or (conf.get("unbranched") and unbranched)
112
+ or {{subject, merged}} & set(tiered.get("subjects", []))) else 0
113
+ rec = dict(t0=time.time(), tier=os.environ.get("TIER"), cwd=os.path.realpath(os.getcwd()), commit=git("rev-parse", "HEAD"), branch=branch,
114
+ status=git("status", "--short"), base=os.environ.get("IMPLEMENT_SPEC_BASE"), locked=os.environ.get("IMPLEMENT_SPEC_LOCKED"),
109
115
  pycache=os.environ.get("PYTHONPYCACHEPREFIX"), exit=code)
110
116
  print("GATE-OUTPUT-MARK", rec["commit"])
111
117
  (rig / "gates" / f"{{time.time_ns()}}-{{os.getpid()}}.json").write_text(json.dumps(rec))
@@ -190,7 +196,8 @@ class Rig:
190
196
  def run(self, steps, *extra, parallel="2", watch=False):
191
197
  """Run the driver once; with `watch`, read state.json in a tight loop meanwhile (torn reads, snapshots)."""
192
198
  (self.rig / "plan.json").write_text(json.dumps(steps))
193
- args = ["--tickets", ".agent/tickets", "--gate", str(self.rig / "gate"), "--spec", "specs/csv/spec.md",
199
+ args = ["--tickets", ".agent/tickets", "--gate", f"TIER=full {self.rig / 'gate'}",
200
+ "--fast-gate", f"TIER=fast {self.rig / 'gate'}", "--spec", "specs/csv/spec.md",
194
201
  "--models", str(self.models), "--runner", str(self.rig / "run-agent"), "--parallel", parallel, *extra]
195
202
  out, err = self.tmp / "out.txt", self.tmp / "err.txt"
196
203
  with out.open("w") as o, err.open("w") as e:
@@ -222,10 +229,10 @@ class Rig:
222
229
  def sha(self, nn, role):
223
230
  return self.calls(nn, role)[0]["sha"]
224
231
 
225
- def gates(self):
232
+ def gates(self, tier=None):
226
233
  folder = self.rig / "gates"
227
234
  rows = [json.loads(p.read_text()) for p in folder.glob("*.json")] if folder.exists() else []
228
- return sorted(rows, key=lambda r: r["t0"])
235
+ return sorted([r for r in rows if tier in (None, r["tier"])], key=lambda r: r["t0"])
229
236
 
230
237
  def ledger(self):
231
238
  path = self.repo / ".agent/implement/ledger.md"
@@ -255,12 +262,9 @@ class Rig:
255
262
  return f"exit {self.code}\n{self.out}{self.err}"
256
263
 
257
264
 
258
- def commit_of(entry):
259
- return entry if isinstance(entry, str) else entry["commit"]
260
-
261
-
262
265
  def green(state, nn):
263
- return {commit_of(e) for e in state["tickets"][nn]["green_gates"]}
266
+ """The green gates of the ticket as (tier, commit) pairs."""
267
+ return {(tier, commit) for tier, commits in state["tickets"][nn]["green_gates"].items() for commit in commits}
264
268
 
265
269
 
266
270
  @pytest.fixture(scope="module")
@@ -319,36 +323,45 @@ def test_failing_prepare_exits_3_before_any_agent_naming_slot_and_command(tmp_pa
319
323
  assert not rig.calls() and not rig.gates()
320
324
 
321
325
 
322
- def test_fast_forward_merge_has_exactly_one_gate_record_and_no_merge_gate(tmp_path):
326
+ def test_a_fast_forward_merge_has_one_fast_and_one_full_record_of_the_ticket_tip(tmp_path):
323
327
  rig = Rig(tmp_path, {"01-export-rows.md": ticket("01", "Export rows")}).run(plan())
324
328
  assert rig.code == 0, rig.output()
325
329
  a1 = rig.sha("01", "implementer")
326
330
  assert rig.walked() == a1
327
331
  records = sorted((rig.repo / ".agent/implement/01").glob("gate-*.log"))
328
- assert [p.name for p in records] == [f"gate-{a1[:7]}.log"]
329
- text = records[0].read_text()
330
- assert a1[:7] in text and "GATE-OUTPUT-MARK" in text and len(re.findall(r"\d\d:\d\d:\d\d", text)) >= 2
331
- assert re.search(r"exit\D*0", text) and not re.search(r"^(\?\?| M|M |A )", text, re.M)
332
- (gate,) = rig.walk_gates()
333
- assert (gate["commit"], gate["status"], gate["cwd"]) == (a1, "", str(rig.repo.resolve()))
332
+ assert [p.name for p in records] == [f"gate-fast-{a1[:7]}.log", f"gate-full-{a1[:7]}.log"]
333
+ for tier, record in zip(("fast", "full"), records):
334
+ text = record.read_text()
335
+ assert f"tier: {tier}\ncommit: {a1}\n" in text and "GATE-OUTPUT-MARK" in text
336
+ assert len(re.findall(r"\d\d:\d\d:\d\d", text)) >= 2
337
+ assert re.search(r"exit\D*0", text) and not re.search(r"^(\?\?| M|M |A )", text, re.M)
338
+ fast, full = rig.walk_gates()
339
+ assert (fast["tier"], fast["commit"], fast["branch"]) == ("fast", a1, "ticket/feat%2Fcsv/01")
340
+ assert (full["tier"], full["commit"], full["branch"]) == ("full", a1, "HEAD") # the commit that lands, detached
341
+ assert {gate["status"] for gate in (fast, full)} == {""}
342
+ assert {gate["cwd"] for gate in (fast, full)} == {str(rig.repo.resolve())}
334
343
 
335
344
 
336
345
  def test_gate_environment_names_the_pr_branch_and_a_pycache_prefix_under_agent_implement(tmp_path):
337
346
  rig = Rig(tmp_path, {"01-export-rows.md": ticket("01", "Export rows")}).run(plan())
338
347
  assert rig.code == 0, rig.output()
339
- (gate,) = rig.walk_gates()
340
- assert gate["base"] == "feat/csv" and gate["pycache"]
341
- assert os.path.realpath(gate["pycache"]).startswith(str((rig.repo / ".agent/implement").resolve()) + os.sep)
348
+ gates = rig.walk_gates()
349
+ assert [gate["tier"] for gate in gates] == ["fast", "full"]
350
+ for gate in gates:
351
+ assert gate["base"] == "feat/csv" and gate["pycache"]
352
+ assert os.path.realpath(gate["pycache"]).startswith(str((rig.repo / ".agent/implement").resolve()) + os.sep)
342
353
 
343
354
 
344
355
  def test_red_gate_blocks_the_ticket_after_round_2_names_the_record_and_launches_no_review(blocked):
345
356
  assert blocked.code == 1, blocked.output()
346
357
  a1 = blocked.sha("01", "implementer")
347
- finding = f"Ticket 01: critical finding of kind code from the gate at .agent/implement/01/gate-{a1[:7]}.log:0: "
358
+ finding = f"Ticket 01: critical finding of kind code from the gate at .agent/implement/01/gate-fast-{a1[:7]}.log:0: "
348
359
  assert [l for l in blocked.ledger() if l.startswith(finding)], blocked.ledger()
349
- assert re.search(r"exit\D*1", (blocked.repo / f".agent/implement/01/gate-{a1[:7]}.log").read_text())
360
+ assert re.search(r"exit\D*1", (blocked.repo / f".agent/implement/01/gate-fast-{a1[:7]}.log").read_text())
350
361
  last = blocked.calls("01", "fixer")[-1]["sha"]
351
- assert [l for l in blocked.ledger() if "01" in l and "BLOCKED" in l and f"gate-{last[:7]}.log" in l], blocked.ledger()
362
+ assert [l for l in blocked.ledger() if "01" in l and "BLOCKED" in l and f"gate-fast-{last[:7]}.log" in l], blocked.ledger()
363
+ assert not [gate for gate in blocked.gates("full") if gate["branch"] == "ticket/feat%2Fcsv/01"]
364
+ assert not list((blocked.repo / ".agent/implement/01").glob("gate-full-*.log")), "no full gate on a blocked ticket"
352
365
  assert [c["role"] for c in blocked.calls("01")] == ["test-writer", "implementer"] + ["fixer"] * 2
353
366
  assert blocked.state()["tickets"]["01"]["phase"] == "blocked"
354
367
  assert "ticket/feat%2Fcsv/01" in blocked.branches() and "feat: 01 rows" not in blocked.pr_subjects()
@@ -371,8 +384,10 @@ def test_non_fast_forward_merge_is_a_plumbing_merge_commit_gated_once(tmp_path):
371
384
  a01, a03 = rig.sha("01", "implementer"), rig.sha("03", "implementer")
372
385
  tip = rig.walked()
373
386
  assert len(git(rig.repo, "rev-list", "--parents", "-n1", tip).split()) == 3, "tip is a merge commit"
374
- commits = [g["commit"] for g in rig.walk_gates()]
375
- assert sorted(commits) == sorted([a01, a03, tip]), commits
387
+ fast = [g["commit"] for g in rig.walk_gates() if g["tier"] == "fast"]
388
+ full = [g["commit"] for g in rig.walk_gates() if g["tier"] == "full"]
389
+ # 03 lands first, as a fast-forward; 01 lands as the merge commit. No full gate runs on 01's own tip.
390
+ assert sorted(fast) == sorted([a01, a03]) and full == [a03, tip], (fast, full)
376
391
  waited = rig.calls("01", "implementer")[0]
377
392
  assert waited["after_wait"]["branch"] == "ticket/feat%2Fcsv/01" and waited["after_wait"]["head"] == waited["head"]
378
393
  assert waited["after_wait"]["status"] == ""
@@ -406,7 +421,7 @@ def test_state_json_is_atomic_and_no_transition_is_lost_with_two_tickets_in_flig
406
421
  for nn in ("01", "02", "03"):
407
422
  entry = final["tickets"][nn]
408
423
  assert entry["phase"] == "merged" and entry["round"] == 0
409
- assert std.sha(nn, "implementer") in green(final, nn)
424
+ assert ("fast", std.sha(nn, "implementer")) in green(final, nn)
410
425
  assert entry["test_writer_sha"] == std.sha(nn, "test-writer") and entry["locked"] == [f"tests/test_{nn}.py"]
411
426
 
412
427
 
@@ -433,7 +448,7 @@ def test_resume_returns_a_ticket_with_an_unverifiable_tip_to_implement_from_the_
433
448
  state, fake = rig.state(), "1" * 40
434
449
  tw_sha = rig.sha("01", "test-writer")
435
450
  assert state["tickets"]["01"]["test_writer_sha"] == tw_sha
436
- state["tickets"]["01"].update(phase="review", tip=fake, green_gates=[])
451
+ state["tickets"]["01"].update(phase="review", tip=fake, green_gates={"fast": [], "full": []})
437
452
  (rig.repo / ".agent/implement/state.json").write_text(json.dumps(state))
438
453
  before = rig.ledger()
439
454
  rig.gate_conf()
@@ -449,7 +464,7 @@ def test_resume_returns_a_ticket_with_an_unverifiable_tip_to_implement_from_the_
449
464
  def test_resume_keeps_a_settled_gate_and_runs_no_gate_again(tmp_path):
450
465
  rig = single_blocked(tmp_path)
451
466
  a1, state = rig.sha("01", "implementer"), rig.state()
452
- state["tickets"]["01"].update(phase="merge", tip=a1, green_gates=[a1])
467
+ state["tickets"]["01"].update(phase="merge", tip=a1, green_gates={"fast": [a1], "full": [a1]})
453
468
  (rig.repo / ".agent/implement/state.json").write_text(json.dumps(state))
454
469
  gates_before = len(rig.gates())
455
470
  rig.gate_conf(red=["ticket/feat%2Fcsv/01"]) # any gate run on the ticket would block it; the end of run gates feat/csv
@@ -465,7 +480,9 @@ def test_summary_md_and_stdout_carry_the_measurement_table(std):
465
480
  assert rows and all(row in std.out for row in rows), summary
466
481
  lines = summary.splitlines()
467
482
  line = lambda *words: [l for l in lines if all(w in l.lower() for w in words)]
468
- assert [l for l in line("gate") if re.search(rf"\b{len(std.gates())}\b", l)], summary
483
+ for tier in ("fast", "full"):
484
+ assert f"| {tier} gates run | {len(std.gates(tier))} |" in lines, summary
485
+ assert not line("| gates run |"), summary
469
486
  for role in ("test-writer", "implementer"):
470
487
  assert [l for l in line(role) if "anthropic/claude-opus-5@medium" in l and re.search(r"\b3\b", l)], summary
471
488
  assert [l for l in line(role) if re.search(r"\d+(\.\d+)?\s*s\b", l)], summary
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-10-29T01:26:25.649Z",
3
+ "generatedAt": "2026-10-29T07:54:23.516Z",
4
4
  "skills": [
5
5
  {
6
6
  "name": "agents-wayfinder",
@@ -58,8 +58,8 @@
58
58
  },
59
59
  {
60
60
  "name": "implement-spec",
61
- "version": "0.1.45",
62
- "hash": "sha256-414150538cb2f16ab2d27a7c49fd1ee49fc92ac009e775afe9df9ebc46348c1f",
61
+ "version": "0.1.46",
62
+ "hash": "sha256-fc47dd018aeb520ba6db5196f2487bdf126c1c447d250462767f2a1fd72d6664",
63
63
  "description": "Implement a specification in code."
64
64
  },
65
65
  {