feat: advance conformance and deterministic ID migration
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a023c0-a0a3-7c03-b395-5a0d2757214d
This commit is contained in:
parent
3791411591
commit
ad621d6c0d
10 changed files with 513 additions and 20 deletions
59
tests/test_hub_record_authority.py
Normal file
59
tests/test_hub_record_authority.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
from pathlib import Path
|
||||
|
||||
import yaml
|
||||
|
||||
EXPECTED_STATE_HUB_TABLES = {
|
||||
"agent_messages",
|
||||
"capability_catalog",
|
||||
"capability_requests",
|
||||
"contributions",
|
||||
"decisions",
|
||||
"doi_cache",
|
||||
"domain_goals",
|
||||
"domains",
|
||||
"extension_points",
|
||||
"fabric_graph_edges",
|
||||
"fabric_graph_imports",
|
||||
"fabric_graph_nodes",
|
||||
"intake_notes",
|
||||
"intakes",
|
||||
"interface_changes",
|
||||
"legacy_interface_usage_buckets",
|
||||
"legacy_interfaces",
|
||||
"managed_repos",
|
||||
"progress_events",
|
||||
"repo_goals",
|
||||
"sbom_entries",
|
||||
"sbom_snapshots",
|
||||
"service_catalog",
|
||||
"service_cloud",
|
||||
"service_first_party",
|
||||
"service_self_hosted",
|
||||
"service_third_party",
|
||||
"suggestion_notes",
|
||||
"suggestion_relevance_bumps",
|
||||
"suggestions",
|
||||
"tasks",
|
||||
"td_notes",
|
||||
"technical_debt",
|
||||
"token_events",
|
||||
"topics",
|
||||
"tpsc_catalog",
|
||||
"tpsc_entries",
|
||||
"tpsc_snapshots",
|
||||
"workplan_dependencies",
|
||||
"workplan_launch_requests",
|
||||
"workplans",
|
||||
"write_idempotency_keys",
|
||||
}
|
||||
|
||||
|
||||
def test_every_state_hub_table_has_one_authority_class() -> None:
|
||||
path = Path(__file__).parents[1] / "config" / "hub-record-authority.yaml"
|
||||
document = yaml.safe_load(path.read_text(encoding="utf-8"))
|
||||
classes = set(document["classes"])
|
||||
records = document["records"]
|
||||
|
||||
assert set(records) == EXPECTED_STATE_HUB_TABLES
|
||||
assert {record["class"] for record in records.values()} <= classes
|
||||
assert all(record.get("owner") for record in records.values())
|
||||
|
|
@ -4,7 +4,11 @@ from pathlib import Path
|
|||
|
||||
import pytest
|
||||
|
||||
from repo_manager.identifiers import derive_work_record_uuid, scan_live_identifier_collisions
|
||||
from repo_manager.identifiers import (
|
||||
derive_work_record_uuid,
|
||||
plan_identifier_migration,
|
||||
scan_live_identifier_collisions,
|
||||
)
|
||||
|
||||
|
||||
def _workplan(path: Path, identifier: str, status: str, task_status: str = "todo") -> None:
|
||||
|
|
@ -48,3 +52,48 @@ def test_preflight_blocks_live_collision_but_ignores_archived_history(tmp_path:
|
|||
_workplan(two / "workplans" / "two.md", "SHARED-WP-0001", "archived")
|
||||
report = scan_live_identifier_collisions(tmp_path)
|
||||
assert report["ok"] is True
|
||||
|
||||
|
||||
def test_migration_plan_preserves_mapping_and_is_atomic_per_repo(tmp_path: Path) -> None:
|
||||
one = tmp_path / "one"
|
||||
two = tmp_path / "two"
|
||||
_workplan(one / "workplans" / "one.md", "ONE-WP-0001", "active")
|
||||
_workplan(two / "workplans" / "two.md", "TWO-WP-0001", "ready", task_status="done")
|
||||
|
||||
report = plan_identifier_migration(tmp_path, "fleet-a")
|
||||
|
||||
assert report["ok"] is True
|
||||
assert report["apply_policy"] == "all-or-nothing per repository"
|
||||
assert report["totals"] == {
|
||||
"repositories": 2,
|
||||
"eligible": 2,
|
||||
"skipped": 0,
|
||||
"records": 3,
|
||||
"replace": 0,
|
||||
"assign": 3,
|
||||
"unchanged": 0,
|
||||
}
|
||||
one_plan = next(item for item in report["repositories"] if item["repo"] == "one")
|
||||
assert one_plan["atomic_unit"] is True
|
||||
assert {item["record_id"] for item in one_plan["mappings"]} == {
|
||||
"ONE-WP-0001",
|
||||
"ONE-WP-0001-T01",
|
||||
}
|
||||
assert all(item["current_uuid"] is None for item in one_plan["mappings"])
|
||||
|
||||
|
||||
def test_migration_plan_skips_entire_repo_affected_by_collision(tmp_path: Path) -> None:
|
||||
one = tmp_path / "one"
|
||||
two = tmp_path / "two"
|
||||
_workplan(one / "workplans" / "one.md", "SHARED-WP-0001", "active")
|
||||
_workplan(one / "workplans" / "safe.md", "ONE-WP-0002", "active")
|
||||
_workplan(two / "workplans" / "two.md", "SHARED-WP-0001", "ready")
|
||||
|
||||
report = plan_identifier_migration(tmp_path, "fleet-a")
|
||||
|
||||
assert report["ok"] is False
|
||||
assert report["totals"]["skipped"] == 2
|
||||
one_plan = next(item for item in report["repositories"] if item["repo"] == "one")
|
||||
assert one_plan["eligible"] is False
|
||||
assert any(item["record_id"] == "ONE-WP-0002" for item in one_plan["mappings"])
|
||||
assert any(item["reason"] == "live identifier collision" for item in one_plan["blockers"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue