feat: finish register receiving and authority routing
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
parent
6d134425df
commit
d103955217
28 changed files with 970 additions and 48 deletions
49
tests/test_authority.py
Normal file
49
tests/test_authority.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from repo_manager.authority import (
|
||||
AuthorityError,
|
||||
load_authority_contract,
|
||||
resolve_record_authority,
|
||||
)
|
||||
|
||||
|
||||
def test_file_derived_route_is_scoped_by_domain_and_repository() -> None:
|
||||
route = resolve_record_authority(
|
||||
"workplans",
|
||||
repo_slug="repo-manager",
|
||||
domain_slug="infotech",
|
||||
claimed_owner="repo-manager",
|
||||
)
|
||||
|
||||
assert route["owner"] == "repo-manager"
|
||||
assert route["authority_key"] == "repository:infotech/repo-manager"
|
||||
|
||||
|
||||
def test_hub_native_route_has_one_central_owner() -> None:
|
||||
route = resolve_record_authority("progress_events", claimed_owner="hub-core")
|
||||
|
||||
assert route["owner"] == "hub-core"
|
||||
assert route["authority_key"] == "hub:hub-core"
|
||||
|
||||
|
||||
def test_unknown_or_conflicting_owner_is_rejected() -> None:
|
||||
with pytest.raises(AuthorityError, match="unknown record type"):
|
||||
resolve_record_authority("mystery")
|
||||
with pytest.raises(AuthorityError, match="authority mismatch"):
|
||||
resolve_record_authority("progress_events", claimed_owner="repo-manager")
|
||||
|
||||
|
||||
def test_every_contract_record_resolves_to_exactly_one_owner() -> None:
|
||||
contract = load_authority_contract()
|
||||
|
||||
for record_type, rule in contract["records"].items():
|
||||
context = (
|
||||
{"repo_slug": "example", "domain_slug": "infotech"}
|
||||
if rule["class"] == "file-derived"
|
||||
else {}
|
||||
)
|
||||
route = resolve_record_authority(record_type, **context)
|
||||
assert route["owner"] == rule["owner"]
|
||||
assert route["authority_key"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue