@jesdi/skills 0.0.62 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/implement-spec/ARCHITECTURE.md +5 -0
- package/skills/implement-spec/README.md +6 -5
- package/skills/implement-spec/driver.py +11 -1
- package/skills/implement-spec/driver_decisions.py +23 -0
- package/skills/implement-spec/driver_fixloop.py +17 -5
- package/skills/implement-spec/driver_report.py +16 -5
- package/skills/implement-spec/driver_state.py +2 -2
- package/skills/implement-spec/prompts/rejected.md +1 -0
- package/skills/implement-spec/tests/test_decisions.py +57 -0
- package/skills/implement-spec/tests/test_fixloop.py +14 -2
- package/skills/implement-spec/tests/test_report.py +18 -0
- package/skills/implement-spec/tests/test_review.py +1 -1
- package/skills/implement-spec/tests/test_state.py +1 -1
- package/skills-manifest.json +3 -3
package/package.json
CHANGED
|
@@ -152,6 +152,9 @@ and do not know about the run, except `driver_run.py`, which the three deciding
|
|
|
152
152
|
- A reviewer or a correctness pass that reports BLOCKED or NEEDS_CONTEXT raises `driver_run.Stopped`, which
|
|
153
153
|
carries the report. `driver_fixloop._run_reviewers` turns it into a `review-stopped` question, or, after an
|
|
154
154
|
`accept` ruling on that role (`driver_decisions.accepted`), uses the report as it is.
|
|
155
|
+
- A reviewer or a correctness pass whose report the driver rejects two times asks a `review-rejected` question.
|
|
156
|
+
The stop records each rejection in the ticket's `rejected` (role -> why); after `retry`, the role's first prompt
|
|
157
|
+
carries it (`prompts/rejected.md`), and the next review that ends clears it.
|
|
155
158
|
- An implementer or a fixer that reports BLOCKED or NEEDS_CONTEXT asks a question in `Run._ask_stop`: `locked-test`
|
|
156
159
|
for a contradicted locked test, else `implementer-stopped` or `fixer-stopped`. The stop of a fixer sets the round
|
|
157
160
|
back by one, so its `retry` (gate and review the tip, then a fixer) runs the same round again.
|
|
@@ -165,6 +168,8 @@ and do not know about the run, except `driver_run.py`, which the three deciding
|
|
|
165
168
|
|
|
166
169
|
- A stop is a bounded question in `state.json`. Only `driver_decisions.stop` adds one. An answered question is
|
|
167
170
|
never open again.
|
|
171
|
+
- An open question of a merged ticket is dropped (`driver_decisions.drop_merged`), at the start of a run and after
|
|
172
|
+
each landing, with a ledger line: a ticket the operator set to `merge` by hand leaves its stop behind.
|
|
168
173
|
- An answers file counts only when it is bound to the revision of the current `decisions.json`.
|
|
169
174
|
- Only a question whose kind parks gives exit 2. A third round of the final review is never started: its open
|
|
170
175
|
findings become questions.
|
|
@@ -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`, `implementer-stopped`, `fixer-stopped`, `merged-locked-file` 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`, `review-rejected`, `implementer-stopped`, `fixer-stopped`, `merged-locked-file` 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; 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.
|
|
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, and a report of theirs that the driver rejects two times asks a `review-rejected` 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`), 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
|
|
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, and is a file at the tip: a correction that deletes a locked file leaves it out of `locked`. 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
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`) | 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. |
|
|
182
|
+
| reviewer | `prompts/reviewer.md` | `findings` (`severity`, `file`, `line`, `title`, `evidence`, `kind`), `mutations` (`test`, `file`, `line`, `red`) | 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. Neither does a locked file that is not at the reviewed tip. Each `red` is in the log. |
|
|
183
183
|
| correctness | `prompts/correctness.md` | the same as the reviewer | `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,12 +199,13 @@ 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
|
+
| `review-rejected` | `<NN>-review-rejected-<n>` | The driver rejects the report of the reviewer or the correctness pass, and the report of its rerun too (for example, no mutation proof for a locked test file). One question for each agent. | 2 | `retry` (recommended): the ticket resumes from the review, each agent of the review runs again, and the first prompt of the rejected agent says why the driver rejected it. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
202
203
|
| `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
204
|
| `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. |
|
|
204
205
|
| `merged-locked-file` | `<NN>-merged-locked-file-<n>` | The landing check refuses the landing: the tree that would land changes this locked file of a merged ticket. One question for each file. | 2 | `restore` (recommended): the driver puts the file back to the version of the PR branch in a commit of its own on the ticket branch, and the ticket resumes from its landing. `adopt`: the ticket adds the file to its `locked`, so its change lands, and resumes from its landing. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. When the merge gate is red after `restore` or `adopt`, the driver takes the restore commit back and asks again, without the option that was tried. |
|
|
205
206
|
| `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. |
|
|
206
207
|
|
|
207
|
-
`n` counts the questions of that ticket and kind in the run, so an id is never used twice.
|
|
208
|
+
`n` counts the questions of that ticket and kind in the run, so an id is never used twice. An open question of a ticket that has merged is dropped, with a ledger line: it leaves `decisions.json` and parks no run.
|
|
208
209
|
|
|
209
210
|
Answer with `--answer <question id>=<option id>` on the next run, or through the page, which gives `.agent/implement-answers.json`. An answers file counts only when it is submitted and its `revision` equals the `revision` of `decisions.json`. The driver ignores any other file or answer and says so in the ledger. Each answer becomes one `Ruling:` sentence in the ledger.
|
|
210
211
|
|
|
@@ -278,6 +278,7 @@ def _merge(ticket: Ticket, slot: str, run: Run) -> None:
|
|
|
278
278
|
with run.merging, during("the merge"):
|
|
279
279
|
landing, rulings = _land(ticket, slot, run)
|
|
280
280
|
run.state.update(lambda state: _record_landing(state, number, landing, rulings.adopted()))
|
|
281
|
+
_drop_merged(run.state)
|
|
281
282
|
for path in rulings.adopted():
|
|
282
283
|
ledger(f"Ticket {number}: by the ruling (adopt), the ticket locks {path}, so its change to that locked file of "
|
|
283
284
|
"a merged ticket landed.")
|
|
@@ -310,6 +311,14 @@ def _block(number: str, run: Run, ledger_line: int) -> None:
|
|
|
310
311
|
ledger(f"Ticket {number}: {driver_decisions.decides(ask.kind, len(ask.subjects))} in {DECISIONS}.")
|
|
311
312
|
|
|
312
313
|
|
|
314
|
+
def _drop_merged(state: driver_state.State) -> None:
|
|
315
|
+
"""Drop the open questions of each merged ticket: a stopped ticket that the operator set to `merge` has them."""
|
|
316
|
+
dropped: list[dict] = []
|
|
317
|
+
state.update(lambda new: dropped.extend(driver_decisions.drop_merged(new)))
|
|
318
|
+
for question in dropped:
|
|
319
|
+
ledger(f"Ticket {question['ticket']}: the question {question['id']} is dropped: the ticket merged.")
|
|
320
|
+
|
|
321
|
+
|
|
313
322
|
def _halt(run: Run, owner: str, why: str) -> None:
|
|
314
323
|
"""Start no other agent: the run ends with exit 4, and `owner` keeps its phase for the next run."""
|
|
315
324
|
run.halted.append(why)
|
|
@@ -443,7 +452,7 @@ def _resume(tickets: list[Ticket], state: driver_state.State, pr: str, slots: in
|
|
|
443
452
|
|
|
444
453
|
def _publish_questions(run: dict) -> str:
|
|
445
454
|
"""Write decisions.json and the review page for the questions of `run` of state.json; "" or the error."""
|
|
446
|
-
if not run["questions"]:
|
|
455
|
+
if not (run["questions"] or DECISIONS.exists()): # a dropped question leaves a file to rewrite
|
|
447
456
|
return ""
|
|
448
457
|
document = driver_decisions.document(run)
|
|
449
458
|
DECISIONS.write_text(json.dumps(document, indent=1) + "\n")
|
|
@@ -459,6 +468,7 @@ def _publish_questions(run: dict) -> str:
|
|
|
459
468
|
|
|
460
469
|
def _apply_answers(state: driver_state.State, args) -> list[str]:
|
|
461
470
|
"""Turn each answer that counts into a ruling and let its ticket go on; [] or the errors that stop the run."""
|
|
471
|
+
_drop_merged(state)
|
|
462
472
|
run = state.read()["run"]
|
|
463
473
|
questions, document = run["questions"], driver_decisions.document(run)
|
|
464
474
|
if errors := driver_answers.given(args.answer, document):
|
|
@@ -91,6 +91,19 @@ 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
|
+
"review-rejected": Kind(
|
|
95
|
+
True,
|
|
96
|
+
"Ticket {ticket}: the driver rejected an agent of the review two times: {subject}",
|
|
97
|
+
"The driver rejected the report of the reviewer or the correctness pass of ticket {ticket}, and the report of "
|
|
98
|
+
"its rerun too, so the review did not end. Ticket {ticket} is BLOCKED and each ticket that it blocks waits.",
|
|
99
|
+
"retry",
|
|
100
|
+
{"retry": Option(
|
|
101
|
+
"The review runs again, with each of its agents. The first prompt of the rejected agent says why the "
|
|
102
|
+
"driver rejected its report.",
|
|
103
|
+
"Ruling: {ticket} review runs again (retry): {subject}.", {"phase": "review"}),
|
|
104
|
+
"redesign": Option(
|
|
105
|
+
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
106
|
+
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
94
107
|
"implementer-stopped": Kind(
|
|
95
108
|
True,
|
|
96
109
|
"Ticket {ticket}: the implementer stopped: {subject}",
|
|
@@ -177,6 +190,16 @@ def accepted(questions: list[dict], ticket: str, kind: str) -> list[str]:
|
|
|
177
190
|
return [q["subject"] for q in questions if (q["ticket"], q["kind"], q["answer"]) == (ticket, kind, "accept")]
|
|
178
191
|
|
|
179
192
|
|
|
193
|
+
def drop_merged(state: dict) -> list[dict]:
|
|
194
|
+
"""Remove the open questions of each merged ticket from `state`: the stop that asked them is over (issue #136).
|
|
195
|
+
Returns them."""
|
|
196
|
+
merged = {number for number, entry in state["tickets"].items() if entry["phase"] == "merged"}
|
|
197
|
+
run = state["run"]
|
|
198
|
+
dropped = [q for q in run["questions"] if q["answer"] is None and q["ticket"] in merged]
|
|
199
|
+
run["questions"] = [q for q in run["questions"] if q not in dropped]
|
|
200
|
+
return dropped
|
|
201
|
+
|
|
202
|
+
|
|
180
203
|
def contradicted(role: str, report: dict) -> str:
|
|
181
204
|
"""The locked tests that a BLOCKED report of an implementer or a fixer says contradict the spec; "" when it is not
|
|
182
205
|
that stop."""
|
|
@@ -69,12 +69,15 @@ def _log_findings(job: Job, findings: list[dict]) -> list[dict]:
|
|
|
69
69
|
def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) -> list[dict]:
|
|
70
70
|
"""Run the (role, model entry) pairs of `cast` at the same time in the one slot. Returns their reports.
|
|
71
71
|
A role that stops (BLOCKED, NEEDS_CONTEXT) asks a `review-stopped` question, unless an `accept` ruling on an
|
|
72
|
-
earlier stop of that role lets the review go on with its report.
|
|
72
|
+
earlier stop of that role lets the review go on with its report. A role whose report the driver rejects two
|
|
73
|
+
times asks a `review-rejected` question; after `retry`, its first prompt says why (issue #136)."""
|
|
73
74
|
number = job.ticket.number
|
|
74
75
|
values, running = job.pointers(job.round - 1), [role for role, _ in cast]
|
|
75
76
|
values["fixer_report"] = os.path.relpath(OUT / number / f"fixer-{job.round}.json", job.slot)
|
|
76
|
-
errors, stops = {}, {}
|
|
77
|
-
|
|
77
|
+
errors, stops, rejected = {}, {}, {}
|
|
78
|
+
state = job.run.state.read()
|
|
79
|
+
accepted = driver_decisions.accepted(state["run"]["questions"], number, "review-stopped")
|
|
80
|
+
before = state["tickets"][number]["rejected"] # role -> why the driver rejected it before the ruling
|
|
78
81
|
|
|
79
82
|
def call(role: str, entry: str) -> dict:
|
|
80
83
|
# A full review (no fix range) must give a mutation proof for each locked test file, not for a locked fixture
|
|
@@ -82,8 +85,10 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
82
85
|
full = not job.previous and role == "reviewer"
|
|
83
86
|
notes = ["rereview"] if job.previous else ["full-review"] if full else []
|
|
84
87
|
notes += ["unchanged"] * (job.previous == job.tip) # a fixer with no commit: its reasons need a check
|
|
88
|
+
notes += ["rejected"] * (role in before)
|
|
85
89
|
try:
|
|
86
|
-
return job.run.agent(role, job.ticket.number, job.slot, values,
|
|
90
|
+
return job.run.agent(role, job.ticket.number, job.slot, {**values, "rejection": before.get(role, "")},
|
|
91
|
+
entry=entry, fix_round=job.round,
|
|
87
92
|
notes=notes, check={"full": True, "locked": locked} if full else {},
|
|
88
93
|
alone=lambda: len(running) == 1)
|
|
89
94
|
except Stopped as stopped:
|
|
@@ -93,7 +98,8 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
93
98
|
stops[role] = str(stopped)
|
|
94
99
|
errors[role] = f"the {role}: {stopped}"
|
|
95
100
|
return {}
|
|
96
|
-
except Blocked as blocked:
|
|
101
|
+
except Blocked as blocked: # the driver rejected its report two times
|
|
102
|
+
rejected[role] = str(blocked)
|
|
97
103
|
errors[role] = f"the {role}: {blocked}"
|
|
98
104
|
return {}
|
|
99
105
|
finally:
|
|
@@ -105,6 +111,10 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
105
111
|
first = next(role for role, _ in cast if role in stops)
|
|
106
112
|
job.run.ask(number, "review-stopped", [stops[role] for role, _ in cast if role in stops],
|
|
107
113
|
str(OUT / number / f"{first}-{job.round}.json"))
|
|
114
|
+
elif rejected:
|
|
115
|
+
first = next(role for role, _ in cast if role in rejected)
|
|
116
|
+
job.run.ask(number, "review-rejected", [errors[role] for role, _ in cast if role in rejected],
|
|
117
|
+
str(OUT / number / f"{first}-{job.round}.json"), rejected=rejected)
|
|
108
118
|
if errors:
|
|
109
119
|
raise Blocked("; ".join(errors[role] for role, _ in cast if role in errors))
|
|
110
120
|
return reports
|
|
@@ -121,6 +131,8 @@ def _review(job: Job) -> list[dict]:
|
|
|
121
131
|
cast.append(("correctness", driver_agents.correctness_entry(run.models)))
|
|
122
132
|
reports = run.read_only(number, job.slot, job.values["branch"], job.tip,
|
|
123
133
|
lambda: _run_reviewers(job, cast, tested(state)))
|
|
134
|
+
if state["rejected"]:
|
|
135
|
+
run.state.ticket(number, rejected={}) # the rejection is answered: no later review repeats it
|
|
124
136
|
for (role, _), report in zip(cast, reports):
|
|
125
137
|
found += _log_findings(job, [{**finding, "source": role} for finding in report["findings"]])
|
|
126
138
|
job.proofs |= {(proof["file"], proof["line"]) for proof in report.get("mutations", [])}
|
|
@@ -58,8 +58,14 @@ def _owner_errors(report: dict, context: dict) -> list[str]:
|
|
|
58
58
|
for commit in report["commits"] if commit["ticket"] not in context["owners"]]
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def _present(repo: str, commit: str, paths: list[str]) -> list[str]:
|
|
62
|
+
"""The `paths` that are files at `commit`."""
|
|
63
|
+
return _git(repo, "ls-tree", "-r", "--name-only", "-z", commit, "--", *paths, end="\0") if paths else []
|
|
64
|
+
|
|
65
|
+
|
|
61
66
|
def _commit_errors(report: dict, context: dict) -> list[str]:
|
|
62
|
-
"""Every commit is new since the role started and on the branch; every locked path is in such a commit
|
|
67
|
+
"""Every commit is new since the role started and on the branch; every locked path is in such a commit and is a
|
|
68
|
+
file at the branch tip: a deleted file holds no test that a review could prove (issue #136)."""
|
|
63
69
|
repo, branch, commits = context["repo"], context["branch"], _shas(report)
|
|
64
70
|
new = _git(repo, "rev-list", f"{context['start']}..{branch}")
|
|
65
71
|
errors = [f"commit {sha[:7]} is not a new commit on {branch}"
|
|
@@ -67,6 +73,9 @@ def _commit_errors(report: dict, context: dict) -> list[str]:
|
|
|
67
73
|
if locked := report.get("locked"):
|
|
68
74
|
changed = _git(repo, "log", "--name-only", "-z", "--format=", f"{context['start']}..{branch}", end="\0")
|
|
69
75
|
errors += [f"locked path {path} is not in the role's commits" for path in locked if path not in changed]
|
|
76
|
+
present = _present(repo, branch, locked)
|
|
77
|
+
errors += [f"locked path {path} is not a file at the tip of {branch}: list in `locked` only files you keep"
|
|
78
|
+
for path in locked if path in changed and path not in present]
|
|
70
79
|
return errors
|
|
71
80
|
|
|
72
81
|
|
|
@@ -139,12 +148,14 @@ def _proof_errors(report: dict, context: dict) -> list[str]:
|
|
|
139
148
|
|
|
140
149
|
def _locked_errors(report: dict, context: dict) -> list[str]:
|
|
141
150
|
"""In a full review, each locked test file has a mutation proof (`mutations[].test` is `<file>::<test>`).
|
|
142
|
-
`locked` names no fixture of the ticket: a fixture holds no test that a proof could name (#118).
|
|
151
|
+
`locked` names no fixture of the ticket: a fixture holds no test that a proof could name (#118). A locked file
|
|
152
|
+
that is not at the reviewed tip holds no test either (issue #136)."""
|
|
143
153
|
if not context.get("full") or "findings" not in report:
|
|
144
154
|
return []
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
155
|
+
locked = context.get("locked", [])
|
|
156
|
+
tests, present = [proof["test"] for proof in report.get("mutations", [])], _present(context["repo"], context["start"], locked)
|
|
157
|
+
return [f"mutations: no mutation proof for the locked test file {path}" for path in locked
|
|
158
|
+
if path in present and not any(test.startswith(path) for test in tests)]
|
|
148
159
|
|
|
149
160
|
|
|
150
161
|
def _fixture_errors(report: dict) -> list[str]:
|
|
@@ -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, fixtures, green_gates, slot, note, held}}}"""
|
|
5
|
+
"tickets": {"NN": {phase, round, tip, test_writer_sha, locked, fixtures, green_gates, slot, note, held, rejected}}}"""
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import fcntl
|
|
@@ -22,7 +22,7 @@ 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": {}, "rejected": {},
|
|
26
26
|
"fixtures": []}
|
|
27
27
|
|
|
28
28
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Before the ruling of the operator, the driver rejected two reports of this role in this review: {rejection}. This time, give what the driver asked for.
|
|
@@ -569,3 +569,60 @@ def test_a_fixer_that_stops_asks_the_operator_and_retry_runs_its_round_again(tmp
|
|
|
569
569
|
assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
|
|
570
570
|
assert rig.state()["tickets"]["01"]["round"] == 1 and len(rig.calls("01", "fixer")) == 2
|
|
571
571
|
assert rig.led("Ruling: 01 fix round runs again (retry): the fixer reported NEEDS_CONTEXT")
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
# ---------------------------------------------------------------- a review report rejected twice; a question of a merged ticket
|
|
575
|
+
|
|
576
|
+
REJECTED = "01-review-rejected-1"
|
|
577
|
+
NO_PROOF = "mutations: no mutation proof for the locked test file tests/test_01b.py"
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
def test_a_review_report_rejected_twice_asks_the_operator_and_retry_resumes_it(tmp_path):
|
|
581
|
+
"""Issue #136: a reviewer that gave no mutation proof for a second locked file, two times, was a dead end."""
|
|
582
|
+
# Both attempts give a proof for tests/test_01.py only; the third reviewer is the unscripted one, with every proof.
|
|
583
|
+
steps = plan(**{"01/test-writer": [two_locked()], "01/reviewer": [review("01"), review("01")]})
|
|
584
|
+
rig = Inside(tmp_path, ONE).run(steps)
|
|
585
|
+
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
586
|
+
(question,) = rig.state()["run"]["questions"]
|
|
587
|
+
assert (question["id"], question["recommended"]) == (REJECTED, "retry")
|
|
588
|
+
assert [o["id"] for o in question["options"]] == ["retry", "redesign"]
|
|
589
|
+
assert question["evidence"][0] == ".agent/implement/01/reviewer-0.json"
|
|
590
|
+
assert question["subject"] == f"the reviewer: {NO_PROOF}"
|
|
591
|
+
rig.run(steps, "--answer", f"{REJECTED}=retry")
|
|
592
|
+
assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
|
|
593
|
+
assert len(rig.calls("01", "reviewer")) == 3
|
|
594
|
+
assert rig.led(f"Ruling: 01 review runs again (retry): the reviewer: {NO_PROOF}")
|
|
595
|
+
assert NO_PROOF in rig.calls("01", "reviewer")[2]["prompt"]
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
def test_a_test_writer_report_that_locks_a_file_it_deleted_is_rejected(tmp_path):
|
|
599
|
+
"""Issue #136: the correction of ticket 21 deleted a locked file and still listed it in `locked`; the driver
|
|
600
|
+
accepted it, and no reviewer could prove that file."""
|
|
601
|
+
deleted = two_locked()
|
|
602
|
+
deleted["git_after"] = [["add", "-A"], ["commit", "-q", "-m", "test: 01 both"], ["rm", "-q", "tests/test_01b.py"]]
|
|
603
|
+
rig = Inside(tmp_path, ONE).run(plan(**{"01/test-writer": [deleted, two_locked()]}))
|
|
604
|
+
assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
|
|
605
|
+
assert rig.led("Ticket 01: test-writer ran on", "locked path tests/test_01b.py is not a file at the tip of")
|
|
606
|
+
assert len(rig.calls("01", "test-writer")) == 2 and len(rig.calls("01", "reviewer")) == 1
|
|
607
|
+
|
|
608
|
+
|
|
609
|
+
def test_a_question_of_a_ticket_that_merged_is_dropped_and_does_not_park_the_run(tmp_path, capsys):
|
|
610
|
+
"""Issue #136: the operator set a stopped ticket to `merge` by hand; its question stayed open, with exit 2."""
|
|
611
|
+
rig = Inside(tmp_path, ONE).run(steps(stops()))
|
|
612
|
+
assert rig.code == 2, rig.ledger()
|
|
613
|
+
capsys.readouterr()
|
|
614
|
+
path = rig.repo / ".agent/implement/state.json"
|
|
615
|
+
state = json.loads(path.read_text())
|
|
616
|
+
state["tickets"]["01"]["phase"] = "merge"
|
|
617
|
+
path.write_text(json.dumps(state))
|
|
618
|
+
rig.run(steps(stops()))
|
|
619
|
+
assert rig.code == 0 and rig.state()["tickets"]["01"]["phase"] == "merged", rig.ledger()
|
|
620
|
+
assert decisions(rig)["questions"] == [] and IMPLEMENTER_STOPPED not in capsys.readouterr().out
|
|
621
|
+
assert rig.led(f"Ticket 01: the question {IMPLEMENTER_STOPPED} is dropped: the ticket merged.")
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
def test_dropping_the_questions_of_merged_tickets_keeps_the_answered_ones_and_those_of_other_tickets():
|
|
625
|
+
state = {"tickets": {"01": {"phase": "merged"}, "02": {"phase": "blocked"}},
|
|
626
|
+
"run": {"questions": [asked(), {**asked(stop=2), "id": "01-x", "answer": "accept"}, asked(ticket="02")]}}
|
|
627
|
+
assert [q["id"] for q in driver_decisions.drop_merged(state)] == ["01-locked-test-1"]
|
|
628
|
+
assert [q["id"] for q in state["run"]["questions"]] == ["01-x", "02-locked-test-1"]
|
|
@@ -16,6 +16,7 @@ import driver_report
|
|
|
16
16
|
import driver_run
|
|
17
17
|
import driver_review
|
|
18
18
|
import test_review
|
|
19
|
+
from conftest import GIT
|
|
19
20
|
from test_cli import three
|
|
20
21
|
from test_review import FABLE, ONE, OPUS, RISKY, SOL, STUCK, correct, finding, fix, review
|
|
21
22
|
from test_walk import impl, plan, tw
|
|
@@ -812,7 +813,10 @@ def test_a_fixer_that_does_not_finish_blocks_the_ticket_in_its_round(tmp_path):
|
|
|
812
813
|
|
|
813
814
|
def test_a_first_review_proves_each_locked_file_and_a_second_bad_report_blocks(tmp_path):
|
|
814
815
|
rig = Inside(tmp_path).run(plan(**{"01/reviewer": [review("01", lines=())] * 2}))
|
|
815
|
-
assert
|
|
816
|
+
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
817
|
+
assert rig.led("BLOCKED at the review: the reviewer: mutations: no mutation proof for the locked test file "
|
|
818
|
+
"tests/test_01.py.")
|
|
819
|
+
assert [q["id"] for q in rig.state()["run"]["questions"]] == ["01-review-rejected-1"]
|
|
816
820
|
assert "feat: 01 rows" not in rig.pr_subjects()
|
|
817
821
|
|
|
818
822
|
|
|
@@ -863,7 +867,15 @@ def test_the_locked_file_rule_is_for_the_first_review_only(tmp_path):
|
|
|
863
867
|
report = dict(status="DONE", commits=[], files=[], concerns=[], findings=[], mutations=[])
|
|
864
868
|
path = tmp_path / "reviewer-0.json"
|
|
865
869
|
path.write_text(json.dumps(report))
|
|
866
|
-
|
|
870
|
+
repo = tmp_path / "repo"
|
|
871
|
+
(repo / "tests").mkdir(parents=True)
|
|
872
|
+
for name in ("a", "b"):
|
|
873
|
+
(repo / f"tests/{name}.py").write_text("def test_x():\n pass\n")
|
|
874
|
+
subprocess.run(["git", "init", "-q", "-b", "main", str(repo)], check=True)
|
|
875
|
+
subprocess.run(["git", "-C", str(repo), "add", "-A"], check=True)
|
|
876
|
+
subprocess.run([*GIT, "-C", str(repo), "commit", "-q", "-m", "tests"], check=True)
|
|
877
|
+
context = {"repo": str(repo), "branch": "main", "start": "HEAD", "log": str(path),
|
|
878
|
+
"locked": ["tests/a.py", "tests/b.py"]}
|
|
867
879
|
assert driver_report.validate("reviewer", str(path), context) == []
|
|
868
880
|
assert driver_report.validate("reviewer", str(path), {**context, "full": True}) == [
|
|
869
881
|
"mutations: no mutation proof for the locked test file tests/a.py",
|
|
@@ -174,6 +174,24 @@ def test_locked_path_absent_from_the_commit_is_a_violation(world):
|
|
|
174
174
|
assert any("tests/test_other.py" in e for e in errors), errors
|
|
175
175
|
|
|
176
176
|
|
|
177
|
+
def test_a_locked_path_that_the_commits_delete_is_a_violation(world):
|
|
178
|
+
"""Issue #136: a correction deleted a locked file and still listed it, so no review could prove it."""
|
|
179
|
+
shas, check, tmp_path = world
|
|
180
|
+
root = tmp_path / "slot"
|
|
181
|
+
git(root, "rm", "-q", "tests/test_export.py")
|
|
182
|
+
git(root, "commit", "-q", "-m", "drop the test")
|
|
183
|
+
assert check("test-writer", writer(shas), start=shas["base"]) == [
|
|
184
|
+
"locked path tests/test_export.py is not a file at the tip of ticket/01: list in `locked` only files you keep"]
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def test_a_full_review_needs_no_proof_for_a_locked_file_that_is_not_at_the_tip(world):
|
|
188
|
+
shas, check, _ = world
|
|
189
|
+
locked = ["tests/test_export.py", "tests/test_gone.py"]
|
|
190
|
+
assert check("reviewer", reviewer(), start=shas["impl"], full=True, locked=locked) == []
|
|
191
|
+
assert check("reviewer", reviewer(mutations=[]), start=shas["impl"], full=True, locked=locked) == [
|
|
192
|
+
"mutations: no mutation proof for the locked test file tests/test_export.py"]
|
|
193
|
+
|
|
194
|
+
|
|
177
195
|
def test_red_line_absent_from_the_log_is_a_violation(world):
|
|
178
196
|
shas, check, _ = world
|
|
179
197
|
assert check("test-writer", writer(shas), start=shas["base"]) == []
|
|
@@ -299,7 +299,7 @@ def test_a_red_line_missing_from_the_reviewer_log_reruns_once_then_blocks(tmp_pa
|
|
|
299
299
|
rig.run(plan(**{"01/reviewer": [bad, review("01") if second_matches else bad]}))
|
|
300
300
|
first, second = rig.calls("01", "reviewer")
|
|
301
301
|
assert "red line not found in log" in second["prompt"] and "red line not found" not in first["prompt"]
|
|
302
|
-
assert rig.code == (0 if second_matches else
|
|
302
|
+
assert rig.code == (0 if second_matches else 2), rig.output() # 2: the `review-rejected` question
|
|
303
303
|
assert len(rig.calls("01", "reviewer")) == 2
|
|
304
304
|
if not second_matches:
|
|
305
305
|
assert rig.led("01", "BLOCKED") and "feat: 01 rows" not in rig.pr_subjects()
|
|
@@ -37,7 +37,7 @@ def test_start_keeps_a_recorded_run_and_adds_only_the_new_tickets(tmp_path):
|
|
|
37
37
|
assert again["tickets"]["01"]["phase"] == "merged" and again["tickets"]["01"]["fixtures"] == []
|
|
38
38
|
assert again["tickets"]["02"] == {
|
|
39
39
|
"phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": [], "slot": None,
|
|
40
|
-
"note": "", "held": {}, "fixtures": []}
|
|
40
|
+
"note": "", "held": {}, "rejected": {}, "fixtures": []}
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
def test_verified_trusts_a_tip_only_while_it_is_on_the_ticket_branch(repo, tmp_path):
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-10-
|
|
3
|
+
"generatedAt": "2026-10-21T18:30:23.850Z",
|
|
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.
|
|
50
|
-
"hash": "sha256-
|
|
49
|
+
"version": "0.1.38",
|
|
50
|
+
"hash": "sha256-01334d43e5591f2aee50bb5838f8e769f57623c9ae0362b326b2aa3bdbfedaa1",
|
|
51
51
|
"description": "Implement a specification in code."
|
|
52
52
|
},
|
|
53
53
|
{
|