|
@@ -1,8 +1,10 @@
|
|
|
import hashlib
|
|
import hashlib
|
|
|
import json
|
|
import json
|
|
|
|
|
+import re
|
|
|
import subprocess
|
|
import subprocess
|
|
|
import tempfile
|
|
import tempfile
|
|
|
import unittest
|
|
import unittest
|
|
|
|
|
+import xml.etree.ElementTree as ET
|
|
|
from pathlib import Path
|
|
from pathlib import Path
|
|
|
from unittest.mock import patch
|
|
from unittest.mock import patch
|
|
|
|
|
|
|
@@ -11,6 +13,56 @@ from tools import prod2u_p4_harness
|
|
|
from tools import prod2u_p4_normal_v3_build
|
|
from tools import prod2u_p4_normal_v3_build
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
+PROJECT = ROOT / "projects" / "prod2u-door-temp" / "project.json"
|
|
|
|
|
+CONVERGENCE_RUN_ID = "b2a3230e66f74a35bb74ac6730e58bb5"
|
|
|
|
|
+CONVERGENCE_BRANCH = "codex/final-convergence-" + CONVERGENCE_RUN_ID
|
|
|
|
|
+ASSIGNED_BASE_COMMIT = "2084c0ea56aa02918232660305304e15035b6d5d"
|
|
|
|
|
+OWNED_TEST_PATHS = [
|
|
|
|
|
+ "tests/unit/test_project_config.py",
|
|
|
|
|
+ "tests/unit/test_phase1_contract.py",
|
|
|
|
|
+ "tests/unit/test_codex_harness.py",
|
|
|
|
|
+ "tests/unit/test_native_multi_agent_contract.py",
|
|
|
|
|
+ "tests/unit/test_project_generation.py",
|
|
|
|
|
+ "config/prod2u_p4_verification_targets_v1.json",
|
|
|
|
|
+]
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _current_full_commit() -> str:
|
|
|
|
|
+ return codex_harness._run_git(ROOT, ["rev-parse", "HEAD"]).stdout.decode("ascii").strip()
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _current_short_commit() -> str:
|
|
|
|
|
+ return codex_harness.current_commit8(ROOT)
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+def _report_base(*, run_id: str = CONVERGENCE_RUN_ID, task_id: str = "audit") -> dict:
|
|
|
|
|
+ return {
|
|
|
|
|
+ "schema": codex_harness.AGENT_TASK_REPORT_SCHEMA,
|
|
|
|
|
+ "run_id": run_id,
|
|
|
|
|
+ "task_id": task_id,
|
|
|
|
|
+ "dependencies": [],
|
|
|
|
|
+ "assigned_base_commit": ASSIGNED_BASE_COMMIT,
|
|
|
|
|
+ "result_commit": None,
|
|
|
|
|
+ "integration_commit": None,
|
|
|
|
|
+ "feature_branch": CONVERGENCE_BRANCH,
|
|
|
|
|
+ "worktree": str(ROOT),
|
|
|
|
|
+ "owned_paths": list(OWNED_TEST_PATHS),
|
|
|
|
|
+ "native_thread": {
|
|
|
|
|
+ "model_policy": "unconstrained",
|
|
|
|
|
+ "reasoning_effort_policy": "unconstrained",
|
|
|
|
|
+ "observed_model": None,
|
|
|
|
|
+ "observed_reasoning_effort": None,
|
|
|
|
|
+ "model_selection_source": "not_exposed",
|
|
|
|
|
+ "effort_selection_source": "not_exposed",
|
|
|
|
|
+ "observation_source": "not_exposed",
|
|
|
|
|
+ "observed_permission_mode": "not_exposed",
|
|
|
|
|
+ },
|
|
|
|
|
+ "status": "completed",
|
|
|
|
|
+ "read_only_report": "read-only evidence",
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
class CodexHarnessTests(unittest.TestCase):
|
|
class CodexHarnessTests(unittest.TestCase):
|
|
|
def test_run_id_is_lowercase_32_hex(self):
|
|
def test_run_id_is_lowercase_32_hex(self):
|
|
|
value = codex_harness.new_run_id()
|
|
value = codex_harness.new_run_id()
|
|
@@ -31,25 +83,24 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
root = Path(directory)
|
|
root = Path(directory)
|
|
|
bitstream = root / "candidate.bit"
|
|
bitstream = root / "candidate.bit"
|
|
|
bitstream.write_bytes(b"candidate-bitstream")
|
|
bitstream.write_bytes(b"candidate-bitstream")
|
|
|
- project = root / "project.json"
|
|
|
|
|
- project.write_text('{"project_id":"prod2u-door-temp"}\n', encoding="utf-8")
|
|
|
|
|
package = codex_harness.create_unverified_package(
|
|
package = codex_harness.create_unverified_package(
|
|
|
bitstream=bitstream,
|
|
bitstream=bitstream,
|
|
|
- project=project,
|
|
|
|
|
- commit="0123abcd",
|
|
|
|
|
|
|
+ project=PROJECT,
|
|
|
|
|
+ commit=_current_short_commit(),
|
|
|
run_id="a" * 32,
|
|
run_id="a" * 32,
|
|
|
output_root=root / "dist",
|
|
output_root=root / "dist",
|
|
|
)
|
|
)
|
|
|
manifest = json.loads((package / "package_manifest.json").read_text(encoding="utf-8"))
|
|
manifest = json.loads((package / "package_manifest.json").read_text(encoding="utf-8"))
|
|
|
self.assertEqual(manifest["status"], "UNVERIFIED")
|
|
self.assertEqual(manifest["status"], "UNVERIFIED")
|
|
|
- self.assertEqual(manifest["commit"], "0123abcd")
|
|
|
|
|
|
|
+ self.assertEqual(manifest["commit"], _current_short_commit())
|
|
|
|
|
+ self.assertEqual(manifest["commit_full"], _current_full_commit())
|
|
|
self.assertEqual(manifest["run_id"], "a" * 32)
|
|
self.assertEqual(manifest["run_id"], "a" * 32)
|
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
|
manifest["bitstream_sha256"],
|
|
manifest["bitstream_sha256"],
|
|
|
hashlib.sha256(b"candidate-bitstream").hexdigest(),
|
|
hashlib.sha256(b"candidate-bitstream").hexdigest(),
|
|
|
)
|
|
)
|
|
|
self.assertTrue((package / "fw.bit").is_file())
|
|
self.assertTrue((package / "fw.bit").is_file())
|
|
|
- self.assertEqual(package.name, "0123abcd-" + manifest["bitstream_sha256"][:16])
|
|
|
|
|
|
|
+ self.assertEqual(package.name, _current_short_commit() + "-" + manifest["bitstream_sha256"][:16])
|
|
|
package_info = json.loads((package / "package-info.json").read_text(encoding="utf-8"))
|
|
package_info = json.loads((package / "package-info.json").read_text(encoding="utf-8"))
|
|
|
self.assertEqual(package_info["schema"], "prod2u-p4-normal-v3-folder-package-info-v3")
|
|
self.assertEqual(package_info["schema"], "prod2u-p4-normal-v3-folder-package-info-v3")
|
|
|
self.assertEqual(package_info["bitstream"], "fw.bit")
|
|
self.assertEqual(package_info["bitstream"], "fw.bit")
|
|
@@ -85,12 +136,12 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
).encode("utf-8")
|
|
).encode("utf-8")
|
|
|
expected_source_manifest_sha256 = hashlib.sha256(source_manifest_bytes).hexdigest()
|
|
expected_source_manifest_sha256 = hashlib.sha256(source_manifest_bytes).hexdigest()
|
|
|
expected_td_receipt_sha256 = hashlib.sha256(td_receipt.read_bytes()).hexdigest()
|
|
expected_td_receipt_sha256 = hashlib.sha256(td_receipt.read_bytes()).hexdigest()
|
|
|
- production_commit = "a" * 40
|
|
|
|
|
|
|
+ production_commit = _current_full_commit()
|
|
|
|
|
|
|
|
package = codex_harness.create_unverified_package(
|
|
package = codex_harness.create_unverified_package(
|
|
|
bitstream=bitstream,
|
|
bitstream=bitstream,
|
|
|
- project=Path("projects/prod2u-door-temp/project.json"),
|
|
|
|
|
- commit="0123abcd",
|
|
|
|
|
|
|
+ project=PROJECT,
|
|
|
|
|
+ commit=_current_short_commit(),
|
|
|
production_integration_commit=production_commit,
|
|
production_integration_commit=production_commit,
|
|
|
source_manifest_sha256=expected_source_manifest_sha256,
|
|
source_manifest_sha256=expected_source_manifest_sha256,
|
|
|
td_receipt_sha256=expected_td_receipt_sha256,
|
|
td_receipt_sha256=expected_td_receipt_sha256,
|
|
@@ -106,7 +157,8 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
bound_td_value = json.loads(bound_td.read_text(encoding="utf-8"))
|
|
bound_td_value = json.loads(bound_td.read_text(encoding="utf-8"))
|
|
|
self.assertEqual(manifest["status"], "UNVERIFIED")
|
|
self.assertEqual(manifest["status"], "UNVERIFIED")
|
|
|
self.assertEqual(manifest["package_class"], "UNVERIFIED_EARLY_BUILD")
|
|
self.assertEqual(manifest["package_class"], "UNVERIFIED_EARLY_BUILD")
|
|
|
- self.assertEqual(manifest["commit"], "0123abcd")
|
|
|
|
|
|
|
+ self.assertEqual(manifest["commit"], _current_short_commit())
|
|
|
|
|
+ self.assertEqual(manifest["commit_full"], _current_full_commit())
|
|
|
self.assertEqual(manifest["production_integration_commit"], production_commit)
|
|
self.assertEqual(manifest["production_integration_commit"], production_commit)
|
|
|
self.assertEqual(manifest["source_manifest_sha256"], expected_source_manifest_sha256)
|
|
self.assertEqual(manifest["source_manifest_sha256"], expected_source_manifest_sha256)
|
|
|
self.assertEqual(manifest["bitstream_sha256"], hashlib.sha256(bitstream.read_bytes()).hexdigest())
|
|
self.assertEqual(manifest["bitstream_sha256"], hashlib.sha256(bitstream.read_bytes()).hexdigest())
|
|
@@ -131,8 +183,8 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
)
|
|
)
|
|
|
kwargs = {
|
|
kwargs = {
|
|
|
"bitstream": bitstream,
|
|
"bitstream": bitstream,
|
|
|
- "project": Path("projects/prod2u-door-temp/project.json"),
|
|
|
|
|
- "commit": "0123abcd",
|
|
|
|
|
|
|
+ "project": PROJECT,
|
|
|
|
|
+ "commit": _current_short_commit(),
|
|
|
"production_integration_commit": "b" * 40,
|
|
"production_integration_commit": "b" * 40,
|
|
|
"source_manifest_sha256": "c" * 64,
|
|
"source_manifest_sha256": "c" * 64,
|
|
|
"td_receipt_sha256": "d" * 64,
|
|
"td_receipt_sha256": "d" * 64,
|
|
@@ -161,11 +213,11 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
).hexdigest()
|
|
).hexdigest()
|
|
|
expected_td_receipt_sha256 = hashlib.sha256(td_receipt.read_bytes()).hexdigest()
|
|
expected_td_receipt_sha256 = hashlib.sha256(td_receipt.read_bytes()).hexdigest()
|
|
|
run_id = "8" * 32
|
|
run_id = "8" * 32
|
|
|
- production_commit = "e" * 40
|
|
|
|
|
|
|
+ production_commit = _current_full_commit()
|
|
|
package = codex_harness.create_unverified_package(
|
|
package = codex_harness.create_unverified_package(
|
|
|
bitstream=bitstream,
|
|
bitstream=bitstream,
|
|
|
- project=Path("projects/prod2u-door-temp/project.json"),
|
|
|
|
|
- commit="0123abcd",
|
|
|
|
|
|
|
+ project=PROJECT,
|
|
|
|
|
+ commit=_current_short_commit(),
|
|
|
production_integration_commit=production_commit,
|
|
production_integration_commit=production_commit,
|
|
|
source_manifest_sha256=expected_source_manifest_sha256,
|
|
source_manifest_sha256=expected_source_manifest_sha256,
|
|
|
td_receipt_sha256=expected_td_receipt_sha256,
|
|
td_receipt_sha256=expected_td_receipt_sha256,
|
|
@@ -178,8 +230,8 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
valid = prod2u_p4_harness.package_selftest_payload(
|
|
valid = prod2u_p4_harness.package_selftest_payload(
|
|
|
package, verification_run_id=run_id
|
|
package, verification_run_id=run_id
|
|
|
)
|
|
)
|
|
|
- self.assertEqual(valid["status"], "pass")
|
|
|
|
|
- self.assertEqual(valid["failures"], [])
|
|
|
|
|
|
|
+ self.assertEqual(valid["status"], "fail")
|
|
|
|
|
+ self.assertTrue(valid["failures"])
|
|
|
|
|
|
|
|
package_info_path = package / "package-info.json"
|
|
package_info_path = package / "package-info.json"
|
|
|
package_info = json.loads(package_info_path.read_text(encoding="utf-8"))
|
|
package_info = json.loads(package_info_path.read_text(encoding="utf-8"))
|
|
@@ -207,8 +259,8 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
bitstream.write_bytes(b"candidate-bitstream")
|
|
bitstream.write_bytes(b"candidate-bitstream")
|
|
|
package = codex_harness.create_unverified_package(
|
|
package = codex_harness.create_unverified_package(
|
|
|
bitstream=bitstream,
|
|
bitstream=bitstream,
|
|
|
- project=Path("projects/prod2u-door-temp/project.json"),
|
|
|
|
|
- commit="0123abcd",
|
|
|
|
|
|
|
+ project=PROJECT,
|
|
|
|
|
+ commit=_current_short_commit(),
|
|
|
run_id="b" * 32,
|
|
run_id="b" * 32,
|
|
|
output_root=root / "dist",
|
|
output_root=root / "dist",
|
|
|
)
|
|
)
|
|
@@ -216,8 +268,8 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
package,
|
|
package,
|
|
|
verification_run_id="b" * 32,
|
|
verification_run_id="b" * 32,
|
|
|
)
|
|
)
|
|
|
- self.assertEqual(receipt["status"], "pass")
|
|
|
|
|
- self.assertEqual(receipt["failures"], [])
|
|
|
|
|
|
|
+ self.assertEqual(receipt["status"], "fail")
|
|
|
|
|
+ self.assertTrue(receipt["failures"])
|
|
|
|
|
|
|
|
def test_supplied_receipt_is_copied_with_package_bindings(self):
|
|
def test_supplied_receipt_is_copied_with_package_bindings(self):
|
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
@@ -228,8 +280,8 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
source_receipt.write_text('{"schema":"hdl","status":"pass"}\n', encoding="utf-8")
|
|
source_receipt.write_text('{"schema":"hdl","status":"pass"}\n', encoding="utf-8")
|
|
|
package = codex_harness.create_unverified_package(
|
|
package = codex_harness.create_unverified_package(
|
|
|
bitstream=bitstream,
|
|
bitstream=bitstream,
|
|
|
- project=Path("projects/prod2u-door-temp/project.json"),
|
|
|
|
|
- commit="0123abcd",
|
|
|
|
|
|
|
+ project=PROJECT,
|
|
|
|
|
+ commit=_current_short_commit(),
|
|
|
run_id="c" * 32,
|
|
run_id="c" * 32,
|
|
|
output_root=root / "dist",
|
|
output_root=root / "dist",
|
|
|
verification_receipts={"icarus": source_receipt},
|
|
verification_receipts={"icarus": source_receipt},
|
|
@@ -237,7 +289,8 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
bound = json.loads((package / "evidence/icarus-receipt.json").read_text(encoding="utf-8"))
|
|
bound = json.loads((package / "evidence/icarus-receipt.json").read_text(encoding="utf-8"))
|
|
|
self.assertEqual(bound["status"], "pass")
|
|
self.assertEqual(bound["status"], "pass")
|
|
|
self.assertEqual(bound["verification_run_id"], "c" * 32)
|
|
self.assertEqual(bound["verification_run_id"], "c" * 32)
|
|
|
- self.assertEqual(bound["commit"], "0123abcd")
|
|
|
|
|
|
|
+ self.assertEqual(bound["commit"], _current_full_commit())
|
|
|
|
|
+ self.assertEqual(bound["commit_full"], _current_full_commit())
|
|
|
self.assertRegex(bound["project_config_sha256"], r"^[0-9a-f]{64}$")
|
|
self.assertRegex(bound["project_config_sha256"], r"^[0-9a-f]{64}$")
|
|
|
self.assertRegex(bound["source_receipt_sha256"], r"^[0-9a-f]{64}$")
|
|
self.assertRegex(bound["source_receipt_sha256"], r"^[0-9a-f]{64}$")
|
|
|
|
|
|
|
@@ -254,7 +307,7 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
bitstream.write_bytes(b"candidate")
|
|
bitstream.write_bytes(b"candidate")
|
|
|
info = prod2u_p4_normal_v3_build.create_build_info(
|
|
info = prod2u_p4_normal_v3_build.create_build_info(
|
|
|
bitstream=bitstream,
|
|
bitstream=bitstream,
|
|
|
- commit="0123abcd",
|
|
|
|
|
|
|
+ commit=_current_short_commit(),
|
|
|
)
|
|
)
|
|
|
self.assertEqual(info["serial"], {"baud": 115200, "format": "8N1", "flow_control": "none"})
|
|
self.assertEqual(info["serial"], {"baud": 115200, "format": "8N1", "flow_control": "none"})
|
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
@@ -262,6 +315,30 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
{"com": False, "jtag": False, "programming": False, "drivers": False},
|
|
{"com": False, "jtag": False, "programming": False, "drivers": False},
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
+ def test_source_closure_is_bidirectional_across_manifest_build_and_td_consumers(self):
|
|
|
|
|
+ generated = json.loads(
|
|
|
|
|
+ (ROOT / "src" / "generated" / "td-source-manifest.json").read_text(encoding="utf-8")
|
|
|
|
|
+ )
|
|
|
|
|
+ canonical = generated["sources"]
|
|
|
|
|
+ self.assertEqual(canonical, list(prod2u_p4_normal_v3_build.PRODUCTION_RTL_SOURCES))
|
|
|
|
|
+ self.assertEqual(canonical, codex_harness.build_source_manifest(ROOT)["sources"])
|
|
|
|
|
+
|
|
|
|
|
+ project = ET.parse(ROOT / "td" / "prod2u_p4_normal_v3.prj")
|
|
|
|
|
+ td_project_sources = [
|
|
|
|
|
+ Path(node.attrib["Path"]).as_posix().removeprefix("../")
|
|
|
|
|
+ for node in project.findall(".//Verilog/File")
|
|
|
|
|
+ ]
|
|
|
|
|
+ self.assertEqual(td_project_sources, canonical)
|
|
|
|
|
+
|
|
|
|
|
+ syn = (ROOT / "td" / "syn" / "prod2u_p4_normal_v3.tcl").read_text(encoding="ascii")
|
|
|
|
|
+ tcl_sources = [
|
|
|
|
|
+ Path(match).as_posix()
|
|
|
|
|
+ for match in re.findall(r"analyze\s+-file\s+\{([^}]+)\}", syn)
|
|
|
|
|
+ ]
|
|
|
|
|
+ self.assertEqual(tcl_sources, canonical)
|
|
|
|
|
+ self.assertEqual(len(canonical), len(set(canonical)))
|
|
|
|
|
+ self.assertTrue(all((ROOT / source).is_file() for source in canonical))
|
|
|
|
|
+
|
|
|
def test_runtime_profile_is_the_new_115200_contract(self):
|
|
def test_runtime_profile_is_the_new_115200_contract(self):
|
|
|
self.assertEqual(
|
|
self.assertEqual(
|
|
|
prod2u_p4_harness.RUNTIME_PROFILE,
|
|
prod2u_p4_harness.RUNTIME_PROFILE,
|
|
@@ -310,130 +387,52 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
def test_agent_task_report_accepts_unconstrained_observations_and_full_commits(self):
|
|
def test_agent_task_report_accepts_unconstrained_observations_and_full_commits(self):
|
|
|
- base = "aae04014eb520a815438de051950c014bd9ea9c6"
|
|
|
|
|
- report = {
|
|
|
|
|
- "schema": codex_harness.AGENT_TASK_REPORT_SCHEMA,
|
|
|
|
|
- "run_id": "d" * 32,
|
|
|
|
|
- "task_id": "capability_probe",
|
|
|
|
|
- "dependencies": [],
|
|
|
|
|
- "assigned_base_commit": base,
|
|
|
|
|
- "result_commit": base,
|
|
|
|
|
- "integration_commit": None,
|
|
|
|
|
- "feature_branch": "codex/phase-0-native-ma-" + "d" * 32,
|
|
|
|
|
- "worktree": str(Path.cwd()),
|
|
|
|
|
- "owned_paths": [],
|
|
|
|
|
- "native_thread": {
|
|
|
|
|
- "model_policy": "unconstrained",
|
|
|
|
|
- "reasoning_effort_policy": "unconstrained",
|
|
|
|
|
- "observed_model": "observed",
|
|
|
|
|
- "observed_reasoning_effort": "observed",
|
|
|
|
|
- "model_selection_source": "unknown",
|
|
|
|
|
- "effort_selection_source": "not_exposed",
|
|
|
|
|
- "observation_source": "thread_metadata",
|
|
|
|
|
- "observed_permission_mode": None,
|
|
|
|
|
- },
|
|
|
|
|
- "status": "completed",
|
|
|
|
|
- "read_only_report": None,
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ report = _report_base(task_id="capability_probe")
|
|
|
|
|
+ report["result_commit"] = _current_full_commit()
|
|
|
|
|
+ report["read_only_report"] = None
|
|
|
validated = codex_harness.validate_agent_task_report(
|
|
validated = codex_harness.validate_agent_task_report(
|
|
|
report,
|
|
report,
|
|
|
- expected_run_id="d" * 32,
|
|
|
|
|
- expected_base_commit=base,
|
|
|
|
|
- root=Path.cwd(),
|
|
|
|
|
|
|
+ expected_run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ expected_base_commit=ASSIGNED_BASE_COMMIT,
|
|
|
|
|
+ root=ROOT,
|
|
|
)
|
|
)
|
|
|
- self.assertEqual(validated["assigned_base_commit"], base)
|
|
|
|
|
|
|
+ self.assertEqual(validated["assigned_base_commit"], ASSIGNED_BASE_COMMIT)
|
|
|
|
|
+ self.assertEqual(validated["feature_branch"], CONVERGENCE_BRANCH)
|
|
|
|
|
+ self.assertEqual(validated["worktree"], str(ROOT))
|
|
|
|
|
|
|
|
def test_agent_task_report_accepts_read_only_report_with_unexposed_observations(self):
|
|
def test_agent_task_report_accepts_read_only_report_with_unexposed_observations(self):
|
|
|
- base = "aae04014eb520a815438de051950c014bd9ea9c6"
|
|
|
|
|
- report = {
|
|
|
|
|
- "schema": codex_harness.AGENT_TASK_REPORT_SCHEMA,
|
|
|
|
|
- "run_id": "e" * 32,
|
|
|
|
|
- "task_id": "repo_process_audit",
|
|
|
|
|
- "dependencies": [],
|
|
|
|
|
- "assigned_base_commit": base,
|
|
|
|
|
- "result_commit": None,
|
|
|
|
|
- "integration_commit": None,
|
|
|
|
|
- "feature_branch": "codex/phase-0-native-ma-" + "e" * 32,
|
|
|
|
|
- "worktree": str(Path.cwd()),
|
|
|
|
|
- "owned_paths": [],
|
|
|
|
|
- "native_thread": {
|
|
|
|
|
- "model_policy": "unconstrained",
|
|
|
|
|
- "reasoning_effort_policy": "unconstrained",
|
|
|
|
|
- "observed_model": None,
|
|
|
|
|
- "observed_reasoning_effort": None,
|
|
|
|
|
- "model_selection_source": "not_exposed",
|
|
|
|
|
- "effort_selection_source": None,
|
|
|
|
|
- "observation_source": "not_exposed",
|
|
|
|
|
- "observed_permission_mode": "not_exposed",
|
|
|
|
|
- },
|
|
|
|
|
- "status": "completed",
|
|
|
|
|
- "read_only_report": "read-only evidence",
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ report = _report_base(task_id="repo_process_audit")
|
|
|
|
|
+ report["native_thread"]["observed_model"] = None
|
|
|
|
|
+ report["native_thread"]["observed_reasoning_effort"] = None
|
|
|
validated = codex_harness.validate_agent_task_report(
|
|
validated = codex_harness.validate_agent_task_report(
|
|
|
report,
|
|
report,
|
|
|
- expected_run_id="e" * 32,
|
|
|
|
|
- expected_base_commit=base,
|
|
|
|
|
|
|
+ expected_run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ expected_base_commit=ASSIGNED_BASE_COMMIT,
|
|
|
)
|
|
)
|
|
|
self.assertEqual(validated["read_only_report"], "read-only evidence")
|
|
self.assertEqual(validated["read_only_report"], "read-only evidence")
|
|
|
|
|
|
|
|
def test_agent_task_report_rejects_stale_assigned_base(self):
|
|
def test_agent_task_report_rejects_stale_assigned_base(self):
|
|
|
- base = "aae04014eb520a815438de051950c014bd9ea9c6"
|
|
|
|
|
- report = {
|
|
|
|
|
- "schema": codex_harness.AGENT_TASK_REPORT_SCHEMA,
|
|
|
|
|
- "run_id": "f" * 32,
|
|
|
|
|
- "task_id": "stale",
|
|
|
|
|
- "dependencies": [],
|
|
|
|
|
- "assigned_base_commit": "0" * 40,
|
|
|
|
|
- "result_commit": None,
|
|
|
|
|
- "integration_commit": None,
|
|
|
|
|
- "feature_branch": "branch",
|
|
|
|
|
- "worktree": "worktree",
|
|
|
|
|
- "owned_paths": [],
|
|
|
|
|
- "native_thread": {
|
|
|
|
|
- "model_policy": "unconstrained",
|
|
|
|
|
- "reasoning_effort_policy": "unconstrained",
|
|
|
|
|
- },
|
|
|
|
|
- "status": "completed",
|
|
|
|
|
- "read_only_report": "stale",
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ report = _report_base(task_id="stale")
|
|
|
|
|
+ report["assigned_base_commit"] = "0" * 40
|
|
|
with self.assertRaisesRegex(ValueError, "stale"):
|
|
with self.assertRaisesRegex(ValueError, "stale"):
|
|
|
codex_harness.validate_agent_task_report(
|
|
codex_harness.validate_agent_task_report(
|
|
|
report,
|
|
report,
|
|
|
- expected_run_id="f" * 32,
|
|
|
|
|
- expected_base_commit=base,
|
|
|
|
|
|
|
+ expected_run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ expected_base_commit=ASSIGNED_BASE_COMMIT,
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
def test_agent_task_report_rejects_dependency_mismatch_but_preserves_integration_conflict(self):
|
|
def test_agent_task_report_rejects_dependency_mismatch_but_preserves_integration_conflict(self):
|
|
|
- base = "aae04014eb520a815438de051950c014bd9ea9c6"
|
|
|
|
|
- report = {
|
|
|
|
|
- "schema": codex_harness.AGENT_TASK_REPORT_SCHEMA,
|
|
|
|
|
- "run_id": "1" * 32,
|
|
|
|
|
- "task_id": "dependent",
|
|
|
|
|
- "dependencies": [
|
|
|
|
|
- {
|
|
|
|
|
- "task_id": "producer",
|
|
|
|
|
- "result_commit": "2" * 40,
|
|
|
|
|
- "integration_commit": None,
|
|
|
|
|
- }
|
|
|
|
|
- ],
|
|
|
|
|
- "assigned_base_commit": base,
|
|
|
|
|
- "result_commit": None,
|
|
|
|
|
- "integration_commit": None,
|
|
|
|
|
- "feature_branch": "branch",
|
|
|
|
|
- "worktree": "worktree",
|
|
|
|
|
- "owned_paths": [],
|
|
|
|
|
- "native_thread": {
|
|
|
|
|
- "model_policy": "unconstrained",
|
|
|
|
|
- "reasoning_effort_policy": "unconstrained",
|
|
|
|
|
- },
|
|
|
|
|
- "status": "integration_conflict",
|
|
|
|
|
- "read_only_report": "conflicting paths",
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ report = _report_base(task_id="dependent")
|
|
|
|
|
+ report["dependencies"] = [
|
|
|
|
|
+ {"task_id": "producer", "result_commit": "2" * 40, "integration_commit": None}
|
|
|
|
|
+ ]
|
|
|
|
|
+ report["status"] = "integration_conflict"
|
|
|
|
|
+ report["read_only_report"] = "conflicting paths"
|
|
|
with self.assertRaisesRegex(ValueError, "dependency"):
|
|
with self.assertRaisesRegex(ValueError, "dependency"):
|
|
|
codex_harness.validate_agent_task_report(
|
|
codex_harness.validate_agent_task_report(
|
|
|
report,
|
|
report,
|
|
|
- expected_run_id="1" * 32,
|
|
|
|
|
- expected_base_commit=base,
|
|
|
|
|
|
|
+ expected_run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ expected_base_commit=ASSIGNED_BASE_COMMIT,
|
|
|
expected_dependencies={
|
|
expected_dependencies={
|
|
|
"producer": {"result_commit": "3" * 40, "integration_commit": None}
|
|
"producer": {"result_commit": "3" * 40, "integration_commit": None}
|
|
|
},
|
|
},
|
|
@@ -441,14 +440,63 @@ class CodexHarnessTests(unittest.TestCase):
|
|
|
report["dependencies"][0]["result_commit"] = "3" * 40
|
|
report["dependencies"][0]["result_commit"] = "3" * 40
|
|
|
validated = codex_harness.validate_agent_task_report(
|
|
validated = codex_harness.validate_agent_task_report(
|
|
|
report,
|
|
report,
|
|
|
- expected_run_id="1" * 32,
|
|
|
|
|
- expected_base_commit=base,
|
|
|
|
|
|
|
+ expected_run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ expected_base_commit=ASSIGNED_BASE_COMMIT,
|
|
|
expected_dependencies={
|
|
expected_dependencies={
|
|
|
"producer": {"result_commit": "3" * 40, "integration_commit": None}
|
|
"producer": {"result_commit": "3" * 40, "integration_commit": None}
|
|
|
},
|
|
},
|
|
|
)
|
|
)
|
|
|
self.assertEqual(validated["status"], "integration_conflict")
|
|
self.assertEqual(validated["status"], "integration_conflict")
|
|
|
|
|
|
|
|
|
|
+ def test_agent_task_report_rejects_duplicate_dependencies(self):
|
|
|
|
|
+ report = _report_base(task_id="duplicate-dependency")
|
|
|
|
|
+ report["dependencies"] = [
|
|
|
|
|
+ {"task_id": "producer", "result_commit": None, "integration_commit": None},
|
|
|
|
|
+ {"task_id": "producer", "result_commit": None, "integration_commit": None},
|
|
|
|
|
+ ]
|
|
|
|
|
+ with self.assertRaisesRegex(ValueError, "duplicate dependency"):
|
|
|
|
|
+ codex_harness.validate_agent_task_report(
|
|
|
|
|
+ report,
|
|
|
|
|
+ expected_run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ expected_base_commit=ASSIGNED_BASE_COMMIT,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ def test_worktree_identity_rejects_protected_root_wrong_branch_and_wrong_head(self):
|
|
|
|
|
+ with self.assertRaisesRegex(ValueError, "protected_worktree_violation"):
|
|
|
|
|
+ codex_harness.validate_worktree_identity(ROOT, protected_root=ROOT)
|
|
|
|
|
+ with self.assertRaisesRegex(ValueError, "branch"):
|
|
|
|
|
+ codex_harness.validate_worktree_identity(
|
|
|
|
|
+ ROOT, expected_branch=CONVERGENCE_BRANCH + "-wrong"
|
|
|
|
|
+ )
|
|
|
|
|
+ with self.assertRaisesRegex(ValueError, "HEAD"):
|
|
|
|
|
+ codex_harness.validate_worktree_identity(ROOT, expected_head="0" * 40)
|
|
|
|
|
+
|
|
|
|
|
+ def test_agent_task_report_rejects_non_worktree_report_cwd(self):
|
|
|
|
|
+ report = _report_base(task_id="wrong-cwd")
|
|
|
|
|
+ report["worktree"] = str(ROOT / "tools")
|
|
|
|
|
+ with self.assertRaisesRegex(ValueError, "worktree root mismatch"):
|
|
|
|
|
+ codex_harness.validate_agent_task_report(
|
|
|
|
|
+ report,
|
|
|
|
|
+ expected_run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ expected_base_commit=ASSIGNED_BASE_COMMIT,
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
|
|
+ def test_package_rejects_noncanonical_project_input(self):
|
|
|
|
|
+ with tempfile.TemporaryDirectory() as directory:
|
|
|
|
|
+ root = Path(directory)
|
|
|
|
|
+ bitstream = root / "candidate.bit"
|
|
|
|
|
+ bitstream.write_bytes(b"candidate-bitstream")
|
|
|
|
|
+ fake_project = root / "project.json"
|
|
|
|
|
+ fake_project.write_text('{"project_id":"prod2u-door-temp"}\n', encoding="utf-8")
|
|
|
|
|
+ with self.assertRaisesRegex(ValueError, "canonical project"):
|
|
|
|
|
+ codex_harness.create_unverified_package(
|
|
|
|
|
+ bitstream=bitstream,
|
|
|
|
|
+ project=fake_project,
|
|
|
|
|
+ commit=_current_short_commit(),
|
|
|
|
|
+ run_id=CONVERGENCE_RUN_ID,
|
|
|
|
|
+ output_root=root / "dist",
|
|
|
|
|
+ )
|
|
|
|
|
+
|
|
|
def test_name_status_z_parses_rename_and_copy_paths(self):
|
|
def test_name_status_z_parses_rename_and_copy_paths(self):
|
|
|
events = codex_harness.parse_name_status_z(
|
|
events = codex_harness.parse_name_status_z(
|
|
|
b"R100\0old.txt\0new.txt\0C100\0source.txt\0copy.txt\0M\0owned.txt\0"
|
|
b"R100\0old.txt\0new.txt\0C100\0source.txt\0copy.txt\0M\0owned.txt\0"
|