@jesdi/skills 0.0.57 → 0.0.59

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jesdi/skills",
3
- "version": "0.0.57",
3
+ "version": "0.0.59",
4
4
  "description": "jesdi's agent skills (content package consumed by @jesdi/skills-cli)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -146,6 +146,12 @@ and do not know about the run, except `driver_run.py`, which the three deciding
146
146
  - A reviewer or a correctness pass that reports BLOCKED or NEEDS_CONTEXT raises `driver_run.Stopped`, which
147
147
  carries the report. `driver_fixloop._run_reviewers` turns it into a `review-stopped` question, or, after an
148
148
  `accept` ruling on that role (`driver_decisions.accepted`), uses the report as it is.
149
+ - An implementer or a fixer that reports BLOCKED or NEEDS_CONTEXT asks a question in `Run._ask_stop`: `locked-test`
150
+ for a contradicted locked test, else `implementer-stopped` or `fixer-stopped`. The stop of a fixer sets the round
151
+ back by one, so its `retry` (gate and review the tip, then a fixer) runs the same round again.
152
+ - An implementer or a fixer with nothing to change reports DONE with no commit (`driver_report._unchanged_errors`):
153
+ the branch did not move, the tree is clean, and a concern says why. The driver gates and reviews that tip as it
154
+ would a new one.
149
155
  - The correctness prompt carries the checks of `review-diff` (`driver_review.checks`): the pass reads files only
150
156
  from git at the tip and from `.agent/`, and a project-local install sits in an ignored directory.
151
157
 
@@ -57,7 +57,7 @@ Default timeouts in minutes: explorer 30, test-writer 30, implementer 90, review
57
57
  |---|---|
58
58
  | 0 | Done: every ticket is merged and no question is open. Also the end of a valid `--dry-run`. In local mode without `--push`, nothing is pushed. |
59
59
  | 1 | A ticket is BLOCKED, or the end of run is BLOCKED. The other tickets ran as far as they could. |
60
- | 2 | Parked: a question of kind `locked-test`, `locked-test-again`, `review-stopped` or `final-finding` is open. Exit 2 wins over exit 1. |
60
+ | 2 | Parked: a question of kind `locked-test`, `locked-test-again`, `review-stopped`, `implementer-stopped`, `fixer-stopped` or `final-finding` is open. Exit 2 wins over exit 1. |
61
61
  | 3 | Invalid input or a failed precondition: a usage error, a ticket error, a model error, an uncommitted change, a slot that cannot be made, another driver that runs on the same PR branch. No agent starts. The one exception: a review page that cannot be written gives exit 3 at the end of a run, after agents ran. |
62
62
  | 4 | Stopped: the CLI of an agent failed two times and wrote no report (for example, the account cannot use the model). The driver starts no other agent and lets the running agents end. No ticket is BLOCKED by it: fix the CLI or the model entry, then run the same command again to resume. |
63
63
  | 130 | The operator interrupted the run. The driver stops each agent. The work stays in the slots for the next run. |
@@ -111,7 +111,7 @@ Rules for each agent:
111
111
  - A call blocks until the agent ends. The driver does not poll.
112
112
  - An agent stops only the processes it started and their child processes, by PID, and never kills a process it did not start, nor uses `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. A process it did not start that blocks it goes into its concerns.
113
113
  - An agent gets one rerun: after a rejected report, after a timeout, or after it left the ticket branch. The rerun prompt is the first prompt plus the reason.
114
- - A report with status `BLOCKED` or `NEEDS_CONTEXT` blocks the ticket. From the reviewer or the correctness pass, it also asks a `review-stopped` question.
114
+ - A report with status `BLOCKED` or `NEEDS_CONTEXT` blocks the ticket. From the reviewer or the correctness pass, it also asks a `review-stopped` question; from the implementer or a fixer, a `locked-test` question when a concern starts with `locked test contradicts spec:`, else an `implementer-stopped` or `fixer-stopped` question. Nothing left to change is no stop: the implementer and the fixer report it as DONE with no commit.
115
115
  - A BLOCKED ticket stops the tickets that it blocks. All other tickets run on.
116
116
 
117
117
  ### Findings and fix rounds
@@ -177,9 +177,9 @@ Every report has `status` (`DONE`, `DONE_WITH_CONCERNS`, `NEEDS_CONTEXT`, `BLOCK
177
177
 
178
178
  | Role | Template | More fields | Checks after the schema |
179
179
  |---|---|---|---|
180
- | test-writer | `prompts/test-writer.md` | `locked` (test file paths), `red` (`test`, `line`) | The driver reads a test node id `<file>::<test>` in `locked` as its file. With DONE: one commit, one locked file and one red line or more. Each locked path is in a commit that the role made. Each `line` is in the log. A locked file of a merged ticket that the role changed is in `locked`. A correction (after `overrule-test`, or for a review finding) changes only the files that it lists in `locked` and the files that the driver restored before it. When the gate is red on the restore commit, a DONE correction lists a restored file in `locked`. Each `not_addressed[].finding` is the title of a finding of the correction; a DONE correction with each of its findings there needs no commit. |
181
- | implementer | `prompts/implementer.md` | `green` | With DONE: one commit or more. |
182
- | reviewer | `prompts/reviewer.md` | `findings` (`severity`, `file`, `line`, `title`, `evidence`, `kind`), `mutations` (`test`, `file`, `line`, `red`); `commits` is empty | In a full review (one with no fix range: round 1, and the review after a test-writer correction): `mutations` is required, with a proof for each locked test file (`test` is `<locked file>::<test name>`). Each `red` is in the log. |
180
+ | test-writer | `prompts/test-writer.md` | `locked` (test file paths), `red` (`test`, `line`), optional `fixtures` (each locked file that holds no test, as a fake `gh`) | The driver reads a test node id `<file>::<test>` in `locked` as its file. Each fixture is in `locked`; the ticket record keeps it a fixture until a later correction lists the file again. With DONE: one commit, one locked file and one red line or more. Each locked path is in a commit that the role made. Each `line` is in the log. A locked file of a merged ticket that the role changed is in `locked`. A correction (after `overrule-test`, or for a review finding) changes only the files that it lists in `locked` and the files that the driver restored before it. When the gate is red on the restore commit, a DONE correction lists a restored file in `locked`. Each `not_addressed[].finding` is the title of a finding of the correction; a DONE correction with each of its findings there needs no commit. |
181
+ | implementer | `prompts/implementer.md` | `green` | With DONE and no commit: no new commit on the branch, no uncommitted change, and a concern that says why the start needs no change. The driver then gates and reviews the start commit. |
182
+ | reviewer | `prompts/reviewer.md` | `findings` (`severity`, `file`, `line`, `title`, `evidence`, `kind`), `mutations` (`test`, `file`, `line`, `red`); `commits` is empty | In a full review (one with no fix range: round 1, and the review after a test-writer correction): `mutations` is required, with a proof for each locked test file (`test` is `<locked file>::<test name>`). A locked fixture needs no proof: it holds no test that a proof could name, and the locked-file check protects it. Each `red` is in the log. |
183
183
  | correctness | `prompts/correctness.md` | the same as the reviewer; `commits` is empty | `mutations` is optional. |
184
184
  | fixer | `prompts/fixer.md` | `green`, `ticket` | With DONE and no commit: no new commit on the branch, no uncommitted change, a gate that is green on the start, and a concern that names each finding of the round. |
185
185
  | final-reviewer | `prompts/final-reviewer.md` | `findings` | None. |
@@ -199,6 +199,8 @@ A question is a bounded choice for the operator. `driver_decisions.py` `KINDS` h
199
199
  | `finding` | `<NN>-finding-<n>` | A finding is open after fix round 4. One question for each finding. | 1 | `accept`: close the finding; the ticket merges when each of its findings is accepted. `split` (recommended) and `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
200
200
  | `locked-test-again` | `<NN>-locked-test-again-<n>` | A finding for a test-writer correction is open in the review right after a correction, or the driver rejects the correction's report (for example, it changes a file that it does not list in `locked`). One question for each finding. | 2 | `correct-again` (recommended): the ticket resumes from the review, and that review's findings get one more correction. `accept`: no more correction runs for the ticket, its locked tests stay as they are, and the ticket goes on to its fix rounds with its other findings; a changed locked file is still restored. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. After two `correct-again` stops on a ticket, its next question offers only `accept` (recommended) and `redesign`, so a test-writer and a reviewer that never agree cannot loop. |
201
201
  | `review-stopped` | `<NN>-review-stopped-<n>` | The reviewer or the correctness pass reports `BLOCKED` or `NEEDS_CONTEXT`. One question for each agent that stopped. | 2 | `retry` (recommended): the ticket resumes from the review, and each agent of the review runs again. `accept`: the same, and for the rest of the ticket a `BLOCKED` or `NEEDS_CONTEXT` report of that agent does not stop it: the review goes on with that report's findings and those of the other reports. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
202
+ | `implementer-stopped` | `<NN>-implementer-stopped-<n>` | The implementer reports `BLOCKED` or `NEEDS_CONTEXT`, and no concern starts with `locked test contradicts spec:`. | 2 | `retry` (recommended): the implementer runs again from the tip it left. `accept-tip`: the driver gates and reviews that tip, and the fix rounds close what the review finds. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
203
+ | `fixer-stopped` | `<NN>-fixer-stopped-<n>` | A fixer reports `BLOCKED` or `NEEDS_CONTEXT`, and no concern starts with `locked test contradicts spec:`. | 2 | `retry` (recommended): the round that stopped does not count; the driver gates and reviews the tip the fixer left, and a fixer runs that round again on the review's findings. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
202
204
  | `final-finding` | `final-finding-<n>` | A finding is open after the second round of the final review. | 2 | `fix` (recommended): the finding stays open and nothing is pushed. `accept`: close the finding. |
203
205
 
204
206
  `n` counts the questions of that ticket and kind in the run, so an id is never used twice.
@@ -210,7 +212,7 @@ Answer with `--answer <question id>=<option id>` on the next run, or through the
210
212
  | Check | Where it lives |
211
213
  |---|---|
212
214
  | Locked tests with a demonstrated red | `driver_report.py` `_proof_errors`: each red line of the test-writer report must be in its log. `driver_review.py` `locked_findings`: a locked file of the ticket that differs from the test-writer commit is a critical finding, before each review. `driver_review.py` `merged_changes`: a locked file of a merged ticket that the ticket changed is a critical `fixture` finding, before each review. `driver_merge.py` `refused`, called from `driver.py` `_checked_landing` under the merge lock: a locked file of a merged ticket that differs between the PR tip and the tree that is about to land refuses the landing, so a later ticket cannot change the locked test of an earlier one. `driver_report.py` `_merged_errors` rejects a test-writer report that changes such a file and does not list it. |
213
- | One mutation proof for each locked test | `prompts/full-review.md`, the note of each full review, names the locked test files that need a proof. `driver_report.py` `_locked_errors` and `_proof_errors` reject a full review with no proof for a locked test file, or with a red line that is not in the log. `driver_review.py` `follow` finds the proofs that a fix makes due again. |
215
+ | One mutation proof for each locked test | `prompts/full-review.md`, the note of each full review, names the locked test files that need a proof: each locked file that is not a fixture. `driver_report.py` `_locked_errors` and `_proof_errors` reject a full review with no proof for a locked test file, or with a red line that is not in the log. `driver_review.py` `follow` finds the proofs that a fix makes due again. |
214
216
  | One independent correctness pass for each risky ticket | `driver_fixloop.py` `_review` adds the pass for a ticket with a **Risk** line. `driver_agents.py` `correctness_entry` picks the entry of another provider, and `load_models` stops the run when there is none or its CLI is not on PATH. |
215
217
  | One full gate for each candidate | `driver_gate.py` `run`, called from `driver_run.py` `Run.gate`: one record for each commit the driver is about to trust. Green is exit 0 on a tree that is clean before and after, with HEAD not moved. |
216
218
  | Post-merge check on the PR branch | `driver.py` `_checked_landing`: a merge commit is gated before the PR branch moves to it. A fast-forward of a gated tip uses the record of that tip. `driver_final.py` `_review_until_reviewed` gates the tip again after the tidy and after the fix batch. |
@@ -120,7 +120,8 @@ def _run_roles(ticket: Ticket, slot_number: int, run: Run) -> None:
120
120
  report = run.agent(role, number, slot, values, notes=notes, check=check)
121
121
  facts = {"tip": driver_slots.head(slot)}
122
122
  if role == "test-writer":
123
- facts.update(driver_review.written(slot, entry, report["locked"], facts["tip"]))
123
+ facts.update(driver_review.written(slot, entry, report["locked"], report.get("fixtures", []),
124
+ facts["tip"]))
124
125
  values["locked"] = " ".join(facts["locked"])
125
126
  run.state.ticket(number, phase=AFTER.get(role, "review"), note="", **facts)
126
127
  start, notes = facts["tip"], []
@@ -91,6 +91,36 @@ KINDS = {
91
91
  "redesign": Option(
92
92
  "Keep the ticket BLOCKED. The design changes before more work on it.",
93
93
  "Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
94
+ "implementer-stopped": Kind(
95
+ True,
96
+ "Ticket {ticket}: the implementer stopped: {subject}",
97
+ "The implementer of ticket {ticket} reported BLOCKED or NEEDS_CONTEXT, and no concern says that a locked test "
98
+ "contradicts the spec. Ticket {ticket} is BLOCKED and each ticket that it blocks waits.",
99
+ "retry",
100
+ {"retry": Option(
101
+ "The implementer runs again from the tip it left.",
102
+ "Ruling: {ticket} implementer runs again (retry): {subject}.", {"phase": "implement"}),
103
+ "accept-tip": Option(
104
+ "The implementer does not run again: the driver gates and reviews the tip it left, and the fix rounds "
105
+ "close what the review finds.",
106
+ "Ruling: {ticket} tip goes to the gate and the review as it is (accept-tip): {subject}.",
107
+ {"phase": "gate"}),
108
+ "redesign": Option(
109
+ "Keep the ticket BLOCKED. The design changes before more work on it.",
110
+ "Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
111
+ "fixer-stopped": Kind(
112
+ True,
113
+ "Ticket {ticket}: the fixer stopped: {subject}",
114
+ "The fixer of ticket {ticket} reported BLOCKED or NEEDS_CONTEXT, and no concern says that a locked test "
115
+ "contradicts the spec. Ticket {ticket} is BLOCKED and each ticket that it blocks waits.",
116
+ "retry",
117
+ {"retry": Option(
118
+ "The round that stopped does not count: the driver gates and reviews the tip the fixer left, and a fixer "
119
+ "runs that round again on what the review finds.",
120
+ "Ruling: {ticket} fix round runs again (retry): {subject}.", {"phase": "review"}),
121
+ "redesign": Option(
122
+ "Keep the ticket BLOCKED. The design changes before more work on it.",
123
+ "Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
94
124
  # A final-review question belongs to no ticket: its `ticket` is "".
95
125
  "final-finding": Kind(
96
126
  True,
@@ -43,11 +43,16 @@ class Job:
43
43
  findings = os.path.relpath(OUT / self.ticket.number / f"findings-{review}.json", self.slot)
44
44
  gate = os.path.relpath(driver_gate.record_path(OUT / self.ticket.number, self.tip), self.slot)
45
45
  return {**self.values, "start_sha": self.tip, "from_sha": self.previous, "round": str(self.round),
46
- "locked": " ".join(entry["locked"]), "test_writer_sha": str(entry["test_writer_sha"] or ""),
46
+ "locked": " ".join(entry["locked"]), "locked_tests": " ".join(tested(entry)), "test_writer_sha": str(entry["test_writer_sha"] or ""),
47
47
  "findings": findings, "gate_record": gate,
48
48
  "proofs": " ".join(f"{file}:{line}" for file, line in sorted(self.again))}
49
49
 
50
50
 
51
+ def tested(entry: dict) -> list[str]:
52
+ """The locked files of the ticket record that hold tests: each one needs a mutation proof in a full review."""
53
+ return [path for path in entry["locked"] if path not in entry["fixtures"]]
54
+
55
+
51
56
  def entry(models: dict[str, list[str]], round: int) -> str:
52
57
  """The implementer entry of a fix round: the second one from round 3, when the list has one."""
53
58
  entries = models["implementer"]
@@ -72,7 +77,8 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
72
77
  accepted = driver_decisions.accepted(job.run.state.read()["run"]["questions"], number, "review-stopped")
73
78
 
74
79
  def call(role: str, entry: str) -> dict:
75
- # A full review (no fix range) must give a mutation proof for each locked test file; the prompt names them.
80
+ # A full review (no fix range) must give a mutation proof for each locked test file, not for a locked fixture
81
+ # (#118); the prompt names them.
76
82
  full = not job.previous and role == "reviewer"
77
83
  notes = ["rereview"] if job.previous else ["full-review"] if full else []
78
84
  notes += ["unchanged"] * (job.previous == job.tip) # a fixer with no commit: its reasons need a check
@@ -114,7 +120,7 @@ def _review(job: Job) -> list[dict]:
114
120
  if job.ticket.risk:
115
121
  cast.append(("correctness", driver_agents.correctness_entry(run.models)))
116
122
  reports = run.read_only(number, job.slot, job.values["branch"], job.tip,
117
- lambda: _run_reviewers(job, cast, state["locked"]))
123
+ lambda: _run_reviewers(job, cast, tested(state)))
118
124
  for (role, _), report in zip(cast, reports):
119
125
  found += _log_findings(job, [{**finding, "source": role} for finding in report["findings"]])
120
126
  job.proofs |= {(proof["file"], proof["line"]) for proof in report.get("mutations", [])}
@@ -154,7 +160,8 @@ def _correct(job: Job, findings: list[dict]) -> list[dict]:
154
160
  raise
155
161
  job.tip, job.previous, job.corrected = driver_slots.head(job.slot), "", True
156
162
  entry = run.state.read()["tickets"][number]
157
- run.state.ticket(number, tip=job.tip, **driver_review.written(job.slot, entry, report["locked"], job.tip))
163
+ run.state.ticket(number, tip=job.tip, **driver_review.written(job.slot, entry, report["locked"],
164
+ report.get("fixtures", []), job.tip))
158
165
  return _uncorrected(job, findings, report.get("not_addressed", []))
159
166
 
160
167
 
@@ -69,14 +69,20 @@ def _commit_errors(report: dict, context: dict) -> list[str]:
69
69
  return errors
70
70
 
71
71
 
72
- def _unchanged_errors(report: dict, context: dict) -> list[str]:
73
- """A DONE fixer with no commit (issue #123): the branch did not move, no change is left uncommitted, the gate of
74
- the start is green, and a concern names each finding, with why it needs no change."""
75
- if "fix" not in context or report["commits"] or report["status"] not in ("DONE", "DONE_WITH_CONCERNS"):
72
+ def _unchanged_errors(role: str, report: dict, context: dict) -> list[str]:
73
+ """A DONE implementer or fixer with no commit (issue #123): the branch did not move, no change is left
74
+ uncommitted, the gate of the start is green, and a concern says why no change is needed: for a fixer, one
75
+ concern names each finding."""
76
+ done = report["status"] in ("DONE", "DONE_WITH_CONCERNS")
77
+ if role not in ("implementer", "fixer") or report["commits"] or not done:
76
78
  return []
77
- return _moved_errors(context) + [
79
+ titles = context.get("fix", [])
80
+ errors = _moved_errors(context) + [
78
81
  f"no commit, and no concern names the finding {title}: give each finding a concern that says why it needs no "
79
- "change" for title in context["fix"] if not any(title in concern for concern in report["concerns"])]
82
+ "change" for title in titles if not any(title in concern for concern in report["concerns"])]
83
+ if not (titles or report["concerns"]):
84
+ errors.append("no commit, and no concern: say in `concerns` why the start needs no change")
85
+ return errors
80
86
 
81
87
 
82
88
  def _moved_errors(context: dict) -> list[str]:
@@ -131,7 +137,8 @@ def _proof_errors(report: dict, context: dict) -> list[str]:
131
137
 
132
138
 
133
139
  def _locked_errors(report: dict, context: dict) -> list[str]:
134
- """In a full review, each locked test file has a mutation proof (`mutations[].test` is `<file>::<test>`)."""
140
+ """In a full review, each locked test file has a mutation proof (`mutations[].test` is `<file>::<test>`).
141
+ `locked` names no fixture of the ticket: a fixture holds no test that a proof could name (#118)."""
135
142
  if not context.get("full") or "findings" not in report:
136
143
  return []
137
144
  tests = [proof["test"] for proof in report.get("mutations", [])]
@@ -139,6 +146,12 @@ def _locked_errors(report: dict, context: dict) -> list[str]:
139
146
  if not any(test.startswith(path) for test in tests)]
140
147
 
141
148
 
149
+ def _fixture_errors(report: dict) -> list[str]:
150
+ """Each fixture of a test-writer report (a locked file that holds no test) is in its `locked`."""
151
+ return [f"fixtures: {path} is not in `locked`" for path in report.get("fixtures", [])
152
+ if path not in report.get("locked", [])]
153
+
154
+
142
155
  def locked_files(listed: list[str]) -> list[str]:
143
156
  """The files of a `locked` list: a test node id `<file>::<test>` names its file. In order, each file once."""
144
157
  return list(dict.fromkeys(entry.partition("::")[0] for entry in listed))
@@ -157,6 +170,7 @@ def validate(role: str, path: str, context: dict) -> list[str]:
157
170
  report = {name: value for name, value in report.items() if name in rules["properties"]}
158
171
  if "locked" in report:
159
172
  report["locked"] = locked_files(report["locked"])
160
- return (_commit_errors(report, context) + _owner_errors(report, context) + _unchanged_errors(report, context)
161
- + _correction_errors(report, context) + _merged_errors(report, context) + _proof_errors(report, context)
162
- + _locked_errors(report, context))
173
+ return (_commit_errors(report, context) + _owner_errors(report, context)
174
+ + _unchanged_errors(role, report, context) + _correction_errors(report, context)
175
+ + _merged_errors(report, context) + _proof_errors(report, context) + _locked_errors(report, context)
176
+ + _fixture_errors(report))
@@ -80,17 +80,18 @@ def restore_locked(slot: str, entry: dict) -> list[str]:
80
80
  return restored
81
81
 
82
82
 
83
- def written(slot: str, entry: dict, listed: list[str], tip: str) -> dict:
84
- """The locked-file fields of the ticket record after a test-writer commit at `tip` that lists `listed`.
85
- `tip` is the new reference. A locked file that a correction does not list and that differs from the old
86
- reference keeps the old one in `held`, so a change the implementer made before stays a finding."""
83
+ def written(slot: str, entry: dict, listed: list[str], fixtures: list[str], tip: str) -> dict:
84
+ """The locked-file fields of the ticket record after a test-writer commit at `tip` that lists `listed`, of which
85
+ `fixtures` hold no test. `tip` is the new reference. A locked file that a correction does not list and that differs
86
+ from the old reference keeps the old one in `held`, so a change the implementer made before stays a finding."""
87
87
  held = {path: sha for path, sha in entry["held"].items() if path not in listed}
88
88
  others = [path for path in entry["locked"] if path not in listed and path not in held]
89
89
  if entry["test_writer_sha"] and others:
90
90
  diff = git(slot, "diff", "--name-only", "-z", entry["test_writer_sha"], tip, "--", *others)
91
91
  # A diff that git cannot make holds each file.
92
92
  held.update(dict.fromkeys(names(diff.stdout) if diff.returncode == 0 else others, entry["test_writer_sha"]))
93
- return {"test_writer_sha": tip, "locked": list(dict.fromkeys(entry["locked"] + listed)), "held": held}
93
+ return {"test_writer_sha": tip, "locked": list(dict.fromkeys(entry["locked"] + listed)), "held": held,
94
+ "fixtures": [path for path in entry["fixtures"] if path not in listed] + fixtures}
94
95
 
95
96
 
96
97
  def route(findings: list[dict], locked: list[str], protected: list[str]) -> tuple[list[dict], list[dict]]:
@@ -119,15 +119,28 @@ class Run:
119
119
  report = _attempts(self, role, number, slot, values, **options)
120
120
  if role == "test-writer":
121
121
  report["locked"] = driver_report.locked_files(report["locked"]) # as validate read it
122
- if subject := driver_decisions.contradicted(role, report):
123
- # The implementer's commits stay: after the ruling the ticket goes on from them.
124
- evidence = OUT / number / f"{role}-{options.get('fix_round', 0)}.json"
125
- self.ask(number, "locked-test", [subject], str(evidence), tip=driver_slots.head(slot))
126
122
  if report.get("status") in ("BLOCKED", "NEEDS_CONTEXT"):
127
123
  concerns = "; ".join(report["concerns"]) or "no concern given"
128
- raise Stopped(f"the {role} reported {report['status']}: {concerns}", report)
124
+ why = f"the {role} reported {report['status']}: {concerns}"
125
+ if number != FINAL:
126
+ self._ask_stop(role, number, slot, report, why, options.get("fix_round", 0))
127
+ raise Stopped(why, report)
129
128
  return report
130
129
 
130
+ def _ask_stop(self, role: str, number: str, slot: str, report: dict, why: str, fix_round: int) -> None:
131
+ """The question of a stopped implementer or fixer: `locked-test` when it says a locked test contradicts the
132
+ spec, else `<role>-stopped` (issue #123). Its commits stay: after the ruling the ticket goes on from them."""
133
+ if role not in ("implementer", "fixer"):
134
+ return
135
+ evidence, tip = str(OUT / number / f"{role}-{fix_round}.json"), driver_slots.head(slot)
136
+ if subject := driver_decisions.contradicted(role, report):
137
+ self.ask(number, "locked-test", [subject], evidence, tip=tip)
138
+ elif role == "implementer":
139
+ self.ask(number, "implementer-stopped", [why], evidence, tip=tip)
140
+ else:
141
+ # The round that stopped does not count: `retry` reviews the tip and runs that round again.
142
+ self.ask(number, "fixer-stopped", [why], evidence, tip=tip, round=fix_round - 1)
143
+
131
144
  def read_only(self, number: str, slot: str, branch: str, tip: str, review: Callable[[], T]) -> T:
132
145
  """Run `review` (read-only agents) and return its result. A review that changes the slot runs once more."""
133
146
  for last in (False, True):
@@ -2,7 +2,7 @@
2
2
 
3
3
  {"run": {revision, pr_branch, schema, gates, stops, agents: [{ticket, role, entry, seconds, cost}], questions, start,
4
4
  landed: [[ticket, the PR tip its merge made]], final},
5
- "tickets": {"NN": {phase, round, tip, test_writer_sha, locked, green_gates, slot, note, held}}}"""
5
+ "tickets": {"NN": {phase, round, tip, test_writer_sha, locked, fixtures, green_gates, slot, note, held}}}"""
6
6
  from __future__ import annotations
7
7
 
8
8
  import fcntl
@@ -22,7 +22,8 @@ PHASES = ("pending", "test-writer", "implement", "gate", "review", "fix", "merge
22
22
 
23
23
  def _ticket() -> dict:
24
24
  return {"phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": [],
25
- "slot": None, "note": "", "held": {}}
25
+ "slot": None, "note": "", "held": {},
26
+ "fixtures": []}
26
27
 
27
28
 
28
29
  def _final() -> dict:
@@ -52,6 +53,9 @@ class State:
52
53
  tickets = state.setdefault("tickets", {})
53
54
  for number in numbers:
54
55
  tickets.setdefault(number, _ticket())
56
+ for entry in tickets.values(): # a run of an older driver lacks the newer keys
57
+ for key, value in _ticket().items():
58
+ entry.setdefault(key, value)
55
59
  return self.update(change)
56
60
 
57
61
  def update(self, change) -> dict:
@@ -1,3 +1,3 @@
1
1
 
2
- When this correction adds a requirement, update each shared fake or fixture that other locked tests use, so that those tests satisfy the requirement too.
2
+ When this correction adds a requirement, update each shared fake or fixture that other locked tests use, so that those tests satisfy the requirement too. List each file you change in `locked`, and each one that holds no test in `fixtures` too.
3
3
  Then run each whole file of `locked` and each locked test of merged tickets. In `concerns`, name each red test and why it is expected to be red, or write that all are green.
@@ -14,7 +14,7 @@ Use targeted tests while you work.
14
14
  Before you report DONE or DONE_WITH_CONCERNS, make the gate green on your final commit: run `{gate}` with IMPLEMENT_SPEC_BASE={pr_branch} in the environment, then fix, commit, and run it again until it passes. The driver runs the gate again on that commit, and a re-review reads the lines you changed.
15
15
  A finding from the `gate` is a red gate: its file is the gate record. Read the output there and make the gate green.
16
16
  Commit your work on the checked-out ticket branch. Do not dispatch subagents.
17
- When a finding needs no change, for example because a correction before you already resolved it, change nothing for it. When no finding needs a change, make no commit: report DONE_WITH_CONCERNS, list no commit in `commits`, and give one concern per finding to fix that starts with its title and says why it needs no change. A re-review checks each reason. This is not for a red gate: a fix of a red gate is a commit.
17
+ When a finding needs no change, for example because a correction before you already resolved it, change nothing for it. When no finding needs a change, make no commit: report DONE_WITH_CONCERNS, list no commit in `commits`, and give one concern per finding to fix that starts with its title and says why it needs no change. A re-review checks each reason. This is not for a red gate: a fix of a red gate is a commit. Report NEEDS_CONTEXT or BLOCKED only for a question that stops your work: the operator answers it.
18
18
  In `ticket`, give the number of the ticket that owns your commits. In `green`, give the summary lines of the passing test output.
19
19
 
20
20
  Write one JSON report at {report} that matches this schema:
@@ -1,2 +1,2 @@
1
1
 
2
- This is a full review of {start_sha}: give one mutation proof or more for each of these locked test files: {locked}
2
+ This is a full review of {start_sha}: give one mutation proof or more for each of these locked test files: {locked_tests}
@@ -11,6 +11,7 @@ Never edit a locked file. If a locked test contradicts the spec or the ticket, s
11
11
  Commit your work on the checked-out ticket branch. Do not dispatch subagents. In `commits`, list only the commits you made: the start commit and each commit before it are not yours.
12
12
  Use targeted tests while you work.
13
13
  Before you report DONE or DONE_WITH_CONCERNS, make the gate green on your final commit: run `{gate}` with IMPLEMENT_SPEC_BASE={pr_branch} in the environment, then fix, commit, and run it again until it passes. The driver runs the gate again on that commit.
14
+ When the start commit already meets the ticket, for example because a test-writer correction made the locked tests green, make no commit: report DONE_WITH_CONCERNS, list no commit in `commits`, and give a concern that says why the start needs no change. The driver gates and reviews the start commit. Report NEEDS_CONTEXT or BLOCKED only for a question that stops your work: the operator answers it.
14
15
  In `green`, give the summary lines of the passing test output.
15
16
 
16
17
  Write one JSON report at {report} that matches this schema:
@@ -21,13 +22,11 @@ Write one JSON report at {report} that matches this schema:
21
22
  "required": ["status", "commits", "files", "concerns", "green"],
22
23
  "properties": {
23
24
  "status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
24
- "commits": {"type": "array", "items": {"type": "string", "pattern": "^[0-9a-f]{7,40}$"}},
25
+ "commits": {"description": "Only the commits you made, so empty when you changed nothing: never list a commit that was on the branch at your start.", "type": "array", "items": {"type": "string", "pattern": "^[0-9a-f]{7,40}$"}},
25
26
  "files": {"type": "array", "items": {"type": "string"}},
26
27
  "concerns": {"type": "array", "items": {"type": "string"}},
27
28
  "green": {"type": "array", "items": {"type": "string"}}
28
- },
29
- "if": {"properties": {"status": {"enum": ["DONE", "DONE_WITH_CONCERNS"]}}},
30
- "then": {"properties": {"commits": {"minItems": 1}}}
29
+ }
31
30
  }
32
31
  ```
33
32
 
@@ -26,7 +26,7 @@ Write one JSON report at {report}. When your sandbox is read-only, give the JSON
26
26
  "files": {"type": "array", "items": {"type": "string"}},
27
27
  "concerns": {"type": "array", "items": {"type": "string"}},
28
28
  "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}}}},
29
- "mutations": {"description": "Required in a full review: one proof or more for each locked test file, with `test` as `<locked file>::<test name>`. A review scoped to a fix gives the proofs that it names.", "type": "array", "items": {"type": "object", "required": ["test", "file", "line", "red"], "properties": {"test": {"type": "string", "minLength": 1}, "file": {"type": "string", "minLength": 1}, "line": {"type": "integer"}, "red": {"type": "string", "minLength": 1}}}}
29
+ "mutations": {"description": "Required in a full review: one proof or more for each locked test file that the end of this prompt names (a locked fixture holds no test and needs none), with `test` as `<locked file>::<test name>`. A review scoped to a fix gives the proofs that it names.", "type": "array", "items": {"type": "object", "required": ["test", "file", "line", "red"], "properties": {"test": {"type": "string", "minLength": 1}, "file": {"type": "string", "minLength": 1}, "line": {"type": "integer"}, "red": {"type": "string", "minLength": 1}}}}
30
30
  }
31
31
  }
32
32
  ```
@@ -26,6 +26,7 @@ Write one JSON report at {report} that matches this schema:
26
26
  "files": {"type": "array", "items": {"type": "string"}},
27
27
  "concerns": {"type": "array", "items": {"type": "string"}},
28
28
  "locked": {"type": "array", "items": {"type": "string"}},
29
+ "fixtures": {"description": "Each file of `locked` that holds no test, as a fake, a fixture or a helper: a review needs no mutation proof for it.", "type": "array", "items": {"type": "string"}},
29
30
  "red": {"type": "array", "items": {"type": "object", "required": ["test", "line"], "properties": {"test": {"type": "string", "minLength": 1}, "line": {"type": "string", "minLength": 1}}}},
30
31
  "not_addressed": {"type": "array", "items": {"type": "object", "required": ["finding", "reason"], "properties": {"finding": {"type": "string", "minLength": 1}, "reason": {"type": "string", "minLength": 1}}}}
31
32
  },
@@ -13,7 +13,7 @@ import driver_review_page
13
13
  from test_cli import git
14
14
  from test_fixloop import Inside, inside # noqa: F401 (the autouse fixture puts the rig's CLIs on PATH)
15
15
  from test_tidy import Inside as Pushing, tools # noqa: F401 (an unattended run pushes: the rig with an origin and a fake gh)
16
- from test_review import ONE, finding, fix, review
16
+ from test_review import ONE, STUCK, finding, fix, review
17
17
  from test_stops import CONTRA, NEW_TEST, Q1, UNATTENDED, blocked, correction, decisions, stage, steps, write_answers
18
18
  from test_walk import impl, plan, tw
19
19
 
@@ -293,15 +293,16 @@ def test_a_locked_file_keeps_its_old_reference_until_a_test_writer_lists_it(repo
293
293
  old = commit("b.py", "1\n")
294
294
  commit("b.py", "the implementer changed it\n")
295
295
  tip = commit("a.py", "the correction\n")
296
- first = driver_review.written(".", {"test_writer_sha": None, "locked": [], "held": {}}, ["a.py", "b.py", "c.py"], old)
297
- assert first == {"test_writer_sha": old, "locked": ["a.py", "b.py", "c.py"], "held": {}}
298
- after = driver_review.written(".", first, ["a.py"], tip)
299
- assert after == {"test_writer_sha": tip, "locked": ["a.py", "b.py", "c.py"], "held": {"b.py": old}}
296
+ first = driver_review.written(".", {"test_writer_sha": None, "locked": [], "held": {}, "fixtures": []},
297
+ ["a.py", "b.py", "c.py"], [], old)
298
+ assert first == {"test_writer_sha": old, "locked": ["a.py", "b.py", "c.py"], "held": {}, "fixtures": []}
299
+ after = driver_review.written(".", first, ["a.py"], [], tip)
300
+ assert after == {"test_writer_sha": tip, "locked": ["a.py", "b.py", "c.py"], "held": {"b.py": old}, "fixtures": []}
300
301
  (finding,) = driver_review.locked_findings(".", after)
301
302
  assert (finding["title"], finding["evidence"]) == ("locked file changed: b.py", f"git diff {old}..HEAD -- b.py")
302
- assert driver_review.written(".", after, ["b.py"], tip)["held"] == {}, "the test-writer corrected it: a new reference"
303
+ assert driver_review.written(".", after, ["b.py"], [], tip)["held"] == {}, "the test-writer corrected it: a new reference"
303
304
  # A diff that git cannot make holds each other file, and then the check of the review fails in the open.
304
- lost = driver_review.written(".", {**first, "test_writer_sha": "0" * 40}, ["a.py"], tip)
305
+ lost = driver_review.written(".", {**first, "test_writer_sha": "0" * 40}, ["a.py"], [], tip)
305
306
  assert lost["held"] == {"b.py": "0" * 40, "c.py": "0" * 40}
306
307
  assert [f["title"].split(":")[0] for f in driver_review.locked_findings(".", lost)] == ["locked file check failed"]
307
308
 
@@ -488,3 +489,83 @@ def test_no_open_question_or_no_file_reads_nothing_and_given_writes_only_valid_a
488
489
  assert driver_answers.given([(Q1, "overrule-test")], one) == []
489
490
  assert driver_answers.read(one) == ({Q1: "overrule-test"}, [])
490
491
  assert driver_answers.read(doc()) == ({}, []), "with no open question the file is history"
492
+
493
+
494
+ # ---------------------------------------------------------------- an implementer or a fixer with nothing to change, or that stops
495
+
496
+ IMPLEMENTER_STOPPED, FIXER_STOPPED = "01-implementer-stopped-1", "01-fixer-stopped-1"
497
+ NO_CHANGE = "the correction made the locked tests green: the start needs no change"
498
+
499
+
500
+ def unchanged():
501
+ """An implementer step with no commit: the start commit already meets the ticket."""
502
+ return {"report": {"status": "DONE_WITH_CONCERNS", "commits": [], "files": [], "concerns": [NO_CHANGE],
503
+ "green": ["1 passed"]}}
504
+
505
+
506
+ def stops(role="implementer", status="NEEDS_CONTEXT"):
507
+ report = {"status": status, "commits": [], "files": [], "concerns": ["the ticket names no column order"],
508
+ "green": [], **({"ticket": "01"} if role == "fixer" else {})}
509
+ return {"report": report}
510
+
511
+
512
+ def test_an_implementer_with_nothing_to_change_after_a_correction_is_accepted_and_its_start_is_gated(tmp_path):
513
+ """Issue 123: after `overrule-test` the correction made the locked tests green, so the implementer had nothing to
514
+ change, and no report of it was valid: NEEDS_CONTEXT blocked the ticket with no question."""
515
+ rig = stopped(tmp_path)
516
+ rig.run(steps(blocked(), unchanged()), "--answer", f"{Q1}=overrule-test")
517
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
518
+ assert len(rig.calls("01", "implementer")) == 2 and rig.led("implementer ran on", "report accepted")
519
+ corrected = rig.calls("01", "test-writer")[1]["sha"]
520
+ assert corrected in [gate["commit"] for gate in rig.gates()]
521
+ assert rig.calls("01", "reviewer")[0]["head"] == corrected
522
+ assert "list no commit" in rig.prompt("implementer-0")
523
+
524
+
525
+ @pytest.mark.parametrize("status", ["NEEDS_CONTEXT", "BLOCKED"])
526
+ def test_an_implementer_that_stops_asks_the_operator_and_retry_runs_it_again(tmp_path, status):
527
+ """Issue 123: a stop of the implementer that is not `locked test contradicts spec:` had no question."""
528
+ rig = Inside(tmp_path, ONE).run(steps(stops(status=status)))
529
+ assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
530
+ (question,) = rig.state()["run"]["questions"]
531
+ assert (question["id"], question["recommended"]) == (IMPLEMENTER_STOPPED, "retry")
532
+ assert [o["id"] for o in question["options"]] == ["retry", "accept-tip", "redesign"]
533
+ assert question["evidence"][0] == ".agent/implement/01/implementer-0.json"
534
+ assert question["subject"] == f"the implementer reported {status}: the ticket names no column order"
535
+ rig.run(steps(stops(status=status), impl("01")), "--answer", f"{IMPLEMENTER_STOPPED}=retry")
536
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
537
+ assert len(rig.calls("01", "implementer")) == 2 and len(rig.calls("01", "test-writer")) == 1
538
+ assert rig.led(f"Ruling: 01 implementer runs again (retry): the implementer reported {status}")
539
+
540
+
541
+ def test_accept_tip_gates_and_reviews_the_tip_the_stopped_implementer_left(tmp_path):
542
+ rig = Inside(tmp_path, ONE).run(steps(stops()))
543
+ assert rig.code == 2, rig.ledger()
544
+ rig.run(steps(stops()), "--answer", f"{IMPLEMENTER_STOPPED}=accept-tip")
545
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
546
+ tip = rig.sha("01", "test-writer")
547
+ assert len(rig.calls("01", "implementer")) == 1 and tip in [gate["commit"] for gate in rig.gates()]
548
+ assert rig.calls("01", "reviewer")[0]["head"] == tip
549
+
550
+
551
+ def test_an_implementer_stop_answered_redesign_keeps_the_ticket_blocked(tmp_path):
552
+ rig = Inside(tmp_path, ONE).run(steps(stops()))
553
+ rig.run(steps(stops()), "--answer", f"{IMPLEMENTER_STOPPED}=redesign")
554
+ assert rig.code == 1 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
555
+ assert len(rig.calls("01", "implementer")) == 1
556
+
557
+
558
+ def test_a_fixer_that_stops_asks_the_operator_and_retry_runs_its_round_again(tmp_path):
559
+ """Issue 123: the round that stopped does not count, so the retry is that round again, after a review."""
560
+ steps = plan(**{"01/reviewer": [review("01", [STUCK]), review("01", [STUCK]), review("01")],
561
+ "01/fixer": [stops("fixer"), fix("01", 1)]})
562
+ rig = Inside(tmp_path, ONE).run(steps)
563
+ assert rig.code == 2 and rig.state()["tickets"]["01"]["round"] == 0, rig.ledger()
564
+ (question,) = rig.state()["run"]["questions"]
565
+ assert (question["id"], question["recommended"]) == (FIXER_STOPPED, "retry")
566
+ assert [o["id"] for o in question["options"]] == ["retry", "redesign"]
567
+ assert question["evidence"][0] == ".agent/implement/01/fixer-1.json"
568
+ rig.run(steps, "--answer", f"{FIXER_STOPPED}=retry")
569
+ assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
570
+ assert rig.state()["tickets"]["01"]["round"] == 1 and len(rig.calls("01", "fixer")) == 2
571
+ assert rig.led("Ruling: 01 fix round runs again (retry): the fixer reported NEEDS_CONTEXT")
@@ -221,7 +221,7 @@ def test_a_report_that_says_blocked_blocks_the_ticket_without_a_rerun(repo, tmp_
221
221
  repo()
222
222
  body = f"""printf '{{"status": "{status}", "commits": [], "files": [], "concerns": ["test_x contradicts the spec"], "green": []}}' > "$report"\n"""
223
223
  code, ledger = agents(tmp_path, capsys, body)
224
- assert code == 1 and len(ledger) == 2
224
+ assert code == 2 and len(ledger) == 3 and "question of kind implementer-stopped" in ledger[2]
225
225
  assert ledger[1] == f"Ticket 01: BLOCKED at the implementer: the implementer reported {status}: test_x contradicts the spec."
226
226
 
227
227
 
@@ -364,6 +364,7 @@ REFACTOR = {"seam": "none — refactor"}
364
364
  # A fixer that cannot make the red gate green: the ticket blocks at fix round 1.
365
365
  GIVE_UP = """[ $role != fixer ] || { printf '{"status": "BLOCKED", "commits": [], "files": [], "concerns": ["the gate stays red"], "green": [], "ticket": "01"}' > "$report"; exit 0; }\n"""
366
366
  GAVE_UP = "Ticket 01: BLOCKED at fix round 1: the fixer reported BLOCKED: the gate stays red."
367
+ ASKED = "Ticket 01: the operator decides on 1 question of kind fixer-stopped in .agent/implement/decisions.json."
367
368
 
368
369
 
369
370
  def walk(tmp_path, capsys, body, *args, gate="true"):
@@ -462,14 +463,14 @@ def test_a_red_gate_is_a_finding_and_the_ticket_it_blocks_never_starts(repo, tmp
462
463
  two(repo, second="01")
463
464
  code, ledger, out = walk(tmp_path, capsys, GIVE_UP + WORK + REPORT, gate="echo CHECK-OUTPUT; exit 1")
464
465
  tip = out_of("git", "rev-parse", "--short=7", "ticket/feat%2Fx/01")
465
- assert code == 1 and ledger[-1] == GAVE_UP, out
466
+ assert code == 2 and ledger[-2:] == [GAVE_UP, ASKED], out
466
467
  assert ledger[1] == (f"Ticket 01: critical finding of kind code from the gate at "
467
468
  f".agent/implement/01/gate-{tip}.log:0: the gate is red on {tip}.")
468
469
  record = (tmp_path / f".agent/implement/01/gate-{tip}.log").read_text()
469
470
  assert "status: clean\n" in record and "CHECK-OUTPUT\n\nexit: 1\nafter: clean\nend: " in record
470
471
  assert "Ticket 02 is not merged: its phase is pending." in out and "| gates run | 1 |" in out
471
472
  assert out_of("git", "symbolic-ref", "--short", "HEAD") == "feat/x"
472
- assert walk(tmp_path, capsys, "exit 9\n")[0] == 1 # a BLOCKED ticket stays BLOCKED on a rerun
473
+ assert walk(tmp_path, capsys, "exit 9\n")[0] == 2 # a BLOCKED ticket stays BLOCKED on a rerun
473
474
 
474
475
 
475
476
  def test_a_red_merge_gate_blocks_the_ticket_and_the_pr_branch_does_not_move(repo, tmp_path, capsys):
@@ -486,12 +487,12 @@ def test_a_red_merge_gate_blocks_the_ticket_and_the_pr_branch_does_not_move(repo
486
487
  def test_a_tree_that_is_not_clean_is_a_red_gate_and_the_slot_keeps_the_work(repo, tmp_path, capsys):
487
488
  repo(t01=ticket("01", **REFACTOR))
488
489
  code, ledger, out = walk(tmp_path, capsys, GIVE_UP + WORK + REPORT + "echo left > junk.txt\n", gate="echo NEVER")
489
- assert code == 1 and "from the gate at .agent/implement/01/gate-" in ledger[-3] and ledger[-1] == GAVE_UP, out
490
+ assert code == 2 and "from the gate at .agent/implement/01/gate-" in ledger[-4] and ledger[-2:] == [GAVE_UP, ASKED], out
490
491
  record = next((tmp_path / ".agent/implement/01").glob("gate-*.log")).read_text()
491
492
  assert "status: not clean\n ?? junk.txt\n" in record and "exit: not run" in record and "\nNEVER\n" not in record
492
493
  assert out_of("git", "symbolic-ref", "--short", "HEAD") == "ticket/feat%2Fx/01" and (tmp_path / "junk.txt").exists()
493
494
  code, _, out = walk(tmp_path, capsys, "exit 9\n")
494
- assert code == 3 and "uncommitted change: junk.txt" in out
495
+ assert code == 2 and (tmp_path / "junk.txt").exists(), "the stop repeats: the work in the slot is no error"
495
496
 
496
497
 
497
498
  def test_a_failing_prepare_stops_the_run_and_removes_the_slot(repo, tmp_path, capsys):
@@ -886,7 +887,7 @@ def test_a_merge_commit_the_slot_cannot_check_out_is_not_gated_and_does_not_land
886
887
  def test_a_gate_that_changes_the_tree_or_moves_head_is_red(repo, tmp_path, capsys, gate, after):
887
888
  repo(t01=ticket("01", **REFACTOR))
888
889
  code, ledger, out = walk(tmp_path, capsys, GIVE_UP + WORK + REPORT, gate=gate)
889
- assert code == 1 and "from the gate at .agent/implement/01/gate-" in ledger[-3] and ledger[-1] == GAVE_UP, out
890
+ assert code == 2 and "from the gate at .agent/implement/01/gate-" in ledger[-4] and ledger[-2:] == [GAVE_UP, ASKED], out
890
891
  record = next((tmp_path / ".agent/implement/01").glob("gate-*.log")).read_text()
891
892
  assert "\nexit: 0\n" in record and after in record
892
893
  assert state_of(tmp_path)["tickets"]["01"]["green_gates"] == []
@@ -727,13 +727,11 @@ def test_the_escalation_takes_the_next_entry_of_the_list():
727
727
  assert driver_fixloop.entry({"implementer": ["a@low"]}, 3) == "a@low"
728
728
 
729
729
 
730
- @pytest.mark.parametrize("step, error", [
731
- ({}, "BLOCKED at fix round 1: report .agent/implement/01/fixer-1.json is not"),
732
- ({"report": {"status": "BLOCKED", "commits": [], "files": [], "concerns": ["cannot"], "green": [], "ticket": "01"}},
733
- "BLOCKED at fix round 1: the fixer reported BLOCKED: cannot.")])
734
- def test_a_fixer_that_does_not_finish_blocks_the_ticket_in_its_round(tmp_path, step, error):
735
- rig = Inside(tmp_path).run(plan(**{"01/reviewer": [review("01", [STUCK])], "01/fixer": [step, step]}))
730
+ def test_a_fixer_that_does_not_finish_blocks_the_ticket_in_its_round(tmp_path):
731
+ """A fixer that reports BLOCKED asks a `fixer-stopped` question: test_decisions covers it."""
732
+ rig = Inside(tmp_path).run(plan(**{"01/reviewer": [review("01", [STUCK])], "01/fixer": [{}, {}]}))
736
733
  entry = rig.state()["tickets"]["01"]
734
+ error = "BLOCKED at fix round 1: report .agent/implement/01/fixer-1.json is not"
737
735
  assert error in blocked(rig) and entry["round"] == 1 and entry["tip"] == rig.sha("01", "implementer")
738
736
 
739
737
 
@@ -767,6 +765,27 @@ def test_a_full_review_after_a_correction_names_each_locked_file_that_needs_a_pr
767
765
  assert "In round 1" not in full and due not in again
768
766
 
769
767
 
768
+ def test_a_full_review_needs_no_proof_for_a_locked_fixture_that_holds_no_test(tmp_path):
769
+ """Issue #118: a fake `gh` the test-writer locks holds no test, so no `<locked file>::<test name>` can name it."""
770
+ first = {**tw("01"), "files": {"tests/test_01.py": "def test_x():\n assert 0\n", "tests/fakes/gh": "exit 0\n"}}
771
+ first["report"] = {**first["report"], "files": ["tests/test_01.py", "tests/fakes/gh"],
772
+ "locked": ["tests/test_01.py", "tests/fakes/gh"], "fixtures": ["tests/fakes/gh"]}
773
+ rig = Inside(tmp_path).run(plan(**{"01/test-writer": [first], "01/reviewer": [review("01")]}))
774
+ assert rig.code == 0 and len(rig.calls("01", "reviewer")) == 1, rig.ledger()
775
+ assert rig.state()["tickets"]["01"]["fixtures"] == ["tests/fakes/gh"]
776
+ assert "for each of these locked test files: tests/test_01.py\n" in rig.calls("01", "reviewer")[0]["prompt"]
777
+
778
+
779
+ def test_a_fixture_must_be_a_locked_file_and_a_correction_that_relists_it_decides_again(tmp_path):
780
+ report = dict(status="NEEDS_CONTEXT", commits=[], files=[], concerns=[], locked=["a"], red=[], fixtures=["gh"])
781
+ path = tmp_path / "test-writer-0.json"
782
+ path.write_text(json.dumps(report))
783
+ context = {"repo": ".", "branch": "HEAD", "start": "HEAD", "log": str(path)}
784
+ assert "fixtures: gh is not in `locked`" in driver_report.validate("test-writer", str(path), context)
785
+ entry = {"test_writer_sha": None, "locked": ["tests/a.py", "gh", "fake"], "held": {}, "fixtures": ["gh", "fake"]}
786
+ assert driver_review.written(".", entry, ["gh"], [], "tip")["fixtures"] == ["fake"]
787
+
788
+
770
789
  def test_the_locked_file_rule_is_for_the_first_review_only(tmp_path):
771
790
  report = dict(status="DONE", commits=[], files=[], concerns=[], findings=[], mutations=[])
772
791
  path = tmp_path / "reviewer-0.json"
@@ -134,6 +134,17 @@ def test_implementer_without_a_new_commit_is_a_violation(world):
134
134
  assert check("implementer", implementer(shas), start=shas["impl"]) # its only commit is not new
135
135
 
136
136
 
137
+ def test_an_implementer_with_nothing_to_change_reports_no_commit_and_why(world):
138
+ """Issue 123: an implementer whose start already meets the ticket has a report the driver accepts."""
139
+ shas, check, _ = world
140
+ why = ["the correction made the locked tests green: the start needs no change"]
141
+ assert check("implementer", implementer(shas, commits=[], concerns=why), start=shas["impl"]) == []
142
+ assert check("implementer", implementer(shas, commits=[]), start=shas["impl"]) == [
143
+ "no commit, and no concern: say in `concerns` why the start needs no change"]
144
+ assert check("implementer", implementer(shas, commits=[], concerns=why), start=shas["tests"]) == [
145
+ f"commit {shas['impl'][:7]} is on ticket/01 and not in `commits`: list each commit you made"]
146
+
147
+
137
148
  def test_a_fixer_with_nothing_to_change_reports_no_commit_and_a_reason_per_finding(world):
138
149
  """Issue 123: a fixer whose findings need no change has a report the driver accepts: no commit, a concern each."""
139
150
  shas, check, tmp = world
@@ -30,12 +30,14 @@ def test_updates_from_many_threads_are_all_kept_and_no_scratch_file_stays(tmp_pa
30
30
  def test_start_keeps_a_recorded_run_and_adds_only_the_new_tickets(tmp_path):
31
31
  state = driver_state.State(tmp_path / "state.json")
32
32
  revision = state.start("feat/x", ["01"])["run"]["revision"]
33
+ state.update(lambda record: record["tickets"]["01"].pop("fixtures")) # a run of an older driver
33
34
  state.ticket("01", phase="merged")
34
35
  again = state.start("other", ["01", "02"])
35
36
  assert (again["run"]["revision"], again["run"]["pr_branch"]) == (revision, "feat/x")
36
- assert again["tickets"]["01"]["phase"] == "merged" and again["tickets"]["02"] == {
37
+ assert again["tickets"]["01"]["phase"] == "merged" and again["tickets"]["01"]["fixtures"] == []
38
+ assert again["tickets"]["02"] == {
37
39
  "phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": [], "slot": None,
38
- "note": "", "held": {}}
40
+ "note": "", "held": {}, "fixtures": []}
39
41
 
40
42
 
41
43
  def test_verified_trusts_a_tip_only_while_it_is_on_the_ticket_branch(repo, tmp_path):
@@ -13,8 +13,8 @@ Interface choices (ticket 05):
13
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
14
  and `<NN>-finding-<n>` for an open finding after round 4. Options: `overrule-test` / `overrule-implementer`
15
15
  (recommended: overrule-implementer), and `accept` / `split` / `redesign`.
16
- - an implementer is BLOCKED with a stop only when a `concerns` entry starts with "locked test contradicts spec:";
17
- any other BLOCKED report is an ordinary BLOCKED ticket (exit 1, no decisions file).
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).
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
@@ -193,11 +193,11 @@ def test_answer_for_an_unknown_question_id_exits_3_naming_it_before_any_agent(tm
193
193
  assert "no-such-question" in rig.out + rig.err and len(rig.calls()) == seen
194
194
 
195
195
 
196
- def test_a_blocked_report_that_is_not_a_contradicted_locked_test_is_not_a_stop(tmp_path):
196
+ def test_a_blocked_report_that_is_not_a_contradicted_locked_test_is_an_implementer_stop(tmp_path):
197
197
  rig = Review(tmp_path)
198
198
  rig.run(steps(blocked("cannot reach the database")))
199
- assert rig.code == 1, rig.output()
200
- assert not (rig.repo / ".agent/implement/decisions.json").exists()
199
+ assert rig.code == 2, rig.output()
200
+ assert [q["id"] for q in decisions(rig)["questions"]] == ["01-implementer-stopped-1"]
201
201
  assert rig.state()["tickets"]["01"]["phase"] == "blocked"
202
202
 
203
203
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-10-20T15:11:42.597Z",
3
+ "generatedAt": "2026-10-20T16:37:17.283Z",
4
4
  "skills": [
5
5
  {
6
6
  "name": "backlog",
@@ -46,8 +46,8 @@
46
46
  },
47
47
  {
48
48
  "name": "implement-spec",
49
- "version": "0.1.32",
50
- "hash": "sha256-65312a2ea436f3f7c99c5b53fced3118d07c4c90602f46cfb8037ed2e5c4eb9b",
49
+ "version": "0.1.34",
50
+ "hash": "sha256-ca0c5e9ee91c37da47c844b5617ac8e57dfe7a79c402a4c286e887471f54e9fb",
51
51
  "description": "Implement a specification in code."
52
52
  },
53
53
  {