@jesdi/skills 0.0.60 → 0.0.62

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.60",
3
+ "version": "0.0.62",
4
4
  "description": "jesdi's agent skills (content package consumed by @jesdi/skills-cli)",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -105,8 +105,10 @@ and do not know about the run, except `driver_run.py`, which the three deciding
105
105
  - A role that commits keeps its tree after a timeout or an interrupt; its rerun continues from it.
106
106
  - A read-only role (reviewer, correctness, final-reviewer, pr-writer) has no work to keep. When it changes its slot or
107
107
  the shared git config, the driver restores them and runs the review one more time (`Run.read_only`). The config is
108
- a byte copy taken before the role (`driver_review.shared_config`): every worktree reads that one file, so a key a
109
- role writes there, such as a `core.worktree` on a temp directory, breaks git in all of them.
108
+ the keys of that file before the role (`driver_review.shared_config`): every worktree reads that one file, so a key a
109
+ role writes there, such as a `core.worktree` on a temp directory, breaks git in all of them. Other sessions write
110
+ it too, so the tracking keys of a new branch (`driver_review._tracking`) do not count and only the changed keys go
111
+ back, checked after; the whole file goes back only when git cannot write them.
110
112
  - A slot with uncommitted work of an interrupted or parked ticket is kept for that ticket (`driver_state.kept`).
111
113
  - A blocked ticket keeps its slot when the slot is not clean.
112
114
 
@@ -100,7 +100,7 @@ A ticket is ready when each ticket in its **Blocked by** line is merged and no r
100
100
  1. **test-writer** (`prompts/test-writer.md`). It writes one black-box test for each criterion through the Seam and commits them red. Those files are locked. Its prompt names the locked tests of merged tickets: each fixture must set up the precondition of its scenario under the spec rules and those tests. When the ticket must change one of those files, the test-writer changes it and lists it in `locked`. A ticket with Seam `none — refactor` has no test-writer.
101
101
  2. **implementer** (`prompts/implementer.md`). It starts from that commit and makes the locked tests green. It makes the gate (`--gate`) green on its final commit before it reports DONE or DONE_WITH_CONCERNS.
102
102
  3. **Gate.** The driver runs `--gate` on the ticket tip.
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.
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 keys of the shared config (`git rev-parse --git-common-dir`, then `config`) against what they were before. One change does not count: a new `branch.<name>` section with only `remote` on a configured remote and `merge` on `refs/heads/...`, which another session's `git worktree add -b` writes while a review runs. When the slot or another key changed, the driver restores the slot and only the changed keys, so other sessions' writes stay; when git cannot write them back (a held `config.lock`, a valueless key), the whole file goes back, and when that fails too the ticket is blocked, 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
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`.
@@ -173,21 +173,21 @@ The defaults need both `claude` and `codex` on PATH. The `openai` defaults name
173
173
 
174
174
  Each agent writes one JSON report. The schema of a role is the `json` block of its prompt template, so the agent reads the text that the driver enforces. `driver_report.py` `validate` checks the report against the schema, against git and against the log of the agent. A field that the schema does not name is ignored.
175
175
 
176
- Every report has `status` (`DONE`, `DONE_WITH_CONCERNS`, `NEEDS_CONTEXT`, `BLOCKED`), `commits`, `files` and `concerns`.
176
+ Every report has `status` (`DONE`, `DONE_WITH_CONCERNS`, `NEEDS_CONTEXT`, `BLOCKED`), `files` and `concerns`. A role that commits also has `commits`. A read-only role (reviewer, correctness, final-reviewer, pr-writer) has none: a reviewer reads `commits` as the commits it reviews, and the driver would refuse each of them as not new. The driver checks instead that a read-only role leaves its slot on the tip it got, with a clean tree.
177
177
 
178
178
  | Role | Template | More fields | Checks after the schema |
179
179
  |---|---|---|---|
180
180
  | test-writer | `prompts/test-writer.md` | `locked` (test file paths), `red` (`test`, `line`), optional `fixtures` (each locked file that holds no test, as a fake `gh`) | The driver reads a test node id `<file>::<test>` in `locked` as its file. Each fixture is in `locked`; the ticket record keeps it a fixture until a later correction lists the file again. With DONE: one commit, one locked file and one red line or more. Each locked path is in a commit that the role made. Each `line` is in the log. A locked file of a merged ticket that the role changed is in `locked`. A correction (after `overrule-test`, or for a review finding) changes only the files that it lists in `locked` and the files that the driver restored before it. When the gate is red on the restore commit, a DONE correction lists a restored file in `locked`. Each `not_addressed[].finding` is the title of a finding of the correction; a DONE correction with each of its findings there needs no commit. |
181
181
  | implementer | `prompts/implementer.md` | `green` | With DONE 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`); `commits` is empty | In a full review (one with no fix range: round 1, and the review after a test-writer correction): `mutations` is required, with a proof for each locked test file (`test` is `<locked file>::<test name>`). A locked fixture needs no proof: it holds no test that a proof could name, and the locked-file check protects it. Each `red` is in the log. |
