tba-durability-attestation 0.4.0.dev2__tar.gz
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.
- tba_durability_attestation-0.4.0.dev2/PKG-INFO +24 -0
- tba_durability_attestation-0.4.0.dev2/README.md +3 -0
- tba_durability_attestation-0.4.0.dev2/pyproject.toml +22 -0
- tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/__init__.py +5 -0
- tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/inventory.py +22 -0
- tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/operations/__init__.py +1 -0
- tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/operations/attestation.py +133 -0
- tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/py.typed +1 -0
- tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/specifications/__init__.py +1 -0
- tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/specifications/attestation.py +67 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: tba-durability-attestation
|
|
3
|
+
Version: 0.4.0.dev2
|
|
4
|
+
Summary: Carrier-neutral layer-30 durable table operations.
|
|
5
|
+
License-Expression: Apache-2.0
|
|
6
|
+
Requires-Python: >=3.10,<3.15
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
13
|
+
Requires-Dist: tba-bases-replay (==0.4.0.dev2)
|
|
14
|
+
Requires-Dist: tba-contracts-identity (==0.4.0.dev2)
|
|
15
|
+
Requires-Dist: tba-contracts-security-trust (==0.1.0)
|
|
16
|
+
Requires-Dist: tba-primitives-identity (==0.4.0.dev2)
|
|
17
|
+
Requires-Dist: tba-storage-attestation (==0.4.0.dev2)
|
|
18
|
+
Requires-Dist: tigrbl (==0.4.5.dev8)
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# tba-durability-attestation
|
|
22
|
+
|
|
23
|
+
Carrier-neutral layer-30 durable operations and derived table specifications.
|
|
24
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "tba-durability-attestation"
|
|
3
|
+
version = "0.4.0.dev2"
|
|
4
|
+
description = "Carrier-neutral layer-30 durable table operations."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10,<3.15"
|
|
7
|
+
license = "Apache-2.0"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"tigrbl==0.4.5.dev8",
|
|
10
|
+
"tba-primitives-identity==0.4.0.dev2",
|
|
11
|
+
"tba-contracts-identity==0.4.0.dev2",
|
|
12
|
+
"tba-bases-replay==0.4.0.dev2",
|
|
13
|
+
"tba-contracts-security-trust==0.1.0",
|
|
14
|
+
"tba-storage-attestation==0.4.0.dev2",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[build-system]
|
|
18
|
+
requires = ["poetry-core>=1.0.0"]
|
|
19
|
+
build-backend = "poetry.core.masonry.api"
|
|
20
|
+
|
|
21
|
+
[tool.poetry]
|
|
22
|
+
packages = [{ include = "tba_durability_attestation", from = "src" }]
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Immutable inventory of this durable family's table specifications."""
|
|
2
|
+
|
|
3
|
+
from . import specifications as _specifications
|
|
4
|
+
|
|
5
|
+
RUNTIME_TABLE_SPECS = tuple(
|
|
6
|
+
value
|
|
7
|
+
for name, value in vars(_specifications).items()
|
|
8
|
+
if name.endswith("RuntimeSpec") and getattr(value, "model", None) is not None
|
|
9
|
+
)
|
|
10
|
+
RUNTIME_TABLES = tuple(spec.model for spec in RUNTIME_TABLE_SPECS)
|
|
11
|
+
RUNTIME_OPERATION_BY_ALIAS = {
|
|
12
|
+
operation.alias: operation
|
|
13
|
+
for spec in RUNTIME_TABLE_SPECS
|
|
14
|
+
for operation in spec.ops
|
|
15
|
+
if operation.extra.get("owner_layer") == "30-storage-runtime"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
__all__ = [
|
|
19
|
+
"RUNTIME_OPERATION_BY_ALIAS",
|
|
20
|
+
"RUNTIME_TABLE_SPECS",
|
|
21
|
+
"RUNTIME_TABLES",
|
|
22
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .attestation import *
|
tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/operations/attestation.py
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"""Durable attestation and reference-material operations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from collections.abc import Mapping
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from tba_storage_attestation.tables import AttestationEndorsement, AttestationEvidence, AttestationReferenceManifest, AttestationReferenceValue, AttestationResult
|
|
9
|
+
from tba_primitives_identity.persistence import reject_sensitive_raw_fields
|
|
10
|
+
|
|
11
|
+
from tigrbl import (
|
|
12
|
+
provideTableHandler,
|
|
13
|
+
database_from_context,
|
|
14
|
+
maybe_await,
|
|
15
|
+
payload_from_context,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
record_attestation_evidence = provideTableHandler(
|
|
19
|
+
AttestationEvidence, payload_validator=reject_sensitive_raw_fields
|
|
20
|
+
)
|
|
21
|
+
record_attestation_result = provideTableHandler(
|
|
22
|
+
AttestationResult, payload_validator=reject_sensitive_raw_fields
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def make_attestation_appraisal_recorder(
|
|
27
|
+
*,
|
|
28
|
+
db: Any,
|
|
29
|
+
evidence_id: str,
|
|
30
|
+
artifact_locator: str,
|
|
31
|
+
evidence_digest: str,
|
|
32
|
+
issuer: str | None = None,
|
|
33
|
+
policy_id: str | None = None,
|
|
34
|
+
evidence_recorder: Any = None,
|
|
35
|
+
result_recorder: Any = None,
|
|
36
|
+
):
|
|
37
|
+
"""Bind caller-owned durable state to the capability recorder signature."""
|
|
38
|
+
|
|
39
|
+
evidence_recorder = evidence_recorder or record_attestation_evidence
|
|
40
|
+
result_recorder = result_recorder or record_attestation_result
|
|
41
|
+
|
|
42
|
+
async def record(verified_evidence: Any, appraisal_result: Any) -> Any:
|
|
43
|
+
evidence = verified_evidence.evidence
|
|
44
|
+
envelope = verified_evidence.envelope.envelope
|
|
45
|
+
await evidence_recorder(
|
|
46
|
+
{
|
|
47
|
+
"payload": {
|
|
48
|
+
"evidence_id": evidence_id,
|
|
49
|
+
"profile": evidence.profile,
|
|
50
|
+
"format": envelope.format.value,
|
|
51
|
+
"issuer": issuer,
|
|
52
|
+
"artifact_locator": artifact_locator,
|
|
53
|
+
"evidence_digest": evidence_digest,
|
|
54
|
+
},
|
|
55
|
+
"db": db,
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
return await result_recorder(
|
|
59
|
+
{
|
|
60
|
+
"payload": {
|
|
61
|
+
"evidence_id": evidence_id,
|
|
62
|
+
"policy_id": policy_id,
|
|
63
|
+
"trusted": appraisal_result.trusted,
|
|
64
|
+
"reason": appraisal_result.reason,
|
|
65
|
+
"result_claims": dict(appraisal_result.claims),
|
|
66
|
+
},
|
|
67
|
+
"db": db,
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return record
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
async def publish_reference_material(ctx: Mapping[str, Any]) -> Mapping[str, object]:
|
|
75
|
+
"""Stage a manifest and its material in one caller-owned transaction."""
|
|
76
|
+
|
|
77
|
+
payload = payload_from_context(ctx)
|
|
78
|
+
reject_sensitive_raw_fields(payload)
|
|
79
|
+
manifest = payload.get("manifest")
|
|
80
|
+
values = payload.get("reference_values", ())
|
|
81
|
+
endorsements = payload.get("endorsements", ())
|
|
82
|
+
if not isinstance(manifest, Mapping):
|
|
83
|
+
raise TypeError("reference material requires a manifest mapping")
|
|
84
|
+
if not isinstance(values, (list, tuple)) or not all(
|
|
85
|
+
isinstance(value, Mapping) for value in values
|
|
86
|
+
):
|
|
87
|
+
raise TypeError("reference_values must be a sequence of mappings")
|
|
88
|
+
if not isinstance(endorsements, (list, tuple)) or not all(
|
|
89
|
+
isinstance(value, Mapping) for value in endorsements
|
|
90
|
+
):
|
|
91
|
+
raise TypeError("endorsements must be a sequence of mappings")
|
|
92
|
+
|
|
93
|
+
db = database_from_context(ctx)
|
|
94
|
+
manifest_id = manifest.get("manifest_id")
|
|
95
|
+
if not manifest_id:
|
|
96
|
+
raise ValueError("reference manifest requires manifest_id")
|
|
97
|
+
manifest_record = await maybe_await(
|
|
98
|
+
AttestationReferenceManifest.handlers.create.core(
|
|
99
|
+
AttestationReferenceManifest, manifest, db
|
|
100
|
+
)
|
|
101
|
+
)
|
|
102
|
+
value_records = []
|
|
103
|
+
for value in values:
|
|
104
|
+
material = {"manifest_id": manifest_id, **dict(value)}
|
|
105
|
+
value_records.append(
|
|
106
|
+
await maybe_await(
|
|
107
|
+
AttestationReferenceValue.handlers.create.core(
|
|
108
|
+
AttestationReferenceValue, material, db
|
|
109
|
+
)
|
|
110
|
+
)
|
|
111
|
+
)
|
|
112
|
+
endorsement_records = []
|
|
113
|
+
for endorsement in endorsements:
|
|
114
|
+
endorsement_records.append(
|
|
115
|
+
await maybe_await(
|
|
116
|
+
AttestationEndorsement.handlers.create.core(
|
|
117
|
+
AttestationEndorsement, endorsement, db
|
|
118
|
+
)
|
|
119
|
+
)
|
|
120
|
+
)
|
|
121
|
+
return {
|
|
122
|
+
"manifest": manifest_record,
|
|
123
|
+
"reference_values": tuple(value_records),
|
|
124
|
+
"endorsements": tuple(endorsement_records),
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
__all__ = [
|
|
129
|
+
"make_attestation_appraisal_recorder",
|
|
130
|
+
"publish_reference_material",
|
|
131
|
+
"record_attestation_evidence",
|
|
132
|
+
"record_attestation_result",
|
|
133
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/specifications/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .attestation import *
|
tba_durability_attestation-0.4.0.dev2/src/tba_durability_attestation/specifications/attestation.py
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Attestation table aliases and executable runtime specifications."""
|
|
2
|
+
|
|
3
|
+
from tba_storage_attestation.tables import AttestationEvidence, AttestationReferenceManifest, AttestationResult
|
|
4
|
+
|
|
5
|
+
from tigrbl import deriveTableSpec
|
|
6
|
+
from tigrbl import makeOp
|
|
7
|
+
from tba_durability_attestation.operations.attestation import (
|
|
8
|
+
publish_reference_material,
|
|
9
|
+
record_attestation_evidence,
|
|
10
|
+
record_attestation_result,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
AttestationEvidenceTable = AttestationEvidence
|
|
14
|
+
AttestationResultTable = AttestationResult
|
|
15
|
+
AttestationReferenceManifestTable = AttestationReferenceManifest
|
|
16
|
+
|
|
17
|
+
AttestationEvidenceRuntimeSpec = deriveTableSpec(
|
|
18
|
+
AttestationEvidenceTable,
|
|
19
|
+
ops=(
|
|
20
|
+
makeOp(
|
|
21
|
+
extra={"owner_layer": "30-storage-runtime"},
|
|
22
|
+
expose_routes=False,
|
|
23
|
+
expose_rpc=False,
|
|
24
|
+
expose_method=True,
|
|
25
|
+
tx_scope="read_write",
|
|
26
|
+
alias="record_evidence",
|
|
27
|
+
handler=record_attestation_evidence,
|
|
28
|
+
),
|
|
29
|
+
),
|
|
30
|
+
)
|
|
31
|
+
AttestationResultRuntimeSpec = deriveTableSpec(
|
|
32
|
+
AttestationResultTable,
|
|
33
|
+
ops=(
|
|
34
|
+
makeOp(
|
|
35
|
+
extra={"owner_layer": "30-storage-runtime"},
|
|
36
|
+
expose_routes=False,
|
|
37
|
+
expose_rpc=False,
|
|
38
|
+
expose_method=True,
|
|
39
|
+
tx_scope="read_write",
|
|
40
|
+
alias="record_appraisal_result",
|
|
41
|
+
handler=record_attestation_result,
|
|
42
|
+
),
|
|
43
|
+
),
|
|
44
|
+
)
|
|
45
|
+
AttestationReferenceManifestRuntimeSpec = deriveTableSpec(
|
|
46
|
+
AttestationReferenceManifestTable,
|
|
47
|
+
ops=(
|
|
48
|
+
makeOp(
|
|
49
|
+
extra={"owner_layer": "30-storage-runtime"},
|
|
50
|
+
expose_routes=False,
|
|
51
|
+
expose_rpc=False,
|
|
52
|
+
expose_method=True,
|
|
53
|
+
tx_scope="read_write",
|
|
54
|
+
alias="publish_reference_material",
|
|
55
|
+
handler=publish_reference_material,
|
|
56
|
+
),
|
|
57
|
+
),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
__all__ = [
|
|
61
|
+
"AttestationEvidenceRuntimeSpec",
|
|
62
|
+
"AttestationEvidenceTable",
|
|
63
|
+
"AttestationReferenceManifestRuntimeSpec",
|
|
64
|
+
"AttestationReferenceManifestTable",
|
|
65
|
+
"AttestationResultRuntimeSpec",
|
|
66
|
+
"AttestationResultTable",
|
|
67
|
+
]
|