@elvis1513/auto-coding-skill 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +111 -54
- package/cli/assets/agents/browser-debugger.toml +5 -7
- package/cli/assets/agents/docs-researcher.toml +3 -5
- package/cli/assets/agents/explorer.toml +5 -10
- package/cli/assets/agents/fixer.toml +19 -17
- package/cli/assets/agents/reviewer.toml +14 -10
- package/cli/assets/skill/SKILL.md +111 -49
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +475 -0
- package/cli/assets/skill/data/templates/ENGINEERING.md +164 -82
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +4 -4
- package/cli/assets/skill/data/templates/docs/tasks/closure-log.md +7 -6
- package/cli/assets/skill/data/templates/docs/tasks/taskbook.md +11 -4
- package/cli/assets/skill/scripts/ap.py +1000 -563
- package/cli/src/index.js +399 -51
- package/cli/tests/ap_concurrency_test.py +396 -75
- package/cli/tests/ap_profiles_test.py +242 -99
- package/cli/tests/index.test.js +409 -15
- package/package.json +3 -3
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
|
+
import os
|
|
5
6
|
import subprocess
|
|
6
7
|
import sys
|
|
7
8
|
import tempfile
|
|
@@ -13,7 +14,7 @@ import yaml
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
REPO_ROOT = Path(__file__).resolve().parents[2]
|
|
16
|
-
AP_SCRIPT = REPO_ROOT / "
|
|
17
|
+
AP_SCRIPT = REPO_ROOT / "src" / "auto-coding-skill" / "scripts" / "ap.py"
|
|
17
18
|
_MISSING = object()
|
|
18
19
|
|
|
19
20
|
|
|
@@ -50,8 +51,22 @@ def git_output(cwd: Path, *args: str) -> str:
|
|
|
50
51
|
|
|
51
52
|
def base_config(isolation: str | object = "worktree") -> dict:
|
|
52
53
|
config = {
|
|
53
|
-
"workflow": {"mode": "dev", "profile": "auto"},
|
|
54
|
+
"workflow": {"mode": "dev", "profile": "auto", "completion": "push"},
|
|
54
55
|
"project": {"name": "concurrency-test"},
|
|
56
|
+
"access": {
|
|
57
|
+
"project": {
|
|
58
|
+
"frontend": {"url": "https://project-front.test", "username": "front", "password": "front-pass"},
|
|
59
|
+
"backend": {"url": "https://project-back.test", "username": "back", "password": "back-pass"},
|
|
60
|
+
},
|
|
61
|
+
"jenkins": {
|
|
62
|
+
"frontend": {"url": "https://jenkins-front.test", "username": "front", "password": "front-pass"},
|
|
63
|
+
"backend": {"url": "https://jenkins-back.test", "username": "back", "password": "back-pass"},
|
|
64
|
+
},
|
|
65
|
+
"gitlab": {"url": "https://gitlab.test", "username": "git", "password": "git-pass"},
|
|
66
|
+
"nexus": {
|
|
67
|
+
"frontend": {"url": "https://nexus.test", "username": "nexus", "password": "nexus-pass"},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
55
70
|
"commands": {
|
|
56
71
|
"gate_changed": "true",
|
|
57
72
|
"gate_standard": "true",
|
|
@@ -148,6 +163,26 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
148
163
|
check=check,
|
|
149
164
|
)
|
|
150
165
|
|
|
166
|
+
def approve_task(self, repo: Path, task_id: str) -> str:
|
|
167
|
+
status = self.ap(repo, "task-status", task_id, "--json")
|
|
168
|
+
fingerprint = json.loads(status.stdout)["tasks"][0]["current_diff_fingerprint"]
|
|
169
|
+
self.ap(
|
|
170
|
+
repo,
|
|
171
|
+
"task-review",
|
|
172
|
+
task_id,
|
|
173
|
+
"--verdict",
|
|
174
|
+
"approved",
|
|
175
|
+
"--diff-fingerprint",
|
|
176
|
+
fingerprint,
|
|
177
|
+
"--reviewer",
|
|
178
|
+
"test-reviewer",
|
|
179
|
+
)
|
|
180
|
+
return fingerprint
|
|
181
|
+
|
|
182
|
+
def commit_push(self, repo: Path, task_id: str, message: str) -> subprocess.CompletedProcess[str]:
|
|
183
|
+
self.approve_task(repo, task_id)
|
|
184
|
+
return self.ap(repo, "commit-push", task_id, "--msg", message)
|
|
185
|
+
|
|
151
186
|
def task_worktree(self, repo: Path, task_id: str) -> Path:
|
|
152
187
|
wanted = f"refs/heads/codex/{task_id}"
|
|
153
188
|
current_path: Path | None = None
|
|
@@ -159,7 +194,15 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
159
194
|
self.fail(f"no worktree registered for {wanted}")
|
|
160
195
|
|
|
161
196
|
def start_task(self, repo: Path, task_id: str) -> Path:
|
|
162
|
-
result = self.ap(
|
|
197
|
+
result = self.ap(
|
|
198
|
+
repo,
|
|
199
|
+
"task-start",
|
|
200
|
+
task_id,
|
|
201
|
+
"--base",
|
|
202
|
+
"origin/dev",
|
|
203
|
+
"--owned-path",
|
|
204
|
+
".",
|
|
205
|
+
)
|
|
163
206
|
worktree = self.task_worktree(repo, task_id)
|
|
164
207
|
self.assertIn(task_id, result.stdout + result.stderr)
|
|
165
208
|
self.assertTrue(worktree.is_dir())
|
|
@@ -249,6 +292,272 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
249
292
|
),
|
|
250
293
|
"task-start must persist a task manifest in the Git common directory",
|
|
251
294
|
)
|
|
295
|
+
active_task = (worktree / "docs" / "tasks" / "active" / "START-1.md").read_text(
|
|
296
|
+
encoding="utf-8"
|
|
297
|
+
)
|
|
298
|
+
for field in [
|
|
299
|
+
"Worktree:",
|
|
300
|
+
"Orchestrator:",
|
|
301
|
+
"Owning fixer:",
|
|
302
|
+
"Owned paths:",
|
|
303
|
+
"Depends on integrated tasks:",
|
|
304
|
+
"Reviewer / stable diff:",
|
|
305
|
+
"Review verdict:",
|
|
306
|
+
]:
|
|
307
|
+
self.assertIn(field, active_task)
|
|
308
|
+
|
|
309
|
+
def test_schema_one_task_status_fails_closed_with_migration_recovery(self) -> None:
|
|
310
|
+
_, repo, _ = self.make_repo()
|
|
311
|
+
self.start_task(repo, "LEGACY-SCHEMA")
|
|
312
|
+
registry = self.registry_manifest_path(repo, "LEGACY-SCHEMA")
|
|
313
|
+
payload = json.loads(registry.read_text(encoding="utf-8"))
|
|
314
|
+
payload["schema"] = 1
|
|
315
|
+
for field in [
|
|
316
|
+
"owned_paths",
|
|
317
|
+
"depends_on",
|
|
318
|
+
"prerequisite_shas",
|
|
319
|
+
"writer_lease",
|
|
320
|
+
"review",
|
|
321
|
+
]:
|
|
322
|
+
payload.pop(field, None)
|
|
323
|
+
registry.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
324
|
+
|
|
325
|
+
result = self.ap(repo, "task-status", "LEGACY-SCHEMA", check=False)
|
|
326
|
+
rendered = result.stdout + result.stderr
|
|
327
|
+
self.assertNotEqual(0, result.returncode)
|
|
328
|
+
self.assertIn("legacy schema-1 task", rendered)
|
|
329
|
+
self.assertIn("cannot safely infer or claim owned_paths", rendered)
|
|
330
|
+
self.assertIn("previously installed runtime", rendered)
|
|
331
|
+
self.assertIn("restore the 3.0.0 runtime", rendered)
|
|
332
|
+
|
|
333
|
+
def test_owned_paths_are_required_and_unowned_changes_are_rejected(self) -> None:
|
|
334
|
+
_, repo, remote = self.make_repo()
|
|
335
|
+
missing = self.ap(
|
|
336
|
+
repo,
|
|
337
|
+
"task-start",
|
|
338
|
+
"NO-OWNED",
|
|
339
|
+
"--base",
|
|
340
|
+
"origin/dev",
|
|
341
|
+
check=False,
|
|
342
|
+
)
|
|
343
|
+
self.assertNotEqual(0, missing.returncode)
|
|
344
|
+
self.assertIn("owned-path", (missing.stdout + missing.stderr).lower())
|
|
345
|
+
self.assert_remote_branch(remote, "codex/NO-OWNED", False)
|
|
346
|
+
|
|
347
|
+
self.ap(
|
|
348
|
+
repo,
|
|
349
|
+
"task-start",
|
|
350
|
+
"OWNED-ONLY",
|
|
351
|
+
"--base",
|
|
352
|
+
"origin/dev",
|
|
353
|
+
"--owned-path",
|
|
354
|
+
"src/owned",
|
|
355
|
+
)
|
|
356
|
+
worktree = self.task_worktree(repo, "OWNED-ONLY")
|
|
357
|
+
outside = worktree / "src" / "outside.txt"
|
|
358
|
+
outside.parent.mkdir(parents=True)
|
|
359
|
+
outside.write_text("outside\n", encoding="utf-8")
|
|
360
|
+
status = self.ap(worktree, "task-status", "OWNED-ONLY", "--json")
|
|
361
|
+
fingerprint = json.loads(status.stdout)["tasks"][0]["current_diff_fingerprint"]
|
|
362
|
+
review = self.ap(
|
|
363
|
+
worktree,
|
|
364
|
+
"task-review",
|
|
365
|
+
"OWNED-ONLY",
|
|
366
|
+
"--verdict",
|
|
367
|
+
"approved",
|
|
368
|
+
"--diff-fingerprint",
|
|
369
|
+
fingerprint,
|
|
370
|
+
check=False,
|
|
371
|
+
)
|
|
372
|
+
self.assertNotEqual(0, review.returncode)
|
|
373
|
+
self.assertIn("outside task owned_paths", review.stdout + review.stderr)
|
|
374
|
+
|
|
375
|
+
def test_approved_fingerprint_expires_when_owned_diff_changes(self) -> None:
|
|
376
|
+
_, repo, remote = self.make_repo()
|
|
377
|
+
worktree = self.start_task(repo, "STALE-REVIEW")
|
|
378
|
+
payload = worktree / "payload.txt"
|
|
379
|
+
payload.write_text("reviewed\n", encoding="utf-8")
|
|
380
|
+
registry = self.registry_manifest_path(repo, "STALE-REVIEW")
|
|
381
|
+
manifest = json.loads(registry.read_text(encoding="utf-8"))
|
|
382
|
+
owner = manifest["owner"]
|
|
383
|
+
manifest["owner"] = "another-lifecycle-owner"
|
|
384
|
+
registry.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
385
|
+
status = self.ap(worktree, "task-status", "STALE-REVIEW", "--json")
|
|
386
|
+
fingerprint = json.loads(status.stdout)["tasks"][0]["current_diff_fingerprint"]
|
|
387
|
+
non_owner_review = self.ap(
|
|
388
|
+
worktree,
|
|
389
|
+
"task-review",
|
|
390
|
+
"STALE-REVIEW",
|
|
391
|
+
"--verdict",
|
|
392
|
+
"approved",
|
|
393
|
+
"--diff-fingerprint",
|
|
394
|
+
fingerprint,
|
|
395
|
+
check=False,
|
|
396
|
+
)
|
|
397
|
+
self.assertNotEqual(0, non_owner_review.returncode)
|
|
398
|
+
self.assertIn("lifecycle owner", non_owner_review.stdout + non_owner_review.stderr)
|
|
399
|
+
manifest["owner"] = owner
|
|
400
|
+
registry.write_text(json.dumps(manifest, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
401
|
+
self.approve_task(worktree, "STALE-REVIEW")
|
|
402
|
+
payload.write_text("changed after review\n", encoding="utf-8")
|
|
403
|
+
|
|
404
|
+
result = self.ap(
|
|
405
|
+
worktree,
|
|
406
|
+
"commit-push",
|
|
407
|
+
"STALE-REVIEW",
|
|
408
|
+
"--msg",
|
|
409
|
+
"STALE-REVIEW: must fail",
|
|
410
|
+
check=False,
|
|
411
|
+
)
|
|
412
|
+
self.assertNotEqual(0, result.returncode)
|
|
413
|
+
self.assertIn("fingerprint is stale", result.stdout + result.stderr)
|
|
414
|
+
self.assert_remote_branch(remote, "codex/STALE-REVIEW", False)
|
|
415
|
+
|
|
416
|
+
def test_writer_lease_requires_match_and_owner_handoff_uses_generation_cas(self) -> None:
|
|
417
|
+
_, repo, _ = self.make_repo()
|
|
418
|
+
owner = os.environ["CODEX_THREAD_ID"]
|
|
419
|
+
self.ap(
|
|
420
|
+
repo,
|
|
421
|
+
"task-start",
|
|
422
|
+
"LEASE-1",
|
|
423
|
+
"--base",
|
|
424
|
+
"origin/dev",
|
|
425
|
+
"--owned-path",
|
|
426
|
+
".",
|
|
427
|
+
"--writer",
|
|
428
|
+
"fixer-label",
|
|
429
|
+
)
|
|
430
|
+
worktree = self.task_worktree(repo, "LEASE-1")
|
|
431
|
+
(worktree / "lease.txt").write_text("ready\n", encoding="utf-8")
|
|
432
|
+
self.approve_task(worktree, "LEASE-1")
|
|
433
|
+
|
|
434
|
+
mismatch = self.ap(
|
|
435
|
+
worktree,
|
|
436
|
+
"commit-push",
|
|
437
|
+
"LEASE-1",
|
|
438
|
+
"--msg",
|
|
439
|
+
"LEASE-1: wrong writer",
|
|
440
|
+
check=False,
|
|
441
|
+
)
|
|
442
|
+
self.assertNotEqual(0, mismatch.returncode)
|
|
443
|
+
self.assertIn("writer lease mismatch", (mismatch.stdout + mismatch.stderr).lower())
|
|
444
|
+
|
|
445
|
+
spoofed = self.ap(
|
|
446
|
+
worktree,
|
|
447
|
+
"commit-push",
|
|
448
|
+
"LEASE-1",
|
|
449
|
+
"--msg",
|
|
450
|
+
"LEASE-1: spoofed writer",
|
|
451
|
+
"--writer",
|
|
452
|
+
"fixer-label",
|
|
453
|
+
check=False,
|
|
454
|
+
)
|
|
455
|
+
self.assertNotEqual(0, spoofed.returncode)
|
|
456
|
+
self.assertIn("actor identity cannot be overridden", spoofed.stdout + spoofed.stderr)
|
|
457
|
+
|
|
458
|
+
self.ap(
|
|
459
|
+
repo,
|
|
460
|
+
"task-handoff",
|
|
461
|
+
"LEASE-1",
|
|
462
|
+
"--from",
|
|
463
|
+
"fixer-label",
|
|
464
|
+
"--to",
|
|
465
|
+
owner,
|
|
466
|
+
"--generation",
|
|
467
|
+
"1",
|
|
468
|
+
)
|
|
469
|
+
stale = self.ap(
|
|
470
|
+
repo,
|
|
471
|
+
"task-handoff",
|
|
472
|
+
"LEASE-1",
|
|
473
|
+
"--from",
|
|
474
|
+
owner,
|
|
475
|
+
"--to",
|
|
476
|
+
"next-writer",
|
|
477
|
+
"--generation",
|
|
478
|
+
"1",
|
|
479
|
+
check=False,
|
|
480
|
+
)
|
|
481
|
+
self.assertNotEqual(0, stale.returncode)
|
|
482
|
+
self.assertIn("generation changed", stale.stdout + stale.stderr)
|
|
483
|
+
manifest = json.loads(self.registry_manifest_path(repo, "LEASE-1").read_text(encoding="utf-8"))
|
|
484
|
+
self.assertEqual(owner, manifest["writer_lease"]["holder"])
|
|
485
|
+
self.assertEqual(2, manifest["writer_lease"]["generation"])
|
|
486
|
+
|
|
487
|
+
def test_dependency_sha_must_already_be_in_task_base(self) -> None:
|
|
488
|
+
_, repo, _ = self.make_repo()
|
|
489
|
+
tree = git_output(repo, "rev-parse", "HEAD^{tree}")
|
|
490
|
+
orphan = git_output(repo, "commit-tree", tree, "-m", "unintegrated prerequisite")
|
|
491
|
+
result = self.ap(
|
|
492
|
+
repo,
|
|
493
|
+
"task-start",
|
|
494
|
+
"DEPENDENT-1",
|
|
495
|
+
"--base",
|
|
496
|
+
"origin/dev",
|
|
497
|
+
"--owned-path",
|
|
498
|
+
".",
|
|
499
|
+
"--depends-on",
|
|
500
|
+
f"UPSTREAM-1={orphan}",
|
|
501
|
+
check=False,
|
|
502
|
+
)
|
|
503
|
+
self.assertNotEqual(0, result.returncode)
|
|
504
|
+
self.assertIn("not integrated", result.stdout + result.stderr)
|
|
505
|
+
|
|
506
|
+
def test_target_advance_rebases_then_requires_review_before_integration(self) -> None:
|
|
507
|
+
_, repo, remote = self.make_repo()
|
|
508
|
+
worktree = self.start_task(repo, "REBASE-REVIEW")
|
|
509
|
+
(worktree / "task.txt").write_text("task\n", encoding="utf-8")
|
|
510
|
+
self.commit_push(worktree, "REBASE-REVIEW", "REBASE-REVIEW: ready")
|
|
511
|
+
|
|
512
|
+
(repo / "upstream.txt").write_text("upstream\n", encoding="utf-8")
|
|
513
|
+
git(repo, "add", "upstream.txt")
|
|
514
|
+
git(repo, "commit", "-qm", "advance target")
|
|
515
|
+
git(repo, "push", "-q", "origin", "dev")
|
|
516
|
+
|
|
517
|
+
rebased = self.ap(repo, "task-integrate", "REBASE-REVIEW", check=False)
|
|
518
|
+
self.assertNotEqual(0, rebased.returncode)
|
|
519
|
+
self.assertIn("review again", rebased.stdout + rebased.stderr)
|
|
520
|
+
manifest = json.loads(self.registry_manifest_path(repo, "REBASE-REVIEW").read_text(encoding="utf-8"))
|
|
521
|
+
self.assertEqual("pushed", manifest["state"])
|
|
522
|
+
self.assertEqual("pending", manifest["review"]["verdict"])
|
|
523
|
+
self.assertNotEqual(
|
|
524
|
+
0,
|
|
525
|
+
git(remote, "cat-file", "-e", "refs/heads/dev:task.txt", check=False).returncode,
|
|
526
|
+
)
|
|
527
|
+
|
|
528
|
+
self.approve_task(worktree, "REBASE-REVIEW")
|
|
529
|
+
self.ap(repo, "task-integrate", "REBASE-REVIEW")
|
|
530
|
+
self.assertEqual("task", git_output(remote, "show", "refs/heads/dev:task.txt"))
|
|
531
|
+
|
|
532
|
+
def test_rebase_conflict_can_resume_only_then_requires_fresh_review(self) -> None:
|
|
533
|
+
_, repo, remote = self.make_repo()
|
|
534
|
+
worktree = self.start_task(repo, "RESUME-1")
|
|
535
|
+
(worktree / "shared.txt").write_text("task side\n", encoding="utf-8")
|
|
536
|
+
self.commit_push(worktree, "RESUME-1", "RESUME-1: ready")
|
|
537
|
+
|
|
538
|
+
(repo / "shared.txt").write_text("target side\n", encoding="utf-8")
|
|
539
|
+
git(repo, "add", "shared.txt")
|
|
540
|
+
git(repo, "commit", "-qm", "conflicting target change")
|
|
541
|
+
git(repo, "push", "-q", "origin", "dev")
|
|
542
|
+
|
|
543
|
+
conflict = self.ap(repo, "task-integrate", "RESUME-1", check=False)
|
|
544
|
+
self.assertNotEqual(0, conflict.returncode)
|
|
545
|
+
self.assertIn("rebase conflicted", conflict.stdout + conflict.stderr)
|
|
546
|
+
manifest = json.loads(self.registry_manifest_path(repo, "RESUME-1").read_text(encoding="utf-8"))
|
|
547
|
+
self.assertEqual("conflicted", manifest["state"])
|
|
548
|
+
self.assertEqual("pending", manifest["review"]["verdict"])
|
|
549
|
+
|
|
550
|
+
(worktree / "shared.txt").write_text("resolved\n", encoding="utf-8")
|
|
551
|
+
git(worktree, "add", "shared.txt")
|
|
552
|
+
git(worktree, "-c", "core.editor=true", "rebase", "--continue")
|
|
553
|
+
self.ap(repo, "task-resume", "RESUME-1")
|
|
554
|
+
manifest = json.loads(self.registry_manifest_path(repo, "RESUME-1").read_text(encoding="utf-8"))
|
|
555
|
+
self.assertEqual("pushed", manifest["state"])
|
|
556
|
+
self.assertEqual("pending", manifest["review"]["verdict"])
|
|
557
|
+
|
|
558
|
+
self.approve_task(worktree, "RESUME-1")
|
|
559
|
+
self.ap(repo, "task-integrate", "RESUME-1")
|
|
560
|
+
self.assertEqual("resolved", git_output(remote, "show", "refs/heads/dev:shared.txt"))
|
|
252
561
|
|
|
253
562
|
def test_task_start_rolls_back_checkout_hook_side_effects(self) -> None:
|
|
254
563
|
hook_bodies = {
|
|
@@ -269,7 +578,16 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
269
578
|
self.install_hook(repo, "post-checkout", body)
|
|
270
579
|
task_id = f"HOOK-{label.upper()}"
|
|
271
580
|
|
|
272
|
-
result = self.ap(
|
|
581
|
+
result = self.ap(
|
|
582
|
+
repo,
|
|
583
|
+
"task-start",
|
|
584
|
+
task_id,
|
|
585
|
+
"--base",
|
|
586
|
+
"origin/dev",
|
|
587
|
+
"--owned-path",
|
|
588
|
+
".",
|
|
589
|
+
check=False,
|
|
590
|
+
)
|
|
273
591
|
|
|
274
592
|
self.assertNotEqual(0, result.returncode)
|
|
275
593
|
self.assertIn("hook", (result.stdout + result.stderr).lower())
|
|
@@ -317,8 +635,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
317
635
|
}
|
|
318
636
|
self.assertEqual(before, after)
|
|
319
637
|
|
|
320
|
-
def
|
|
321
|
-
_, repo, remote = self.make_repo("
|
|
638
|
+
def test_missing_task_manifest_is_rejected_in_linked_worktree(self) -> None:
|
|
639
|
+
_, repo, remote = self.make_repo("worktree")
|
|
322
640
|
worktree = self.start_task(repo, "NO-MANIFEST")
|
|
323
641
|
git_dir = Path(git_output(worktree, "rev-parse", "--git-dir"))
|
|
324
642
|
if not git_dir.is_absolute():
|
|
@@ -398,6 +716,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
398
716
|
second_status = git(second_worktree, "status", "--short").stdout
|
|
399
717
|
self.assertIn("?? docs/tasks/active/", second_status)
|
|
400
718
|
self.assertIn("?? second-task-only.txt", second_status)
|
|
719
|
+
self.approve_task(worktree, "ISOLATED-1")
|
|
720
|
+
self.approve_task(second_worktree, "ISOLATED-2")
|
|
401
721
|
with ThreadPoolExecutor(max_workers=2) as pool:
|
|
402
722
|
first_commit = pool.submit(
|
|
403
723
|
self.ap,
|
|
@@ -448,15 +768,32 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
448
768
|
)
|
|
449
769
|
|
|
450
770
|
def test_task_integrate_from_primary_pushes_target_and_cleans_task_refs(self) -> None:
|
|
451
|
-
|
|
771
|
+
root, repo, remote = self.make_repo()
|
|
772
|
+
gate_marker = root / "gate-invocations"
|
|
773
|
+
commit_hook_marker = root / "commit-hook-invocations"
|
|
774
|
+
push_hook_marker = root / "push-hook-invocations"
|
|
775
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
776
|
+
original = engineering.read_text(encoding="utf-8")
|
|
777
|
+
configured = original.replace(
|
|
778
|
+
"gate_changed: 'true'",
|
|
779
|
+
f"gate_changed: 'printf x >> {gate_marker}'",
|
|
780
|
+
)
|
|
781
|
+
self.assertNotEqual(original, configured)
|
|
782
|
+
engineering.write_text(configured, encoding="utf-8")
|
|
783
|
+
git(repo, "add", "docs/ENGINEERING.md")
|
|
784
|
+
git(repo, "commit", "-qm", "configure observable fast gate")
|
|
785
|
+
git(repo, "push", "-q", "origin", "dev")
|
|
786
|
+
self.install_hook(repo, "pre-commit", f"printf c >> '{commit_hook_marker}'\n")
|
|
787
|
+
self.install_hook(repo, "pre-push", f"printf p >> '{push_hook_marker}'\n")
|
|
788
|
+
|
|
452
789
|
worktree = self.start_task(repo, "INTEGRATE-1")
|
|
453
790
|
(worktree / "integrated.txt").write_text("integrated\n", encoding="utf-8")
|
|
454
|
-
self.
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
"
|
|
791
|
+
self.commit_push(worktree, "INTEGRATE-1", "INTEGRATE-1: ready")
|
|
792
|
+
task_commit = git_output(worktree, "rev-parse", "HEAD")
|
|
793
|
+
self.assertEqual("c", commit_hook_marker.read_text(encoding="utf-8"))
|
|
794
|
+
self.assertFalse(
|
|
795
|
+
push_hook_marker.exists(),
|
|
796
|
+
"the internal backup push must not duplicate the final pre-push hook",
|
|
460
797
|
)
|
|
461
798
|
|
|
462
799
|
rejected = self.ap(worktree, "task-integrate", "INTEGRATE-1", check=False)
|
|
@@ -475,18 +812,36 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
475
812
|
self.assertFalse(worktree.exists())
|
|
476
813
|
self.assert_local_branch(repo, "codex/INTEGRATE-1", False)
|
|
477
814
|
self.assert_remote_branch(remote, "codex/INTEGRATE-1", False)
|
|
815
|
+
self.assertEqual("x", gate_marker.read_text(encoding="utf-8"), "push flow must run the fast gate exactly once")
|
|
816
|
+
self.assertEqual("c", commit_hook_marker.read_text(encoding="utf-8"), "push flow must create exactly one hook-visible commit")
|
|
817
|
+
self.assertEqual("p", push_hook_marker.read_text(encoding="utf-8"), "the final target push hook must run exactly once")
|
|
818
|
+
self.assertEqual(task_commit, git_output(remote, "rev-parse", "refs/heads/dev"), "integration must not create a second evidence commit")
|
|
819
|
+
|
|
820
|
+
def test_task_integrate_rejects_legacy_gate_failed_state(self) -> None:
|
|
821
|
+
_, repo, remote = self.make_repo()
|
|
822
|
+
worktree = self.start_task(repo, "FAILED-GATE")
|
|
823
|
+
(worktree / "must-not-integrate.txt").write_text("blocked\n", encoding="utf-8")
|
|
824
|
+
self.commit_push(worktree, "FAILED-GATE", "FAILED-GATE: staged task")
|
|
825
|
+
registry = self.registry_manifest_path(repo, "FAILED-GATE")
|
|
826
|
+
payload = json.loads(registry.read_text(encoding="utf-8"))
|
|
827
|
+
payload["state"] = "gate-failed"
|
|
828
|
+
registry.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
829
|
+
|
|
830
|
+
result = self.ap(repo, "task-integrate", "FAILED-GATE", check=False)
|
|
831
|
+
|
|
832
|
+
self.assertNotEqual(0, result.returncode)
|
|
833
|
+
self.assertIn("committed and pushed", (result.stdout + result.stderr).lower())
|
|
834
|
+
self.assertTrue(worktree.exists())
|
|
835
|
+
self.assertNotEqual(
|
|
836
|
+
0,
|
|
837
|
+
git(remote, "cat-file", "-e", "refs/heads/dev:must-not-integrate.txt", check=False).returncode,
|
|
838
|
+
)
|
|
478
839
|
|
|
479
840
|
def test_task_finish_keep_remote_reports_retained_branch(self) -> None:
|
|
480
841
|
_, repo, remote = self.make_repo()
|
|
481
842
|
worktree = self.start_task(repo, "KEEP-REMOTE")
|
|
482
843
|
(worktree / "kept.txt").write_text("kept remotely\n", encoding="utf-8")
|
|
483
|
-
self.
|
|
484
|
-
worktree,
|
|
485
|
-
"commit-push",
|
|
486
|
-
"KEEP-REMOTE",
|
|
487
|
-
"--msg",
|
|
488
|
-
"KEEP-REMOTE: ready",
|
|
489
|
-
)
|
|
844
|
+
self.commit_push(worktree, "KEEP-REMOTE", "KEEP-REMOTE: ready")
|
|
490
845
|
self.ap(repo, "task-integrate", "KEEP-REMOTE", "--keep-worktree")
|
|
491
846
|
|
|
492
847
|
finish = self.ap(repo, "task-finish", "KEEP-REMOTE", "--keep-remote")
|
|
@@ -504,13 +859,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
504
859
|
(deleting / "shared.txt").unlink()
|
|
505
860
|
(observer / "observer.txt").write_text("observer\n", encoding="utf-8")
|
|
506
861
|
|
|
507
|
-
self.
|
|
508
|
-
deleting,
|
|
509
|
-
"commit-push",
|
|
510
|
-
"DELETE-1",
|
|
511
|
-
"--msg",
|
|
512
|
-
"DELETE-1: delete shared file",
|
|
513
|
-
)
|
|
862
|
+
self.commit_push(deleting, "DELETE-1", "DELETE-1: delete shared file")
|
|
514
863
|
|
|
515
864
|
deleted_ref = "refs/heads/codex/DELETE-1"
|
|
516
865
|
self.assertNotEqual(
|
|
@@ -571,13 +920,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
571
920
|
_, repo, remote = self.make_repo()
|
|
572
921
|
worktree = self.start_task(repo, "PRUNE-REGISTERED")
|
|
573
922
|
(worktree / "registered.txt").write_text("registered\n", encoding="utf-8")
|
|
574
|
-
self.
|
|
575
|
-
worktree,
|
|
576
|
-
"commit-push",
|
|
577
|
-
"PRUNE-REGISTERED",
|
|
578
|
-
"--msg",
|
|
579
|
-
"PRUNE-REGISTERED: ready",
|
|
580
|
-
)
|
|
923
|
+
self.commit_push(worktree, "PRUNE-REGISTERED", "PRUNE-REGISTERED: ready")
|
|
581
924
|
self.ap(
|
|
582
925
|
repo,
|
|
583
926
|
"task-integrate",
|
|
@@ -602,13 +945,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
602
945
|
|
|
603
946
|
worktree = self.start_task(repo, "IGNORED-1")
|
|
604
947
|
(worktree / "payload.txt").write_text("ready\n", encoding="utf-8")
|
|
605
|
-
self.
|
|
606
|
-
worktree,
|
|
607
|
-
"commit-push",
|
|
608
|
-
"IGNORED-1",
|
|
609
|
-
"--msg",
|
|
610
|
-
"IGNORED-1: ready",
|
|
611
|
-
)
|
|
948
|
+
self.commit_push(worktree, "IGNORED-1", "IGNORED-1: ready")
|
|
612
949
|
self.ap(repo, "task-integrate", "IGNORED-1", "--keep-worktree")
|
|
613
950
|
|
|
614
951
|
(worktree / ".env").write_text("must survive\n", encoding="utf-8")
|
|
@@ -674,13 +1011,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
674
1011
|
"--recursive",
|
|
675
1012
|
)
|
|
676
1013
|
(worktree / "payload.txt").write_text("ready\n", encoding="utf-8")
|
|
677
|
-
self.
|
|
678
|
-
worktree,
|
|
679
|
-
"commit-push",
|
|
680
|
-
"SUBMODULE-1",
|
|
681
|
-
"--msg",
|
|
682
|
-
"SUBMODULE-1: ready",
|
|
683
|
-
)
|
|
1014
|
+
self.commit_push(worktree, "SUBMODULE-1", "SUBMODULE-1: ready")
|
|
684
1015
|
self.ap(repo, "task-integrate", "SUBMODULE-1", "--keep-worktree")
|
|
685
1016
|
|
|
686
1017
|
task_module = worktree / "vendor" / "module"
|
|
@@ -909,13 +1240,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
909
1240
|
git(repo, "config", "--local", "--get", "submodule.vendor/module.active", check=False).returncode,
|
|
910
1241
|
)
|
|
911
1242
|
(worktree / "payload.txt").write_text("ready\n", encoding="utf-8")
|
|
912
|
-
self.
|
|
913
|
-
worktree,
|
|
914
|
-
"commit-push",
|
|
915
|
-
"SUBMODULE-CONFIG",
|
|
916
|
-
"--msg",
|
|
917
|
-
"SUBMODULE-CONFIG: ready",
|
|
918
|
-
)
|
|
1243
|
+
self.commit_push(worktree, "SUBMODULE-CONFIG", "SUBMODULE-CONFIG: ready")
|
|
919
1244
|
self.ap(repo, "task-integrate", "SUBMODULE-CONFIG")
|
|
920
1245
|
|
|
921
1246
|
self.assertEqual(before_status, git_output(repo, "submodule", "status", "--", "vendor/module"))
|
|
@@ -990,6 +1315,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
990
1315
|
"alternate",
|
|
991
1316
|
"--remote",
|
|
992
1317
|
"upstream",
|
|
1318
|
+
"--owned-path",
|
|
1319
|
+
".",
|
|
993
1320
|
)
|
|
994
1321
|
worktree = self.task_worktree(repo, "RELATIVE-BASE")
|
|
995
1322
|
self.assertIn("../module-b.git", (worktree / ".gitmodules").read_text(encoding="utf-8"))
|
|
@@ -1060,13 +1387,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1060
1387
|
"--recursive",
|
|
1061
1388
|
)
|
|
1062
1389
|
(worktree / "payload.txt").write_text("ready\n", encoding="utf-8")
|
|
1063
|
-
self.
|
|
1064
|
-
worktree,
|
|
1065
|
-
"commit-push",
|
|
1066
|
-
"SUBMODULE-RESIDUAL",
|
|
1067
|
-
"--msg",
|
|
1068
|
-
"SUBMODULE-RESIDUAL: ready",
|
|
1069
|
-
)
|
|
1390
|
+
self.commit_push(worktree, "SUBMODULE-RESIDUAL", "SUBMODULE-RESIDUAL: ready")
|
|
1070
1391
|
self.ap(repo, "task-integrate", "SUBMODULE-RESIDUAL", "--keep-worktree")
|
|
1071
1392
|
|
|
1072
1393
|
module_b = worktree / "vendor" / "b"
|
|
@@ -1127,13 +1448,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1127
1448
|
root, repo, remote = self.make_repo()
|
|
1128
1449
|
worktree = self.start_task(repo, "REMOTE-RACE")
|
|
1129
1450
|
(worktree / "payload.txt").write_text("ready\n", encoding="utf-8")
|
|
1130
|
-
self.
|
|
1131
|
-
worktree,
|
|
1132
|
-
"commit-push",
|
|
1133
|
-
"REMOTE-RACE",
|
|
1134
|
-
"--msg",
|
|
1135
|
-
"REMOTE-RACE: ready",
|
|
1136
|
-
)
|
|
1451
|
+
self.commit_push(worktree, "REMOTE-RACE", "REMOTE-RACE: ready")
|
|
1137
1452
|
self.ap(repo, "task-integrate", "REMOTE-RACE", "--keep-worktree")
|
|
1138
1453
|
|
|
1139
1454
|
attacker = root / "attacker"
|
|
@@ -1174,13 +1489,13 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1174
1489
|
worktree = self.start_task(repo, "MUTATE-1")
|
|
1175
1490
|
engineering = worktree / "docs" / "ENGINEERING.md"
|
|
1176
1491
|
text = engineering.read_text(encoding="utf-8")
|
|
1177
|
-
text = text.replace("
|
|
1178
|
-
text = text.replace("gate_full: 'true'", "gate_full: 'printf gate-change >> shared.txt'")
|
|
1492
|
+
text = text.replace("gate_changed: 'true'", "gate_changed: 'printf gate-change >> shared.txt'")
|
|
1179
1493
|
engineering.write_text(text, encoding="utf-8")
|
|
1180
1494
|
git(worktree, "add", "docs/ENGINEERING.md")
|
|
1181
1495
|
git(worktree, "commit", "-qm", "configure mutating gate")
|
|
1182
1496
|
before = git_output(worktree, "rev-parse", "HEAD")
|
|
1183
1497
|
(worktree / "task.txt").write_text("task\n", encoding="utf-8")
|
|
1498
|
+
self.approve_task(worktree, "MUTATE-1")
|
|
1184
1499
|
|
|
1185
1500
|
result = self.ap(
|
|
1186
1501
|
worktree,
|
|
@@ -1208,6 +1523,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1208
1523
|
)
|
|
1209
1524
|
before = git_output(worktree, "rev-parse", "HEAD")
|
|
1210
1525
|
(worktree / "payload.txt").write_text("payload\n", encoding="utf-8")
|
|
1526
|
+
self.approve_task(worktree, "COMMIT-HOOK")
|
|
1211
1527
|
|
|
1212
1528
|
result = self.ap(
|
|
1213
1529
|
worktree,
|
|
@@ -1224,7 +1540,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1224
1540
|
self.assertEqual("hook mutation\n", (worktree / "hook-after.txt").read_text(encoding="utf-8"))
|
|
1225
1541
|
self.assert_remote_branch(remote, "codex/COMMIT-HOOK", False)
|
|
1226
1542
|
|
|
1227
|
-
def
|
|
1543
|
+
def test_missing_config_defaults_to_worktree_and_legacy_is_rejected(self) -> None:
|
|
1228
1544
|
_, default_repo, _ = self.make_repo(_MISSING)
|
|
1229
1545
|
(default_repo / "shared.txt").write_text("must stay isolated\n", encoding="utf-8")
|
|
1230
1546
|
default_commit = self.assert_rejected_without_mutation(
|
|
@@ -1239,16 +1555,21 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1239
1555
|
self.start_task(default_repo, "DEFAULT-1")
|
|
1240
1556
|
|
|
1241
1557
|
_, legacy_repo, legacy_remote = self.make_repo("legacy")
|
|
1558
|
+
before = git_output(legacy_repo, "rev-parse", "HEAD")
|
|
1242
1559
|
(legacy_repo / "shared.txt").write_text("legacy shared checkout\n", encoding="utf-8")
|
|
1243
|
-
self.ap(
|
|
1560
|
+
result = self.ap(
|
|
1244
1561
|
legacy_repo,
|
|
1245
1562
|
"commit-push",
|
|
1246
1563
|
"LEGACY-1",
|
|
1247
1564
|
"--msg",
|
|
1248
|
-
"LEGACY-1:
|
|
1565
|
+
"LEGACY-1: must be rejected",
|
|
1566
|
+
check=False,
|
|
1249
1567
|
)
|
|
1568
|
+
self.assertNotEqual(0, result.returncode)
|
|
1569
|
+
self.assertIn("must be worktree", result.stdout + result.stderr)
|
|
1570
|
+
self.assertEqual(before, git_output(legacy_repo, "rev-parse", "HEAD"))
|
|
1250
1571
|
self.assertEqual(
|
|
1251
|
-
"
|
|
1572
|
+
"baseline",
|
|
1252
1573
|
git_output(legacy_remote, "show", "refs/heads/dev:shared.txt"),
|
|
1253
1574
|
)
|
|
1254
1575
|
|