@jesdi/skills 0.0.77 → 0.0.78

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 (70) hide show
  1. package/README.md +3 -2
  2. package/package.json +1 -1
  3. package/skills/implement-spec/ARCHITECTURE.md +102 -54
  4. package/skills/implement-spec/README.md +53 -51
  5. package/skills/implement-spec/SKILL.md +5 -6
  6. package/skills/implement-spec/driver.py +67 -153
  7. package/skills/implement-spec/driver_agents.py +75 -25
  8. package/skills/implement-spec/driver_decisions.py +92 -199
  9. package/skills/implement-spec/driver_dispute.py +189 -0
  10. package/skills/implement-spec/driver_final.py +196 -97
  11. package/skills/implement-spec/driver_fixloop.py +102 -192
  12. package/skills/implement-spec/driver_legacy.py +73 -5
  13. package/skills/implement-spec/driver_locked.py +186 -0
  14. package/skills/implement-spec/driver_merge.py +3 -48
  15. package/skills/implement-spec/driver_report.py +84 -64
  16. package/skills/implement-spec/driver_review.py +12 -119
  17. package/skills/implement-spec/driver_run.py +167 -130
  18. package/skills/implement-spec/driver_state.py +11 -9
  19. package/skills/implement-spec/models.json +0 -2
  20. package/skills/implement-spec/prompts/arbitration.md +34 -0
  21. package/skills/implement-spec/prompts/conflict.md +1 -0
  22. package/skills/implement-spec/prompts/correction.md +7 -4
  23. package/skills/implement-spec/prompts/elsewhere.md +6 -0
  24. package/skills/implement-spec/prompts/final-fixer.md +1 -1
  25. package/skills/implement-spec/prompts/final-lens.md +40 -0
  26. package/skills/implement-spec/prompts/final-reviewer.md +7 -7
  27. package/skills/implement-spec/prompts/fixer.md +2 -2
  28. package/skills/implement-spec/prompts/implementer.md +1 -1
  29. package/skills/implement-spec/prompts/lens-copy.md +1 -0
  30. package/skills/implement-spec/prompts/lens-correctness.md +8 -0
  31. package/skills/implement-spec/prompts/lens-spec.md +2 -0
  32. package/skills/implement-spec/prompts/lens-structure.md +2 -0
  33. package/skills/implement-spec/prompts/rebase-conflict.md +1 -0
  34. package/skills/implement-spec/prompts/rereview.md +0 -1
  35. package/skills/implement-spec/prompts/rerun.md +1 -1
  36. package/skills/implement-spec/prompts/reviewer.md +3 -6
  37. package/skills/implement-spec/prompts/ruled.md +3 -0
  38. package/skills/implement-spec/prompts/test-writer.md +4 -5
  39. package/skills/implement-spec/tests/test_agents.py +23 -22
  40. package/skills/implement-spec/tests/test_amendments.py +6 -48
  41. package/skills/implement-spec/tests/test_arbitration.py +314 -0
  42. package/skills/implement-spec/tests/test_cli.py +3 -3
  43. package/skills/implement-spec/tests/test_decisions.py +251 -374
  44. package/skills/implement-spec/tests/test_driver.py +22 -50
  45. package/skills/implement-spec/tests/test_final.py +45 -77
  46. package/skills/implement-spec/tests/test_fixloop.py +400 -633
  47. package/skills/implement-spec/tests/test_landing.py +23 -126
  48. package/skills/implement-spec/tests/test_lenses.py +217 -0
  49. package/skills/implement-spec/tests/test_merge.py +0 -43
  50. package/skills/implement-spec/tests/test_models.py +50 -1
  51. package/skills/implement-spec/tests/test_report.py +9 -23
  52. package/skills/implement-spec/tests/test_review.py +15 -153
  53. package/skills/implement-spec/tests/test_review_page.py +7 -3
  54. package/skills/implement-spec/tests/test_scoped.py +125 -0
  55. package/skills/implement-spec/tests/test_state.py +8 -3
  56. package/skills/implement-spec/tests/test_stops.py +43 -61
  57. package/skills/implement-spec/tests/test_tidy.py +77 -98
  58. package/skills/implement-spec/tests/test_walk.py +7 -6
  59. package/skills/review-page/SKILL.md +1 -1
  60. package/skills/to-tickets/SKILL.md +1 -1
  61. package/skills-manifest.json +7 -7
  62. package/skills/implement-spec/prompts/corrected.md +0 -3
  63. package/skills/implement-spec/prompts/correctness.md +0 -42
  64. package/skills/implement-spec/prompts/final-scoped.md +0 -1
  65. package/skills/implement-spec/prompts/full-review.md +0 -2
  66. package/skills/implement-spec/prompts/overruled.md +0 -7
  67. package/skills/implement-spec/prompts/rejected.md +0 -1
  68. package/skills/implement-spec/prompts/restored-red.md +0 -3
  69. package/skills/implement-spec/prompts/restored.md +0 -3
  70. package/skills/implement-spec/prompts/stands.md +0 -2
@@ -10,20 +10,18 @@ Interface choices (ticket 05):
10
10
  `json.dumps(file without "revision", sort_keys=True, separators=(",", ":"))` encoded as UTF-8 (ASCII content here).
11
11
  - evidence strings are file pointers: `.agent/implement/<NN>/implementer.json` and `.agent/implement/ledger.md:<line>`,
12
12
  the line being a ledger line that names the ticket and BLOCKED.
13
- - question ids are `<NN>-locked-test-<n>` with n counting per run (the first is 1, a second stop on the ticket is 2),
14
- and a capped ticket with unmet criteria blocks without a finding question. Options for `locked-test` are
15
- `overrule-test` / `overrule-implementer` (recommended: overrule-implementer).
16
- - an implementer is BLOCKED with a `locked-test` stop only when a `concerns` entry starts with "locked test
17
- contradicts spec:"; any other BLOCKED report is an `implementer-stopped` stop (issue #123).
13
+ - question ids are `<NN>-ticket-blocked-<n>` with n counting per run (the first is 1, a second stop on the ticket is
14
+ 2), and a capped ticket with unmet criteria blocks without a finding question. Options for `ticket-blocked` are
15
+ `retry` / `edit` (recommended: retry).
16
+ - an implementer that reports BLOCKED reruns on the next entry, and a second BLOCKED asks `ticket-blocked`; a dispute
17
+ of a locked test goes to arbitration instead (test_arbitration).
18
18
  - the answers file is `.agent/implement-answers.json` in the schema.md shape: `v`, `stage: "implement"`, `submitted`
19
19
  (`"changes"`), `revision`, `answers`. A rerun applies it only with `submitted` set and `revision` equal to the current
20
20
  decisions revision; otherwise a ledger line says "ignored" (and "revision" for a stale file, the option id for an
21
21
  option the question does not offer), and the stop repeats with exit 2 and the same decisions file.
