@jesdi/skills 0.0.53 → 0.0.55
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 +9 -0
- package/skills/implement-spec/README.md +6 -4
- package/skills/implement-spec/driver.py +1 -1
- package/skills/implement-spec/driver_decisions.py +57 -2
- package/skills/implement-spec/driver_fixloop.py +45 -10
- package/skills/implement-spec/driver_review.py +9 -2
- package/skills/implement-spec/driver_run.py +9 -1
- package/skills/implement-spec/prompts/correctness.md +7 -3
- package/skills/implement-spec/tests/test_fixloop.py +141 -11
- package/skills-manifest.json +3 -3
package/package.json
CHANGED
|
@@ -138,6 +138,15 @@ and do not know about the run, except `driver_run.py`, which the three deciding
|
|
|
138
138
|
- No test-writer correction runs after round 4 (`driver_fixloop._act_on`): its findings become `finding` questions
|
|
139
139
|
with the others. A correction there would add red locked tests that no fix round makes green, and `accept` could
|
|
140
140
|
not merge the ticket.
|
|
141
|
+
- A correction that does not close its findings (the next review finds one again, or the driver rejects its
|
|
142
|
+
report) asks a `locked-test-again` question. `correct-again` and `accept` send the ticket back to `review`, and
|
|
143
|
+
`driver_decisions.corrections` reads the answers from `state.json`: the count of `correct-again` stops bounds the
|
|
144
|
+
extra corrections (`AGAIN`), and an `accept` stop closes the ticket's locked-test findings in `_act_on`.
|
|
145
|
+
- A reviewer or a correctness pass that reports BLOCKED or NEEDS_CONTEXT raises `driver_run.Stopped`, which
|
|
146
|
+
carries the report. `driver_fixloop._run_reviewers` turns it into a `review-stopped` question, or, after an
|
|
147
|
+
`accept` ruling on that role (`driver_decisions.accepted`), uses the report as it is.
|
|
148
|
+
- The correctness prompt carries the checks of `review-diff` (`driver_review.checks`): the pass reads files only
|
|
149
|
+
from git at the tip and from `.agent/`, and a project-local install sits in an ignored directory.
|
|
141
150
|
|
|
142
151
|
### Questions
|
|
143
152
|
|
|
@@ -17,7 +17,7 @@ Before any agent starts, the driver checks these. Each failed check prints one l
|
|
|
17
17
|
- `.agent/` is gitignored and the worktree has no uncommitted change.
|
|
18
18
|
- Each ticket file `NN-name.md` has a title, a **Blocked by** line and a **Seam** line, and the graph has no cycle (`driver_tickets.py`). A ticket needs one criterion or more, unless its Seam is `none — refactor`. A ticket needs a **Touches** line when the set has more than one ticket. The [to-tickets skill](../to-tickets/SKILL.md) has the line format.
|
|
19
19
|
- Each model entry is valid, and the CLI of the first entry of each role is on PATH. For the correctness role, the entry is the first of its list on another provider than the first implementer entry: that list must have such an entry, and its CLI must be on PATH. This applies to every run, also when no ticket has a **Risk** line.
|
|
20
|
-
- The `review-diff` skill is installed next to this one: the final review of every run reads it, and
|
|
20
|
+
- The `review-diff` skill is installed next to this one: the final review of every run reads it, and the correctness prompt carries its `correctness.md`, so the pass needs no read of a file that git ignores.
|
|
21
21
|
- With `--push` or `--unattended`, the repository has an `origin` remote.
|
|
22
22
|
- Each model that the run can use answers one short test prompt (the preflight). A model that fails gives one line with its error. `--dry-run` skips the preflight.
|
|
23
23
|
|
|
@@ -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` 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` 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,14 +111,14 @@ 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.
|
|
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.
|
|
115
115
|
- A BLOCKED ticket stops the tickets that it blocks. All other tickets run on.
|
|
116
116
|
|
|
117
117
|
### Findings and fix rounds
|
|
118
118
|
|
|
119
119
|
| Finding | What the driver does |
|
|
120
120
|
|---|---|
|
|
121
|
-
| kind `fixture`, any severity, or kind `test`, `critical` or `important`, on a locked file of the ticket | One test-writer correction, outside the fix rounds. The fixer may not edit a locked file, so a fix round cannot close a `test` finding there. The corrected files are the new locked versions, and the next review is a full review. A finding that the correction reports in `not_addressed` (it needs a production change first) becomes a finding of kind `code`, with the reason as its evidence, and goes to a fix round at once; the ledger says it was not corrected. A finding of this kind that is open after the correction blocks the ticket. No correction runs after round 4. |
|
|
121
|
+
| kind `fixture`, any severity, or kind `test`, `critical` or `important`, on a locked file of the ticket | One test-writer correction, outside the fix rounds. The fixer may not edit a locked file, so a fix round cannot close a `test` finding there. The corrected files are the new locked versions, and the next review is a full review. A finding that the correction reports in `not_addressed` (it needs a production change first) becomes a finding of kind `code`, with the reason as its evidence, and goes to a fix round at once; the ledger says it was not corrected. A finding of this kind that is open in the review after the correction, or a correction that the driver rejects, blocks the ticket with a `locked-test-again` question. No correction runs after round 4. |
|
|
122
122
|
| `critical` or `important` | One fix round. |
|
|
123
123
|
| `minor` | It stays in the ledger and in the findings file. The final reviewer gets the list. |
|
|
124
124
|
|
|
@@ -197,6 +197,8 @@ A question is a bounded choice for the operator. `driver_decisions.py` `KINDS` h
|
|
|
197
197
|
|---|---|---|---|---|
|
|
198
198
|
| `locked-test` | `<NN>-locked-test-<n>` | An implementer or a fixer reports BLOCKED with a concern that starts with `locked test contradicts spec:`. | 2 | `overrule-test`: the test-writer corrects the test from that report, then the implementer runs again, and the fix rounds count from 0: the corrected tests are a new contract. `overrule-implementer` (recommended): the implementer runs again. |
|
|
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
|
+
| `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
|
+
| `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. |
|
|
200
202
|
| `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. |
|
|
201
203
|
|
|
202
204
|
`n` counts the questions of that ticket and kind in the run, so an id is never used twice.
|
|
@@ -87,7 +87,7 @@ def _prompt_values(ticket: Ticket, slot: str, run: Run) -> dict[str, str]:
|
|
|
87
87
|
return {"spec": os.path.relpath(run.args.spec, slot), "seam": ticket.seam, "pr_branch": run.pr,
|
|
88
88
|
"branch": run.names.ticket(ticket.number),
|
|
89
89
|
"ticket": os.path.relpath(Path(run.args.tickets) / ticket.file, slot),
|
|
90
|
-
"correctness":
|
|
90
|
+
"correctness": driver_review.checks(), "gate": run.args.gate,
|
|
91
91
|
"blocked_report": os.path.relpath(_blocked_report(ticket.number, run), slot),
|
|
92
92
|
"writer_report": os.path.relpath(folder / "test-writer-0.json", slot)}
|
|
93
93
|
|
|
@@ -57,6 +57,40 @@ KINDS = {
|
|
|
57
57
|
"redesign": Option(
|
|
58
58
|
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
59
59
|
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
60
|
+
"locked-test-again": Kind(
|
|
61
|
+
True,
|
|
62
|
+
"Ticket {ticket}: a locked-test finding is open after the test-writer correction: {subject}",
|
|
63
|
+
"The test-writer correction did not close this finding on the locked tests: the review after it found it "
|
|
64
|
+
"again, or the driver rejected the correction (the ledger line says which). Ticket {ticket} is BLOCKED and "
|
|
65
|
+
"each ticket that it blocks waits.",
|
|
66
|
+
"correct-again",
|
|
67
|
+
{"correct-again": Option(
|
|
68
|
+
"The test-writer corrects the locked tests once more, from the next review. Then the fix rounds go on.",
|
|
69
|
+
"Ruling: {ticket} locked-test finding goes back to the test-writer for one more correction "
|
|
70
|
+
"(correct-again): {subject}.", {"phase": "review"}),
|
|
71
|
+
"accept": Option(
|
|
72
|
+
"Close the finding as it is: the locked tests stay as they are, and no more correction runs for the "
|
|
73
|
+
"ticket. The ticket goes on to its fix rounds with its other findings.",
|
|
74
|
+
"Ruling: {ticket} locked-test finding closed as it is (accept): {subject}.", {"phase": "review"}),
|
|
75
|
+
"redesign": Option(
|
|
76
|
+
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
77
|
+
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
78
|
+
"review-stopped": Kind(
|
|
79
|
+
True,
|
|
80
|
+
"Ticket {ticket}: an agent of the review stopped: {subject}",
|
|
81
|
+
"The reviewer or the correctness pass of ticket {ticket} reported BLOCKED or NEEDS_CONTEXT, so the review "
|
|
82
|
+
"did not end. Ticket {ticket} is BLOCKED and each ticket that it blocks waits.",
|
|
83
|
+
"retry",
|
|
84
|
+
{"retry": Option(
|
|
85
|
+
"The review runs again, with each of its agents.",
|
|
86
|
+
"Ruling: {ticket} review runs again (retry): {subject}.", {"phase": "review"}),
|
|
87
|
+
"accept": Option(
|
|
88
|
+
"The review runs again, and from now on a BLOCKED or NEEDS_CONTEXT report of this agent does not stop "
|
|
89
|
+
"the ticket: the review goes on with its findings and those of the other reports.",
|
|
90
|
+
"Ruling: {ticket} review goes on past this stop (accept): {subject}.", {"phase": "review"}),
|
|
91
|
+
"redesign": Option(
|
|
92
|
+
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
93
|
+
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
60
94
|
# A final-review question belongs to no ticket: its `ticket` is "".
|
|
61
95
|
"final-finding": Kind(
|
|
62
96
|
True,
|
|
@@ -72,6 +106,24 @@ KINDS = {
|
|
|
72
106
|
}
|
|
73
107
|
|
|
74
108
|
|
|
109
|
+
AGAIN = 2 # the extra corrections a ticket may get: a test-writer and a reviewer that never agree cannot loop
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def corrections(questions: list[dict], ticket: str) -> tuple[int, bool]:
|
|
113
|
+
"""(the extra corrections that the `locked-test-again` stops of `ticket` gave, whether one stop accepted its
|
|
114
|
+
findings). A stop with one `correct-again` answer gives one correction; a stop with only `accept` accepts."""
|
|
115
|
+
stops: dict[int, set] = {}
|
|
116
|
+
for q in questions:
|
|
117
|
+
if (q["ticket"], q["kind"]) == (ticket, "locked-test-again") and q["answer"]:
|
|
118
|
+
stops.setdefault(q["stop"], set()).add(q["answer"])
|
|
119
|
+
return sum("correct-again" in answers for answers in stops.values()), {"accept"} in stops.values()
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def accepted(questions: list[dict], ticket: str, kind: str) -> list[str]:
|
|
123
|
+
"""The subjects of the questions of `kind` on `ticket` that the operator answered `accept`."""
|
|
124
|
+
return [q["subject"] for q in questions if (q["ticket"], q["kind"], q["answer"]) == (ticket, kind, "accept")]
|
|
125
|
+
|
|
126
|
+
|
|
75
127
|
def contradicted(role: str, report: dict) -> str:
|
|
76
128
|
"""The locked tests that a BLOCKED report of an implementer or a fixer says contradict the spec; "" when it is not
|
|
77
129
|
that stop."""
|
|
@@ -85,9 +137,12 @@ def question(kind: str, ticket: str, subject: str, evidence: list[str], asked: l
|
|
|
85
137
|
"""A new open question, id `<NN>-<kind>-<n>` (`<kind>-<n>` with no ticket); n counts in `asked`, the whole run."""
|
|
86
138
|
made, values = KINDS[kind], {"ticket": ticket, "subject": subject}
|
|
87
139
|
number = 1 + sum((q["ticket"], q["kind"]) == (ticket, kind) for q in asked)
|
|
140
|
+
options, recommended = made.options, made.recommended
|
|
141
|
+
if kind == "locked-test-again" and corrections(asked, ticket)[0] >= AGAIN:
|
|
142
|
+
options, recommended = {name: options[name] for name in ("accept", "redesign")}, "accept"
|
|
88
143
|
return {"id": f"{ticket}-{kind}-{number}".lstrip("-"), "title": made.title.format(**values), "why": made.why.format(**values),
|
|
89
|
-
"evidence": evidence, "recommended":
|
|
90
|
-
"options": [{"id": name, "description": option.description} for name, option in
|
|
144
|
+
"evidence": evidence, "recommended": recommended,
|
|
145
|
+
"options": [{"id": name, "description": option.description} for name, option in options.items()],
|
|
91
146
|
"ticket": ticket, "kind": kind, "subject": subject, "stop": stop, "answer": None}
|
|
92
147
|
|
|
93
148
|
|
|
@@ -11,11 +11,12 @@ from concurrent.futures import ThreadPoolExecutor
|
|
|
11
11
|
from dataclasses import dataclass, field
|
|
12
12
|
|
|
13
13
|
import driver_agents
|
|
14
|
+
import driver_decisions
|
|
14
15
|
import driver_gate
|
|
15
16
|
import driver_merge
|
|
16
17
|
import driver_review
|
|
17
18
|
import driver_slots
|
|
18
|
-
from driver_run import OUT, Blocked, Run, during, ledger
|
|
19
|
+
from driver_run import OUT, Blocked, Run, Stopped, during, ledger
|
|
19
20
|
from driver_tickets import Ticket
|
|
20
21
|
|
|
21
22
|
ROUNDS = 4
|
|
@@ -61,9 +62,13 @@ def _log_findings(job: Job, findings: list[dict]) -> list[dict]:
|
|
|
61
62
|
|
|
62
63
|
|
|
63
64
|
def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) -> list[dict]:
|
|
64
|
-
"""Run the (role, model entry) pairs of `cast` at the same time in the one slot. Returns their reports.
|
|
65
|
+
"""Run the (role, model entry) pairs of `cast` at the same time in the one slot. Returns their reports.
|
|
66
|
+
A role that stops (BLOCKED, NEEDS_CONTEXT) asks a `review-stopped` question, unless an `accept` ruling on an
|
|
67
|
+
earlier stop of that role lets the review go on with its report."""
|
|
68
|
+
number = job.ticket.number
|
|
65
69
|
values, running = job.pointers(job.round - 1), [role for role, _ in cast]
|
|
66
|
-
errors
|
|
70
|
+
errors, stops = {}, {}
|
|
71
|
+
accepted = driver_decisions.accepted(job.run.state.read()["run"]["questions"], number, "review-stopped")
|
|
67
72
|
|
|
68
73
|
def call(role: str, entry: str) -> dict:
|
|
69
74
|
# A full review (no fix range) must give a mutation proof for each locked test file; the prompt names them.
|
|
@@ -73,6 +78,13 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
73
78
|
return job.run.agent(role, job.ticket.number, job.slot, values, entry=entry, fix_round=job.round,
|
|
74
79
|
notes=notes, check={"full": True, "locked": locked} if full else {},
|
|
75
80
|
alone=lambda: len(running) == 1)
|
|
81
|
+
except Stopped as stopped:
|
|
82
|
+
if any(subject.startswith(f"the {role} ") for subject in accepted):
|
|
83
|
+
ledger(f"Ticket {number}: {stopped}; by the ruling (accept), the review goes on with the other reports.")
|
|
84
|
+
return stopped.report
|
|
85
|
+
stops[role] = str(stopped)
|
|
86
|
+
errors[role] = f"the {role}: {stopped}"
|
|
87
|
+
return {}
|
|
76
88
|
except Blocked as blocked:
|
|
77
89
|
errors[role] = f"the {role}: {blocked}"
|
|
78
90
|
return {}
|
|
@@ -81,6 +93,10 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
81
93
|
|
|
82
94
|
with ThreadPoolExecutor(len(cast)) as pool:
|
|
83
95
|
reports = list(pool.map(lambda agent: call(*agent), cast))
|
|
96
|
+
if stops:
|
|
97
|
+
first = next(role for role, _ in cast if role in stops)
|
|
98
|
+
job.run.ask(number, "review-stopped", [stops[role] for role, _ in cast if role in stops],
|
|
99
|
+
str(OUT / number / f"{first}-{job.round}.json"))
|
|
84
100
|
if errors:
|
|
85
101
|
raise Blocked("; ".join(errors[role] for role, _ in cast if role in errors))
|
|
86
102
|
return reports
|
|
@@ -108,9 +124,10 @@ def _correct(job: Job, findings: list[dict]) -> list[dict]:
|
|
|
108
124
|
"""One test-writer correction for the findings on the locked tests. It is outside the fix rounds. Returns the
|
|
109
125
|
findings that it did not correct, as findings of kind code for the fixer (issue #111)."""
|
|
110
126
|
run, number = job.run, job.ticket.number
|
|
127
|
+
titles, evidence = [finding["title"] for finding in findings], str(OUT / number / f"findings-{job.round}.json")
|
|
111
128
|
if job.corrected:
|
|
112
|
-
|
|
113
|
-
raise Blocked(f"the review: a locked-test finding is open after the test-writer correction: {titles}")
|
|
129
|
+
run.ask(number, "locked-test-again", titles, evidence)
|
|
130
|
+
raise Blocked(f"the review: a locked-test finding is open after the test-writer correction: {'; '.join(titles)}")
|
|
114
131
|
restored = run.restore_locked_files(number, job.slot)
|
|
115
132
|
job.tip = driver_slots.head(job.slot) # the restore is a commit of the driver
|
|
116
133
|
# The gate was green on the tip before the restore, so a red gate here is a restored file that fails with the
|
|
@@ -126,9 +143,13 @@ def _correct(job: Job, findings: list[dict]) -> list[dict]:
|
|
|
126
143
|
"record": record and os.path.relpath(record, job.slot)}
|
|
127
144
|
notes = ["correction"] + ["restored"] * bool(restored) + ["restored-red"] * bool(record)
|
|
128
145
|
with during("the test-writer correction"):
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
146
|
+
try:
|
|
147
|
+
report = run.agent("test-writer", number, job.slot, values, notes=notes, fix_round=job.round + 1,
|
|
148
|
+
check={"correction": True, "restored": restored, "restore_red": bool(record),
|
|
149
|
+
"findings": titles})
|
|
150
|
+
except Blocked:
|
|
151
|
+
run.ask(number, "locked-test-again", titles, evidence) # a rejected correction is one that did not close
|
|
152
|
+
raise
|
|
132
153
|
job.tip, job.previous, job.corrected = driver_slots.head(job.slot), "", True
|
|
133
154
|
entry = run.state.read()["tickets"][number]
|
|
134
155
|
run.state.ticket(number, tip=job.tip, **driver_review.written(job.slot, entry, report["locked"], job.tip))
|
|
@@ -181,10 +202,24 @@ def _fix(job: Job) -> None:
|
|
|
181
202
|
job.corrected, job.proofs, job.again = False, set(followed), due
|
|
182
203
|
|
|
183
204
|
|
|
205
|
+
def _unaccepted(job: Job, state: dict, to_correct: list[dict]) -> list[dict]:
|
|
206
|
+
"""The findings for a correction once an `accept` ruling closed the ticket's locked-test findings: only the
|
|
207
|
+
driver's, since a changed locked file is still restored. With no such ruling, `to_correct`."""
|
|
208
|
+
number = job.ticket.number
|
|
209
|
+
if not driver_decisions.corrections(state["run"]["questions"], number)[1]:
|
|
210
|
+
return to_correct
|
|
211
|
+
for finding in to_correct:
|
|
212
|
+
if finding["source"] != "driver":
|
|
213
|
+
ledger(f"Ticket {number}: {finding['kind']} finding in {finding['file']} closed as it is by the ruling "
|
|
214
|
+
f"(accept), with no correction: {finding['title']}.")
|
|
215
|
+
return [finding for finding in to_correct if finding["source"] == "driver"]
|
|
216
|
+
|
|
217
|
+
|
|
184
218
|
def _act_on(job: Job, found: list[dict]) -> bool:
|
|
185
219
|
"""Do what the findings of a review ask for: a correction, a fix round, or a stop. True: none is open."""
|
|
186
|
-
|
|
187
|
-
to_correct, to_fix = driver_review.route(found, locked)
|
|
220
|
+
state = job.run.state.read()
|
|
221
|
+
to_correct, to_fix = driver_review.route(found, state["tickets"][job.ticket.number]["locked"])
|
|
222
|
+
to_correct = _unaccepted(job, state, to_correct)
|
|
188
223
|
if job.round == ROUNDS:
|
|
189
224
|
# No correction after round 4: no fix round could make its new locked tests green, so `accept` could not merge.
|
|
190
225
|
to_correct, to_fix = [], [finding for finding in found if finding in to_correct + to_fix]
|
|
@@ -13,7 +13,7 @@ import driver_agents
|
|
|
13
13
|
from driver_slots import git, head, names, on_branch
|
|
14
14
|
from driver_tickets import Ticket
|
|
15
15
|
|
|
16
|
-
# The correctness pass
|
|
16
|
+
# The checks of the correctness pass: this file of the review-diff skill, which is installed next to this one.
|
|
17
17
|
CORRECTNESS = driver_agents.SKILL.parent / "review-diff" / "correctness.md"
|
|
18
18
|
OPEN = ("critical", "important") # the severities that start a fix round
|
|
19
19
|
_HUNK = re.compile(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@", re.M)
|
|
@@ -24,10 +24,17 @@ def precondition_errors(tickets: list[Ticket]) -> list[str]:
|
|
|
24
24
|
risky = [ticket.number for ticket in tickets if ticket.risk]
|
|
25
25
|
if CORRECTNESS.exists() or not risky:
|
|
26
26
|
return []
|
|
27
|
-
return [f"{CORRECTNESS} is missing: ticket {', '.join(risky)} has a Risk line and its correctness
|
|
27
|
+
return [f"{CORRECTNESS} is missing: ticket {', '.join(risky)} has a Risk line and its correctness prompt carries "
|
|
28
28
|
"that file; install the review-diff skill next to implement-spec"]
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
def checks() -> str:
|
|
32
|
+
"""CORRECTNESS, inlined into the correctness prompt: the pass reads files only from git at the tip and from
|
|
33
|
+
`.agent/`, and a project-local install of review-diff sits in an ignored directory (issue #120). "" when it is
|
|
34
|
+
missing: only a ticket with a Risk line renders it, and `precondition_errors` checks the file for those."""
|
|
35
|
+
return CORRECTNESS.read_text() if CORRECTNESS.exists() else ""
|
|
36
|
+
|
|
37
|
+
|
|
31
38
|
def locked_changes(slot: str, sha: str | None, locked: list[str]) -> list[dict]:
|
|
32
39
|
"""One critical finding per locked file that differs from the test-writer's commit `sha`, or for a diff that
|
|
33
40
|
git cannot make."""
|
|
@@ -37,6 +37,14 @@ class Blocked(Exception):
|
|
|
37
37
|
"""A ticket, or the end of run, cannot go on. The message says why."""
|
|
38
38
|
|
|
39
39
|
|
|
40
|
+
class Stopped(Blocked):
|
|
41
|
+
"""An agent's accepted report says BLOCKED or NEEDS_CONTEXT. `report` is that report."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, why: str, report: dict):
|
|
44
|
+
super().__init__(why)
|
|
45
|
+
self.report = report
|
|
46
|
+
|
|
47
|
+
|
|
40
48
|
class Halted(Exception):
|
|
41
49
|
"""The CLI of an agent failed with no report, two times: a model the account cannot use, a CLI that is not
|
|
42
50
|
signed in. The run starts no other agent and ends with exit 4; the ticket keeps its phase for the next run."""
|
|
@@ -117,7 +125,7 @@ class Run:
|
|
|
117
125
|
self.ask(number, "locked-test", [subject], str(evidence), tip=driver_slots.head(slot))
|
|
118
126
|
if report.get("status") in ("BLOCKED", "NEEDS_CONTEXT"):
|
|
119
127
|
concerns = "; ".join(report["concerns"]) or "no concern given"
|
|
120
|
-
raise
|
|
128
|
+
raise Stopped(f"the {role} reported {report['status']}: {concerns}", report)
|
|
121
129
|
return report
|
|
122
130
|
|
|
123
131
|
def read_only(self, number: str, slot: str, branch: str, tip: str, review: Callable[[], T]) -> T:
|
|
@@ -5,10 +5,14 @@ Ticket: {ticket}
|
|
|
5
5
|
Seam: {seam}
|
|
6
6
|
Range: {pr_branch}...{branch}, with the ticket tip at {start_sha}
|
|
7
7
|
Locked files: {locked}
|
|
8
|
-
Checks: {correctness}
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
The output section of the checks
|
|
9
|
+
Apply each check of the review-diff checks below to the diff of the range, with the Risk line of the ticket first: races, idempotency, time, authorization, persistence keys and identities, migrations, error paths.
|
|
10
|
+
The output section of the checks does not apply here: your findings go into the report.
|
|
11
|
+
|
|
12
|
+
<checks>
|
|
13
|
+
{correctness}
|
|
14
|
+
</checks>
|
|
15
|
+
|
|
12
16
|
Read file content from git at {start_sha} (`git diff`, `git show {start_sha}:<path>`), never from the working tree, and run no tests: another agent makes temporary edits in this worktree while you work.
|
|
13
17
|
The one exception is the input of the driver, which git can lack because `.agent/` is ignored: read the spec, the ticket and the findings file from the working tree. The other agent does not edit them.
|
|
14
18
|
Report only a defect that you can show with a concrete sequence of events. `mutations` is optional for this pass.
|
|
@@ -83,7 +83,7 @@ def test_a_risky_ticket_gets_both_agents_and_one_merged_findings_file(tmp_path):
|
|
|
83
83
|
again = rig.prompt(f"{role}-1", "02")
|
|
84
84
|
assert "This is the re-review after fix round 1." in again and "findings-0.json" in again
|
|
85
85
|
assert again.rstrip().endswith("one ref store.") and "re-review" not in rig.prompt(f"{role}-0", "02")
|
|
86
|
-
assert
|
|
86
|
+
assert driver_review.CORRECTNESS.read_text() in rig.prompt("correctness-0", "02")
|
|
87
87
|
assert "correctness.md" not in rig.prompt("reviewer-0", "02") and not rig.led("folded")
|
|
88
88
|
assert json.loads((rig.folder("02") / "findings-1.json").read_text()) == []
|
|
89
89
|
|
|
@@ -141,12 +141,67 @@ def test_a_locked_file_check_that_git_cannot_make_is_a_finding(tmp_path):
|
|
|
141
141
|
assert found["severity"] == "critical" and found["title"].startswith("locked file check failed: ")
|
|
142
142
|
|
|
143
143
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
144
|
+
STALE = finding("STALE", kind="fixture", file="tests/test_01.py")
|
|
145
|
+
AGAIN_1 = "01-locked-test-again-1"
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def corrections(n):
|
|
149
|
+
"""`n` test-writer corrections of tests/test_01.py, each with its own content."""
|
|
150
|
+
return [{**tw("01"), "files": {"tests/test_01.py": f"# corrected {i}\n"}, "commit": f"test: 01 correction {i}"}
|
|
151
|
+
for i in range(1, n + 1)]
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def asked(rig):
|
|
155
|
+
"""The open questions of the run: id -> option ids."""
|
|
156
|
+
return {q["id"]: [o["id"] for o in q["options"]] for q in rig.state()["run"]["questions"] if q["answer"] is None}
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def test_a_locked_test_finding_that_comes_back_after_its_correction_asks_the_operator(tmp_path):
|
|
160
|
+
# Issue #107: the ticket was BLOCKED with no question, so only an edit of state.json could resume it.
|
|
161
|
+
steps = plan(**{"01/test-writer": [tw("01"), *corrections(2)],
|
|
162
|
+
"01/reviewer": [review("01", [STALE])] * 3 + [review("01")]})
|
|
163
|
+
rig = Inside(tmp_path).run(steps)
|
|
164
|
+
assert rig.code == 2 and rig.state()["tickets"]["01"]["phase"] == "blocked", rig.ledger()
|
|
165
|
+
assert rig.led("BLOCKED at the review: a locked-test finding is open after the test-writer correction: STALE.")
|
|
166
|
+
assert asked(rig) == {AGAIN_1: ["correct-again", "accept", "redesign"]}
|
|
167
|
+
(question,) = rig.state()["run"]["questions"]
|
|
168
|
+
assert question["recommended"] == "correct-again" and question["evidence"][0] == ".agent/implement/01/findings-0.json"
|
|
169
|
+
rig.run(steps, "--answer", f"{AGAIN_1}=correct-again")
|
|
170
|
+
assert rig.code == 0, rig.ledger()
|
|
171
|
+
order = [call["role"] for call in rig.calls("01")]
|
|
172
|
+
assert order == ["test-writer", "implementer", "reviewer", "test-writer", "reviewer", "reviewer", "test-writer",
|
|
173
|
+
"reviewer"]
|
|
174
|
+
assert rig.led("Ruling: 01 locked-test finding goes back to the test-writer for one more correction")
|
|
175
|
+
assert rig.state()["tickets"]["01"]["phase"] == "merged"
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_an_accepted_locked_test_finding_lets_the_ticket_go_on_to_its_fix_rounds(tmp_path):
|
|
179
|
+
steps = plan(**{"01/test-writer": [tw("01"), *corrections(1)], "01/fixer": [fix("01", 1)],
|
|
180
|
+
"01/reviewer": [review("01", [STALE]), review("01", [STALE]), review("01", [STALE, STUCK]),
|
|
181
|
+
review("01", [STALE])]})
|
|
182
|
+
rig = Inside(tmp_path).run(steps)
|
|
183
|
+
assert rig.code == 2 and list(asked(rig)) == [AGAIN_1], rig.ledger()
|
|
184
|
+
rig.run(steps, "--answer", f"{AGAIN_1}=accept")
|
|
185
|
+
assert rig.code == 0, rig.ledger()
|
|
186
|
+
order = [call["role"] for call in rig.calls("01")]
|
|
187
|
+
assert order == ["test-writer", "implementer", "reviewer", "test-writer", "reviewer", "reviewer", "fixer",
|
|
188
|
+
"reviewer"]
|
|
189
|
+
assert rig.state()["tickets"]["01"]["round"] == 1
|
|
190
|
+
assert rig.led("STALE", "closed as it is by the ruling")
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def test_the_extra_corrections_are_bounded_and_redesign_keeps_the_ticket_blocked(tmp_path):
|
|
194
|
+
steps = plan(**{"01/test-writer": [tw("01"), *corrections(3)], "01/reviewer": [review("01", [STALE])] * 6})
|
|
195
|
+
rig = Inside(tmp_path).run(steps)
|
|
196
|
+
for n in (1, 2):
|
|
197
|
+
assert asked(rig) == {f"01-locked-test-again-{n}": ["correct-again", "accept", "redesign"]}, rig.ledger()
|
|
198
|
+
rig.run(steps, "--answer", f"01-locked-test-again-{n}=correct-again")
|
|
199
|
+
# Two extra corrections did not close it: a third one is not offered.
|
|
200
|
+
assert asked(rig) == {"01-locked-test-again-3": ["accept", "redesign"]}, rig.ledger()
|
|
201
|
+
assert len(rig.calls("01", "test-writer")) == 4
|
|
202
|
+
rig.run(steps, "--answer", "01-locked-test-again-3=redesign")
|
|
203
|
+
assert rig.code == 1 and rig.state()["tickets"]["01"]["phase"] == "blocked" and asked(rig) == {}
|
|
204
|
+
assert rig.led("Ruling: 01 stays BLOCKED, the design changes first (redesign): STALE.")
|
|
150
205
|
|
|
151
206
|
|
|
152
207
|
def test_an_open_finding_survives_the_fixture_correction_of_its_review_and_starts_the_fix_round(tmp_path):
|
|
@@ -282,10 +337,15 @@ def test_the_fix_rounds_count_from_0_after_an_overruled_test(tmp_path):
|
|
|
282
337
|
assert rig.state()["tickets"]["01"]["round"] == 1 and not rig.led("after round 4")
|
|
283
338
|
|
|
284
339
|
|
|
285
|
-
def
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
340
|
+
def test_a_fixture_correction_that_is_rejected_asks_the_operator(tmp_path):
|
|
341
|
+
# Issue #107: a correction the driver rejects (for one, a change to a file it does not list) was a dead end too.
|
|
342
|
+
steps = plan(**{"01/test-writer": [tw("01"), {}, {}, *corrections(1)],
|
|
343
|
+
"01/reviewer": [review("01", [STALE])] * 2 + [review("01")]})
|
|
344
|
+
rig = Inside(tmp_path).run(steps)
|
|
345
|
+
assert rig.code == 2 and list(asked(rig)) == [AGAIN_1], rig.ledger()
|
|
346
|
+
assert rig.led("BLOCKED at the test-writer correction: report .agent/implement/01/test-writer-1.json is not")
|
|
347
|
+
rig.run(steps, "--answer", f"{AGAIN_1}=correct-again")
|
|
348
|
+
assert rig.code == 0 and len(rig.calls("01", "test-writer")) == 4, rig.ledger()
|
|
289
349
|
|
|
290
350
|
|
|
291
351
|
# ---------------------------------------------------------------- the locked files of the merged tickets
|
|
@@ -871,6 +931,76 @@ def test_the_correctness_pass_reads_the_untracked_inputs_of_the_driver_from_the_
|
|
|
871
931
|
assert "read the spec, the ticket and the findings file from the working tree" in again
|
|
872
932
|
|
|
873
933
|
|
|
934
|
+
def test_the_correctness_prompt_carries_the_checks_of_a_review_diff_in_a_gitignored_directory(tmp_path, monkeypatch):
|
|
935
|
+
"""Issue #120: a project-local install is ignored, and the pass may read neither the tree nor git for it."""
|
|
936
|
+
rig = Inside(tmp_path, RISKY, {"correctness": [SOL, OPUS], "implementer": [OPUS]}, ignore=".my-skills/")
|
|
937
|
+
checks = rig.repo / ".my-skills/review-diff/correctness.md"
|
|
938
|
+
checks.parent.mkdir(parents=True)
|
|
939
|
+
checks.write_text("# Correctness reviewer\n\n| Check | Flag |\n|---|---|\n| Ledger | A row booked twice. |\n")
|
|
940
|
+
monkeypatch.setattr(driver_review, "CORRECTNESS", checks)
|
|
941
|
+
rig.run(plan())
|
|
942
|
+
assert rig.code == 0, rig.ledger()
|
|
943
|
+
ignored = subprocess.run(["git", "-C", str(rig.repo), "check-ignore", "-q", str(checks)])
|
|
944
|
+
assert ignored.returncode == 0
|
|
945
|
+
assert "| Ledger | A row booked twice. |" in rig.prompt("correctness-0", "02")
|
|
946
|
+
|
|
947
|
+
|
|
948
|
+
STOPPED = "02-review-stopped-1"
|
|
949
|
+
|
|
950
|
+
|
|
951
|
+
def stuck(role, status="NEEDS_CONTEXT"):
|
|
952
|
+
"""A review step whose report stops: BLOCKED or NEEDS_CONTEXT, with no finding."""
|
|
953
|
+
step = review("02") if role == "reviewer" else correct()
|
|
954
|
+
step["report"] = {**step["report"], "status": status, "concerns": ["the checks file is absent"]}
|
|
955
|
+
return step
|
|
956
|
+
|
|
957
|
+
|
|
958
|
+
def risky(tmp_path):
|
|
959
|
+
return Inside(tmp_path, RISKY, {"correctness": [SOL, OPUS], "implementer": [OPUS]})
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
@pytest.mark.parametrize("role", ["reviewer", "correctness"])
|
|
963
|
+
def test_a_review_that_reports_needs_context_asks_the_operator_and_retry_resumes_it(tmp_path, role):
|
|
964
|
+
"""Issue #120: a stopped reviewer or correctness pass was a dead end with no question."""
|
|
965
|
+
steps = plan(**{f"02/{role}": [stuck(role)]})
|
|
966
|
+
rig = risky(tmp_path)
|
|
967
|
+
rig.run(steps)
|
|
968
|
+
assert rig.code == 2 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
969
|
+
assert rig.led(f"BLOCKED at the review: the {role}: the {role} reported NEEDS_CONTEXT: the checks file is absent.")
|
|
970
|
+
(question,) = rig.state()["run"]["questions"]
|
|
971
|
+
assert (question["id"], question["recommended"]) == (STOPPED, "retry")
|
|
972
|
+
assert [o["id"] for o in question["options"]] == ["retry", "accept", "redesign"]
|
|
973
|
+
assert question["evidence"][0] == f".agent/implement/02/{role}-0.json"
|
|
974
|
+
rig.run(steps, "--answer", f"{STOPPED}=retry")
|
|
975
|
+
assert rig.code == 0 and rig.state()["tickets"]["02"]["phase"] == "merged", rig.ledger()
|
|
976
|
+
assert len(rig.calls("02", role)) == 2
|
|
977
|
+
assert rig.led(f"Ruling: 02 review runs again (retry): the {role} reported NEEDS_CONTEXT")
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
def test_an_accepted_review_stop_closes_the_review_with_the_other_reports(tmp_path):
|
|
981
|
+
steps = plan(**{"02/correctness": [stuck("correctness", "BLOCKED")] * 2,
|
|
982
|
+
"02/reviewer": [review("02"), review("02", [finding("R-IMPORTANT")]), review("02")],
|
|
983
|
+
"02/fixer": [fix("02", 1)]})
|
|
984
|
+
rig = risky(tmp_path)
|
|
985
|
+
rig.run(steps)
|
|
986
|
+
assert rig.code == 2, rig.ledger()
|
|
987
|
+
rig.run(steps, "--answer", f"{STOPPED}=accept")
|
|
988
|
+
assert rig.code == 0 and rig.state()["tickets"]["02"]["phase"] == "merged", rig.ledger()
|
|
989
|
+
# The reviewer's finding still gets its fix round; the stopped pass does not stop the ticket again.
|
|
990
|
+
assert rig.state()["tickets"]["02"]["round"] == 1 and len(rig.calls("02", "correctness")) == 3
|
|
991
|
+
assert rig.led("the correctness reported BLOCKED: the checks file is absent", "goes on with the other reports")
|
|
992
|
+
|
|
993
|
+
|
|
994
|
+
def test_a_review_stop_answered_redesign_keeps_the_ticket_blocked(tmp_path):
|
|
995
|
+
steps = plan(**{"02/correctness": [stuck("correctness")]})
|
|
996
|
+
rig = risky(tmp_path)
|
|
997
|
+
rig.run(steps)
|
|
998
|
+
assert rig.code == 2, rig.ledger()
|
|
999
|
+
rig.run(steps, "--answer", f"{STOPPED}=redesign")
|
|
1000
|
+
assert rig.code == 1 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
1001
|
+
assert len(rig.calls("02", "correctness")) == 1
|
|
1002
|
+
|
|
1003
|
+
|
|
874
1004
|
@pytest.mark.parametrize("role", ["reviewer", "correctness"])
|
|
875
1005
|
def test_the_schema_of_a_review_says_that_commits_holds_only_the_agents_own_commits(role):
|
|
876
1006
|
"""Issue 66: a reviewer that lists a commit of the range costs a rerun (`is not a new commit`)."""
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-10-
|
|
3
|
+
"generatedAt": "2026-10-20T09:33:22.965Z",
|
|
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.30",
|
|
50
|
+
"hash": "sha256-90d82ac9c1a617819e45d91c0a5cd79ed53f982ea60bd35ef7e668d6bfc46e1b",
|
|
51
51
|
"description": "Implement a specification in code."
|
|
52
52
|
},
|
|
53
53
|
{
|