@jesdi/skills 0.0.56 → 0.0.58
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/README.md +5 -5
- package/skills/implement-spec/driver.py +2 -1
- package/skills/implement-spec/driver_fixloop.py +19 -8
- package/skills/implement-spec/driver_report.py +35 -4
- package/skills/implement-spec/driver_review.py +6 -5
- package/skills/implement-spec/driver_state.py +6 -2
- package/skills/implement-spec/prompts/corrected.md +1 -1
- package/skills/implement-spec/prompts/fixer.md +3 -4
- package/skills/implement-spec/prompts/full-review.md +1 -1
- package/skills/implement-spec/prompts/implementer.md +1 -1
- package/skills/implement-spec/prompts/reviewer.md +1 -1
- package/skills/implement-spec/prompts/test-writer.md +1 -0
- package/skills/implement-spec/prompts/unchanged.md +1 -0
- package/skills/implement-spec/tests/test_decisions.py +7 -6
- package/skills/implement-spec/tests/test_fixloop.py +39 -0
- package/skills/implement-spec/tests/test_report.py +20 -0
- package/skills/implement-spec/tests/test_state.py +4 -2
- package/skills-manifest.json +3 -3
package/package.json
CHANGED
|
@@ -122,7 +122,7 @@ Rules for each agent:
|
|
|
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
|
|
|
125
|
-
A fix round has three steps: the **fixer** (`prompts/fixer.md`) makes the gate green on its final commit, as the implementer does; the driver runs the gate on the new tip; a re-review reads the range of the fix. A mutation proof is repeated only when the fix changed its production line.
|
|
125
|
+
A fix round has three steps: the **fixer** (`prompts/fixer.md`) makes the gate green on its final commit, as the implementer does; the driver runs the gate on the new tip; a re-review reads the range of the fix. A mutation proof is repeated only when the fix changed its production line. A fixer whose findings need no change, for example because a test-writer correction before it already resolved them, makes no commit and gives in `concerns` a reason for each finding; the round still counts, and the re-review of the same tip checks each reason.
|
|
126
126
|
|
|
127
127
|
A red gate on the commit of the implementer or of a fixer is a critical finding with source `gate`. Its file is the gate record, and the record holds the output. No review runs on that tip, and the next round starts: a red gate on the commit of the implementer starts round 1. The review after that round covers each fix since the last review and repeats each proof that one of them made due. Two red gates block the ticket: one after round 4, and one on the commit of a test-writer correction, because the correction is outside the fix rounds and a fixer may not edit the locked files.
|
|
128
128
|
|
|
@@ -177,11 +177,11 @@ 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. |
|
|
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
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. |
|
|
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
|
-
| fixer | `prompts/fixer.md` | `green`, `ticket` | With DONE:
|
|
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. |
|
|
186
186
|
| pr-writer | `prompts/pr-writer.md` | `body`; `commits` is empty | None. |
|
|
187
187
|
| fixer of the final review | `prompts/final-fixer.md` | `green`; `commits` is a list of (`sha`, `ticket`) | Each new commit on the branch is in `commits`, with a ticket of the run. |
|
|
@@ -210,7 +210,7 @@ Answer with `--answer <question id>=<option id>` on the next run, or through the
|
|
|
210
210
|
| Check | Where it lives |
|
|
211
211
|
|---|---|
|
|
212
212
|
| 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. |
|
|
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: 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
214
|
| 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
215
|
| 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
216
|
| 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"],
|
|
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"], []
|
|
@@ -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"]
|
|
@@ -67,13 +72,16 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
67
72
|
earlier stop of that role lets the review go on with its report."""
|
|
68
73
|
number = job.ticket.number
|
|
69
74
|
values, running = job.pointers(job.round - 1), [role for role, _ in cast]
|
|
75
|
+
values["fixer_report"] = os.path.relpath(OUT / number / f"fixer-{job.round}.json", job.slot)
|
|
70
76
|
errors, stops = {}, {}
|
|
71
77
|
accepted = driver_decisions.accepted(job.run.state.read()["run"]["questions"], number, "review-stopped")
|
|
72
78
|
|
|
73
79
|
def call(role: str, entry: str) -> dict:
|
|
74
|
-
# A full review (no fix range) must give a mutation proof for each locked test file
|
|
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.
|
|
75
82
|
full = not job.previous and role == "reviewer"
|
|
76
83
|
notes = ["rereview"] if job.previous else ["full-review"] if full else []
|
|
84
|
+
notes += ["unchanged"] * (job.previous == job.tip) # a fixer with no commit: its reasons need a check
|
|
77
85
|
try:
|
|
78
86
|
return job.run.agent(role, job.ticket.number, job.slot, values, entry=entry, fix_round=job.round,
|
|
79
87
|
notes=notes, check={"full": True, "locked": locked} if full else {},
|
|
@@ -112,7 +120,7 @@ def _review(job: Job) -> list[dict]:
|
|
|
112
120
|
if job.ticket.risk:
|
|
113
121
|
cast.append(("correctness", driver_agents.correctness_entry(run.models)))
|
|
114
122
|
reports = run.read_only(number, job.slot, job.values["branch"], job.tip,
|
|
115
|
-
lambda: _run_reviewers(job, cast, state
|
|
123
|
+
lambda: _run_reviewers(job, cast, tested(state)))
|
|
116
124
|
for (role, _), report in zip(cast, reports):
|
|
117
125
|
found += _log_findings(job, [{**finding, "source": role} for finding in report["findings"]])
|
|
118
126
|
job.proofs |= {(proof["file"], proof["line"]) for proof in report.get("mutations", [])}
|
|
@@ -152,7 +160,8 @@ def _correct(job: Job, findings: list[dict]) -> list[dict]:
|
|
|
152
160
|
raise
|
|
153
161
|
job.tip, job.previous, job.corrected = driver_slots.head(job.slot), "", True
|
|
154
162
|
entry = run.state.read()["tickets"][number]
|
|
155
|
-
run.state.ticket(number, tip=job.tip, **driver_review.written(job.slot, entry, report["locked"],
|
|
163
|
+
run.state.ticket(number, tip=job.tip, **driver_review.written(job.slot, entry, report["locked"],
|
|
164
|
+
report.get("fixtures", []), job.tip))
|
|
156
165
|
return _uncorrected(job, findings, report.get("not_addressed", []))
|
|
157
166
|
|
|
158
167
|
|
|
@@ -177,8 +186,9 @@ def _uncorrected(job: Job, findings: list[dict], not_addressed: list[dict]) -> l
|
|
|
177
186
|
return list(code.values())
|
|
178
187
|
|
|
179
188
|
|
|
180
|
-
def _fix(job: Job) -> None:
|
|
181
|
-
"""Run the next fix round: a fixer on the implementer's list
|
|
189
|
+
def _fix(job: Job, findings: list[dict]) -> None:
|
|
190
|
+
"""Run the next fix round: a fixer on the implementer's list, for `findings`. A fixer that makes no commit gives
|
|
191
|
+
a reason per finding, and the review of the same tip checks them (issue #123)."""
|
|
182
192
|
run, number = job.run, job.ticket.number
|
|
183
193
|
job.round += 1
|
|
184
194
|
on = entry(run.models, job.round)
|
|
@@ -188,7 +198,8 @@ def _fix(job: Job) -> None:
|
|
|
188
198
|
elif job.round == 3:
|
|
189
199
|
ledger(f"Ticket {number} round 3: the implementer has no next entry, so the round stays on {on}.")
|
|
190
200
|
with during(f"fix round {job.round}"):
|
|
191
|
-
run.agent("fixer", number, job.slot, job.pointers(job.round - 1), entry=on, fix_round=job.round
|
|
201
|
+
run.agent("fixer", number, job.slot, job.pointers(job.round - 1), entry=on, fix_round=job.round,
|
|
202
|
+
check={"fix": [finding["title"] for finding in findings], "red": job.red})
|
|
192
203
|
before, job.tip = job.tip, driver_slots.head(job.slot)
|
|
193
204
|
run.state.ticket(number, tip=job.tip)
|
|
194
205
|
followed = driver_review.follow(job.slot, before, job.tip, job.proofs)
|
|
@@ -237,7 +248,7 @@ def _act_on(job: Job, found: list[dict]) -> bool:
|
|
|
237
248
|
evidence = OUT / job.ticket.number / f"findings-{ROUNDS}.json"
|
|
238
249
|
job.run.ask(job.ticket.number, "finding", titles, str(evidence))
|
|
239
250
|
raise Blocked(f"the review: after round {ROUNDS} these findings are open: {'; '.join(titles)}")
|
|
240
|
-
_fix(job)
|
|
251
|
+
_fix(job, to_fix)
|
|
241
252
|
return False
|
|
242
253
|
|
|
243
254
|
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
context: repo (slot path), branch, start (HEAD when the role started), log, full (a full review: no fix range), locked,
|
|
4
4
|
correction (a test-writer corrects locked tests), restored (locked files the driver put back before it),
|
|
5
5
|
restore_red (the gate is red on the commit of that restore), findings (the titles a correction gets),
|
|
6
|
-
owners (ticket numbers, for the final fix batch), merged (locked files of merged tickets, not its own), pr (tip)
|
|
6
|
+
owners (ticket numbers, for the final fix batch), merged (locked files of merged tickets, not its own), pr (tip),
|
|
7
|
+
fix (the titles of the findings a fixer gets), red (the gate is red on `start`)."""
|
|
7
8
|
from __future__ import annotations
|
|
8
9
|
|
|
9
10
|
import json
|
|
@@ -68,6 +69,28 @@ def _commit_errors(report: dict, context: dict) -> list[str]:
|
|
|
68
69
|
return errors
|
|
69
70
|
|
|
70
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"):
|
|
76
|
+
return []
|
|
77
|
+
return _moved_errors(context) + [
|
|
78
|
+
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"])]
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _moved_errors(context: dict) -> list[str]:
|
|
83
|
+
"""What a report with no commit leaves out: a commit on the branch, a change in the tree, a red gate."""
|
|
84
|
+
repo, branch = context["repo"], context["branch"]
|
|
85
|
+
errors = [f"commit {sha[:7]} is on {branch} and not in `commits`: list each commit you made"
|
|
86
|
+
for sha in _git(repo, "rev-list", f"{context['start']}..{branch}")]
|
|
87
|
+
if _git(repo, "status", "--porcelain", "--untracked-files=no"):
|
|
88
|
+
errors.append("no commit, and the tree has uncommitted changes: commit the fix and list the commit")
|
|
89
|
+
if context.get("red"):
|
|
90
|
+
errors.append(f"no commit, and the gate is red on {context['start'][:7]}: a fix of a red gate is a commit")
|
|
91
|
+
return errors
|
|
92
|
+
|
|
93
|
+
|
|
71
94
|
def _correction_errors(report: dict, context: dict) -> list[str]:
|
|
72
95
|
"""A correction changes only the files it lists in `locked` and the files the driver `restored`."""
|
|
73
96
|
if not context.get("correction"):
|
|
@@ -108,7 +131,8 @@ def _proof_errors(report: dict, context: dict) -> list[str]:
|
|
|
108
131
|
|
|
109
132
|
|
|
110
133
|
def _locked_errors(report: dict, context: dict) -> list[str]:
|
|
111
|
-
"""In a full review, each locked test file has a mutation proof (`mutations[].test` is `<file>::<test>`).
|
|
134
|
+
"""In a full review, each locked test file has a mutation proof (`mutations[].test` is `<file>::<test>`).
|
|
135
|
+
`locked` names no fixture of the ticket: a fixture holds no test that a proof could name (#118)."""
|
|
112
136
|
if not context.get("full") or "findings" not in report:
|
|
113
137
|
return []
|
|
114
138
|
tests = [proof["test"] for proof in report.get("mutations", [])]
|
|
@@ -116,6 +140,12 @@ def _locked_errors(report: dict, context: dict) -> list[str]:
|
|
|
116
140
|
if not any(test.startswith(path) for test in tests)]
|
|
117
141
|
|
|
118
142
|
|
|
143
|
+
def _fixture_errors(report: dict) -> list[str]:
|
|
144
|
+
"""Each fixture of a test-writer report (a locked file that holds no test) is in its `locked`."""
|
|
145
|
+
return [f"fixtures: {path} is not in `locked`" for path in report.get("fixtures", [])
|
|
146
|
+
if path not in report.get("locked", [])]
|
|
147
|
+
|
|
148
|
+
|
|
119
149
|
def locked_files(listed: list[str]) -> list[str]:
|
|
120
150
|
"""The files of a `locked` list: a test node id `<file>::<test>` names its file. In order, each file once."""
|
|
121
151
|
return list(dict.fromkeys(entry.partition("::")[0] for entry in listed))
|
|
@@ -134,5 +164,6 @@ def validate(role: str, path: str, context: dict) -> list[str]:
|
|
|
134
164
|
report = {name: value for name, value in report.items() if name in rules["properties"]}
|
|
135
165
|
if "locked" in report:
|
|
136
166
|
report["locked"] = locked_files(report["locked"])
|
|
137
|
-
return (_commit_errors(report, context) + _owner_errors(report, context) +
|
|
138
|
-
+
|
|
167
|
+
return (_commit_errors(report, context) + _owner_errors(report, context) + _unchanged_errors(report, context)
|
|
168
|
+
+ _correction_errors(report, context) + _merged_errors(report, context) + _proof_errors(report, context)
|
|
169
|
+
+ _locked_errors(report, context) + _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
|
|
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]]:
|
|
@@ -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,6 +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
18
|
In `ticket`, give the number of the ticket that owns your commits. In `green`, give the summary lines of the passing test output.
|
|
18
19
|
|
|
19
20
|
Write one JSON report at {report} that matches this schema:
|
|
@@ -24,14 +25,12 @@ Write one JSON report at {report} that matches this schema:
|
|
|
24
25
|
"required": ["status", "commits", "files", "concerns", "green", "ticket"],
|
|
25
26
|
"properties": {
|
|
26
27
|
"status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
|
|
27
|
-
"commits": {"type": "array", "items": {"type": "string", "pattern": "^[0-9a-f]{7,40}$"}},
|
|
28
|
+
"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}$"}},
|
|
28
29
|
"files": {"type": "array", "items": {"type": "string"}},
|
|
29
30
|
"concerns": {"type": "array", "items": {"type": "string"}},
|
|
30
31
|
"green": {"type": "array", "items": {"type": "string"}},
|
|
31
32
|
"ticket": {"type": "string", "pattern": "^[0-9]+$"}
|
|
32
|
-
}
|
|
33
|
-
"if": {"properties": {"status": {"enum": ["DONE", "DONE_WITH_CONCERNS"]}}},
|
|
34
|
-
"then": {"properties": {"commits": {"minItems": 1}}}
|
|
33
|
+
}
|
|
35
34
|
}
|
|
36
35
|
```
|
|
37
36
|
|
|
@@ -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: {
|
|
2
|
+
This is a full review of {start_sha}: give one mutation proof or more for each of these locked test files: {locked_tests}
|
|
@@ -8,7 +8,7 @@ Locked files: {locked}
|
|
|
8
8
|
|
|
9
9
|
Make the locked tests green and meet each criterion of the ticket. For internal code, work in vertical test-first slices: one failing test, the smallest code that passes it, then the next slice.
|
|
10
10
|
Never edit a locked file. If a locked test contradicts the spec or the ticket, stop and report BLOCKED with a concern that starts with `locked test contradicts spec:`, then the test and the evidence.
|
|
11
|
-
Commit your work on the checked-out ticket branch. Do not dispatch subagents.
|
|
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
14
|
In `green`, give the summary lines of the passing test output.
|
|
@@ -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
|
},
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The fixer of round {round} changed nothing: its report {fixer_report} gives in `concerns` why each finding needs no change. Check each reason at {start_sha}, and report again each finding that still holds.
|
|
@@ -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": {}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
|
|
@@ -582,6 +582,24 @@ def test_four_rounds_then_blocked_with_the_escalation_at_round_3(tmp_path):
|
|
|
582
582
|
assert rig.state()["tickets"]["03"]["phase"] == "merged"
|
|
583
583
|
|
|
584
584
|
|
|
585
|
+
def test_a_fixer_with_nothing_to_change_is_accepted_and_the_same_tip_is_reviewed_again(tmp_path):
|
|
586
|
+
"""Issue 123: a fixer whose finding needs no change reports no commit. That is no rerun: the round counts, the
|
|
587
|
+
gate of the tip stands, and the re-review weighs the fixer's reason."""
|
|
588
|
+
rig = Inside(tmp_path)
|
|
589
|
+
nothing = {"report": {"status": "DONE_WITH_CONCERNS", "commits": [], "files": [], "green": ["1 passed"],
|
|
590
|
+
"ticket": "01", "concerns": ["STUCK: the code already handles it"]}}
|
|
591
|
+
rig.run(plan(**{"01/reviewer": [review("01", [STUCK]), review("01")], "01/fixer": [nothing]}))
|
|
592
|
+
assert rig.code == 0, rig.ledger()
|
|
593
|
+
assert len(rig.calls("01", "fixer")) == 1 and rig.led("fixer ran on", "report accepted")
|
|
594
|
+
assert rig.state()["tickets"]["01"]["round"] == 1 and rig.state()["tickets"]["01"]["phase"] == "merged"
|
|
595
|
+
tip = rig.sha("01", "implementer")
|
|
596
|
+
assert [gate["commit"] for gate in rig.gates()].count(tip) == 1
|
|
597
|
+
again = rig.prompt("reviewer-1")
|
|
598
|
+
assert f"The fix is {tip}..{tip}" in again and "The fixer of round 1 changed nothing" in again
|
|
599
|
+
assert ".agent/implement/01/fixer-1.json" in again and "no concern names" not in rig.prompt("fixer-1")
|
|
600
|
+
assert "list no commit" in rig.prompt("fixer-1")
|
|
601
|
+
|
|
602
|
+
|
|
585
603
|
def test_a_red_gate_on_a_fixer_commit_starts_the_next_round_with_the_record_as_evidence(tmp_path):
|
|
586
604
|
"""Issue 64: the gate of a fix round is red. That is a finding for the next round, not a BLOCKED ticket."""
|
|
587
605
|
rig = Inside(tmp_path, gate={"subjects": ["fix: 01 round 1"]})
|
|
@@ -749,6 +767,27 @@ def test_a_full_review_after_a_correction_names_each_locked_file_that_needs_a_pr
|
|
|
749
767
|
assert "In round 1" not in full and due not in again
|
|
750
768
|
|
|
751
769
|
|
|
770
|
+
def test_a_full_review_needs_no_proof_for_a_locked_fixture_that_holds_no_test(tmp_path):
|
|
771
|
+
"""Issue #118: a fake `gh` the test-writer locks holds no test, so no `<locked file>::<test name>` can name it."""
|
|
772
|
+
first = {**tw("01"), "files": {"tests/test_01.py": "def test_x():\n assert 0\n", "tests/fakes/gh": "exit 0\n"}}
|
|
773
|
+
first["report"] = {**first["report"], "files": ["tests/test_01.py", "tests/fakes/gh"],
|
|
774
|
+
"locked": ["tests/test_01.py", "tests/fakes/gh"], "fixtures": ["tests/fakes/gh"]}
|
|
775
|
+
rig = Inside(tmp_path).run(plan(**{"01/test-writer": [first], "01/reviewer": [review("01")]}))
|
|
776
|
+
assert rig.code == 0 and len(rig.calls("01", "reviewer")) == 1, rig.ledger()
|
|
777
|
+
assert rig.state()["tickets"]["01"]["fixtures"] == ["tests/fakes/gh"]
|
|
778
|
+
assert "for each of these locked test files: tests/test_01.py\n" in rig.calls("01", "reviewer")[0]["prompt"]
|
|
779
|
+
|
|
780
|
+
|
|
781
|
+
def test_a_fixture_must_be_a_locked_file_and_a_correction_that_relists_it_decides_again(tmp_path):
|
|
782
|
+
report = dict(status="NEEDS_CONTEXT", commits=[], files=[], concerns=[], locked=["a"], red=[], fixtures=["gh"])
|
|
783
|
+
path = tmp_path / "test-writer-0.json"
|
|
784
|
+
path.write_text(json.dumps(report))
|
|
785
|
+
context = {"repo": ".", "branch": "HEAD", "start": "HEAD", "log": str(path)}
|
|
786
|
+
assert "fixtures: gh is not in `locked`" in driver_report.validate("test-writer", str(path), context)
|
|
787
|
+
entry = {"test_writer_sha": None, "locked": ["tests/a.py", "gh", "fake"], "held": {}, "fixtures": ["gh", "fake"]}
|
|
788
|
+
assert driver_review.written(".", entry, ["gh"], [], "tip")["fixtures"] == ["fake"]
|
|
789
|
+
|
|
790
|
+
|
|
752
791
|
def test_the_locked_file_rule_is_for_the_first_review_only(tmp_path):
|
|
753
792
|
report = dict(status="DONE", commits=[], files=[], concerns=[], findings=[], mutations=[])
|
|
754
793
|
path = tmp_path / "reviewer-0.json"
|
|
@@ -134,6 +134,26 @@ 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_a_fixer_with_nothing_to_change_reports_no_commit_and_a_reason_per_finding(world):
|
|
138
|
+
"""Issue 123: a fixer whose findings need no change has a report the driver accepts: no commit, a concern each."""
|
|
139
|
+
shas, check, tmp = world
|
|
140
|
+
fixer = lambda **changes: implementer(shas, **{"commits": [], "ticket": "01", **changes})
|
|
141
|
+
fix = {"start": shas["impl"], "fix": ["STUCK", "LOOSE"]}
|
|
142
|
+
reasons = ["STUCK: the correction at abc1234 resolved it", "LOOSE: the code already handles it"]
|
|
143
|
+
assert check("fixer", fixer(status="DONE_WITH_CONCERNS", concerns=reasons), **fix) == []
|
|
144
|
+
assert check("fixer", fixer(concerns=reasons[:1]), **fix) == [
|
|
145
|
+
"no commit, and no concern names the finding LOOSE: give each finding a concern that says why it needs no change"]
|
|
146
|
+
assert check("fixer", fixer(concerns=reasons), **fix, red=True) == [
|
|
147
|
+
f"no commit, and the gate is red on {shas['impl'][:7]}: a fix of a red gate is a commit"]
|
|
148
|
+
# A commit that predates the fixer is still refused, and a commit it made is in `commits`.
|
|
149
|
+
assert check("fixer", fixer(commits=[shas["impl"]], concerns=reasons), **fix)
|
|
150
|
+
assert check("fixer", fixer(concerns=reasons), **{**fix, "start": shas["tests"]}) == [
|
|
151
|
+
f"commit {shas['impl'][:7]} is on ticket/01 and not in `commits`: list each commit you made"]
|
|
152
|
+
(tmp / "slot" / "demo/export.py").write_text("changed\n")
|
|
153
|
+
assert check("fixer", fixer(concerns=reasons), **fix) == [
|
|
154
|
+
"no commit, and the tree has uncommitted changes: commit the fix and list the commit"]
|
|
155
|
+
|
|
156
|
+
|
|
137
157
|
def test_locked_path_absent_from_the_commit_is_a_violation(world):
|
|
138
158
|
shas, check, _ = world
|
|
139
159
|
assert check("test-writer", writer(shas), start=shas["base"]) == []
|
|
@@ -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"]["
|
|
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):
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-10-20T15:
|
|
3
|
+
"generatedAt": "2026-10-20T15:57:25.481Z",
|
|
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.33",
|
|
50
|
+
"hash": "sha256-f5d4bb64baedc840c40253138ece3c8781424ebf7619447b2e10858888a93c7c",
|
|
51
51
|
"description": "Implement a specification in code."
|
|
52
52
|
},
|
|
53
53
|
{
|