22
22
  - `--answer` with an unknown question id exits 3 before any agent and names the id on stdout or stderr.
23
- - the ruling for an overruled test is the ledger line "Ruling: 01 locked test overruled"; a finding ruling line
24
- names the ticket, the finding title and the chosen option.
25
- - the stop of the correction is observed in the runner log: a second `test-writer` call on the ticket (before the
26
- implementer's second call) and a second `implementer` call whose HEAD is the correction commit.
23
+ - the ruling of a retry is the ledger line "Ruling: 01 runs again (retry)"; a finding ruling line names the ticket,
24
+ the finding title and the chosen option.
27
25
  - stage.json: `{"stage": "implement", "status": "awaiting-review", "artifact": ".agent/implement-review.html",
28
26
  "open_questions": N}` at a stop; at a BLOCKED end `{"stage": "implement", "status": "blocked", "blocked": ["01"]}`.
29
27
  - ticket 08: `--unattended` pushes at the end, so it is refused in a repository with no `origin`. The unattended tests
@@ -36,16 +34,14 @@ import re
36
34
 
37
35
  import pytest
38
36
 
39
- import driver_review_page
40
- from test_cli import git
41
37
  from test_review import ONE, Review, finding, fix, review
42
38
  from test_review_page import TEMPLATE, check_page
43
- from test_walk import impl, plan, tw
39
+ from test_walk import impl, plan
44
40
 
45
- CONTRA = "locked test contradicts spec: tests/test_01.py::test_x"
41
+ STOP = "no write access to fixtures/"
46
42
  UNATTENDED = ("--unattended", "--stage-json", ".agent/stage.json")
47
- NEW_TEST = "def test_x():\n assert '01' == '01'\n"
48
- Q1 = "01-locked-test-1"
43
+ Q1 = "01-ticket-blocked-1"
44
+ RULED = "Ruling: 01 runs again (retry)"
49
45
 
50
46
 
51
47
  def revision(decisions):
@@ -54,16 +50,12 @@ def revision(decisions):
54
50
 
55
51
 
56
52
  def blocked(*concerns):
57
- return {"report": {"status": "BLOCKED", "commits": [], "files": [], "concerns": list(concerns or [CONTRA]),
53
+ return {"report": {"status": "BLOCKED", "commits": [], "files": [], "concerns": list(concerns or [STOP]),
58
54
  "green": []}}
59
55
 
60
56
 
61
- def correction():
62
- return {**tw("01"), "files": {"tests/test_01.py": NEW_TEST}, "commit": "test: 01 overruled"}
63
-
64
-
65
57
  def steps(*implementers, **more):
66
- return plan(**{"01/implementer": list(implementers), "01/test-writer": [tw("01"), correction()], **more})
58
+ return plan(**{"01/implementer": list(implementers), **more})
67
59
 
68
60
 
69
61
  def decisions(rig):
@@ -85,9 +77,9 @@ def write_answers(rig, answers, **fields):
85
77
 
86
78
 
87
79
  def stopped(tmp, *extra, then=(impl("01"),), files=ONE, rig=Review):
88
- """A rig after run 1: 01's implementer reported the contradicted locked test."""
80
+ """A rig after run 1: 01's implementer and its rerun reported BLOCKED."""
89
81
  rig = rig(tmp, files)
90
- return rig.run(steps(blocked(), *then), *extra)
82
+ return rig.run(steps(blocked(), blocked(), *then), *extra)
91
83
 
92
84
 
93
85
  @pytest.fixture(scope="module")
@@ -97,12 +89,12 @@ def local(tmp_path_factory):
97
89
 
98
90
  # ---------------------------------------------------------------- the question
99
91
 
100
- def test_a_contradicted_locked_test_writes_one_question_with_pointers(local):
92
+ def test_a_blocked_ticket_writes_one_question_with_pointers(local):
101
93
  assert local.code == 2, local.output()
102
94
  (q,) = decisions(local)["questions"]
103
95
  assert q["id"] == Q1
104
- assert {o["id"] for o in q["options"]} == {"overrule-test", "overrule-implementer"}
105
- assert q["recommended"] == "overrule-implementer"
96
+ assert {o["id"] for o in q["options"]} == {"retry", "edit"}
97
+ assert q["recommended"] == "retry"
106
98
  assert q["title"] and q["why"]
107
99
  evidence = "\n".join(q["evidence"])
108
100
  assert ".agent/implement/01/implementer-0.json" in evidence and (local.folder() / "implementer-0.json").exists()
@@ -121,15 +113,15 @@ def test_revision_is_the_sha256_of_the_file_without_it_and_ids_are_valid_and_uni
121
113
 
122
114
 
123
115
  def test_a_second_stop_on_the_same_ticket_gets_a_new_id_and_a_new_revision(tmp_path):
124
- rig = stopped(tmp_path, then=(blocked(), impl("01")))
116
+ rig = stopped(tmp_path)
125
117
  first = decisions(rig)
126
- rig.run(steps(blocked(), blocked(), impl("01")), "--answer", f"{Q1}=overrule-test")
118
+ rig.run(steps(blocked(), blocked(), blocked(), blocked(), impl("01")), "--answer", f"{Q1}=retry")
127
119
  assert rig.code == 2, rig.output()
128
120
  second = decisions(rig)
129
121
  ids = [q["id"] for q in second["questions"]]
130
- assert "01-locked-test-2" in ids and len(ids) == len(set(ids))
122
+ assert "01-ticket-blocked-2" in ids and len(ids) == len(set(ids))
131
123
  assert second["revision"] != first["revision"] == revision(first) and second["revision"] == revision(second)
132
- assert "01-locked-test-2" in rig.out
124
+ assert "01-ticket-blocked-2" in rig.out
133
125
 
134
126
 
135
127
  # ---------------------------------------------------------------- the page
@@ -144,63 +136,53 @@ def test_the_stop_renders_the_review_page_from_the_template(local):
144
136
 
145
137
  def test_without_unattended_the_driver_prints_question_and_options_exits_2_and_launches_nothing_more(local):
146
138
  assert local.code == 2
147
- for word in (Q1, "overrule-test", "overrule-implementer"):
139
+ for word in (Q1, "retry", "edit"):
148
140
  assert word in local.out + local.err, word
149
- assert [c["role"] for c in local.calls()] == ["test-writer", "implementer"]
141
+ assert [c["role"] for c in local.calls()] == ["test-writer", "implementer", "implementer"]
150
142
  assert "feat: 01 rows" not in local.pr_subjects()
151
143
 
152
144
 
153
- def test_answer_overrule_test_writes_the_answers_file_rules_corrects_the_test_and_resumes(tmp_path):
145
+ def test_answer_retry_writes_the_answers_file_rules_and_resumes(tmp_path):
154
146
  rig = stopped(tmp_path)
155
147
  rev = decisions(rig)["revision"]
156
- rig.run(steps(blocked(), impl("01")), "--answer", f"{Q1}=overrule-test")
148
+ rig.run(steps(blocked(), blocked(), impl("01")), "--answer", f"{Q1}=retry")
157
149
  assert rig.code == 0, rig.output()
158
150
  file = json.loads(answers_file(rig).read_text())
159
151
  assert (file["v"], file["stage"], file["submitted"], file["revision"]) == (1, "implement", "changes", rev)
160
- assert file["answers"] == {Q1: "overrule-test"}
161
- assert rig.led("Ruling: 01 locked test overruled")
162
- fixes, resumed = rig.calls("01", "test-writer"), rig.calls("01", "implementer")
163
- assert len(fixes) == 2 and len(resumed) == 2, "one test-writer correction, then the implementer again"
164
- assert fixes[1]["t1"] <= resumed[1]["t0"] and resumed[1]["head"] == fixes[1]["sha"]
165
- assert git(rig.repo, "show", "feat/csv:tests/test_01.py") == NEW_TEST and "feat: 01 rows" in rig.pr_subjects()
152
+ assert file["answers"] == {Q1: "retry"}
153
+ assert rig.led(RULED)
154
+ assert len(rig.calls("01", "test-writer")) == 1 and len(rig.calls("01", "implementer")) == 3
155
+ assert "feat: 01 rows" in rig.pr_subjects()
166
156
 
167
157
 
168
158
  def test_an_answers_file_from_another_revision_is_ignored_with_a_ledger_line_and_the_stop_repeats(tmp_path):
169
159
  rig = stopped(tmp_path)
170
160
  before = decisions(rig)
171
- write_answers(rig, {Q1: "overrule-test"}, revision="0" * 64)
172
- rig.run(steps(blocked(), impl("01")))
161
+ write_answers(rig, {Q1: "retry"}, revision="0" * 64)
162
+ rig.run(steps(blocked(), blocked(), impl("01")))
173
163
  assert rig.code == 2, rig.output()
174
- assert rig.led("ignored", "revision") and not rig.led("Ruling: 01 locked test overruled")
164
+ assert rig.led("ignored", "revision") and not rig.led(RULED)
175
165
  assert decisions(rig) == before and Q1 in rig.out
176
- assert [c["role"] for c in rig.calls()] == ["test-writer", "implementer"]
166
+ assert [c["role"] for c in rig.calls()] == ["test-writer", "implementer", "implementer"]
177
167
 
178
168
 
179
169
  def test_an_answer_naming_an_option_the_question_does_not_offer_is_ignored_with_a_ledger_line(tmp_path):
180
170
  rig = stopped(tmp_path)
181
171
  write_answers(rig, {Q1: "bogus-option"})
182
- rig.run(steps(blocked(), impl("01")))
172
+ rig.run(steps(blocked(), blocked(), impl("01")))
183
173
  assert rig.code == 2, rig.output()
184
- assert rig.led("ignored", "bogus-option") and not rig.led("Ruling: 01 locked test overruled")
185
- assert [c["role"] for c in rig.calls()] == ["test-writer", "implementer"]
174
+ assert rig.led("ignored", "bogus-option") and not rig.led(RULED)
175
+ assert [c["role"] for c in rig.calls()] == ["test-writer", "implementer", "implementer"]
186
176
 
187
177
 
188
178
  def test_answer_for_an_unknown_question_id_exits_3_naming_it_before_any_agent(tmp_path):
189
179
  rig = stopped(tmp_path)
190
180
  seen = len(rig.calls())
191
- rig.run(steps(blocked(), impl("01")), "--answer", "no-such-question=accept")
181
+ rig.run(steps(blocked(), blocked(), impl("01")), "--answer", "no-such-question=accept")
192
182
  assert rig.code == 3, rig.output()
193
183
  assert "no-such-question" in rig.out + rig.err and len(rig.calls()) == seen
194
184
 
195
185
 
196
- def test_a_blocked_report_that_is_not_a_contradicted_locked_test_is_an_implementer_stop(tmp_path):
197
- rig = Review(tmp_path)
198
- rig.run(steps(blocked("cannot reach the database")))
199
- assert rig.code == 2, rig.output()
200
- assert [q["id"] for q in decisions(rig)["questions"]] == ["01-implementer-stopped-1"]
201
- assert rig.state()["tickets"]["01"]["phase"] == "blocked"
202
-
203
-
204
186
  # ---------------------------------------------------------------- capped ticket
205
187
 
206
188
  def test_unmet_criteria_at_cap_block_without_a_finding_question(tmp_path):
@@ -227,17 +209,17 @@ def test_unattended_stop_writes_stage_json_and_exits_2(tmp_path):
227
209
  def test_unattended_rerun_with_a_submitted_answers_file_at_the_current_revision_continues_silently(tmp_path):
228
210
  from test_final import Final
229
211
  rig = stopped(tmp_path, *UNATTENDED, rig=Final)
230
- write_answers(rig, {Q1: "overrule-test"})
231
- rig.run(steps(blocked(), impl("01")), *UNATTENDED)
212
+ write_answers(rig, {Q1: "retry"})
213
+ rig.run(steps(blocked(), blocked(), impl("01")), *UNATTENDED)
232
214
  assert rig.code == 0, rig.output()
233
- assert Q1 not in rig.out + rig.err and rig.led("Ruling: 01 locked test overruled")
234
- assert len(rig.calls("01", "implementer")) == 2 and "feat: 01 rows" in rig.pr_subjects()
215
+ assert Q1 not in rig.out + rig.err and rig.led(RULED)
216
+ assert len(rig.calls("01", "implementer")) == 3 and "feat: 01 rows" in rig.pr_subjects()
235
217
  assert stage(rig) == {"stage": "implement", "status": "done"}
236
218
 
237
219
 
238
220
  def test_unattended_blocked_ticket_ends_with_stage_json_blocked_naming_it_and_exit_1(tmp_path):
239
221
  from test_final import Final
240
222
  rig = Final(tmp_path, gate={"red": ["ticket/feat%2Fcsv/01"]})
241
- rig.run(plan(), *UNATTENDED)
223
+ rig.run(plan(**{"01/fixer": [fix("01", n) for n in (1, 2)]}), *UNATTENDED)
242
224
  assert rig.code == 1, rig.output()
243
225
  assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["01"]}
@@ -22,7 +22,7 @@ from test_final import FILES, FINAL_MODELS, RESOLVE, THREE, TITLES, final, fixer
22
22
  from test_fixloop import inside # noqa: F401 (the autouse fixture puts the rig's CLIs on PATH)
23
23
  from test_review import FABLE, ONE, finding
24
24
  from test_stops import UNATTENDED, decisions, stage
25
- from test_walk import plan, tw
25
+ from test_walk import fix, plan, tw
26
26
 
27
27
 
28
28
  class Inside(test_final.Final):
@@ -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 full gate is green on " + tip[:7])
85
+ assert rig.led("End of run: final-spec 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") == ""
@@ -151,9 +151,9 @@ def test_a_base_branch_needs_an_origin(tmp_path):
151
151
 
152
152
  def test_the_final_review_does_not_start_while_a_ticket_is_not_merged_and_the_ledger_says_so_once(tmp_path):
153
153
  rig = Inside(tmp_path, THREE, gate={"red": ["ticket/feat%2Fcsv/01"]})
154
- rig.run(plan())
155
- rig.run(plan(), *UNATTENDED)
156
- assert rig.code == 1 and not rig.final_calls("final-reviewer") and not rig.recovery()
154
+ rig.run(plan(**{"01/fixer": [fix("01", n) for n in (1, 2)]}))
155
+ rig.run(plan(**{"01/fixer": [fix("01", n) for n in (1, 2)]}), *UNATTENDED)
156
+ assert rig.code == 1 and not rig.final_calls("final-spec") and not rig.recovery()
157
157
  assert rig.led("End-of-run work skipped") == ["End-of-run work skipped: these tickets are not merged: 01, 02."]
158
158
  assert "The end-of-run work (rebase, tidy, final review, push) did not run: these tickets are not merged: 01, 02." in rig.out
159
159
  assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["01"]}
@@ -180,7 +180,7 @@ def test_a_branch_that_cannot_move_to_the_tidied_tip_keeps_the_recorded_ticket_t
180
180
  (line,) = rig.led("End of run: BLOCKED at the rewrite: cannot move feat/csv to the tidied tip")
181
181
  assert line.endswith(f"the ref moved; feat/csv is unrewritten at its recovery point {rig.recovery()[:7]}.")
182
182
  assert rig.branch() == rig.recovery() == rig.state()["tickets"]["01"]["tip"] and not rig.final().get("tidied")
183
- assert not rig.final_calls("final-reviewer") and "End of run: BLOCKED at the rewrite" in rig.out
183
+ assert not rig.final_calls("final-spec") and "End of run: BLOCKED at the rewrite" in rig.out
184
184
 
185
185
 
186
186
  def test_a_tidied_tip_that_left_the_branch_stops_the_end_of_run(tmp_path):
@@ -219,9 +219,9 @@ def test_a_fix_batch_is_named_per_commit_and_a_commit_with_no_owner_is_a_violati
219
219
  first["report"]["commits"].pop()
220
220
  retry = {"report": dict(first["report"], commits=[{"sha": "$HEAD~1", "ticket": "02"}, {"sha": "$HEAD", "ticket": "01"}])}
221
221
  retry["files"] = {"wip.txt": "not committed\n"}
222
- rig.run(plan(**{"final/final-reviewer": [final(finding("Q-ONE"), finding("Q-MINOR", "minor")), final()],
222
+ rig.run(plan(**{"final/final-spec": [final(finding("Q-ONE"), finding("Q-MINOR", "minor"))],
223
223
  "final/fixer": [first, retry]}))
224
- assert rig.code == 1, rig.out
224
+ assert rig.code == 2, rig.out
225
225
  assert rig.led("End of run: fixer ran on", "is on feat/csv and not in `commits`: each commit of the batch needs its ticket")
226
226
  assert rig.led("End of run: BLOCKED at the fix batch: commits.0.sha") # `$HEAD~1` is no SHA: a second violation
227
227
  reviewed = rig.final()["reviewed"]
@@ -242,8 +242,8 @@ def test_a_fix_batch_is_named_per_commit_and_a_commit_with_no_owner_is_a_violati
242
242
  (rig.repo / "wip.txt").unlink()
243
243
 
244
244
  stray(rig, "fix(99): by hand") # a commit with the name of a fix commit and no validated owner
245
- rig.run(plan(), "--push")
246
- assert rig.code == 1 and rig.pushes() == [] and len(rig.final_calls("final-reviewer")) == 1, rig.out
245
+ rig.run(plan(), "--answer", "final-ticket-blocked-1=retry", "--push")
246
+ assert rig.code == 1 and rig.pushes() == [] and len(rig.final_calls("final-spec")) == 1, rig.out
247
247
  assert rig.led("End of run: BLOCKED at the tip", f"is not a tip the driver made: only {reviewed[:7]} gets a review")
248
248
 
249
249
  git(rig.repo, "reset", "-q", "--hard", reviewed)
@@ -255,7 +255,7 @@ def test_a_fix_batch_is_named_per_commit_and_a_commit_with_no_owner_is_a_violati
255
255
  def test_a_fixer_that_times_out_twice_keeps_its_files_and_the_branch_stays_at_the_reviewed_tip(tmp_path):
256
256
  rig = Inside(tmp_path, ONE)
257
257
  slow = {"files": {"wip.txt": "half done\n"}, "sleep": 30}
258
- rig.run(plan(**{"final/final-reviewer": [final(finding("Q-ONE"))], "final/fixer": [slow, slow]}),
258
+ rig.run(plan(**{"final/final-spec": [final(finding("Q-ONE"))], "final/fixer": [slow, slow]}),
259
259
  "--timeout", "fixer=0.01", *UNATTENDED)
260
260
  reviewed = rig.final()["reviewed"]
261
261
  assert rig.code == 1 and rig.pushes() == [] and rig.branch() == reviewed, rig.out
@@ -266,7 +266,7 @@ def test_a_fixer_that_times_out_twice_keeps_its_files_and_the_branch_stays_at_th
266
266
 
267
267
  def test_a_fix_commit_for_a_ticket_that_is_not_in_the_run_is_a_violation(tmp_path):
268
268
  rig = Inside(tmp_path, ONE)
269
- rig.run(plan(**{"final/final-reviewer": [final(finding("Q-ONE")), final()],
269
+ rig.run(plan(**{"final/final-spec": [final(finding("Q-ONE"))],
270
270
  "final/fixer": [fixer(fn("01"), "fix(01): named already", ticket_of="09"),
271
271
  {"report": dict(fixer(fn("01"), "x")["report"], commits=[{"sha": "$HEAD", "ticket": "01"}])}]}))
272
272
  assert rig.code == 0, rig.out
@@ -274,26 +274,27 @@ def test_a_fix_commit_for_a_ticket_that_is_not_in_the_run_is_a_violation(tmp_pat
274
274
  (row,) = rig.commits(rig.final()["tidied"])
275
275
  assert row["subject"] == "fix(01): named already" and rig.final()["reviewed"] == row["sha"] == rig.branch()
276
276
  assert rig.led("Fix batch of the final review: 1 commit on", f"{row['sha'][:7]} fix(01): named already.")
277
- scoped = rig.final_calls("final-reviewer")[1]["prompt"]
277
+ (scoped,) = [call["prompt"] for call in rig.final_calls("final-reviewer")]
278
278
  assert f"Range: {rig.final()['tidied']}..{row['sha']}\n" in scoped and "This is the scoped review after the fix batch" in scoped
279
279
  assert scoped.rstrip().endswith("one ref store.") and ".agent/implement/final/findings-0.json" in scoped
280
280
 
281
281
 
282
- def test_a_final_reviewer_that_changes_the_slot_is_restored_and_runs_once_more(tmp_path):
282
+ def test_a_lens_that_changes_the_slot_is_restored_and_every_lens_runs_once_more(tmp_path):
283
283
  rig = Inside(tmp_path, ONE)
284
284
  dirty = final(finding("DROPPED"), files={"left.txt": "x"})
285
285
  moved_head = final(files={"more.txt": "x"}, commit="by the reviewer")
286
- rig.run(plan(**{"final/final-reviewer": [dirty, final(finding("KEPT", "minor"))]}))
287
- assert rig.code == 0 and len(rig.final_calls("final-reviewer")) == 2 and not (rig.repo / "left.txt").exists(), rig.out
286
+ rig.run(plan(**{"final/final-spec": [dirty, final(finding("KEPT", "minor"))]}))
287
+ assert [len(rig.final_calls(role)) for role in ("final-spec", "final-correctness", "final-structure")] == [2, 2, 2]
288
+ assert rig.code == 0 and not (rig.repo / "left.txt").exists(), rig.out
288
289
  assert rig.led("End of run: a read-only role broke its rule: the tree is not as the review found it: left.txt; the "
289
290
  f"driver restored slot 1 to {rig.branch()[:7]} and runs the final review again.")
290
291
  assert rig.led("KEPT") and not rig.led("DROPPED") and rig.final()["reviewed"] == rig.branch()
291
292
 
292
293
 
293
- def test_a_final_reviewer_that_changes_the_slot_twice_ends_the_run_with_a_clean_slot(tmp_path):
294
+ def test_a_lens_that_changes_the_slot_twice_ends_the_run_with_a_clean_slot(tmp_path):
294
295
  rig = Inside(tmp_path, ONE)
295
296
  moved_head = final(files={"more.txt": "x"}, commit="by the reviewer")
296
- rig.run(plan(**{"final/final-reviewer": [final(files={"left.txt": "x"}), moved_head]}), *UNATTENDED)
297
+ rig.run(plan(**{"final/final-spec": [final(files={"left.txt": "x"}), moved_head]}), *UNATTENDED)
297
298
  tip = rig.final()["tidied"]
298
299
  assert rig.code == 1 and rig.final()["reviewed"] is None and rig.branch() == tip, rig.out
299
300
  assert rig.led(f"End of run: BLOCKED at the final review: the slot is no longer on feat/csv at {tip[:7]}.")
@@ -305,66 +306,13 @@ def test_a_final_reviewer_that_changes_the_slot_twice_ends_the_run_with_a_clean_
305
306
  def test_a_red_gate_on_the_tidied_tip_stops_before_the_final_review(tmp_path):
306
307
  rig = Inside(tmp_path, ONE, gate={"red": ["feat/csv"]})
307
308
  rig.run(plan(), *UNATTENDED)
308
- assert rig.code == 1 and not rig.final_calls("final-reviewer") and rig.pushes() == [], rig.out
309
+ assert rig.code == 1 and not rig.final_calls("final-spec") and rig.pushes() == [], rig.out
309
310
  assert rig.led("End of run: BLOCKED at the gate: the full gate is red on " + rig.branch()[:7])
310
311
  assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["final"]}
311
312
  # The fast gate of the ticket tip, the full gate of its fast-forward, and the full gate of the tidied tip.
312
313
  assert rig.state()["run"]["gates"] == {"fast": 1, "full": 2} and "| full gates run | 2 |" in rig.out
313
314
 
314
315
 
315
- # ---------------------------------------------------------------- the triage after the second round
316
-
317
- def parked(tmp_path, *findings):
318
- rig = Inside(tmp_path, ONE)
319
- steps = plan(**{"final/final-reviewer": [final(*findings), final(*findings)],
320
- "final/fixer": [fixer(fn("01"), "first try", ticket_of="01")]})
321
- return rig.run(steps), steps
322
-
323
-
324
- def test_open_findings_after_the_second_round_park_the_run_on_one_question_each(tmp_path):
325
- rig, steps = parked(tmp_path, finding("STILL-OPEN"), finding("ALSO"))
326
- assert rig.code == 2 and rig.pushes() == [], rig.out
327
- first, second = decisions(rig)["questions"]
328
- assert (first["id"], second["id"]) == ("final-finding-1", "final-finding-2")
329
- assert first["title"] == "Final review: a finding is open after the second review round: STILL-OPEN (demo/export.py:99)"
330
- assert [o["id"] for o in first["options"]] == ["fix", "accept"] and first["recommended"] == "fix"
331
- assert first["evidence"] == [".agent/implement/final/findings-1.json", ".agent/implement/final/final-reviewer-1.json"]
332
- assert "Question final-finding-1: " in rig.out and rig.state()["run"]["stops"] == 1
333
- assert rig.led("End of run: the operator decides on 2 questions of kind final-finding")
334
- assert len(rig.final_calls("final-reviewer")) == 2 and len(rig.final_calls("fixer")) == 1
335
-
336
- rig.run(steps, "--answer", "final-finding-1=accept")
337
- assert rig.code == 2 and rig.led("Ruling: final-review finding closed as it is (accept): STILL-OPEN (demo/export.py:99).")
338
- assert [q["id"] for q in decisions(rig)["questions"]] == ["final-finding-2"] and not any(stop_lines(rig.out))
339
-
340
- rig.run(steps, "--answer", "final-finding-2=accept", "--push")
341
- assert rig.code == 0 and rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"], rig.out
342
- body = rig.prs()[0]["body"]
343
- assert "- Ruling: final-review finding closed as it is (accept): ALSO (demo/export.py:99)." in body
344
- assert f"- {rig.branch()[:7]} fix(01): first try" in body
345
- assert f"Scoped review after the fix batch: {rig.final()['tidied']}..{rig.branch()}" in body
346
- assert len(rig.final_calls("final-reviewer")) == 2, "no third round"
347
-
348
-
349
- def test_the_answer_fix_keeps_the_finding_open_and_nothing_is_pushed(tmp_path):
350
- rig, steps = parked(tmp_path, finding("STILL-OPEN"))
351
- rig.run(steps, "--answer", "final-finding-1=fix", *UNATTENDED)
352
- assert rig.code == 1 and rig.pushes() == [] and not rig.prs(), rig.out
353
- assert rig.led("Ruling: final-review finding stays open and nothing is pushed (fix): STILL-OPEN")
354
- assert rig.led("End of run: BLOCKED at the operator keeps 1 finding of the final review open (fix): nothing is pushed.")
355
- assert stage(rig) == {"stage": "implement", "status": "blocked", "blocked": ["final"]}
356
-
357
-
358
- def test_a_commit_after_the_second_review_is_never_reviewed_or_pushed(tmp_path):
359
- rig, steps = parked(tmp_path, finding("STILL-OPEN"))
360
- rig.run(steps, "--answer", "final-finding-1=accept")
361
- assert rig.code == 0 and all(stop_lines(rig.out))
362
- stray(rig, "fix(01): by hand")
363
- rig.run(steps, "--push")
364
- assert rig.code == 1 and rig.pushes() == [] and len(rig.final_calls("final-reviewer")) == 2
365
- assert rig.led("End of run: BLOCKED at the two review rounds are done and the tip", "is not the reviewed tip")
366
-
367
-
368
316
  # ---------------------------------------------------------------- the rebase
369
317
 
370
318
  def moved(tmp_path, base, *conflict, **kw):
@@ -382,14 +330,14 @@ def test_a_base_that_moved_with_no_conflict_is_rebased_onto_with_no_agent_and_on
382
330
  assert ref(rig.repo, "feat/csv~3") == base and git(rig.repo, "show", "feat/csv:docs.md") == "base docs\n"
383
331
  assert [p.name for p in (rig.repo / ".agent/implement/final").glob("gate-*.log")] == [f"gate-full-{rig.branch()[:7]}.log"]
384
332
  assert rig.final()["commits"] == {nn: row["sha"] for nn, row in zip(order, rows)}
385
- assert rig.final()["onto"] == base and f"Range: {base}..{rig.branch()}\n" in rig.final_calls("final-reviewer")[0]["prompt"]
333
+ assert rig.final()["onto"] == base and f"Range: {base}..{rig.branch()}\n" in rig.final_calls("final-spec")[0]["prompt"]
386
334
  assert rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"] and stage(rig) == {"stage": "implement", "status": "done"}
387
335
 
388
336
 
389
337
  def test_a_resolved_rebase_keeps_the_ticket_messages_and_gates_the_rebased_tip_and_the_tidied_tip(tmp_path):
390
338
  cli = {"demo/cli.py": "def main():\n return 'base'\n"}
391
- resolved = {**RESOLVE, "files": {"demo/cli.py": "def main():\n return 'both'\n"}, "git_end": []}
392
- rig = moved(tmp_path, cli, resolved) # the agent commits as "resolve conflict" and the driver goes on with the rebase
339
+ resolved = {**RESOLVE, "files": {"demo/cli.py": "def main():\n return 'both'\n"}}
340
+ rig = moved(tmp_path, cli, resolved) # the agent commits as "resolve conflict" and goes on with the rebase
393
341
  assert rig.code == 0, rig.out + "\n".join(rig.ledger())
394
342
  (call,) = rig.final_calls("conflict")
395
343
  assert "Files in conflict: demo/cli.py\n" in call["prompt"] and "Base branch: main, at commit " in call["prompt"]
@@ -407,7 +355,7 @@ def test_a_resolved_rebase_keeps_the_ticket_messages_and_gates_the_rebased_tip_a
407
355
  def test_a_second_conflict_leaves_the_branch_at_its_recovery_point_with_all_its_commits(tmp_path):
408
356
  step = {**RESOLVE, "files": {"demo/export.py": "resolved = 1\n"}, "report": {**RESOLVE["report"], "files": ["demo/export.py"]}}
409
357
  rig = moved(tmp_path, {"demo/export.py": "def export_csv():\n return 'base'\n"}, step)
410
- assert rig.code == 1 and len(rig.final_calls("conflict")) == 1 and not rig.final_calls("final-reviewer"), rig.out
358
+ assert rig.code == 1 and len(rig.final_calls("conflict")) == 1 and not rig.final_calls("final-spec"), rig.out
411
359
  recovery = rig.recovery()
412
360
  assert rig.branch() == recovery and len(rig.commits(rig.start, recovery)) == 6, "two commits per ticket, as before"
413
361
  assert rig.led("End of run: BLOCKED at the rewrite: the rebase onto main conflicts a second time, in demo/export.py; "
@@ -417,16 +365,19 @@ def test_a_second_conflict_leaves_the_branch_at_its_recovery_point_with_all_its_
417
365
  assert {e["phase"] for e in rig.state()["tickets"].values()} == {"merged"}
418
366
 
419
367
  rig.run(plan(), *UNATTENDED) # the rerun starts the rewrite again from the same recovery point
420
- assert rig.code == 1 and rig.recovery() == recovery == rig.branch()
368
+ assert rig.code == 2 and rig.recovery() == recovery == rig.branch()
421
369
  assert len(rig.final_calls("conflict")) == 3, "the conflict agent of the rerun, which has no script, and its one rerun"
370
+ (question,) = decisions(rig)["questions"]
371
+ assert question["id"] == "final-ticket-blocked-1" and "End of run: an agent stopped" in question["title"]
372
+ assert "the conflict: report .agent/implement/final/conflict-0.json is not readable JSON" in question["title"]
422
373
  assert not rig.led("returned to implement")
423
374
 
424
375
 
425
376
  def test_a_conflict_agent_that_gives_up_leaves_no_rebase_open(tmp_path):
426
377
  stuck = {"report": {"status": "BLOCKED", "commits": [], "files": [], "concerns": ["both sides are needed"]}}
427
- rig = moved(tmp_path, {"demo/cli.py": "base\n"}, stuck)
428
- assert rig.code == 1 and rig.branch() == rig.recovery(), rig.out
429
- assert rig.led("End of run: BLOCKED at the rewrite: the conflict agent: the conflict reported BLOCKED: both sides are needed;")
378
+ rig = moved(tmp_path, {"demo/cli.py": "base\n"}, stuck, stuck)
379
+ assert rig.code == 2 and rig.branch() == rig.recovery() and len(rig.final_calls("conflict")) == 2, rig.out
380
+ assert rig.led("End of run: BLOCKED at the rewrite: the conflict agent: it reported BLOCKED: both sides are needed;")
430
381
  assert git(rig.repo, "status", "--short") == "" and git(rig.repo, "symbolic-ref", "--short", "HEAD") == "feat/csv\n"
431
382
  assert not (rig.repo / ".git/rebase-merge").exists()
432
383
 
@@ -521,7 +472,7 @@ def test_a_reviewed_tip_with_no_green_gate_record_is_not_pushed(tmp_path):
521
472
 
522
473
 
523
474
  def test_the_rerun_command_drops_the_answers_and_the_pr_title_falls_back_to_the_branch():
524
- command = driver_final.again(["--gate", "make check", "--answer", "final-finding-1=accept", "--answer=x=y", "--spec", "s.md"])
475
+ command = driver_final.again(["--gate", "make check", "--answer", "final-ticket-blocked-1=retry", "--answer=x=y", "--spec", "s.md"])
525
476
  assert command == f"sh {driver_final.driver_agents.SKILL / 'run.sh'} --gate 'make check' --spec s.md --push"
526
477
  assert driver_final._name(SimpleNamespace(args=SimpleNamespace(spec="nowhere.md"), pr="feat/x")) == "feat/x"
527
478
 
@@ -533,8 +484,9 @@ def test_without_the_review_diff_skill_every_repository_stops_before_any_agent(t
533
484
  monkeypatch.setattr(driver_final, "REVIEW_DIFF", tmp_path / "review-diff/SKILL.md")
534
485
  rig = Inside(tmp_path, ONE, remote=remote).run(plan())
535
486
  assert rig.code == 3 and not rig.calls(), rig.out
536
- assert rig.out == (f"{tmp_path}/review-diff/SKILL.md is missing: the final review runs through it; install the "
537
- "review-diff skill next to implement-spec\n")
487
+ assert rig.out == "".join(f"the review-diff skill is missing its {name}: the {lens} lens of the final review "
488
+ "follows it; install it next to implement-spec with `npx skills add jesdi/general-skills "
489
+ "--skill review-diff`\n" for name, lens in (("spec.md", "spec"), ("correctness.md", "correctness")))
538
490
 
539
491
 
540
492
  def test_a_push_without_the_pr_skill_stops_before_any_agent_and_a_local_run_does_not_need_it(tmp_path, monkeypatch):
@@ -583,7 +535,7 @@ def test_without_an_origin_the_run_ends_reviewed_and_a_push_is_refused_at_the_st
583
535
  assert driver_summary.render({"run": fresh, "tickets": {}}).startswith("0 of 0 tickets are merged into feat/x.\n\n| Measure")
584
536
 
585
537
 
586
- @pytest.mark.parametrize("name", ["final-reviewer", "final-fixer", "rebase-conflict"])
538
+ @pytest.mark.parametrize("name", ["final-reviewer", "final-lens", "final-fixer", "rebase-conflict"])
587
539
  def test_the_templates_of_the_end_of_run_hold_a_valid_schema_and_end_with_the_rule(name):
588
540
  jsonschema.Draft202012Validator.check_schema(driver_report.schema(name))
589
541
  text = (driver_report.PROMPTS / f"{name}.md").read_text()
@@ -606,7 +558,7 @@ def test_a_history_that_origin_already_has_is_not_rebased_and_not_tidied(tmp_pat
606
558
  assert [r["subject"] for r in rig.commits(published)] == ["test: 01 red", "feat: 01 rows"], "no tidy"
607
559
  assert ref(rig.repo, "feat/csv~2") == published and not rig.recovery(), "no rebase, so no recovery point"
608
560
  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
609
- assert len(rig.final_calls("final-reviewer")) == 1 and rig.led("End of run: the full gate is green on " + rig.branch()[:7])
561
+ assert len(rig.final_calls("final-spec")) == 1 and rig.led("End of run: the full gate is green on " + rig.branch()[:7])
610
562
  assert rig.pushes()[-1] == f"refs/heads/feat/csv {rig.branch()}" and ref(rig.origin, "refs/heads/feat/csv") == rig.branch()
611
563
  assert f"- 01: {rig.branch()[:7]} Export rows" in rig.prs()[0]["body"] and stage(rig)["status"] == "done"
612
564
 
@@ -615,24 +567,51 @@ def weak(nn="01"):
615
567
  return {f"tests/test_{nn}.py": "def test_x():\n assert True\n"}
616
568
 
617
569
 
618
- def test_a_fix_batch_that_changes_a_locked_test_gives_a_critical_finding_and_is_not_pushed(tmp_path):
570
+ def test_a_rebase_resolution_that_changes_a_locked_test_is_rejected_and_the_conflict_agent_runs_again(tmp_path):
571
+ rig = Inside(tmp_path, ONE)
572
+ rig.move_base({"demo/export.py": "def export_csv():\n return 'base'\n"})
573
+ # The agent does not go on with the rebase: the driver does, then checks the rebased tip.
574
+ weakens = {"commit": "resolve conflict", "files": {"demo/export.py": "x = 1\n", **weak()}, "report": RESOLVE["report"]}
575
+ puts_back = {"files": tw("01")["files"], "git_end": [["commit", "-q", "-a", "--amend", "--no-edit"]],
576
+ "report": RESOLVE["report"]}
577
+ rig.run(plan(**{"final/conflict": [weakens, puts_back]}), *UNATTENDED)
578
+ assert rig.code == 0 and rig.pushes() == [f"refs/heads/feat/csv {rig.branch()}"], rig.out
579
+ first, second = rig.led("End of run: conflict ran on")
580
+ assert "locked file changed: tests/test_01.py" in first and second.endswith("report accepted.")
581
+ assert git(rig.repo, "show", "feat/csv:tests/test_01.py") == tw("01")["files"]["tests/test_01.py"]
582
+ assert git(rig.repo, "show", "feat/csv:demo/export.py") == "x = 1\n"
583
+
584
+
585
+ def test_a_rebase_the_agent_left_open_with_no_conflict_is_continued_by_the_driver(tmp_path):
586
+ rig = Inside(tmp_path, ONE)
587
+ rig.move_base({"demo/export.py": "def export_csv():\n return 'base'\n"})
588
+ committed = {"commit": "resolve conflict", "files": {"demo/export.py": "x = 1\n"}, "report": RESOLVE["report"]}
589
+ rig.run(plan(**{"final/conflict": [committed]}), *UNATTENDED)
590
+ assert rig.code == 0, rig.out
591
+ (only,) = rig.led("End of run: conflict ran on")
592
+ assert only.endswith("report accepted.") and git(rig.repo, "show", "feat/csv:demo/export.py") == "x = 1\n"
593
+
594
+
595
+ def test_a_rebase_resolution_the_agent_never_staged_is_rejected_with_the_git_error_and_the_agent_runs_again(tmp_path):
619
596
  rig = Inside(tmp_path, ONE)
620
- batch = fixer(fn("01"), "weaken the test", ticket_of="01")
621
- batch["commits"][0]["files"].update(weak())
622
- rig.run(plan(**{"final/final-reviewer": [final(finding("Q-ONE")), final()], "final/fixer": [batch]}), *UNATTENDED)
623
- assert rig.code == 2 and rig.pushes() == [] and not rig.prs(), rig.out
624
- assert rig.led("Final review round 2: critical finding of kind code at tests/test_01.py:1: locked file changed: tests/test_01.py.")
625
- (q,) = decisions(rig)["questions"]
626
- assert q["title"].endswith("locked file changed: tests/test_01.py (tests/test_01.py:1)")
597
+ rig.move_base({"demo/export.py": "def export_csv():\n return 'base'\n"})
598
+ unstaged = {"files": {"demo/export.py": "x = 1\n"}, "git_end": [["rev-parse", "HEAD"]], "report": RESOLVE["report"]}
599
+ stages = {"git_end": [["add", "-A"], ["rebase", "--continue"]], "report": RESOLVE["report"]}
600
+ rig.run(plan(**{"final/conflict": [unstaged, stages]}), *UNATTENDED)
601
+ assert rig.code == 0, rig.out + "\n".join(rig.ledger())
602
+ first, second = rig.led("End of run: conflict ran on")
603
+ assert "git rebase --continue failed at the stop you resolved: " in first and second.endswith("report accepted.")
604
+ assert git(rig.repo, "show", "feat/csv:demo/export.py") == "x = 1\n"
627
605
 
628
606
 
629
- def test_a_rebase_resolution_that_changes_a_locked_test_leaves_the_branch_at_its_recovery_point(tmp_path):
607
+ def test_a_staged_resolution_reported_at_the_stop_is_checked_on_the_tip_the_driver_rebased(tmp_path):
630
608
  rig = Inside(tmp_path, ONE)
631
609
  rig.move_base({"demo/export.py": "def export_csv():\n return 'base'\n"})
632
- rig.run(plan(**{"final/conflict": [{**RESOLVE, "files": {"demo/export.py": "x = 1\n", **weak()}}]}), *UNATTENDED)
633
- assert rig.code == 1 and rig.pushes() == [] and rig.branch() == rig.recovery(), rig.out
634
- assert rig.led("End of run: BLOCKED at the rewrite: the conflict agent: locked file changed: tests/test_01.py;")
635
- assert git(rig.repo, "status", "--short") == "" and not rig.final_calls("final-reviewer")
610
+ staged = {"files": {"demo/export.py": "x = 1\n"}, "git_end": [["add", "-A"]], "report": RESOLVE["report"]}
611
+ rig.run(plan(**{"final/conflict": [staged]}), *UNATTENDED)
612
+ assert rig.code == 0, rig.out + "\n".join(rig.ledger())
613
+ (only,) = rig.led("End of run: conflict ran on")
614
+ assert only.endswith("report accepted.") and git(rig.repo, "show", "feat/csv:demo/export.py") == "x = 1\n"
636
615
 
637
616
 
638
617
  def test_a_rebase_with_no_commit_to_replay_puts_each_ticket_on_the_fetched_base(tmp_path, monkeypatch):
@@ -62,11 +62,9 @@ rec = dict(id=f"{{time.time_ns()}}-{{os.getpid()}}", key=key, nn=nn, role=role,
62
62
  save(rec)
63
63
  step = json.loads((rig / "plan.json").read_text()).get(key, [])
64
64
  step = step[n] if n < len(step) else {{}}
65
- if role in ("reviewer", "correctness", "final-reviewer") and "report" not in step: # a role the test does not script reports no findings
66
- reds = [f"FAILED {{p}}::test_x - AttributeError" for p in git("diff", "--name-only", "feat/csv...HEAD", "--", "tests").split()]
67
- proofs = [dict(test=r.split()[1], file="demo/export.py", line=1, red=r) for r in reds]
68
- step = dict(step, stdout="".join(r + "\\n" for r in reds), report=dict(
69
- status="DONE", commits=[], files=[], concerns=[], findings=[], mutations=proofs))
65
+ # A role the test does not script reports no findings.
66
+ if role in ("reviewer", "final-reviewer", "final-spec", "final-correctness", "final-structure") and "report" not in step:
67
+ step = dict(step, report=dict(status="DONE", commits=[], files=[], concerns=[], findings=[]))
70
68
  if role == "pr-writer" and "report" not in step: # an unscripted pr-writer writes a summary and a valid merge-risk block
71
69
  step = dict(step, report=dict(status="DONE", commits=[], files=[], concerns=[], body="## Summary\\n\\nCSV export.\\n\\n## Merge Danger\\n\\n```merge-risk v1\\ndoor: two-way\\nblast_radius: isolated\\ntouches: [docs]\\nrollback: revert\\nverdict: auto\\nreasons:\\n - \\"Only prose changes\\"\\n```\\n"))
72
70
  for name in step.get("touch", []):
@@ -439,7 +437,10 @@ def single_blocked(tmp_path):
439
437
  rig = Rig(tmp_path, {"01-export-rows.md": ticket("01", "Export rows")}, gate={"all": True})
440
438
  rig.run({**plan(), "01/implementer": [impl("01"), impl("01", text="def fn_01():\n return 'again'\n",
441
439
  commit="feat: 01 again")]})
442
- assert rig.code == 1, rig.output()
440
+ # The unscripted fixer writes no report, so the ticket blocks with a question; the resume tests drop it.
441
+ assert rig.code == 2, rig.output()
442
+ path = rig.repo / ".agent/implement/state.json"
443
+ path.write_text(json.dumps({**rig.state(), "run": {**rig.state()["run"], "questions": []}}))
443
444
  return rig
444
445
 
445
446
 
@@ -63,7 +63,7 @@ Track pills, in `track`. Check the proposed track:
63
63
 
64
64
  - Never edit the `<script>` or the CSS. Only fill slots.
65
65
  - Every question has an id that matches `[a-z0-9_-]{1,64}`. The id `track` is reserved for the track pills. Slot content never carries the id `state`, or the name `track` outside the track slot: the script owns them.
66
- - Every question has exactly one recommended option, marked with `chip rec`. It is one recommended option, never zero and never two.
66
+ - Every question has exactly one recommended option, marked with `chip rec`, never two. The one exception is a question whose choice must stay with the reader, such as implement-spec's `spec-ambiguous`: it marks none.
67
67
  - Option values are short ids. Put no option text in a value.
68
68
  - The page has no network, no storage and no external file: no script `src`, no `<link>`, no image or font URL.
69
69
  - Keep `<meta name="agent-ops-review" content="1">`. The dispatcher looks for it.
@@ -123,7 +123,7 @@ The **Touches** line is a best guess, for scheduling: `implement-spec` never run
123
123
 
124
124
  <risk-rule>
125
125
 
126
- The optional **Risk** line names the shared state, persistence keys or identities, concurrency, money or auth the ticket touches, and turns on `implement-spec`'s correctness pass: a second, independent reviewer on another provider. The driver does not start when it has no CLI of another provider: the reviewer never does this pass. Any text on the line turns the pass on, so a ticket with no such risk has no **Risk** line, never `**Risk:** none`.
126
+ The optional **Risk** line names the shared state, persistence keys or identities, concurrency, money or auth the ticket touches. `implement-spec`'s reviewer checks it as one more criterion: a risk that the diff does not handle is an unmet criterion, which starts a fix round and blocks the ticket at the cap. The driver reads any text on the line as a risk, so a ticket with no such risk has no **Risk** line, never `**Risk:** none`.
127
127
 
128
128
  </risk-rule>
129
129