Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions tests/test_live_codex_qualification_c10.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
from __future__ import annotations

from contextlib import nullcontext
from pathlib import Path
import sys
import types
import unittest
from unittest import mock

ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tools"))

import live_codex_qualification_c10 as c10

C10_SOURCE = ROOT / "tools" / "live_codex_qualification_c10.py"
V7_SOURCE = ROOT / "tools" / "live_codex_qualification_harness_v7.py"


class LiveCodexC10Tests(unittest.TestCase):
def test_v7_installs_deterministic_c10_runtime(self) -> None:
source = V7_SOURCE.read_text(encoding="utf-8")
self.assertIn("import live_codex_qualification_c10 as c10", source)
self.assertIn("c10.install(v6, _live_runner_persisted_trust_runtime)", source)

def test_c10_fixture_is_outer_harness_owned_and_product_validated(self) -> None:
source = C10_SOURCE.read_text(encoding="utf-8")
self.assertIn("v4._start_active_run(", source)
self.assertIn("v4._create_checkpoint(planning=planning, run_root=run_root)", source)
self.assertGreaterEqual(source.count("v4._checkpoint_validation(planning)"), 4)
self.assertIn('"fixture_prepared_by_outer_harness=true"', source)
self.assertNotIn("planner_prompt", source)

def test_postcompact_is_independent_of_session_start_context(self) -> None:
source = C10_SOURCE.read_text(encoding="utf-8")
self.assertIn('configured.pop("SessionStart", None)', source)
self.assertIn('bool(configured.get("PreCompact"))', source)
self.assertIn('bool(configured.get("PostCompact"))', source)
self.assertIn("not compact_session_start", source)
self.assertIn("postcompact_isolated", source)

def test_compaction_trigger_is_qualification_only(self) -> None:
source = C10_SOURCE.read_text(encoding="utf-8")
self.assertIn('compat._set_feature(text, "token_budget", "false")', source)
self.assertIn('"token_budget_disabled_in_isolated_fixture": True', source)
self.assertIn("C10_SESSION_COMPACT_LIMIT = 1_000_000", source)
self.assertIn("C10_COMPACT_LIMIT = 200", source)

def test_opaque_recovery_value_is_not_persisted_in_evidence(self) -> None:
source = C10_SOURCE.read_text(encoding="utf-8")
self.assertIn("proof = secrets.token_hex(16)", source)
self.assertIn("def _payload_summary", source)
self.assertIn('"opaque_recovery_value_persisted=false"', source)
self.assertNotIn('"model_payload": session_payload', source)
self.assertNotIn('"model_payload": compact_payload', source)

def test_install_routes_only_c10(self) -> None:
calls: list[dict[str, object]] = []

def original(**kwargs: object) -> tuple[str, bool]:
calls.append(dict(kwargs))
return "ORIGINAL", False

dummy = types.SimpleNamespace(_ORIGINAL_CAPABILITY_RUNTIME=original)
trust = lambda: nullcontext(Path("."))
with mock.patch.object(c10, "run_c10", return_value=("REPRODUCED", True)) as run_c10:
c10.install(dummy, trust)
self.assertEqual(
dummy._ORIGINAL_CAPABILITY_RUNTIME(capability_id="C11", sentinel=1),
("ORIGINAL", False),
)
self.assertEqual(
dummy._ORIGINAL_CAPABILITY_RUNTIME(capability_id="C10", sentinel=2),
("REPRODUCED", True),
)
self.assertEqual(calls, [{"capability_id": "C11", "sentinel": 1}])
run_c10.assert_called_once_with(live_trust_runtime=trust, sentinel=2)

def test_safety_boundary_is_not_weakened(self) -> None:
source = C10_SOURCE.read_text(encoding="utf-8")
self.assertNotIn("--dangerously-bypass-approvals-and-sandbox", source)
self.assertNotIn("danger-full-access", source)
self.assertNotIn("--privileged", source)
self.assertNotIn("SYS_ADMIN", source)
self.assertIn('sandbox="read-only"', source)
self.assertIn("base.git_snapshot", source)


if __name__ == "__main__":
unittest.main()
Loading