tigrbl-ops-ltap 0.4.6.dev1__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.
@@ -0,0 +1,13 @@
1
+ from .contracts import AccessScope, RegisteredTableProvider
2
+ from .resources import LtapTable, TableSnapshot, operation_input
3
+ from .service import CursorStore, LtapService
4
+
5
+ __all__ = [
6
+ "AccessScope",
7
+ "CursorStore",
8
+ "LtapService",
9
+ "LtapTable",
10
+ "RegisteredTableProvider",
11
+ "TableSnapshot",
12
+ "operation_input",
13
+ ]
@@ -0,0 +1,126 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass
4
+ from datetime import datetime
5
+ from typing import Annotated, Protocol
6
+
7
+ from pydantic import BaseModel, ConfigDict, Field, JsonValue
8
+ from tigrbl_core._spec.engine_op_capabilities import (
9
+ EngineOpBinding,
10
+ EngineOpRequirement,
11
+ )
12
+ from tigrbl_core._spec.engine_spec import EngineSpec
13
+
14
+ Key = int | str
15
+ Selector = Annotated[str, Field(min_length=1, max_length=128)]
16
+ PageSize = Annotated[int, Field(ge=1, le=100)]
17
+
18
+
19
+ class Request(BaseModel):
20
+ model_config = ConfigDict(extra="forbid")
21
+
22
+
23
+ class SnapshotLookup(Request):
24
+ table_id: Selector
25
+ snapshot_id: Selector | None = None
26
+
27
+
28
+ class SnapshotList(Request):
29
+ table_id: Selector
30
+ page_size: PageSize = 50
31
+ cursor: Selector | None = None
32
+
33
+
34
+ class RowLookup(Request):
35
+ item_id: Selector
36
+ as_of_snapshot: Selector | None = None
37
+
38
+
39
+ class RowList(Request):
40
+ as_of_snapshot: Selector | None = None
41
+ page_size: PageSize = 50
42
+ cursor: Selector | None = None
43
+
44
+
45
+ class Snapshot(BaseModel):
46
+ snapshot_id: str
47
+ committed_at: datetime
48
+ parent_snapshot_id: str | None = None
49
+
50
+
51
+ class SnapshotPage(BaseModel):
52
+ items: list[Snapshot]
53
+ cursor: str | None = None
54
+
55
+
56
+ class RowResult(BaseModel):
57
+ snapshot_id: str
58
+ item: dict[str, JsonValue]
59
+
60
+
61
+ class RowPage(BaseModel):
62
+ snapshot_id: str | None
63
+ items: list[dict[str, JsonValue]]
64
+ cursor: str | None = None
65
+
66
+
67
+ @dataclass(frozen=True)
68
+ class AccessScope:
69
+ """Server-issued scope. Equalities and columns are the complete row policy."""
70
+
71
+ tenant: str
72
+ principal: str
73
+ columns: tuple[str, ...] = ()
74
+ equalities: tuple[tuple[str, Key], ...] = ()
75
+
76
+
77
+ @dataclass(frozen=True)
78
+ class HistoryView:
79
+ table_identity: str
80
+ revision: str
81
+ items: tuple[Snapshot, ...]
82
+
83
+
84
+ @dataclass(frozen=True)
85
+ class PinnedRows:
86
+ table_identity: str
87
+ snapshot_id: str | None
88
+ rows: tuple[tuple[Key, dict[str, JsonValue]], ...]
89
+
90
+
91
+ class Provider(Protocol):
92
+ def operation_bindings(self) -> tuple[EngineOpBinding, ...]: ...
93
+
94
+
95
+ @dataclass(frozen=True)
96
+ class RegisteredTableProvider:
97
+ engine: EngineSpec
98
+ table: str
99
+
100
+ def operation_bindings(self) -> tuple[EngineOpBinding, ...]:
101
+ return self.engine.operation_bindings(table=self.table)
102
+
103
+
104
+ LIST_SNAPSHOTS = EngineOpRequirement(
105
+ "ltap.list_snapshots", "1.0.0", ("immutable_history",)
106
+ )
107
+ GET_SNAPSHOT = EngineOpRequirement("ltap.get_snapshot", "1.0.0")
108
+ READ_AT_SNAPSHOT = EngineOpRequirement(
109
+ "ltap.read_at_snapshot", "1.0.0", ("row_policy",)
110
+ )
111
+ LIST_AT_SNAPSHOT = EngineOpRequirement(
112
+ "ltap.list_at_snapshot", "1.0.0", ("stable_key_order", "row_policy")
113
+ )
114
+ REQUIREMENTS = (LIST_SNAPSHOTS, GET_SNAPSHOT, READ_AT_SNAPSHOT, LIST_AT_SNAPSHOT)
115
+
116
+
117
+ class SnapshotMissing(Exception):
118
+ """The requested snapshot, table or row is unavailable."""
119
+
120
+
121
+ class ViewUnavailable(Exception):
122
+ """The provider cannot honor a pinned continuation."""
123
+
124
+
125
+ class ReadBudgetExceeded(Exception):
126
+ """A bounded read could not finish."""
@@ -0,0 +1,168 @@
1
+ from __future__ import annotations
2
+
3
+ from collections.abc import Mapping
4
+
5
+ from pydantic import BaseModel, ValidationError
6
+ from tigrbl_core._spec import (
7
+ HttpJsonRpcBindingSpec,
8
+ HttpRestBindingSpec,
9
+ OpSpec,
10
+ TableProfileSpec,
11
+ )
12
+ from tigrbl_core._spec.operation_security import OperationSecurity
13
+ from tigrbl_typing.status.exceptions import HTTPException
14
+
15
+ from .contracts import (
16
+ GET_SNAPSHOT,
17
+ LIST_AT_SNAPSHOT,
18
+ LIST_SNAPSHOTS,
19
+ READ_AT_SNAPSHOT,
20
+ RowList,
21
+ RowLookup,
22
+ RowPage,
23
+ RowResult,
24
+ Snapshot,
25
+ SnapshotList,
26
+ SnapshotLookup,
27
+ SnapshotPage,
28
+ )
29
+ from .service import LtapService
30
+
31
+
32
+ def operation_input(schema: type[BaseModel], ctx):
33
+ """Normalize the same coordinates for handlers and app authorization."""
34
+ payload = ctx.get("payload")
35
+ values = (
36
+ payload.model_dump(exclude_unset=True)
37
+ if isinstance(payload, BaseModel)
38
+ else payload
39
+ )
40
+ if values is not None and not isinstance(values, Mapping):
41
+ raise HTTPException(status_code=400, detail="Invalid LTAP request")
42
+ values = dict(values or {})
43
+ carrier = ctx.get("request")
44
+ rest_query = (
45
+ getattr(carrier, "query_params", {})
46
+ if getattr(carrier, "method", None) == "GET"
47
+ else {}
48
+ )
49
+ for source in (rest_query, ctx.get("query_params"), ctx.get("path_params")):
50
+ for key, value in (source or {}).items():
51
+ if key in values and str(values[key]) != str(value):
52
+ raise HTTPException(
53
+ status_code=400, detail="Conflicting LTAP parameters"
54
+ )
55
+ values[key] = value
56
+ try:
57
+ return schema.model_validate(values)
58
+ except ValidationError as exc:
59
+ raise HTTPException(status_code=400, detail="Invalid LTAP request") from exc
60
+
61
+
62
+ def _operation(
63
+ service, name, namespace, alias, requirement, paths, request, result, table
64
+ ):
65
+ async def handle(ctx):
66
+ payload = operation_input(request, ctx)
67
+ response = await service.execute(requirement, payload, ctx, table=table)
68
+ return response.model_dump(mode="json")
69
+
70
+ bindings = tuple(HttpRestBindingSpec("http.rest", ("GET",), path) for path in paths)
71
+ return OpSpec(
72
+ alias=alias,
73
+ target="custom",
74
+ handler=handle,
75
+ arity="collection",
76
+ tx_scope="none",
77
+ persist="skip",
78
+ request_model=request,
79
+ response_model=result,
80
+ security=OperationSecurity(f"{namespace}.{name.lower()}.{alias}", "ltap_table"),
81
+ engine_requirements=(requirement,),
82
+ bindings=(*bindings, HttpJsonRpcBindingSpec("http.jsonrpc", f"{name}.{alias}")),
83
+ )
84
+
85
+
86
+ def _resource(base, name, namespace, ops):
87
+ profile = TableProfileSpec(
88
+ kind=f"{namespace}.{base.__name__.lower()}",
89
+ namespace=namespace,
90
+ custom=True,
91
+ role="concrete",
92
+ docs_exposure="declared",
93
+ runtime_exposure="declared",
94
+ ops=ops,
95
+ )
96
+ return type(
97
+ name, (base,), {"TABLE_PROFILE": profile, "__module__": base.__module__}
98
+ )
99
+
100
+
101
+ class LtapTable:
102
+ @classmethod
103
+ def bind(
104
+ cls,
105
+ service: LtapService,
106
+ *,
107
+ table_id: str,
108
+ name: str,
109
+ path: str,
110
+ namespace="ltap",
111
+ ):
112
+ service.require_table(table_id)
113
+ operations = (
114
+ _operation(
115
+ service,
116
+ name,
117
+ namespace,
118
+ "read",
119
+ READ_AT_SNAPSHOT,
120
+ (path + "/{item_id}",),
121
+ RowLookup,
122
+ RowResult,
123
+ table_id,
124
+ ),
125
+ _operation(
126
+ service,
127
+ name,
128
+ namespace,
129
+ "list",
130
+ LIST_AT_SNAPSHOT,
131
+ (path,),
132
+ RowList,
133
+ RowPage,
134
+ table_id,
135
+ ),
136
+ )
137
+ return _resource(cls, name, namespace, operations)
138
+
139
+
140
+ class TableSnapshot:
141
+ @classmethod
142
+ def bind(cls, service: LtapService, *, name="TableSnapshot", namespace="ltap"):
143
+ root = "/tables/{table_id}/snapshots"
144
+ operations = (
145
+ _operation(
146
+ service,
147
+ name,
148
+ namespace,
149
+ "list",
150
+ LIST_SNAPSHOTS,
151
+ (root,),
152
+ SnapshotList,
153
+ SnapshotPage,
154
+ None,
155
+ ),
156
+ _operation(
157
+ service,
158
+ name,
159
+ namespace,
160
+ "read",
161
+ GET_SNAPSHOT,
162
+ (root + "/{snapshot_id}", root + "/_ops/current"),
163
+ SnapshotLookup,
164
+ Snapshot,
165
+ None,
166
+ ),
167
+ )
168
+ return _resource(cls, name, namespace, operations)
@@ -0,0 +1,225 @@
1
+ from __future__ import annotations
2
+
3
+ from asyncio import to_thread
4
+ from collections import OrderedDict
5
+ from collections.abc import Callable, Mapping
6
+ from dataclasses import dataclass, replace
7
+ from inspect import isawaitable
8
+ from secrets import token_urlsafe
9
+ from threading import Lock
10
+ from time import monotonic
11
+
12
+ from tigrbl_core._spec.engine_op_capabilities import require_engine_operation
13
+ from tigrbl_typing.status.exceptions import HTTPException
14
+
15
+ from .contracts import (
16
+ REQUIREMENTS,
17
+ AccessScope,
18
+ Provider,
19
+ ReadBudgetExceeded,
20
+ RowList,
21
+ RowLookup,
22
+ RowPage,
23
+ RowResult,
24
+ SnapshotList,
25
+ SnapshotLookup,
26
+ SnapshotMissing,
27
+ SnapshotPage,
28
+ ViewUnavailable,
29
+ )
30
+
31
+
32
+ @dataclass(frozen=True)
33
+ class Continuation:
34
+ operation: str
35
+ table: str
36
+ scope: AccessScope
37
+ size: int
38
+ identity: str
39
+ pin: str
40
+ after: tuple | int | str
41
+
42
+
43
+ class CursorStore:
44
+ """A bounded in-process default store for opaque pagination tokens."""
45
+
46
+ def __init__(self, *, ttl: float = 300, capacity: int = 1024):
47
+ if ttl <= 0 or capacity <= 0:
48
+ raise ValueError("Cursor lifetime and capacity must be positive")
49
+ self._ttl = ttl
50
+ self._capacity = capacity
51
+ self._entries: OrderedDict[str, tuple[float, Continuation]] = OrderedDict()
52
+ self._lock = Lock()
53
+
54
+ def issue(self, continuation: Continuation) -> str:
55
+ token = token_urlsafe(32)
56
+ now = monotonic()
57
+ with self._lock:
58
+ self._prune(now)
59
+ if len(self._entries) >= self._capacity:
60
+ self._entries.popitem(last=False)
61
+ self._entries[token] = (now + self._ttl, continuation)
62
+ return token
63
+
64
+ def get(self, token: str) -> Continuation:
65
+ with self._lock:
66
+ self._prune(monotonic())
67
+ entry = self._entries.get(token)
68
+ if entry is None:
69
+ raise ViewUnavailable
70
+ return entry[1]
71
+
72
+ def _prune(self, now: float) -> None:
73
+ while self._entries and next(iter(self._entries.values()))[0] <= now:
74
+ self._entries.popitem(last=False)
75
+
76
+
77
+ class LtapService:
78
+ def __init__(
79
+ self,
80
+ tables: Mapping[str, Provider],
81
+ scope: Callable,
82
+ *,
83
+ cursors: CursorStore | None = None,
84
+ ):
85
+ self._scope = scope
86
+ self._cursors = cursors if cursors is not None else CursorStore()
87
+ self._handlers = {}
88
+ for table, provider in tables.items():
89
+ bindings = provider.operation_bindings()
90
+ self._handlers[table] = {
91
+ item.capability_id: require_engine_operation(bindings, item)
92
+ for item in REQUIREMENTS
93
+ }
94
+
95
+ def require_table(self, table: str) -> None:
96
+ if table not in self._handlers:
97
+ raise ValueError("LTAP resource requires a configured table provider")
98
+
99
+ async def execute(self, requirement, request, ctx, *, table: str | None = None):
100
+ if table is None:
101
+ table = request.table_id
102
+ action = requirement.capability_id
103
+ principal = ctx.get("auth_context")
104
+ if principal is None:
105
+ raise HTTPException(status_code=401, detail="Authentication required")
106
+ scope = self._scope(principal, action, table, request)
107
+ if isawaitable(scope):
108
+ scope = await scope
109
+ if (
110
+ not isinstance(scope, AccessScope)
111
+ or not scope.tenant
112
+ or not scope.principal
113
+ ):
114
+ raise HTTPException(status_code=403, detail="Operation forbidden")
115
+
116
+ try:
117
+ handler = self._handlers.get(table, {}).get(action)
118
+ if handler is None:
119
+ raise SnapshotMissing
120
+ if isinstance(request, SnapshotLookup):
121
+ return await to_thread(handler, request.snapshot_id)
122
+ if isinstance(request, RowLookup):
123
+ pinned = await to_thread(
124
+ handler, request.as_of_snapshot, scope, request.item_id
125
+ )
126
+ if not pinned.rows:
127
+ raise SnapshotMissing
128
+ return RowResult(snapshot_id=pinned.snapshot_id, item=pinned.rows[0][1])
129
+
130
+ cursor = self._continuation(request, table, action, scope)
131
+ if isinstance(request, SnapshotList):
132
+ return await self._history(
133
+ handler, request, table, action, scope, cursor
134
+ )
135
+ return await self._rows(handler, request, table, action, scope, cursor)
136
+ except SnapshotMissing as exc:
137
+ if getattr(request, "cursor", None):
138
+ raise HTTPException(
139
+ status_code=409, detail="Continuation unavailable"
140
+ ) from exc
141
+ raise HTTPException(
142
+ status_code=404, detail="LTAP resource unavailable"
143
+ ) from exc
144
+ except ViewUnavailable as exc:
145
+ raise HTTPException(
146
+ status_code=409, detail="Continuation unavailable"
147
+ ) from exc
148
+ except ReadBudgetExceeded as exc:
149
+ raise HTTPException(
150
+ status_code=503, detail="LTAP read budget exceeded"
151
+ ) from exc
152
+
153
+ def _continuation(self, request, table, action, scope):
154
+ if request.cursor is None:
155
+ return None
156
+ cursor = self._cursors.get(request.cursor)
157
+ if cursor != replace(
158
+ cursor, operation=action, table=table, scope=scope, size=request.page_size
159
+ ):
160
+ raise ViewUnavailable
161
+ if isinstance(request, RowList) and request.as_of_snapshot not in (
162
+ None,
163
+ cursor.pin,
164
+ ):
165
+ raise HTTPException(
166
+ status_code=400, detail="Selector conflicts with continuation"
167
+ )
168
+ return cursor
169
+
170
+ async def _history(self, handler, request, table, action, scope, cursor):
171
+ view = await to_thread(handler, cursor.pin if cursor else None)
172
+ if cursor and cursor.identity != view.table_identity:
173
+ raise ViewUnavailable
174
+ key = lambda snapshot: (snapshot.committed_at, snapshot.snapshot_id)
175
+ ordered = sorted(view.items, key=key, reverse=True)
176
+ if cursor:
177
+ ordered = [item for item in ordered if key(item) < cursor.after]
178
+ items = ordered[: request.page_size]
179
+ token = None
180
+ if len(ordered) > request.page_size:
181
+ token = self._cursors.issue(
182
+ Continuation(
183
+ action,
184
+ table,
185
+ scope,
186
+ request.page_size,
187
+ view.table_identity,
188
+ view.revision,
189
+ key(items[-1]),
190
+ )
191
+ )
192
+ return SnapshotPage(items=items, cursor=token)
193
+
194
+ async def _rows(self, handler, request, table, action, scope, cursor):
195
+ pin = cursor.pin if cursor else request.as_of_snapshot
196
+ view = await to_thread(
197
+ handler,
198
+ pin,
199
+ scope,
200
+ cursor.after if cursor else None,
201
+ request.page_size + 1,
202
+ cursor.identity if cursor else None,
203
+ )
204
+ if cursor and (cursor.identity, cursor.pin) != (
205
+ view.table_identity,
206
+ view.snapshot_id,
207
+ ):
208
+ raise ViewUnavailable
209
+ items = view.rows[: request.page_size]
210
+ token = None
211
+ if len(view.rows) > request.page_size:
212
+ token = self._cursors.issue(
213
+ Continuation(
214
+ action,
215
+ table,
216
+ scope,
217
+ request.page_size,
218
+ view.table_identity,
219
+ view.snapshot_id,
220
+ items[-1][0],
221
+ )
222
+ )
223
+ return RowPage(
224
+ snapshot_id=view.snapshot_id, items=[row for _, row in items], cursor=token
225
+ )
@@ -0,0 +1,327 @@
1
+ Metadata-Version: 2.5
2
+ Name: tigrbl-ops-ltap
3
+ Version: 0.4.6.dev1
4
+ Summary: Read-only lake table and snapshot operations for Tigrbl
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ License-File: NOTICE
8
+ Requires-Python: <3.15,>=3.10
9
+ Requires-Dist: pydantic<3,>=2.10
10
+ Requires-Dist: tigrbl-core>=0.4.6.dev5
11
+ Requires-Dist: tigrbl-typing
12
+ Description-Content-Type: text/markdown
13
+
14
+ # tigrbl-ops-ltap
15
+
16
+ <!-- readme-standards:begin branding -->
17
+ <p align="center"><a href="https://github.com/tigrbl/tigrbl"><img src="https://raw.githubusercontent.com/tigrbl/tigrbl/master/assets/tigrbl.brand.theme.svg" alt="Tigrbl" width="300"></a></p>
18
+ <p align="center"><strong>tigrbl-ops-ltap</strong></p>
19
+ <p align="center">Read-only lake table and snapshot operations for Tigrbl</p>
20
+ <p align="center">
21
+ <a href="https://pypi.org/project/tigrbl-ops-ltap/"><img alt="pypi: tigrbl-ops-ltap unpublished" src="https://img.shields.io/static/v1?label=pypi&amp;message=tigrbl-ops-ltap%20unpublished&amp;labelColor=1E293B&amp;color=92400E"></a>
22
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/pyproject.toml"><img alt="Source version: 0.4.6.dev1" src="https://img.shields.io/static/v1?label=Source%20version&amp;message=0.4.6.dev1&amp;labelColor=1E293B&amp;color=4338CA"></a>
23
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/pyproject.toml"><img alt="Python: &gt;=3.10,&lt;3.15" src="https://img.shields.io/static/v1?label=Python&amp;message=%3E%3D3.10%2C%3C3.15&amp;labelColor=1E293B&amp;color=0F766E"></a>
24
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/pyproject.toml"><img alt="Layer: 060_ops" src="https://img.shields.io/static/v1?label=Layer&amp;message=060_ops&amp;labelColor=1E293B&amp;color=6D28D9"></a>
25
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/README.md#lifecycle-and-migration"><img alt="Lifecycle: active" src="https://img.shields.io/static/v1?label=Lifecycle&amp;message=active&amp;labelColor=1E293B&amp;color=166534"></a>
26
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/LICENSE"><img alt="License: Apache-2.0" src="https://img.shields.io/static/v1?label=License&amp;message=Apache-2.0&amp;labelColor=1E293B&amp;color=86198F"></a>
27
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/NOTICE"><img alt="Notice: attribution" src="https://img.shields.io/static/v1?label=Notice&amp;message=attribution&amp;labelColor=1E293B&amp;color=86198F"></a>
28
+ </p>
29
+ <p align="center">
30
+ <a href="https://pypi.org/project/tigrbl-ops-ltap/"><img alt="pypi downloads: tigrbl-ops-ltap: unpublished" src="https://img.shields.io/static/v1?label=pypi%20downloads&amp;message=tigrbl-ops-ltap%3A%20unpublished&amp;labelColor=1E293B&amp;color=92400E"></a>
31
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/README.md"><img alt="README hits: tigrbl-ops-ltap" src="https://hits.sh/github.com/tigrbl/tigrbl/pkgs/060_ops/tigrbl_ops_ltap/README.md.svg?label=README%20hits&amp;labelColor=1E293B&amp;color=0E7490"></a>
32
+ </p>
33
+ <p align="center">
34
+ <a href="https://github.com/tigrbl/tigrbl/actions/workflows/readme-standards.yml"><img alt="README standards: CI gate" src="https://img.shields.io/static/v1?label=README%20standards&amp;message=CI%20gate&amp;labelColor=1E293B&amp;color=1D4ED8"></a>
35
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/docs/readme/test_examples.py"><img alt="Tests: pytest suite" src="https://img.shields.io/static/v1?label=Tests&amp;message=pytest%20suite&amp;labelColor=1E293B&amp;color=0F766E"></a>
36
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/README.md#certification-status"><img alt="Certification: not certified" src="https://img.shields.io/static/v1?label=Certification&amp;message=not%20certified&amp;labelColor=1E293B&amp;color=92400E"></a>
37
+ <a href="https://github.com/tigrbl/tigrbl/blob/master/tools/readme/POLICY.md"><img alt="Governance: repository policy" src="https://img.shields.io/static/v1?label=Governance&amp;message=repository%20policy&amp;labelColor=1E293B&amp;color=4338CA"></a>
38
+ <a href="https://github.com/tigrbl/tigrbl/actions/workflows/readme-standards.yml"><img alt="Evidence: source and CI" src="https://img.shields.io/static/v1?label=Evidence&amp;message=source%20and%20CI&amp;labelColor=1E293B&amp;color=6D28D9"></a>
39
+ </p>
40
+ <p align="center"><a href="#overview">Overview</a> · <a href="#installation">Installation</a> · <a href="#quick-start">Quick Start</a> · <a href="#usage">Usage</a> · <a href="#public-api-and-import-surfaces">API</a> · <a href="#contributing">Contributing</a> · <a href="#governance">Governance</a> · <a href="#license">License</a></p>
41
+ <!-- readme-standards:end branding -->
42
+
43
+ ---
44
+
45
+ ## Overview
46
+
47
+ ### Summary
48
+
49
+ Use an LTAP provider to expose a catalog-backed snapshot list, snapshot lookup,
50
+ and snapshot-pinned row reads. Configure an explicit table inventory, a scope
51
+ resolver and an application operation authorizer. All bindings are read-only.
52
+
53
+ Create a resource with `LtapTable.bind(service, table_id="orders", name="Order",
54
+ path="/orders")` and mount it with `app.include_table`. Mount one
55
+ `TableSnapshot.bind(service)` resource for the shared inventory. Configure
56
+ JSON-RPC on the same application to publish the matching methods.
57
+
58
+ The scope resolver receives the authenticated principal, semantic capability ID,
59
+ public table ID, and validated request. Return an `AccessScope` with the
60
+ effective column projection and row equalities, or deny the action. Data lists
61
+ can pin a historical snapshot across pages and require the corresponding history
62
+ permission. The default cursor store is bounded and local to the application
63
+ process. Use the same store for all requests in a paged result.
64
+
65
+ ### Why This Package
66
+
67
+ Share one versioned provider contract across data and catalog resources.
68
+
69
+ ### When to Use
70
+
71
+ Use it for applications that serve historical row reads and snapshot metadata backed by a versioned catalog.
72
+
73
+ ### Features
74
+
75
+ List and look up snapshots, pin reads and pages to a snapshot, and mount matching REST and JSON-RPC operations.
76
+
77
+ ### Non-Goals
78
+
79
+ Write and maintenance operations are outside the read-only scope.
80
+
81
+ ---
82
+
83
+ ## Getting Started
84
+
85
+ ### Prerequisites
86
+
87
+ Use Python 3.10 through 3.14 and synchronize dependencies from the workspace root.
88
+
89
+ ### Installation
90
+
91
+ #### uv
92
+
93
+ <!-- readme-standards:begin installation.uv -->
94
+ `tigrbl-ops-ltap` is not declared published. From the source checkout:
95
+
96
+ ```bash
97
+ uv pip install .
98
+ ```
99
+ <!-- readme-standards:end installation.uv -->
100
+
101
+ #### pip
102
+
103
+ <!-- readme-standards:begin installation.pip -->
104
+ `tigrbl-ops-ltap` is not declared published. From the source checkout:
105
+
106
+ ```bash
107
+ python -m pip install .
108
+ ```
109
+ <!-- readme-standards:end installation.pip -->
110
+
111
+ #### Poetry
112
+
113
+ <!-- readme-standards:begin installation.poetry -->
114
+ `tigrbl-ops-ltap` is not declared published. From a separate Poetry project, replace the path with your checkout:
115
+
116
+ ```bash
117
+ poetry add /path/to/tigrbl-ops-ltap
118
+ ```
119
+ <!-- readme-standards:end installation.poetry -->
120
+
121
+ ### Quick Start
122
+
123
+ #### Example
124
+
125
+ <!-- readme-standards:begin example.quick-start -->
126
+ Source: [docs/readme/quick_start.py](https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/docs/readme/quick_start.py).
127
+
128
+ ```python
129
+ from tigrbl_ops_ltap.contracts import SnapshotList
130
+
131
+ request = SnapshotList(table_id="orders", page_size=25)
132
+ assert request.table_id == "orders"
133
+ assert request.cursor is None
134
+ ```
135
+ <!-- readme-standards:end example.quick-start -->
136
+
137
+ #### Expected Result
138
+
139
+ The request validates the public table ID and page size and starts without a cursor.
140
+
141
+ ---
142
+
143
+ ## Usage
144
+
145
+ ### Common Workflows
146
+
147
+ <!-- readme-standards:begin example.usage -->
148
+ Source: [docs/readme/usage.py](https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/docs/readme/usage.py).
149
+
150
+ ```python
151
+ from tigrbl_ops_ltap import LtapService, LtapTable, TableSnapshot
152
+
153
+
154
+ def mount_ltap(app, provider, resolve_scope):
155
+ service = LtapService({"orders": provider}, resolve_scope)
156
+ orders = LtapTable.bind(service, table_id="orders", name="Order", path="/orders")
157
+ app.include_table(orders, prefix="")
158
+ app.include_table(TableSnapshot.bind(service), prefix="")
159
+ ```
160
+ <!-- readme-standards:end example.usage -->
161
+
162
+ ### Configuration
163
+
164
+ Configure one provider per table ID, an application authorizer, and a scope resolver for row and column permissions.
165
+
166
+ ### Error Handling
167
+
168
+ Restart on an unavailable continuation. Missing snapshots and rows use the resource unavailable outcome.
169
+
170
+ ### Best Practices
171
+
172
+ Keep the same cursor store and page size for every page of a result.
173
+
174
+ ---
175
+
176
+ ## Package Boundary
177
+
178
+ ### What It Owns
179
+
180
+ The package owns request and response types, authorization scope, pagination, and LTAP resource declarations.
181
+
182
+ ### Public API and Import Surfaces
183
+
184
+ Import `AccessScope`, `CursorStore`, `LtapService`, `LtapTable`, `TableSnapshot`, and `RegisteredTableProvider` from `tigrbl_ops_ltap`.
185
+
186
+ ### Entry Points
187
+
188
+ <!-- readme-standards:begin entry-points -->
189
+ This package declares no command-line, GUI, or plugin entry points in its manifest.
190
+ <!-- readme-standards:end entry-points -->
191
+
192
+ ### Injected Dependencies
193
+
194
+ The application supplies the provider inventory, scope resolver, and optional cursor store.
195
+
196
+ ### Protocol Consumers
197
+
198
+ Tigrbl uses the resource declarations to project REST, JSON-RPC, OpenAPI, and OpenRPC.
199
+
200
+ ### Extensions
201
+
202
+ A provider may bind operation handlers through `EngineSpec` or supply the same typed bindings directly.
203
+
204
+ ---
205
+
206
+ ## Operations and Readiness
207
+
208
+ ### Operational Requirements
209
+
210
+ Mount the resources in a Tigrbl application with the protected operation authorizer enabled.
211
+
212
+ ### Health and Observability
213
+
214
+ Use the host application's request outcomes and provider telemetry for health and latency.
215
+
216
+ ### Security and Resource Limits
217
+
218
+ The service reauthorizes every page and binds opaque cursors to the operation, principal, tenant, and policy.
219
+
220
+ ### Compatibility
221
+
222
+ New providers must match the semantic capability IDs, exact contract versions, and required guarantees.
223
+
224
+ ---
225
+
226
+ ## Verification
227
+
228
+ ### Tests
229
+
230
+ Run the [example tests](./docs/readme/test_examples.py) and the [Iceberg integration suite](../../090_engines/tigrbl_engine_iceberg/tests/test_ltap.py).
231
+
232
+ ### Certification Status
233
+
234
+ The package is a development preview. The SSOT registry records the local integration evidence.
235
+
236
+ ### Evidence
237
+
238
+ See the [read-only slice](../../../docs/proposals/ltap-read-only-slice.md) and its real-catalog acceptance tests.
239
+
240
+ ---
241
+
242
+ ## FAQ
243
+
244
+ ### Why
245
+
246
+ Pinned pages keep one stable view while another request commits changes.
247
+
248
+ ### How
249
+
250
+ Bind `LtapTable` for each configured table and mount one `TableSnapshot` catalog resource.
251
+
252
+ ### When
253
+
254
+ Configure LTAP when a client must read the same table version across requests.
255
+
256
+ ---
257
+
258
+ ## Documentation and Related Packages
259
+
260
+ ### More Documentation
261
+
262
+ The [LTAP read-only slice](../../../docs/proposals/ltap-read-only-slice.md) defines the request, cursor, and provider contracts.
263
+
264
+ This README is the package-local distribution entry point. See the
265
+ [workspace docs](../../../docs/README.md),
266
+ [current conformance target](../../../docs/conformance/CURRENT_TARGET.md),
267
+ [package catalog](../../../docs/developer/PACKAGE_CATALOG.md),
268
+ [package layout](../../../docs/developer/PACKAGE_LAYOUT.md), and
269
+ [SSOT registry](../../../.ssot/registry.json).
270
+
271
+ ### Related Packages
272
+
273
+ `tigrbl-core` defines capability types. `tigrbl-engine-iceberg` implements the first provider.
274
+
275
+ ### Project Links
276
+
277
+ <!-- readme-standards:begin project-links -->
278
+ - [pypi: tigrbl-ops-ltap](https://pypi.org/project/tigrbl-ops-ltap/)
279
+ <!-- readme-standards:end project-links -->
280
+
281
+ ---
282
+
283
+ ## Contributing
284
+
285
+ ### How to Contribute
286
+
287
+ Exercise changes in the resource requests and provider contract through both transport bindings.
288
+
289
+ ### Development Setup
290
+
291
+ Run `uv sync --all-packages --all-groups` at the repository root before running the relevant pytest suite.
292
+
293
+ ### Notes for Maintainers
294
+
295
+ Keep storage SDK dependencies in provider packages.
296
+
297
+ ---
298
+
299
+ ## Governance
300
+
301
+ ### Ownership and Decision Making
302
+
303
+ Tigrbl maintainers review changes to the package contract and corresponding compatibility tests.
304
+
305
+ ### Standards and Policies
306
+
307
+ Follow the [workspace README policy](../../../tools/readme/POLICY.md) and record behavioral evidence in SSOT.
308
+
309
+ ### Lifecycle and Migration
310
+
311
+ Applications opt in explicitly to this read-only development package.
312
+
313
+ ---
314
+
315
+ ## License and Attribution
316
+
317
+ ### License
318
+
319
+ <!-- readme-standards:begin license -->
320
+ Licensed under `Apache-2.0`. See [LICENSE](https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/LICENSE).
321
+ <!-- readme-standards:end license -->
322
+
323
+ ### Notices
324
+
325
+ <!-- readme-standards:begin notices -->
326
+ See [NOTICE](https://github.com/tigrbl/tigrbl/blob/master/pkgs/060_ops/tigrbl_ops_ltap/NOTICE) for attribution.
327
+ <!-- readme-standards:end notices -->
@@ -0,0 +1,9 @@
1
+ tigrbl_ops_ltap/__init__.py,sha256=PaNWasiqLgYc4E_SSv6BfEPSoFbSgc5tSkrTc8BcsDQ,335
2
+ tigrbl_ops_ltap/contracts.py,sha256=kEcTBIL70b-W-xouqEfGqco3s6WSULXyJJ5Q_HzEQEs,2986
3
+ tigrbl_ops_ltap/resources.py,sha256=fkYDuM6McTDBNFgPXtVQjWSsQJcpW5guFI0xz93gIPQ,4803
4
+ tigrbl_ops_ltap/service.py,sha256=l3ajS-2XzdqbtOc1IU4tQRTDTEpWFcLzIBjiHy0YL3g,7871
5
+ tigrbl_ops_ltap-0.4.6.dev1.dist-info/METADATA,sha256=6T9UpsrXBCKtT93iJ-2DfpqnW8A7lEQ-tQPPWwWVT2s,12867
6
+ tigrbl_ops_ltap-0.4.6.dev1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
7
+ tigrbl_ops_ltap-0.4.6.dev1.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
8
+ tigrbl_ops_ltap-0.4.6.dev1.dist-info/licenses/NOTICE,sha256=EvJMTshzsWz43LiK-DeN2ZuLtrP49cxvlrFlJ8F_buc,221
9
+ tigrbl_ops_ltap-0.4.6.dev1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ Tigrbl
2
+ Copyright 2026 Swarmauri
3
+
4
+ This product includes software developed by Swarmauri.
5
+
6
+ Tigrbl is licensed under the Apache License, Version 2.0.
7
+ See the LICENSE file distributed with this work for the full license text.