@elvis1513/auto-coding-skill 4.2.6 → 4.2.8
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 +71 -12
- package/cli/assets/agents/reviewer.toml +6 -6
- package/cli/assets/managed-install.json +1 -1
- package/cli/assets/skill/SKILL.md +6 -7
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +17 -0
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +2 -2
- package/cli/assets/skill/data/templates/ENGINEERING.md +2 -2
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +13 -16
- package/cli/assets/skill/scripts/ap.py +2096 -142
- package/cli/tests/ap_concurrency_test.py +632 -46
- package/cli/tests/ap_profiles_test.py +382 -34
- package/cli/tests/index.test.js +23 -21
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
from __future__ import annotations
|
|
3
3
|
|
|
4
|
+
import hashlib
|
|
4
5
|
import json
|
|
5
6
|
import os
|
|
6
7
|
import subprocess
|
|
@@ -29,6 +30,7 @@ def command(
|
|
|
29
30
|
) -> subprocess.CompletedProcess[str]:
|
|
30
31
|
env = os.environ.copy()
|
|
31
32
|
env.setdefault("CODEX_THREAD_ID", _TEST_OWNER)
|
|
33
|
+
env.setdefault("AUTOCODING_TEST_RUNNER_OVERRIDE", "1")
|
|
32
34
|
result = subprocess.run(
|
|
33
35
|
list(args),
|
|
34
36
|
cwd=cwd,
|
|
@@ -214,6 +216,41 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
214
216
|
self.approve_task(repo, task_id)
|
|
215
217
|
return self.ap(repo, "commit-push", task_id, "--msg", message)
|
|
216
218
|
|
|
219
|
+
def artifact_reviewer_runner(self, root: Path, *tokens: str) -> str:
|
|
220
|
+
fake_reviewer = root / "fake-artifact-reviewer.py"
|
|
221
|
+
fake_reviewer.write_text(
|
|
222
|
+
"import hashlib, json, os, pathlib, subprocess, sys\n"
|
|
223
|
+
"if os.environ.get('CODEX_THREAD_ID'):\n"
|
|
224
|
+
" raise SystemExit(9)\n"
|
|
225
|
+
"assignment_path = pathlib.Path(os.environ['AUTOCODING_REVIEW_ASSIGNMENT'])\n"
|
|
226
|
+
"assignment_bytes = assignment_path.read_bytes()\n"
|
|
227
|
+
"if hashlib.sha256(assignment_bytes).hexdigest() != os.environ['AUTOCODING_REVIEW_ASSIGNMENT_SHA256']:\n"
|
|
228
|
+
" raise SystemExit(10)\n"
|
|
229
|
+
"assignment = json.loads(assignment_bytes)\n"
|
|
230
|
+
"artifact_path = pathlib.Path(assignment['diff_artifact_path'])\n"
|
|
231
|
+
"emitted = subprocess.run([sys.executable, sys.argv[1], '--repo', str(pathlib.Path.cwd()), "
|
|
232
|
+
"'review-artifact', '--file', str(assignment_path)], capture_output=True, check=False)\n"
|
|
233
|
+
"if emitted.returncode != 0:\n"
|
|
234
|
+
" raise SystemExit(11)\n"
|
|
235
|
+
"payload = emitted.stdout\n"
|
|
236
|
+
"actual = hashlib.sha256(payload).hexdigest()\n"
|
|
237
|
+
"if actual != assignment['diff_artifact_sha256']:\n"
|
|
238
|
+
" raise SystemExit(12)\n"
|
|
239
|
+
"if os.environ.get('AUTOCODING_REVIEW_DIFF_ARTIFACT') != str(artifact_path):\n"
|
|
240
|
+
" raise SystemExit(13)\n"
|
|
241
|
+
"if os.environ.get('AUTOCODING_REVIEW_DIFF_ARTIFACT_SHA256') != actual:\n"
|
|
242
|
+
" raise SystemExit(14)\n"
|
|
243
|
+
"if int(os.environ['AUTOCODING_REVIEW_TIMEOUT_SECONDS']) not in (150, 360):\n"
|
|
244
|
+
" raise SystemExit(15)\n"
|
|
245
|
+
"for token in sys.argv[2:]:\n"
|
|
246
|
+
" if token.encode('utf-8') not in payload:\n"
|
|
247
|
+
" raise SystemExit(16)\n"
|
|
248
|
+
"print(json.dumps({'verdict': 'approved', 'summary': 'artifact reviewed', "
|
|
249
|
+
"'evidence': ['diff_artifact_sha256=' + actual]}))\n",
|
|
250
|
+
encoding="utf-8",
|
|
251
|
+
)
|
|
252
|
+
return json.dumps([sys.executable, str(fake_reviewer), str(AP_SCRIPT), *tokens])
|
|
253
|
+
|
|
217
254
|
def task_worktree(self, repo: Path, task_id: str) -> Path:
|
|
218
255
|
wanted = f"refs/heads/codex/{task_id}"
|
|
219
256
|
current_path: Path | None = None
|
|
@@ -362,6 +399,28 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
362
399
|
common_dir = (repo / common_dir).resolve()
|
|
363
400
|
return common_dir / "auto-coding-skill" / "tasks" / f"{task_id}.json"
|
|
364
401
|
|
|
402
|
+
def shorten_review_deadline(
|
|
403
|
+
self,
|
|
404
|
+
repo: Path,
|
|
405
|
+
task_id: str,
|
|
406
|
+
issued: dict,
|
|
407
|
+
seconds: int = 2,
|
|
408
|
+
) -> None:
|
|
409
|
+
deadline = datetime.now(timezone.utc).replace(microsecond=0) + timedelta(seconds=seconds)
|
|
410
|
+
assignment = issued["assignment"]
|
|
411
|
+
assignment["deadline_at"] = deadline.isoformat()
|
|
412
|
+
assignment["issued_at"] = (deadline - timedelta(seconds=150)).isoformat()
|
|
413
|
+
assignment_path = Path(issued["assignment_path"])
|
|
414
|
+
assignment_path.write_text(json.dumps(assignment, indent=2) + "\n", encoding="utf-8")
|
|
415
|
+
manifest_path = self.registry_manifest_path(repo, task_id)
|
|
416
|
+
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
417
|
+
manifest["review"]["issued_at"] = assignment["issued_at"]
|
|
418
|
+
manifest["review"]["deadline_at"] = assignment["deadline_at"]
|
|
419
|
+
manifest["review"]["assignment_sha256"] = hashlib.sha256(
|
|
420
|
+
assignment_path.read_bytes()
|
|
421
|
+
).hexdigest()
|
|
422
|
+
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
423
|
+
|
|
365
424
|
def install_hook(self, repo: Path, name: str, body: str) -> Path:
|
|
366
425
|
common_dir = Path(git_output(repo, "rev-parse", "--git-common-dir"))
|
|
367
426
|
if not common_dir.is_absolute():
|
|
@@ -779,7 +838,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
779
838
|
self.assertNotIn("initialization is incomplete", output)
|
|
780
839
|
|
|
781
840
|
def test_continue_direct_can_adopt_owned_changes_for_new_review_lifecycle(self) -> None:
|
|
782
|
-
|
|
841
|
+
root, repo, remote = self.make_repo("adaptive", require_review=False)
|
|
783
842
|
claim = self.claim_direct(repo, "shared.txt")
|
|
784
843
|
(repo / "shared.txt").write_text("continued direct\n", encoding="utf-8")
|
|
785
844
|
started = self.ap(
|
|
@@ -810,9 +869,35 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
810
869
|
)
|
|
811
870
|
self.assertNotEqual(0, missing_reviewer.returncode)
|
|
812
871
|
self.assertIn("explicit --reviewer", missing_reviewer.stdout + missing_reviewer.stderr)
|
|
813
|
-
|
|
872
|
+
runner = self.artifact_reviewer_runner(root, "continued direct")
|
|
873
|
+
reviewed = json.loads(
|
|
874
|
+
self.ap(
|
|
875
|
+
repo,
|
|
876
|
+
"review-run",
|
|
877
|
+
"DIRECT-CONTINUE",
|
|
878
|
+
"--reviewer",
|
|
879
|
+
"direct-reviewer",
|
|
880
|
+
"--runner-command-json",
|
|
881
|
+
runner,
|
|
882
|
+
"--json",
|
|
883
|
+
).stdout
|
|
884
|
+
)
|
|
885
|
+
self.assertEqual("approved", reviewed["verdict"])
|
|
886
|
+
assignment_path = Path(
|
|
887
|
+
json.loads(
|
|
888
|
+
self.registry_manifest_path(repo, "DIRECT-CONTINUE").read_text(encoding="utf-8")
|
|
889
|
+
)["review"]["assignment_path"]
|
|
890
|
+
)
|
|
891
|
+
pushed = self.ap(
|
|
892
|
+
repo,
|
|
893
|
+
"commit-push",
|
|
894
|
+
"DIRECT-CONTINUE",
|
|
895
|
+
"--msg",
|
|
896
|
+
"DIRECT-CONTINUE: update",
|
|
897
|
+
)
|
|
814
898
|
self.assertIn("execution_mode=direct", pushed.stdout)
|
|
815
899
|
self.assertEqual("continued direct", git_output(remote, "show", "refs/heads/dev:shared.txt"))
|
|
900
|
+
self.assertFalse(assignment_path.parent.exists())
|
|
816
901
|
|
|
817
902
|
claim = self.claim_direct(repo, "shared.txt")
|
|
818
903
|
(repo / "shared.txt").write_text("owned again\n", encoding="utf-8")
|
|
@@ -898,31 +983,222 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
898
983
|
self.assertEqual(first, second)
|
|
899
984
|
assignment = first["assignment"]
|
|
900
985
|
self.assertEqual("focused", assignment["review_depth"])
|
|
901
|
-
self.assertEqual(
|
|
986
|
+
self.assertEqual(150, assignment["timeout_seconds"])
|
|
902
987
|
self.assertEqual(1, assignment["scope_revision"])
|
|
903
988
|
self.assertTrue(Path(first["assignment_path"]).is_file())
|
|
989
|
+
assignment_path = Path(first["assignment_path"])
|
|
990
|
+
artifact_path = Path(assignment["diff_artifact_path"])
|
|
991
|
+
artifact = artifact_path.read_bytes()
|
|
992
|
+
self.assertEqual(assignment_path.parent, artifact_path.parent)
|
|
993
|
+
self.assertEqual(0o600, assignment_path.stat().st_mode & 0o777)
|
|
994
|
+
self.assertEqual(0o600, artifact_path.stat().st_mode & 0o777)
|
|
995
|
+
self.assertEqual(hashlib.sha256(artifact).hexdigest(), assignment["diff_artifact_sha256"])
|
|
996
|
+
self.assertEqual("git-binary-patch-v1", assignment["diff_artifact_format"])
|
|
997
|
+
self.assertIn(b"review me", artifact)
|
|
998
|
+
emitted = self.ap(
|
|
999
|
+
worktree,
|
|
1000
|
+
"review-artifact",
|
|
1001
|
+
"--file",
|
|
1002
|
+
str(assignment_path),
|
|
1003
|
+
)
|
|
1004
|
+
self.assertEqual(artifact, emitted.stdout.encode("utf-8"))
|
|
904
1005
|
issued = datetime.fromisoformat(assignment["issued_at"])
|
|
905
1006
|
deadline = datetime.fromisoformat(assignment["deadline_at"])
|
|
906
|
-
self.assertEqual(
|
|
1007
|
+
self.assertEqual(150, int((deadline - issued).total_seconds()))
|
|
1008
|
+
|
|
1009
|
+
artifact_path.write_bytes(artifact + b"tampered\n")
|
|
1010
|
+
tampered = self.ap(
|
|
1011
|
+
worktree,
|
|
1012
|
+
"review-assignment",
|
|
1013
|
+
"REVIEW-DEADLINE",
|
|
1014
|
+
"--reviewer",
|
|
1015
|
+
"reviewer-1",
|
|
1016
|
+
check=False,
|
|
1017
|
+
)
|
|
1018
|
+
self.assertNotEqual(0, tampered.returncode)
|
|
1019
|
+
self.assertIn("SHA-256 mismatch", tampered.stdout + tampered.stderr)
|
|
1020
|
+
|
|
1021
|
+
def test_review_assignment_hash_binding_rejects_assignment_file_tampering(self) -> None:
|
|
1022
|
+
_, repo, _ = self.make_repo()
|
|
1023
|
+
worktree = self.start_task(repo, "REVIEW-ASSIGNMENT-HASH", "shared.txt")
|
|
1024
|
+
(worktree / "shared.txt").write_text("hash-bound review\n", encoding="utf-8")
|
|
1025
|
+
issued = json.loads(
|
|
1026
|
+
self.ap(
|
|
1027
|
+
worktree,
|
|
1028
|
+
"review-assignment",
|
|
1029
|
+
"REVIEW-ASSIGNMENT-HASH",
|
|
1030
|
+
"--reviewer",
|
|
1031
|
+
"reviewer-hash",
|
|
1032
|
+
"--json",
|
|
1033
|
+
).stdout
|
|
1034
|
+
)
|
|
1035
|
+
assignment_path = Path(issued["assignment_path"])
|
|
1036
|
+
original = assignment_path.read_bytes()
|
|
1037
|
+
manifest = json.loads(
|
|
1038
|
+
self.registry_manifest_path(repo, "REVIEW-ASSIGNMENT-HASH").read_text(
|
|
1039
|
+
encoding="utf-8"
|
|
1040
|
+
)
|
|
1041
|
+
)
|
|
1042
|
+
self.assertEqual(
|
|
1043
|
+
hashlib.sha256(original).hexdigest(),
|
|
1044
|
+
manifest["review"]["assignment_sha256"],
|
|
1045
|
+
)
|
|
1046
|
+
|
|
1047
|
+
assignment_path.write_bytes(original + b" \n")
|
|
1048
|
+
rejected = self.ap(
|
|
1049
|
+
worktree,
|
|
1050
|
+
"review-assignment",
|
|
1051
|
+
"REVIEW-ASSIGNMENT-HASH",
|
|
1052
|
+
"--reviewer",
|
|
1053
|
+
"reviewer-hash",
|
|
1054
|
+
check=False,
|
|
1055
|
+
)
|
|
1056
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
1057
|
+
self.assertIn("assignment SHA-256 mismatch", rejected.stdout + rejected.stderr)
|
|
1058
|
+
|
|
1059
|
+
def test_review_assignment_rejects_symlinked_review_root(self) -> None:
|
|
1060
|
+
root, repo, _ = self.make_repo()
|
|
1061
|
+
worktree = self.start_task(repo, "REVIEW-SYMLINK", "shared.txt")
|
|
1062
|
+
(worktree / "shared.txt").write_text("must stay git local\n", encoding="utf-8")
|
|
1063
|
+
review_root = self.registry_manifest_path(repo, "REVIEW-SYMLINK").parent.parent / "reviews"
|
|
1064
|
+
task_review_dir = review_root / "REVIEW-SYMLINK"
|
|
1065
|
+
if task_review_dir.exists():
|
|
1066
|
+
task_review_dir.rmdir()
|
|
1067
|
+
if review_root.exists():
|
|
1068
|
+
review_root.rmdir()
|
|
1069
|
+
outside = root / "outside-reviews"
|
|
1070
|
+
outside.mkdir()
|
|
1071
|
+
review_root.symlink_to(outside, target_is_directory=True)
|
|
1072
|
+
|
|
1073
|
+
rejected = self.ap(
|
|
1074
|
+
worktree,
|
|
1075
|
+
"review-assignment",
|
|
1076
|
+
"REVIEW-SYMLINK",
|
|
1077
|
+
"--reviewer",
|
|
1078
|
+
"reviewer-symlink",
|
|
1079
|
+
check=False,
|
|
1080
|
+
)
|
|
1081
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
1082
|
+
self.assertIn("symlinked Git-local review storage", rejected.stdout + rejected.stderr)
|
|
1083
|
+
self.assertFalse((outside / "REVIEW-SYMLINK").exists())
|
|
1084
|
+
|
|
1085
|
+
def test_review_snapshot_covers_git_states_without_mutating_main_index_or_objects(self) -> None:
|
|
1086
|
+
_, repo, _ = self.make_repo()
|
|
1087
|
+
(repo / "delete-me.txt").write_text("delete me\n", encoding="utf-8")
|
|
1088
|
+
git(repo, "add", "delete-me.txt")
|
|
1089
|
+
git(repo, "commit", "-qm", "add deletion fixture")
|
|
1090
|
+
git(repo, "push", "-q", "origin", "dev")
|
|
1091
|
+
worktree = self.start_task(repo, "REVIEW-GIT-STATES", ".")
|
|
1092
|
+
(worktree / "delete-me.txt").unlink()
|
|
1093
|
+
shared = worktree / "shared.txt"
|
|
1094
|
+
shared.write_text("executable review\n", encoding="utf-8")
|
|
1095
|
+
shared.chmod(shared.stat().st_mode | 0o111)
|
|
1096
|
+
(worktree / "binary-review.bin").write_bytes(b"\x00\x01binary-review\xff" * 32)
|
|
1097
|
+
(worktree / "review-link").symlink_to("shared.txt")
|
|
1098
|
+
index_path = Path(git_output(worktree, "rev-parse", "--git-path", "index"))
|
|
1099
|
+
if not index_path.is_absolute():
|
|
1100
|
+
index_path = (worktree / index_path).resolve()
|
|
1101
|
+
index_before = index_path.read_bytes()
|
|
1102
|
+
objects_before = git_output(worktree, "count-objects", "-v")
|
|
1103
|
+
|
|
1104
|
+
issued = json.loads(
|
|
1105
|
+
self.ap(
|
|
1106
|
+
worktree,
|
|
1107
|
+
"review-assignment",
|
|
1108
|
+
"REVIEW-GIT-STATES",
|
|
1109
|
+
"--reviewer",
|
|
1110
|
+
"reviewer-git-states",
|
|
1111
|
+
"--json",
|
|
1112
|
+
).stdout
|
|
1113
|
+
)
|
|
1114
|
+
patch = Path(issued["assignment"]["diff_artifact_path"]).read_bytes()
|
|
1115
|
+
self.assertIn(b"deleted file mode 100644", patch)
|
|
1116
|
+
self.assertIn(b"old mode 100644", patch)
|
|
1117
|
+
self.assertIn(b"new mode 100755", patch)
|
|
1118
|
+
self.assertIn(b"new file mode 120000", patch)
|
|
1119
|
+
self.assertIn(b"GIT binary patch", patch)
|
|
1120
|
+
self.assertEqual(index_before, index_path.read_bytes())
|
|
1121
|
+
self.assertEqual(objects_before, git_output(worktree, "count-objects", "-v"))
|
|
1122
|
+
self.assertFalse(list(Path(issued["assignment_path"]).parent.glob(".snapshot-*")))
|
|
1123
|
+
|
|
1124
|
+
def test_review_snapshot_stops_and_cleans_when_stream_limit_is_exceeded(self) -> None:
|
|
1125
|
+
_, repo, _ = self.make_repo()
|
|
1126
|
+
worktree = self.start_task(repo, "REVIEW-SIZE-LIMIT", "shared.txt")
|
|
1127
|
+
# The input itself stays below the test limit while the Git patch
|
|
1128
|
+
# headers plus body exceed it, exercising the streaming PIPE cutoff.
|
|
1129
|
+
(worktree / "shared.txt").write_text("small\n", encoding="utf-8")
|
|
1130
|
+
previous = os.environ.get("AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES")
|
|
1131
|
+
os.environ["AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES"] = "128"
|
|
1132
|
+
try:
|
|
1133
|
+
rejected = self.ap(
|
|
1134
|
+
worktree,
|
|
1135
|
+
"review-assignment",
|
|
1136
|
+
"REVIEW-SIZE-LIMIT",
|
|
1137
|
+
"--reviewer",
|
|
1138
|
+
"reviewer-size",
|
|
1139
|
+
check=False,
|
|
1140
|
+
)
|
|
1141
|
+
finally:
|
|
1142
|
+
if previous is None:
|
|
1143
|
+
os.environ.pop("AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES", None)
|
|
1144
|
+
else:
|
|
1145
|
+
os.environ["AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES"] = previous
|
|
1146
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
1147
|
+
self.assertIn("safety limit", rejected.stdout + rejected.stderr)
|
|
1148
|
+
review_dir = (
|
|
1149
|
+
self.registry_manifest_path(repo, "REVIEW-SIZE-LIMIT").parent.parent
|
|
1150
|
+
/ "reviews"
|
|
1151
|
+
/ "REVIEW-SIZE-LIMIT"
|
|
1152
|
+
)
|
|
1153
|
+
self.assertFalse(list(review_dir.glob(".snapshot-*")))
|
|
1154
|
+
self.assertFalse(list(review_dir.glob("*.assignment.json")))
|
|
1155
|
+
self.assertFalse(list(review_dir.glob("*.patch")))
|
|
1156
|
+
|
|
1157
|
+
def test_review_snapshot_rejects_oversized_input_before_creating_temp_objects(self) -> None:
|
|
1158
|
+
_, repo, _ = self.make_repo()
|
|
1159
|
+
worktree = self.start_task(repo, "REVIEW-INPUT-LIMIT", "shared.txt")
|
|
1160
|
+
(worktree / "shared.txt").write_text("x" * 4096 + "\n", encoding="utf-8")
|
|
1161
|
+
objects_before = git_output(worktree, "count-objects", "-v")
|
|
1162
|
+
previous = os.environ.get("AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES")
|
|
1163
|
+
os.environ["AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES"] = "128"
|
|
1164
|
+
try:
|
|
1165
|
+
rejected = self.ap(
|
|
1166
|
+
worktree,
|
|
1167
|
+
"review-assignment",
|
|
1168
|
+
"REVIEW-INPUT-LIMIT",
|
|
1169
|
+
"--reviewer",
|
|
1170
|
+
"reviewer-input-size",
|
|
1171
|
+
check=False,
|
|
1172
|
+
)
|
|
1173
|
+
finally:
|
|
1174
|
+
if previous is None:
|
|
1175
|
+
os.environ.pop("AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES", None)
|
|
1176
|
+
else:
|
|
1177
|
+
os.environ["AUTOCODING_REVIEW_ARTIFACT_MAX_BYTES"] = previous
|
|
1178
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
1179
|
+
self.assertIn("snapshot input exceeds", rejected.stdout + rejected.stderr)
|
|
1180
|
+
review_dir = (
|
|
1181
|
+
self.registry_manifest_path(repo, "REVIEW-INPUT-LIMIT").parent.parent
|
|
1182
|
+
/ "reviews"
|
|
1183
|
+
/ "REVIEW-INPUT-LIMIT"
|
|
1184
|
+
)
|
|
1185
|
+
self.assertFalse(review_dir.exists())
|
|
1186
|
+
self.assertEqual(objects_before, git_output(worktree, "count-objects", "-v"))
|
|
907
1187
|
|
|
908
1188
|
def test_review_run_supervises_separate_process_and_records_result_once(self) -> None:
|
|
909
1189
|
root, repo, _ = self.make_repo()
|
|
910
|
-
worktree = self.start_task(repo, "REVIEW-RUN", "
|
|
911
|
-
(worktree / "shared.txt").write_text("review
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
"
|
|
915
|
-
"if os.environ.get('CODEX_THREAD_ID'):\n"
|
|
916
|
-
" raise SystemExit(9)\n"
|
|
917
|
-
"assignment_path = pathlib.Path(os.environ['AUTOCODING_REVIEW_ASSIGNMENT'])\n"
|
|
918
|
-
"assignment = json.loads(assignment_path.read_text(encoding='utf-8'))\n"
|
|
919
|
-
"if int(os.environ['AUTOCODING_REVIEW_TIMEOUT_SECONDS']) not in (90, 300):\n"
|
|
920
|
-
" raise SystemExit(10)\n"
|
|
921
|
-
"print(json.dumps({'verdict': 'approved', 'summary': 'runtime reviewed', "
|
|
922
|
-
"'evidence': ['assignment=' + assignment['task_id']]}))\n",
|
|
1190
|
+
worktree = self.start_task(repo, "REVIEW-RUN", ".")
|
|
1191
|
+
(worktree / "shared.txt").write_text("staged tracked review token\n", encoding="utf-8")
|
|
1192
|
+
git(worktree, "add", "shared.txt")
|
|
1193
|
+
(worktree / "untracked-review.txt").write_text(
|
|
1194
|
+
"untracked review token\n",
|
|
923
1195
|
encoding="utf-8",
|
|
924
1196
|
)
|
|
925
|
-
runner =
|
|
1197
|
+
runner = self.artifact_reviewer_runner(
|
|
1198
|
+
root,
|
|
1199
|
+
"staged tracked review token",
|
|
1200
|
+
"untracked review token",
|
|
1201
|
+
)
|
|
926
1202
|
completed = self.ap(
|
|
927
1203
|
worktree,
|
|
928
1204
|
"review-run",
|
|
@@ -935,7 +1211,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
935
1211
|
)
|
|
936
1212
|
result = json.loads(completed.stdout)
|
|
937
1213
|
self.assertEqual("approved", result["verdict"])
|
|
938
|
-
self.assertEqual("
|
|
1214
|
+
self.assertEqual("artifact reviewed", result["summary"])
|
|
939
1215
|
|
|
940
1216
|
status = json.loads(
|
|
941
1217
|
self.ap(worktree, "task-status", "REVIEW-RUN", "--json").stdout
|
|
@@ -982,7 +1258,153 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
982
1258
|
check=False,
|
|
983
1259
|
)
|
|
984
1260
|
self.assertNotEqual(0, tampered.returncode)
|
|
985
|
-
self.assertIn("
|
|
1261
|
+
self.assertIn("result changed", tampered.stdout + tampered.stderr)
|
|
1262
|
+
|
|
1263
|
+
def test_review_run_retries_clean_exit_without_event_and_rejects_approved_file(self) -> None:
|
|
1264
|
+
root, repo, _ = self.make_repo()
|
|
1265
|
+
worktree = self.start_task(repo, "REVIEW-NO-EVENT", "shared.txt")
|
|
1266
|
+
(worktree / "shared.txt").write_text("review without event\n", encoding="utf-8")
|
|
1267
|
+
counter = root / "attempt-count.txt"
|
|
1268
|
+
runner_path = root / "no-event-reviewer.py"
|
|
1269
|
+
runner_path.write_text(
|
|
1270
|
+
"import json, os\n"
|
|
1271
|
+
"from pathlib import Path\n"
|
|
1272
|
+
f"counter = Path({str(counter)!r})\n"
|
|
1273
|
+
"counter.write_text(str(int(counter.read_text() or '0') + 1) if counter.exists() else '1')\n"
|
|
1274
|
+
"Path(os.environ['AUTOCODING_REVIEW_RESULT']).write_text(json.dumps({'verdict': 'approved'}) + '\\n')\n",
|
|
1275
|
+
encoding="utf-8",
|
|
1276
|
+
)
|
|
1277
|
+
rejected = self.ap(
|
|
1278
|
+
worktree,
|
|
1279
|
+
"review-run",
|
|
1280
|
+
"REVIEW-NO-EVENT",
|
|
1281
|
+
"--reviewer",
|
|
1282
|
+
"reviewer-no-event",
|
|
1283
|
+
"--runner-command-json",
|
|
1284
|
+
json.dumps([sys.executable, str(runner_path)]),
|
|
1285
|
+
check=False,
|
|
1286
|
+
)
|
|
1287
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
1288
|
+
self.assertIn("runtime-unavailable", rejected.stdout + rejected.stderr)
|
|
1289
|
+
self.assertEqual("2", counter.read_text())
|
|
1290
|
+
status = json.loads(
|
|
1291
|
+
self.ap(worktree, "task-status", "REVIEW-NO-EVENT", "--json").stdout
|
|
1292
|
+
)["tasks"][0]
|
|
1293
|
+
self.assertEqual("runtime-unavailable", status["review"]["runtime_state"])
|
|
1294
|
+
self.assertEqual("blocked", status["review"]["verdict"])
|
|
1295
|
+
|
|
1296
|
+
def test_substantive_result_written_before_timeout_cannot_be_bypassed(self) -> None:
|
|
1297
|
+
root, repo, _ = self.make_repo()
|
|
1298
|
+
worktree = self.start_task(repo, "REVIEW-SUBSTANTIVE", "shared.txt")
|
|
1299
|
+
(worktree / "shared.txt").write_text("substantive finding\n", encoding="utf-8")
|
|
1300
|
+
issued = json.loads(
|
|
1301
|
+
self.ap(
|
|
1302
|
+
worktree,
|
|
1303
|
+
"review-assignment",
|
|
1304
|
+
"REVIEW-SUBSTANTIVE",
|
|
1305
|
+
"--reviewer",
|
|
1306
|
+
"reviewer-substantive",
|
|
1307
|
+
"--json",
|
|
1308
|
+
).stdout
|
|
1309
|
+
)
|
|
1310
|
+
self.shorten_review_deadline(repo, "REVIEW-SUBSTANTIVE", issued)
|
|
1311
|
+
runner_path = root / "substantive-reviewer.py"
|
|
1312
|
+
runner_path.write_text(
|
|
1313
|
+
"import json, os, time\n"
|
|
1314
|
+
"from pathlib import Path\n"
|
|
1315
|
+
"result = Path(os.environ['AUTOCODING_REVIEW_RESULT'])\n"
|
|
1316
|
+
"result.write_text(json.dumps({'verdict': 'changes-requested', 'summary': 'real defect'}) + '\\n')\n"
|
|
1317
|
+
"result.chmod(0o600)\n"
|
|
1318
|
+
"print(json.dumps({'type': 'turn.started'}), flush=True)\n"
|
|
1319
|
+
"time.sleep(30)\n",
|
|
1320
|
+
encoding="utf-8",
|
|
1321
|
+
)
|
|
1322
|
+
timed_out = self.ap(
|
|
1323
|
+
worktree,
|
|
1324
|
+
"review-run",
|
|
1325
|
+
"REVIEW-SUBSTANTIVE",
|
|
1326
|
+
"--reviewer",
|
|
1327
|
+
"reviewer-substantive",
|
|
1328
|
+
"--runner-command-json",
|
|
1329
|
+
json.dumps([sys.executable, str(runner_path)]),
|
|
1330
|
+
check=False,
|
|
1331
|
+
)
|
|
1332
|
+
self.assertNotEqual(0, timed_out.returncode)
|
|
1333
|
+
self.assertIn("cannot be bypassed", timed_out.stdout + timed_out.stderr)
|
|
1334
|
+
status = json.loads(
|
|
1335
|
+
self.ap(worktree, "task-status", "REVIEW-SUBSTANTIVE", "--json").stdout
|
|
1336
|
+
)["tasks"][0]
|
|
1337
|
+
review = status["review"]
|
|
1338
|
+
self.assertEqual("changes-requested", review["verdict"])
|
|
1339
|
+
self.assertEqual("blocked", review["runtime_state"])
|
|
1340
|
+
receipt = json.loads(Path(review["runtime_receipt_path"]).read_text())
|
|
1341
|
+
self.assertEqual("blocked", receipt["status"])
|
|
1342
|
+
self.assertEqual("changes-requested", receipt["verdict"])
|
|
1343
|
+
self.assertEqual(1, len(receipt["attempts"]))
|
|
1344
|
+
bypass = self.ap(
|
|
1345
|
+
worktree,
|
|
1346
|
+
"review-runtime-override",
|
|
1347
|
+
"REVIEW-SUBSTANTIVE",
|
|
1348
|
+
"--diff-fingerprint",
|
|
1349
|
+
status["current_diff_fingerprint"],
|
|
1350
|
+
"--authorized-by",
|
|
1351
|
+
"product-owner",
|
|
1352
|
+
"--authorization-ref",
|
|
1353
|
+
"conversation-substantive",
|
|
1354
|
+
"--reason",
|
|
1355
|
+
"A substantive Reviewer result must remain blocking.",
|
|
1356
|
+
"--evidence",
|
|
1357
|
+
"reviewer returned changes requested",
|
|
1358
|
+
"--confirm-runtime-bypass",
|
|
1359
|
+
check=False,
|
|
1360
|
+
)
|
|
1361
|
+
self.assertNotEqual(0, bypass.returncode)
|
|
1362
|
+
self.assertIn("allowed only after", bypass.stdout + bypass.stderr)
|
|
1363
|
+
|
|
1364
|
+
def test_substantive_agent_message_before_timeout_cannot_be_bypassed(self) -> None:
|
|
1365
|
+
root, repo, _ = self.make_repo()
|
|
1366
|
+
worktree = self.start_task(repo, "REVIEW-EVENT-FINDING", "shared.txt")
|
|
1367
|
+
(worktree / "shared.txt").write_text("event finding\n", encoding="utf-8")
|
|
1368
|
+
issued = json.loads(
|
|
1369
|
+
self.ap(
|
|
1370
|
+
worktree,
|
|
1371
|
+
"review-assignment",
|
|
1372
|
+
"REVIEW-EVENT-FINDING",
|
|
1373
|
+
"--reviewer",
|
|
1374
|
+
"reviewer-event-finding",
|
|
1375
|
+
"--json",
|
|
1376
|
+
).stdout
|
|
1377
|
+
)
|
|
1378
|
+
self.shorten_review_deadline(repo, "REVIEW-EVENT-FINDING", issued)
|
|
1379
|
+
runner_path = root / "event-finding-reviewer.py"
|
|
1380
|
+
runner_path.write_text(
|
|
1381
|
+
"import json, sys, time\n"
|
|
1382
|
+
"result = json.dumps({'verdict': 'blocked', 'summary': 'event-only defect'})\n"
|
|
1383
|
+
"print(json.dumps({'type': 'turn.started'}), flush=True)\n"
|
|
1384
|
+
"sys.stdout.write(json.dumps({'type': 'item.completed', 'item': {'type': 'agent_message', 'text': result}}))\n"
|
|
1385
|
+
"sys.stdout.flush()\n"
|
|
1386
|
+
"time.sleep(30)\n",
|
|
1387
|
+
encoding="utf-8",
|
|
1388
|
+
)
|
|
1389
|
+
timed_out = self.ap(
|
|
1390
|
+
worktree,
|
|
1391
|
+
"review-run",
|
|
1392
|
+
"REVIEW-EVENT-FINDING",
|
|
1393
|
+
"--reviewer",
|
|
1394
|
+
"reviewer-event-finding",
|
|
1395
|
+
"--runner-command-json",
|
|
1396
|
+
json.dumps([sys.executable, str(runner_path)]),
|
|
1397
|
+
check=False,
|
|
1398
|
+
)
|
|
1399
|
+
self.assertNotEqual(0, timed_out.returncode)
|
|
1400
|
+
self.assertIn("cannot be bypassed", timed_out.stdout + timed_out.stderr)
|
|
1401
|
+
status = json.loads(
|
|
1402
|
+
self.ap(worktree, "task-status", "REVIEW-EVENT-FINDING", "--json").stdout
|
|
1403
|
+
)["tasks"][0]
|
|
1404
|
+
self.assertEqual("blocked", status["review"]["verdict"])
|
|
1405
|
+
self.assertEqual("blocked", status["review"]["runtime_state"])
|
|
1406
|
+
result = json.loads(Path(status["review"]["runtime_result_path"]).read_text())
|
|
1407
|
+
self.assertEqual("event-only defect", result["summary"])
|
|
986
1408
|
|
|
987
1409
|
def test_blocked_runtime_cannot_be_reassigned_or_overwritten_as_approved(self) -> None:
|
|
988
1410
|
root, repo, _ = self.make_repo()
|
|
@@ -1037,8 +1459,27 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1037
1459
|
)
|
|
1038
1460
|
self.assertNotEqual(0, overwritten.returncode)
|
|
1039
1461
|
self.assertIn("runtime state=blocked", overwritten.stdout + overwritten.stderr)
|
|
1462
|
+
bypass = self.ap(
|
|
1463
|
+
worktree,
|
|
1464
|
+
"review-runtime-override",
|
|
1465
|
+
"REVIEW-BLOCKED",
|
|
1466
|
+
"--diff-fingerprint",
|
|
1467
|
+
status["current_diff_fingerprint"],
|
|
1468
|
+
"--authorized-by",
|
|
1469
|
+
"product-owner",
|
|
1470
|
+
"--authorization-ref",
|
|
1471
|
+
"conversation-blocked",
|
|
1472
|
+
"--reason",
|
|
1473
|
+
"User cannot override a substantive Reviewer blocked verdict.",
|
|
1474
|
+
"--evidence",
|
|
1475
|
+
"reviewer returned blocked",
|
|
1476
|
+
"--confirm-runtime-bypass",
|
|
1477
|
+
check=False,
|
|
1478
|
+
)
|
|
1479
|
+
self.assertNotEqual(0, bypass.returncode)
|
|
1480
|
+
self.assertIn("allowed only after", bypass.stdout + bypass.stderr)
|
|
1040
1481
|
|
|
1041
|
-
def
|
|
1482
|
+
def test_review_run_retries_runtime_unavailable_and_allows_bound_user_override(self) -> None:
|
|
1042
1483
|
root, repo, _ = self.make_repo()
|
|
1043
1484
|
worktree = self.start_task(repo, "REVIEW-TIMEOUT", "shared.txt")
|
|
1044
1485
|
(worktree / "shared.txt").write_text("review me slowly\n", encoding="utf-8")
|
|
@@ -1052,42 +1493,145 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1052
1493
|
"--json",
|
|
1053
1494
|
).stdout
|
|
1054
1495
|
)
|
|
1055
|
-
|
|
1056
|
-
assignment = issued["assignment"]
|
|
1057
|
-
assignment["deadline_at"] = deadline.isoformat()
|
|
1058
|
-
assignment["issued_at"] = (deadline - timedelta(seconds=90)).isoformat()
|
|
1059
|
-
assignment_path = Path(issued["assignment_path"])
|
|
1060
|
-
assignment_path.write_text(json.dumps(assignment, indent=2) + "\n", encoding="utf-8")
|
|
1061
|
-
manifest_path = self.registry_manifest_path(repo, "REVIEW-TIMEOUT")
|
|
1062
|
-
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
1063
|
-
manifest["review"]["issued_at"] = assignment["issued_at"]
|
|
1064
|
-
manifest["review"]["deadline_at"] = assignment["deadline_at"]
|
|
1065
|
-
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
1496
|
+
self.shorten_review_deadline(repo, "REVIEW-TIMEOUT", issued, seconds=5)
|
|
1066
1497
|
|
|
1067
1498
|
slow_reviewer = root / "slow-reviewer.py"
|
|
1068
1499
|
slow_reviewer.write_text("import time\ntime.sleep(30)\n", encoding="utf-8")
|
|
1069
1500
|
started = time.monotonic()
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1501
|
+
previous_startup_timeout = os.environ.get("AUTOCODING_REVIEW_STARTUP_TIMEOUT_SECONDS")
|
|
1502
|
+
os.environ["AUTOCODING_REVIEW_STARTUP_TIMEOUT_SECONDS"] = "0.1"
|
|
1503
|
+
try:
|
|
1504
|
+
timed_out = self.ap(
|
|
1505
|
+
worktree,
|
|
1506
|
+
"review-run",
|
|
1507
|
+
"REVIEW-TIMEOUT",
|
|
1508
|
+
"--reviewer",
|
|
1509
|
+
"reviewer-timeout",
|
|
1510
|
+
"--runner-command-json",
|
|
1511
|
+
json.dumps([sys.executable, str(slow_reviewer)]),
|
|
1512
|
+
check=False,
|
|
1513
|
+
)
|
|
1514
|
+
finally:
|
|
1515
|
+
if previous_startup_timeout is None:
|
|
1516
|
+
os.environ.pop("AUTOCODING_REVIEW_STARTUP_TIMEOUT_SECONDS", None)
|
|
1517
|
+
else:
|
|
1518
|
+
os.environ["AUTOCODING_REVIEW_STARTUP_TIMEOUT_SECONDS"] = previous_startup_timeout
|
|
1080
1519
|
elapsed = time.monotonic() - started
|
|
1081
1520
|
self.assertNotEqual(0, timed_out.returncode)
|
|
1082
1521
|
self.assertLess(elapsed, 6.0)
|
|
1083
|
-
self.assertIn("
|
|
1522
|
+
self.assertIn("runtime-unavailable", timed_out.stdout + timed_out.stderr)
|
|
1084
1523
|
status = json.loads(
|
|
1085
1524
|
self.ap(worktree, "task-status", "REVIEW-TIMEOUT", "--json").stdout
|
|
1086
1525
|
)["tasks"][0]
|
|
1087
1526
|
self.assertEqual("blocked", status["review"]["verdict"])
|
|
1088
|
-
self.assertEqual("
|
|
1527
|
+
self.assertEqual("runtime-unavailable", status["review"]["runtime_state"])
|
|
1089
1528
|
receipt = json.loads(Path(status["review"]["runtime_receipt_path"]).read_text())
|
|
1090
|
-
self.assertEqual(
|
|
1529
|
+
self.assertEqual(2, receipt["schema"])
|
|
1530
|
+
self.assertEqual("runtime-unavailable", receipt["status"])
|
|
1531
|
+
self.assertEqual(2, len(receipt["attempts"]))
|
|
1532
|
+
self.assertRegex(receipt["event_log_sha256"], r"^[0-9a-f]{64}$")
|
|
1533
|
+
|
|
1534
|
+
receipt_path = Path(status["review"]["runtime_receipt_path"])
|
|
1535
|
+
original_receipt = receipt_path.read_bytes()
|
|
1536
|
+
tampered_receipt = json.loads(original_receipt)
|
|
1537
|
+
tampered_receipt["failure_kind"] = "tampered-before-override"
|
|
1538
|
+
receipt_path.write_text(json.dumps(tampered_receipt) + "\n", encoding="utf-8")
|
|
1539
|
+
rejected_receipt = self.ap(
|
|
1540
|
+
worktree,
|
|
1541
|
+
"review-runtime-override",
|
|
1542
|
+
"REVIEW-TIMEOUT",
|
|
1543
|
+
"--diff-fingerprint",
|
|
1544
|
+
status["current_diff_fingerprint"],
|
|
1545
|
+
"--authorized-by",
|
|
1546
|
+
"product-owner",
|
|
1547
|
+
"--authorization-ref",
|
|
1548
|
+
"conversation-pre-tamper",
|
|
1549
|
+
"--reason",
|
|
1550
|
+
"Tampered pre-override evidence must be rejected.",
|
|
1551
|
+
"--evidence",
|
|
1552
|
+
"targeted tests passed",
|
|
1553
|
+
"--confirm-runtime-bypass",
|
|
1554
|
+
check=False,
|
|
1555
|
+
)
|
|
1556
|
+
self.assertNotEqual(0, rejected_receipt.returncode)
|
|
1557
|
+
self.assertIn("changed after failure finalization", rejected_receipt.stdout + rejected_receipt.stderr)
|
|
1558
|
+
receipt_path.write_bytes(original_receipt)
|
|
1559
|
+
|
|
1560
|
+
event_log_path = Path(status["review"]["runtime_event_log_path"])
|
|
1561
|
+
original_event_log = event_log_path.read_bytes()
|
|
1562
|
+
event_log_path.write_bytes(original_event_log + b'{"event_type":"tampered"}\n')
|
|
1563
|
+
rejected_event = self.ap(
|
|
1564
|
+
worktree,
|
|
1565
|
+
"review-runtime-override",
|
|
1566
|
+
"REVIEW-TIMEOUT",
|
|
1567
|
+
"--diff-fingerprint",
|
|
1568
|
+
status["current_diff_fingerprint"],
|
|
1569
|
+
"--authorized-by",
|
|
1570
|
+
"product-owner",
|
|
1571
|
+
"--authorization-ref",
|
|
1572
|
+
"conversation-event-tamper",
|
|
1573
|
+
"--reason",
|
|
1574
|
+
"Tampered event evidence must be rejected before override.",
|
|
1575
|
+
"--evidence",
|
|
1576
|
+
"targeted tests passed",
|
|
1577
|
+
"--confirm-runtime-bypass",
|
|
1578
|
+
check=False,
|
|
1579
|
+
)
|
|
1580
|
+
self.assertNotEqual(0, rejected_event.returncode)
|
|
1581
|
+
self.assertIn("event log changed", rejected_event.stdout + rejected_event.stderr)
|
|
1582
|
+
event_log_path.write_bytes(original_event_log)
|
|
1583
|
+
|
|
1584
|
+
override = json.loads(
|
|
1585
|
+
self.ap(
|
|
1586
|
+
worktree,
|
|
1587
|
+
"review-runtime-override",
|
|
1588
|
+
"REVIEW-TIMEOUT",
|
|
1589
|
+
"--diff-fingerprint",
|
|
1590
|
+
status["current_diff_fingerprint"],
|
|
1591
|
+
"--authorized-by",
|
|
1592
|
+
"product-owner",
|
|
1593
|
+
"--authorization-ref",
|
|
1594
|
+
"conversation-2026-07-17",
|
|
1595
|
+
"--reason",
|
|
1596
|
+
"User accepted the exhausted Reviewer runtime failure.",
|
|
1597
|
+
"--evidence",
|
|
1598
|
+
"targeted tests passed",
|
|
1599
|
+
"--confirm-runtime-bypass",
|
|
1600
|
+
"--json",
|
|
1601
|
+
).stdout
|
|
1602
|
+
)
|
|
1603
|
+
self.assertEqual("runtime-bypassed", override["verdict"])
|
|
1604
|
+
bypassed_status = json.loads(
|
|
1605
|
+
self.ap(worktree, "task-status", "REVIEW-TIMEOUT", "--json").stdout
|
|
1606
|
+
)["tasks"][0]
|
|
1607
|
+
self.assertEqual("runtime-bypassed", bypassed_status["review"]["verdict"])
|
|
1608
|
+
self.assertEqual("runtime-bypassed", bypassed_status["review"]["runtime_state"])
|
|
1609
|
+
|
|
1610
|
+
receipt_path = Path(bypassed_status["review"]["runtime_receipt_path"])
|
|
1611
|
+
original_receipt = receipt_path.read_bytes()
|
|
1612
|
+
tampered_receipt = json.loads(original_receipt)
|
|
1613
|
+
tampered_receipt["failure_kind"] = "tampered"
|
|
1614
|
+
receipt_path.write_text(json.dumps(tampered_receipt) + "\n", encoding="utf-8")
|
|
1615
|
+
rejected_tamper = self.ap(
|
|
1616
|
+
worktree,
|
|
1617
|
+
"commit-push",
|
|
1618
|
+
"REVIEW-TIMEOUT",
|
|
1619
|
+
"--msg",
|
|
1620
|
+
"test: reject tampered runtime bypass",
|
|
1621
|
+
check=False,
|
|
1622
|
+
)
|
|
1623
|
+
self.assertNotEqual(0, rejected_tamper.returncode)
|
|
1624
|
+
self.assertIn("receipt SHA-256", rejected_tamper.stdout + rejected_tamper.stderr)
|
|
1625
|
+
receipt_path.write_bytes(original_receipt)
|
|
1626
|
+
|
|
1627
|
+
pushed = self.ap(
|
|
1628
|
+
worktree,
|
|
1629
|
+
"commit-push",
|
|
1630
|
+
"REVIEW-TIMEOUT",
|
|
1631
|
+
"--msg",
|
|
1632
|
+
"test: allow bound runtime bypass",
|
|
1633
|
+
)
|
|
1634
|
+
self.assertIn("commit-push", pushed.stdout + pushed.stderr)
|
|
1091
1635
|
|
|
1092
1636
|
def test_task_review_requires_assignment_and_exact_head(self) -> None:
|
|
1093
1637
|
_, repo, _ = self.make_repo()
|
|
@@ -1156,13 +1700,16 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1156
1700
|
assignment = issued["assignment"]
|
|
1157
1701
|
past_deadline = datetime.now(timezone.utc).replace(microsecond=0) - timedelta(seconds=1)
|
|
1158
1702
|
assignment["deadline_at"] = past_deadline.isoformat()
|
|
1159
|
-
assignment["issued_at"] = (past_deadline - timedelta(seconds=
|
|
1703
|
+
assignment["issued_at"] = (past_deadline - timedelta(seconds=150)).isoformat()
|
|
1160
1704
|
assignment_path.write_text(json.dumps(assignment, indent=2) + "\n", encoding="utf-8")
|
|
1161
1705
|
|
|
1162
1706
|
manifest_path = self.registry_manifest_path(repo, "REVIEW-EXPIRED")
|
|
1163
1707
|
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
1164
1708
|
manifest["review"]["issued_at"] = assignment["issued_at"]
|
|
1165
1709
|
manifest["review"]["deadline_at"] = assignment["deadline_at"]
|
|
1710
|
+
manifest["review"]["assignment_sha256"] = hashlib.sha256(
|
|
1711
|
+
assignment_path.read_bytes()
|
|
1712
|
+
).hexdigest()
|
|
1166
1713
|
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
1167
1714
|
|
|
1168
1715
|
renewed = self.ap(
|
|
@@ -1724,6 +2271,12 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1724
2271
|
worktree = self.start_task(repo, "INTEGRATE-1")
|
|
1725
2272
|
(worktree / "integrated.txt").write_text("integrated\n", encoding="utf-8")
|
|
1726
2273
|
self.commit_push(worktree, "INTEGRATE-1", "INTEGRATE-1: ready")
|
|
2274
|
+
review_dir = Path(
|
|
2275
|
+
json.loads(
|
|
2276
|
+
self.registry_manifest_path(repo, "INTEGRATE-1").read_text(encoding="utf-8")
|
|
2277
|
+
)["review"]["assignment_path"]
|
|
2278
|
+
).parent
|
|
2279
|
+
self.assertTrue(review_dir.is_dir())
|
|
1727
2280
|
task_commit = git_output(worktree, "rev-parse", "HEAD")
|
|
1728
2281
|
self.assertEqual("c", commit_hook_marker.read_text(encoding="utf-8"))
|
|
1729
2282
|
self.assertFalse(
|
|
@@ -1747,6 +2300,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1747
2300
|
self.assertFalse(worktree.exists())
|
|
1748
2301
|
self.assert_local_branch(repo, "codex/INTEGRATE-1", False)
|
|
1749
2302
|
self.assert_remote_branch(remote, "codex/INTEGRATE-1", False)
|
|
2303
|
+
self.assertFalse(review_dir.exists())
|
|
1750
2304
|
self.assertEqual("x", gate_marker.read_text(encoding="utf-8"), "push flow must run the fast gate exactly once")
|
|
1751
2305
|
self.assertEqual("c", commit_hook_marker.read_text(encoding="utf-8"), "push flow must create exactly one hook-visible commit")
|
|
1752
2306
|
self.assertEqual("p", push_hook_marker.read_text(encoding="utf-8"), "the final target push hook must run exactly once")
|
|
@@ -1871,6 +2425,31 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1871
2425
|
self.assert_local_branch(repo, "codex/PRUNE-REGISTERED", False)
|
|
1872
2426
|
self.assert_remote_branch(remote, "codex/PRUNE-REGISTERED", False)
|
|
1873
2427
|
|
|
2428
|
+
def test_task_prune_removes_orphan_git_local_review_artifacts(self) -> None:
|
|
2429
|
+
_, repo, _ = self.make_repo()
|
|
2430
|
+
worktree = self.start_task(repo, "PRUNE-REVIEW-ORPHAN", "shared.txt")
|
|
2431
|
+
(worktree / "shared.txt").write_text("orphan review\n", encoding="utf-8")
|
|
2432
|
+
issued = json.loads(
|
|
2433
|
+
self.ap(
|
|
2434
|
+
worktree,
|
|
2435
|
+
"review-assignment",
|
|
2436
|
+
"PRUNE-REVIEW-ORPHAN",
|
|
2437
|
+
"--reviewer",
|
|
2438
|
+
"reviewer-orphan",
|
|
2439
|
+
"--json",
|
|
2440
|
+
).stdout
|
|
2441
|
+
)
|
|
2442
|
+
review_dir = Path(issued["assignment_path"]).parent
|
|
2443
|
+
self.assertTrue(review_dir.is_dir())
|
|
2444
|
+
git(repo, "worktree", "unlock", str(worktree))
|
|
2445
|
+
git(repo, "worktree", "remove", "--force", str(worktree))
|
|
2446
|
+
self.registry_manifest_path(repo, "PRUNE-REVIEW-ORPHAN").unlink()
|
|
2447
|
+
|
|
2448
|
+
self.ap(repo, "task-prune")
|
|
2449
|
+
|
|
2450
|
+
self.assertFalse(review_dir.exists())
|
|
2451
|
+
self.assert_local_branch(repo, "codex/PRUNE-REVIEW-ORPHAN", False)
|
|
2452
|
+
|
|
1874
2453
|
def test_cleanup_blocks_unknown_ignored_data_but_allows_runtime_evidence(self) -> None:
|
|
1875
2454
|
_, repo, remote = self.make_repo()
|
|
1876
2455
|
(repo / ".gitignore").write_text(".env\n.local/\n", encoding="utf-8")
|
|
@@ -2388,6 +2967,11 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
2388
2967
|
worktree = self.start_task(repo, "REMOTE-RACE")
|
|
2389
2968
|
(worktree / "payload.txt").write_text("ready\n", encoding="utf-8")
|
|
2390
2969
|
self.commit_push(worktree, "REMOTE-RACE", "REMOTE-RACE: ready")
|
|
2970
|
+
review_dir = Path(
|
|
2971
|
+
json.loads(
|
|
2972
|
+
self.registry_manifest_path(repo, "REMOTE-RACE").read_text(encoding="utf-8")
|
|
2973
|
+
)["review"]["assignment_path"]
|
|
2974
|
+
).parent
|
|
2391
2975
|
self.ap(repo, "task-integrate", "REMOTE-RACE", "--keep-worktree")
|
|
2392
2976
|
|
|
2393
2977
|
attacker = root / "attacker"
|
|
@@ -2412,6 +2996,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
2412
2996
|
manifest_path = self.registry_manifest_path(repo, "REMOTE-RACE")
|
|
2413
2997
|
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
2414
2998
|
self.assertEqual("cleanup-pending", manifest["state"])
|
|
2999
|
+
self.assertTrue(review_dir.is_dir())
|
|
2415
3000
|
|
|
2416
3001
|
prune = self.ap(repo, "task-prune")
|
|
2417
3002
|
self.assertIn("remote cleanup pending", prune.stdout + prune.stderr)
|
|
@@ -2421,6 +3006,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
2421
3006
|
git(remote, "update-ref", "-d", "refs/heads/codex/REMOTE-RACE", changed_remote_tip)
|
|
2422
3007
|
self.ap(repo, "task-prune")
|
|
2423
3008
|
self.assertFalse(manifest_path.exists())
|
|
3009
|
+
self.assertFalse(review_dir.exists())
|
|
2424
3010
|
self.assert_remote_branch(remote, "codex/REMOTE-RACE", False)
|
|
2425
3011
|
|
|
2426
3012
|
def test_gate_mutation_aborts_before_staging_or_commit(self) -> None:
|