@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.
- package/package.json +1 -1
- package/skills/implement-spec/README.md +27 -22
- package/skills/implement-spec/SKILL.md +1 -1
- package/skills/implement-spec/driver.py +75 -44
- package/skills/implement-spec/driver_final.py +60 -34
- package/skills/implement-spec/driver_fixloop.py +65 -17
- package/skills/implement-spec/driver_gate.py +25 -12
- package/skills/implement-spec/driver_legacy.py +19 -7
- package/skills/implement-spec/driver_merge.py +20 -2
- package/skills/implement-spec/driver_report.py +10 -3
- package/skills/implement-spec/driver_run.py +17 -13
- package/skills/implement-spec/driver_state.py +17 -7
- package/skills/implement-spec/driver_summary.py +1 -1
- package/skills/implement-spec/driver_tidy.py +2 -8
- package/skills/implement-spec/prompts/final-fixer.md +1 -1
- package/skills/implement-spec/prompts/final-reviewer.md +2 -2
- package/skills/implement-spec/prompts/fixer.md +1 -1
- package/skills/implement-spec/prompts/implementer.md +1 -1
- package/skills/implement-spec/prompts/landing-merge.md +1 -0
- package/skills/implement-spec/prompts/landing-red.md +2 -0
- package/skills/implement-spec/tests/test_agents.py +2 -2
- package/skills/implement-spec/tests/test_amendments.py +1 -1
- package/skills/implement-spec/tests/test_cli.py +4 -4
- package/skills/implement-spec/tests/test_driver.py +73 -30
- package/skills/implement-spec/tests/test_final.py +41 -7
- package/skills/implement-spec/tests/test_fixloop.py +172 -21
- package/skills/implement-spec/tests/test_landing.py +1 -1
- package/skills/implement-spec/tests/test_merge.py +8 -0
- package/skills/implement-spec/tests/test_report.py +2 -2
- package/skills/implement-spec/tests/test_review.py +16 -8
- package/skills/implement-spec/tests/test_state.py +6 -6
- package/skills/implement-spec/tests/test_summary.py +3 -2
- package/skills/implement-spec/tests/test_tidy.py +16 -13
- package/skills/implement-spec/tests/test_walk.py +55 -36
- package/skills-manifest.json +3 -3
|
@@ -98,7 +98,7 @@ def models_file(tmp_path, **overrides):
|
|
|
98
98
|
|
|
99
99
|
def drive(env, repo, *args, script=RUN):
|
|
100
100
|
env_vars, _ = env
|
|
101
|
-
args = args or ("--tickets", ".agent/tickets", "--gate", "make check", "--dry-run")
|
|
101
|
+
args = args or ("--tickets", ".agent/tickets", "--gate", "make check", "--fast-gate", "make check", "--dry-run")
|
|
102
102
|
return subprocess.run(["sh", str(script), *args], cwd=repo, env=env_vars,
|
|
103
103
|
text=True, capture_output=True, timeout=300)
|
|
104
104
|
|
|
@@ -227,7 +227,7 @@ def test_models_file_naming_a_provider_without_its_cli_exits_3(env, tmp_path):
|
|
|
227
227
|
(tmp_path / "bin/codex").unlink()
|
|
228
228
|
repo = make_repo(tmp_path / "demo", three())
|
|
229
229
|
models = models_file(tmp_path, implementer=["openai/gpt-sol@medium"])
|
|
230
|
-
proc = drive(env, repo, "--tickets", ".agent/tickets", "--gate", "make check", "--models", str(models), "--dry-run")
|
|
230
|
+
proc = drive(env, repo, "--tickets", ".agent/tickets", "--gate", "make check", "--fast-gate", "make check", "--models", str(models), "--dry-run")
|
|
231
231
|
assert proc.returncode == 3, proc.stderr
|
|
232
232
|
assert any("implementer" in l and "codex" in l for l in proc.stdout.splitlines())
|
|
233
233
|
|
|
@@ -240,7 +240,7 @@ def test_one_implementer_model_is_rejected_before_any_agent(env, tmp_path):
|
|
|
240
240
|
models.write_text(json.dumps(entries))
|
|
241
241
|
before = snapshot(repo)
|
|
242
242
|
|
|
243
|
-
proc = drive(env, repo, "--tickets", ".agent/tickets", "--gate", "make check", "--models", str(models),
|
|
243
|
+
proc = drive(env, repo, "--tickets", ".agent/tickets", "--gate", "make check", "--fast-gate", "make check", "--models", str(models),
|
|
244
244
|
"--dry-run")
|
|
245
245
|
|
|
246
246
|
assert proc.returncode == 3, proc.stdout + proc.stderr
|
|
@@ -259,7 +259,7 @@ def test_valid_set_prints_frontier_width_and_dry_run_creates_nothing(env, tmp_pa
|
|
|
259
259
|
(tmp_path / "run link.sh").symlink_to(RUN)
|
|
260
260
|
script = tmp_path / "run link.sh"
|
|
261
261
|
before = snapshot(repo)
|
|
262
|
-
proc = drive(env, repo, "--tickets", ".agent/tickets", "--gate", "make check", "--dry-run", script=script)
|
|
262
|
+
proc = drive(env, repo, "--tickets", ".agent/tickets", "--gate", "make check", "--fast-gate", "make check", "--dry-run", script=script)
|
|
263
263
|
assert proc.returncode == 0, proc.stdout + proc.stderr
|
|
264
264
|
assert "max frontier width: 2" in proc.stdout
|
|
265
265
|
assert_untouched(proc, repo, before, tmp_path)
|
|
@@ -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) ==
|
|
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
|
-
#
|
|
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
|
-
#
|
|
401
|
-
|
|
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."
|
|
427
|
-
|
|
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
|
|
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 = '
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 ==
|
|
832
|
-
|
|
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]
|
|
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
|
|
|
@@ -23,16 +23,19 @@ Interface choices (ticket 06):
|
|
|
23
23
|
commit of the rebase that touches the same file conflicts again.
|
|
24
24
|
"""
|
|
25
25
|
import json
|
|
26
|
+
import os
|
|
26
27
|
import re
|
|
27
28
|
import shutil
|
|
28
29
|
import subprocess
|
|
29
30
|
import sys
|
|
31
|
+
import tempfile
|
|
32
|
+
from pathlib import Path
|
|
30
33
|
from types import SimpleNamespace
|
|
31
34
|
|
|
32
35
|
import pytest
|
|
33
36
|
|
|
34
37
|
from test_cli import SKILL, git, ticket
|
|
35
|
-
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
|
|
36
39
|
from test_stops import UNATTENDED, decisions, stage
|
|
37
40
|
from test_walk import fix, impl, plan, tw
|
|
38
41
|
|
|
@@ -230,12 +233,12 @@ def test_seven_commits_in_merge_order_are_tidied_into_three_ticket_commits_with_
|
|
|
230
233
|
def test_one_gate_record_exists_for_the_tidied_tip_and_the_final_reviewer_is_pointed_at_it(story):
|
|
231
234
|
rig, tip = story.rig, story.local.tip
|
|
232
235
|
records = sorted((rig.repo / ".agent/implement/final").glob("gate-*.log"))
|
|
233
|
-
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
|
|
234
237
|
assert "GATE-OUTPUT-MARK" in records[0].read_text() and tip[:7] in records[0].read_text()
|
|
235
238
|
(gate,) = [g for g in rig.gates() if g["commit"] == tip]
|
|
236
239
|
first = rig.final_calls("final-reviewer")[0]
|
|
237
240
|
assert gate["t0"] < first["t0"], "the gate runs before the final review"
|
|
238
|
-
assert f"final/gate-{tip[:7]}.log" in first["prompt"]
|
|
241
|
+
assert f"final/gate-full-{tip[:7]}.log" in first["prompt"]
|
|
239
242
|
|
|
240
243
|
|
|
241
244
|
def test_the_final_reviewer_runs_on_the_first_model_entry_pointed_at_review_diff_minors_and_rulings(story):
|
|
@@ -350,9 +353,16 @@ def test_final_fix_batch_rejects_an_unaddressed_must_fix(tmp_path):
|
|
|
350
353
|
assert any("addressed_must_fix: missing MERGED-QUOTING-REGRESSION (demo/export.py:99)" in line for line in rig.ledger())
|
|
351
354
|
|
|
352
355
|
|
|
353
|
-
def
|
|
356
|
+
def test_the_fixer_of_the_final_review_gets_the_fast_gate_with_every_merged_locked_file(fixed):
|
|
354
357
|
(batch,) = fixed.final_calls("fixer")
|
|
355
|
-
gate_rule(batch["prompt"],
|
|
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"]
|
|
356
366
|
|
|
357
367
|
|
|
358
368
|
def test_a_scoped_review_covers_the_range_after_the_reviewed_tip_and_one_gate_runs_on_the_new_tip(fixed):
|
|
@@ -361,7 +371,7 @@ def test_a_scoped_review_covers_the_range_after_the_reviewed_tip_and_one_gate_ru
|
|
|
361
371
|
assert reviewed[:7] in scoped["prompt"] and tip[:7] in scoped["prompt"]
|
|
362
372
|
assert len([g for g in fixed.gates() if g["commit"] == tip]) == 1
|
|
363
373
|
records = sorted(p.name for p in (fixed.repo / ".agent/implement/final").glob("gate-*.log"))
|
|
364
|
-
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"})
|
|
365
375
|
assert len(fixed.final_calls("final-reviewer")) == 2 and all(stop_lines(fixed.out))
|
|
366
376
|
|
|
367
377
|
|
|
@@ -501,6 +511,30 @@ def test_unattended_with_a_blocked_ticket_pushes_nothing_and_exits_1(tmp_path):
|
|
|
501
511
|
assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["01"]}
|
|
502
512
|
|
|
503
513
|
|
|
514
|
+
def test_with_commit_gpgsign_on_every_pushed_commit_is_signed_with_the_configured_key(tmp_path):
|
|
515
|
+
gpg = shutil.which("gpg")
|
|
516
|
+
if not gpg:
|
|
517
|
+
pytest.skip("no gpg")
|
|
518
|
+
home = Path(tempfile.mkdtemp(prefix="gpg", dir="/tmp")) # the agent socket path must stay short
|
|
519
|
+
try:
|
|
520
|
+
rig = Final(tmp_path, THREE)
|
|
521
|
+
rig.env["GNUPGHOME"] = str(home)
|
|
522
|
+
subprocess.run([gpg, "--batch", "--passphrase", "", "--quick-gen-key", "t <t@example.com>", "ed25519",
|
|
523
|
+
"sign", "never"], env=rig.env, check=True, capture_output=True)
|
|
524
|
+
rig.env.update(GIT_CONFIG_COUNT="3", GIT_CONFIG_VALUE_0="true", GIT_CONFIG_KEY_1="gpg.program",
|
|
525
|
+
GIT_CONFIG_VALUE_1=gpg, GIT_CONFIG_KEY_2="user.signingkey", GIT_CONFIG_VALUE_2="t@example.com")
|
|
526
|
+
rig.run(plan(), *UNATTENDED)
|
|
527
|
+
assert rig.code == 0, rig.output()
|
|
528
|
+
pushed = git(rig.repo, "rev-list", f"{rig.start}..{ref(rig.origin, 'refs/heads/feat/csv')}").split()
|
|
529
|
+
assert len(pushed) == 3
|
|
530
|
+
for commit in pushed:
|
|
531
|
+
verified = subprocess.run(["git", "verify-commit", commit], cwd=rig.repo, env=rig.env, capture_output=True)
|
|
532
|
+
assert verified.returncode == 0, (commit, verified.stderr)
|
|
533
|
+
finally:
|
|
534
|
+
subprocess.run([str(Path(gpg).with_name("gpgconf")), "--kill", "gpg-agent"], env={**os.environ, "GNUPGHOME": str(home)})
|
|
535
|
+
shutil.rmtree(home, ignore_errors=True)
|
|
536
|
+
|
|
537
|
+
|
|
504
538
|
# ---------------------------------------------------------------- the merge-risk block of the PR body (ticket 15)
|
|
505
539
|
|
|
506
540
|
PR_RISK = SKILL.parent / "pr-risk"
|
|
@@ -545,7 +579,7 @@ def pushed_run(tmp_path, monkeypatch, steps, risk_in, gh_fails=False):
|
|
|
545
579
|
shutil.copy(PR_RISK / module, where / "pr-risk" / module)
|
|
546
580
|
env = {**rig.env, "HOME": str(home), "CLAUDE_CONFIG_DIR": str(claude)}
|
|
547
581
|
(rig.rig / "plan.json").write_text(json.dumps(steps))
|
|
548
|
-
args = ["--tickets", ".agent/tickets", "--gate",
|
|
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",
|
|
549
583
|
"--models", str(rig.models), "--runner", str(rig.rig / "run-agent"), "--push"]
|
|
550
584
|
rig.rerun = lambda: _rerun(rig, ["sh", str(skills / "implement-spec/run.sh"), *args], env)
|
|
551
585
|
rig.rerun()
|