@jesdi/skills 0.0.51 → 0.0.53

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jesdi/skills",
3
- "version": "0.0.51",
3
+ "version": "0.0.53",
4
4
  "description": "jesdi's agent skills (content package consumed by @jesdi/skills-cli)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -19,7 +19,7 @@ A comment in the code is for a line that looks wrong or removable without it.
19
19
  | `driver_report.py` | Validation of one agent report against its schema, git and the agent's log |
20
20
  | `driver_review.py` | The locked-file check of a ticket's own tests, the routing of findings, mutation proofs |
21
21
  | `driver_merge.py` | Merges by git plumbing, the locked-file check of a landing, the move of the PR ref |
22
- | `driver_gate.py` | One run of the gate command and its record |
22
+ | `driver_gate.py` | One gate of a commit: the command, once more when a signal ended it, and its record |
23
23
  | `driver_slots.py` | The worktrees that tickets run in, and the `git` helper |
24
24
  | `driver_state.py` | `state.json` (the resume contract) and the kernel lock |
25
25
  | `driver_names.py` | The names of one run: its ticket branches, its recovery ref and its lock file |
@@ -132,6 +132,9 @@ and do not know about the run, except `driver_run.py`, which the three deciding
132
132
  it blocks only after round 4. A red gate on a test-writer correction blocks.
133
133
  - The implementer and each fixer get the `--gate` command and run it before they report. The gate of the driver
134
134
  stays the source of truth: an agent's run of the gate counts for nothing.
135
+ - A finding that a correction reports in `not_addressed` goes to the fixer of the same round as kind `code`
136
+ (`driver_fixloop._correct` rewrites it in the findings file): the test needs a production change first, so a
137
+ second correction could not close it.
135
138
  - No test-writer correction runs after round 4 (`driver_fixloop._act_on`): its findings become `finding` questions
136
139
  with the others. A correction there would add red locked tests that no fix round makes green, and `accept` could
137
140
  not merge the ticket.
@@ -83,7 +83,7 @@ Everything is under `.agent/`, which is never committed.
83
83
  | `.agent/implement/decisions.json` | The open questions and their `revision`. Written only after a stop. |
84
84
  | `.agent/implement/<NN>/` | One folder for each ticket. |
85
85
  | `.agent/implement/<NN>/<role>-<K>.json`, `.log`, `.prompt.md` | The report, the log and the prompt of one agent. K is the fix round. |
86
- | `.agent/implement/<NN>/gate-<sha7>.log` | One gate record: start, commit, status, command, output, exit, the state after the command, end. |
86
+ | `.agent/implement/<NN>/gate-<sha7>.log` | One gate record: start, commit, status, command, output, exit, the state after the command, end. A command that a signal ended, with the tree clean and HEAD unmoved, did not judge the commit: the driver runs it once more, that run overwrites the record, and the ledger says the gate was killed by the signal and runs again. A signal ended the command when its exit is negative, or when it is 128+N for N in SIGHUP (1), SIGINT (2), SIGKILL (9) or SIGTERM (15): the gate runs in `/bin/sh -c`, and a shell that does not exec the command, as Ubuntu's dash does not, outlives its killed child and exits with 128+N. Any other exit, 142 (128+SIGALRM) among them, is a red record with no second run. A second signal leaves the record red. |
87
87
  | `.agent/implement/<NN>/findings-<K>.json` | The merged findings of the review after fix round K, or the red gate of round K. |
88
88
  | `.agent/implement/final/` | The same files for the end of run, and `pr-body.md`: the pr-writer's body, then the facts of the run. |
89
89
  | `.agent/implement/pycache/` | Compiled Python of the gate, kept out of the slots. |
@@ -109,6 +109,7 @@ A ticket is ready when each ticket in its **Blocked by** line is merged and no r
109
109
  Rules for each agent:
110
110
 
111
111
  - A call blocks until the agent ends. The driver does not poll.
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.
112
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.
113
114
  - A report with status `BLOCKED` or `NEEDS_CONTEXT` blocks the ticket.
114
115
  - A BLOCKED ticket stops the tickets that it blocks. All other tickets run on.
@@ -117,7 +118,7 @@ Rules for each agent:
117
118
 
118
119
  | Finding | What the driver does |
119
120
  |---|---|
120
- | kind `fixture`, any severity, or kind `test`, `critical` or `important`, on a locked file of the ticket | One test-writer correction, outside the fix rounds. The fixer may not edit a locked file, so a fix round cannot close a `test` finding there. The corrected files are the new locked versions, and the next review is a full review. A finding of this kind that is open after the correction blocks the ticket. No correction runs after round 4. |
121
+ | kind `fixture`, any severity, or kind `test`, `critical` or `important`, on a locked file of the ticket | One test-writer correction, outside the fix rounds. The fixer may not edit a locked file, so a fix round cannot close a `test` finding there. The corrected files are the new locked versions, and the next review is a full review. A finding that the correction reports in `not_addressed` (it needs a production change first) becomes a finding of kind `code`, with the reason as its evidence, and goes to a fix round at once; the ledger says it was not corrected. A finding of this kind that is open after the correction blocks the ticket. No correction runs after round 4. |
121
122
  | `critical` or `important` | One fix round. |
122
123
  | `minor` | It stays in the ledger and in the findings file. The final reviewer gets the list. |
123
124
 
@@ -176,7 +177,7 @@ Every report has `status` (`DONE`, `DONE_WITH_CONCERNS`, `NEEDS_CONTEXT`, `BLOCK
176
177
 
177
178
  | Role | Template | More fields | Checks after the schema |
178
179
  |---|---|---|---|
179
- | test-writer | `prompts/test-writer.md` | `locked` (test file paths), `red` (`test`, `line`) | The driver reads a test node id `<file>::<test>` in `locked` as its file. With DONE: one commit, one locked file and one red line or more. Each locked path is in a commit that the role made. Each `line` is in the log. A locked file of a merged ticket that the role changed is in `locked`. A correction (after `overrule-test`, or for a review finding) changes only the files that it lists in `locked` and the files that the driver restored before it. When the gate is red on the restore commit, a DONE correction lists a restored file in `locked`. |
180
+ | test-writer | `prompts/test-writer.md` | `locked` (test file paths), `red` (`test`, `line`) | The driver reads a test node id `<file>::<test>` in `locked` as its file. With DONE: one commit, one locked file and one red line or more. Each locked path is in a commit that the role made. Each `line` is in the log. A locked file of a merged ticket that the role changed is in `locked`. A correction (after `overrule-test`, or for a review finding) changes only the files that it lists in `locked` and the files that the driver restored before it. When the gate is red on the restore commit, a DONE correction lists a restored file in `locked`. Each `not_addressed[].finding` is the title of a finding of the correction; a DONE correction with each of its findings there needs no commit. |
180
181
  | implementer | `prompts/implementer.md` | `green` | With DONE: one commit or more. |
181
182
  | reviewer | `prompts/reviewer.md` | `findings` (`severity`, `file`, `line`, `title`, `evidence`, `kind`), `mutations` (`test`, `file`, `line`, `red`); `commits` is empty | In a full review (one with no fix range: round 1, and the review after a test-writer correction): `mutations` is required, with a proof for each locked test file (`test` is `<locked file>::<test name>`). Each `red` is in the log. |
182
183
  | correctness | `prompts/correctness.md` | the same as the reviewer; `commits` is empty | `mutations` is optional. |
@@ -104,8 +104,9 @@ def _review(job: Job) -> list[dict]:
104
104
  return found
105
105
 
106
106
 
107
- def _correct(job: Job, findings: list[dict]) -> None:
108
- """One test-writer correction for the findings on the locked tests. It is outside the fix rounds."""
107
+ def _correct(job: Job, findings: list[dict]) -> list[dict]:
108
+ """One test-writer correction for the findings on the locked tests. It is outside the fix rounds. Returns the
109
+ findings that it did not correct, as findings of kind code for the fixer (issue #111)."""
109
110
  run, number = job.run, job.ticket.number
110
111
  if job.corrected:
111
112
  titles = "; ".join(finding["title"] for finding in findings)
@@ -120,19 +121,39 @@ def _correct(job: Job, findings: list[dict]) -> None:
120
121
  job.previous = "" # no review has seen the restore commit
121
122
  ledger(f"Ticket {number}: the code does not need the change to {', '.join(restored)}: the restore closes it, "
122
123
  "with no correction.")
123
- return
124
+ return []
124
125
  values = {**job.pointers(job.round), "restored": " ".join(restored),
125
126
  "record": record and os.path.relpath(record, job.slot)}
126
127
  notes = ["correction"] + ["restored"] * bool(restored) + ["restored-red"] * bool(record)
127
128
  with during("the test-writer correction"):
128
129
  report = run.agent("test-writer", number, job.slot, values, notes=notes, fix_round=job.round + 1,
129
- check={"correction": True, "restored": restored, "restore_red": bool(record)})
130
+ check={"correction": True, "restored": restored, "restore_red": bool(record),
131
+ "findings": [finding["title"] for finding in findings]})
130
132
  job.tip, job.previous, job.corrected = driver_slots.head(job.slot), "", True
131
133
  entry = run.state.read()["tickets"][number]
132
134
  run.state.ticket(number, tip=job.tip, **driver_review.written(job.slot, entry, report["locked"], job.tip))
135
+ return _uncorrected(job, findings, report.get("not_addressed", []))
136
+
137
+
138
+ def _uncorrected(job: Job, findings: list[dict], not_addressed: list[dict]) -> list[dict]:
139
+ """Log what the correction did with each finding. Returns each one it did not correct as a finding of kind
140
+ code, with its reason as the evidence: the test needs a production change first, so a fixer closes it."""
141
+ number = job.ticket.number
142
+ reasons = {item["finding"]: item["reason"] for item in not_addressed}
133
143
  for finding in findings:
144
+ result = (f"The test-writer did not correct it: {reasons[finding['title']]}. It goes to the fixer as a finding "
145
+ "of kind code." if finding["title"] in reasons else f"The test-writer corrected it at {job.tip[:7]}.")
134
146
  ledger(f"Ticket {number}: {finding['kind']} correction in {finding['file']}, outside the fix rounds: "
135
- f"{finding['title']}: {finding['evidence']}. The test-writer corrected it at {job.tip[:7]}.")
147
+ f"{finding['title']}: {finding['evidence']}. {result}")
148
+ code = {finding["title"]: {**finding, "kind": "code", "evidence": f"the test-writer did not correct it: {reason}"}
149
+ for finding in findings if (reason := reasons.get(finding["title"]))}
150
+ if code:
151
+ # The fixer reads the findings file of this review, so the finding is of kind code there too.
152
+ path = OUT / number / f"findings-{job.round}.json"
153
+ written = [code.get(finding["title"], finding) if finding in findings else finding
154
+ for finding in json.loads(path.read_text())]
155
+ path.write_text(json.dumps(written, indent=1) + "\n")
156
+ return list(code.values())
136
157
 
137
158
 
138
159
  def _fix(job: Job) -> None:
@@ -170,7 +191,7 @@ def _act_on(job: Job, found: list[dict]) -> bool:
170
191
  # A changed locked file is fixed first: a correction on top of it would make the changed file the reference.
171
192
  locked_file_changed = any(finding["source"] == "driver" for finding in to_fix)
172
193
  if to_correct and not locked_file_changed:
173
- _correct(job, to_correct)
194
+ to_fix += [finding for finding in _correct(job, to_correct) if finding["severity"] in driver_review.OPEN]
174
195
  if not to_fix:
175
196
  return False
176
197
  if not to_fix:
@@ -1,11 +1,15 @@
1
1
  """The gate: the repo's one check command, run by the driver on the commit it is about to trust.
2
2
 
3
3
  A gate record is `<folder>/gate-<first 7 hex of the commit>.log`. It is green only for exit 0 on a tree that is
4
- clean before the command and after it, with HEAD still on the commit.
4
+ clean before the command and after it, with HEAD still on the commit. A command that a signal ended, on a clean tree
5
+ with HEAD unmoved, did not judge the commit: it runs once more, and that run overwrites the record. A signal ended the
6
+ command when its exit is negative, or when it is 128+N for N in SIGHUP, SIGINT, SIGKILL or SIGTERM: a shell that does
7
+ not exec its last command, as dash does not, outlives the killed child and exits with 128+N.
5
8
  """
6
9
  from __future__ import annotations
7
10
 
8
11
  import os
12
+ import signal
9
13
  import subprocess
10
14
  from datetime import datetime, timezone
11
15
  from pathlib import Path
@@ -25,18 +29,25 @@ def _after(slot: str, commit: str) -> str:
25
29
  return "not clean\n" + "".join(f" {line}\n" for line in status.splitlines()).rstrip("\n") if status else "clean"
26
30
 
27
31
 
32
+ _KILLS = {signal.SIGHUP, signal.SIGINT, signal.SIGKILL, signal.SIGTERM}
33
+
34
+
35
+ def _signal(code: int | str) -> int | None:
36
+ """The signal that ended the command: from a negative exit, or from 128+N as a shell reports its killed child."""
37
+ if not isinstance(code, int):
38
+ return None
39
+ if code < 0:
40
+ return -code
41
+ return code - 128 if code - 128 in _KILLS else None
42
+
43
+
28
44
  def record_path(folder: Path, commit: str) -> Path:
29
45
  return folder / f"gate-{commit[:7]}.log"
30
46
 
31
47
 
32
- def run(command: str, slot: str, folder: Path, pr_branch: str) -> tuple[bool, Path]:
33
- """Gate the HEAD of `slot`. Returns (green, the record)."""
34
- commit = head(slot)
48
+ def _attempt(command: str, slot: str, commit: str, record: Path, env: dict) -> tuple[int | str, str]:
49
+ """Run the command once into `record`. Returns (the exit code or "not run", the state after it)."""
35
50
  status = git(slot, "status", "--short").stdout
36
- folder.mkdir(parents=True, exist_ok=True)
37
- record = record_path(folder, commit)
38
- # The cache of compiled Python stays out of the slot, so the gate leaves the tree clean.
39
- env = dict(os.environ, IMPLEMENT_SPEC_BASE=pr_branch, PYTHONPYCACHEPREFIX=str(folder.parent.resolve() / "pycache"))
40
51
  with record.open("w") as out:
41
52
  out.write(f"start: {_now()}\ncommit: {commit}\nstatus: {'not clean' if status else 'clean'}\n")
42
53
  out.writelines(f" {line}\n" for line in status.splitlines())
@@ -48,4 +59,21 @@ def run(command: str, slot: str, folder: Path, pr_branch: str) -> tuple[bool, Pa
48
59
  ).returncode
49
60
  after = "not run" if status else _after(slot, commit)
50
61
  out.write(f"\nexit: {code}\nafter: {after}\nend: {_now()}\n")
51
- return code == 0 and after == "clean", record
62
+ return code, after
63
+
64
+
65
+ def run(command: str, slot: str, folder: Path, pr_branch: str) -> tuple[bool, Path, list[str]]:
66
+ """Gate the HEAD of `slot`. Returns (green, the record, a ledger sentence per gate that a signal ended)."""
67
+ commit = head(slot)
68
+ folder.mkdir(parents=True, exist_ok=True)
69
+ record = record_path(folder, commit)
70
+ # The cache of compiled Python stays out of the slot, so the gate leaves the tree clean.
71
+ env = dict(os.environ, IMPLEMENT_SPEC_BASE=pr_branch, PYTHONPYCACHEPREFIX=str(folder.parent.resolve() / "pycache"))
72
+ code, after = _attempt(command, slot, commit, record, env)
73
+ killed = []
74
+ # A process outside the gate can kill it, as a `pkill -f` of another slot does: that run judged nothing.
75
+ number = _signal(code)
76
+ if number and after == "clean":
77
+ killed.append(f"the gate of {commit[:7]} was killed by signal {number} and runs again")
78
+ code, after = _attempt(command, slot, commit, record, env)
79
+ return code == 0 and after == "clean", record, killed
@@ -2,7 +2,7 @@
2
2
 
3
3
  context: repo (slot path), branch, start (HEAD when the role started), log, full (a full review: no fix range), locked,
4
4
  correction (a test-writer corrects locked tests), restored (locked files the driver put back before it),
5
- restore_red (the gate is red on the commit of that restore),
5
+ restore_red (the gate is red on the commit of that restore), findings (the titles a correction gets),
6
6
  owners (ticket numbers, for the final fix batch), merged (locked files of merged tickets, not its own), pr (tip)."""
7
7
  from __future__ import annotations
8
8
 
@@ -81,7 +81,8 @@ def _correction_errors(report: dict, context: dict) -> list[str]:
81
81
  errors.append("the gate is red on the restore commit, so a restored file fails with the code of this ticket: "
82
82
  "update that file and list it in `locked`, or report BLOCKED with a concern that starts with "
83
83
  "`locked test contradicts spec:`")
84
- return errors
84
+ return errors + [f"not_addressed: {item['finding']} is not the title of a finding of this correction"
85
+ for item in report.get("not_addressed", []) if item["finding"] not in context.get("findings", [])]
85
86
 
86
87
 
87
88
  def _merged_errors(report: dict, context: dict) -> list[str]:
@@ -150,7 +150,9 @@ class Run:
150
150
  at = driver_slots.head(slot)
151
151
  if at != commit:
152
152
  raise Blocked(f"the slot is at {at[:7]}, not at {commit[:7]}: the gate did not run")
153
- green, record = driver_gate.run(self.args.gate, slot, OUT / number, self.pr)
153
+ green, record, killed = driver_gate.run(self.args.gate, slot, OUT / number, self.pr)
154
+ for sentence in killed:
155
+ ledger(f"{_owner(number)}: {sentence}.")
154
156
 
155
157
  def count(state: dict) -> None:
156
158
  state["run"]["gates"] += 1
@@ -29,4 +29,5 @@ Write one JSON report at {report} that matches this schema:
29
29
  }
30
30
  ```
31
31
 
32
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
32
33
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -3,4 +3,5 @@ This call is a correction of the locked tests, not a new test set. Read in {find
3
3
  A `fixture` finding: a locked test encodes a stale path, format, fixture layout or setup detail. Correct only that detail and keep what each test asserts.
4
4
  A `test` finding: a locked test is too weak, for example it stays green when the production line it protects is broken. Make the test assert the behavior of its criterion so that it fails on that break. Do not remove an assertion.
5
5
  For this you may read the implementation.
6
+ When a finding needs a production change first, so that no correct test can be green, leave the test as it is and add the finding to `not_addressed`: `finding` is its `title` as the findings file gives it, `reason` is the production change it needs. The driver sends it to the fixer as a finding of kind `code`. A correction whose findings are all in `not_addressed` may report DONE with no commit.
6
7
  The implementation exists, so a corrected test is green: for `red`, break the production line that the test protects, run the test, print its failing output, then revert the edit. In `locked`, list each test file you corrected: test file paths only, not test node ids. Unlike `mutations[].test` of the reviewer, `locked` takes no `::<test name>`.
@@ -34,4 +34,5 @@ Write one JSON report at {report} that matches this schema:
34
34
  }
35
35
  ```
36
36
 
37
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
37
38
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -35,4 +35,5 @@ Write one JSON report at {report} that matches this schema:
35
35
 
36
36
  Run git as plain `git` in this worktree, and leave the git config as it is: all worktrees read one shared config, and one key written there, such as a `core.worktree`, breaks git in each of them. So never set GIT_DIR or GIT_WORK_TREE, and never write with `git config`.
37
37
  To run a check off this worktree, read the gate record of the driver, {gate}, or make a copy with `git worktree add --detach <temp dir> {start_sha}`, run the check there, and remove the copy with `git worktree remove --force <temp dir>` before you report.
38
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
38
39
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -35,4 +35,5 @@ Write one JSON report at {report} that matches this schema:
35
35
  }
36
36
  ```
37
37
 
38
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
38
39
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -31,4 +31,5 @@ Write one JSON report at {report} that matches this schema:
31
31
  }
32
32
  ```
33
33
 
34
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
34
35
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -30,4 +30,5 @@ Write one JSON report at {report} that matches this schema:
30
30
  }
31
31
  ```
32
32
 
33
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
33
34
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -33,4 +33,5 @@ Write one JSON report at {report}. When your sandbox is read-only, give the JSON
33
33
 
34
34
  Run git as plain `git` in this worktree, and leave the git config as it is: all worktrees read one shared config, and one key written there, such as a `core.worktree`, breaks git in each of them. So never set GIT_DIR or GIT_WORK_TREE, and never write with `git config`.
35
35
  To run a check off this worktree, read the gate record of the driver, {gate_record}, or make a copy with `git worktree add --detach <temp dir> {start_sha}`, run the check there, and remove the copy with `git worktree remove --force <temp dir>` before you report.
36
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
36
37
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -25,11 +25,13 @@ Write one JSON report at {report} that matches this schema:
25
25
  "files": {"type": "array", "items": {"type": "string"}},
26
26
  "concerns": {"type": "array", "items": {"type": "string"}},
27
27
  "locked": {"type": "array", "items": {"type": "string"}},
28
- "red": {"type": "array", "items": {"type": "object", "required": ["test", "line"], "properties": {"test": {"type": "string", "minLength": 1}, "line": {"type": "string", "minLength": 1}}}}
28
+ "red": {"type": "array", "items": {"type": "object", "required": ["test", "line"], "properties": {"test": {"type": "string", "minLength": 1}, "line": {"type": "string", "minLength": 1}}}},
29
+ "not_addressed": {"type": "array", "items": {"type": "object", "required": ["finding", "reason"], "properties": {"finding": {"type": "string", "minLength": 1}, "reason": {"type": "string", "minLength": 1}}}}
29
30
  },
30
- "if": {"properties": {"status": {"enum": ["DONE", "DONE_WITH_CONCERNS"]}}},
31
+ "if": {"properties": {"status": {"enum": ["DONE", "DONE_WITH_CONCERNS"]}}, "not": {"required": ["not_addressed"], "properties": {"not_addressed": {"minItems": 1}}}},
31
32
  "then": {"properties": {"commits": {"minItems": 1}, "locked": {"minItems": 1}, "red": {"minItems": 1}}}
32
33
  }
33
34
  ```
34
35
 
36
+ Stop only processes you started and their child processes, by PID (for example the PID of a job you put in the background, or its process group). Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name or pattern: other slots and sessions share the machine. If a process you did not start blocks you, report it in your concerns and do not kill it.
35
37
  Never run `git stash`, never reset, and never check out another branch: worktrees share one stash and one ref store.
@@ -290,6 +290,16 @@ def test_every_prompt_ends_with_report_path_schema_and_the_never_rule(env, role,
290
290
  assert report in prompt
291
291
 
292
292
 
293
+ @pytest.mark.parametrize("role", ["test-writer", "implementer", "fixer", "conflict", "reviewer", "final-reviewer",
294
+ "final-fixer", "rebase-conflict"])
295
+ def test_each_role_that_runs_commands_stops_only_its_own_processes(role):
296
+ """Issue 101: a `pkill -f` of one slot killed the gate of another."""
297
+ text = (SKILL / f"prompts/{role}.md").read_text()
298
+ assert "Stop only processes you started and their child processes, by PID" in text
299
+ assert "Never kill a process you did not start, and never use `pkill`, `killall` or a `kill` by name" in text
300
+ assert "If a process you did not start blocks you, report it in your concerns and do not kill it." in text
301
+
302
+
293
303
  def test_no_report_is_a_violation_with_one_rerun_then_blocked(env):
294
304
  w = World(env, refactor=True)
295
305
  blocked(w.run({"implementer": [{}, {}, impl()]}))
@@ -4,6 +4,7 @@ import json
4
4
  import os
5
5
  import shutil
6
6
  import subprocess
7
+ import sys
7
8
 
8
9
  import jsonschema
9
10
  import pytest
@@ -23,10 +24,13 @@ from test_walk import impl, plan, tw
23
24
  class Inside(test_review.Review):
24
25
  """The rig of test_review with the driver called in this process."""
25
26
 
27
+ command = "{gate}" # the gate command; `{gate}` is the rig's gate script
28
+
26
29
  def run(self, steps, *extra, parallel="2", watch=False):
27
30
  (self.rig / "plan.json").write_text(json.dumps(steps))
28
- args = ["--tickets", ".agent/tickets", "--gate", str(self.rig / "gate"), "--spec", "specs/csv/spec.md",
29
- "--models", str(self.models), "--runner", str(self.rig / "run-agent"), "--parallel", parallel, *extra]
31
+ args = ["--tickets", ".agent/tickets", "--gate", self.command.format(gate=self.rig / "gate"), "--spec",
32
+ "specs/csv/spec.md", "--models", str(self.models), "--runner", str(self.rig / "run-agent"), "--parallel",
33
+ parallel, *extra]
30
34
  here = os.getcwd()
31
35
  os.chdir(self.repo)
32
36
  try:
@@ -177,6 +181,56 @@ def test_a_test_finding_on_a_locked_file_gets_the_test_writer_correction_not_a_f
177
181
  assert driver_review.route([vacuous, minor, elsewhere], ["tests/test_01.py"]) == ([vacuous], [elsewhere])
178
182
 
179
183
 
184
+ NEEDS_CODE = "needs production code: the code has no multi-PR view"
185
+
186
+
187
+ def not_addressing(*titles, **report):
188
+ """A correction of tests/test_01.py that reports `titles` under `not_addressed`."""
189
+ step = {**tw("01"), "files": {"tests/test_01.py": "# corrected\n"}, "commit": "test: 01 fixture fix"}
190
+ reasons = [{"finding": title, "reason": NEEDS_CODE} for title in titles]
191
+ return {**step, "report": {**step["report"], **report, "not_addressed": reasons}}
192
+
193
+
194
+ def test_a_test_finding_the_correction_did_not_address_goes_to_the_fixer_as_a_code_finding(tmp_path):
195
+ # Issue #111: the ledger said "corrected it at <sha>" for every finding, and the finding came back each review.
196
+ stale = finding("STALE", kind="fixture", file="tests/test_01.py")
197
+ vacuous = finding("VACUOUS", "critical", kind="test", file="tests/test_01.py")
198
+ rig = Inside(tmp_path).run(plan(**{"01/test-writer": [tw("01"), not_addressing("VACUOUS")],
199
+ "01/fixer": [fix("01", 1)],
200
+ "01/reviewer": [review("01", [stale, vacuous]), review("01")]}))
201
+ assert rig.code == 0, rig.ledger()
202
+ order = [call["role"] for call in rig.calls("01")]
203
+ assert order == ["test-writer", "implementer", "reviewer", "test-writer", "fixer", "reviewer"]
204
+ assert rig.led("STALE: STALE. The test-writer corrected it at")
205
+ assert rig.led("VACUOUS", "corrected it at") == []
206
+ assert rig.led(f"test correction in tests/test_01.py, outside the fix rounds: VACUOUS: VACUOUS. The test-writer "
207
+ f"did not correct it: {NEEDS_CODE}. It goes to the fixer as a finding of kind code.")
208
+ # The fixer reads the finding as one of kind code, with the reason of the test-writer as its evidence.
209
+ (routed,) = [f for f in json.loads((rig.folder() / "findings-0.json").read_text()) if f["title"] == "VACUOUS"]
210
+ assert (routed["kind"], routed["evidence"]) == ("code", f"the test-writer did not correct it: {NEEDS_CODE}")
211
+ assert rig.state()["tickets"]["01"]["round"] == 1 and "findings-0.json" in rig.prompt("fixer-1")
212
+
213
+
214
+ def test_a_correction_that_addresses_no_finding_needs_no_commit(tmp_path):
215
+ vacuous = finding("VACUOUS", "critical", kind="test", file="tests/test_01.py")
216
+ none = not_addressing("VACUOUS", commits=[], files=[], locked=[], red=[])
217
+ del none["commit"], none["files"]
218
+ rig = Inside(tmp_path).run(plan(**{"01/test-writer": [tw("01"), none], "01/fixer": [fix("01", 1)],
219
+ "01/reviewer": [review("01", [vacuous]), review("01")]}))
220
+ assert rig.code == 0, rig.ledger()
221
+ assert [call["role"] for call in rig.calls("01")].count("test-writer") == 2 # no rerun
222
+ assert rig.led("VACUOUS. The test-writer did not correct it") and rig.state()["tickets"]["01"]["round"] == 1
223
+
224
+
225
+ def test_a_correction_that_names_a_finding_it_was_not_given_is_rerun(tmp_path):
226
+ vacuous = finding("VACUOUS", "critical", kind="test", file="tests/test_01.py")
227
+ rig = Inside(tmp_path).run(plan(**{"01/test-writer": [tw("01"), not_addressing("OTHER"), not_addressing()],
228
+ "01/reviewer": [review("01", [vacuous]), review("01")]}))
229
+ assert rig.code == 0, rig.ledger()
230
+ assert "not_addressed: OTHER is not the title of a finding of this correction" in rig.prompt("test-writer-1")
231
+ assert rig.led("VACUOUS: VACUOUS. The test-writer corrected it at")
232
+
233
+
180
234
  def test_a_test_writer_that_lists_test_node_ids_in_locked_locks_their_files(tmp_path):
181
235
  # Issue #71: a node id `<file>::<test>` in `locked` names its file, for the first run and for a correction.
182
236
  vacuous = finding("VACUOUS", "critical", kind="test", file="tests/test_01.py")
@@ -480,6 +534,76 @@ def test_a_red_gate_on_the_implementer_commit_starts_fix_round_1_with_the_record
480
534
  assert gate["title"] == f"the gate is red on {tip[:7]}" and record in gate["evidence"]
481
535
  assert "findings-0.json" in rig.prompt("fixer-1") and rig.state()["tickets"]["01"]["phase"] == "merged"
482
536
  assert "The fix is" not in rig.prompt("reviewer-1") # no review saw the implementer commit: a full review
537
+ assert [gate["commit"] for gate in rig.gates()].count(tip) == 1 and not rig.led("killed by signal")
538
+
539
+
540
+ def killed(rig, subject, times, end="os.kill(os.getpid(), signal.SIGTERM)"):
541
+ """The rig's gate, ended by `end` (SIGTERM by default) on its first `times` runs on the commit with `subject`, as a
542
+ `pkill -f` of another slot ends it (issue 101). A killed run logs nothing into `<rig>/gates/`."""
543
+ gate, real = rig.rig / "gate", rig.rig / "real-gate"
544
+ gate.rename(real)
545
+ gate.write_text(f"""#!{sys.executable}
546
+ import os, signal, subprocess, sys
547
+ from pathlib import Path
548
+ kills = Path(__file__).with_name("kills")
549
+ subject = subprocess.run(["git", "log", "-1", "--format=%s"], capture_output=True, text=True).stdout.strip()
550
+ if subject == {subject!r} and len(kills.read_text() if kills.exists() else "") < {times}:
551
+ with kills.open("a") as file:
552
+ file.write("x")
553
+ {end}
554
+ os.execv({str(real)!r}, [{str(real)!r}])
555
+ """)
556
+ gate.chmod(0o755)
557
+ return rig
558
+
559
+
560
+ # How the gate's shell reports a SIGTERM of the command: `exec` replaces the shell, so the exit is -15; a shell that
561
+ # outlives its child, as Ubuntu's dash does even for one simple command, exits 128+15.
562
+ SHAPES = {"exec": ("exec {gate}", -15), "compound": ("{gate}; exit $?", 143)}
563
+
564
+
565
+ def shaped(tmp_path, command):
566
+ rig = Inside(tmp_path)
567
+ rig.command = command
568
+ return rig
569
+
570
+
571
+ @pytest.mark.parametrize("command, code", SHAPES.values(), ids=SHAPES)
572
+ def test_a_gate_killed_by_a_signal_runs_once_more_and_its_green_second_run_counts(tmp_path, command, code):
573
+ rig = killed(shaped(tmp_path, command), "feat: 01 rows", 1).run(plan(**{"01/reviewer": [review("01")]}))
574
+ assert rig.code == 0, rig.ledger()
575
+ tip = rig.sha("01", "implementer")
576
+ assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "reviewer"]
577
+ assert rig.led("killed by signal") == [f"Ticket 01: the gate of {tip[:7]} was killed by signal 15 and runs again."]
578
+ assert rig.led(f"Ticket 01: the gate is green on {tip[:7]}") and not rig.led("finding of kind")
579
+ assert json.loads((rig.folder() / "findings-0.json").read_text()) == [] # the review's, with no gate finding
580
+ record = (rig.folder() / f"gate-{tip[:7]}.log").read_text()
581
+ assert record.count("exit: ") == 1 and "\nexit: 0\nafter: clean\n" in record # the second run overwrote it
582
+
583
+
584
+ @pytest.mark.parametrize("command, code", SHAPES.values(), ids=SHAPES)
585
+ def test_a_gate_killed_by_a_signal_twice_is_red(tmp_path, command, code):
586
+ rig = killed(shaped(tmp_path, command), "feat: 01 rows", 2)
587
+ rig.run(plan(**{"01/reviewer": [review("01")], "01/fixer": [fix("01", 1)]}))
588
+ assert rig.code == 0, rig.ledger()
589
+ tip = rig.sha("01", "implementer")
590
+ assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "fixer", "reviewer"]
591
+ assert len(rig.led("killed by signal")) == 1 and tip not in [gate["commit"] for gate in rig.gates()]
592
+ (gate,) = json.loads((rig.folder() / "findings-0.json").read_text())
593
+ assert gate["title"] == f"the gate is red on {tip[:7]}"
594
+ assert f"\nexit: {code}\nafter: clean\n" in (rig.folder() / f"gate-{tip[:7]}.log").read_text()
595
+
596
+
597
+ @pytest.mark.parametrize("exit", [1, 142]) # 142 is 128+SIGALRM: a signal, but not one that kills a gate from outside
598
+ def test_a_gate_that_exits_with_any_other_code_is_red_without_running_again(tmp_path, exit):
599
+ rig = killed(shaped(tmp_path, "{gate}; exit $?"), "feat: 01 rows", 1, end=f"sys.exit({exit})")
600
+ rig.run(plan(**{"01/reviewer": [review("01")], "01/fixer": [fix("01", 1)]}))
601
+ assert rig.code == 0, rig.ledger()
602
+ tip = rig.sha("01", "implementer")
603
+ assert [call["role"] for call in rig.calls("01")] == ["test-writer", "implementer", "fixer", "reviewer"]
604
+ assert not rig.led("killed by signal") and tip not in [gate["commit"] for gate in rig.gates()]
605
+ record = (rig.folder() / f"gate-{tip[:7]}.log").read_text()
606
+ assert record.count("exit: ") == 1 and f"\nexit: {exit}\nafter: clean\n" in record
483
607
 
484
608
 
485
609
  def test_a_red_gate_on_the_fixer_commit_of_round_4_blocks_the_ticket(tmp_path):
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-10-19T10:48:11.958Z",
3
+ "generatedAt": "2026-10-19T23:09:36.924Z",
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.26",
50
- "hash": "sha256-40637f9172d94edb3ef009f91f58e27f7cd400ed15935c5a62654822a57208c5",
49
+ "version": "0.1.28",
50
+ "hash": "sha256-bcdecd8970590a6678eec2601eccabadc23a7f92c9e9aba1887a67518f71dc2c",
51
51
  "description": "Implement a specification in code."
52
52
  },
53
53
  {