@elvis1513/auto-coding-skill 4.3.2 → 4.3.4
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 +61 -1
- package/cli/assets/managed-install.json +1 -1
- package/cli/assets/skill/SKILL.md +7 -0
- package/cli/assets/skill/data/policies/feedback-resolutions-v1.json +48 -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 +7 -1
- package/cli/assets/skill/scripts/ap.py +931 -51
- package/cli/src/index.js +0 -12
- package/cli/tests/ap_concurrency_test.py +306 -9
- package/cli/tests/ap_profiles_test.py +108 -2
- package/cli/tests/core_shell_test.py +5 -5
- package/cli/tests/index.test.js +40 -34
- package/package.json +1 -1
package/cli/src/index.js
CHANGED
|
@@ -1874,18 +1874,6 @@ function readPackageVersion(){
|
|
|
1874
1874
|
}
|
|
1875
1875
|
|
|
1876
1876
|
function feedbackLifecycleStatus(root, assetSkill){
|
|
1877
|
-
if (!exists(path.join(root, "docs", "skill-feedback", "reports"))) {
|
|
1878
|
-
return {
|
|
1879
|
-
available: true,
|
|
1880
|
-
skillVersion: "",
|
|
1881
|
-
reportCount: 0,
|
|
1882
|
-
activeReportCount: 0,
|
|
1883
|
-
closedReportCount: 0,
|
|
1884
|
-
actionRequiredCount: 0,
|
|
1885
|
-
lifecycleCounts: {},
|
|
1886
|
-
actionRequired: [],
|
|
1887
|
-
};
|
|
1888
|
-
}
|
|
1889
1877
|
const result = spawnSync(
|
|
1890
1878
|
runtimePython(),
|
|
1891
1879
|
[path.join(assetSkill, "scripts", "ap.py"), "feedback-collect", "--project", root, "--json"],
|
|
@@ -4,6 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
import hashlib
|
|
5
5
|
import json
|
|
6
6
|
import os
|
|
7
|
+
import shutil
|
|
7
8
|
import subprocess
|
|
8
9
|
import sys
|
|
9
10
|
import tempfile
|
|
@@ -180,6 +181,52 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
180
181
|
check=check,
|
|
181
182
|
)
|
|
182
183
|
|
|
184
|
+
def ap_script(
|
|
185
|
+
self,
|
|
186
|
+
repo: Path,
|
|
187
|
+
script: Path,
|
|
188
|
+
*args: str,
|
|
189
|
+
check: bool = True,
|
|
190
|
+
) -> subprocess.CompletedProcess[str]:
|
|
191
|
+
return command(
|
|
192
|
+
repo,
|
|
193
|
+
sys.executable,
|
|
194
|
+
str(script),
|
|
195
|
+
"--repo",
|
|
196
|
+
str(repo),
|
|
197
|
+
*args,
|
|
198
|
+
check=check,
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
def managed_runtime(self, root: Path) -> Path:
|
|
202
|
+
install_root = root / "managed-runtime"
|
|
203
|
+
skill = install_root / ".agents" / "skills" / "auto-coding-skill"
|
|
204
|
+
shutil.copytree(REPO_ROOT / "src" / "auto-coding-skill", skill)
|
|
205
|
+
script = skill / "scripts" / "ap.py"
|
|
206
|
+
relative = ".agents/skills/auto-coding-skill/scripts/ap.py"
|
|
207
|
+
manifest = {
|
|
208
|
+
"schema_version": 1,
|
|
209
|
+
"skill_version": "4.3.4",
|
|
210
|
+
"manifest_path": ".agents/managed-install.json",
|
|
211
|
+
"entries": [
|
|
212
|
+
{
|
|
213
|
+
"path": relative,
|
|
214
|
+
"source": "skill/scripts/ap.py",
|
|
215
|
+
"ownership": "exact",
|
|
216
|
+
"sha256": hashlib.sha256(script.read_bytes()).hexdigest(),
|
|
217
|
+
"executable": bool(script.stat().st_mode & 0o111),
|
|
218
|
+
"scope": "shared",
|
|
219
|
+
"version": "4.3.4",
|
|
220
|
+
}
|
|
221
|
+
],
|
|
222
|
+
"managed_namespaces": [],
|
|
223
|
+
"preserved": [],
|
|
224
|
+
}
|
|
225
|
+
manifest_path = install_root / ".agents" / "managed-install.json"
|
|
226
|
+
manifest_path.parent.mkdir(parents=True, exist_ok=True)
|
|
227
|
+
manifest_path.write_text(json.dumps(manifest) + "\n", encoding="utf-8")
|
|
228
|
+
return script
|
|
229
|
+
|
|
183
230
|
def approve_task(self, repo: Path, task_id: str) -> str:
|
|
184
231
|
issued = json.loads(
|
|
185
232
|
self.ap(
|
|
@@ -216,7 +263,12 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
216
263
|
self.approve_task(repo, task_id)
|
|
217
264
|
return self.ap(repo, "commit-push", task_id, "--msg", message)
|
|
218
265
|
|
|
219
|
-
def artifact_reviewer_runner(
|
|
266
|
+
def artifact_reviewer_runner(
|
|
267
|
+
self,
|
|
268
|
+
root: Path,
|
|
269
|
+
*tokens: str,
|
|
270
|
+
runtime_script: Path = AP_SCRIPT,
|
|
271
|
+
) -> str:
|
|
220
272
|
fake_reviewer = root / "fake-artifact-reviewer.py"
|
|
221
273
|
fake_reviewer.write_text(
|
|
222
274
|
"import hashlib, json, os, pathlib, subprocess, sys\n"
|
|
@@ -249,7 +301,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
249
301
|
"'evidence': ['diff_artifact_sha256=' + actual]}))\n",
|
|
250
302
|
encoding="utf-8",
|
|
251
303
|
)
|
|
252
|
-
return json.dumps([sys.executable, str(fake_reviewer), str(
|
|
304
|
+
return json.dumps([sys.executable, str(fake_reviewer), str(runtime_script), *tokens])
|
|
253
305
|
|
|
254
306
|
def task_worktree(self, repo: Path, task_id: str) -> Path:
|
|
255
307
|
wanted = f"refs/heads/codex/{task_id}"
|
|
@@ -332,6 +384,30 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
332
384
|
self.assertIn("AGENTS.md:2", result.stdout + result.stderr)
|
|
333
385
|
self.assert_local_branch(repo, "codex/POLICY-START", False)
|
|
334
386
|
|
|
387
|
+
def test_task_start_rejects_owner_and_writer_that_conflict_with_runtime_identity(self) -> None:
|
|
388
|
+
_, repo, _ = self.make_repo()
|
|
389
|
+
for field in ("owner", "writer"):
|
|
390
|
+
with self.subTest(field=field):
|
|
391
|
+
task_id = f"IDENTITY-{field.upper()}"
|
|
392
|
+
rejected = self.ap(
|
|
393
|
+
repo,
|
|
394
|
+
"task-start",
|
|
395
|
+
task_id,
|
|
396
|
+
"--base",
|
|
397
|
+
"origin/dev",
|
|
398
|
+
"--owned-path",
|
|
399
|
+
"shared.txt",
|
|
400
|
+
"--isolated",
|
|
401
|
+
"--review-required",
|
|
402
|
+
f"--{field}",
|
|
403
|
+
"different-runtime-actor",
|
|
404
|
+
check=False,
|
|
405
|
+
)
|
|
406
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
407
|
+
self.assertIn("does not match CODEX_THREAD_ID", rejected.stdout + rejected.stderr)
|
|
408
|
+
self.assertFalse(self.registry_manifest_path(repo, task_id).exists())
|
|
409
|
+
self.assert_local_branch(repo, f"codex/{task_id}", False)
|
|
410
|
+
|
|
335
411
|
def test_task_start_rejects_legacy_gate_yaml_before_creating_branch(self) -> None:
|
|
336
412
|
_, repo, _ = self.make_repo()
|
|
337
413
|
engineering = repo / "docs" / "ENGINEERING.md"
|
|
@@ -930,13 +1006,22 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
930
1006
|
"src",
|
|
931
1007
|
"--isolated",
|
|
932
1008
|
"--review-required",
|
|
933
|
-
"--writer",
|
|
934
|
-
"self-reviewer",
|
|
935
1009
|
)
|
|
936
1010
|
worktree = self.task_worktree(repo, "SELF-REVIEW")
|
|
937
1011
|
payload = worktree / "src" / "payload.txt"
|
|
938
1012
|
payload.parent.mkdir(parents=True, exist_ok=True)
|
|
939
1013
|
payload.write_text("changed\n", encoding="utf-8")
|
|
1014
|
+
self.ap(
|
|
1015
|
+
repo,
|
|
1016
|
+
"task-handoff",
|
|
1017
|
+
"SELF-REVIEW",
|
|
1018
|
+
"--from",
|
|
1019
|
+
_TEST_OWNER,
|
|
1020
|
+
"--to",
|
|
1021
|
+
"self-reviewer",
|
|
1022
|
+
"--generation",
|
|
1023
|
+
"1",
|
|
1024
|
+
)
|
|
940
1025
|
status = json.loads(
|
|
941
1026
|
self.ap(worktree, "task-status", "SELF-REVIEW", "--json").stdout
|
|
942
1027
|
)["tasks"][0]
|
|
@@ -1361,6 +1446,47 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1361
1446
|
self.assertNotEqual(0, bypass.returncode)
|
|
1362
1447
|
self.assertIn("allowed only after", bypass.stdout + bypass.stderr)
|
|
1363
1448
|
|
|
1449
|
+
def test_substantive_result_survives_nonzero_reviewer_exit(self) -> None:
|
|
1450
|
+
root, repo, _ = self.make_repo()
|
|
1451
|
+
worktree = self.start_task(repo, "REVIEW-NONZERO", "shared.txt")
|
|
1452
|
+
(worktree / "shared.txt").write_text("nonzero substantive finding\n", encoding="utf-8")
|
|
1453
|
+
runner_path = root / "nonzero-substantive-reviewer.py"
|
|
1454
|
+
runner_path.write_text(
|
|
1455
|
+
"import json, os\n"
|
|
1456
|
+
"from pathlib import Path\n"
|
|
1457
|
+
"result = Path(os.environ['AUTOCODING_REVIEW_RESULT'])\n"
|
|
1458
|
+
"result.write_text(json.dumps({'verdict': 'changes-requested', 'summary': 'specific defect'}) + '\\n')\n"
|
|
1459
|
+
"result.chmod(0o600)\n"
|
|
1460
|
+
"print(json.dumps({'type': 'turn.started'}), flush=True)\n"
|
|
1461
|
+
"raise SystemExit(7)\n",
|
|
1462
|
+
encoding="utf-8",
|
|
1463
|
+
)
|
|
1464
|
+
rejected = self.ap(
|
|
1465
|
+
worktree,
|
|
1466
|
+
"review-run",
|
|
1467
|
+
"REVIEW-NONZERO",
|
|
1468
|
+
"--reviewer",
|
|
1469
|
+
"reviewer-nonzero",
|
|
1470
|
+
"--runner-command-json",
|
|
1471
|
+
json.dumps([sys.executable, str(runner_path)]),
|
|
1472
|
+
check=False,
|
|
1473
|
+
)
|
|
1474
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
1475
|
+
self.assertIn("cannot be bypassed", rejected.stdout + rejected.stderr)
|
|
1476
|
+
status = json.loads(
|
|
1477
|
+
self.ap(worktree, "task-status", "REVIEW-NONZERO", "--json").stdout
|
|
1478
|
+
)["tasks"][0]
|
|
1479
|
+
review = status["review"]
|
|
1480
|
+
self.assertEqual("changes-requested", review["verdict"])
|
|
1481
|
+
self.assertEqual("blocked", review["runtime_state"])
|
|
1482
|
+
self.assertEqual(7, review["runtime_exit_code"])
|
|
1483
|
+
result = json.loads(Path(review["runtime_result_path"]).read_text())
|
|
1484
|
+
self.assertEqual("specific defect", result["summary"])
|
|
1485
|
+
receipt = json.loads(Path(review["runtime_receipt_path"]).read_text())
|
|
1486
|
+
self.assertEqual("blocked", receipt["status"])
|
|
1487
|
+
self.assertEqual("changes-requested", receipt["verdict"])
|
|
1488
|
+
self.assertEqual(7, receipt["exit_code"])
|
|
1489
|
+
|
|
1364
1490
|
def test_substantive_agent_message_before_timeout_cannot_be_bypassed(self) -> None:
|
|
1365
1491
|
root, repo, _ = self.make_repo()
|
|
1366
1492
|
worktree = self.start_task(repo, "REVIEW-EVENT-FINDING", "shared.txt")
|
|
@@ -1479,6 +1605,167 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1479
1605
|
self.assertNotEqual(0, bypass.returncode)
|
|
1480
1606
|
self.assertIn("allowed only after", bypass.stdout + bypass.stderr)
|
|
1481
1607
|
|
|
1608
|
+
def test_known_432_artifact_access_block_gets_one_immutable_managed_retry(self) -> None:
|
|
1609
|
+
root, repo, _ = self.make_repo()
|
|
1610
|
+
managed_script = self.managed_runtime(root)
|
|
1611
|
+
worktree = self.start_task(repo, "REVIEW-MANAGED-RETRY", "shared.txt")
|
|
1612
|
+
(worktree / "shared.txt").write_text("managed retry payload\n", encoding="utf-8")
|
|
1613
|
+
common_dir = Path(git_output(repo, "rev-parse", "--git-common-dir"))
|
|
1614
|
+
if not common_dir.is_absolute():
|
|
1615
|
+
common_dir = (repo / common_dir).resolve()
|
|
1616
|
+
state_root = common_dir / "auto-coding-skill"
|
|
1617
|
+
blocked_reviewer = root / "known-artifact-access-block.py"
|
|
1618
|
+
blocked_reviewer.write_text(
|
|
1619
|
+
"import json\n"
|
|
1620
|
+
f"state_root = {str(state_root)!r}\n"
|
|
1621
|
+
"print(json.dumps({"
|
|
1622
|
+
"'verdict': 'blocked', "
|
|
1623
|
+
"'summary': 'Review could not begin because review-artifact failed before emitting the immutable patch.', "
|
|
1624
|
+
"'evidence': ['review-artifact exited 2: Cannot protect Git-local review storage at ' + state_root + ': Operation not permitted.'], "
|
|
1625
|
+
"'risks': ['The immutable patch was not emitted or substantively reviewed.']}))\n",
|
|
1626
|
+
encoding="utf-8",
|
|
1627
|
+
)
|
|
1628
|
+
blocked = self.ap(
|
|
1629
|
+
worktree,
|
|
1630
|
+
"review-run",
|
|
1631
|
+
"REVIEW-MANAGED-RETRY",
|
|
1632
|
+
"--reviewer",
|
|
1633
|
+
"managed-retry-reviewer",
|
|
1634
|
+
"--runner-command-json",
|
|
1635
|
+
json.dumps([sys.executable, str(blocked_reviewer)]),
|
|
1636
|
+
check=False,
|
|
1637
|
+
)
|
|
1638
|
+
self.assertNotEqual(0, blocked.returncode)
|
|
1639
|
+
manifest_path = self.registry_manifest_path(repo, "REVIEW-MANAGED-RETRY")
|
|
1640
|
+
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
1641
|
+
manifest["skill_version"] = "4.3.2"
|
|
1642
|
+
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
1643
|
+
prior_review = manifest["review"]
|
|
1644
|
+
prior_paths = [
|
|
1645
|
+
Path(prior_review["assignment_path"]),
|
|
1646
|
+
Path(prior_review["diff_artifact_path"]),
|
|
1647
|
+
Path(prior_review["runtime_result_path"]),
|
|
1648
|
+
Path(prior_review["runtime_receipt_path"]),
|
|
1649
|
+
Path(prior_review["runtime_event_log_path"]),
|
|
1650
|
+
]
|
|
1651
|
+
prior_bytes = {path: path.read_bytes() for path in prior_paths}
|
|
1652
|
+
fingerprint = prior_review["diff_fingerprint"]
|
|
1653
|
+
|
|
1654
|
+
authorized = json.loads(
|
|
1655
|
+
self.ap_script(
|
|
1656
|
+
worktree,
|
|
1657
|
+
managed_script,
|
|
1658
|
+
"review-runtime-retry",
|
|
1659
|
+
"REVIEW-MANAGED-RETRY",
|
|
1660
|
+
"--diff-fingerprint",
|
|
1661
|
+
fingerprint,
|
|
1662
|
+
"--reason-code",
|
|
1663
|
+
"managed-review-artifact-access",
|
|
1664
|
+
"--confirm-managed-runtime-retry",
|
|
1665
|
+
"--json",
|
|
1666
|
+
).stdout
|
|
1667
|
+
)
|
|
1668
|
+
self.assertEqual("retry-authorized", authorized["status"])
|
|
1669
|
+
self.assertEqual("retry-v4.3.4", authorized["retry_token"])
|
|
1670
|
+
audit_path = Path(authorized["audit_path"])
|
|
1671
|
+
self.assertEqual(0o600, audit_path.stat().st_mode & 0o777)
|
|
1672
|
+
audit = json.loads(audit_path.read_text(encoding="utf-8"))
|
|
1673
|
+
self.assertEqual("4.3.2", audit["task_skill_version"])
|
|
1674
|
+
self.assertEqual(hashlib.sha256(prior_bytes[prior_paths[2]]).hexdigest(), audit["prior_result_sha256"])
|
|
1675
|
+
|
|
1676
|
+
runner = self.artifact_reviewer_runner(
|
|
1677
|
+
root,
|
|
1678
|
+
"managed retry payload",
|
|
1679
|
+
runtime_script=managed_script,
|
|
1680
|
+
)
|
|
1681
|
+
reviewed = json.loads(
|
|
1682
|
+
self.ap_script(
|
|
1683
|
+
worktree,
|
|
1684
|
+
managed_script,
|
|
1685
|
+
"review-run",
|
|
1686
|
+
"REVIEW-MANAGED-RETRY",
|
|
1687
|
+
"--reviewer",
|
|
1688
|
+
"managed-retry-reviewer",
|
|
1689
|
+
"--runner-command-json",
|
|
1690
|
+
runner,
|
|
1691
|
+
"--json",
|
|
1692
|
+
).stdout
|
|
1693
|
+
)
|
|
1694
|
+
self.assertEqual("approved", reviewed["verdict"])
|
|
1695
|
+
for path, original in prior_bytes.items():
|
|
1696
|
+
self.assertEqual(original, path.read_bytes(), str(path))
|
|
1697
|
+
status = json.loads(
|
|
1698
|
+
self.ap_script(
|
|
1699
|
+
worktree,
|
|
1700
|
+
managed_script,
|
|
1701
|
+
"task-status",
|
|
1702
|
+
"REVIEW-MANAGED-RETRY",
|
|
1703
|
+
"--json",
|
|
1704
|
+
).stdout
|
|
1705
|
+
)["tasks"][0]
|
|
1706
|
+
retry_review = status["review"]
|
|
1707
|
+
self.assertEqual("approved", retry_review["verdict"])
|
|
1708
|
+
self.assertIn(".retry-v4.3.4.result.json", retry_review["runtime_result_path"])
|
|
1709
|
+
retry_receipt = json.loads(Path(retry_review["runtime_receipt_path"]).read_text())
|
|
1710
|
+
self.assertEqual("retry-v4.3.4", retry_receipt["runtime_retry_token"])
|
|
1711
|
+
self.assertEqual(authorized["audit_sha256"], retry_receipt["runtime_retry_audit_sha256"])
|
|
1712
|
+
|
|
1713
|
+
repeated = self.ap_script(
|
|
1714
|
+
worktree,
|
|
1715
|
+
managed_script,
|
|
1716
|
+
"review-runtime-retry",
|
|
1717
|
+
"REVIEW-MANAGED-RETRY",
|
|
1718
|
+
"--diff-fingerprint",
|
|
1719
|
+
fingerprint,
|
|
1720
|
+
"--reason-code",
|
|
1721
|
+
"managed-review-artifact-access",
|
|
1722
|
+
"--confirm-managed-runtime-retry",
|
|
1723
|
+
check=False,
|
|
1724
|
+
)
|
|
1725
|
+
self.assertNotEqual(0, repeated.returncode)
|
|
1726
|
+
|
|
1727
|
+
def test_managed_retry_rejects_a_substantive_blocked_result(self) -> None:
|
|
1728
|
+
root, repo, _ = self.make_repo()
|
|
1729
|
+
managed_script = self.managed_runtime(root)
|
|
1730
|
+
worktree = self.start_task(repo, "REVIEW-RETRY-FINDING", "shared.txt")
|
|
1731
|
+
(worktree / "shared.txt").write_text("substantive retry rejection\n", encoding="utf-8")
|
|
1732
|
+
reviewer = root / "substantive-block.py"
|
|
1733
|
+
reviewer.write_text(
|
|
1734
|
+
"import json\n"
|
|
1735
|
+
"print(json.dumps({'verdict': 'blocked', 'summary': 'real correctness defect', "
|
|
1736
|
+
"'findings': ['P1: incorrect authorization check'], "
|
|
1737
|
+
"'risks': ['Production authorization can be bypassed.']}))\n",
|
|
1738
|
+
encoding="utf-8",
|
|
1739
|
+
)
|
|
1740
|
+
self.ap(
|
|
1741
|
+
worktree,
|
|
1742
|
+
"review-run",
|
|
1743
|
+
"REVIEW-RETRY-FINDING",
|
|
1744
|
+
"--reviewer",
|
|
1745
|
+
"finding-reviewer",
|
|
1746
|
+
"--runner-command-json",
|
|
1747
|
+
json.dumps([sys.executable, str(reviewer)]),
|
|
1748
|
+
check=False,
|
|
1749
|
+
)
|
|
1750
|
+
manifest_path = self.registry_manifest_path(repo, "REVIEW-RETRY-FINDING")
|
|
1751
|
+
manifest = json.loads(manifest_path.read_text(encoding="utf-8"))
|
|
1752
|
+
manifest["skill_version"] = "4.3.2"
|
|
1753
|
+
manifest_path.write_text(json.dumps(manifest, indent=2) + "\n", encoding="utf-8")
|
|
1754
|
+
rejected = self.ap_script(
|
|
1755
|
+
worktree,
|
|
1756
|
+
managed_script,
|
|
1757
|
+
"review-runtime-retry",
|
|
1758
|
+
"REVIEW-RETRY-FINDING",
|
|
1759
|
+
"--diff-fingerprint",
|
|
1760
|
+
manifest["review"]["diff_fingerprint"],
|
|
1761
|
+
"--reason-code",
|
|
1762
|
+
"managed-review-artifact-access",
|
|
1763
|
+
"--confirm-managed-runtime-retry",
|
|
1764
|
+
check=False,
|
|
1765
|
+
)
|
|
1766
|
+
self.assertNotEqual(0, rejected.returncode)
|
|
1767
|
+
self.assertIn("not the exact non-substantive", rejected.stdout + rejected.stderr)
|
|
1768
|
+
|
|
1482
1769
|
def test_review_run_retries_runtime_unavailable_and_allows_bound_user_override(self) -> None:
|
|
1483
1770
|
root, repo, _ = self.make_repo()
|
|
1484
1771
|
worktree = self.start_task(repo, "REVIEW-TIMEOUT", "shared.txt")
|
|
@@ -1855,13 +2142,23 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1855
2142
|
"origin/dev",
|
|
1856
2143
|
"--owned-path",
|
|
1857
2144
|
".",
|
|
1858
|
-
"--writer",
|
|
1859
|
-
"fixer-label",
|
|
1860
2145
|
)
|
|
1861
2146
|
worktree = self.task_worktree(repo, "LEASE-1")
|
|
1862
2147
|
(worktree / "lease.txt").write_text("ready\n", encoding="utf-8")
|
|
1863
2148
|
self.approve_task(worktree, "LEASE-1")
|
|
1864
2149
|
|
|
2150
|
+
self.ap(
|
|
2151
|
+
repo,
|
|
2152
|
+
"task-handoff",
|
|
2153
|
+
"LEASE-1",
|
|
2154
|
+
"--from",
|
|
2155
|
+
owner,
|
|
2156
|
+
"--to",
|
|
2157
|
+
"fixer-label",
|
|
2158
|
+
"--generation",
|
|
2159
|
+
"1",
|
|
2160
|
+
)
|
|
2161
|
+
|
|
1865
2162
|
mismatch = self.ap(
|
|
1866
2163
|
worktree,
|
|
1867
2164
|
"commit-push",
|
|
@@ -1895,7 +2192,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1895
2192
|
"--to",
|
|
1896
2193
|
owner,
|
|
1897
2194
|
"--generation",
|
|
1898
|
-
"
|
|
2195
|
+
"2",
|
|
1899
2196
|
)
|
|
1900
2197
|
stale = self.ap(
|
|
1901
2198
|
repo,
|
|
@@ -1906,14 +2203,14 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
1906
2203
|
"--to",
|
|
1907
2204
|
"next-writer",
|
|
1908
2205
|
"--generation",
|
|
1909
|
-
"
|
|
2206
|
+
"2",
|
|
1910
2207
|
check=False,
|
|
1911
2208
|
)
|
|
1912
2209
|
self.assertNotEqual(0, stale.returncode)
|
|
1913
2210
|
self.assertIn("generation changed", stale.stdout + stale.stderr)
|
|
1914
2211
|
manifest = json.loads(self.registry_manifest_path(repo, "LEASE-1").read_text(encoding="utf-8"))
|
|
1915
2212
|
self.assertEqual(owner, manifest["writer_lease"]["holder"])
|
|
1916
|
-
self.assertEqual(
|
|
2213
|
+
self.assertEqual(3, manifest["writer_lease"]["generation"])
|
|
1917
2214
|
|
|
1918
2215
|
def test_dependency_sha_must_already_be_in_task_base(self) -> None:
|
|
1919
2216
|
_, repo, _ = self.make_repo()
|
|
@@ -8,6 +8,8 @@ import hashlib
|
|
|
8
8
|
import io
|
|
9
9
|
import json
|
|
10
10
|
import os
|
|
11
|
+
import re
|
|
12
|
+
import shlex
|
|
11
13
|
import signal
|
|
12
14
|
import subprocess
|
|
13
15
|
import sys
|
|
@@ -192,6 +194,18 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
192
194
|
self.assertTrue(registry_path.exists())
|
|
193
195
|
self.assertEqual(b"immutable evidence\n", evidence_path.read_bytes())
|
|
194
196
|
|
|
197
|
+
def test_review_directory_read_validation_is_mutation_free(self) -> None:
|
|
198
|
+
repo, _ = self.make_repo()
|
|
199
|
+
review_dir = ap._task_review_dir(repo, "READ-ONLY-GUARD", create=True)
|
|
200
|
+
common_dir = ap._git_common_dir(repo).resolve()
|
|
201
|
+
|
|
202
|
+
with mock.patch.object(Path, "chmod", side_effect=PermissionError("read-only sandbox")):
|
|
203
|
+
ap._guard_review_directory(review_dir, common_dir, create=False)
|
|
204
|
+
|
|
205
|
+
os.chmod(review_dir, 0o755)
|
|
206
|
+
with self.assertRaisesRegex(APError, "must use mode 0700"):
|
|
207
|
+
ap._guard_review_directory(review_dir, common_dir, create=False)
|
|
208
|
+
|
|
195
209
|
@staticmethod
|
|
196
210
|
def write_config(repo: Path, cfg: dict) -> None:
|
|
197
211
|
path = repo / "docs" / "ENGINEERING.md"
|
|
@@ -791,7 +805,14 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
791
805
|
'developer_instructions = "review only the immutable artifact"\n',
|
|
792
806
|
encoding="utf-8",
|
|
793
807
|
)
|
|
794
|
-
|
|
808
|
+
runtime_python_path = repo / "Python Runtime" / "bin" / "python3"
|
|
809
|
+
runtime_python_path.parent.mkdir(parents=True)
|
|
810
|
+
runtime_python_path.symlink_to(Path(sys.executable))
|
|
811
|
+
runtime_python = str(runtime_python_path)
|
|
812
|
+
with (
|
|
813
|
+
mock.patch.object(ap.shutil, "which", return_value="/usr/local/bin/codex"),
|
|
814
|
+
mock.patch.object(ap.sys, "executable", runtime_python),
|
|
815
|
+
):
|
|
795
816
|
focused = ap._codex_reviewer_command(
|
|
796
817
|
repo,
|
|
797
818
|
assignment_path,
|
|
@@ -814,7 +835,30 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
814
835
|
self.assertIn('model_reasoning_effort="xhigh"', deep)
|
|
815
836
|
self.assertEqual("vendor/reviewer-model", focused[focused.index("--model") + 1])
|
|
816
837
|
prompt = focused[-1]
|
|
817
|
-
|
|
838
|
+
runtime_python = os.path.abspath(runtime_python)
|
|
839
|
+
self.assertTrue(Path(runtime_python).is_symlink())
|
|
840
|
+
runtime_script = str(Path(ap.__file__).resolve())
|
|
841
|
+
artifact_match = re.search(r"Before analysis, run `([^`]+)`;", prompt)
|
|
842
|
+
self.assertIsNotNone(artifact_match)
|
|
843
|
+
self.assertEqual(
|
|
844
|
+
[runtime_python, runtime_script, "review-artifact", "--file", str(assignment_path)],
|
|
845
|
+
shlex.split(artifact_match.group(1)),
|
|
846
|
+
)
|
|
847
|
+
template_match = re.search(r"Use `([^`]+)` when useful", prompt)
|
|
848
|
+
self.assertIsNotNone(template_match)
|
|
849
|
+
self.assertEqual(
|
|
850
|
+
[
|
|
851
|
+
runtime_python,
|
|
852
|
+
runtime_script,
|
|
853
|
+
"agent-result-template",
|
|
854
|
+
"--file",
|
|
855
|
+
str(assignment_path),
|
|
856
|
+
"--verdict",
|
|
857
|
+
"approved",
|
|
858
|
+
],
|
|
859
|
+
shlex.split(template_match.group(1)),
|
|
860
|
+
)
|
|
861
|
+
self.assertNotIn("docs/tools/autopipeline/ap.py", prompt)
|
|
818
862
|
self.assertIn("diff_artifact_sha256", prompt)
|
|
819
863
|
self.assertIn("never substitute a live git diff", prompt)
|
|
820
864
|
developer_override = next(
|
|
@@ -2871,6 +2915,68 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
2871
2915
|
self.assertTrue(plan["review_required"])
|
|
2872
2916
|
self.assertIn("release_or_tooling", plan["categories"])
|
|
2873
2917
|
|
|
2918
|
+
def test_root_agents_protocol_is_high_risk_release_tooling(self) -> None:
|
|
2919
|
+
repo, cfg = self.make_repo()
|
|
2920
|
+
plan = self.plan(
|
|
2921
|
+
repo,
|
|
2922
|
+
cfg,
|
|
2923
|
+
planned_paths=["AGENTS.md"],
|
|
2924
|
+
requested_task_kind="change",
|
|
2925
|
+
)
|
|
2926
|
+
self.assertEqual("high-risk", plan["profile"])
|
|
2927
|
+
self.assertTrue(plan["review_required"])
|
|
2928
|
+
self.assertIn("release_or_tooling", plan["categories"])
|
|
2929
|
+
|
|
2930
|
+
def test_generic_migration_language_and_managed_policy_are_not_database_risk(self) -> None:
|
|
2931
|
+
repo, cfg = self.make_repo()
|
|
2932
|
+
plan = self.plan(
|
|
2933
|
+
repo,
|
|
2934
|
+
cfg,
|
|
2935
|
+
planned_paths=["docs/project/overlay-migration.md"],
|
|
2936
|
+
intent="Document project overlay migration behavior",
|
|
2937
|
+
requested_task_kind="change",
|
|
2938
|
+
)
|
|
2939
|
+
self.assertNotIn("db", plan["categories"])
|
|
2940
|
+
self.assertNotIn("db", plan["intent_categories"])
|
|
2941
|
+
self.assertNotIn("db", plan["high_confidence_intent_categories"])
|
|
2942
|
+
self.assertNotIn(
|
|
2943
|
+
"db",
|
|
2944
|
+
ap._classify_paths(
|
|
2945
|
+
[".agents/skills/auto-coding-skill/data/policies/workflow-migrations-v1.json"]
|
|
2946
|
+
)["categories"],
|
|
2947
|
+
)
|
|
2948
|
+
self.assertNotIn(
|
|
2949
|
+
"db",
|
|
2950
|
+
ap._classify_paths(
|
|
2951
|
+
["src/auto-coding-skill/data/policies/workflow-migrations-v1.json"]
|
|
2952
|
+
)["categories"],
|
|
2953
|
+
)
|
|
2954
|
+
self.assertIn("db", ap._classify_paths(["migrations/001.sql"])["categories"])
|
|
2955
|
+
|
|
2956
|
+
def test_database_named_source_files_remain_high_risk(self) -> None:
|
|
2957
|
+
repo, cfg = self.make_repo()
|
|
2958
|
+
for path in [
|
|
2959
|
+
"src/db.py",
|
|
2960
|
+
"src/database.py",
|
|
2961
|
+
"src/schema.py",
|
|
2962
|
+
"src/migrations.py",
|
|
2963
|
+
"internal/db.go",
|
|
2964
|
+
"backend/db_migrations/001.py",
|
|
2965
|
+
"backend/database-migrations/001.py",
|
|
2966
|
+
"backend/schema_migrations/001.py",
|
|
2967
|
+
"backend/db-migrations/001.py",
|
|
2968
|
+
]:
|
|
2969
|
+
with self.subTest(path=path):
|
|
2970
|
+
self.assertIn("db", ap._classify_paths([path])["categories"])
|
|
2971
|
+
plan = self.plan(
|
|
2972
|
+
repo,
|
|
2973
|
+
cfg,
|
|
2974
|
+
planned_paths=[path],
|
|
2975
|
+
requested_task_kind="change",
|
|
2976
|
+
)
|
|
2977
|
+
self.assertEqual("high-risk", plan["profile"])
|
|
2978
|
+
self.assertTrue(plan["review_required"])
|
|
2979
|
+
|
|
2874
2980
|
def test_explicit_full_structure_scope_inspects_clean_tracked_files(self) -> None:
|
|
2875
2981
|
cfg = base_config()
|
|
2876
2982
|
cfg["structure"] = {
|
|
@@ -87,7 +87,7 @@ class ProjectConfigResolverTests(unittest.TestCase):
|
|
|
87
87
|
(self.repo / "docs" / "project").mkdir(parents=True)
|
|
88
88
|
self.write_managed(
|
|
89
89
|
"""workflow:
|
|
90
|
-
skill_version: "4.3.
|
|
90
|
+
skill_version: "4.3.4"
|
|
91
91
|
mode: dev
|
|
92
92
|
profile: auto
|
|
93
93
|
completion: push
|
|
@@ -130,7 +130,7 @@ access:
|
|
|
130
130
|
effective = core.load_effective_config(self.repo)
|
|
131
131
|
|
|
132
132
|
self.assertEqual("sample", effective["project"]["name"])
|
|
133
|
-
self.assertEqual("4.3.
|
|
133
|
+
self.assertEqual("4.3.4", effective["workflow"]["skill_version"])
|
|
134
134
|
self.assertEqual(self.repo / "docs" / "ENGINEERING.md", core.find_config(self.repo))
|
|
135
135
|
self.assertEqual({}, core.load_project_overrides(self.repo))
|
|
136
136
|
|
|
@@ -153,7 +153,7 @@ access:
|
|
|
153
153
|
|
|
154
154
|
effective = core.load_effective_config(self.repo)
|
|
155
155
|
|
|
156
|
-
self.assertEqual("4.3.
|
|
156
|
+
self.assertEqual("4.3.4", effective["workflow"]["skill_version"])
|
|
157
157
|
self.assertEqual("dev", effective["workflow"]["mode"])
|
|
158
158
|
self.assertEqual("project-profile", effective["workflow"]["profile"])
|
|
159
159
|
self.assertEqual("push", effective["workflow"]["completion"])
|
|
@@ -292,11 +292,11 @@ access:
|
|
|
292
292
|
|
|
293
293
|
def test_large_managed_body_is_not_part_of_frontmatter_bound(self) -> None:
|
|
294
294
|
self.write_managed(
|
|
295
|
-
'workflow:\n skill_version: "4.3.
|
|
295
|
+
'workflow:\n skill_version: "4.3.4"\n',
|
|
296
296
|
body="x" * (core.MANAGED_CONFIG_FRONTMATTER_MAX_BYTES + 1),
|
|
297
297
|
)
|
|
298
298
|
|
|
299
|
-
self.assertEqual("4.3.
|
|
299
|
+
self.assertEqual("4.3.4", core.load_effective_config(self.repo)["workflow"]["skill_version"])
|
|
300
300
|
|
|
301
301
|
def test_yaml_failure_does_not_echo_content_or_absolute_path(self) -> None:
|
|
302
302
|
secret = "NEVER_ECHO_THIS_SECRET"
|