@jesdi/skills 0.0.91 → 0.0.92
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/skills/implement-spec/README.md +4 -1
- package/skills/implement-spec/driver_decisions.py +6 -4
- package/skills/implement-spec/driver_run.py +4 -6
- package/skills/implement-spec/driver_slots.py +13 -1
- package/skills/implement-spec/recovery.md +63 -0
- package/skills/implement-spec/tests/test_agents.py +2 -2
- package/skills/implement-spec/tests/test_driver.py +110 -2
- package/skills/implement-spec/tests/test_slots.py +67 -0
- package/skills/implement-spec/tests/test_tidy.py +2 -1
- package/skills-manifest.json +3 -3
package/package.json
CHANGED
|
@@ -81,6 +81,7 @@ Everything is under `.agent/`, which is never committed.
|
|
|
81
81
|
|---|---|
|
|
82
82
|
| `.agent/implement/state.json` | The resume contract: the run record and one record for each ticket (`driver_state.py`). |
|
|
83
83
|
| `<git common directory>/implement-spec/<key>.lock` | An empty file, not in the worktree. The driver that runs holds a kernel file lock on it (`driver_state.py` `lock`). Do not remove it during a run. |
|
|
84
|
+
| `<git common directory>/implement-spec-worktrees.lock` | Shared by driver processes for `worktree`, `checkout`, `switch` and `branch` commands, so a checkout never reads another driver's half-written registration. Held only during that Git command, never during preparation, agents or gates. Git commands outside the driver do not participate. |
|
|
84
85
|
| `.agent/implement/ledger.md` | One plain sentence for each event. Only the driver writes it, and it reads no fact from it. |
|
|
85
86
|
| `.agent/implement/summary.md` | The result in sentences, and the measurement table: fast gates and full gates, agents, wall time, fix rounds, human stops, cost. |
|
|
86
87
|
| `.agent/implement/decisions.json` | The open questions and their `revision`. Written only after a stop. |
|
|
@@ -229,7 +230,7 @@ A question is a bounded choice for the operator. `driver_decisions.py` `KINDS` h
|
|
|
229
230
|
| Kind | Question id | Asked when | Run exit | Options |
|
|
230
231
|
|---|---|---|---|---|
|
|
231
232
|
| `spec-ambiguous` | `<NN>-spec-ambiguous-<n>` | A second dispute on a locked test that the reviewer ruled on in the ticket, or a second correction needed for a locked test of the ticket (a `test-wrong` ruling or a review finding on a test corrected before); or a dispute or a review correction after the ticket's locked tests were settled 3 times. Another test of the same file, or another missing test that a review finding asks for, is no second correction. The subject names the test, the requirement and the two readings; the evidence is `spec-ambiguous-<n>.json`. | 2 | No option is recommended. `keep-test`: the role that disputed runs again against the test; after a review finding, the ticket resumes from the review and later findings with the same key are closed: on that test, a `fixture` finding on that file that names no test, or the same missing test. `correct-test`: one more correction, to the second reading, then the role that disputed runs again (the fixer of the same round after the review of its round); after a review finding, the review runs again. `edit-spec`: the ticket stays BLOCKED, with the ruling in the ledger. None of them changes the ticket's `disputes` or `corrected`. |
|
|
232
|
-
| `ticket-blocked` | `<NN>-ticket-blocked-<n>`, `final-ticket-blocked-<n>` | A ticket agent (test-writer, implementer, reviewer, fixer, conflict) or an agent of the end of run stopped with `BLOCKED` or `NEEDS_CONTEXT` or was rejected, and its rerun
|
|
233
|
+
| `ticket-blocked` | `<NN>-ticket-blocked-<n>`, `final-ticket-blocked-<n>` | A ticket agent (test-writer, implementer, reviewer, fixer, conflict) or an agent of the end of run stopped with `BLOCKED` or `NEEDS_CONTEXT` or was rejected, and its rerun did too (the same model for a timeout or moved branch, the next entry otherwise); or a finding is open after the scoped review of the final fix batch (one question per finding). The subject names the role and the reason, or the finding. | 2 | `retry` (recommended): the role runs again on its first entry from the tip the ticket left, with its one rerun; for a fixer, the round that stopped does not count: the driver gates and reviews the tip, and a fixer runs that round again on the review's findings. An arbitration or a correction runs for another role, so its work is not kept: after a dispute, the role that disputed runs again from the tip before them; after a review correction, the driver reviews that tip again. For the end of run, the stopped agent runs again from where the end of run is; for an open finding, one more fix batch and scoped review run. `edit`: the ticket, or the end of run, stays BLOCKED, with the ruling in the ledger, so the spec or the ticket can be edited. |
|
|
233
234
|
|
|
234
235
|
`final-finding` (fix or accept a finding open after the second round of the final review) became a `ticket-blocked` question of the end of run, id `final-ticket-blocked-<n>`: whether one more batch runs is the operator's call, and nothing ships with an open finding, so there is no `accept`.
|
|
235
236
|
|
|
@@ -237,6 +238,8 @@ A question is a bounded choice for the operator. `driver_decisions.py` `KINDS` h
|
|
|
237
238
|
|
|
238
239
|
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.
|
|
239
240
|
|
|
241
|
+
For an older questionless BLOCKED record, see [operator recovery](recovery.md). Recovery requires an explicit verified checkpoint; starting this version never guesses one.
|
|
242
|
+
|
|
240
243
|
## The non-negotiable checks
|
|
241
244
|
|
|
242
245
|
| Check | Where it lives |
|
|
@@ -68,13 +68,15 @@ KINDS = {
|
|
|
68
68
|
# The end of run asks it too, with the ticket `final`: for an agent, or for a finding open after the scoped review.
|
|
69
69
|
"ticket-blocked": Kind(
|
|
70
70
|
"{owner}: an agent stopped or was rejected, and its rerun too, or a final-review finding is open: {subject}",
|
|
71
|
-
"An agent ran two times, the
|
|
72
|
-
"both times; or the scoped review after the fix batch of the final review left
|
|
71
|
+
"An agent ran two times, using the same model for a timeout or moved branch and the next entry otherwise, "
|
|
72
|
+
"and stopped or was rejected both times; or the scoped review after the fix batch of the final review left "
|
|
73
|
+
"a finding open. {owner} is "
|
|
73
74
|
"BLOCKED, each ticket that it blocks waits, and nothing is pushed.",
|
|
74
75
|
"retry",
|
|
75
76
|
{"retry": Option(
|
|
76
|
-
"The role runs again on its first entry from the tip the ticket left, with
|
|
77
|
-
"entry; for an open final-review finding,
|
|
77
|
+
"The role runs again on its first entry from the tip the ticket left, with one rerun (the same model "
|
|
78
|
+
"for a timeout or moved branch, the next entry otherwise); for an open final-review finding, "
|
|
79
|
+
"one more fix batch and scoped review run.",
|
|
78
80
|
"Ruling: {ticket} runs again (retry): {subject}.", True),
|
|
79
81
|
"edit": Option(
|
|
80
82
|
"Keep it BLOCKED, so the spec or the ticket can be edited before more work on it.",
|
|
@@ -319,11 +319,9 @@ def _ask_blocked(run: Run, call: Call, report: Path, error: str) -> None:
|
|
|
319
319
|
run.ask(call.number, "ticket-blocked", [f"the {call.role}: {error}"], str(report), resume)
|
|
320
320
|
|
|
321
321
|
|
|
322
|
-
def _give_up(run: Run, call: Call, report: Path, error: str
|
|
323
|
-
"""
|
|
324
|
-
|
|
325
|
-
if not same:
|
|
326
|
-
_ask_blocked(run, call, report, error)
|
|
322
|
+
def _give_up(run: Run, call: Call, report: Path, error: str) -> NoReturn:
|
|
323
|
+
"""Every exhausted rerun asks before another attempt, including timeouts and moved branches."""
|
|
324
|
+
_ask_blocked(run, call, report, error)
|
|
327
325
|
raise Blocked(error)
|
|
328
326
|
|
|
329
327
|
|
|
@@ -403,4 +401,4 @@ def _attempts(run: Run, call: Call) -> dict:
|
|
|
403
401
|
if code is None:
|
|
404
402
|
minutes *= 2
|
|
405
403
|
entry = entry if same else rerun_on
|
|
406
|
-
_give_up(run, call, report, error
|
|
404
|
+
_give_up(run, call, report, error)
|
|
@@ -4,6 +4,7 @@ Every path is relative to the PR worktree, which is the driver's working directo
|
|
|
4
4
|
"""
|
|
5
5
|
from __future__ import annotations
|
|
6
6
|
|
|
7
|
+
import fcntl
|
|
7
8
|
import subprocess
|
|
8
9
|
from pathlib import Path
|
|
9
10
|
|
|
@@ -14,7 +15,18 @@ class PreparationError(RuntimeError):
|
|
|
14
15
|
|
|
15
16
|
def git(slot: str, *args: str) -> subprocess.CompletedProcess[str]:
|
|
16
17
|
# core.quotePath off: git prints a path with a non-ASCII name as it is, so it equals the path that a report names.
|
|
17
|
-
|
|
18
|
+
command = ["git", "-C", slot, "-c", "core.quotePath=false", *args]
|
|
19
|
+
if not args or args[0] not in ("checkout", "switch", "branch", "worktree"):
|
|
20
|
+
return subprocess.run(command, capture_output=True, text=True)
|
|
21
|
+
# These commands mutate or scan the shared registry. Git exposes a temporarily empty
|
|
22
|
+
# commondir while adding a checkout; another checkout can otherwise fail reading it.
|
|
23
|
+
common = subprocess.run(["git", "-C", slot, "rev-parse", "--path-format=absolute", "--git-common-dir"],
|
|
24
|
+
capture_output=True, text=True)
|
|
25
|
+
if common.returncode:
|
|
26
|
+
return common
|
|
27
|
+
with (Path(common.stdout.strip()) / "implement-spec-worktrees.lock").open("a") as held:
|
|
28
|
+
fcntl.flock(held, fcntl.LOCK_EX)
|
|
29
|
+
return subprocess.run(command, capture_output=True, text=True)
|
|
18
30
|
|
|
19
31
|
|
|
20
32
|
def names(listing: str) -> list[str]:
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Recover an older questionless implementer stop
|
|
2
|
+
|
|
3
|
+
Use this only when an older run stopped after two implementer attempts and left ticket `phase: blocked` with no question. Repair the reported environment problem first. New runs ask `ticket-blocked` after exhausted retries, including timeouts and moved branches.
|
|
4
|
+
|
|
5
|
+
Stop the driver and prevent the dispatcher from resuming it during recovery. In the PR worktree, preserve any dirty files with a binary patch and exact file copies outside tracked paths. Do not reset the checkout or overwrite locked tests. Keep the branch and driver records; recovery adds a question, not a passing gate.
|
|
6
|
+
|
|
7
|
+
Read the ticket's ledger and reports. Confirm that the implementer stopped before any accepted implementation and that its recorded tip is still the test-writer commit. The command below accepts only that narrow checkpoint: schema 5, round zero, no gate results, no prior question for this ticket, two recorded implementer attempts, and an intact test-writer commit on the ticket branch. Other phases, uncertain evidence, or prior operator decisions require investigation; do not guess a phase or delete state to start over.
|
|
8
|
+
|
|
9
|
+
Run the following from the PR worktree, replacing the skill path, ticket number and full verified test-writer SHA. It takes the driver's locks, backs up state, records a question through the existing helper and leaves the ticket BLOCKED. No checkout, branch or gate is changed.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
python3 - /path/to/implement-spec 01 VERIFIED_TEST_WRITER_SHA <<'PY'
|
|
13
|
+
import json
|
|
14
|
+
import sys
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
sys.path.insert(0, sys.argv[1])
|
|
18
|
+
import driver
|
|
19
|
+
import driver_decisions
|
|
20
|
+
import driver_names
|
|
21
|
+
import driver_slots
|
|
22
|
+
import driver_state
|
|
23
|
+
|
|
24
|
+
number, tip = sys.argv[2:]
|
|
25
|
+
path = Path('.agent/implement/state.json')
|
|
26
|
+
state = driver_state.State(path)
|
|
27
|
+
pr = state.read()['run']['pr_branch']
|
|
28
|
+
common = Path(driver_slots.git('.', 'rev-parse', '--git-common-dir').stdout.strip()).resolve()
|
|
29
|
+
held, error = driver._hold(common, pr)
|
|
30
|
+
if not held:
|
|
31
|
+
raise SystemExit(error)
|
|
32
|
+
with held:
|
|
33
|
+
before = path.read_bytes()
|
|
34
|
+
data = json.loads(before)
|
|
35
|
+
entry = data['tickets'][number]
|
|
36
|
+
attempts = [a['role'] for a in data['run']['agents'] if a['ticket'] == number]
|
|
37
|
+
branch = driver_names.Names(pr).ticket(number)
|
|
38
|
+
valid = (data['run']['schema'] == 5 and entry['phase'] == 'blocked'
|
|
39
|
+
and entry['round'] == 0 and entry['tip'] == entry['test_writer_sha'] == tip
|
|
40
|
+
and entry['locked'] and not any(entry['green_gates'].values())
|
|
41
|
+
and not any(q['ticket'] == number for q in data['run']['questions'])
|
|
42
|
+
and attempts[-2:] == ['implementer', 'implementer']
|
|
43
|
+
and driver_slots.git('.', 'rev-parse', '--verify', branch).stdout.strip() == tip)
|
|
44
|
+
if not valid:
|
|
45
|
+
raise SystemExit('Checkpoint not verified; leave state unchanged and investigate.')
|
|
46
|
+
backup = path.with_name(f'state-before-recovery-{number}.json')
|
|
47
|
+
with backup.open('xb') as out:
|
|
48
|
+
out.write(before)
|
|
49
|
+
def recover(current):
|
|
50
|
+
driver_decisions.stop(current['run'], 'ticket-blocked', number,
|
|
51
|
+
['Operator verified the repaired environment and pre-implementation checkpoint.'],
|
|
52
|
+
['.agent/implement/ledger.md'], driver_decisions.Resume('implement', tip))
|
|
53
|
+
updated = state.update(recover)
|
|
54
|
+
question = updated['run']['questions'][-1]['id']
|
|
55
|
+
with path.with_name('ledger.md').open('a') as out:
|
|
56
|
+
out.write(f'Operator recovery: backup {backup}; added {question} at verified tip {tip}.\n')
|
|
57
|
+
print(f'Rerun the original driver command with --answer {question}=retry')
|
|
58
|
+
PY
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The normal driver invocation publishes the question and consumes that answer. Keep all original gate, spec and push flags. It reruns the implementer, then the normal gates and reviews; locked-test ownership stays unchanged. An unanswered invocation stays parked and creates no second question.
|
|
62
|
+
|
|
63
|
+
If the driver refuses dirty files, keep their verified backup and determine which slot owns them before restoring anything. Inspect preserved implementation as input to the resumed implementer; do not apply test changes over its locked baseline. Keep the recovery backup until the ticket is safely completed.
|
|
@@ -422,10 +422,10 @@ def test_timeout_keeps_the_tree_and_reruns_once_with_double_the_limit(env):
|
|
|
422
422
|
assert git(w.repo, "show", "feat/csv:wip.txt") == "half done\n"
|
|
423
423
|
|
|
424
424
|
|
|
425
|
-
def
|
|
425
|
+
def test_second_timeout_asks_before_retrying_the_ticket(env):
|
|
426
426
|
w = World(env, refactor=True)
|
|
427
427
|
hang = {"files": {"wip.txt": "half done\n"}, "sleep": 60}
|
|
428
|
-
|
|
428
|
+
asks(w.run({"implementer": [hang, hang, impl()]}, "--timeout", "implementer=0.04"))
|
|
429
429
|
assert len(w.calls("implementer")) == 2
|
|
430
430
|
assert any("BLOCKED" in l and "timed out" in l for l in w.ledger().splitlines()), w.ledger()
|
|
431
431
|
assert (w.repo / "wip.txt").exists()
|
|
@@ -304,10 +304,10 @@ def test_concurrent_first_runs_of_the_launcher_all_succeed(tmp_path):
|
|
|
304
304
|
assert [p.name for p in (cache / "venv").iterdir()] == ["3.13.7-jsonschema-4.26.0"]
|
|
305
305
|
|
|
306
306
|
|
|
307
|
-
def
|
|
307
|
+
def test_a_timeout_doubles_the_limit_and_a_second_one_asks_to_retry(repo, tmp_path, capsys):
|
|
308
308
|
repo()
|
|
309
309
|
code, ledger = agents(tmp_path, capsys, "exec sleep 30\n", "--timeout", "implementer=0.005")
|
|
310
|
-
assert code ==
|
|
310
|
+
assert code == 2
|
|
311
311
|
assert ledger[0].endswith(": timed out after 0.005 minutes.") and ledger[1].endswith(": timed out after 0.01 minutes.")
|
|
312
312
|
assert ledger[2].startswith("Ticket 01: BLOCKED at the implementer: timed out")
|
|
313
313
|
|
|
@@ -330,6 +330,70 @@ def test_a_moved_head_resets_the_slot_and_reruns(repo, tmp_path, capsys, move, p
|
|
|
330
330
|
assert subprocess.run(["git", "rev-parse", "feat/x~1"], capture_output=True, text=True).stdout.strip() == tip
|
|
331
331
|
|
|
332
332
|
|
|
333
|
+
@pytest.mark.parametrize("failure", [
|
|
334
|
+
"git checkout -q --detach; git branch -q -D ticket/feat%2Fx/01; exit 0\n",
|
|
335
|
+
"echo unfinished > code.txt; exec sleep 30\n",
|
|
336
|
+
])
|
|
337
|
+
def test_exhausted_same_model_retry_can_resume_without_losing_locked_tests(repo, tmp_path, capsys, failure):
|
|
338
|
+
repo()
|
|
339
|
+
writer = f"if [ $role = test-writer ]; then\n{COMMIT}{WRITER}{REPORT}exit 0; fi\n"
|
|
340
|
+
code, _ = agents(tmp_path, capsys, writer + failure,
|
|
341
|
+
"--timeout", "implementer=0.005", seam="`f()`")
|
|
342
|
+
assert code == 2
|
|
343
|
+
state = state_of(tmp_path)
|
|
344
|
+
entry = state["tickets"]["01"]
|
|
345
|
+
locked = entry["test_writer_sha"]
|
|
346
|
+
question, = state["run"]["questions"]
|
|
347
|
+
assert question["id"] == "01-ticket-blocked-1"
|
|
348
|
+
assert question["resume"] == {"phase": "implement", "tip": locked}
|
|
349
|
+
assert entry["phase"] == "blocked" and entry["locked"] == ["work.txt"]
|
|
350
|
+
assert state["run"]["gates"] == {"fast": 0, "full": 0}
|
|
351
|
+
if "unfinished" in failure:
|
|
352
|
+
assert (tmp_path / "code.txt").read_text() == "unfinished\n"
|
|
353
|
+
code, _ = agents(tmp_path, capsys, failure, seam="`f()`")
|
|
354
|
+
assert code == 2 and state_of(tmp_path)["run"]["questions"] == [question]
|
|
355
|
+
assert state_of(tmp_path)["run"]["agents"] == state["run"]["agents"]
|
|
356
|
+
good = COMMIT.replace("work.txt", "code.txt") + IMPLEMENTER + REPORT
|
|
357
|
+
code, _ = agents(tmp_path, capsys, good, "--answer", question["id"] + "=retry", seam="`f()`")
|
|
358
|
+
assert code == 0
|
|
359
|
+
final = state_of(tmp_path)
|
|
360
|
+
assert final["tickets"]["01"]["phase"] == "merged"
|
|
361
|
+
assert final["tickets"]["01"]["test_writer_sha"] == locked
|
|
362
|
+
assert final["run"]["gates"]["fast"] >= 1 and final["run"]["gates"]["full"] >= 1
|
|
363
|
+
assert (tmp_path / "work.txt").read_text() == "test-writer\n"
|
|
364
|
+
assert sum(agent["role"] == "test-writer" for agent in final["run"]["agents"]) == 1
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
def test_documented_recovery_validates_an_older_checkpoint_before_adding_a_question(repo, tmp_path, capsys):
|
|
368
|
+
repo()
|
|
369
|
+
writer = f"if [ $role = test-writer ]; then\n{COMMIT}{WRITER}{REPORT}exit 0; fi\n"
|
|
370
|
+
failure = "git checkout -q --detach; git branch -q -D ticket/feat%2Fx/01; exit 0\n"
|
|
371
|
+
assert agents(tmp_path, capsys, writer + failure, seam="`f()`")[0] == 2
|
|
372
|
+
path = tmp_path / ".agent/implement/state.json"
|
|
373
|
+
data = state_of(tmp_path)
|
|
374
|
+
data["run"]["questions"] = [] # persisted by the older same-model failure path
|
|
375
|
+
path.write_text(json.dumps(data))
|
|
376
|
+
before = path.read_bytes()
|
|
377
|
+
tip = data["tickets"]["01"]["test_writer_sha"]
|
|
378
|
+
skill = Path(driver.__file__).parent
|
|
379
|
+
script = (skill / "recovery.md").read_text().split("<<'PY'\n", 1)[1].split("\nPY\n", 1)[0]
|
|
380
|
+
command = [sys.executable, "-", str(skill), "01"]
|
|
381
|
+
refused = subprocess.run([*command, "0" * 40], input=script, text=True, capture_output=True)
|
|
382
|
+
assert refused.returncode != 0 and "Checkpoint not verified" in refused.stderr
|
|
383
|
+
assert path.read_bytes() == before and not path.with_name("state-before-recovery-01.json").exists()
|
|
384
|
+
recovered = subprocess.run([*command, tip], input=script, text=True, capture_output=True)
|
|
385
|
+
assert recovered.returncode == 0, recovered.stderr
|
|
386
|
+
assert "--answer 01-ticket-blocked-1=retry" in recovered.stdout
|
|
387
|
+
assert path.with_name("state-before-recovery-01.json").read_bytes() == before
|
|
388
|
+
after = path.read_bytes()
|
|
389
|
+
repeated = subprocess.run([*command, tip], input=script, text=True, capture_output=True)
|
|
390
|
+
assert repeated.returncode != 0 and path.read_bytes() == after
|
|
391
|
+
good = COMMIT.replace("work.txt", "code.txt") + IMPLEMENTER + REPORT
|
|
392
|
+
assert agents(tmp_path, capsys, good, "--answer", "01-ticket-blocked-1=retry", seam="`f()`")[0] == 0
|
|
393
|
+
assert state_of(tmp_path)["tickets"]["01"]["test_writer_sha"] == tip
|
|
394
|
+
assert (tmp_path / "work.txt").read_text() == "test-writer\n"
|
|
395
|
+
|
|
396
|
+
|
|
333
397
|
def test_an_existing_ticket_branch_stops_the_run(repo, tmp_path, capsys):
|
|
334
398
|
repo()
|
|
335
399
|
subprocess.run(["git", "branch", "ticket/feat%2Fx/01"], check=True)
|
|
@@ -1062,3 +1126,47 @@ def test_resume_reports_all_saved_state_errors_without_starting_an_agent(repo, t
|
|
|
1062
1126
|
".agent/implement/state.json: ticket 01 has the unknown phase 'polish'",
|
|
1063
1127
|
".agent/implement/state.json: ticket 02 has the unknown phase 'ship'",
|
|
1064
1128
|
]
|
|
1129
|
+
|
|
1130
|
+
|
|
1131
|
+
def test_parallel_checkout_waits_for_worktree_registration_to_finish(repo, tmp_path, capsys, monkeypatch):
|
|
1132
|
+
"""Pause Git at its visible-but-incomplete registry entry while the other ticket starts."""
|
|
1133
|
+
import shutil
|
|
1134
|
+
import threading
|
|
1135
|
+
import driver_slots
|
|
1136
|
+
|
|
1137
|
+
two(repo)
|
|
1138
|
+
partial, checked = threading.Event(), threading.Event()
|
|
1139
|
+
real_run, real_ticket = subprocess.run, driver._run_ticket
|
|
1140
|
+
failures = []
|
|
1141
|
+
|
|
1142
|
+
def ticket_after_registration_starts(ticket, slot, run):
|
|
1143
|
+
if slot == 1:
|
|
1144
|
+
assert partial.wait(5), "slot 2 was never registered"
|
|
1145
|
+
return real_ticket(ticket, slot, run)
|
|
1146
|
+
|
|
1147
|
+
def paused_git(argv, *args, **kwargs):
|
|
1148
|
+
if argv[0] == "git" and "worktree" in argv and "add" in argv:
|
|
1149
|
+
metadata = tmp_path / ".git/worktrees/slot-2"
|
|
1150
|
+
metadata.mkdir(parents=True)
|
|
1151
|
+
checkout = tmp_path / ".agent/worktrees/slot-2"
|
|
1152
|
+
checkout.mkdir(parents=True)
|
|
1153
|
+
(checkout / ".git").write_text(f"gitdir: {metadata}\n")
|
|
1154
|
+
(metadata / "gitdir").write_text(str(checkout / ".git") + "\n")
|
|
1155
|
+
(metadata / "HEAD").write_text(out_of("git", "rev-parse", "feat/x") + "\n")
|
|
1156
|
+
(metadata / "commondir").touch() # open(O_CREAT) precedes Git writing ../..
|
|
1157
|
+
partial.set()
|
|
1158
|
+
checked.wait(1)
|
|
1159
|
+
shutil.rmtree(metadata)
|
|
1160
|
+
shutil.rmtree(checkout)
|
|
1161
|
+
result = real_run(argv, *args, **kwargs)
|
|
1162
|
+
if argv[0] == "git" and "checkout" in argv and "ticket/feat%2Fx/01" in argv:
|
|
1163
|
+
if result.returncode:
|
|
1164
|
+
failures.append(result.stderr)
|
|
1165
|
+
checked.set()
|
|
1166
|
+
return result
|
|
1167
|
+
|
|
1168
|
+
monkeypatch.setattr(driver, "_run_ticket", ticket_after_registration_starts)
|
|
1169
|
+
monkeypatch.setattr(driver_slots.subprocess, "run", paused_git)
|
|
1170
|
+
code, _, out = walk(tmp_path, capsys, WORK + REPORT)
|
|
1171
|
+
assert code == 0, out + "\n" + "\n".join(failures)
|
|
1172
|
+
assert failures == []
|
|
@@ -116,3 +116,70 @@ def test_a_locked_index_does_not_report_a_slot_released(repo, tmp_path):
|
|
|
116
116
|
Path(index).touch()
|
|
117
117
|
assert not driver_slots.release(slot)
|
|
118
118
|
assert driver_slots.on_branch(slot) == 'ticket/held'
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def test_registry_operations_coordinate_across_processes_and_linked_checkouts(repo, tmp_path):
|
|
122
|
+
import sys
|
|
123
|
+
from pathlib import Path
|
|
124
|
+
import pytest
|
|
125
|
+
|
|
126
|
+
repo()
|
|
127
|
+
other = tmp_path.parent / f"{tmp_path.name}-linked"
|
|
128
|
+
subprocess.run(["git", "worktree", "add", "-q", "--detach", str(other)], check=True)
|
|
129
|
+
unrelated = tmp_path.parent / f"{tmp_path.name}-independent"
|
|
130
|
+
subprocess.run(["git", "clone", "-q", "--no-hardlinks", str(tmp_path), str(unrelated)], check=True)
|
|
131
|
+
program = r'''
|
|
132
|
+
import subprocess, sys
|
|
133
|
+
sys.path.insert(0, sys.argv[1])
|
|
134
|
+
import driver_slots
|
|
135
|
+
real_run = subprocess.run
|
|
136
|
+
mode = sys.argv[2]
|
|
137
|
+
def pause_add(command, *args, **kwargs):
|
|
138
|
+
if "worktree" in command and "add" in command:
|
|
139
|
+
print("holding registration", flush=True)
|
|
140
|
+
sys.stdin.readline()
|
|
141
|
+
return real_run(command, *args, **kwargs)
|
|
142
|
+
if mode == "add":
|
|
143
|
+
driver_slots.subprocess.run = pause_add
|
|
144
|
+
result = driver_slots.git(".", "worktree", "add", "-q", "--detach", ".agent/worktrees/new")
|
|
145
|
+
else:
|
|
146
|
+
print("requesting checkout", flush=True)
|
|
147
|
+
result = driver_slots.git(".", "checkout", "-q", "--detach")
|
|
148
|
+
print(result.stderr, flush=True)
|
|
149
|
+
sys.exit(result.returncode)
|
|
150
|
+
'''
|
|
151
|
+
command = [sys.executable, "-u", "-c", program, str(Path(driver_slots.__file__).parent)]
|
|
152
|
+
add = subprocess.Popen([*command, "add"], cwd=tmp_path, stdin=subprocess.PIPE,
|
|
153
|
+
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
|
154
|
+
checkout = None
|
|
155
|
+
try:
|
|
156
|
+
assert add.stdout.readline().strip() == "holding registration"
|
|
157
|
+
checkout = subprocess.Popen([*command, "checkout"], cwd=other, stdout=subprocess.PIPE,
|
|
158
|
+
stderr=subprocess.PIPE, text=True)
|
|
159
|
+
assert checkout.stdout.readline().strip() == "requesting checkout"
|
|
160
|
+
with pytest.raises(subprocess.TimeoutExpired):
|
|
161
|
+
checkout.communicate(timeout=0.2)
|
|
162
|
+
# Read-only commands do not wait on worktree registration.
|
|
163
|
+
probe = "import sys; sys.path.insert(0, sys.argv[1]); import driver_slots; print(driver_slots.head('.'))"
|
|
164
|
+
read = subprocess.run([sys.executable, "-c", probe, str(Path(driver_slots.__file__).parent)],
|
|
165
|
+
cwd=tmp_path, capture_output=True, text=True, timeout=5)
|
|
166
|
+
assert read.returncode == 0 and read.stdout.strip(), read.stderr
|
|
167
|
+
independent = subprocess.run([*command, "checkout"], cwd=unrelated, capture_output=True, text=True, timeout=5)
|
|
168
|
+
assert independent.returncode == 0, independent.stderr
|
|
169
|
+
add.stdin.write("continue\n")
|
|
170
|
+
add.stdin.flush()
|
|
171
|
+
out, err = add.communicate(timeout=5)
|
|
172
|
+
assert add.returncode == 0, out + err
|
|
173
|
+
out, err = checkout.communicate(timeout=5)
|
|
174
|
+
assert checkout.returncode == 0, out + err
|
|
175
|
+
finally:
|
|
176
|
+
for process in (add, checkout):
|
|
177
|
+
if process is not None and process.poll() is None:
|
|
178
|
+
process.kill()
|
|
179
|
+
process.communicate()
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_git_without_a_command_still_returns_gits_usage_error(repo):
|
|
183
|
+
repo()
|
|
184
|
+
result = driver_slots.git(".")
|
|
185
|
+
assert result.returncode != 0 and "usage: git" in result.stdout + result.stderr
|
|
@@ -260,7 +260,8 @@ def test_a_fixer_that_times_out_twice_keeps_its_files_and_the_branch_stays_at_th
|
|
|
260
260
|
rig.run(plan(**{"final/final-spec": [final(finding("Q-ONE"))], "final/fixer": [slow, slow]}),
|
|
261
261
|
"--timeout", "fixer=0.01", *UNATTENDED)
|
|
262
262
|
reviewed = rig.final()["reviewed"]
|
|
263
|
-
assert rig.code ==
|
|
263
|
+
assert rig.code == 2 and rig.pushes() == [] and rig.branch() == reviewed, rig.out
|
|
264
|
+
assert decisions(rig)["questions"][0]["id"] == "final-ticket-blocked-1"
|
|
264
265
|
assert (rig.repo / "wip.txt").read_text() == "half done\n"
|
|
265
266
|
assert rig.led(f"End of run: the fix batch was rejected, so the driver moved feat/csv back to its reviewed tip "
|
|
266
267
|
f"{reviewed[:7]}; the fixer made no commit. The files of the fixer stay in slot 1 as they are.")
|
package/skills-manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-08T03:27:01.103Z",
|
|
4
4
|
"skills": [
|
|
5
5
|
{
|
|
6
6
|
"name": "agents-wayfinder",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
60
|
"name": "implement-spec",
|
|
61
|
-
"version": "0.1.
|
|
62
|
-
"hash": "sha256-
|
|
61
|
+
"version": "0.1.55",
|
|
62
|
+
"hash": "sha256-2580c33f386f59b4eb362c1416eeb84420baa8cd3a2edbff1ed07950dcea8ef4",
|
|
63
63
|
"description": "Implement a specification in code."
|
|
64
64
|
},
|
|
65
65
|
{
|