generated from coulomb/repo-seed
Implement phase-memory foundation
This commit is contained in:
44
tests/test_contracts.py
Normal file
44
tests/test_contracts.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from phase_memory.contracts import graph_from_markitect, profile_from_markitect
|
||||
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures"
|
||||
|
||||
|
||||
def test_profile_ingress_preserves_markitect_profile_intent() -> None:
|
||||
data = json.loads((FIXTURES / "memory-profile.json").read_text(encoding="utf-8"))
|
||||
|
||||
result = profile_from_markitect(data)
|
||||
|
||||
assert result.valid, [diagnostic.to_dict() for diagnostic in result.diagnostics]
|
||||
assert result.value.profile_id == "phase-memory-fixture-profile"
|
||||
assert result.value.memory_kinds == ("reasoning", "conversation", "knowledge", "package")
|
||||
assert result.value.policy["durable_writes"] == "review-gated"
|
||||
|
||||
|
||||
def test_graph_ingress_checks_edge_integrity_without_owning_vocabulary() -> None:
|
||||
data = json.loads((FIXTURES / "memory-graph.json").read_text(encoding="utf-8"))
|
||||
|
||||
result = graph_from_markitect(data)
|
||||
|
||||
assert result.valid, [diagnostic.to_dict() for diagnostic in result.diagnostics]
|
||||
assert result.value.graph_id == "phase-memory-fixture-graph"
|
||||
assert len(result.value.nodes) == 4
|
||||
assert result.value.node_ids == {
|
||||
"decision.boundary",
|
||||
"event.restart",
|
||||
"artifact.profile",
|
||||
"risk.durable-write",
|
||||
}
|
||||
|
||||
|
||||
def test_graph_ingress_rejects_missing_edge_endpoint() -> None:
|
||||
data = json.loads((FIXTURES / "memory-graph.json").read_text(encoding="utf-8"))
|
||||
data["edges"][0]["target"] = "missing"
|
||||
|
||||
result = graph_from_markitect(data)
|
||||
|
||||
assert not result.valid
|
||||
assert any(diagnostic.code == "missing_edge_target" for diagnostic in result.diagnostics)
|
||||
Reference in New Issue
Block a user