Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions object_model_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
else Path(__file__).resolve().parent.parent
/ "PyMEOS" / "pymeos" / "factory.py")


def _oracle_id(path: Path) -> str:
"""The oracle named by its place INSIDE PyMEOS, never by this machine.

Where the file sits on a given disk is a property of the checkout, not of
the audit, so recording it makes the artefact differ between two machines
that read the very same oracle -- and a consumer that regenerates the file
to check for drift then sees drift that is not there.
"""
parts = path.resolve().parts
return "/".join(parts[-2:]) if len(parts) >= 2 else path.name

_SUBTYPE = {"INSTANT": "TINSTANT", "SEQUENCE": "TSEQUENCE",
"SEQUENCE_SET": "TSEQUENCESET"}
_TEMPORAL_RE = re.compile(
Expand Down Expand Up @@ -76,7 +88,7 @@ def add(kind, detail, status, ref=None):
if oracle is None:
return {
"status": "oracle-unavailable",
"oraclePath": str(PYMEOS),
"oraclePath": _oracle_id(PYMEOS),
"note": "PyMEOS factory.py not found; reporting curated "
"corrections only — no fabricated parity verdict.",
"total": len(work), "aligned": 0,
Expand Down Expand Up @@ -137,7 +149,7 @@ def add(kind, detail, status, ref=None):
needs = [w for w in work if w["status"] == "needs-correction"]
return {
"status": "audited",
"oraclePath": str(PYMEOS),
"oraclePath": _oracle_id(PYMEOS),
"total": len(work),
"aligned": aligned_concrete,
"divergences": len(work),
Expand Down
18 changes: 17 additions & 1 deletion tests/test_object_model_parity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
sys.path.insert(0, str(ROOT))

from parser.object_model import attach_object_model
from object_model_parity import build_parity, _parse_oracle, PYMEOS
from object_model_parity import (build_parity, _parse_oracle, _oracle_id,
PYMEOS)

MODEL = ROOT / "meta" / "object-model.json"
_CATALOG = ROOT / "output" / "meos-idl.json"
Expand Down Expand Up @@ -58,6 +59,21 @@ def test_audited_against_fake_oracle(self):
self.assertEqual(rep["knownCorrections"] + rep["needsCorrection"],
rep["divergences"])

def test_oracle_is_named_by_its_place_not_by_this_machine(self):
"""Two checkouts of the same oracle must yield the same artefact.

The consumer regenerates this file to detect drift, so an oracle path
carrying the checkout's location reports drift between any two machines
reading the very same oracle -- and the drift gate can then never go
green.
"""
a = _oracle_id(Path("/home/someone/src/PyMEOS/pymeos/factory.py"))
b = _oracle_id(Path("/opt/build-7f3/PyMEOS/pymeos/factory.py"))
self.assertEqual(a, b)
self.assertEqual(a, "pymeos/factory.py")
self.assertNotIn("/home", a)
self.assertFalse(Path(a).is_absolute())

def test_every_divergence_has_a_correction(self):
oracle = _parse_oracle(PYMEOS)
if oracle is None:
Expand Down
Loading