isongraph-ext 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- isongraph_ext/__init__.py +3 -0
- isongraph_ext/baselines/REGISTRY.ison +3 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/MANIFEST.ison +22 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/domains.ison +8 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/receipts/cpp.ison +3 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/receipts/cs.ison +3 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/receipts/js.ison +3 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/receipts/python.ison +3 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/receipts/rust.ison +3 -0
- isongraph_ext/baselines/ce9d3b78afd79cbdffdd67546bcb5278dc38be70/receipts/ts.ison +3 -0
- isongraph_ext/igdm/__init__.py +13 -0
- isongraph_ext/igdm/__main__.py +92 -0
- isongraph_ext/igdm/bind.py +49 -0
- isongraph_ext/igdm/errors.py +12 -0
- isongraph_ext/igdm/payload.py +478 -0
- isongraph_ext/igdm/records.py +121 -0
- isongraph_ext/igdm/verify.py +118 -0
- isongraph_ext/igpv/__init__.py +14 -0
- isongraph_ext/igpv/__main__.py +186 -0
- isongraph_ext/igpv/bind.py +52 -0
- isongraph_ext/igpv/errors.py +14 -0
- isongraph_ext/igpv/lineage.py +100 -0
- isongraph_ext/igpv/locators.py +51 -0
- isongraph_ext/igpv/payload.py +511 -0
- isongraph_ext/igpv/records.py +134 -0
- isongraph_ext/igpv/resolve.py +63 -0
- isongraph_ext/igpv/verify.py +178 -0
- isongraph_ext/igx/__init__.py +15 -0
- isongraph_ext/igx/__main__.py +86 -0
- isongraph_ext/igx/admit.py +95 -0
- isongraph_ext/igx/baselines.py +133 -0
- isongraph_ext/igx/bind.py +57 -0
- isongraph_ext/igx/binding.py +241 -0
- isongraph_ext/igx/digest.py +33 -0
- isongraph_ext/igx/errors.py +14 -0
- isongraph_ext/igx/receipt_rules.py +34 -0
- isongraph_ext/igx/registry.py +10 -0
- isongraph_ext/igx/source.py +84 -0
- isongraph_ext/igx/verify.py +141 -0
- isongraph_ext/igx/versions.py +60 -0
- isongraph_ext/py.typed +0 -0
- isongraph_ext-0.3.0.dist-info/METADATA +144 -0
- isongraph_ext-0.3.0.dist-info/RECORD +46 -0
- isongraph_ext-0.3.0.dist-info/WHEEL +5 -0
- isongraph_ext-0.3.0.dist-info/licenses/LICENSE +21 -0
- isongraph_ext-0.3.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
meta.baseline
|
|
2
|
+
canonical_writer_dist canonical_writer_dist_version core_commit core_format core_runtime_dist core_runtime_dist_version core_semantic_spec core_vector_corpus_commit core_vector_corpus_digest core_vector_corpus_version core_version
|
|
3
|
+
ison-py 1.2.0 ce9d3b78afd79cbdffdd67546bcb5278dc38be70 isongraph ison-graph 1.4.1 ISONGraph-Semantic/2-draft f88af8bd29680e7b6e7716585be936d5738eb55f 1d1a6648abeeadece24b43a163949d02241911706866236cc32bd6b61745bcb0 1 1.4.1
|
|
4
|
+
|
|
5
|
+
table.core_runtime
|
|
6
|
+
module sha256
|
|
7
|
+
ison_graph/__init__.py 2a13a36d63d85e766df961aae2d52550c2e9c52f60a5ee46560ddce4a301ece4
|
|
8
|
+
ison_graph/multigraph.py 6d4e874a75f43d8914422bf2006f995a6334bfe4fe9eb5552c0f2f31fb4ff3e6
|
|
9
|
+
ison_graph/query.py d0c34fa8649de066049a1670ccc00f8af28029c2ed7374256b9fb9a978423cd4
|
|
10
|
+
ison_graph/schema.py 06f82dc13eb02794b11d0386c8f8090b0f9a5d2f48be839e828703e2e5e2d1b4
|
|
11
|
+
ison_graph/structural.py ffa53c3edd5dc76e6e7db20b74473f59bb6b329b09479445699eeba59e2232c7
|
|
12
|
+
ison_graph/viz.py e62949eb91c9a3fe4be3972de94baddf7f41f034f5c61db51ceb8bcb4ca9b6d6
|
|
13
|
+
|
|
14
|
+
table.files
|
|
15
|
+
path sha256
|
|
16
|
+
"domains.ison" 6d9db34ceedd5c1309060bc2dfeddcdd302b6664737bfe904c14391870254897
|
|
17
|
+
receipts/cpp.ison b330dc23e4d882c71942d035d1848f03841f932345c823f93b560c86f40e83a8
|
|
18
|
+
receipts/cs.ison f37d41566cf69c3e6b933483946bc8559c8ceb160c2d6d4ea36caab8f94ccfc7
|
|
19
|
+
receipts/js.ison acbe2104736148bf19c0d93649781b9c142066bec4fe1ab0b6fdc116abc39ed6
|
|
20
|
+
receipts/python.ison cece1259ac61172a1d519b5ad31cef8b29ff3e466f629f4cb72b4f34fdda9ac0
|
|
21
|
+
receipts/rust.ison 6dd9c2dcf5407f598233f6c3f21bf831a02f141a509ff45b112729ae35690040
|
|
22
|
+
receipts/ts.ison 393ba7e64e6c2be3606f2e8b03124dd2ff0cef33d069f38c6cb0b075dec268c4
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
meta.core_conformance_receipt
|
|
2
|
+
canonicalized core_commit core_format core_version corpus_commit corpus_digest corpus_version defect lossy pass port port_version posture rejected_as_expected semantic_spec todo total
|
|
3
|
+
0 ce9d3b78afd79cbdffdd67546bcb5278dc38be70 isongraph 1.4.1 f88af8bd29680e7b6e7716585be936d5738eb55f 1d1a6648abeeadece24b43a163949d02241911706866236cc32bd6b61745bcb0 1 0 0 0 cpp 1.4.1 PARTIAL 0 ISONGraph-Semantic/2-draft 32 32
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
meta.core_conformance_receipt
|
|
2
|
+
canonicalized core_commit core_format core_version corpus_commit corpus_digest corpus_version defect lossy pass port port_version posture rejected_as_expected semantic_spec todo total
|
|
3
|
+
0 ce9d3b78afd79cbdffdd67546bcb5278dc38be70 isongraph 1.4.1 f88af8bd29680e7b6e7716585be936d5738eb55f 1d1a6648abeeadece24b43a163949d02241911706866236cc32bd6b61745bcb0 1 0 0 0 cs 1.4.1 PARTIAL 0 ISONGraph-Semantic/2-draft 32 32
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
meta.core_conformance_receipt
|
|
2
|
+
canonicalized core_commit core_format core_version corpus_commit corpus_digest corpus_version defect lossy pass port port_version posture rejected_as_expected semantic_spec todo total
|
|
3
|
+
6 ce9d3b78afd79cbdffdd67546bcb5278dc38be70 isongraph 1.4.1 f88af8bd29680e7b6e7716585be936d5738eb55f 1d1a6648abeeadece24b43a163949d02241911706866236cc32bd6b61745bcb0 1 1 4 16 js 1.4.1 KNOWN_DEFECT 5 ISONGraph-Semantic/2-draft 0 32
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
meta.core_conformance_receipt
|
|
2
|
+
canonicalized core_commit core_format core_version corpus_commit corpus_digest corpus_version defect lossy pass port port_version posture rejected_as_expected semantic_spec todo total
|
|
3
|
+
7 ce9d3b78afd79cbdffdd67546bcb5278dc38be70 isongraph 1.4.1 f88af8bd29680e7b6e7716585be936d5738eb55f 1d1a6648abeeadece24b43a163949d02241911706866236cc32bd6b61745bcb0 1 0 0 19 python 1.4.1 FULL 6 ISONGraph-Semantic/2-draft 0 32
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
meta.core_conformance_receipt
|
|
2
|
+
canonicalized core_commit core_format core_version corpus_commit corpus_digest corpus_version defect lossy pass port port_version posture rejected_as_expected semantic_spec todo total
|
|
3
|
+
0 ce9d3b78afd79cbdffdd67546bcb5278dc38be70 isongraph 1.4.1 f88af8bd29680e7b6e7716585be936d5738eb55f 1d1a6648abeeadece24b43a163949d02241911706866236cc32bd6b61745bcb0 1 0 0 0 rust 1.4.1 PARTIAL 0 ISONGraph-Semantic/2-draft 32 32
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
meta.core_conformance_receipt
|
|
2
|
+
canonicalized core_commit core_format core_version corpus_commit corpus_digest corpus_version defect lossy pass port port_version posture rejected_as_expected semantic_spec todo total
|
|
3
|
+
6 ce9d3b78afd79cbdffdd67546bcb5278dc38be70 isongraph 1.4.1 f88af8bd29680e7b6e7716585be936d5738eb55f 1d1a6648abeeadece24b43a163949d02241911706866236cc32bd6b61745bcb0 1 1 4 16 ts 1.4.1 KNOWN_DEFECT 5 ISONGraph-Semantic/2-draft 0 32
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""IGDM/1 Datamatics (19-IGDM1-DESIGN.md)."""
|
|
2
|
+
|
|
3
|
+
from ..igpv.records import EdgeAddress, NodeRef
|
|
4
|
+
from ..igx.registry import DEFAULT_REGISTRY
|
|
5
|
+
from .bind import bind, verify_and_admit
|
|
6
|
+
from .errors import IGDMError
|
|
7
|
+
from .payload import DatamaticsPayload, check_references, unrecognized_roles
|
|
8
|
+
from .records import DEFAULT_LIMITS, EdgeHints, Group, LayoutHints, Limits, Member, NodeHints
|
|
9
|
+
from .verify import DatamaticsVerification, verify
|
|
10
|
+
|
|
11
|
+
__all__ = ["IGDMError", "DEFAULT_LIMITS", "EdgeHints", "Group", "LayoutHints", "Limits", "Member", "NodeHints", "EdgeAddress", "NodeRef",
|
|
12
|
+
"DEFAULT_REGISTRY", "DatamaticsPayload", "check_references", "unrecognized_roles", "DatamaticsVerification", "verify",
|
|
13
|
+
"bind", "verify_and_admit"]
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"""CLI (19 §4): verify -> 0/1/2, 64 on usage; one canonical ISON document per response."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import sys
|
|
7
|
+
from collections.abc import Mapping
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from ison_parser import Block, Document, dumps_canonical
|
|
11
|
+
|
|
12
|
+
from ..igx.admit import AdmissionPolicy
|
|
13
|
+
from ..igx.binding import ExtensionBinding
|
|
14
|
+
from ..igx.errors import IGXError
|
|
15
|
+
from .bind import verify_and_admit
|
|
16
|
+
from .errors import IGDMError
|
|
17
|
+
|
|
18
|
+
EX_USAGE = 64 # BSD sysexits: never collides with 2 (admission denied) or 1 (invalid binding/payload)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class _Parser(argparse.ArgumentParser):
|
|
22
|
+
def error(self, message: str) -> None: # type: ignore[override]
|
|
23
|
+
self.print_usage(sys.stderr)
|
|
24
|
+
sys.stderr.write(f"error: {message}\n")
|
|
25
|
+
raise SystemExit(EX_USAGE)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _utf8_streams() -> None:
|
|
29
|
+
"""Output is UTF-8, LF-terminated ISON regardless of console locale or platform (same rule as the igx CLI)."""
|
|
30
|
+
for stream in (sys.stdout, sys.stderr):
|
|
31
|
+
reconfigure = getattr(stream, "reconfigure", None)
|
|
32
|
+
if reconfigure is not None:
|
|
33
|
+
reconfigure(encoding="utf-8", errors="strict", newline="\n")
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _meta(name: str, row: dict) -> Block:
|
|
37
|
+
return Block("meta", name, list(row), [row])
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def _emit(blocks: list[Block]) -> None:
|
|
41
|
+
sys.stdout.write(dumps_canonical(Document(blocks=blocks)) + "\n")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _joined(items) -> str | None:
|
|
45
|
+
items = list(items)
|
|
46
|
+
return ",".join(items) if items else None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def _kv(m: Mapping) -> str | None:
|
|
50
|
+
return _joined(f"{k}={v}" for k, v in m.items())
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def main(argv: list[str]) -> int:
|
|
54
|
+
_utf8_streams()
|
|
55
|
+
ap = _Parser(prog="python -m isongraph_ext.igdm")
|
|
56
|
+
sub = ap.add_subparsers(dest="cmd", required=True)
|
|
57
|
+
v = sub.add_parser("verify")
|
|
58
|
+
v.add_argument("graph", type=Path)
|
|
59
|
+
v.add_argument("binding", type=Path)
|
|
60
|
+
v.add_argument("payload", type=Path)
|
|
61
|
+
v.add_argument("--allow-retired", action="store_true")
|
|
62
|
+
a = ap.parse_args(argv)
|
|
63
|
+
try:
|
|
64
|
+
graph, binding_bytes, payload_bytes = a.graph.read_bytes(), a.binding.read_bytes(), a.payload.read_bytes()
|
|
65
|
+
except OSError as e:
|
|
66
|
+
ap.print_usage(sys.stderr)
|
|
67
|
+
sys.stderr.write(f"error: {e}\n")
|
|
68
|
+
return EX_USAGE
|
|
69
|
+
try:
|
|
70
|
+
binding = ExtensionBinding.from_ison(binding_bytes)
|
|
71
|
+
result, dm, decision = verify_and_admit(payload_bytes, binding, graph, policy=AdmissionPolicy(allow_retired_baselines=a.allow_retired))
|
|
72
|
+
except (IGXError, IGDMError) as e:
|
|
73
|
+
_emit([_meta("error", {"code": e.code, "field": e.field, "detail": e.detail, "step": e.step})])
|
|
74
|
+
return 1
|
|
75
|
+
_emit([
|
|
76
|
+
_meta("verification", {
|
|
77
|
+
"binding_digest": result.binding_digest, "semantic_verification": result.semantic_verification,
|
|
78
|
+
"source_canonical": result.source_canonical, "source_semantic_eligibility": result.source_semantic_eligibility,
|
|
79
|
+
"source_semantic_reason": result.source_semantic_reason, "steps_passed": _joined(result.steps_passed),
|
|
80
|
+
"unrecognized_optional": _joined(c.extension for c in result.unrecognized_optional)}),
|
|
81
|
+
_meta("datamatics", {
|
|
82
|
+
"payload_sha256": dm.payload_sha256, "binding_digest": dm.binding_digest, "target_artifact_sha256": dm.target_artifact_sha256,
|
|
83
|
+
"object_resolution": dm.object_resolution, "unrecognized_roles": _joined(dm.unrecognized_roles),
|
|
84
|
+
"counts": _kv(dm.counts), "steps_passed": _joined(dm.steps_passed)}),
|
|
85
|
+
_meta("admission", {"admitted": decision.admitted, "code": decision.code, "step": decision.step,
|
|
86
|
+
"receipt_posture": decision.receipt_posture, "reasons": _joined(decision.reasons)}),
|
|
87
|
+
])
|
|
88
|
+
return 0 if decision.admitted else 2
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
if __name__ == "__main__":
|
|
92
|
+
sys.exit(main(sys.argv[1:]))
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"""Producer path and trustworthy consumer path (19 §4), mirroring igpv.bind."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping, Sequence
|
|
6
|
+
|
|
7
|
+
from ..igx.admit import DEFAULT_POLICY, AdmissionPolicy, AdmissionResult, admit
|
|
8
|
+
from ..igx.baselines import BASELINES, DEFAULT_BASELINE, Baseline
|
|
9
|
+
from ..igx.bind import bind as igx_bind
|
|
10
|
+
from ..igx.binding import Capability, Consumer, ExtensionBinding
|
|
11
|
+
from ..igx.digest import sha256_hex
|
|
12
|
+
from ..igx.registry import DEFAULT_REGISTRY, CapabilityRegistry
|
|
13
|
+
from ..igx.source import as_bytes
|
|
14
|
+
from ..igx.verify import VerificationResult
|
|
15
|
+
from . import records as R
|
|
16
|
+
from .errors import IGDMError
|
|
17
|
+
from .payload import DatamaticsPayload
|
|
18
|
+
from .verify import DatamaticsVerification, verify
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def bind(target: str | bytes, payload: DatamaticsPayload, *, requirement: str = "REQUIRED", serialization_profile: str,
|
|
22
|
+
producer_port: str, identity_claim: str, capabilities: Sequence[Capability] = (), consumer: Consumer | None = None,
|
|
23
|
+
baseline: Baseline = DEFAULT_BASELINE, registry: CapabilityRegistry = DEFAULT_REGISTRY,
|
|
24
|
+
policy: AdmissionPolicy = DEFAULT_POLICY, limits: R.Limits = R.DEFAULT_LIMITS) -> ExtensionBinding:
|
|
25
|
+
if requirement not in ("REQUIRED", "OPTIONAL"):
|
|
26
|
+
raise IGDMError("MALFORMED_DATAMATICS", "table.capabilities.igdm.requirement", "REQUIRED or OPTIONAL", "D1")
|
|
27
|
+
if any(c.extension == R.CAPABILITY for c in capabilities):
|
|
28
|
+
raise IGDMError("MALFORMED_DATAMATICS", "table.capabilities.igdm", "bind() adds the igdm row itself; do not pass one", "D1")
|
|
29
|
+
payload.check()
|
|
30
|
+
data = as_bytes(target)
|
|
31
|
+
actual = sha256_hex(data)
|
|
32
|
+
if payload.target_artifact_sha256 != actual:
|
|
33
|
+
raise IGDMError("TARGET_BINDING_MISMATCH", "meta.igdm.target_artifact_sha256", f"target bytes hash to {actual}", "D2")
|
|
34
|
+
if payload.target_serialization_profile != serialization_profile:
|
|
35
|
+
raise IGDMError("TARGET_BINDING_MISMATCH", "meta.igdm.target_serialization_profile",
|
|
36
|
+
f"{payload.target_serialization_profile} != {serialization_profile}", "D2")
|
|
37
|
+
caps = tuple(capabilities) + (Capability(R.CAPABILITY, R.CAPABILITY_RANGE, requirement, payload.digest),)
|
|
38
|
+
binding = igx_bind(data, serialization_profile=serialization_profile, producer_port=producer_port, identity_claim=identity_claim,
|
|
39
|
+
capabilities=caps, consumer=consumer, baseline=baseline, registry=registry, policy=policy)
|
|
40
|
+
verify(payload, binding, data, limits=limits, baselines={**BASELINES, baseline.core_commit: baseline}, registry=registry)
|
|
41
|
+
return binding
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def verify_and_admit(payload: str | bytes | DatamaticsPayload, binding: ExtensionBinding, target: str | bytes, *,
|
|
45
|
+
limits: R.Limits = R.DEFAULT_LIMITS, baselines: Mapping[str, Baseline] = BASELINES,
|
|
46
|
+
registry: CapabilityRegistry = DEFAULT_REGISTRY, policy: AdmissionPolicy = DEFAULT_POLICY
|
|
47
|
+
) -> tuple[VerificationResult, DatamaticsVerification, AdmissionResult]:
|
|
48
|
+
result, dm = verify(payload, binding, target, limits=limits, baselines=baselines, registry=registry)
|
|
49
|
+
return result, dm, admit(binding, result, policy=policy, baselines=baselines)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""The one exception type IGDM/1 raises (19 §3.1). Admission denials are the binding's results, not exceptions."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class IGDMError(Exception):
|
|
7
|
+
def __init__(self, code: str, field: str, detail: str, step: str) -> None:
|
|
8
|
+
super().__init__(f"{step} {code} {field}: {detail}")
|
|
9
|
+
self.code = code
|
|
10
|
+
self.field = field
|
|
11
|
+
self.detail = detail
|
|
12
|
+
self.step = step
|