183
- | correctness | `prompts/correctness.md` | the same as the reviewer; `commits` is empty | `mutations` is optional. |
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. |
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. |
186
- | pr-writer | `prompts/pr-writer.md` | `body`; `commits` is empty | None. |
186
+ | pr-writer | `prompts/pr-writer.md` | `body` | None. |
187
187
  | fixer of the final review | `prompts/final-fixer.md` | `green`; `commits` is a list of (`sha`, `ticket`) | Each new commit on the branch is in `commits`, with a ticket of the run. |
188
188
  | conflict | `prompts/conflict.md`, `prompts/rebase-conflict.md` | none | With DONE: one commit or more. No locked file may change. |
189
189
 
190
- For each role, every commit in `commits` must be new since the role started and on its branch. `severity` is `critical`, `important` or `minor`. `kind` is `code`, `test` or `fixture`. A read-only `codex` agent cannot write a file, so it gives the JSON as its last message and the CLI saves it as the report.
190
+ For each role that commits, every commit in `commits` must be new since the role started and on its branch. `severity` is `critical`, `important` or `minor`. `kind` is `code`, `test` or `fixture`. A read-only `codex` agent cannot write a file, so it gives the JSON as its last message and the CLI saves it as the report.
191
191
 
192
192
  ## Question kinds
193
193
 
@@ -41,8 +41,9 @@ def _seen(line: str, log: str) -> bool:
41
41
 
42
42
 
43
43
  def _shas(report: dict) -> list[str]:
44
- """`commits` as SHAs: the fix batch of the final review gives each commit with its ticket."""
45
- return [commit["sha"] if isinstance(commit, dict) else commit for commit in report["commits"]]
44
+ """`commits` as SHAs: the fix batch of the final review gives each commit with its ticket. A read-only role has
45
+ no `commits` (issue #129)."""
46
+ return [commit["sha"] if isinstance(commit, dict) else commit for commit in report.get("commits", [])]
46
47
 
47
48
 
48
49
  def _owner_errors(report: dict, context: dict) -> list[str]:
