Files
rune/tests/test_v1_authority_map.py
T
Nick 5e67a0a24f
CI Pipeline / lint (push) Successful in 22s
CI Pipeline / unit-tests (push) Successful in 1m23s
CI Pipeline / canary (push) Failing after 7s
CI Pipeline / best-practices (push) Successful in 5s
CI Pipeline / documentation (push) Successful in 9s
CI Pipeline / gitea-offline (push) Successful in 39s
CI Pipeline / required-checks (push) Skipped
CI Pipeline / lint (pull_request) Successful in 21s
CI Pipeline / unit-tests (pull_request) Successful in 1m25s
CI Pipeline / canary (pull_request) Failing after 7s
CI Pipeline / best-practices (pull_request) Successful in 5s
CI Pipeline / documentation (pull_request) Successful in 6s
CI Pipeline / gitea-offline (pull_request) Successful in 39s
CI Pipeline / required-checks (pull_request) Skipped
fix: update authority-map policy test for full-suite CI discovery
2026-09-04 20:05:23 +01:00

120 lines
3.8 KiB
Python

"""P0-01 contracts for Rune v1 authority ownership and admission."""
from __future__ import annotations
import json
import re
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
MANIFEST = ROOT / "config" / "v1_authority_map.json"
AUTHORITY_DOC = ROOT / "docs" / "v1" / "AUTHORITY_MAP.md"
PR_TEMPLATE = ROOT / ".gitea" / "PULL_REQUEST_TEMPLATE.md"
CI_WORKFLOW = ROOT / ".gitea" / "workflows" / "ci.yml"
REQUIRED_RESPONSIBILITIES = {
"conversation_state",
"task_state",
"context_construction",
"memory_selection",
"capability_selection",
"model_routing",
"provider_adaptation",
"tool_schema_execution",
"permissions_approval",
"verification",
"outcome_learning",
"response_adaptation",
"tui_rendering",
"identity_self_model",
"build_orchestration",
"schedules_background_events",
}
ALLOWED_DISPOSITIONS = {
"retain-authority",
"migrate-adapter",
"archive-candidate",
"dormant-until-dependency",
}
def load_manifest() -> dict:
assert MANIFEST.is_file(), "P0-01 authority manifest does not exist"
return json.loads(MANIFEST.read_text(encoding="utf-8"))
def test_v042_reference_is_frozen_to_reviewed_commit():
manifest = load_manifest()
assert manifest["frozen_reference"] == {
"tag": "v0.42.0",
"commit": "98b8a7048455dd1a5c6fe219c114502549b8227c",
"recoverable": True,
}
def test_manifest_covers_exact_required_responsibilities_once():
manifest = load_manifest()
responsibilities = manifest["responsibilities"]
names = [item["id"] for item in responsibilities]
assert set(names) == REQUIRED_RESPONSIBILITIES
assert len(names) == len(set(names))
def test_each_responsibility_has_one_target_owner_and_closed_path_dispositions():
for responsibility in load_manifest()["responsibilities"]:
assert isinstance(responsibility["v1_owner"], str)
assert responsibility["v1_owner"].strip()
assert re.fullmatch(r"#\d+", responsibility["dependency_issue"])
assert responsibility["current_paths"]
for current in responsibility["current_paths"]:
assert current["disposition"] in ALLOWED_DISPOSITIONS
assert current["path"]
assert current["role"]
assert current["evidence"]
def test_every_repository_source_path_in_manifest_exists():
for responsibility in load_manifest()["responsibilities"]:
for current in responsibility["current_paths"]:
path = current["path"].split(":", 1)[0]
assert (ROOT / path).exists(), f"Missing mapped source: {path}"
def test_authority_document_states_invariant_and_does_not_claim_migration_complete():
assert AUTHORITY_DOC.is_file()
text = AUTHORITY_DOC.read_text(encoding="utf-8")
assert "No subsystem may inject model context outside the ContextBroker" in text
assert "current authority" in text.lower()
assert "intended v1 authority" in text.lower()
assert "This map does not implement the migrations" in text
for responsibility in REQUIRED_RESPONSIBILITIES:
assert f"`{responsibility}`" in text
def test_pr_template_enforces_v1_feature_admission_questions():
text = PR_TEMPLATE.read_text(encoding="utf-8")
for heading in (
"Purpose",
"Owner",
"Trigger",
"Dormant cost",
"Context contribution",
"Authority",
"Failure mode",
"Verification",
"Learning",
"Removal",
"Benchmark",
):
assert heading in text
assert "replace, extend, or remain dormant" in text
def test_gitea_required_gate_runs_authority_map_contracts():
text = CI_WORKFLOW.read_text(encoding="utf-8")
# Full-suite auto-discovery: all tests run, including this file.
assert "pytest tests/" in text
assert "unit-tests:" in text
assert "needs: [lint, unit-tests, canary" in text