umf-access 0.1.0.dev8__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.
- umf_access/__init__.py +109 -0
- umf_access/adoption.py +41 -0
- umf_access/build/__init__.py +2 -0
- umf_access/build/approximate.py +34 -0
- umf_access/build/catalog.py +1626 -0
- umf_access/build/commands.py +394 -0
- umf_access/build/pg_privileges.py +1544 -0
- umf_access/build/privileges.py +134 -0
- umf_access/build/search.py +365 -0
- umf_access/build/unity_search.py +104 -0
- umf_access/bulk.py +227 -0
- umf_access/canonical.py +23 -0
- umf_access/capture.py +410 -0
- umf_access/catalog.py +325 -0
- umf_access/codec_support.py +427 -0
- umf_access/commands.py +93 -0
- umf_access/delta_read.py +758 -0
- umf_access/dsl/__init__.py +148 -0
- umf_access/dsl/_context.py +36 -0
- umf_access/dsl/_expressions.py +625 -0
- umf_access/dsl/_joined.py +4 -0
- umf_access/dsl/_nodes.py +207 -0
- umf_access/dsl/_query.py +5559 -0
- umf_access/dsl/_selection.py +143 -0
- umf_access/dsl/navigation.py +302 -0
- umf_access/dsl/render.py +516 -0
- umf_access/dsl/search.py +343 -0
- umf_access/engine_catalog.py +563 -0
- umf_access/generated_core.py +5 -0
- umf_access/lifecycle/__init__.py +46 -0
- umf_access/lifecycle/_darwin_process_observer.c +306 -0
- umf_access/lifecycle/approval.py +366 -0
- umf_access/lifecycle/backfills.py +79 -0
- umf_access/lifecycle/catalog.py +289 -0
- umf_access/lifecycle/cli.py +231 -0
- umf_access/lifecycle/concurrent.py +196 -0
- umf_access/lifecycle/conversion_policy.py +188 -0
- umf_access/lifecycle/correspondence.py +203 -0
- umf_access/lifecycle/generation_authority_bootstrap.py +1491 -0
- umf_access/lifecycle/generation_authority_session.py +125 -0
- umf_access/lifecycle/generation_enrollment_authority.py +1108 -0
- umf_access/lifecycle/generation_enrollment_ledger.py +698 -0
- umf_access/lifecycle/generation_ingress.py +185 -0
- umf_access/lifecycle/generation_root_registry.py +138 -0
- umf_access/lifecycle/head.py +250 -0
- umf_access/lifecycle/head_view.py +81 -0
- umf_access/lifecycle/host.py +1183 -0
- umf_access/lifecycle/ingress_custody.py +750 -0
- umf_access/lifecycle/ingress_local_postgres.py +7990 -0
- umf_access/lifecycle/ingress_store.py +1488 -0
- umf_access/lifecycle/ledger.py +276 -0
- umf_access/lifecycle/ledger_schema.py +116 -0
- umf_access/lifecycle/mixed.py +593 -0
- umf_access/lifecycle/outcome_schema.py +136 -0
- umf_access/lifecycle/owner_approval_core.py +1810 -0
- umf_access/lifecycle/owner_authority.py +472 -0
- umf_access/lifecycle/owner_bootstrap.py +2077 -0
- umf_access/lifecycle/owner_wire.py +161 -0
- umf_access/lifecycle/phase_fence.py +52 -0
- umf_access/lifecycle/phase_policy.py +422 -0
- umf_access/lifecycle/privileges.py +145 -0
- umf_access/lifecycle/probe.py +39 -0
- umf_access/lifecycle/progress.py +497 -0
- umf_access/lifecycle/roles.py +96 -0
- umf_access/lifecycle/row_originals.py +1712 -0
- umf_access/lifecycle/row_originals_creation.py +759 -0
- umf_access/lifecycle/row_originals_receipt.py +413 -0
- umf_access/lifecycle/seeds.py +99 -0
- umf_access/lifecycle/sql_containment.py +358 -0
- umf_access/lifecycle/sql_containment_cli.py +33 -0
- umf_access/lifecycle/sql_containment_parser.py +20 -0
- umf_access/lifecycle/supervisor_journal_codec.py +1251 -0
- umf_access/lifecycle/table_boundary.py +22 -0
- umf_access/lifecycle/target_custody_codec.py +788 -0
- umf_access/lifecycle/witness.py +72 -0
- umf_access/managed_actions.py +271 -0
- umf_access/managed_bulk.py +353 -0
- umf_access/managed_delta.py +150 -0
- umf_access/managed_support.py +166 -0
- umf_access/manifest_commands.py +278 -0
- umf_access/native_actions.py +1007 -0
- umf_access/native_program.py +570 -0
- umf_access/pages.py +125 -0
- umf_access/postgres_bulk.py +509 -0
- umf_access/postgres_read.py +1230 -0
- umf_access/postgres_search.py +639 -0
- umf_access/protocols.py +665 -0
- umf_access/py.typed +0 -0
- umf_access/related_keys.py +233 -0
- umf_access/reviewed.py +706 -0
- umf_access/search_catalog.py +122 -0
- umf_access/targets.py +312 -0
- umf_access/types.py +220 -0
- umf_access/unified/__init__.py +187 -0
- umf_access/unified/_binding.py +654 -0
- umf_access/unified/head_session.py +144 -0
- umf_access/unified/native_binding.py +143 -0
- umf_access/unified/operation_values.py +173 -0
- umf_access/unified/outcome_values.py +76 -0
- umf_access/unified/session_async.py +161 -0
- umf_access/unified/session_binding.py +108 -0
- umf_access/unified/session_policy.py +152 -0
- umf_access/unified/session_psycopg2.py +70 -0
- umf_access/unified/session_sqlalchemy.py +161 -0
- umf_access/unified/session_sync.py +148 -0
- umf_access/unified/table_reads.py +314 -0
- umf_access/unified/table_writes.py +193 -0
- umf_access/unity_search.py +312 -0
- umf_access/values.py +280 -0
- umf_access/verification.py +64 -0
- umf_access-0.1.0.dev8.dist-info/METADATA +15 -0
- umf_access-0.1.0.dev8.dist-info/RECORD +117 -0
- umf_access-0.1.0.dev8.dist-info/WHEEL +4 -0
- umf_access-0.1.0.dev8.dist-info/entry_points.txt +4 -0
- umf_access-0.1.0.dev8.dist-info/licenses/LICENSE-APACHE +201 -0
- umf_access-0.1.0.dev8.dist-info/licenses/LICENSE-MIT +21 -0
- umf_access-0.1.0.dev8.dist-info/licenses/LICENSE.md +239 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
"""Sync and async host bindings for the generated UMF access transport."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import inspect
|
|
6
|
+
from collections.abc import Awaitable, Callable, Mapping
|
|
7
|
+
|
|
8
|
+
from ._binding import UnifiedAccessError, _TableBinding
|
|
9
|
+
from .head_session import (
|
|
10
|
+
observe_table_head,
|
|
11
|
+
observe_table_head_async,
|
|
12
|
+
verify_table_correspondence,
|
|
13
|
+
verify_table_correspondence_async,
|
|
14
|
+
)
|
|
15
|
+
from .native_binding import NativeTableBinding, SyncNativeTableBinding
|
|
16
|
+
from .session_async import AsyncSession
|
|
17
|
+
from .session_policy import SessionError, SessionIdentity, SessionPolicy
|
|
18
|
+
from .session_psycopg2 import Psycopg2Session
|
|
19
|
+
from .session_sqlalchemy import AsyncSQLAlchemySession, SQLAlchemySession
|
|
20
|
+
from .session_sync import SyncSession
|
|
21
|
+
from .table_reads import AsyncTableReader, SyncTableReader
|
|
22
|
+
from .table_writes import AsyncTableWriter, SyncTableWriter, WriteOutcomeUnknown
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class WeftTableBinding(_TableBinding):
|
|
26
|
+
"""Async Weft compiler binding with host-owned execution callbacks."""
|
|
27
|
+
|
|
28
|
+
def __init__(
|
|
29
|
+
self,
|
|
30
|
+
binding: Mapping[str, object],
|
|
31
|
+
compiler: object,
|
|
32
|
+
execute: Callable[[Mapping[str, object], Mapping[str, object]], Awaitable[Mapping[str, object]]],
|
|
33
|
+
*,
|
|
34
|
+
target: str,
|
|
35
|
+
action_executor: Callable[[str, Mapping[str, object], str | None], Awaitable[Mapping[str, object]]] | None = None,
|
|
36
|
+
at_least: Callable[[str], Awaitable[bool]] | None = None,
|
|
37
|
+
page_size: int = 100,
|
|
38
|
+
cursor_secret: bytes | None = None,
|
|
39
|
+
) -> None:
|
|
40
|
+
super().__init__(binding, compiler, target=target,
|
|
41
|
+
page_size=page_size, cursor_secret=cursor_secret)
|
|
42
|
+
self._execute = execute
|
|
43
|
+
self._action_executor = action_executor
|
|
44
|
+
self._at_least = at_least
|
|
45
|
+
|
|
46
|
+
async def execute(self, request: Mapping[str, object]) -> Mapping[str, object]:
|
|
47
|
+
"""Execute one generated request; all failures use the shared response shape."""
|
|
48
|
+
if not isinstance(request, Mapping):
|
|
49
|
+
return UnifiedAccessError("INVALID", "request object required").as_response(self.schema)
|
|
50
|
+
try:
|
|
51
|
+
kind = self._check_request(request)
|
|
52
|
+
if kind == "apply":
|
|
53
|
+
return await self._apply(request)
|
|
54
|
+
return await self._read(request)
|
|
55
|
+
except UnifiedAccessError as error:
|
|
56
|
+
return error.as_response(self.schema)
|
|
57
|
+
|
|
58
|
+
async def _read(self, request: Mapping[str, object]) -> Mapping[str, object]:
|
|
59
|
+
freshness = request.get("at_least")
|
|
60
|
+
if freshness is not None:
|
|
61
|
+
if type(freshness) is not str:
|
|
62
|
+
raise UnifiedAccessError("INVALID", "freshness token must be text")
|
|
63
|
+
if self._at_least is None:
|
|
64
|
+
raise UnifiedAccessError("UNSUPPORTED", "host cannot establish requested freshness")
|
|
65
|
+
if not await self._at_least(freshness):
|
|
66
|
+
raise UnifiedAccessError("NOT_YET_CURRENT", "requested freshness was not established")
|
|
67
|
+
artifact, host_request, query, size, cursor_scope = self._prepare_read(request)
|
|
68
|
+
try:
|
|
69
|
+
response = await self._execute(artifact, host_request)
|
|
70
|
+
except UnifiedAccessError:
|
|
71
|
+
raise
|
|
72
|
+
except Exception: # noqa: BLE001 -- sanitize executor errors
|
|
73
|
+
raise UnifiedAccessError("BUSY", "host read execution failed") from None
|
|
74
|
+
return self._finish_read(response, query, size, cursor_scope)
|
|
75
|
+
|
|
76
|
+
async def _apply(self, request: Mapping[str, object]) -> Mapping[str, object]:
|
|
77
|
+
if self._action_executor is None:
|
|
78
|
+
raise UnifiedAccessError("UNSUPPORTED", "host has no trusted action executor")
|
|
79
|
+
action, inputs, key = self._prepare_action(request)
|
|
80
|
+
try:
|
|
81
|
+
response = await self._action_executor(action, inputs, key)
|
|
82
|
+
except UnifiedAccessError:
|
|
83
|
+
raise
|
|
84
|
+
except Exception: # noqa: BLE001 -- no retry after dispatch
|
|
85
|
+
raise UnifiedAccessError("WRITE_OUTCOME_UNKNOWN", "action response was lost after dispatch") from None
|
|
86
|
+
return self._finish_action(response)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def _sync_result(value):
|
|
90
|
+
if inspect.isawaitable(value):
|
|
91
|
+
if inspect.iscoroutine(value):
|
|
92
|
+
value.close()
|
|
93
|
+
raise UnifiedAccessError("INVALID", "synchronous callback returned an awaitable")
|
|
94
|
+
return value
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class SyncWeftTableBinding(_TableBinding):
|
|
98
|
+
"""Synchronous Weft binding; never runs an event loop."""
|
|
99
|
+
|
|
100
|
+
def __init__(
|
|
101
|
+
self,
|
|
102
|
+
binding: Mapping[str, object],
|
|
103
|
+
compiler: object,
|
|
104
|
+
execute: Callable[[Mapping[str, object], Mapping[str, object]], Mapping[str, object]],
|
|
105
|
+
*,
|
|
106
|
+
target: str,
|
|
107
|
+
action_executor: Callable[[str, Mapping[str, object], str | None], Mapping[str, object]] | None = None,
|
|
108
|
+
at_least: Callable[[str], bool] | None = None,
|
|
109
|
+
page_size: int = 100,
|
|
110
|
+
cursor_secret: bytes | None = None,
|
|
111
|
+
) -> None:
|
|
112
|
+
if any(inspect.iscoroutinefunction(callback) or inspect.iscoroutinefunction(getattr(callback, "__call__", None)) # noqa: B004 -- inspect async __call__, not callability
|
|
113
|
+
for callback in (execute, action_executor, at_least)):
|
|
114
|
+
raise TypeError("synchronous callbacks required")
|
|
115
|
+
super().__init__(binding, compiler, target=target,
|
|
116
|
+
page_size=page_size, cursor_secret=cursor_secret)
|
|
117
|
+
self._execute = execute
|
|
118
|
+
self._action_executor = action_executor
|
|
119
|
+
self._at_least = at_least
|
|
120
|
+
|
|
121
|
+
def execute(self, request: Mapping[str, object]) -> Mapping[str, object]:
|
|
122
|
+
"""Execute one generated request; all failures use the shared response shape."""
|
|
123
|
+
if not isinstance(request, Mapping):
|
|
124
|
+
return UnifiedAccessError("INVALID", "request object required").as_response(self.schema)
|
|
125
|
+
try:
|
|
126
|
+
kind = self._check_request(request)
|
|
127
|
+
if kind == "apply":
|
|
128
|
+
return self._apply(request)
|
|
129
|
+
return self._read(request)
|
|
130
|
+
except UnifiedAccessError as error:
|
|
131
|
+
return error.as_response(self.schema)
|
|
132
|
+
|
|
133
|
+
def _read(self, request: Mapping[str, object]) -> Mapping[str, object]:
|
|
134
|
+
freshness = request.get("at_least")
|
|
135
|
+
if freshness is not None:
|
|
136
|
+
if type(freshness) is not str:
|
|
137
|
+
raise UnifiedAccessError("INVALID", "freshness token must be text")
|
|
138
|
+
if self._at_least is None:
|
|
139
|
+
raise UnifiedAccessError("UNSUPPORTED", "host cannot establish requested freshness")
|
|
140
|
+
if not _sync_result(self._at_least(freshness)):
|
|
141
|
+
raise UnifiedAccessError("NOT_YET_CURRENT", "requested freshness was not established")
|
|
142
|
+
artifact, host_request, query, size, cursor_scope = self._prepare_read(request)
|
|
143
|
+
try:
|
|
144
|
+
response = _sync_result(self._execute(artifact, host_request))
|
|
145
|
+
except UnifiedAccessError:
|
|
146
|
+
raise
|
|
147
|
+
except Exception: # noqa: BLE001 -- sanitize executor errors
|
|
148
|
+
raise UnifiedAccessError("BUSY", "host read execution failed") from None
|
|
149
|
+
return self._finish_read(response, query, size, cursor_scope)
|
|
150
|
+
|
|
151
|
+
def _apply(self, request: Mapping[str, object]) -> Mapping[str, object]:
|
|
152
|
+
if self._action_executor is None:
|
|
153
|
+
raise UnifiedAccessError("UNSUPPORTED", "host has no trusted action executor")
|
|
154
|
+
action, inputs, key = self._prepare_action(request)
|
|
155
|
+
try:
|
|
156
|
+
response = _sync_result(self._action_executor(action, inputs, key))
|
|
157
|
+
except UnifiedAccessError:
|
|
158
|
+
raise
|
|
159
|
+
except Exception: # noqa: BLE001 -- no retry after dispatch
|
|
160
|
+
raise UnifiedAccessError("WRITE_OUTCOME_UNKNOWN", "action response was lost after dispatch") from None
|
|
161
|
+
return self._finish_action(response)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
__all__ = [
|
|
165
|
+
"AsyncSQLAlchemySession",
|
|
166
|
+
"AsyncSession",
|
|
167
|
+
"AsyncTableReader",
|
|
168
|
+
"AsyncTableWriter",
|
|
169
|
+
"NativeTableBinding",
|
|
170
|
+
"Psycopg2Session",
|
|
171
|
+
"SQLAlchemySession",
|
|
172
|
+
"SessionError",
|
|
173
|
+
"SessionIdentity",
|
|
174
|
+
"SessionPolicy",
|
|
175
|
+
"SyncNativeTableBinding",
|
|
176
|
+
"SyncSession",
|
|
177
|
+
"SyncTableReader",
|
|
178
|
+
"SyncTableWriter",
|
|
179
|
+
"SyncWeftTableBinding",
|
|
180
|
+
"UnifiedAccessError",
|
|
181
|
+
"WeftTableBinding",
|
|
182
|
+
"WriteOutcomeUnknown",
|
|
183
|
+
"observe_table_head",
|
|
184
|
+
"observe_table_head_async",
|
|
185
|
+
"verify_table_correspondence",
|
|
186
|
+
"verify_table_correspondence_async",
|
|
187
|
+
]
|