@jesdi/skills 0.0.59 → 0.0.60
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 -1
- package/skills/implement-spec/README.md +5 -4
- package/skills/implement-spec/driver.py +74 -14
- package/skills/implement-spec/driver_decisions.py +28 -0
- package/skills/implement-spec/driver_merge.py +7 -6
- package/skills/implement-spec/driver_run.py +25 -9
- package/skills/implement-spec/prompts/restored.md +1 -1
- package/skills/implement-spec/tests/test_fixloop.py +83 -5
- package/skills/implement-spec/tests/test_landing.py +12 -9
- package/skills/implement-spec/tests/test_merge.py +9 -9
- package/skills-manifest.json +3 -3
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@ and do not know about the run, except `driver_run.py`, which the three deciding
|
|
|
42
42
|
- **A check before the first agent returns a list of errors**, so the operator sees all of them at one time
|
|
43
43
|
(exit 3). Examples: `precondition_errors`, `driver_tickets.parse`, `driver_report.validate`.
|
|
44
44
|
- **The modules that do not know about the run return a result, not `Blocked`.** Some return `""` or the reason
|
|
45
|
-
as a string (`driver_merge.
|
|
45
|
+
as a string (`driver_merge.land`), or what they found (`driver_merge.refused`); the deciding module raises.
|
|
46
46
|
- A slot is a worktree. Slot 1 is the PR worktree; the others are in `.agent/worktrees/`.
|
|
47
47
|
- A number of a ticket is a string (`"03"`). `FINAL` is used in its place for the end of run.
|
|
48
48
|
|
|
@@ -80,6 +80,10 @@ and do not know about the run, except `driver_run.py`, which the three deciding
|
|
|
80
80
|
a ticket lands (`driver_merge.refused`): the tree that lands must have each of them as the PR tip has it. A
|
|
81
81
|
ticket's test-writer may change one only when it lists it. So a review finding on such a file goes to a correction
|
|
82
82
|
too: a fixer's change there is put back, and the ticket would loop until BLOCKED (issue #116).
|
|
83
|
+
- A refused landing asks a `merged-locked-file` question. `driver._rulings` applies its answers at the next landing:
|
|
84
|
+
`restore` is a commit of the driver (`Run.restore_merged_files`), and `adopt` adds the file to the ticket's
|
|
85
|
+
`locked` only when the ticket lands. A red merge gate after a ruling takes the restore commit back and asks again
|
|
86
|
+
(`driver._red_landing`); `driver_decisions.question` leaves out the option that was tried.
|
|
83
87
|
- A conflict resolution, of a merge or of the rebase, may not change a locked file.
|
|
84
88
|
|
|
85
89
|
### The PR branch
|
|
@@ -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` or `final-finding` is open. Exit 2 wins over exit 1. |
|
|
60
|
+
| 2 | Parked: a question of kind `locked-test`, `locked-test-again`, `review-stopped`, `implementer-stopped`, `fixer-stopped`, `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. |
|
|
@@ -102,7 +102,7 @@ A ticket is ready when each ticket in its **Blocked by** line is merged and no r
|
|
|
102
102
|
3. **Gate.** The driver runs `--gate` on the ticket tip.
|
|
103
103
|
4. **Review.** The driver compares each locked file of the ticket with the test-writer commit. A file that differs is a critical finding `locked file changed: <path>`. A locked file of a merged ticket that the ticket changed since its merge base with the PR branch is a critical `fixture` finding `the ticket changed the locked file of a merged ticket: <path>`, so it goes to a correction (see **Before a correction**). Then the **reviewer** (`prompts/reviewer.md`) runs, and for a ticket with a **Risk** line the **correctness** pass (`prompts/correctness.md`) runs at the same time in the same slot. A read-only role (reviewer, correctness, final-reviewer, pr-writer) leaves its slot and the git config as it found them: all worktrees share one config, and one key written there, such as a `core.worktree` on a temp directory, breaks git in each of them. To run a check off the slot, a reviewer reads the driver's gate record or makes its own `git worktree add --detach` copy and removes it. After read-only roles, the driver checks the slot and the shared config (`git rev-parse --git-common-dir`, then `config`) against what they were before. When one of them changed, the driver restores it, writes `a read-only role broke its rule: ...` to the ledger, and runs the review one more time; a second change blocks the ticket.
|
|
104
104
|
5. **Merge.** The driver merges the reviewed tip into the PR branch with git plumbing, then deletes the ticket branch. A conflict goes to the **conflict** agent (`prompts/conflict.md`) once. Its resolution may change no locked file of the ticket. A second conflict blocks the ticket.
|
|
105
|
-
**The landing check.** Merges are serial. Before the PR branch moves, the driver compares the tree that is about to land (the ticket tip of a fast-forward, or the merge commit) with the PR tip: each locked file of each merged ticket must be the same tree entry in both: the same blob with the same mode, so a file that became a symlink is a difference. A file that only one of them has is a difference. A file that the landing ticket lists in its own `locked` is not checked: the test-writer of a later ticket can add a test to a file that an earlier ticket locked, and must list that file. A test-writer report that changes such a file and does not list it is rejected, with the usual one rerun. The review finds such a change first; the landing check catches a change that no review saw, for example of a ticket that merged after the last review. A difference refuses the landing: the ticket is BLOCKED with `locked file changed: <path>` in the ledger, the PR branch does not move, and no fix round runs. The PR branch moves only from the tip that the check read; when another hand moved the branch in between, the driver makes the merge, the check and the gate again, one time. Only that case starts the landing again: a refused landing and a red merge gate block the ticket. The second try runs no conflict agent, so a conflict there blocks the ticket, and so does a branch that moved again.
|
|
105
|
+
**The landing check.** Merges are serial. Before the PR branch moves, the driver compares the tree that is about to land (the ticket tip of a fast-forward, or the merge commit) with the PR tip: each locked file of each merged ticket must be the same tree entry in both: the same blob with the same mode, so a file that became a symlink is a difference. A file that only one of them has is a difference. A file that the landing ticket lists in its own `locked` is not checked: the test-writer of a later ticket can add a test to a file that an earlier ticket locked, and must list that file. A test-writer report that changes such a file and does not list it is rejected, with the usual one rerun. The review finds such a change first; the landing check catches a change that no review saw, for example of a ticket that merged after the last review. A difference refuses the landing: the ticket is BLOCKED with `locked file changed: <path>` in the ledger and a `merged-locked-file` question for each path, the PR branch does not move, and no fix round runs. `restore` puts the file back to the version of the PR branch in a commit of the driver on the ticket branch, and `adopt` adds the file to the ticket's `locked`; then the landing runs again with its gate. When that gate is red, the driver takes the restore commit back and asks again without the option that was tried. The PR branch moves only from the tip that the check read; when another hand moved the branch in between, the driver makes the merge, the check and the gate again, one time. Only that case starts the landing again: a refused landing and a red merge gate block the ticket. The second try runs no conflict agent, so a conflict there blocks the ticket, and so does a branch that moved again.
|
|
106
106
|
**Before a correction.** A test-writer that corrects locked tests (after `overrule-test`, or for a `fixture` finding or a `test` finding on a locked file) starts from the locked versions: the driver puts back each locked file of the ticket and each locked file of a merged ticket that the ticket changed, commits them in one commit of its own, and the ledger names each file. A file of a merged ticket goes back to the version of the PR branch. The commit keeps the tree of the next fixer and of the gate clean, whatever files the correction commits. The correction's prompt names the restored files: when a test in one of them fails only because the ticket changed an interface that the test uses, the correction updates the file to the new interface, keeps what each test asserts, and lists the file in `locked`. Each correction also gets `prompts/corrected.md`: when it adds a requirement, it updates each shared fake or fixture that other locked tests use, runs each whole locked file and each locked test of merged tickets, and names each red test in `concerns`.
|
|
107
107
|
**The gate of the restore.** In the fix loop, the tip before the restore has a green gate, so the driver gates the restore commit and does not leave the question to the correction. A red gate means that a restored file fails with the ticket's code: the correction gets the gate record (`prompts/restored-red.md`), and a DONE correction must list a restored file in `locked`; else it reports BLOCKED with `locked test contradicts spec:`. A green gate with only driver findings to correct closes them with the restore: no test-writer runs. After `overrule-test` the driver does not gate the restore, because the tip before it has no green gate; a change that the next implementer makes to a merged ticket's file is a finding of the next review.
|
|
108
108
|
|
|
@@ -129,7 +129,7 @@ A red gate on the commit of the implementer or of a fixer is a critical finding
|
|
|
129
129
|
- Rounds 1 and 2 run on the first entry of the implementer list.
|
|
130
130
|
- Rounds 3 and 4 run on the second entry of the implementer list. When the list has one entry, they stay on it and the ledger says so.
|
|
131
131
|
- There is no ruling at round 2.
|
|
132
|
-
- Findings that are open after round 4 make the ticket BLOCKED. The run ends with exit 1, and the driver writes one question of kind `finding` for each. A finding that would get a test-writer correction is one of them: no correction runs after round 4, because its new locked tests would have no fix round to make them green and the merge gate would be red. So `accept` on each question merges the reviewed tip.
|
|
132
|
+
- Findings that are open after round 4 make the ticket BLOCKED. The run ends with exit 1, and the driver writes one question of kind `finding` for each. A finding that would get a test-writer correction is one of them: no correction runs after round 4, because its new locked tests would have no fix round to make them green and the merge gate would be red. So `accept` on each question merges the reviewed tip. A tip that still changes a locked file of a merged ticket gets a `merged-locked-file` question at its landing.
|
|
133
133
|
|
|
134
134
|
### End of run
|
|
135
135
|
|
|
@@ -201,6 +201,7 @@ A question is a bounded choice for the operator. `driver_decisions.py` `KINDS` h
|
|
|
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
202
|
| `implementer-stopped` | `<NN>-implementer-stopped-<n>` | The implementer reports `BLOCKED` or `NEEDS_CONTEXT`, and no concern starts with `locked test contradicts spec:`. | 2 | `retry` (recommended): the implementer runs again from the tip it left. `accept-tip`: the driver gates and reviews that tip, and the fix rounds close what the review finds. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
203
203
|
| `fixer-stopped` | `<NN>-fixer-stopped-<n>` | A fixer reports `BLOCKED` or `NEEDS_CONTEXT`, and no concern starts with `locked test contradicts spec:`. | 2 | `retry` (recommended): the round that stopped does not count; the driver gates and reviews the tip the fixer left, and a fixer runs that round again on the review's findings. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
204
|
+
| `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. |
|
|
204
205
|
| `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. |
|
|
205
206
|
|
|
206
207
|
`n` counts the questions of that ticket and kind in the run, so an id is never used twice.
|
|
@@ -211,7 +212,7 @@ Answer with `--answer <question id>=<option id>` on the next run, or through the
|
|
|
211
212
|
|
|
212
213
|
| Check | Where it lives |
|
|
213
214
|
|---|---|
|
|
214
|
-
| Locked tests with a demonstrated red | `driver_report.py` `_proof_errors`: each red line of the test-writer report must be in its log. `driver_review.py` `locked_findings`: a locked file of the ticket that differs from the test-writer commit is a critical finding, before each review. `driver_review.py` `merged_changes`: a locked file of a merged ticket that the ticket changed is a critical `fixture` finding, before each review. `driver_merge.py` `refused`, called from `driver.py` `_checked_landing` under the merge lock: a locked file of a merged ticket that differs between the PR tip and the tree that is about to land refuses the landing, so a later ticket
|
|
215
|
+
| 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 with a `merged-locked-file` question, so a later ticket changes the locked test of an earlier one only by the operator's `adopt`. `driver_report.py` `_merged_errors` rejects a test-writer report that changes such a file and does not list it. |
|
|
215
216
|
| 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. |
|
|
216
217
|
| 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. |
|
|
217
218
|
| 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. |
|
|
@@ -48,6 +48,7 @@ ONLY = ("test-writer", "implementer", "reviewer", "correctness") # `--only` is
|
|
|
48
48
|
# The phase of a ticket while a role runs, and the phase it reaches when the role's report is accepted.
|
|
49
49
|
DURING = {"test-writer": "test-writer", "implementer": "implement"}
|
|
50
50
|
AFTER = {"test-writer": "implement", "implementer": "gate"}
|
|
51
|
+
MERGED_LOCKED = "merged-locked-file" # the question of a landing that changes a locked file of a merged ticket
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
# ---------------------------------------------------------------- one ticket: the roles
|
|
@@ -136,6 +137,16 @@ class _Landing:
|
|
|
136
137
|
commit: str # what the PR branch moves to: `pr_tip` (merged already), `ticket_tip` (fast-forward) or a merge
|
|
137
138
|
|
|
138
139
|
|
|
140
|
+
@dataclass
|
|
141
|
+
class _Rulings:
|
|
142
|
+
"""The answers to the `merged-locked-file` questions of the ticket, as its landing applies them."""
|
|
143
|
+
before: str # the ticket tip before the driver put a file back
|
|
144
|
+
paths: dict[str, str] # file -> `restore` or `adopt`
|
|
145
|
+
|
|
146
|
+
def adopted(self) -> list[str]:
|
|
147
|
+
return [path for path, answer in self.paths.items() if answer == "adopt"]
|
|
148
|
+
|
|
149
|
+
|
|
139
150
|
def _resolve_conflict(ticket: Ticket, slot: str, run: Run, tip: str, files: list[str]) -> str:
|
|
140
151
|
"""Run the conflict agent on the merge that is open in the slot. Returns the new ticket tip."""
|
|
141
152
|
number = ticket.number
|
|
@@ -175,41 +186,87 @@ def _merge_commit(ticket: Ticket, slot: str, run: Run, tip: str, may_resolve: bo
|
|
|
175
186
|
return _Landing(tip, pr_tip, commit)
|
|
176
187
|
|
|
177
188
|
|
|
178
|
-
def
|
|
189
|
+
def _rulings(number: str, slot: str, run: Run) -> _Rulings:
|
|
190
|
+
"""Apply the `restore` rulings on the ticket's files of merged tickets: one commit of the driver. Call it under
|
|
191
|
+
the merge lock."""
|
|
192
|
+
paths = {path: answer for path, answer in
|
|
193
|
+
driver_decisions.ruled(run.state.read()["run"]["questions"], number, MERGED_LOCKED).items()
|
|
194
|
+
if answer != "redesign"}
|
|
195
|
+
rulings = _Rulings(run.state.read()["tickets"][number]["tip"], paths)
|
|
196
|
+
if restore := [path for path, answer in paths.items() if answer == "restore"]:
|
|
197
|
+
git(slot, "checkout", "-q", run.names.ticket(number))
|
|
198
|
+
run.restore_merged_files(number, slot, restore)
|
|
199
|
+
return rulings
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
def _refused(number: str, run: Run, landing: _Landing, rulings: _Rulings) -> None:
|
|
203
|
+
"""The landing check: a locked file of a merged ticket that the landing changes asks a `merged-locked-file`
|
|
204
|
+
question. A file that an `adopt` ruling names is the ticket's own."""
|
|
205
|
+
tickets = run.state.read()["tickets"]
|
|
206
|
+
entry = tickets[number]
|
|
207
|
+
own = {**tickets, number: {**entry, "locked": entry["locked"] + rulings.adopted()}}
|
|
208
|
+
changed, error = driver_merge.refused(own, number, landing.pr_tip, landing.commit)
|
|
209
|
+
if error:
|
|
210
|
+
raise Blocked(error)
|
|
211
|
+
if changed:
|
|
212
|
+
run.ask(number, MERGED_LOCKED, changed,
|
|
213
|
+
f"git diff {landing.pr_tip[:7]} {landing.commit[:7]} -- {' '.join(changed)}")
|
|
214
|
+
raise Blocked("; ".join(f"locked file changed: {path}" for path in changed))
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _red_landing(number: str, slot: str, run: Run, rulings: _Rulings, record: str) -> None:
|
|
218
|
+
"""A red merge gate after `restore` or `adopt` rulings: the restore commit leaves the ticket branch, and each
|
|
219
|
+
ruled file is asked again, without the option that was tried."""
|
|
220
|
+
if rulings.paths:
|
|
221
|
+
if run.state.read()["tickets"][number]["tip"] != rulings.before:
|
|
222
|
+
driver_review.restore(slot, run.names.ticket(number), rulings.before)
|
|
223
|
+
run.state.ticket(number, tip=rulings.before)
|
|
224
|
+
ledger(f"Ticket {number}: the merge gate is red after the restore, so the driver took the restore commit "
|
|
225
|
+
f"back: the ticket tip is {rulings.before[:7]} again.")
|
|
226
|
+
run.ask(number, MERGED_LOCKED, list(rulings.paths), record)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _checked_landing(ticket: Ticket, slot: str, run: Run, may_resolve: bool, rulings: _Rulings) -> _Landing:
|
|
179
230
|
"""The commit to land, with the locked-file check passed and the gate green. Call it under the merge lock."""
|
|
180
231
|
number = ticket.number
|
|
181
232
|
# An earlier try left the slot on its merge commit.
|
|
182
233
|
git(slot, "checkout", "-q", run.names.ticket(number))
|
|
183
234
|
tip = run.state.ticket(number, phase="merge")["tip"]
|
|
184
235
|
landing = _merge_commit(ticket, slot, run, tip, may_resolve)
|
|
185
|
-
|
|
186
|
-
if refusal:
|
|
187
|
-
raise Blocked(refusal)
|
|
236
|
+
_refused(number, run, landing, rulings)
|
|
188
237
|
if landing.commit != landing.pr_tip:
|
|
189
238
|
# No gate has seen a merge commit. A fast-forward to a gated tip finds its green record.
|
|
190
239
|
# When the checkout fails, the slot is on another commit and the gate refuses to run.
|
|
191
240
|
git(slot, "checkout", "-q", "--detach", landing.commit)
|
|
192
|
-
run.
|
|
241
|
+
if record := run.red_gate(number, slot, landing.commit):
|
|
242
|
+
_red_landing(number, slot, run, rulings, record)
|
|
243
|
+
raise Blocked(f"the gate is red on {landing.commit[:7]}, record {record}")
|
|
193
244
|
return landing
|
|
194
245
|
|
|
195
246
|
|
|
196
|
-
def _land(ticket: Ticket, slot: str, run: Run) -> _Landing:
|
|
247
|
+
def _land(ticket: Ticket, slot: str, run: Run) -> tuple[_Landing, _Rulings]:
|
|
197
248
|
"""Move the PR branch to the checked commit. Call it under the merge lock."""
|
|
198
|
-
|
|
249
|
+
rulings = _rulings(ticket.number, slot, run)
|
|
250
|
+
landing = _checked_landing(ticket, slot, run, True, rulings)
|
|
199
251
|
# git moves the ref only from the tip that the check read, so the check and the move are one step.
|
|
200
252
|
error = driver_merge.land(run.pr, landing.commit, landing.pr_tip)
|
|
201
253
|
if error and run.tip() != landing.pr_tip:
|
|
202
254
|
# Another hand moved the PR branch in between: start again from the new tip, one time, with no conflict agent.
|
|
203
|
-
landing = _checked_landing(ticket, slot, run,
|
|
255
|
+
landing = _checked_landing(ticket, slot, run, False, rulings)
|
|
204
256
|
error = driver_merge.land(run.pr, landing.commit, landing.pr_tip)
|
|
205
257
|
if error:
|
|
206
258
|
raise Blocked(error)
|
|
207
|
-
return landing
|
|
259
|
+
return landing, rulings
|
|
208
260
|
|
|
209
261
|
|
|
210
|
-
def _record_landing(state: dict, number: str,
|
|
211
|
-
"""The ticket is merged and `
|
|
212
|
-
|
|
262
|
+
def _record_landing(state: dict, number: str, landing: _Landing, adopted: list[str]) -> None:
|
|
263
|
+
"""The ticket is merged, and `landing.commit` is the PR tip its merge made: a later merge of the ticket replaces
|
|
264
|
+
it. The ticket locks each `adopted` file from its landed tip on."""
|
|
265
|
+
entry, pr_tip = state["tickets"][number], landing.commit
|
|
266
|
+
entry["phase"] = "merged"
|
|
267
|
+
new = [path for path in adopted if path not in entry["locked"]]
|
|
268
|
+
entry["locked"] += new
|
|
269
|
+
entry["held"].update(dict.fromkeys(new, landing.ticket_tip))
|
|
213
270
|
earlier = [landed for landed in state["run"]["landed"] if landed[0] != number]
|
|
214
271
|
state["run"]["landed"] = earlier + [[number, pr_tip]]
|
|
215
272
|
|
|
@@ -219,8 +276,11 @@ def _merge(ticket: Ticket, slot: str, run: Run) -> None:
|
|
|
219
276
|
number, branch = ticket.number, run.names.ticket(ticket.number)
|
|
220
277
|
# The merge gate and the conflict agent run under the lock: the commit the gate saw is the one that lands.
|
|
221
278
|
with run.merging, during("the merge"):
|
|
222
|
-
landing = _land(ticket, slot, run)
|
|
223
|
-
run.state.update(lambda state: _record_landing(state, number, landing.
|
|
279
|
+
landing, rulings = _land(ticket, slot, run)
|
|
280
|
+
run.state.update(lambda state: _record_landing(state, number, landing, rulings.adopted()))
|
|
281
|
+
for path in rulings.adopted():
|
|
282
|
+
ledger(f"Ticket {number}: by the ruling (adopt), the ticket locks {path}, so its change to that locked file of "
|
|
283
|
+
"a merged ticket landed.")
|
|
224
284
|
driver_slots.release(slot) # git deletes no branch that a worktree has checked out
|
|
225
285
|
kept = "" if driver_merge.delete(branch, run.pr) else f"; {branch} is kept"
|
|
226
286
|
if landing.commit == landing.pr_tip:
|
|
@@ -121,6 +121,24 @@ KINDS = {
|
|
|
121
121
|
"redesign": Option(
|
|
122
122
|
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
123
123
|
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
124
|
+
"merged-locked-file": Kind(
|
|
125
|
+
True,
|
|
126
|
+
"Ticket {ticket}: the landing would change the locked file of a merged ticket: {subject}",
|
|
127
|
+
"The landing check found that ticket {ticket} changes this locked file of a merged ticket, so the PR branch "
|
|
128
|
+
"did not move. Ticket {ticket} is BLOCKED and each ticket that it blocks waits.",
|
|
129
|
+
"restore",
|
|
130
|
+
{"restore": Option(
|
|
131
|
+
"The driver puts the file back to the version of the PR branch in a commit of its own on the ticket "
|
|
132
|
+
"branch, then the landing runs again with its gate. A red gate takes the commit back and asks again.",
|
|
133
|
+
"Ruling: {ticket} lands with {subject} put back to the version of the PR branch (restore).",
|
|
134
|
+
{"phase": "merge"}),
|
|
135
|
+
"adopt": Option(
|
|
136
|
+
"The ticket locks the file, so its change lands: the merged ticket's tests in it become the ticket's own. "
|
|
137
|
+
"The landing runs again with its gate. A red gate asks again.",
|
|
138
|
+
"Ruling: {ticket} locks {subject} and lands its change to it (adopt).", {"phase": "merge"}),
|
|
139
|
+
"redesign": Option(
|
|
140
|
+
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
141
|
+
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
124
142
|
# A final-review question belongs to no ticket: its `ticket` is "".
|
|
125
143
|
"final-finding": Kind(
|
|
126
144
|
True,
|
|
@@ -149,6 +167,11 @@ def corrections(questions: list[dict], ticket: str) -> tuple[int, bool]:
|
|
|
149
167
|
return sum("correct-again" in answers for answers in stops.values()), {"accept"} in stops.values()
|
|
150
168
|
|
|
151
169
|
|
|
170
|
+
def ruled(questions: list[dict], ticket: str, kind: str) -> dict[str, str]:
|
|
171
|
+
"""subject -> the last answer to the questions of `kind` on `ticket`."""
|
|
172
|
+
return {q["subject"]: q["answer"] for q in questions if (q["ticket"], q["kind"]) == (ticket, kind) and q["answer"]}
|
|
173
|
+
|
|
174
|
+
|
|
152
175
|
def accepted(questions: list[dict], ticket: str, kind: str) -> list[str]:
|
|
153
176
|
"""The subjects of the questions of `kind` on `ticket` that the operator answered `accept`."""
|
|
154
177
|
return [q["subject"] for q in questions if (q["ticket"], q["kind"], q["answer"]) == (ticket, kind, "accept")]
|
|
@@ -170,6 +193,11 @@ def question(kind: str, ticket: str, subject: str, evidence: list[str], asked: l
|
|
|
170
193
|
options, recommended = made.options, made.recommended
|
|
171
194
|
if kind == "locked-test-again" and corrections(asked, ticket)[0] >= AGAIN:
|
|
172
195
|
options, recommended = {name: options[name] for name in ("accept", "redesign")}, "accept"
|
|
196
|
+
if kind == "merged-locked-file":
|
|
197
|
+
# The file is asked again only when an answer turned the merge gate red: that answer is not offered again.
|
|
198
|
+
tried = {q["answer"] for q in asked if (q["ticket"], q["kind"], q["subject"]) == (ticket, kind, subject)}
|
|
199
|
+
options = {name: option for name, option in options.items() if name == "redesign" or name not in tried}
|
|
200
|
+
recommended = recommended if recommended in options else next(iter(options))
|
|
173
201
|
return {"id": f"{ticket}-{kind}-{number}".lstrip("-"), "title": made.title.format(**values), "why": made.why.format(**values),
|
|
174
202
|
"evidence": evidence, "recommended": recommended,
|
|
175
203
|
"options": [{"id": name, "description": option.description} for name, option in options.items()],
|
|
@@ -67,15 +67,16 @@ def _entries(commit: str, paths: list[str]) -> tuple[dict[str, str], str]:
|
|
|
67
67
|
return {path: entry for entry, _, path in (line.partition("\t") for line in names(tree.stdout))}, ""
|
|
68
68
|
|
|
69
69
|
|
|
70
|
-
def refused(tickets: dict, number: str, old: str, new: str) -> str:
|
|
71
|
-
"""
|
|
72
|
-
|
|
70
|
+
def refused(tickets: dict, number: str, old: str, new: str) -> tuple[list[str], str]:
|
|
71
|
+
"""Why ticket `number` may not land `new` on the PR tip `old`: (each locked file of a merged ticket that is not
|
|
72
|
+
the same blob with the same mode in both, "") or ([], why git cannot tell). ([], "") lets it land."""
|
|
73
73
|
paths = protected(tickets, number)
|
|
74
74
|
if not paths:
|
|
75
|
-
return "" # `git ls-tree` with no path lists the whole tree
|
|
75
|
+
return [], "" # `git ls-tree` with no path lists the whole tree
|
|
76
76
|
(before, error), (after, failed) = _entries(old, paths), _entries(new, paths)
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
if error or failed:
|
|
78
|
+
return [], error or failed
|
|
79
|
+
return [path for path in paths if before.get(path) != after.get(path)], ""
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
def changed(slot: str, pr_tip: str, paths: list[str]) -> list[str]:
|
|
@@ -193,20 +193,36 @@ class Run:
|
|
|
193
193
|
tickets = self.state.read()["tickets"]
|
|
194
194
|
paths = (driver_review.restore_locked(slot, tickets[number])
|
|
195
195
|
+ driver_merge.restore(slot, self.tip(), driver_merge.protected(tickets, number)))
|
|
196
|
-
|
|
197
|
-
changed = names(git(slot, "diff", "--name-only", "-z", "HEAD", "--", *paths).stdout) if paths else []
|
|
198
|
-
if changed:
|
|
199
|
-
words = "implement-spec: restore the locked files before the correction"
|
|
200
|
-
made = subprocess.run(["git", "-C", slot, "commit", "-q", "--no-verify", "-m", words, "--", *changed],
|
|
201
|
-
capture_output=True, text=True, env={**os.environ, **driver_merge.identity("HEAD", slot)})
|
|
202
|
-
if made.returncode:
|
|
203
|
-
raise Blocked(f"the driver cannot commit the restored locked files: {made.stderr.strip()}")
|
|
204
|
-
self.state.ticket(number, tip=driver_slots.head(slot))
|
|
196
|
+
self._commit_restored(number, slot, paths, "implement-spec: restore the locked files before the correction")
|
|
205
197
|
for path in paths:
|
|
206
198
|
ledger(f"Ticket {number}: {path} was not the locked version at the correction: the driver restored it in "
|
|
207
199
|
"a commit, so the correction starts from the locked version.")
|
|
208
200
|
return paths
|
|
209
201
|
|
|
202
|
+
def restore_merged_files(self, number: str, slot: str, paths: list[str]) -> list[str]:
|
|
203
|
+
"""Before a landing, by a `restore` ruling: put each of `paths` that is a locked file of a merged ticket and
|
|
204
|
+
that the ticket changed back to the version of the PR branch, in one commit of the driver. Returns those."""
|
|
205
|
+
protected = driver_merge.protected(self.state.read()["tickets"], number)
|
|
206
|
+
restored = driver_merge.restore(slot, self.tip(), [path for path in paths if path in protected])
|
|
207
|
+
self._commit_restored(number, slot, restored,
|
|
208
|
+
"implement-spec: restore the locked files of merged tickets before the landing")
|
|
209
|
+
for path in restored:
|
|
210
|
+
ledger(f"Ticket {number}: by the ruling (restore), the driver put back {path}, a locked file of a merged "
|
|
211
|
+
"ticket, at the version of the PR branch in a commit before the landing.")
|
|
212
|
+
return restored
|
|
213
|
+
|
|
214
|
+
def _commit_restored(self, number: str, slot: str, paths: list[str], words: str) -> None:
|
|
215
|
+
"""Commit the restored `paths` in the slot as a commit of the driver, and make it the ticket tip."""
|
|
216
|
+
# A path whose change was never committed is back at HEAD already, and `git commit -- <path>` refuses it.
|
|
217
|
+
changed = names(git(slot, "diff", "--name-only", "-z", "HEAD", "--", *paths).stdout) if paths else []
|
|
218
|
+
if not changed:
|
|
219
|
+
return
|
|
220
|
+
made = subprocess.run(["git", "-C", slot, "commit", "-q", "--no-verify", "-m", words, "--", *changed],
|
|
221
|
+
capture_output=True, text=True, env={**os.environ, **driver_merge.identity("HEAD", slot)})
|
|
222
|
+
if made.returncode:
|
|
223
|
+
raise Blocked(f"the driver cannot commit the restored locked files: {made.stderr.strip()}")
|
|
224
|
+
self.state.ticket(number, tip=driver_slots.head(slot))
|
|
225
|
+
|
|
210
226
|
|
|
211
227
|
def _restore_if_changed(number: str, slot: str, branch: str, tip: str, config: tuple[Path, bytes],
|
|
212
228
|
runs_again: bool) -> str:
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
2
|
The driver put back these files at their locked versions, in a commit before this call, because the implementer or a fixer had changed them: {restored}.
|
|
3
|
-
A fixer may not change a locked file. When a test in one of these files now fails only because this ticket changed an interface that the test uses, update that file so it works with the new interface: keep what each test asserts, and list the file in `locked`. Else leave the file as it is.
|
|
3
|
+
A fixer may not change a locked file. When a test in one of these files now fails only because this ticket changed an interface that the test uses, update that file so it works with the new interface: keep what each test asserts, and list the file in `locked`. Else leave the file as it is, unless a finding of this correction is on it.
|
|
@@ -231,9 +231,12 @@ def test_a_test_finding_on_a_locked_file_gets_the_test_writer_correction_not_a_f
|
|
|
231
231
|
entry = rig.state()["tickets"]["01"]
|
|
232
232
|
assert (entry["round"], entry["test_writer_sha"]) == (0, rig.calls("01", "test-writer")[1]["sha"])
|
|
233
233
|
assert rig.led("correction in tests/test_01.py, outside the fix rounds: VACUOUS: VACUOUS.")
|
|
234
|
-
# Only a severe finding of kind `test` on a locked file goes to the test-writer
|
|
234
|
+
# Only a severe finding of kind `test` on a locked file goes to the test-writer, and a severe finding of any kind on
|
|
235
|
+
# a locked file of a merged ticket.
|
|
235
236
|
minor, elsewhere = finding("M", "minor", kind="test", file="tests/test_01.py"), finding("E", kind="test")
|
|
236
237
|
assert driver_review.route([vacuous, minor, elsewhere], ["tests/test_01.py"], []) == ([vacuous], [elsewhere])
|
|
238
|
+
gap, aside = finding("G", file="tests/test_00.py"), finding("A", "minor", file="tests/test_00.py")
|
|
239
|
+
assert driver_review.route([gap, aside, elsewhere], [], ["tests/test_00.py"]) == ([gap], [elsewhere])
|
|
237
240
|
|
|
238
241
|
|
|
239
242
|
NEEDS_CODE = "needs production code: the code has no multi-PR view"
|
|
@@ -567,6 +570,76 @@ def test_a_locked_file_with_a_name_that_git_quotes_is_protected_at_review_for_it
|
|
|
567
570
|
assert "assert 1 == 'y'" in on_pr(rig, ACCENT)
|
|
568
571
|
|
|
569
572
|
|
|
573
|
+
# ---------------------------------------------------------------- a ticket that must change a merged ticket's locked file
|
|
574
|
+
|
|
575
|
+
MERGED_LOCKED = "02-merged-locked-file"
|
|
576
|
+
LANDING_RESTORE = "implement-spec: restore the locked files of merged tickets before the landing"
|
|
577
|
+
|
|
578
|
+
|
|
579
|
+
def touches_01(n):
|
|
580
|
+
"""Fixer `n` of 02, which also changes tests/test_01.py, the locked file of merged ticket 01."""
|
|
581
|
+
return fix("02", n, files={"demo/export.py": f"def fn_02():\n return 'fix{n}'\n",
|
|
582
|
+
"tests/test_01.py": LOCKED_01 + f"# fix {n}\n"})
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
def changed_at_round_4(tmp_path, name, files=None, gate=None):
|
|
586
|
+
"""Ticket 02 whose fixer of round 4 changes the locked file of merged ticket 01: the review after it finds the
|
|
587
|
+
change, and with no round left it is a `finding` question, which the operator accepts."""
|
|
588
|
+
steps = plan(**{"02/reviewer": [review("02", [STUCK])] * 4 + [review("02")],
|
|
589
|
+
"02/fixer": [fix("02", 1), fix("02", 2), fix("02", 3), touches_01(4)]})
|
|
590
|
+
rig = Inside(under(tmp_path, name), files or three(), gate=gate).run(steps, parallel="1")
|
|
591
|
+
assert rig.code == 1 and asked(rig) == {"02-finding-1": ["accept", "split", "redesign"]}, rig.ledger()
|
|
592
|
+
assert rig.state()["run"]["questions"][0]["subject"].startswith("the ticket changed the locked file of a merged ticket")
|
|
593
|
+
return rig.run(steps, "--answer", "02-finding-1=accept", parallel="1"), steps
|
|
594
|
+
|
|
595
|
+
|
|
596
|
+
def test_an_accepted_change_to_a_merged_ticket_locked_file_asks_at_the_landing_and_restore_lands_it(tmp_path):
|
|
597
|
+
"""Issue #116, comment 1: `accept` sent the ticket to its landing, which the landing check refused with no
|
|
598
|
+
question, so no answer could merge it."""
|
|
599
|
+
rig, steps = changed_at_round_4(tmp_path, "restore")
|
|
600
|
+
assert rig.code == 2 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
601
|
+
assert rig.led("Ticket 02: BLOCKED at the merge: locked file changed: tests/test_01.py.")
|
|
602
|
+
assert asked(rig) == {f"{MERGED_LOCKED}-1": ["restore", "adopt", "redesign"]}
|
|
603
|
+
question = [q for q in rig.state()["run"]["questions"] if q["answer"] is None][0]
|
|
604
|
+
assert question["recommended"] == "restore" and question["subject"] == "tests/test_01.py"
|
|
605
|
+
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=restore", parallel="1")
|
|
606
|
+
assert rig.code == 0, rig.ledger()
|
|
607
|
+
assert on_pr(rig, "tests/test_01.py") == LOCKED_01 and LANDING_RESTORE in rig.pr_subjects()
|
|
608
|
+
assert rig.led("Ticket 02: by the ruling (restore), the driver put back tests/test_01.py")
|
|
609
|
+
assert rig.state()["tickets"]["02"]["phase"] == "merged"
|
|
610
|
+
|
|
611
|
+
|
|
612
|
+
def test_adopt_lands_the_change_to_the_merged_ticket_locked_file_and_the_ticket_locks_it(tmp_path):
|
|
613
|
+
rig, steps = changed_at_round_4(tmp_path, "adopt")
|
|
614
|
+
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=adopt", parallel="1")
|
|
615
|
+
assert rig.code == 0, rig.ledger()
|
|
616
|
+
assert on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 4\n"
|
|
617
|
+
assert "tests/test_01.py" in rig.state()["tickets"]["02"]["locked"] and rig.led("by the ruling (adopt)")
|
|
618
|
+
|
|
619
|
+
|
|
620
|
+
def test_redesign_keeps_the_ticket_blocked_at_its_landing(tmp_path):
|
|
621
|
+
rig, steps = changed_at_round_4(tmp_path, "redesign")
|
|
622
|
+
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=redesign", parallel="1")
|
|
623
|
+
assert rig.code == 1 and rig.state()["tickets"]["02"]["phase"] == "blocked", rig.ledger()
|
|
624
|
+
assert on_pr(rig, "tests/test_01.py") == LOCKED_01 and not asked(rig)
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
def test_a_restore_that_turns_the_merge_gate_red_is_taken_back_and_asks_again_without_restore(tmp_path):
|
|
628
|
+
"""The ticket's code needs its change to the file: the restore commit leaves the ticket branch and the question
|
|
629
|
+
comes back with the options left, so the stop still has an answer."""
|
|
630
|
+
two = {name: text for name, text in three().items() if not name.startswith("03")} # 02 lands as a fast-forward
|
|
631
|
+
rig, steps = changed_at_round_4(tmp_path, "red", files=two, gate={"subjects": [LANDING_RESTORE]})
|
|
632
|
+
rig.run(steps, "--answer", f"{MERGED_LOCKED}-1=restore", parallel="1")
|
|
633
|
+
assert rig.code == 2 and rig.led("Ticket 02: BLOCKED at the merge: the gate is red on"), rig.ledger()
|
|
634
|
+
assert asked(rig) == {f"{MERGED_LOCKED}-2": ["adopt", "redesign"]}
|
|
635
|
+
question = [q for q in rig.state()["run"]["questions"] if q["answer"] is None][0]
|
|
636
|
+
assert question["recommended"] == "adopt" and question["evidence"][0].endswith(".log")
|
|
637
|
+
fixer = rig.calls("02", "fixer")[-1]["sha"]
|
|
638
|
+
assert rig.state()["tickets"]["02"]["tip"] == fixer and on_pr(rig, "tests/test_01.py") == LOCKED_01
|
|
639
|
+
rig.run(steps, "--answer", f"{MERGED_LOCKED}-2=adopt", parallel="1")
|
|
640
|
+
assert rig.code == 0 and on_pr(rig, "tests/test_01.py") == LOCKED_01 + "# fix 4\n", rig.ledger()
|
|
641
|
+
|
|
642
|
+
|
|
570
643
|
# ---------------------------------------------------------------- the rounds
|
|
571
644
|
|
|
572
645
|
def test_four_rounds_then_blocked_with_the_escalation_at_round_3(tmp_path):
|
|
@@ -916,9 +989,10 @@ def conflict(tmp_path, resolve):
|
|
|
916
989
|
"""01 and 03 both add demo/cli.py and 03 merges first (as test_review.conflicted); `resolve` is 01's conflict step."""
|
|
917
990
|
rig = Inside(tmp_path, {k: v for k, v in three().items() if not k.startswith("02")})
|
|
918
991
|
one = impl("01", files={"demo/export.py": "def fn_01():\n return '01'\n", "demo/cli.py": test_review.cli("one")})
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
992
|
+
rig.steps = plan(**{"01/test-writer": [{**tw("01"), "touch": ["s1"]}], "01/conflict": [resolve, resolve],
|
|
993
|
+
"03/implementer": [{**impl("03", "demo/cli.py", test_review.cli("three")), "wait": ["s1"]}],
|
|
994
|
+
"01/implementer": [{**one, "wait_pr_moves": True}]})
|
|
995
|
+
return rig.run(rig.steps)
|
|
922
996
|
|
|
923
997
|
|
|
924
998
|
def test_a_conflict_resolution_that_changes_a_locked_file_does_not_land(tmp_path):
|
|
@@ -935,9 +1009,13 @@ def test_a_conflict_resolution_that_changes_a_locked_file_of_a_merged_ticket_doe
|
|
|
935
1009
|
rig = conflict(tmp_path, {"files": {"demo/cli.py": test_review.cli("resolved"), "tests/test_03.py": WEAK},
|
|
936
1010
|
"commit": "merge: resolve cli", "report": done})
|
|
937
1011
|
# The resolution is a commit of the ticket; the landing check refuses the tree that it would put on the PR branch.
|
|
938
|
-
assert "BLOCKED at the merge: locked file changed: tests/test_03.py."
|
|
1012
|
+
assert rig.code == 2 and rig.led("Ticket 01: BLOCKED at the merge: locked file changed: tests/test_03.py."), rig.ledger()
|
|
1013
|
+
assert asked(rig) == {"01-merged-locked-file-1": ["restore", "adopt", "redesign"]}
|
|
939
1014
|
assert rig.tip() == rig.sha("03", "implementer") and on_pr(rig, "tests/test_03.py") == tw("03")["files"]["tests/test_03.py"]
|
|
940
1015
|
assert rig.state()["tickets"]["01"]["tip"] == rig.calls("01", "conflict")[0]["sha"]
|
|
1016
|
+
rig.run(rig.steps, "--answer", "01-merged-locked-file-1=restore")
|
|
1017
|
+
assert rig.code == 0 and on_pr(rig, "tests/test_03.py") == tw("03")["files"]["tests/test_03.py"], rig.ledger()
|
|
1018
|
+
assert on_pr(rig, "demo/cli.py") == test_review.cli("resolved") and len(rig.calls("01", "conflict")) == 1
|
|
941
1019
|
|
|
942
1020
|
|
|
943
1021
|
def test_a_conflict_agent_that_gives_up_leaves_no_open_merge_in_the_slot(tmp_path):
|
|
@@ -5,8 +5,9 @@ and test_final), and through two worktrees of one fixture repository, on two PR
|
|
|
5
5
|
files and with `wait_pr_moves`, never with a sleep.
|
|
6
6
|
|
|
7
7
|
Interface choices (ticket 09):
|
|
8
|
-
- a ticket that "does not land" ends the run with
|
|
9
|
-
`locked file changed: <path
|
|
8
|
+
- a ticket that "does not land" ends the run with phase `blocked`; one ledger sentence names the ticket and
|
|
9
|
+
`locked file changed: <path>`, and a `merged-locked-file` question (exit 2) names the path (issue #116); no commit of
|
|
10
|
+
the ticket is on the PR branch. Whether a fix round ran before is free:
|
|
10
11
|
each plan gives that ticket fixers that write no report.
|
|
11
12
|
- an implementer "merges the PR branch" with the `git` hook of the fake runner: `git merge --no-edit feat/csv` in its
|
|
12
13
|
slot, after `wait_pr_moves`, before it writes its files and commits.
|
|
@@ -61,18 +62,20 @@ def holds(rig, sha, commit="feat/csv"):
|
|
|
61
62
|
return subprocess.run(["git", "merge-base", "--is-ancestor", sha, commit], cwd=rig.repo).returncode == 0
|
|
62
63
|
|
|
63
64
|
|
|
64
|
-
def kept_out(rig, nn):
|
|
65
|
-
"""Ticket `nn` did not land: the run ends with
|
|
66
|
-
assert rig.code
|
|
65
|
+
def kept_out(rig, nn, codes=(1,)):
|
|
66
|
+
"""Ticket `nn` did not land: the run ends with one of `codes` and the PR branch has none of its commits."""
|
|
67
|
+
assert rig.code in codes, rig.output()
|
|
67
68
|
assert phase(rig, nn) == "blocked"
|
|
68
69
|
assert not {f"test: {nn} red", f"feat: {nn} rows"} & set(rig.pr_subjects()), rig.pr_subjects()
|
|
69
70
|
assert not any(holds(rig, c["sha"]) for c in rig.calls(nn) if c["sha"])
|
|
70
71
|
|
|
71
72
|
|
|
72
73
|
def refused(rig, nn, path):
|
|
73
|
-
"""The landing of ticket `nn` was refused for the locked file `path` of a merged ticket."""
|
|
74
|
-
kept_out(rig, nn)
|
|
74
|
+
"""The landing of ticket `nn` was refused for the locked file `path` of a merged ticket, with a question."""
|
|
75
|
+
kept_out(rig, nn, codes=(2,))
|
|
75
76
|
assert rig.led(nn, f"locked file changed: {path}"), rig.ledger()
|
|
77
|
+
(question,) = [q for q in rig.state()["run"]["questions"] if q["answer"] is None]
|
|
78
|
+
assert (question["id"], question["subject"]) == (f"{nn}-merged-locked-file-1", path)
|
|
76
79
|
|
|
77
80
|
|
|
78
81
|
def restored(rig, nn, path):
|
|
@@ -238,8 +241,8 @@ def test_a_ticket_that_lands_while_the_merge_gate_of_another_is_open_does_not_le
|
|
|
238
241
|
if phase(rig, "03") == "merged": # 03 landed first, when no merged ticket had locked the file
|
|
239
242
|
assert rig.code == 0, rig.output()
|
|
240
243
|
assert landed(rig, rig.sha("03", "implementer")) < landed(rig, rig.sha("02", "test-writer")), rig.ledger()
|
|
241
|
-
else: # 02 landed in the window: the driver looked again, or it gave the stale merge commit up
|
|
242
|
-
kept_out(rig, "03")
|
|
244
|
+
else: # 02 landed in the window: the driver looked again (a question), or it gave the stale merge commit up
|
|
245
|
+
kept_out(rig, "03", codes=(1, 2))
|
|
243
246
|
assert on_pr(rig, SHARED) == MORE_SEED
|
|
244
247
|
|
|
245
248
|
|
|
@@ -96,20 +96,20 @@ def test_the_landing_check_refuses_what_it_cannot_read(repo, monkeypatch):
|
|
|
96
96
|
sh("git", "branch", "ticket/02")
|
|
97
97
|
same = commit_on("ticket/02", "a.txt", "a\n")
|
|
98
98
|
tickets = {"01": {"phase": "merged", "locked": ["t.py", "gone.py"]}, "02": {"phase": "merge", "locked": []}}
|
|
99
|
-
assert driver_merge.refused(tickets, "02", base, same) == "" # absent on both sides of two commits that exist
|
|
99
|
+
assert driver_merge.refused(tickets, "02", base, same) == ([], "") # absent on both sides of two commits that exist
|
|
100
100
|
there = commit_on("ticket/02", "t.py", "t\n")
|
|
101
|
-
assert driver_merge.refused(tickets, "02", base, there) == "
|
|
102
|
-
assert driver_merge.refused(tickets, "02", there, base) == "
|
|
101
|
+
assert driver_merge.refused(tickets, "02", base, there) == (["t.py"], "")
|
|
102
|
+
assert driver_merge.refused(tickets, "02", there, base) == (["t.py"], "")
|
|
103
103
|
# A candidate that is no commit: an id that does not resolve, and a tree.
|
|
104
104
|
for bad in ("1" * 40, sh("git", "rev-parse", f"{base}^{{tree}}")):
|
|
105
|
-
assert driver_merge.refused(tickets, "02", base, bad).startswith(f"cannot read the locked files at {bad}: ")
|
|
106
|
-
assert driver_merge.refused(tickets, "02", bad, base).startswith(f"cannot read the locked files at {bad}: ")
|
|
105
|
+
assert driver_merge.refused(tickets, "02", base, bad)[1].startswith(f"cannot read the locked files at {bad}: ")
|
|
106
|
+
assert driver_merge.refused(tickets, "02", bad, base)[1].startswith(f"cannot read the locked files at {bad}: ")
|
|
107
107
|
# A record with no `locked` key is a ticket that locked nothing: no error in the middle of a landing.
|
|
108
108
|
assert driver_merge.protected({"01": {"phase": "merged"}, "02": {"phase": "merge"}}, "02") == []
|
|
109
109
|
assert driver_merge.protected({"01": {"phase": "merged", "locked": ["a"]}}, "02") == ["a"]
|
|
110
110
|
# git fails on both sides: the two answers are equal, and the landing is refused all the same.
|
|
111
111
|
monkeypatch.setenv("GIT_DIR", "/nowhere")
|
|
112
|
-
assert driver_merge.refused(tickets, "02", base, there).startswith(f"cannot read the locked files at {base}: ")
|
|
112
|
+
assert driver_merge.refused(tickets, "02", base, there)[1].startswith(f"cannot read the locked files at {base}: ")
|
|
113
113
|
monkeypatch.delenv("GIT_DIR")
|
|
114
114
|
assert driver_merge.land("pr", there, "1" * 40) != "" and sh("git", "rev-parse", "pr") == base
|
|
115
115
|
|
|
@@ -125,9 +125,9 @@ def test_the_landing_check_compares_the_mode_and_the_type_of_a_locked_file_too(r
|
|
|
125
125
|
link = commit_on("ticket/02", "t.py", "", lambda path: (os.remove(path), os.symlink("t\n", path)))
|
|
126
126
|
blob = lambda commit: sh("git", "rev-parse", f"{commit}:t.py")
|
|
127
127
|
assert blob(file) == blob(runs) == blob(link) and sh("git", "ls-tree", link, "t.py").startswith("120000 ")
|
|
128
|
-
assert driver_merge.refused(tickets, "02", file, file) == ""
|
|
129
|
-
assert driver_merge.refused(tickets, "02", file, runs) == "
|
|
130
|
-
assert driver_merge.refused(tickets, "02", file, link) == "
|
|
128
|
+
assert driver_merge.refused(tickets, "02", file, file) == ([], "")
|
|
129
|
+
assert driver_merge.refused(tickets, "02", file, runs) == (["t.py"], "")
|
|
130
|
+
assert driver_merge.refused(tickets, "02", file, link) == (["t.py"], "")
|
|
131
131
|
|
|
132
132
|
|
|
133
133
|
def test_begin_opens_the_conflicting_merge_on_a_machine_with_no_git_identity(repo, monkeypatch, 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-20T17:59:20.836Z",
|
|
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.35",
|
|
50
|
+
"hash": "sha256-4e94140abbc0dc964ec2dc9c0fbb0e5c4bb4a8e11d1e4c4bbd278c5321223fd6",
|
|
51
51
|
"description": "Implement a specification in code."
|
|
52
52
|
},
|
|
53
53
|
{
|