@jesdi/skills 0.0.62 → 0.0.64
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/README.md +15 -0
- package/package.json +2 -2
- package/skills/babysit-pr/SKILL.md +54 -0
- package/skills/babysit-pr/babysit.py +998 -0
- package/skills/babysit-pr/fixtures/gh +310 -0
- package/skills/babysit-pr/hooks/post-pr-create.sh +56 -0
- package/skills/babysit-pr/hooks.json +10 -0
- package/skills/babysit-pr/judge-prompt.md +10 -0
- package/skills/babysit-pr/test_babysit.py +242 -0
- package/skills/babysit-pr/test_babysit_judge.py +286 -0
- package/skills/babysit-pr/test_babysit_judge_diff.py +25 -0
- package/skills/babysit-pr/test_babysit_judge_isolation.py +61 -0
- package/skills/babysit-pr/test_checks_regressions.py +210 -0
- package/skills/babysit-pr/test_comment_fidelity.py +88 -0
- package/skills/babysit-pr/test_comment_identity.py +70 -0
- package/skills/babysit-pr/test_e2e_setup.py +74 -0
- package/skills/babysit-pr/test_handoff_takeover.py +141 -0
- package/skills/babysit-pr/test_handoff_terminal.py +29 -0
- package/skills/babysit-pr/test_hook_quoting.py +25 -0
- package/skills/babysit-pr/test_hooks.py +62 -0
- package/skills/babysit-pr/test_lease_regressions.py +198 -0
- package/skills/babysit-pr/test_merge_and_handoff.py +260 -0
- package/skills/babysit-pr/test_merge_base_pin.py +10 -0
- package/skills/babysit-pr/test_merge_gate.py +124 -0
- package/skills/babysit-pr/test_merge_session_safety.py +117 -0
- package/skills/babysit-pr/test_merged_pr_labels.py +144 -0
- package/skills/babysit-pr/test_owner_comment_edits.py +26 -0
- package/skills/babysit-pr/test_owner_comments.py +316 -0
- package/skills/babysit-pr/test_retry_and_stall_hardening.py +143 -0
- package/skills/babysit-pr/test_rounds_and_checks.py +305 -0
- package/skills/babysit-pr/test_terminal_label_regressions.py +117 -0
- package/skills/babysit-pr/test_trusted_merge_risk.py +184 -0
- package/skills/babysit-pr/test_update_plan.py +157 -0
- package/skills/implement-spec/ARCHITECTURE.md +5 -0
- package/skills/implement-spec/README.md +7 -6
- package/skills/implement-spec/SKILL.md +1 -1
- package/skills/implement-spec/driver.py +11 -1
- package/skills/implement-spec/driver_decisions.py +23 -0
- package/skills/implement-spec/driver_final.py +49 -10
- package/skills/implement-spec/driver_fixloop.py +17 -5
- package/skills/implement-spec/driver_report.py +16 -5
- package/skills/implement-spec/driver_state.py +2 -2
- package/skills/implement-spec/prompts/pr-writer.md +3 -2
- package/skills/implement-spec/prompts/rejected.md +1 -0
- package/skills/implement-spec/tests/test_decisions.py +57 -0
- package/skills/implement-spec/tests/test_final.py +112 -1
- package/skills/implement-spec/tests/test_fixloop.py +14 -2
- package/skills/implement-spec/tests/test_report.py +18 -0
- package/skills/implement-spec/tests/test_review.py +1 -1
- package/skills/implement-spec/tests/test_state.py +1 -1
- package/skills/implement-spec/tests/test_tidy.py +2 -2
- package/skills/implement-spec/tests/test_walk.py +2 -2
- package/skills/pr-risk/SKILL.md +33 -0
- package/skills/pr-risk/hooks/pre-pr-create.sh +274 -0
- package/skills/pr-risk/hooks.json +10 -0
- package/skills/pr-risk/merge_policy.py +81 -0
- package/skills/pr-risk/merge_risk.py +314 -0
- package/skills/pr-risk/test_hook_commands.py +47 -0
- package/skills/pr-risk/test_hook_heredoc.py +16 -0
- package/skills/pr-risk/test_hook_substitution.py +40 -0
- package/skills/pr-risk/test_hooks.py +175 -0
- package/skills/pr-risk/test_merge_risk.py +97 -0
- package/skills/pr-risk/test_merge_risk_gate.py +217 -0
- package/skills/pr-risk/test_merge_risk_regressions.py +37 -0
- package/skills/pr-risk/test_merge_risk_structure.py +101 -0
- package/skills-manifest.json +15 -3
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""Acceptance tests for `babysit.py update-plan --base <ref>`.
|
|
2
|
+
|
|
3
|
+
Interface under test (run with the PR branch checked out, cwd = the clone):
|
|
4
|
+
babysit.py update-plan --base <ref>
|
|
5
|
+
Prints one JSON object on stdout, exit 0:
|
|
6
|
+
plan "rebase" | "rebase-with-conflict" | "merge"
|
|
7
|
+
compare the ref compared against, e.g. "origin/main"
|
|
8
|
+
push the push command: rebase plans use
|
|
9
|
+
`git push --force-with-lease=<branch>:<old sha> origin <branch>`;
|
|
10
|
+
the merge plan pushes without any force flag
|
|
11
|
+
files conflicting files (rebase-with-conflict only)
|
|
12
|
+
It never changes the worktree, the index, HEAD or any ref.
|
|
13
|
+
"""
|
|
14
|
+
import json
|
|
15
|
+
import subprocess
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
SCRIPT = Path(__file__).with_name("babysit.py").resolve()
|
|
19
|
+
BRANCH = "feat/x"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def git(cwd, *args):
|
|
23
|
+
return subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True, text=True,
|
|
24
|
+
env={"GIT_AUTHOR_NAME": "t", "GIT_AUTHOR_EMAIL": "t@t",
|
|
25
|
+
"GIT_COMMITTER_NAME": "t", "GIT_COMMITTER_EMAIL": "t@t",
|
|
26
|
+
"PATH": "/usr/bin:/bin:/usr/local/bin:/opt/homebrew/bin",
|
|
27
|
+
"HOME": str(cwd)}).stdout.strip()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def commit(cwd, path, text, msg):
|
|
31
|
+
f = Path(cwd) / path
|
|
32
|
+
f.parent.mkdir(parents=True, exist_ok=True)
|
|
33
|
+
f.write_text(text)
|
|
34
|
+
git(cwd, "add", path)
|
|
35
|
+
git(cwd, "commit", "-m", msg)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Repo:
|
|
39
|
+
"""origin (bare) + clone `work`, with main history that already touched src/parse.py twice."""
|
|
40
|
+
|
|
41
|
+
def __init__(self, tmp):
|
|
42
|
+
self.origin = tmp / "origin.git"
|
|
43
|
+
self.work = tmp / "work"
|
|
44
|
+
git(tmp, "init", "--bare", "-b", "main", str(self.origin))
|
|
45
|
+
git(tmp, "clone", str(self.origin), str(self.work))
|
|
46
|
+
git(self.work, "checkout", "-b", "main")
|
|
47
|
+
commit(self.work, "src/parse.py", "a\nb\nc\n", "old 1")
|
|
48
|
+
commit(self.work, "src/parse.py", "a\nb\nc\nd\n", "old 2")
|
|
49
|
+
git(self.work, "push", "origin", "main")
|
|
50
|
+
git(self.work, "checkout", "-b", BRANCH)
|
|
51
|
+
|
|
52
|
+
def branch_commits(self, n, path="src/parse.py"):
|
|
53
|
+
for i in range(n):
|
|
54
|
+
commit(self.work, path, f"X{i}\nb\nc\nd\n", f"branch {i}")
|
|
55
|
+
git(self.work, "push", "origin", BRANCH)
|
|
56
|
+
|
|
57
|
+
def advance(self, branch, n, path="other.txt", text=None):
|
|
58
|
+
git(self.work, "checkout", branch)
|
|
59
|
+
for i in range(n):
|
|
60
|
+
commit(self.work, path, text or f"base {i}\n", f"{branch} {i}")
|
|
61
|
+
git(self.work, "push", "origin", branch)
|
|
62
|
+
git(self.work, "checkout", BRANCH)
|
|
63
|
+
|
|
64
|
+
def plan(self, base="main"):
|
|
65
|
+
git(self.work, "fetch", "origin")
|
|
66
|
+
r = subprocess.run(["python3", str(SCRIPT), "update-plan", "--base", base],
|
|
67
|
+
cwd=self.work, capture_output=True, text=True)
|
|
68
|
+
assert r.returncode == 0, r.stdout + r.stderr
|
|
69
|
+
return json.loads(r.stdout)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def test_new_base_commits_without_conflict_plan_rebase(tmp_path):
|
|
73
|
+
r = Repo(tmp_path)
|
|
74
|
+
r.branch_commits(1)
|
|
75
|
+
r.advance("main", 3)
|
|
76
|
+
old = git(r.work, "rev-parse", "HEAD")
|
|
77
|
+
p = r.plan()
|
|
78
|
+
assert p["plan"] == "rebase"
|
|
79
|
+
assert p["push"] == f"git push --force-with-lease={BRANCH}:{old} origin {BRANCH}"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def test_conflict_in_two_branch_commits_plans_rebase_with_conflict(tmp_path):
|
|
83
|
+
r = Repo(tmp_path)
|
|
84
|
+
r.branch_commits(2)
|
|
85
|
+
r.advance("main", 1, "src/parse.py", "M\nb\nc\nd\n")
|
|
86
|
+
p = r.plan()
|
|
87
|
+
assert p["plan"] == "rebase-with-conflict"
|
|
88
|
+
assert "src/parse.py" in p["files"]
|
|
89
|
+
assert "--force-with-lease=" in p["push"]
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def test_conflict_in_three_branch_commits_plans_merge(tmp_path):
|
|
93
|
+
r = Repo(tmp_path)
|
|
94
|
+
r.branch_commits(3)
|
|
95
|
+
r.advance("main", 1, "src/parse.py", "M\nb\nc\nd\n")
|
|
96
|
+
p = r.plan()
|
|
97
|
+
assert p["plan"] == "merge"
|
|
98
|
+
assert p["compare"] == "origin/main"
|
|
99
|
+
assert "force" not in p["push"]
|
|
100
|
+
assert p["push"].endswith(f"origin {BRANCH}")
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def test_update_plan_leaves_worktree_index_and_head_unchanged(tmp_path):
|
|
104
|
+
r = Repo(tmp_path)
|
|
105
|
+
r.branch_commits(2)
|
|
106
|
+
r.advance("main", 1, "src/parse.py", "M\nb\nc\nd\n")
|
|
107
|
+
(r.work / "src/parse.py").write_text("dirty\n")
|
|
108
|
+
(r.work / "untracked.txt").write_text("u\n")
|
|
109
|
+
(r.work / "staged.txt").write_text("s\n")
|
|
110
|
+
git(r.work, "add", "staged.txt")
|
|
111
|
+
git(r.work, "fetch", "origin")
|
|
112
|
+
before = (git(r.work, "status", "--porcelain"), git(r.work, "rev-parse", "HEAD"),
|
|
113
|
+
git(r.work, "for-each-ref"), git(r.work, "diff", "--cached"),
|
|
114
|
+
(r.work / "src/parse.py").read_text())
|
|
115
|
+
p = r.plan()
|
|
116
|
+
assert p["plan"] == "rebase-with-conflict"
|
|
117
|
+
after = (git(r.work, "status", "--porcelain"), git(r.work, "rev-parse", "HEAD"),
|
|
118
|
+
git(r.work, "for-each-ref"), git(r.work, "diff", "--cached"),
|
|
119
|
+
(r.work / "src/parse.py").read_text())
|
|
120
|
+
assert after == before
|
|
121
|
+
assert not (r.work / ".git" / "MERGE_HEAD").exists()
|
|
122
|
+
assert not (r.work / ".git" / "rebase-merge").exists()
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def test_base_feat_parent_compares_with_origin_feat_parent(tmp_path):
|
|
126
|
+
r = Repo(tmp_path)
|
|
127
|
+
r.branch_commits(1)
|
|
128
|
+
# main would conflict with the branch; the parent does not
|
|
129
|
+
r.advance("main", 1, "src/parse.py", "M\nb\nc\nd\n")
|
|
130
|
+
git(r.work, "checkout", "-b", "feat/parent", "origin/main~1")
|
|
131
|
+
git(r.work, "push", "origin", "feat/parent")
|
|
132
|
+
git(r.work, "checkout", BRANCH)
|
|
133
|
+
r.advance("feat/parent", 1)
|
|
134
|
+
p = r.plan("feat/parent")
|
|
135
|
+
assert p["compare"] == "origin/feat/parent"
|
|
136
|
+
assert p["plan"] == "rebase"
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def test_commits_across_two_conflicting_files_are_counted_as_a_union(tmp_path):
|
|
140
|
+
r = Repo(tmp_path)
|
|
141
|
+
git(r.work, "checkout", "main")
|
|
142
|
+
commit(r.work, "a.py", "a\nb\nc\n", "add a")
|
|
143
|
+
commit(r.work, "b.py", "a\nb\nc\n", "add b")
|
|
144
|
+
git(r.work, "push", "origin", "main")
|
|
145
|
+
git(r.work, "checkout", BRANCH)
|
|
146
|
+
git(r.work, "merge", "--ff-only", "main")
|
|
147
|
+
commit(r.work, "a.py", "A1\nb\nc\n", "branch a1")
|
|
148
|
+
commit(r.work, "a.py", "A2\nb\nc\n", "branch a2")
|
|
149
|
+
commit(r.work, "b.py", "B1\nb\nc\n", "branch b1")
|
|
150
|
+
git(r.work, "push", "origin", BRANCH)
|
|
151
|
+
git(r.work, "checkout", "main")
|
|
152
|
+
commit(r.work, "a.py", "M\nb\nc\n", "main a")
|
|
153
|
+
commit(r.work, "b.py", "M\nb\nc\n", "main b")
|
|
154
|
+
git(r.work, "push", "origin", "main")
|
|
155
|
+
git(r.work, "checkout", BRANCH)
|
|
156
|
+
p = r.plan()
|
|
157
|
+
assert p["plan"] == "merge"
|
|
@@ -152,6 +152,9 @@ and do not know about the run, except `driver_run.py`, which the three deciding
|
|
|
152
152
|
- A reviewer or a correctness pass that reports BLOCKED or NEEDS_CONTEXT raises `driver_run.Stopped`, which
|
|
153
153
|
carries the report. `driver_fixloop._run_reviewers` turns it into a `review-stopped` question, or, after an
|
|
154
154
|
`accept` ruling on that role (`driver_decisions.accepted`), uses the report as it is.
|
|
155
|
+
- A reviewer or a correctness pass whose report the driver rejects two times asks a `review-rejected` question.
|
|
156
|
+
The stop records each rejection in the ticket's `rejected` (role -> why); after `retry`, the role's first prompt
|
|
157
|
+
carries it (`prompts/rejected.md`), and the next review that ends clears it.
|
|
155
158
|
- An implementer or a fixer that reports BLOCKED or NEEDS_CONTEXT asks a question in `Run._ask_stop`: `locked-test`
|
|
156
159
|
for a contradicted locked test, else `implementer-stopped` or `fixer-stopped`. The stop of a fixer sets the round
|
|
157
160
|
back by one, so its `retry` (gate and review the tip, then a fixer) runs the same round again.
|
|
@@ -165,6 +168,8 @@ and do not know about the run, except `driver_run.py`, which the three deciding
|
|
|
165
168
|
|
|
166
169
|
- A stop is a bounded question in `state.json`. Only `driver_decisions.stop` adds one. An answered question is
|
|
167
170
|
never open again.
|
|
171
|
+
- An open question of a merged ticket is dropped (`driver_decisions.drop_merged`), at the start of a run and after
|
|
172
|
+
each landing, with a ledger line: a ticket the operator set to `merge` by hand leaves its stop behind.
|
|
168
173
|
- An answers file counts only when it is bound to the revision of the current `decisions.json`.
|
|
169
174
|
- Only a question whose kind parks gives exit 2. A third round of the final review is never started: its open
|
|
170
175
|
findings become questions.
|
|
@@ -57,7 +57,7 @@ Default timeouts in minutes: explorer 30, test-writer 30, implementer 90, review
|
|
|
57
57
|
|---|---|
|
|
58
58
|
| 0 | Done: every ticket is merged and no question is open. Also the end of a valid `--dry-run`. In local mode without `--push`, nothing is pushed. |
|
|
59
59
|
| 1 | A ticket is BLOCKED, or the end of run is BLOCKED. The other tickets ran as far as they could. |
|
|
60
|
-
| 2 | Parked: a question of kind `locked-test`, `locked-test-again`, `review-stopped`, `implementer-stopped`, `fixer-stopped`, `merged-locked-file` or `final-finding` is open. Exit 2 wins over exit 1. |
|
|
60
|
+
| 2 | Parked: a question of kind `locked-test`, `locked-test-again`, `review-stopped`, `review-rejected`, `implementer-stopped`, `fixer-stopped`, `merged-locked-file` or `final-finding` is open. Exit 2 wins over exit 1. |
|
|
61
61
|
| 3 | Invalid input or a failed precondition: a usage error, a ticket error, a model error, an uncommitted change, a slot that cannot be made, another driver that runs on the same PR branch. No agent starts. The one exception: a review page that cannot be written gives exit 3 at the end of a run, after agents ran. |
|
|
62
62
|
| 4 | Stopped: the CLI of an agent failed two times and wrote no report (for example, the account cannot use the model). The driver starts no other agent and lets the running agents end. No ticket is BLOCKED by it: fix the CLI or the model entry, then run the same command again to resume. |
|
|
63
63
|
| 130 | The operator interrupted the run. The driver stops each agent. The work stays in the slots for the next run. |
|
|
@@ -111,7 +111,7 @@ Rules for each agent:
|
|
|
111
111
|
- A call blocks until the agent ends. The driver does not poll.
|
|
112
112
|
- An agent stops only the processes it started and their child processes, by PID, and never kills a process it did not start, nor uses `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. A process it did not start that blocks it goes into its concerns.
|
|
113
113
|
- An agent gets one rerun: after a rejected report, after a timeout, or after it left the ticket branch. The rerun prompt is the first prompt plus the reason.
|
|
114
|
-
- A report with status `BLOCKED` or `NEEDS_CONTEXT` blocks the ticket. From the reviewer or the correctness pass, it also asks a `review-stopped` question; from the implementer or a fixer, a `locked-test` question when a concern starts with `locked test contradicts spec:`, else an `implementer-stopped` or `fixer-stopped` question. Nothing left to change is no stop: the implementer and the fixer report it as DONE with no commit.
|
|
114
|
+
- A report with status `BLOCKED` or `NEEDS_CONTEXT` blocks the ticket. From the reviewer or the correctness pass, it also asks a `review-stopped` question, and a report of theirs that the driver rejects two times asks a `review-rejected` question; from the implementer or a fixer, a `locked-test` question when a concern starts with `locked test contradicts spec:`, else an `implementer-stopped` or `fixer-stopped` question. Nothing left to change is no stop: the implementer and the fixer report it as DONE with no commit.
|
|
115
115
|
- A BLOCKED ticket stops the tickets that it blocks. All other tickets run on.
|
|
116
116
|
|
|
117
117
|
### Findings and fix rounds
|
|
@@ -140,7 +140,7 @@ The end of run starts only when every ticket is merged and every slot is idle. I
|
|
|
140
140
|
3. **Gate**, then the **final-reviewer** (`prompts/final-reviewer.md`) on the whole range, with the method of the `review-diff` skill. It gets the minor findings of the tickets and the rulings of the operator.
|
|
141
141
|
4. **Fix batch.** Critical and important findings go to one fixer (`prompts/final-fixer.md`). The driver names each of its commits `fix(NN): …` from the ticket in the report. Then the gate, then one scoped review of those commits.
|
|
142
142
|
5. Findings that are open after the second review become questions of kind `final-finding`. There is no third review.
|
|
143
|
-
6. **Push.** With `--push` or `--unattended`, the driver pushes the reviewed tip once, with no force, and opens the PR with `gh`, ready for review. The **pr-writer** (`prompts/pr-writer.md`) writes the body with the method of the `pr` skill; the driver puts the facts of the run after it: the ticket-to-commit map, the fix commits, the rulings and the review coverage (`prompts/pr-body.md`). A push stops before any agent when no `pr` skill is next to this skill, in `${CLAUDE_CONFIG_DIR:-~/.claude}/skills` or in `~/.agents/skills`. Without them it prints the two tips and the command to run again with `--push`.
|
|
143
|
+
6. **Push.** With `--push` or `--unattended`, the driver pushes the reviewed tip once, with no force, and opens the PR with `gh`, ready for review. The **pr-writer** (`prompts/pr-writer.md`) writes the body with the method of the `pr` skill; the driver puts the facts of the run after it: the ticket-to-commit map, the fix commits, the rulings and the review coverage (`prompts/pr-body.md`). The body carries the merge-risk block of the `pr-risk` skill under `## Merge Danger`, above the facts; the driver validates it, runs the pr-writer once more with the errors when it is invalid, and blocks the run, opening no PR, when the second body is invalid too. A push stops before any agent when no `pr` skill or no `pr-risk` skill is next to this skill, in `${CLAUDE_CONFIG_DIR:-~/.claude}/skills` or in `~/.agents/skills`. Without them it prints the two tips and the command to run again with `--push`.
|
|
144
144
|
|
|
145
145
|
History rules:
|
|
146
146
|
|
|
@@ -177,9 +177,9 @@ Every report has `status` (`DONE`, `DONE_WITH_CONCERNS`, `NEEDS_CONTEXT`, `BLOCK
|
|
|
177
177
|
|
|
178
178
|
| Role | Template | More fields | Checks after the schema |
|
|
179
179
|
|---|---|---|---|
|
|
180
|
-
| test-writer | `prompts/test-writer.md` | `locked` (test file paths), `red` (`test`, `line`), optional `fixtures` (each locked file that holds no test, as a fake `gh`) | The driver reads a test node id `<file>::<test>` in `locked` as its file. Each fixture is in `locked`; the ticket record keeps it a fixture until a later correction lists the file again. With DONE: one commit, one locked file and one red line or more. Each locked path is in a commit that the role made
|
|
180
|
+
| test-writer | `prompts/test-writer.md` | `locked` (test file paths), `red` (`test`, `line`), optional `fixtures` (each locked file that holds no test, as a fake `gh`) | The driver reads a test node id `<file>::<test>` in `locked` as its file. Each fixture is in `locked`; the ticket record keeps it a fixture until a later correction lists the file again. With DONE: one commit, one locked file and one red line or more. Each locked path is in a commit that the role made, and is a file at the tip: a correction that deletes a locked file leaves it out of `locked`. Each `line` is in the log. A locked file of a merged ticket that the role changed is in `locked`. A correction (after `overrule-test`, or for a review finding) changes only the files that it lists in `locked` and the files that the driver restored before it. When the gate is red on the restore commit, a DONE correction lists a restored file in `locked`. Each `not_addressed[].finding` is the title of a finding of the correction; a DONE correction with each of its findings there needs no commit. |
|
|
181
181
|
| implementer | `prompts/implementer.md` | `green` | With DONE and no commit: no new commit on the branch, no uncommitted change, and a concern that says why the start needs no change. The driver then gates and reviews the start commit. |
|
|
182
|
-
| reviewer | `prompts/reviewer.md` | `findings` (`severity`, `file`, `line`, `title`, `evidence`, `kind`), `mutations` (`test`, `file`, `line`, `red`) | In a full review (one with no fix range: round 1, and the review after a test-writer correction): `mutations` is required, with a proof for each locked test file (`test` is `<locked file>::<test name>`). A locked fixture needs no proof: it holds no test that a proof could name, and the locked-file check protects it. Each `red` is in the log. |
|
|
182
|
+
| reviewer | `prompts/reviewer.md` | `findings` (`severity`, `file`, `line`, `title`, `evidence`, `kind`), `mutations` (`test`, `file`, `line`, `red`) | In a full review (one with no fix range: round 1, and the review after a test-writer correction): `mutations` is required, with a proof for each locked test file (`test` is `<locked file>::<test name>`). A locked fixture needs no proof: it holds no test that a proof could name, and the locked-file check protects it. Neither does a locked file that is not at the reviewed tip. Each `red` is in the log. |
|
|
183
183
|
| correctness | `prompts/correctness.md` | the same as the reviewer | `mutations` is optional. |
|
|
184
184
|
| fixer | `prompts/fixer.md` | `green`, `ticket` | With DONE and no commit: no new commit on the branch, no uncommitted change, a gate that is green on the start, and a concern that names each finding of the round. |
|
|
185
185
|
| final-reviewer | `prompts/final-reviewer.md` | `findings` | None. |
|
|
@@ -199,12 +199,13 @@ A question is a bounded choice for the operator. `driver_decisions.py` `KINDS` h
|
|
|
199
199
|
| `finding` | `<NN>-finding-<n>` | A finding is open after fix round 4. One question for each finding. | 1 | `accept`: close the finding; the ticket merges when each of its findings is accepted. `split` (recommended) and `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
200
200
|
| `locked-test-again` | `<NN>-locked-test-again-<n>` | A finding for a test-writer correction is open in the review right after a correction, or the driver rejects the correction's report (for example, it changes a file that it does not list in `locked`). One question for each finding. | 2 | `correct-again` (recommended): the ticket resumes from the review, and that review's findings get one more correction. `accept`: no more correction runs for the ticket, its locked tests stay as they are, and the ticket goes on to its fix rounds with its other findings; a changed locked file is still restored. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. After two `correct-again` stops on a ticket, its next question offers only `accept` (recommended) and `redesign`, so a test-writer and a reviewer that never agree cannot loop. |
|
|
201
201
|
| `review-stopped` | `<NN>-review-stopped-<n>` | The reviewer or the correctness pass reports `BLOCKED` or `NEEDS_CONTEXT`. One question for each agent that stopped. | 2 | `retry` (recommended): the ticket resumes from the review, and each agent of the review runs again. `accept`: the same, and for the rest of the ticket a `BLOCKED` or `NEEDS_CONTEXT` report of that agent does not stop it: the review goes on with that report's findings and those of the other reports. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
202
|
+
| `review-rejected` | `<NN>-review-rejected-<n>` | The driver rejects the report of the reviewer or the correctness pass, and the report of its rerun too (for example, no mutation proof for a locked test file). One question for each agent. | 2 | `retry` (recommended): the ticket resumes from the review, each agent of the review runs again, and the first prompt of the rejected agent says why the driver rejected it. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
202
203
|
| `implementer-stopped` | `<NN>-implementer-stopped-<n>` | The implementer reports `BLOCKED` or `NEEDS_CONTEXT`, and no concern starts with `locked test contradicts spec:`. | 2 | `retry` (recommended): the implementer runs again from the tip it left. `accept-tip`: the driver gates and reviews that tip, and the fix rounds close what the review finds. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
203
204
|
| `fixer-stopped` | `<NN>-fixer-stopped-<n>` | A fixer reports `BLOCKED` or `NEEDS_CONTEXT`, and no concern starts with `locked test contradicts spec:`. | 2 | `retry` (recommended): the round that stopped does not count; the driver gates and reviews the tip the fixer left, and a fixer runs that round again on the review's findings. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. |
|
|
204
205
|
| `merged-locked-file` | `<NN>-merged-locked-file-<n>` | The landing check refuses the landing: the tree that would land changes this locked file of a merged ticket. One question for each file. | 2 | `restore` (recommended): the driver puts the file back to the version of the PR branch in a commit of its own on the ticket branch, and the ticket resumes from its landing. `adopt`: the ticket adds the file to its `locked`, so its change lands, and resumes from its landing. `redesign`: the ticket stays BLOCKED, with the ruling in the ledger. When the merge gate is red after `restore` or `adopt`, the driver takes the restore commit back and asks again, without the option that was tried. |
|
|
205
206
|
| `final-finding` | `final-finding-<n>` | A finding is open after the second round of the final review. | 2 | `fix` (recommended): the finding stays open and nothing is pushed. `accept`: close the finding. |
|
|
206
207
|
|
|
207
|
-
`n` counts the questions of that ticket and kind in the run, so an id is never used twice.
|
|
208
|
+
`n` counts the questions of that ticket and kind in the run, so an id is never used twice. An open question of a ticket that has merged is dropped, with a ledger line: it leaves `decisions.json` and parks no run.
|
|
208
209
|
|
|
209
210
|
Answer with `--answer <question id>=<option id>` on the next run, or through the page, which gives `.agent/implement-answers.json`. An answers file counts only when it is submitted and its `revision` equals the `revision` of `decisions.json`. The driver ignores any other file or answer and says so in the ledger. Each answer becomes one `Ruling:` sentence in the ledger.
|
|
210
211
|
|
|
@@ -24,7 +24,7 @@ has passed. The review rounds adapt superpowers' subagent-driven-development
|
|
|
24
24
|
Run the driver. It makes every choice of the run; you start it and relay its result.
|
|
25
25
|
|
|
26
26
|
1. In the PR worktree, run `sh <skill-dir>/run.sh` with the flags the operator gave, unchanged. `<skill-dir>` is the directory of this file. The driver needs `--gate` and `--spec`: ask the operator for a flag that is missing. A run can take hours: run the command in the background and wait for it to exit.
|
|
27
|
-
2. When it exits, relay `.agent/implement/summary.md` and the exit code: 0 is done, 1 is a BLOCKED ticket, 2 is parked on questions, 3 is invalid input, 4 is stopped by a CLI failure (after the fix, the same command resumes). Relay the lines the driver printed after the summary too.
|
|
27
|
+
2. When it exits, relay `.agent/implement/summary.md` and the exit code: 0 is done, 1 is a BLOCKED ticket, 2 is parked on questions, 3 is invalid input, 4 is stopped by a CLI failure (after the fix, the same command resumes). Relay the lines the driver printed after the summary too. With exit 0 and a PR URL such as `https://github.com/jesdi/demo/pull/61`, tell the operator to start the babysitter: run `/babysit-pr https://github.com/jesdi/demo/pull/61`.
|
|
28
28
|
3. With exit 2, and with exit 1 when the driver printed questions, show the operator those questions. When the operator answers, run the same command again with one `--answer <question id>=<option id>` for each answer.
|
|
29
29
|
|
|
30
30
|
Do not answer a question for the operator. Do not edit `.agent/implement/`, the code or the branches during a run.
|
|
@@ -278,6 +278,7 @@ def _merge(ticket: Ticket, slot: str, run: Run) -> None:
|
|
|
278
278
|
with run.merging, during("the merge"):
|
|
279
279
|
landing, rulings = _land(ticket, slot, run)
|
|
280
280
|
run.state.update(lambda state: _record_landing(state, number, landing, rulings.adopted()))
|
|
281
|
+
_drop_merged(run.state)
|
|
281
282
|
for path in rulings.adopted():
|
|
282
283
|
ledger(f"Ticket {number}: by the ruling (adopt), the ticket locks {path}, so its change to that locked file of "
|
|
283
284
|
"a merged ticket landed.")
|
|
@@ -310,6 +311,14 @@ def _block(number: str, run: Run, ledger_line: int) -> None:
|
|
|
310
311
|
ledger(f"Ticket {number}: {driver_decisions.decides(ask.kind, len(ask.subjects))} in {DECISIONS}.")
|
|
311
312
|
|
|
312
313
|
|
|
314
|
+
def _drop_merged(state: driver_state.State) -> None:
|
|
315
|
+
"""Drop the open questions of each merged ticket: a stopped ticket that the operator set to `merge` has them."""
|
|
316
|
+
dropped: list[dict] = []
|
|
317
|
+
state.update(lambda new: dropped.extend(driver_decisions.drop_merged(new)))
|
|
318
|
+
for question in dropped:
|
|
319
|
+
ledger(f"Ticket {question['ticket']}: the question {question['id']} is dropped: the ticket merged.")
|
|
320
|
+
|
|
321
|
+
|
|
313
322
|
def _halt(run: Run, owner: str, why: str) -> None:
|
|
314
323
|
"""Start no other agent: the run ends with exit 4, and `owner` keeps its phase for the next run."""
|
|
315
324
|
run.halted.append(why)
|
|
@@ -443,7 +452,7 @@ def _resume(tickets: list[Ticket], state: driver_state.State, pr: str, slots: in
|
|
|
443
452
|
|
|
444
453
|
def _publish_questions(run: dict) -> str:
|
|
445
454
|
"""Write decisions.json and the review page for the questions of `run` of state.json; "" or the error."""
|
|
446
|
-
if not run["questions"]:
|
|
455
|
+
if not (run["questions"] or DECISIONS.exists()): # a dropped question leaves a file to rewrite
|
|
447
456
|
return ""
|
|
448
457
|
document = driver_decisions.document(run)
|
|
449
458
|
DECISIONS.write_text(json.dumps(document, indent=1) + "\n")
|
|
@@ -459,6 +468,7 @@ def _publish_questions(run: dict) -> str:
|
|
|
459
468
|
|
|
460
469
|
def _apply_answers(state: driver_state.State, args) -> list[str]:
|
|
461
470
|
"""Turn each answer that counts into a ruling and let its ticket go on; [] or the errors that stop the run."""
|
|
471
|
+
_drop_merged(state)
|
|
462
472
|
run = state.read()["run"]
|
|
463
473
|
questions, document = run["questions"], driver_decisions.document(run)
|
|
464
474
|
if errors := driver_answers.given(args.answer, document):
|
|
@@ -91,6 +91,19 @@ KINDS = {
|
|
|
91
91
|
"redesign": Option(
|
|
92
92
|
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
93
93
|
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
94
|
+
"review-rejected": Kind(
|
|
95
|
+
True,
|
|
96
|
+
"Ticket {ticket}: the driver rejected an agent of the review two times: {subject}",
|
|
97
|
+
"The driver rejected the report of the reviewer or the correctness pass of ticket {ticket}, and the report of "
|
|
98
|
+
"its rerun too, so the review did not end. Ticket {ticket} is BLOCKED and each ticket that it blocks waits.",
|
|
99
|
+
"retry",
|
|
100
|
+
{"retry": Option(
|
|
101
|
+
"The review runs again, with each of its agents. The first prompt of the rejected agent says why the "
|
|
102
|
+
"driver rejected its report.",
|
|
103
|
+
"Ruling: {ticket} review runs again (retry): {subject}.", {"phase": "review"}),
|
|
104
|
+
"redesign": Option(
|
|
105
|
+
"Keep the ticket BLOCKED. The design changes before more work on it.",
|
|
106
|
+
"Ruling: {ticket} stays BLOCKED, the design changes first (redesign): {subject}.", {})}),
|
|
94
107
|
"implementer-stopped": Kind(
|
|
95
108
|
True,
|
|
96
109
|
"Ticket {ticket}: the implementer stopped: {subject}",
|
|
@@ -177,6 +190,16 @@ def accepted(questions: list[dict], ticket: str, kind: str) -> list[str]:
|
|
|
177
190
|
return [q["subject"] for q in questions if (q["ticket"], q["kind"], q["answer"]) == (ticket, kind, "accept")]
|
|
178
191
|
|
|
179
192
|
|
|
193
|
+
def drop_merged(state: dict) -> list[dict]:
|
|
194
|
+
"""Remove the open questions of each merged ticket from `state`: the stop that asked them is over (issue #136).
|
|
195
|
+
Returns them."""
|
|
196
|
+
merged = {number for number, entry in state["tickets"].items() if entry["phase"] == "merged"}
|
|
197
|
+
run = state["run"]
|
|
198
|
+
dropped = [q for q in run["questions"] if q["answer"] is None and q["ticket"] in merged]
|
|
199
|
+
run["questions"] = [q for q in run["questions"] if q not in dropped]
|
|
200
|
+
return dropped
|
|
201
|
+
|
|
202
|
+
|
|
180
203
|
def contradicted(role: str, report: dict) -> str:
|
|
181
204
|
"""The locked tests that a BLOCKED report of an implementer or a fixer says contradict the spec; "" when it is not
|
|
182
205
|
that stop."""
|
|
@@ -22,6 +22,7 @@ import re
|
|
|
22
22
|
import shlex
|
|
23
23
|
import shutil
|
|
24
24
|
import subprocess
|
|
25
|
+
import sys
|
|
25
26
|
from pathlib import Path
|
|
26
27
|
|
|
27
28
|
import driver_agents
|
|
@@ -41,12 +42,34 @@ ROUNDS = 2 # the full review and the scoped one after the fix batch
|
|
|
41
42
|
REVIEW_DIFF = driver_agents.SKILL.parent / "review-diff" / "SKILL.md"
|
|
42
43
|
|
|
43
44
|
|
|
44
|
-
def
|
|
45
|
-
"""The SKILL.md of
|
|
46
|
-
|
|
45
|
+
def _installed(name: str) -> Path | None:
|
|
46
|
+
"""The SKILL.md of a skill: next to this skill, else in the skill folder of the Claude home or of the shared
|
|
47
|
+
home of Codex and OpenCode."""
|
|
47
48
|
claude = Path(os.environ.get("CLAUDE_CONFIG_DIR") or Path.home() / ".claude")
|
|
48
49
|
homes = (driver_agents.SKILL.parent, claude / "skills", Path.home() / ".agents" / "skills")
|
|
49
|
-
return next((home /
|
|
50
|
+
return next((home / name / "SKILL.md" for home in homes if (home / name / "SKILL.md").is_file()), None)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def pr_skill() -> Path | None:
|
|
54
|
+
"""The SKILL.md of the pr skill, which the PR body follows."""
|
|
55
|
+
return _installed("pr")
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def pr_risk_skill() -> Path | None:
|
|
59
|
+
"""The SKILL.md of the pr-risk skill, which parses and validates the merge-risk block of the PR body."""
|
|
60
|
+
return _installed("pr-risk")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
PR_RISK_INSTALL = "`npx skills add jesdi/general-skills --skill pr-risk`"
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _risk_errors(method: Path, body: str) -> str:
|
|
67
|
+
"""The errors of the merge-risk block of `body` as `pr-risk` names them, or "" when the block is valid."""
|
|
68
|
+
checked = OUT / FINAL / "pr-risk-check.md"
|
|
69
|
+
checked.write_text(body)
|
|
70
|
+
done = subprocess.run([sys.executable, str(method.parent / "merge_risk.py"), "validate", str(checked)],
|
|
71
|
+
capture_output=True, text=True)
|
|
72
|
+
return (done.stdout + done.stderr).strip() if done.returncode else ""
|
|
50
73
|
|
|
51
74
|
|
|
52
75
|
def _has_origin() -> bool:
|
|
@@ -62,6 +85,9 @@ def precondition_errors(push: bool) -> list[str]:
|
|
|
62
85
|
if push and not pr_skill():
|
|
63
86
|
errors.append("the pr skill is missing: the PR body follows it; install it with "
|
|
64
87
|
"`npx skills add mattpocock/skills --skill pr`, or run without --push and --unattended")
|
|
88
|
+
if push and not pr_risk_skill():
|
|
89
|
+
errors.append(f"the pr-risk skill is missing: the PR body carries its merge-risk block; install it with "
|
|
90
|
+
f"{PR_RISK_INSTALL}, or run without --push and --unattended")
|
|
65
91
|
if push and not _has_origin():
|
|
66
92
|
errors.append("the repository has no origin remote: --unattended and --push push the PR branch to origin; "
|
|
67
93
|
"add the remote, or run without them to stop before the push")
|
|
@@ -433,18 +459,31 @@ def _facts(run: Run, final: dict, tickets: list[Ticket]) -> str:
|
|
|
433
459
|
|
|
434
460
|
def _write_body(run: Run, final: dict, tickets: list[Ticket]) -> Path:
|
|
435
461
|
"""Write the PR body: what the pr-writer wrote with the method of the pr skill, then the facts of the run. A body
|
|
436
|
-
written for the reviewed tip is kept, so a PR that failed to open costs
|
|
462
|
+
written for the reviewed tip is kept when its merge-risk block still validates, so a PR that failed to open costs
|
|
463
|
+
no second agent."""
|
|
437
464
|
body, tip = OUT / FINAL / "pr-body.md", final["reviewed"]
|
|
438
|
-
|
|
465
|
+
method, risk, facts = pr_skill(), pr_risk_skill(), _facts(run, final, tickets)
|
|
466
|
+
if final["body"] == tip and body.is_file() and risk and not _risk_errors(risk, body.read_text()):
|
|
439
467
|
return body
|
|
440
|
-
method, facts = pr_skill(), _facts(run, final, tickets)
|
|
441
468
|
if not method:
|
|
442
469
|
raise Blocked("the pr skill is missing: the PR body follows it; install it with "
|
|
443
470
|
"`npx skills add mattpocock/skills --skill pr`")
|
|
471
|
+
if not risk:
|
|
472
|
+
raise Blocked(f"the pr-risk skill is missing: the PR body carries its merge-risk block; install it with "
|
|
473
|
+
f"{PR_RISK_INSTALL}")
|
|
444
474
|
values = {**_prompt_values(run), "start_sha": tip, "range": f"{final['onto']}..{tip}",
|
|
445
|
-
"gate": str(driver_gate.record_path(OUT / FINAL, tip)), "pr_skill": str(method),
|
|
446
|
-
|
|
447
|
-
|
|
475
|
+
"gate": str(driver_gate.record_path(OUT / FINAL, tip)), "pr_skill": str(method),
|
|
476
|
+
"pr_risk_skill": str(risk), "risk_errors": "", "facts": facts}
|
|
477
|
+
for round_ in range(2): # the pr-writer gets one more run with the errors of the block
|
|
478
|
+
with during("the PR body"):
|
|
479
|
+
report = run.read_only(FINAL, ".", run.pr, tip,
|
|
480
|
+
lambda: run.agent("pr-writer", FINAL, ".", values, fix_round=round_))
|
|
481
|
+
if not (errors := _risk_errors(risk, report["body"])):
|
|
482
|
+
break
|
|
483
|
+
values["risk_errors"] = (f"Your previous body has an invalid merge-risk block. Fix it with the pr-risk "
|
|
484
|
+
f"skill; its errors:\n{errors}\n")
|
|
485
|
+
else:
|
|
486
|
+
raise Blocked(f"the merge-risk block of the PR body is invalid after a second run of the pr-writer: {errors}")
|
|
448
487
|
body.write_text(f"{report['body'].strip()}\n\n{facts}")
|
|
449
488
|
run.state.update(lambda state: state["run"]["final"].update(body=tip))
|
|
450
489
|
return body
|
|
@@ -69,12 +69,15 @@ def _log_findings(job: Job, findings: list[dict]) -> list[dict]:
|
|
|
69
69
|
def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) -> list[dict]:
|
|
70
70
|
"""Run the (role, model entry) pairs of `cast` at the same time in the one slot. Returns their reports.
|
|
71
71
|
A role that stops (BLOCKED, NEEDS_CONTEXT) asks a `review-stopped` question, unless an `accept` ruling on an
|
|
72
|
-
earlier stop of that role lets the review go on with its report.
|
|
72
|
+
earlier stop of that role lets the review go on with its report. A role whose report the driver rejects two
|
|
73
|
+
times asks a `review-rejected` question; after `retry`, its first prompt says why (issue #136)."""
|
|
73
74
|
number = job.ticket.number
|
|
74
75
|
values, running = job.pointers(job.round - 1), [role for role, _ in cast]
|
|
75
76
|
values["fixer_report"] = os.path.relpath(OUT / number / f"fixer-{job.round}.json", job.slot)
|
|
76
|
-
errors, stops = {}, {}
|
|
77
|
-
|
|
77
|
+
errors, stops, rejected = {}, {}, {}
|
|
78
|
+
state = job.run.state.read()
|
|
79
|
+
accepted = driver_decisions.accepted(state["run"]["questions"], number, "review-stopped")
|
|
80
|
+
before = state["tickets"][number]["rejected"] # role -> why the driver rejected it before the ruling
|
|
78
81
|
|
|
79
82
|
def call(role: str, entry: str) -> dict:
|
|
80
83
|
# A full review (no fix range) must give a mutation proof for each locked test file, not for a locked fixture
|
|
@@ -82,8 +85,10 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
82
85
|
full = not job.previous and role == "reviewer"
|
|
83
86
|
notes = ["rereview"] if job.previous else ["full-review"] if full else []
|
|
84
87
|
notes += ["unchanged"] * (job.previous == job.tip) # a fixer with no commit: its reasons need a check
|
|
88
|
+
notes += ["rejected"] * (role in before)
|
|
85
89
|
try:
|
|
86
|
-
return job.run.agent(role, job.ticket.number, job.slot, values,
|
|
90
|
+
return job.run.agent(role, job.ticket.number, job.slot, {**values, "rejection": before.get(role, "")},
|
|
91
|
+
entry=entry, fix_round=job.round,
|
|
87
92
|
notes=notes, check={"full": True, "locked": locked} if full else {},
|
|
88
93
|
alone=lambda: len(running) == 1)
|
|
89
94
|
except Stopped as stopped:
|
|
@@ -93,7 +98,8 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
93
98
|
stops[role] = str(stopped)
|
|
94
99
|
errors[role] = f"the {role}: {stopped}"
|
|
95
100
|
return {}
|
|
96
|
-
except Blocked as blocked:
|
|
101
|
+
except Blocked as blocked: # the driver rejected its report two times
|
|
102
|
+
rejected[role] = str(blocked)
|
|
97
103
|
errors[role] = f"the {role}: {blocked}"
|
|
98
104
|
return {}
|
|
99
105
|
finally:
|
|
@@ -105,6 +111,10 @@ def _run_reviewers(job: Job, cast: list[tuple[str, str]], locked: list[str]) ->
|
|
|
105
111
|
first = next(role for role, _ in cast if role in stops)
|
|
106
112
|
job.run.ask(number, "review-stopped", [stops[role] for role, _ in cast if role in stops],
|
|
107
113
|
str(OUT / number / f"{first}-{job.round}.json"))
|
|
114
|
+
elif rejected:
|
|
115
|
+
first = next(role for role, _ in cast if role in rejected)
|
|
116
|
+
job.run.ask(number, "review-rejected", [errors[role] for role, _ in cast if role in rejected],
|
|
117
|
+
str(OUT / number / f"{first}-{job.round}.json"), rejected=rejected)
|
|
108
118
|
if errors:
|
|
109
119
|
raise Blocked("; ".join(errors[role] for role, _ in cast if role in errors))
|
|
110
120
|
return reports
|
|
@@ -121,6 +131,8 @@ def _review(job: Job) -> list[dict]:
|
|
|
121
131
|
cast.append(("correctness", driver_agents.correctness_entry(run.models)))
|
|
122
132
|
reports = run.read_only(number, job.slot, job.values["branch"], job.tip,
|
|
123
133
|
lambda: _run_reviewers(job, cast, tested(state)))
|
|
134
|
+
if state["rejected"]:
|
|
135
|
+
run.state.ticket(number, rejected={}) # the rejection is answered: no later review repeats it
|
|
124
136
|
for (role, _), report in zip(cast, reports):
|
|
125
137
|
found += _log_findings(job, [{**finding, "source": role} for finding in report["findings"]])
|
|
126
138
|
job.proofs |= {(proof["file"], proof["line"]) for proof in report.get("mutations", [])}
|
|
@@ -58,8 +58,14 @@ def _owner_errors(report: dict, context: dict) -> list[str]:
|
|
|
58
58
|
for commit in report["commits"] if commit["ticket"] not in context["owners"]]
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def _present(repo: str, commit: str, paths: list[str]) -> list[str]:
|
|
62
|
+
"""The `paths` that are files at `commit`."""
|
|
63
|
+
return _git(repo, "ls-tree", "-r", "--name-only", "-z", commit, "--", *paths, end="\0") if paths else []
|
|
64
|
+
|
|
65
|
+
|
|
61
66
|
def _commit_errors(report: dict, context: dict) -> list[str]:
|
|
62
|
-
"""Every commit is new since the role started and on the branch; every locked path is in such a commit
|
|
67
|
+
"""Every commit is new since the role started and on the branch; every locked path is in such a commit and is a
|
|
68
|
+
file at the branch tip: a deleted file holds no test that a review could prove (issue #136)."""
|
|
63
69
|
repo, branch, commits = context["repo"], context["branch"], _shas(report)
|
|
64
70
|
new = _git(repo, "rev-list", f"{context['start']}..{branch}")
|
|
65
71
|
errors = [f"commit {sha[:7]} is not a new commit on {branch}"
|
|
@@ -67,6 +73,9 @@ def _commit_errors(report: dict, context: dict) -> list[str]:
|
|
|
67
73
|
if locked := report.get("locked"):
|
|
68
74
|
changed = _git(repo, "log", "--name-only", "-z", "--format=", f"{context['start']}..{branch}", end="\0")
|
|
69
75
|
errors += [f"locked path {path} is not in the role's commits" for path in locked if path not in changed]
|
|
76
|
+
present = _present(repo, branch, locked)
|
|
77
|
+
errors += [f"locked path {path} is not a file at the tip of {branch}: list in `locked` only files you keep"
|
|
78
|
+
for path in locked if path in changed and path not in present]
|
|
70
79
|
return errors
|
|
71
80
|
|
|
72
81
|
|
|
@@ -139,12 +148,14 @@ def _proof_errors(report: dict, context: dict) -> list[str]:
|
|
|
139
148
|
|
|
140
149
|
def _locked_errors(report: dict, context: dict) -> list[str]:
|
|
141
150
|
"""In a full review, each locked test file has a mutation proof (`mutations[].test` is `<file>::<test>`).
|
|
142
|
-
`locked` names no fixture of the ticket: a fixture holds no test that a proof could name (#118).
|
|
151
|
+
`locked` names no fixture of the ticket: a fixture holds no test that a proof could name (#118). A locked file
|
|
152
|
+
that is not at the reviewed tip holds no test either (issue #136)."""
|
|
143
153
|
if not context.get("full") or "findings" not in report:
|
|
144
154
|
return []
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
155
|
+
locked = context.get("locked", [])
|
|
156
|
+
tests, present = [proof["test"] for proof in report.get("mutations", [])], _present(context["repo"], context["start"], locked)
|
|
157
|
+
return [f"mutations: no mutation proof for the locked test file {path}" for path in locked
|
|
158
|
+
if path in present and not any(test.startswith(path) for test in tests)]
|
|
148
159
|
|
|
149
160
|
|
|
150
161
|
def _fixture_errors(report: dict) -> list[str]:
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
{"run": {revision, pr_branch, schema, gates, stops, agents: [{ticket, role, entry, seconds, cost}], questions, start,
|
|
4
4
|
landed: [[ticket, the PR tip its merge made]], final},
|
|
5
|
-
"tickets": {"NN": {phase, round, tip, test_writer_sha, locked, fixtures, green_gates, slot, note, held}}}"""
|
|
5
|
+
"tickets": {"NN": {phase, round, tip, test_writer_sha, locked, fixtures, green_gates, slot, note, held, rejected}}}"""
|
|
6
6
|
from __future__ import annotations
|
|
7
7
|
|
|
8
8
|
import fcntl
|
|
@@ -22,7 +22,7 @@ PHASES = ("pending", "test-writer", "implement", "gate", "review", "fix", "merge
|
|
|
22
22
|
|
|
23
23
|
def _ticket() -> dict:
|
|
24
24
|
return {"phase": "pending", "round": 0, "tip": None, "test_writer_sha": None, "locked": [], "green_gates": [],
|
|
25
|
-
"slot": None, "note": "", "held": {},
|
|
25
|
+
"slot": None, "note": "", "held": {}, "rejected": {},
|
|
26
26
|
"fixtures": []}
|
|
27
27
|
|
|
28
28
|
|
|
@@ -6,11 +6,12 @@ PR branch: {pr_branch}, at commit {start_sha}
|
|
|
6
6
|
Range: {range}
|
|
7
7
|
Gate record of the driver for {start_sha}: {gate}
|
|
8
8
|
PR method: {pr_skill}
|
|
9
|
+
Merge-risk block: {pr_risk_skill}
|
|
9
10
|
Facts of the run, which the driver puts after your body:
|
|
10
11
|
{facts}
|
|
11
12
|
|
|
12
|
-
Write the body of the PR of the range with the method of the pr skill in the file above: its sections, in its order. Read the spec, the tickets and the range first. The gate record and the tests of the range are the execution-based evidence; you cannot take screenshots. Do not repeat the facts of the run: the driver puts them after your body.
|
|
13
|
-
Do not commit. Leave the branch and the tree as you found them.
|
|
13
|
+
Write the body of the PR of the range with the method of the pr skill in the file above: its sections, in its order. Put the merge-risk block, as the pr-risk skill describes it, under `## Merge Danger`, and check it with `python3 merge_risk.py validate <body-file>` from that skill's folder. Read the spec, the tickets and the range first. The gate record and the tests of the range are the execution-based evidence; you cannot take screenshots. Do not repeat the facts of the run: the driver puts them after your body.
|
|
14
|
+
{risk_errors}Do not commit. Leave the branch and the tree as you found them.
|
|
14
15
|
|
|
15
16
|
Write one JSON report at {report} that matches this schema:
|
|
16
17
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Before the ruling of the operator, the driver rejected two reports of this role in this review: {rejection}. This time, give what the driver asked for.
|