@jesdi/skills 0.0.98 → 0.0.100
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/ARCHITECTURE.md +10 -5
- package/skills/implement-spec/README.md +44 -17
- package/skills/implement-spec/SKILL.md +4 -2
- package/skills/implement-spec/driver.py +166 -40
- package/skills/implement-spec/driver_agents.py +26 -8
- package/skills/implement-spec/driver_arbiter.py +89 -0
- package/skills/implement-spec/driver_decisions.py +212 -39
- package/skills/implement-spec/driver_dispute.py +1 -1
- package/skills/implement-spec/driver_final.py +255 -186
- package/skills/implement-spec/driver_final_gate.py +1 -1
- package/skills/implement-spec/driver_legacy.py +15 -2
- package/skills/implement-spec/driver_overturn.py +106 -0
- package/skills/implement-spec/driver_pr.py +277 -0
- package/skills/implement-spec/driver_report.py +24 -6
- package/skills/implement-spec/driver_review.py +10 -4
- package/skills/implement-spec/driver_run.py +38 -15
- package/skills/implement-spec/driver_slots.py +33 -0
- package/skills/implement-spec/driver_state.py +29 -15
- package/skills/implement-spec/driver_summary.py +11 -4
- package/skills/implement-spec/models.json +2 -1
- package/skills/implement-spec/prompts/arbiter.md +38 -0
- package/skills/implement-spec/prompts/conflict.md +1 -1
- package/skills/implement-spec/prompts/pr-body.md +1 -1
- package/skills/implement-spec/recovery.md +4 -4
- package/skills/implement-spec/tests/conftest.py +3 -0
- package/skills/implement-spec/tests/test_arbiter.py +208 -0
- package/skills/implement-spec/tests/test_arbitration.py +1 -1
- package/skills/implement-spec/tests/test_cli.py +1 -1
- package/skills/implement-spec/tests/test_decisions.py +31 -7
- package/skills/implement-spec/tests/test_driver.py +10 -2
- package/skills/implement-spec/tests/test_final.py +34 -9
- package/skills/implement-spec/tests/test_fixloop.py +2 -2
- package/skills/implement-spec/tests/test_leave_out.py +203 -0
- package/skills/implement-spec/tests/test_legacy.py +25 -0
- package/skills/implement-spec/tests/test_lenses.py +6 -4
- package/skills/implement-spec/tests/test_overturn.py +362 -0
- package/skills/implement-spec/tests/test_report.py +1 -1
- package/skills/implement-spec/tests/test_scoped.py +18 -15
- package/skills/implement-spec/tests/test_ship_draft.py +203 -0
- package/skills/implement-spec/tests/test_slots.py +29 -0
- package/skills/implement-spec/tests/test_state.py +4 -2
- package/skills/implement-spec/tests/test_stops.py +21 -5
- package/skills/implement-spec/tests/test_tidy.py +7 -5
- package/skills-manifest.json +3 -3
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"""`ship-draft`: once the driver's retries are spent on an end-of-run stop, a full gate still red after its repair or an
|
|
2
|
+
end-of-run agent that failed twice, the driver pushes the branch tip that a full gate ran on and opens the PR as
|
|
3
|
+
draft, naming the stop. `--ask` (IMPLEMENT_SPEC_ASK=1, which conftest pins) asks the operator instead; a tip no full
|
|
4
|
+
gate ran on, as after a failed rebase conflict agent, still asks.
|
|
5
|
+
|
|
6
|
+
In process, on the rigs of test_tidy and test_lenses."""
|
|
7
|
+
from test_final import RESOLVE, fixer, fn
|
|
8
|
+
from test_fixloop import inside # noqa: F401 (the autouse fixture puts the rig's CLIs on PATH)
|
|
9
|
+
from test_lenses import LENSES, final, rig_of, stopped
|
|
10
|
+
from test_review import RISKY, finding, fix, review
|
|
11
|
+
from test_stops import UNATTENDED, decisions, stage
|
|
12
|
+
from test_tidy import Inside, git, moved, stray
|
|
13
|
+
from test_tidy import tools # noqa: F401 (tools is an autouse fixture)
|
|
14
|
+
from test_walk import plan
|
|
15
|
+
|
|
16
|
+
AUTONOMOUS = ("--no-ask", "--retries", "0", *UNATTENDED)
|
|
17
|
+
FIXER_STOPPED = {"report": {**stopped()["report"], "green": []}}
|
|
18
|
+
DRAFT = {"stage": "implement", "status": "done", "draft": True, "decisions": 1}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def not_reviewed(rig, since):
|
|
22
|
+
"""The coverage line's list of the commits after `since` that no review covered."""
|
|
23
|
+
return "not reviewed: " + "; ".join(f"{c['sha'][:7]} {c['subject']}" for c in rig.commits(since))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def test_a_full_gate_red_after_its_repair_ships_the_repaired_tip_as_draft(tmp_path):
|
|
27
|
+
rig = Inside(tmp_path)
|
|
28
|
+
rig.gate_conf(full={'subjects': ['feat(01): Export rows', 'fix(01): first repair']})
|
|
29
|
+
rig.run(plan(**{'final/fixer': [fixer('first\n', 'first repair', ticket_of='01')]}), *AUTONOMOUS)
|
|
30
|
+
assert rig.code == 0, rig.output()
|
|
31
|
+
assert len(rig.final_calls('fixer')) == 1 and not any(rig.final_calls(role) for role in LENSES)
|
|
32
|
+
assert rig.pushes() == [f'refs/heads/feat/csv {rig.branch()}'], 'the tip the red gate ran on, repair included'
|
|
33
|
+
(pr,) = rig.prs()
|
|
34
|
+
assert '--draft' in pr['argv']
|
|
35
|
+
assert 'the full integration gate remains red after its repair' in pr['body']
|
|
36
|
+
assert rig.led('open as a draft: the end of run stopped: the full integration gate remains red after its repair')
|
|
37
|
+
assert rig.led('(ship-draft)') and rig.led('Ruled by the driver, not the operator.')
|
|
38
|
+
assert not_reviewed(rig, rig.final()['onto']) in pr['body'], 'no review ran, so every commit is unreviewed'
|
|
39
|
+
assert stage(rig) == DRAFT
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_a_lens_that_fails_twice_ships_the_gated_tip_as_draft_naming_the_lens(tmp_path):
|
|
43
|
+
rig = rig_of(tmp_path)
|
|
44
|
+
rig.run(plan(**{"final/final-structure": [stopped(), stopped()]}), *AUTONOMOUS)
|
|
45
|
+
assert rig.code == 0, rig.out
|
|
46
|
+
assert rig.pushes() == [f"refs/heads/feat/csv {rig.final()['tidied']}"]
|
|
47
|
+
(pr,) = rig.prs()
|
|
48
|
+
assert "--draft" in pr["argv"] and "the final-structure: it reported BLOCKED" in pr["body"]
|
|
49
|
+
assert not_reviewed(rig, rig.final()["onto"]) in pr["body"]
|
|
50
|
+
assert not rig.final_calls("fixer")
|
|
51
|
+
assert stage(rig) == DRAFT
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_a_pr_writer_that_fails_twice_ships_a_draft_with_the_facts_of_the_driver(tmp_path):
|
|
55
|
+
rig = rig_of(tmp_path)
|
|
56
|
+
rig.run(plan(**{"final/pr-writer": [stopped(), stopped()]}), *AUTONOMOUS)
|
|
57
|
+
assert rig.code == 0, rig.out
|
|
58
|
+
assert len(rig.final_calls("pr-writer")) == 2, "no third pr-writer"
|
|
59
|
+
(pr,) = rig.prs()
|
|
60
|
+
assert "--draft" in pr["argv"] and pr["body"].startswith("## Tickets")
|
|
61
|
+
assert "(ship-draft): the pr-writer: report: " in pr["body"]
|
|
62
|
+
assert stage(rig) == DRAFT
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def test_a_final_fixer_that_fails_twice_ships_the_reviewed_tip_as_draft(tmp_path):
|
|
66
|
+
rig = rig_of(tmp_path)
|
|
67
|
+
rig.run(plan(**{"final/final-spec": [final(finding("missing --dry-run flag"))],
|
|
68
|
+
"final/fixer": [FIXER_STOPPED] * 2}), *AUTONOMOUS)
|
|
69
|
+
assert rig.code == 0, rig.out
|
|
70
|
+
reviewed = rig.final()["reviewed"]
|
|
71
|
+
assert rig.pushes() == [f"refs/heads/feat/csv {reviewed}"] and rig.branch() == reviewed
|
|
72
|
+
(pr,) = rig.prs()
|
|
73
|
+
assert "--draft" in pr["argv"] and "the fixer: it reported BLOCKED" in pr["body"]
|
|
74
|
+
assert f"Branch tip and reviewed tip: {reviewed}" in pr["body"]
|
|
75
|
+
assert rig.led("a finding ships open: missing --dry-run flag")
|
|
76
|
+
assert stage(rig) == DRAFT
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def test_a_scoped_review_that_fails_twice_ships_the_fixed_tip_as_draft_naming_the_unreviewed_fix(tmp_path):
|
|
80
|
+
rig = rig_of(tmp_path)
|
|
81
|
+
rig.run(plan(**{"final/final-spec": [final(finding("missing --dry-run flag"))],
|
|
82
|
+
"final/fixer": [fixer(fn("02"), "add the flag")],
|
|
83
|
+
"final/final-reviewer": [stopped(), stopped()]}), *AUTONOMOUS)
|
|
84
|
+
assert rig.code == 0, rig.out
|
|
85
|
+
reviewed = rig.final()["reviewed"]
|
|
86
|
+
assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"] and rig.branch() != reviewed
|
|
87
|
+
(pr,) = rig.prs()
|
|
88
|
+
assert "--draft" in pr["argv"] and "the final-reviewer: it reported BLOCKED" in pr["body"]
|
|
89
|
+
assert f"reviewed tip: {reviewed}; {not_reviewed(rig, reviewed)}" in pr["body"]
|
|
90
|
+
assert "fix(02): add the flag" in not_reviewed(rig, reviewed)
|
|
91
|
+
assert stage(rig) == DRAFT
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def test_a_critical_finding_open_when_the_final_fixer_fails_parks_for_the_operator_who_may_ship_it(tmp_path):
|
|
95
|
+
"""No agent ships a critical finding: the driver does not take `ship-draft` itself while one is open."""
|
|
96
|
+
rig = rig_of(tmp_path)
|
|
97
|
+
steps = plan(**{"final/final-correctness": [final(finding("ledger write not atomic", "critical"))],
|
|
98
|
+
"final/fixer": [FIXER_STOPPED] * 2})
|
|
99
|
+
rig.run(steps, *AUTONOMOUS)
|
|
100
|
+
assert rig.code == 2, rig.out
|
|
101
|
+
assert not rig.pushes() and not rig.prs()
|
|
102
|
+
(question,) = decisions(rig)["questions"]
|
|
103
|
+
assert question["id"] == "final-ticket-blocked-1" and "ship-draft" in [o["id"] for o in question["options"]]
|
|
104
|
+
assert not rig.led("(ship-draft)") and rig.final()["ship"] is None
|
|
105
|
+
rig.run(steps, "--answer", "final-ticket-blocked-1=ship-draft", *AUTONOMOUS)
|
|
106
|
+
assert rig.code == 0, rig.out
|
|
107
|
+
assert rig.pushes() == [f"refs/heads/feat/csv {rig.final()['reviewed']}"]
|
|
108
|
+
(pr,) = rig.prs()
|
|
109
|
+
assert "--draft" in pr["argv"] and rig.led("a finding ships open: ledger write not atomic")
|
|
110
|
+
assert not rig.led("Ruled by the driver, not the operator.")
|
|
111
|
+
assert len(rig.final_calls("fixer")) == 2, "the operator's ship-draft runs no more repair"
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_a_run_stopped_after_the_ruling_pushes_the_recorded_tip_and_refuses_a_branch_that_moved(tmp_path):
|
|
115
|
+
rig = rig_of(tmp_path)
|
|
116
|
+
steps = plan(**{"final/final-structure": [stopped(), stopped()]})
|
|
117
|
+
rig.run(steps, "--no-ask", "--retries", "0")
|
|
118
|
+
shipped = rig.final()["ship"]
|
|
119
|
+
assert rig.code == 0 and not rig.pushes(), rig.out
|
|
120
|
+
assert shipped == {"tip": rig.branch(), "stops": [
|
|
121
|
+
{"subject": "the final-structure: it reported BLOCKED: cannot read the spec", "role": "final-structure"}]}
|
|
122
|
+
stray(rig)
|
|
123
|
+
rig.run(steps, "--push")
|
|
124
|
+
assert rig.code == 1 and not rig.pushes(), rig.out
|
|
125
|
+
assert rig.led(f"feat/csv moved from {shipped['tip'][:7]}, the gated tip that the ship-draft ruling ships")
|
|
126
|
+
git(rig.repo, "reset", "-q", "--hard", shipped["tip"])
|
|
127
|
+
rig.run(steps, "--push")
|
|
128
|
+
assert rig.code == 0 and rig.pushes() == [f"refs/heads/feat/csv {shipped['tip']}"], rig.out
|
|
129
|
+
assert len(rig.final_calls("final-structure")) == 2, "the recorded ruling reviews no more"
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def test_a_red_gate_after_the_fix_of_a_critical_finding_parks_for_the_operator_who_may_ship_it(tmp_path):
|
|
133
|
+
"""The fix batch clears the open findings before any review verifies the fix: the full gate red after its repair
|
|
134
|
+
leaves the critical finding unverified, so the driver does not take `ship-draft` itself."""
|
|
135
|
+
rig = Inside(tmp_path)
|
|
136
|
+
rig.gate_conf(full={'subjects': ['fix(01): review fix', 'fix(01): gate repair']})
|
|
137
|
+
steps = plan(**{'final/final-correctness': [final(finding('ledger write not atomic', 'critical'))],
|
|
138
|
+
'final/fixer': [fixer('review\n', 'review fix', ticket_of='01'),
|
|
139
|
+
fixer('gate\n', 'gate repair', ticket_of='01')]})
|
|
140
|
+
rig.run(steps, *AUTONOMOUS)
|
|
141
|
+
assert rig.code == 2, rig.out
|
|
142
|
+
assert not rig.pushes() and not rig.prs()
|
|
143
|
+
assert not rig.final_calls('final-reviewer')
|
|
144
|
+
assert rig.final()['open'] == []
|
|
145
|
+
(question,) = decisions(rig)['questions']
|
|
146
|
+
assert question['id'] == 'final-ticket-blocked-1' and not rig.led('(ship-draft)')
|
|
147
|
+
rig.run(steps, '--answer', 'final-ticket-blocked-1=ship-draft', *AUTONOMOUS)
|
|
148
|
+
assert rig.code == 0, rig.out
|
|
149
|
+
assert rig.pushes() == [f'refs/heads/feat/csv {rig.branch()}'] and len(rig.final_calls('fixer')) == 2
|
|
150
|
+
(pr,) = rig.prs()
|
|
151
|
+
assert '--draft' in pr['argv'] and not rig.led('Ruled by the driver, not the operator.')
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def parks_then_ships_on_the_operators_answer(rig, steps):
|
|
155
|
+
"""The driver does not take `ship-draft` itself: the stop parks; the operator's `ship-draft` ships a draft."""
|
|
156
|
+
rig.run(steps, *AUTONOMOUS)
|
|
157
|
+
assert rig.code == 2, rig.out
|
|
158
|
+
assert not rig.pushes() and not rig.prs() and not rig.led("(ship-draft)")
|
|
159
|
+
(question,) = decisions(rig)["questions"]
|
|
160
|
+
assert question["id"] == "final-ticket-blocked-1"
|
|
161
|
+
rig.run(steps, "--answer", "final-ticket-blocked-1=ship-draft", *AUTONOMOUS)
|
|
162
|
+
assert rig.code == 0, rig.out
|
|
163
|
+
assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"]
|
|
164
|
+
(pr,) = rig.prs()
|
|
165
|
+
assert "--draft" in pr["argv"] and not rig.led("Ruled by the driver, not the operator.")
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def test_a_critical_finding_of_one_lens_when_another_fails_twice_parks_for_the_operator(tmp_path):
|
|
169
|
+
"""No review settled, but the accepted report of the correctness lens holds a critical finding."""
|
|
170
|
+
rig = rig_of(tmp_path)
|
|
171
|
+
parks_then_ships_on_the_operators_answer(rig, plan(**{
|
|
172
|
+
"final/final-correctness": [final(finding("ledger write not atomic", "critical"))],
|
|
173
|
+
"final/final-structure": [stopped(), stopped()]}))
|
|
174
|
+
assert rig.final()["round"] == 0
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def test_a_carried_must_fix_finding_when_the_first_full_gate_stays_red_parks_for_the_operator(tmp_path):
|
|
178
|
+
"""A must-fix finding carried from a ticket that merged at its fix cap is open before any review."""
|
|
179
|
+
rig = rig_of(tmp_path, RISKY)
|
|
180
|
+
rig.gate_conf(full={"subjects": ["feat(02): Quote fields", "fix(02): first repair"]})
|
|
181
|
+
regression = {**finding("QUOTING-REGRESSION"), "basis": "regression"}
|
|
182
|
+
parks_then_ships_on_the_operators_answer(rig, plan(**{
|
|
183
|
+
"02/reviewer": [review("02", [regression])] * 3, "02/fixer": [fix("02", 1), fix("02", 2)],
|
|
184
|
+
"final/fixer": [fixer(fn("02"), "first repair", ticket_of="02")]}))
|
|
185
|
+
assert [item["title"] for item in rig.final()["must_fix"]] == ["QUOTING-REGRESSION"]
|
|
186
|
+
assert not any(rig.final_calls(role) for role in LENSES)
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def test_the_operators_ship_draft_with_no_gated_tip_is_refused_and_retry_remains(tmp_path):
|
|
190
|
+
"""A failed rebase conflict agent leaves no tip that a full gate ran on: `ship-draft` would record nothing to
|
|
191
|
+
push, so the answer is a usage error and the question stays open."""
|
|
192
|
+
stuck = {"report": {"status": "BLOCKED", "commits": [], "files": [], "concerns": ["both sides are needed"]}}
|
|
193
|
+
resolved = {**RESOLVE, "files": {"demo/cli.py": "def main():\n return 'both'\n"}}
|
|
194
|
+
rig = moved(tmp_path, {"demo/cli.py": "def main():\n return 'base'\n"}, stuck, stuck)
|
|
195
|
+
assert rig.code == 2, rig.out
|
|
196
|
+
steps = plan(**{"final/conflict": [stuck, stuck, resolved]})
|
|
197
|
+
rig.run(steps, "--answer", "final-ticket-blocked-1=ship-draft", *UNATTENDED)
|
|
198
|
+
assert rig.code == 3 and "no full gate ran on" in rig.out and "`retry` remains" in rig.out, rig.out
|
|
199
|
+
(question,) = decisions(rig)["questions"]
|
|
200
|
+
assert question["id"] == "final-ticket-blocked-1" and rig.final()["ship"] is None
|
|
201
|
+
rig.run(steps, "--answer", "final-ticket-blocked-1=retry", *UNATTENDED)
|
|
202
|
+
assert rig.code == 0, rig.out
|
|
203
|
+
assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"] and "--draft" not in rig.prs()[0]["argv"]
|
|
@@ -183,3 +183,32 @@ def test_git_without_a_command_still_returns_gits_usage_error(repo):
|
|
|
183
183
|
repo()
|
|
184
184
|
result = driver_slots.git(".")
|
|
185
185
|
assert result.returncode != 0 and "usage: git" in result.stdout + result.stderr
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def test_a_set_aside_never_replaces_an_earlier_patch_and_writes_it_whole_before_the_reset(repo, tmp_path):
|
|
189
|
+
repo()
|
|
190
|
+
assert driver_slots.setup(2, None) == []
|
|
191
|
+
slot = driver_slots.path(2)
|
|
192
|
+
(tmp_path / slot / "wip.txt").write_text("half done\n")
|
|
193
|
+
earlier = tmp_path / "out/left-out.patch"
|
|
194
|
+
earlier.parent.mkdir()
|
|
195
|
+
earlier.write_text("the snapshot of a set-aside whose reset failed\n")
|
|
196
|
+
patch = driver_slots.fresh(earlier)
|
|
197
|
+
assert patch.name == "left-out-2.patch"
|
|
198
|
+
assert driver_slots.set_aside(slot, patch) == ""
|
|
199
|
+
assert "+half done" in patch.read_text() and earlier.read_text().startswith("the snapshot")
|
|
200
|
+
assert sorted(p.name for p in earlier.parent.iterdir()) == ["left-out-2.patch", "left-out.patch"]
|
|
201
|
+
assert driver_slots.git(slot, "status", "--porcelain").stdout == ""
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def test_the_arbiter_checkout_is_removed_through_git_alone(repo, tmp_path):
|
|
205
|
+
import driver_arbiter
|
|
206
|
+
repo()
|
|
207
|
+
scratch = tmp_path / driver_arbiter.SCRATCH
|
|
208
|
+
scratch.mkdir(parents=True)
|
|
209
|
+
(scratch / "keep.txt").write_text("not a worktree of the run\n")
|
|
210
|
+
assert driver_arbiter._remove_scratch().startswith(f"cannot remove {driver_arbiter.SCRATCH}: ")
|
|
211
|
+
assert (scratch / "keep.txt").exists()
|
|
212
|
+
(scratch / "keep.txt").unlink()
|
|
213
|
+
scratch.rmdir()
|
|
214
|
+
assert driver_arbiter._remove_scratch() == ""
|
|
@@ -42,7 +42,7 @@ def test_start_keeps_a_recorded_run_and_adds_only_the_new_tickets(tmp_path):
|
|
|
42
42
|
assert again["tickets"]["01"]["phase"] == "merged" and again["tickets"]["01"]["landing"] is None
|
|
43
43
|
assert again["tickets"]["02"] == {
|
|
44
44
|
"phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": {"fast": [], "full": []}, "slot": None,
|
|
45
|
-
"note": "", "landing": None, "disputes": {}, "corrected": {}, "settled": 0}
|
|
45
|
+
"note": "", "landing": None, "disputes": {}, "corrected": {}, "settled": 0, "replayed": None}
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
def test_verified_trusts_a_tip_only_while_it_is_on_the_ticket_branch(repo, tmp_path):
|
|
@@ -51,13 +51,15 @@ def test_verified_trusts_a_tip_only_while_it_is_on_the_ticket_branch(repo, tmp_p
|
|
|
51
51
|
subprocess.run([*GIT, "commit", "-q", "--allow-empty", "-m", "work"], check=True)
|
|
52
52
|
tip = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True, text=True).stdout.strip()
|
|
53
53
|
subprocess.run(["git", "branch", "ticket/01", tip], check=True)
|
|
54
|
-
entry = {"phase": "review", "tip": tip, "test_writer_sha": tests}
|
|
54
|
+
entry = {"phase": "review", "tip": tip, "test_writer_sha": tests, "replayed": None}
|
|
55
55
|
assert driver_state.verified(entry, "ticket/01", "feat/x") == ({}, "")
|
|
56
56
|
assert driver_state.verified({**entry, "tip": tests}, "ticket/01", "feat/x") == ({}, "") # an earlier commit of the branch
|
|
57
57
|
back = ({"phase": "implement", "tip": tests}, f"the recorded tip {tip[:7]} is not on ticket/02")
|
|
58
58
|
assert driver_state.verified(entry, "ticket/02", "feat/x") == back # no such branch
|
|
59
59
|
subprocess.run(["git", "branch", "-f", "ticket/01", tests], check=True)
|
|
60
60
|
assert driver_state.verified({**entry, "phase": "merge"}, "ticket/01", "feat/x")[0] == {"phase": "implement", "tip": tests}
|
|
61
|
+
# A replay onto the rewritten PR branch stopped before its tip was recorded: the landing puts the branch back.
|
|
62
|
+
assert driver_state.verified({**entry, "phase": "merge", "replayed": tip}, "ticket/01", "feat/x") == ({}, "")
|
|
61
63
|
# No accepted implementation yet, or finished: nothing to check.
|
|
62
64
|
for phase in ("pending", "test-writer", "implement", "blocked"):
|
|
63
65
|
assert driver_state.verified({**entry, "phase": phase, "tip": "1" * 40}, "ticket/01", "feat/x") == ({}, "")
|
|
@@ -40,6 +40,7 @@ from test_walk import impl, plan
|
|
|
40
40
|
|
|
41
41
|
STOP = "no write access to fixtures/"
|
|
42
42
|
UNATTENDED = ("--unattended", "--stage-json", ".agent/stage.json")
|
|
43
|
+
DONE = {"stage": "implement", "status": "done", "draft": False, "decisions": 0} # a ready PR, no ruling
|
|
43
44
|
Q1 = "01-ticket-blocked-1"
|
|
44
45
|
RULED = "Ruling: 01 runs again (retry)"
|
|
45
46
|
|
|
@@ -93,7 +94,7 @@ def test_a_blocked_ticket_writes_one_question_with_pointers(local):
|
|
|
93
94
|
assert local.code == 2, local.output()
|
|
94
95
|
(q,) = decisions(local)["questions"]
|
|
95
96
|
assert q["id"] == Q1
|
|
96
|
-
assert {o["id"] for o in q["options"]} == {"retry", "edit"}
|
|
97
|
+
assert {o["id"] for o in q["options"]} == {"retry", "leave-out", "edit"}
|
|
97
98
|
assert q["recommended"] == "retry"
|
|
98
99
|
assert q["title"] and q["why"]
|
|
99
100
|
evidence = "\n".join(q["evidence"])
|
|
@@ -214,7 +215,7 @@ def test_unattended_rerun_with_a_submitted_answers_file_at_the_current_revision_
|
|
|
214
215
|
assert rig.code == 0, rig.output()
|
|
215
216
|
assert Q1 not in rig.out + rig.err and rig.led(RULED)
|
|
216
217
|
assert len(rig.calls("01", "implementer")) == 3 and "feat: 01 rows" in rig.pr_subjects()
|
|
217
|
-
assert stage(rig) ==
|
|
218
|
+
assert stage(rig) == DONE
|
|
218
219
|
|
|
219
220
|
|
|
220
221
|
def test_unattended_blocked_ticket_ends_with_stage_json_blocked_naming_it_and_exit_1(tmp_path):
|
|
@@ -234,7 +235,7 @@ def test_with_retries_the_driver_answers_retry_itself_and_lists_its_decision_at_
|
|
|
234
235
|
assert len(rig.calls("01", "implementer")) == 3 and "feat: 01 rows" in rig.pr_subjects()
|
|
235
236
|
summary = (rig.repo / ".agent/implement/summary.md").read_text()
|
|
236
237
|
assert "| human stops | 0 |" in summary and "| stops the driver ruled on | 1 |" in summary
|
|
237
|
-
assert "Driver decisions, taken without the operator:\n-
|
|
238
|
+
assert f"Driver decisions, taken without the operator:\n- {Q1}: {RULED}" in summary
|
|
238
239
|
assert not answers_file(rig).exists()
|
|
239
240
|
|
|
240
241
|
|
|
@@ -248,6 +249,21 @@ def test_after_the_retries_are_spent_the_next_stop_of_the_ticket_asks_the_operat
|
|
|
248
249
|
|
|
249
250
|
def test_the_driver_answers_only_a_recommended_retry():
|
|
250
251
|
import driver_decisions
|
|
251
|
-
ask = lambda id, recommended: {"id": id, "ticket": "01", "
|
|
252
|
+
ask = lambda id, recommended: {"id": id, "ticket": "01", "kind": "ticket-blocked", "stop": 1, "answer": None,
|
|
253
|
+
"recommended": recommended}
|
|
252
254
|
questions = [ask("a", "retry"), ask("b", "accept"), ask("c", "")]
|
|
253
|
-
assert driver_decisions.automatic(questions, 2) == {"a": "retry"}
|
|
255
|
+
assert driver_decisions.automatic(questions, 2, 0) == {"a": "retry"}
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_the_must_fix_retries_count_only_the_stops_with_a_must_fix_finding():
|
|
259
|
+
"""`--must-fix-retries N`: N more fix batches beyond `--retries` while a critical or must-fix finding is open,
|
|
260
|
+
whatever else stopped the end of run. A `finding-open` question keeps the budget of every stop."""
|
|
261
|
+
import driver_decisions
|
|
262
|
+
ask = lambda id, kind, stop, answer=None, by=None: {"id": id, "ticket": "final", "kind": kind, "stop": stop,
|
|
263
|
+
"answer": answer, "by": by, "recommended": "retry"}
|
|
264
|
+
ruled = [ask("b1", "ticket-blocked", 1, "retry", "driver"), ask("m1", "finding-must-fix", 2, "retry", "driver")]
|
|
265
|
+
questions = [*ruled, ask("m2", "finding-must-fix", 3), ask("o1", "finding-open", 3)]
|
|
266
|
+
assert driver_decisions.automatic(questions, 1, 1) == {"m2": "retry"}
|
|
267
|
+
assert driver_decisions.automatic(questions, 1, 0) == {}
|
|
268
|
+
assert driver_decisions.automatic(questions, 2, 0) == {"m2": "retry"}
|
|
269
|
+
assert driver_decisions.automatic(questions, 3, 0) == {"m2": "retry", "o1": "retry"}
|
|
@@ -10,8 +10,10 @@ import jsonschema
|
|
|
10
10
|
import pytest
|
|
11
11
|
|
|
12
12
|
import driver
|
|
13
|
+
import driver_agents
|
|
13
14
|
import driver_final
|
|
14
15
|
import driver_merge
|
|
16
|
+
import driver_pr
|
|
15
17
|
import driver_report
|
|
16
18
|
import driver_state
|
|
17
19
|
import driver_summary
|
|
@@ -21,7 +23,7 @@ from test_cli import git
|
|
|
21
23
|
from test_final import FILES, FINAL_MODELS, RESOLVE, THREE, TITLES, final, fixer, fn, ref, stop_lines
|
|
22
24
|
from test_fixloop import inside # noqa: F401 (the autouse fixture puts the rig's CLIs on PATH)
|
|
23
25
|
from test_review import FABLE, ONE, finding
|
|
24
|
-
from test_stops import UNATTENDED, decisions, stage
|
|
26
|
+
from test_stops import DONE, UNATTENDED, decisions, stage
|
|
25
27
|
from test_walk import fix, plan, tw
|
|
26
28
|
|
|
27
29
|
|
|
@@ -344,7 +346,7 @@ def test_a_base_that_moved_with_no_conflict_is_rebased_onto_with_no_agent_and_on
|
|
|
344
346
|
assert [p.name for p in (rig.repo / ".agent/implement/final").glob("gate-*.log")] == [f"gate-full-{rig.branch()[:7]}.log"]
|
|
345
347
|
assert rig.final()["commits"] == {nn: row["sha"] for nn, row in zip(order, rows)}
|
|
346
348
|
assert rig.final()["onto"] == base and f"Range: {base}..{rig.branch()}\n" in rig.final_calls("final-spec")[0]["prompt"]
|
|
347
|
-
assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"] and stage(rig) ==
|
|
349
|
+
assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"] and stage(rig) == DONE
|
|
348
350
|
|
|
349
351
|
|
|
350
352
|
def test_a_resolved_rebase_keeps_ticket_messages_and_gates_only_the_final_tidied_tip(tmp_path):
|
|
@@ -470,7 +472,7 @@ def test_a_push_or_a_pr_that_fails_is_tried_again_and_nothing_is_sent_twice(tmp_
|
|
|
470
472
|
calls = len(rig.calls())
|
|
471
473
|
rig.run(plan(), *UNATTENDED)
|
|
472
474
|
assert rig.code == 0 and len(rig.pushes()) == 1 and len(rig.prs()) == 1 and len(rig.calls()) == calls, rig.out
|
|
473
|
-
assert stage(rig) ==
|
|
475
|
+
assert stage(rig) == DONE and rig.final()["pr"] == "https://github.example/pull/1"
|
|
474
476
|
|
|
475
477
|
|
|
476
478
|
def test_a_reviewed_tip_with_no_green_gate_record_is_not_pushed(tmp_path):
|
|
@@ -488,14 +490,14 @@ def test_a_reviewed_tip_with_no_green_gate_record_is_not_pushed(tmp_path):
|
|
|
488
490
|
def test_the_rerun_command_drops_the_answers_and_the_pr_title_falls_back_to_the_branch():
|
|
489
491
|
command = driver_final.again(["--gate", "make check", "--answer", "final-ticket-blocked-1=retry", "--answer=x=y", "--spec", "s.md"])
|
|
490
492
|
assert command == f"sh {driver_final.driver_agents.SKILL / 'run.sh'} --gate 'make check' --spec s.md --push"
|
|
491
|
-
assert
|
|
493
|
+
assert driver_pr._name(SimpleNamespace(args=SimpleNamespace(spec="nowhere.md"), pr="feat/x")) == "feat/x"
|
|
492
494
|
|
|
493
495
|
|
|
494
496
|
# ---------------------------------------------------------------- preconditions and the skip
|
|
495
497
|
|
|
496
498
|
@pytest.mark.parametrize("remote", [True, False], ids=["origin", "no-origin"])
|
|
497
499
|
def test_without_the_review_diff_skill_every_repository_stops_before_any_agent(tmp_path, monkeypatch, remote):
|
|
498
|
-
monkeypatch.setattr(
|
|
500
|
+
monkeypatch.setattr(driver_agents, "REVIEW_DIFF", tmp_path / "review-diff/SKILL.md")
|
|
499
501
|
rig = Inside(tmp_path, ONE, remote=remote).run(plan())
|
|
500
502
|
assert rig.code == 3 and not rig.calls(), rig.out
|
|
501
503
|
assert rig.out == "".join(f"the review-diff skill is missing its {name}: the {lens} lens of the final review "
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-18T00:19:39.851Z",
|
|
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.
|
|
62
|
-
"hash": "sha256-
|
|
61
|
+
"version": "0.1.62",
|
|
62
|
+
"hash": "sha256-427ae669822e55a69c1ac4f04b3f5f14c7e220c2dbce685003a63881597680fd",
|
|
63
63
|
"description": "Implement a specification in code."
|
|
64
64
|
},
|
|
65
65
|
{
|