@@ -6,7 +6,9 @@ A mutation proof is keyed by (production file, line); the line is the one the fi
6
6
  """
7
7
  from __future__ import annotations
8
8
 
9
+ import os
9
10
  import re
11
+ import subprocess
10
12
  from pathlib import Path
11
13
 
12
14
  import driver_agents
@@ -148,21 +150,96 @@ def disturbed(slot: str, branch: str, tip: str) -> str:
148
150
  return f"the tree is not as the review found it: {', '.join(left)}" if left else ""
149
151
 
150
152
 
151
- def _read(config: Path) -> bytes:
152
- return config.read_bytes() if config.exists() else b""
153
-
154
-
155
- def shared_config(slot: str) -> tuple[Path, bytes]:
156
- """(the git config file that every worktree of the repository shares, its bytes)."""
157
- common = git(slot, "rev-parse", "--path-format=absolute", "--git-common-dir").stdout.strip()
158
- return Path(common, "config"), _read(Path(common, "config"))
159
-
160
-
161
- def restore_config(before: tuple[Path, bytes]) -> str:
162
- """"" when the shared git config is still `before` (from `shared_config`), else write it back and say so.
163
- One worktree that writes the config breaks git in all of them, as a core.worktree on a gone directory does."""
164
- config, data = before
165
- if _read(config) == data:
166
- return ""
167
- config.write_bytes(data)
168
- return f"the shared git config {config} changed"
153
+ Keys = dict[str, list[str | None]] # each key and its values in order; None is a valueless key, such as `[core] bare`
154
+ Config = tuple[Path, bytes, Keys | None] # (file, its bytes, its keys)
155
+
156
+
157
+ class Unrestored(Exception):
158
+ """The driver could not put the shared git config back."""
159
+
160
+
161
+ def _keys(config: Path) -> Keys | None:
162
+ """The keys of the file; {} when it does not exist, None when git cannot read it."""
163
+ if not config.exists():
164
+ return {}
165
+ listed = subprocess.run(["git", "config", "--file", str(config), "--list", "-z"], capture_output=True, text=True)
166
+ if listed.returncode:
167
+ return None
168
+ keys: Keys = {}
169
+ for entry in filter(None, listed.stdout.split("\0")):
170
+ key, newline, value = entry.partition("\n")
171
+ keys.setdefault(key, []).append(value if newline else None)
172
+ return keys
173
+
174
+
175
+ def shared_config(slot: str) -> Config:
176
+ """(the git config file that every worktree of the repository shares, its bytes, its keys)."""
177
+ config = Path(git(slot, "rev-parse", "--path-format=absolute", "--git-common-dir").stdout.strip(), "config")
178
+ return config, config.read_bytes() if config.exists() else b"", _keys(config)
179
+
180
+
181
+ # What `git worktree add -b x origin/main` writes into a new branch section, per key: the check of its value.
182
+ _TRACKING = {"remote": lambda value, before: f"remote.{value}.url" in before,
183
+ "merge": lambda value, before: value.startswith("refs/heads/")}
184
+
185
+
186
+ def _tracking(key: str, before: Keys, now: Keys) -> bool:
187
+ """Whether `key` is what `git worktree add -b x origin/main` of another session writes while a review runs: a new
188
+ branch section with `remote` on a configured remote and `merge` on a branch. Any other branch key counts."""
189
+ section, _, field = key.rpartition(".")
190
+ check = _TRACKING.get(field) if section.startswith("branch.") else None
191
+ values = now.get(key, [])
192
+ if check is None or len(values) != 1 or values[0] is None:
193
+ return False
194
+ return not any(old.startswith(section + ".") for old in before) and check(values[0], before)
195
+
196
+
197
+ def _rewrite(config: Path, key: str, values: list[str]) -> bool:
198
+ """Set `key` to `values` with git; False when a git call fails, as with a held config.lock."""
199
+ git_config = ["git", "config", "--file", str(config)]
200
+ if subprocess.run([*git_config, "--unset-all", key], capture_output=True).returncode not in (0, 5): # 5: no key
201
+ return False
202
+ return all(not subprocess.run([*git_config, "--add", key, value], capture_output=True).returncode
203
+ for value in values)
204
+
205
+
206
+ def _put_back(config: Path, keys: Keys, changed: list[str]) -> bool:
207
+ """Write the `keys` values of each changed key with git and check them; False when git cannot."""
208
+ if any(None in keys.get(key, []) for key in changed):
209
+ return False # `git config` cannot write a valueless key
210
+ if not all(_rewrite(config, key, keys.get(key, [])) for key in changed):
211
+ return False
212
+ now = _keys(config)
213
+ return now is not None and all(now.get(key) == keys.get(key) for key in changed)
214
+
215
+
216
+ def _write_whole(config: Path, data: bytes) -> bool:
217
+ """Replace the file by `data` in one rename, past any lock; whether the file now holds `data`."""
218
+ try:
219
+ temporary = config.with_name(f"{config.name}.driver-{os.getpid()}")
220
+ temporary.write_bytes(data)
221
+ if config.exists():
222
+ os.chmod(temporary, config.stat().st_mode)
223
+ os.replace(temporary, config)
224
+ return config.read_bytes() == data
225
+ except OSError:
226
+ return False
227
+
228
+
229
+ def restore_config(before: Config) -> str:
230
+ """"" when no key of the shared git config but another session's tracking entry changed since `before` (from
231
+ `shared_config`), else put back the changed keys and say which. One worktree that writes the config breaks git in
232
+ all of them, as a core.worktree on a gone directory does. Only those keys go back: other sessions write the file at
233
+ the same time. When git cannot put them back, the whole file goes back; raises Unrestored when that fails too."""
234
+ config, data, keys = before
235
+ now = _keys(config)
236
+ if now is None or keys is None:
237
+ changed = ["(git cannot read the file)"]
238
+ else:
239
+ changed = sorted(key for key in keys.keys() | now.keys()
240
+ if keys.get(key) != now.get(key) and not _tracking(key, keys, now))
241
+ if not changed or _put_back(config, keys, changed):
242
+ return f"the shared git config {config} changed: {', '.join(changed)}" if changed else ""
243
+ if not _write_whole(config, data):
244
+ raise Unrestored(f"the driver cannot restore the shared git config {config}: {', '.join(changed)}")
245
+ return f"the shared git config {config} changed: {', '.join(changed)}"
@@ -224,12 +224,15 @@ class Run:
224
224
  self.state.ticket(number, tip=driver_slots.head(slot))
225
225
 
226
226
 
227
- def _restore_if_changed(number: str, slot: str, branch: str, tip: str, config: tuple[Path, bytes],
227
+ def _restore_if_changed(number: str, slot: str, branch: str, tip: str, config: driver_review.Config,
228
228
  runs_again: bool) -> str:
229
229
  """After read-only agents: "" when the slot and the shared git config (`driver_review.shared_config` before
230
230
  them) are as they were; else restore both and return what they left."""
231
231
  # The config first: a bad core.worktree in it breaks the git commands of the slot check.
232
- changed = driver_review.restore_config(config)
232
+ try:
233
+ changed = driver_review.restore_config(config)
234
+ except driver_review.Unrestored as error:
235
+ raise Blocked(str(error)) from error
233
236
  moved = driver_review.disturbed(slot, branch, tip)
234
237
  if moved:
235
238
  driver_review.restore(slot, branch, tip)
@@ -24,10 +24,9 @@ Write one JSON report at {report}. When your sandbox is read-only, give the JSON
24
24
  ```json
25
25
  {
26
26
  "type": "object",
27
- "required": ["status", "commits", "files", "concerns", "findings"],
27
+ "required": ["status", "files", "concerns", "findings"],
28
28
  "properties": {
29
29
  "status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
30
- "commits": {"description": "Only the commits you created. A review creates none, so this list is empty: never list a commit of the range.", "type": "array", "items": {"type": "string", "pattern": "^[0-9a-f]{7,40}$"}},
31
30
  "files": {"type": "array", "items": {"type": "string"}},
32
31
  "concerns": {"type": "array", "items": {"type": "string"}},
33
32
  "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}}}},
@@ -22,10 +22,9 @@ Write one JSON report at {report} that matches this schema:
22
22
  ```json
23
23
  {
24
24
  "type": "object",
25
- "required": ["status", "commits", "files", "concerns", "findings"],
25
+ "required": ["status", "files", "concerns", "findings"],
26
26
  "properties": {
27
27
  "status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
28
- "commits": {"type": "array", "items": {"type": "string", "pattern": "^[0-9a-f]{7,40}$"}},
29
28
  "files": {"type": "array", "items": {"type": "string"}},
30
29
  "concerns": {"type": "array", "items": {"type": "string"}},
31
30
  "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}}}}
@@ -17,10 +17,9 @@ Write one JSON report at {report} that matches this schema:
17
17
  ```json
18
18
  {
19
19
  "type": "object",
20
- "required": ["status", "commits", "files", "concerns", "body"],
20
+ "required": ["status", "files", "concerns", "body"],
21
21
  "properties": {
22
22
  "status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
23
- "commits": {"type": "array", "maxItems": 0},
24
23
  "files": {"type": "array", "items": {"type": "string"}},
25
24
  "concerns": {"type": "array", "items": {"type": "string"}},
26
25
  "body": {"type": "string", "minLength": 1}
@@ -19,10 +19,9 @@ Write one JSON report at {report}. When your sandbox is read-only, give the JSON
19
19
  ```json
20
20
  {
21
21
  "type": "object",
22
- "required": ["status", "commits", "files", "concerns", "findings"],
22
+ "required": ["status", "files", "concerns", "findings"],
23
23
  "properties": {
24
24
  "status": {"enum": ["DONE", "DONE_WITH_CONCERNS", "NEEDS_CONTEXT", "BLOCKED"]},
25
- "commits": {"description": "Only the commits you created. A review creates none, so this list is empty: never list a commit of the range.", "type": "array", "items": {"type": "string", "pattern": "^[0-9a-f]{7,40}$"}},
26
25
  "files": {"type": "array", "items": {"type": "string"}},
27
26
  "concerns": {"type": "array", "items": {"type": "string"}},
28
27
  "findings": {"type": "array", "items": {"type": "object", "required": ["severity", "file", "line", "title", "evidence", "kind"], "properties": {"severity": {"enum": ["critical", "important", "minor"]}, "file": {"type": "string"}, "line": {"type": "integer"}, "title": {"type": "string", "minLength": 1}, "evidence": {"type": "string", "minLength": 1}, "kind": {"enum": ["code", "fixture", "test"]}}}},
@@ -932,6 +932,114 @@ def test_a_reviewer_that_writes_the_shared_git_config_gets_it_restored_and_runs_
932
932
  assert f".agent/implement/01/gate-{tip[:7]}.log" in prompt and "never write with `git config`" in prompt
933
933
 
934
934
 
935
+ def test_a_branch_entry_that_another_worktree_writes_during_the_review_is_no_rule_break_and_stays(tmp_path):
936
+ # Issue #130: a `git worktree add -b x origin/main` of another session writes [branch "x"] into the shared config.
937
+ rig = Inside(tmp_path)
938
+ shared = rig.repo / ".git" / "config"
939
+ # The rig has no remote, so only the merge key: the unit tests below cover a remote key.
940
+ track = {"git": [["config", "branch.x.merge", "refs/heads/main"]]}
941
+ rig.run(plan(**{"01/reviewer": [{**review("01"), **track}]}))
942
+ assert rig.code == 0, rig.ledger()
943
+ assert not rig.led("a read-only role broke its rule:") and len(rig.calls("01", "reviewer")) == 1
944
+ assert '[branch "x"]' in shared.read_text()
945
+
946
+
947
+ def config_values(config, key):
948
+ return subprocess.run(["git", "config", "--file", str(config), "--get-all", key], capture_output=True, text=True).stdout
949
+
950
+
951
+ @pytest.mark.parametrize("key, value", [("core.hooksPath", "/tmp/hooks"), ("alias.st", "!rm -rf ."),
952
+ ("include.path", "/tmp/evil"), ("remote.origin.url", "/tmp/evil")])
953
+ def test_a_dangerous_key_is_restored_and_the_other_sessions_branch_entry_stays(tmp_path, key, value):
954
+ rig = Inside(tmp_path)
955
+ shared = rig.repo / ".git" / "config"
956
+ before = config_values(shared, key)
957
+ both = {"git": [["config", key, value], ["config", "branch.x.merge", "refs/heads/main"]]}
958
+ rig.run(plan(**{"01/reviewer": [{**review("01"), **both}, review("01")]}))
959
+ assert rig.code == 0, rig.ledger()
960
+ (line,) = rig.led("Ticket 01: a read-only role broke its rule:")
961
+ assert f"the shared git config {shared.resolve()} changed: {key.lower()}" in line
962
+ assert config_values(shared, key) == before and config_values(shared, "branch.x.merge") == "refs/heads/main\n"
963
+
964
+
965
+ def tracked_repo(tmp_path):
966
+ """A repository with an origin remote and a main branch that tracks it, and its shared config."""
967
+ repo = tmp_path / "repo"
968
+ subprocess.run(["git", "init", "-q", "-b", "main", str(repo)], check=True)
969
+ for key, value in (("remote.origin.url", "/tmp/origin"), ("branch.main.remote", "origin"),
970
+ ("branch.main.merge", "refs/heads/main")):
971
+ subprocess.run(["git", "-C", str(repo), "config", key, value], check=True)
972
+ return repo, repo / ".git" / "config"
973
+
974
+
975
+ def set_key(repo, *args):
976
+ subprocess.run(["git", "-C", str(repo), "config", *args], check=True)
977
+
978
+
979
+ def test_a_new_branch_that_tracks_a_configured_remote_is_no_change(tmp_path):
980
+ repo, config = tracked_repo(tmp_path)
981
+ before = driver_review.shared_config(str(repo))
982
+ set_key(repo, "branch.y.remote", "origin")
983
+ set_key(repo, "branch.y.merge", "refs/heads/main")
984
+ assert driver_review.restore_config(before) == ""
985
+ assert config_values(config, "branch.y.merge") == "refs/heads/main\n"
986
+
987
+
988
+ @pytest.mark.parametrize("key, value", [("branch.x.remote", "/tmp/evil"), ("branch.x.remote", "nowhere"),
989
+ ("branch.x.pushremote", "origin"), ("branch.x.merge", "HEAD"),
990
+ ("branch.main.merge", "refs/heads/evil"), ("branch.main.rebase", "true")])
991
+ def test_a_branch_key_that_no_worktree_add_writes_is_flagged_and_restored(tmp_path, key, value):
992
+ repo, config = tracked_repo(tmp_path)
993
+ before = driver_review.shared_config(str(repo))
994
+ set_key(repo, key, value)
995
+ assert driver_review.restore_config(before) == f"the shared git config {config} changed: {key}"
996
+ assert config.read_bytes() == before[1]
997
+
998
+
999
+ def test_a_branch_key_next_to_an_existing_one_is_flagged(tmp_path):
1000
+ repo, config = tracked_repo(tmp_path)
1001
+ set_key(repo, "branch.x.merge", "refs/heads/main")
1002
+ before = driver_review.shared_config(str(repo))
1003
+ set_key(repo, "branch.x.remote", "origin")
1004
+ assert driver_review.restore_config(before).endswith("changed: branch.x.remote")
1005
+ assert config_values(config, "branch.x.remote") == ""
1006
+
1007
+
1008
+ def test_a_held_config_lock_falls_back_to_the_whole_file_and_is_verified(tmp_path):
1009
+ repo, config = tracked_repo(tmp_path)
1010
+ before = driver_review.shared_config(str(repo))
1011
+ mode = config.stat().st_mode
1012
+ set_key(repo, "core.hooksPath", "/tmp/hooks")
1013
+ config.with_name("config.lock").write_text("")
1014
+ assert driver_review.restore_config(before).endswith("changed: core.hookspath")
1015
+ assert config.read_bytes() == before[1] and config.stat().st_mode == mode
1016
+
1017
+
1018
+ def test_a_config_the_driver_cannot_write_back_raises(tmp_path):
1019
+ repo, config = tracked_repo(tmp_path)
1020
+ before = driver_review.shared_config(str(repo))
1021
+ set_key(repo, "core.hooksPath", "/tmp/hooks")
1022
+ config.with_name("config.lock").write_text("")
1023
+ os.chmod(config.parent, 0o555)
1024
+ try:
1025
+ with pytest.raises(driver_review.Unrestored, match="core.hookspath"):
1026
+ driver_review.restore_config(before)
1027
+ finally:
1028
+ os.chmod(config.parent, 0o755)
1029
+
1030
+
1031
+ @pytest.mark.parametrize("change", [["--unset", "x.flag"], ["x.flag", "false"], ["--add", "x.flag", "true"]])
1032
+ def test_a_valueless_key_goes_back_valueless(tmp_path, change):
1033
+ repo, config = tracked_repo(tmp_path)
1034
+ with config.open("a") as text:
1035
+ text.write("[x]\n\tflag\n")
1036
+ before = driver_review.shared_config(str(repo))
1037
+ assert before[2]["x.flag"] == [None]
1038
+ set_key(repo, *change)
1039
+ assert driver_review.restore_config(before).endswith("changed: x.flag")
1040
+ assert config.read_bytes() == before[1]
1041
+
1042
+
935
1043
  def test_a_reviewer_that_times_out_starts_again_from_the_clean_tip(tmp_path):
936
1044
  hang = {"files": {"demo/export.py": "mutated\n", "junk.txt": "x\n"}, "sleep": 60}
937
1045
  rig = Inside(tmp_path).run(plan(**{"01/reviewer": [hang, review("01")]}), "--timeout", "reviewer=0.03")
@@ -1137,13 +1245,6 @@ def test_a_review_stop_answered_redesign_keeps_the_ticket_blocked(tmp_path):
1137
1245
  assert len(rig.calls("02", "correctness")) == 1
1138
1246
 
1139
1247
 
1140
- @pytest.mark.parametrize("role", ["reviewer", "correctness"])
1141
- def test_the_schema_of_a_review_says_that_commits_holds_only_the_agents_own_commits(role):
1142
- """Issue 66: a reviewer that lists a commit of the range costs a rerun (`is not a new commit`)."""
1143
- description = driver_report.schema(role)["properties"]["commits"]["description"]
1144
- assert "only the commits you created" in description.lower() and "empty" in description
1145
-
1146
-
1147
1248
  def test_the_reviewer_schema_asks_for_one_proof_for_each_locked_test_file_in_the_first_review():
1148
1249
  """Issue 66: a first review with no proof for a locked test file costs a rerun."""
1149
1250
  description = driver_report.schema("reviewer")["properties"]["mutations"]["description"]
@@ -8,6 +8,7 @@ import subprocess
8
8
 
9
9
  import pytest
10
10
 
11
+ from driver_agents import READ_ONLY
11
12
  from driver_report import validate
12
13
 
13
14
  GIT = ["git", "-c", "user.name=t", "-c", "user.email=t@example.com", "-c", "commit.gpgsign=false"]
@@ -192,3 +193,12 @@ def test_reviewer_fields_and_mutation_proofs(world):
192
193
  assert any("mutations" in e for e in check("reviewer", no_proof, start=shas["impl"], full=True))
193
194
  fake = reviewer(mutations=[{"test": "t", "file": "demo/export.py", "line": 2, "red": "never ran"}])
194
195
  assert any("not found in log" in e for e in check("reviewer", fake, start=shas["impl"], full=True))
196
+
197
+
198
+ @pytest.mark.parametrize("role", READ_ONLY)
199
+ def test_a_read_only_role_lists_no_commits_so_the_commits_it_reviewed_are_not_refused(world, role):
200
+ # Issue #129: the final reviewer read `commits` as the commits under review, and each was refused as not new.
201
+ shas, check, _ = world
202
+ report = {"status": "DONE", "files": [], "concerns": [], "findings": [], "body": "b"}
203
+ assert check(role, report, start=shas["impl"]) == []
204
+ assert check(role, {**report, "commits": [shas["tests"], shas["impl"]]}, start=shas["impl"]) == []
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-10-20T17:59:20.836Z",
3
+ "generatedAt": "2026-10-20T22:41:26.424Z",
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.35",
50
- "hash": "sha256-4e94140abbc0dc964ec2dc9c0fbb0e5c4bb4a8e11d1e4c4bbd278c5321223fd6",
49
+ "version": "0.1.37",
50
+ "hash": "sha256-87d03c44e4dfd6624de7cc987f793fce31f419939c29ddbfee19fbabd88dac3e",
51
51
  "description": "Implement a specification in code."
52
52
  },
53
53
  {