Files
aios/tests/test_trusted_plan_release_path.py
T
AIOS Governed Continuation 8427c7bf22
autonomy-smoke-tests V2R2C2 trusted-plan/runtime contract smoke passed; 67 focused tests
autonomy-unit-tests governed source full Linux suite: 781 passed, 3 skipped, 154 subtests
git-diff-check final PR head diff-check passed against protected main
py-compile all tracked Python sources compile in memory without errors
reconciliation-contract completed-replay reconciliation contract: 11 passed
secret-scan final PR diff high-signal secret scan found no credentials
signer-validator-contract signer/validator contract: 5 passed, 2 explicit environment skips
campaign-approval-gate trusted V2R2C2 release-plan dispatch and exact binding contract passed
release-state-machine plan-driven release handler and generic adapter contract passed; legacy path isolated
test(release): cover trusted plan dispatch and adapter binding
2026-08-29 09:10:05 +08:00

61 lines
2.3 KiB
Python

from __future__ import annotations
from pathlib import Path
from types import SimpleNamespace
import sys
import pytest
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "active-runtime" / "app"))
from governed_production_release import ReleaseBlocked, TrustedPlanReleaseExecutor, build_executor_config
from trusted_production_adapter import AdapterBlocked, _binding
def config(tmp_path: Path, version: str = "V2R2C2") -> SimpleNamespace:
return SimpleNamespace(
state_root=tmp_path,
target_version=version,
release_plan_path=None,
authoritative_git_dir=tmp_path,
baseline_path=tmp_path / "baseline.json",
registry_root=tmp_path / "registry",
api_base="http://127.0.0.1:3000/api/v1",
token_path=tmp_path / "token",
remote_name="gitea-http",
)
def test_non_legacy_runtime_selects_trusted_plan_handler(tmp_path: Path):
handler = build_executor_config(config(tmp_path))
assert isinstance(handler, TrustedPlanReleaseExecutor)
def test_trusted_handler_requires_server_side_plan(tmp_path: Path):
handler = build_executor_config(config(tmp_path))
with pytest.raises(ReleaseBlocked, match="TRUSTED_RELEASE_PLAN_REQUIRED"):
handler.consistency({"version": "V2R2C2"})
def test_legacy_runtime_keeps_compatibility_path(tmp_path: Path):
handler = build_executor_config(config(tmp_path, "V2R2C1"))
assert handler.__class__.__name__ == "GovernedProductionReleaseExecutor"
def test_generic_adapter_requires_candidate_and_plan_binding():
value = {
"version": "V2R2C2",
"target_oid": "1" * 40,
"artifact_sha256": "2" * 64,
"artifact_path": "/opt/aios/releases/V2R2C2.tar",
"artifact_size": 1,
"production_service": "aios-v2r2c2-production.service",
"production_port": 18928,
"candidate_id": "rc-v2r2c2-001",
"release_plan_sha256": "sha256:" + "3" * 64,
}
assert _binding(value)["candidate_id"] == "rc-v2r2c2-001"
with pytest.raises(AdapterBlocked, match="legacy_or_unbound_release_rejected"):
_binding({**value, "version": "V2R1C7"})
with pytest.raises(AdapterBlocked, match="trusted_binding_incomplete"):
_binding({key: item for key, item in value.items() if key != "release_plan_sha256"})