diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82bf03f..23d4fb1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,8 +32,28 @@ jobs: - uses: oven-sh/setup-bun@v2 - run: uv sync --frozen --all-packages --python ${{ matrix.python }} - run: bun install --frozen-lockfile + - name: Check out the qualified generated Access source + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + repository: DocumentDrivenDX/umf + ref: d67da43671047fc14f745ee2cbc6d3cfb28e7943 + path: .cache/quality-umf + persist-credentials: false + - name: Check out the qualified Lintel source + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + with: + repository: DocumentDrivenDX/lintel + ref: c99b86bfb4f1f373277e4b81ac41afe258490482 + path: .cache/quality-lintel + persist-credentials: false + - name: Install generated-provider test wheels + run: | + uv build --wheel --out-dir .cache/generated-wheels .cache/quality-umf/python/umf_access_generated_executor + uv build --wheel --out-dir .cache/generated-wheels .cache/quality-umf/python/umf_access + uv build --wheel --out-dir .cache/generated-wheels .cache/quality-lintel + uv pip install --python .venv/bin/python --find-links https://github.com/DocumentDrivenDX/umf/releases/expanded_assets/umf-v0.10.10 .cache/generated-wheels/*.whl "umf-codegen==0.10.10" - name: Boundaries, lint, types and unit tests - run: uv run python scripts/check.py + run: uv run --no-sync python scripts/check.py - name: Version consistency and tree size guard run: | uv run python scripts/check_versions.py @@ -57,7 +77,7 @@ jobs: - name: Build and install the approval desk run: uv run python scripts/prepare_approval.py - name: Integration tests - run: uv run pytest -m integration + run: uv run pytest tests/local -m integration - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: node-version: '26.13.0' diff --git a/packages/batten-local/pyproject.toml b/packages/batten-local/pyproject.toml index b914603..810f3a9 100644 --- a/packages/batten-local/pyproject.toml +++ b/packages/batten-local/pyproject.toml @@ -21,6 +21,9 @@ dependencies = [ "opentelemetry-instrumentation-psycopg>=0.66b2", ] +[project.optional-dependencies] +lintel = ["lintel-api==0.1.0a6", "umf-access[generated]==0.1.0.dev10", "umf-codegen==0.10.10"] + [project.urls] Repository = "https://github.com/DocumentDrivenDX/batten" diff --git a/packages/batten-local/src/batten/hosting/local/_identity.py b/packages/batten-local/src/batten/hosting/local/_identity.py index b18c7b3..476fc3a 100644 --- a/packages/batten-local/src/batten/hosting/local/_identity.py +++ b/packages/batten-local/src/batten/hosting/local/_identity.py @@ -58,6 +58,6 @@ def profile(self, actor: Actor) -> Mapping[str, object]: async def check(self, actor: Actor, operation: str) -> bool: resolved = self.resolve(actor.session) - if resolved is None or resolved.subject != actor.subject: + if resolved is None or resolved != actor: return False return operation in cast(list[str], self._people[actor.subject]["operations"]) diff --git a/packages/batten-local/src/batten/lintel/__init__.py b/packages/batten-local/src/batten/lintel/__init__.py new file mode 100644 index 0000000..b4f12f0 --- /dev/null +++ b/packages/batten-local/src/batten/lintel/__init__.py @@ -0,0 +1,322 @@ +"""Optional Lintel transport adapter; every operation crosses Batten's host gates.""" + +from __future__ import annotations + +from collections.abc import AsyncGenerator, Mapping +from contextlib import asynccontextmanager, nullcontext +from types import MappingProxyType +from typing import TYPE_CHECKING, Protocol + +from batten.contracts import ( + ExecutionScope, + OperationCall, + SelectedCallSpec, + SelectedRequestError, + Selection, +) +from batten.lintel._config import ( + ExposureConfig, + ExposureOperation, + check_prepared_command_routes, + check_prepared_relationship_routes, + checked_operations, +) +from batten.lintel._connections import ConnectionAdmission, prepare_connection_admission +from batten.lintel._failure import failure, native_failure +from batten.lintel._record_config import checked_record_roots +from batten.lintel._record_root import ExposureRecordRoot +from batten.lintel._session import Session +from batten.runtime import Host + +from lintel.ports import ( + ConnectionPage, + ElementRef, + ExecutionError, + OperationRef, + RequestScope, + RequestSession, +) + +if TYPE_CHECKING: + from umf_access_generated_executor import AdmittedNativeTable, GeneratedExecutor + + from lintel.ports import ConnectionIntent + + +class _PlannedSession(RequestSession, Protocol): + async def planned_connection(self, intent: ConnectionIntent) -> ConnectionPage: ... + + +def _native_inputs( + host: Host, + config: ExposureConfig, + native: AdmittedNativeTable | None, + generated: GeneratedExecutor | None, + connection_admission: ConnectionAdmission | None, +) -> tuple[dict[OperationRef, ExposureOperation], ConnectionAdmission | None]: + if native is None: + raise ValueError("native artifact is required") + operations = dict(checked_operations(host, config, native)) + if config.record_roots: + if generated is None: + raise ValueError("Record exposure requires a verified generated executor") + if connection_admission is None: + operations.update(checked_record_roots(host, config, native, generated)) + else: + if connection_admission.prepared_api.version not in { + "lintel.prepared-api/3", + "lintel.prepared-api/4", + "lintel.prepared-api/5", + }: + raise ValueError("prepared API connection admission differs") + operations.update( + checked_record_roots( + host, + config, + native, + generated, + connection_lookups=connection_admission.host_operation_by_lookup, + connection_capabilities=connection_admission.selected_capabilities, + connection_api_version=connection_admission.prepared_api.version, + ) + ) + elif connection_admission is not None: + raise ValueError("API connections require explicit Record roots") + admission = connection_admission + check_prepared_command_routes( + host, + config, + operations, + admission.prepared_api if admission is not None else None, + ) + check_prepared_relationship_routes( + host, + config, + operations, + admission.prepared_api if admission is not None else None, + ) + return operations, admission + + +class LintelExecution: + def __init__( + self, + host: Host, + config: ExposureConfig, + native: AdmittedNativeTable | None = None, + *, + generated: GeneratedExecutor | None = None, + connection_admission: ConnectionAdmission | None = None, + ): + operations, connection_admission = _native_inputs( + host, config, native, generated, connection_admission + ) + self._operations = MappingProxyType(operations) + self._host, self._config = host, config + self._connection_admission = connection_admission + self._response_bytes = ( + connection_admission.response_bytes + if connection_admission is not None + else None + ) + + @staticmethod + def prepare_connections( + config: ExposureConfig, + prepared_api: object, + native: AdmittedNativeTable, + executor: GeneratedExecutor, + ) -> ConnectionAdmission: + from lintel.projection import AdmittedPreparedApi + + if type(prepared_api) is not AdmittedPreparedApi: + raise ValueError("API3 requires a publicly admitted prepared API") + return prepare_connection_admission(config, prepared_api, native, executor) + + def capabilities(self) -> Mapping[str, str]: + return self._config.capabilities + + @asynccontextmanager + async def session(self, scope: RequestScope) -> AsyncGenerator[RequestSession]: + authority = scope.authority + if ( + not isinstance(authority, ExecutionScope) + or not self._host.scope_active(authority) + or scope.application != self._config.application.id + or scope.api_digest != self._config.api_digest + or scope.api_digest != authority.api_digest + or scope.request_id != authority.request_id + or scope.deadline_monotonic != authority.deadline_monotonic + or scope.kind not in {"query", "mutation"} + ): + raise ExecutionError("API_MISMATCH") + admission = self._connection_admission + session = Session( + self._host, + authority, + scope.kind, + self._operations, + connection_operations=( + admission.host_operation_by_lookup if admission is not None else None + ), + result_budget=self._response_bytes, + planned_mode=admission is not None, + ) + resource = ( + self._host.open_selected_session( + authority, consistency="request-snapshot-1" + ) + if self._config.record_roots + else nullcontext() + ) + try: + async with resource: + try: + yield session + finally: + session.active = False + session.ensure_budget() + except ExecutionError: + raise + except SelectedRequestError as error: + raise failure(error.status, error.code) from None + except Exception as error: + try: + session.ensure_budget() + except ExecutionError as refusal: + raise refusal from None + raise native_failure(error) from None + + @asynccontextmanager + async def session_planned( + self, scope: RequestScope, intents: tuple[ConnectionIntent, ...] + ) -> AsyncGenerator[_PlannedSession]: + admission = self._connection_admission + authority = scope.authority + if admission is None or type(intents) is not tuple or not intents: + raise ExecutionError("UNSUPPORTED") + if len(intents) > admission.max_connections: + raise ExecutionError("LIMIT_EXCEEDED") + if not isinstance(authority, ExecutionScope): + raise ExecutionError("API_MISMATCH") + if not self._scope_matches(scope, authority): + raise ExecutionError("API_MISMATCH") + calls = _planned_calls(admission, intents, authority, self._operations) + session = Session( + self._host, + authority, + scope.kind, + self._operations, + planned_intents=intents, + connection_operations=admission.host_operation_by_lookup, + result_budget=admission.response_bytes, + planned_mode=True, + ) + try: + async with self._host.open_selected_session( + authority, + consistency="request-snapshot-1", + calls=calls, + ): + try: + yield session + finally: + session.active = False + session.ensure_budget() + except ExecutionError: + raise + except SelectedRequestError as error: + raise failure(error.status, error.code) from None + except Exception as error: + try: + session.ensure_budget() + except ExecutionError as refusal: + raise refusal from None + raise native_failure(error) from None + + def _scope_matches(self, scope: RequestScope, authority: object) -> bool: + return ( + isinstance(authority, ExecutionScope) + and self._host.scope_active(authority) + and scope.application == self._config.application.id + and scope.api_digest == self._config.api_digest == authority.api_digest + and scope.request_id == authority.request_id + and scope.deadline_monotonic == authority.deadline_monotonic + and scope.kind == "query" + ) + + +def _planned_calls( + admission: ConnectionAdmission, + intents: tuple[ConnectionIntent, ...], + authority: ExecutionScope, + operations: Mapping[OperationRef, ExposureOperation], +) -> tuple[SelectedCallSpec, ...]: + from lintel.ports import ConnectionIntent + + response_keys: set[str] = set() + calls: list[SelectedCallSpec] = [] + for intent in intents: + if type(intent) is not ConnectionIntent: + raise ExecutionError("UNSUPPORTED") + prepared = admission.prepared_by_name.get(intent.field_name) + operation = admission.host_operation_by_lookup.get(intent.lookup) + exposure = operations.get(intent.lookup) + if ( + not intent.response_key + or type(intent.field_name) is not str + or type(intent.lookup) is not OperationRef + or intent.response_key in response_keys + or prepared is None + or prepared.lookup != intent.lookup + or intent.lookup.kind != "record" + or operation is None + or exposure is None + or exposure.host_operation != operation + or intent.arguments + or type(intent.first) is not int + or not 0 <= intent.first <= admission.max_page + or not _valid_cursor(intent.after, admission.cursor_bytes) + or type(intent.fields) is not tuple + or any(type(field) is not ElementRef for field in intent.fields) + or len(set(intent.fields)) != len(intent.fields) + or not set(intent.fields).issubset(prepared.field_refs) + or not set(intent.fields).issubset(exposure.fields) + ): + raise ExecutionError("UNSUPPORTED") + response_keys.add(intent.response_key) + calls.append( + SelectedCallSpec( + OperationCall(operation, {}, authority.principal, scope=authority), + Selection( + "connection", + fields=tuple( + (field.module, field.element) for field in intent.fields + ), + first=intent.first, + after=intent.after, + ), + ) + ) + return tuple(calls) + + +def _valid_cursor(value: str | None, maximum: int) -> bool: + if value is None: + return True + if type(value) is not str: + return False + try: + return len(value.encode("utf-8")) <= maximum + except UnicodeEncodeError: + return False + + +__all__ = [ + "ExposureConfig", + "ExposureOperation", + "ExposureRecordRoot", + "ConnectionAdmission", + "LintelExecution", + "prepare_connection_admission", +] diff --git a/packages/batten-local/src/batten/lintel/_command.py b/packages/batten-local/src/batten/lintel/_command.py new file mode 100644 index 0000000..2b4f6b5 --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_command.py @@ -0,0 +1,95 @@ +"""Exact command outcome projection; no command dispatch occurs here.""" + +from collections.abc import Mapping +from typing import Literal, cast + +from batten.lintel import _decode +from batten.lintel._config import ExposureOperation + +from lintel.ports import CommandResult, ExecutionError + + +def command_result( + value: Mapping[str, object], + exposure: ExposureOperation, + invocation_key: str, + phase: str, +) -> CommandResult: + payload = _decode.object_value( + value, + { + "version", + "status", + "durability", + "invocationKey", + "affected", + "receipt", + "code", + "confirmation", + }, + ) + if ( + payload["version"] != "batten.command-result/1" + or payload["invocationKey"] != invocation_key + ): + raise ExecutionError("INVALID") + status, durability = payload["status"], payload["durability"] + if ( + not isinstance(status, str) + or not isinstance(durability, str) + or status + not in { + "applied", + "recovered", + "not-observed", + "unknown", + "rejected", + } + or durability + not in { + "committed", + "pending-caller-commit", + "unknown", + "none", + } + ): + raise ExecutionError("INVALID") + if ( + phase == "observe" and status not in {"recovered", "not-observed", "rejected"} + ) or (phase == "invoke" and status == "not-observed"): + raise ExecutionError("INVALID") + if status in {"unknown", "not-observed", "rejected"}: + expected = "unknown" if status == "unknown" else "none" + if ( + durability != expected + or _decode.sequence(payload["affected"]) + or payload["receipt"] is not None + ): + raise ExecutionError("INVALID") + elif durability not in {"committed", "pending-caller-commit"}: + raise ExecutionError("INVALID") + elif not isinstance(payload["receipt"], str) or not payload["receipt"]: + raise ExecutionError("INVALID") + if any( + value is not None and not isinstance(value, str) + for value in (payload["receipt"], payload["code"], payload["confirmation"]) + ): + raise ExecutionError("INVALID") + return CommandResult( + cast( + Literal["applied", "recovered", "not-observed", "unknown", "rejected"], + status, + ), + invocation_key, + cast( + Literal["committed", "pending-caller-commit", "unknown", "none"], + durability, + ), + tuple( + _decode.key(value, exposure) + for value in _decode.sequence(payload["affected"]) + ), + payload["receipt"], + cast(str | None, payload["code"]), + cast(str | None, payload["confirmation"]), + ) diff --git a/packages/batten-local/src/batten/lintel/_config.py b/packages/batten-local/src/batten/lintel/_config.py new file mode 100644 index 0000000..c02311f --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_config.py @@ -0,0 +1,174 @@ +"""Host-composed exposure pins joined to a verified native artifact inventory.""" + +from __future__ import annotations + +import json +from collections.abc import Mapping +from dataclasses import dataclass +from types import MappingProxyType +from typing import TYPE_CHECKING, cast + +from batten.contracts import ArtifactRef +from batten.runtime import Host + +from lintel.ports import ElementRef, OperationRef + +from ._record_root import ExposureRecordRoot + +if TYPE_CHECKING: + from umf_access_generated_executor import AdmittedNativeTable + + from lintel.projection import AdmittedPreparedApi + + +@dataclass(frozen=True) +class ExposureOperation: + ref: OperationRef + host_operation: str + selection_kinds: tuple[str, ...] + record: ElementRef + key_id: str + fields: tuple[ElementRef, ...] + key_wrappers: tuple[str, ...] + field_wrappers: tuple[tuple[ElementRef, str], ...] + related_target: ElementRef | None = None + parent_record: ElementRef | None = None + parent_key_id: str | None = None + parent_key_wrappers: tuple[str, ...] = () + nullable_fields: tuple[ElementRef, ...] = () + + +@dataclass(frozen=True) +class ExposureConfig: + application: ArtifactRef + api_digest: str + source_digest: str + operations: tuple[ExposureOperation, ...] + capabilities: Mapping[str, str] + record_roots: tuple[ExposureRecordRoot, ...] = () + + def __post_init__(self) -> None: + object.__setattr__( + self, "capabilities", MappingProxyType(dict(self.capabilities)) + ) + + +def checked_operations( + host: Host, config: ExposureConfig, native: AdmittedNativeTable +) -> Mapping[OperationRef, ExposureOperation]: + from umf_access_generated_executor import AdmittedNativeTable + + if ( + not isinstance(cast(object, native), AdmittedNativeTable) + or config.application != host.config.artifact + or config.source_digest != native.source_digest + or not config.api_digest + ): + raise ValueError("exposure artifact pins differ") + module = native.native_source["configuration"] + if not isinstance(module, Mapping): + raise ValueError("native configuration is absent") + inventory = dict(native.operations) + result: dict[OperationRef, ExposureOperation] = {} + routes: set[str] = set() + for exposed in config.operations: + operation = host.operations.get(exposed.host_operation) + kind = inventory.get(exposed.ref.id) + if ( + exposed.ref in result + or exposed.host_operation in routes + or exposed.ref.module != module["module"] + or exposed.ref.kind != "table" + or operation is None + or kind is None + or operation.mutation != (kind not in {"query", "read"}) + or not set(exposed.selection_kinds).issubset(operation.selection_kinds) + or len(set(exposed.fields)) != len(exposed.fields) + or len(dict(exposed.field_wrappers)) != len(exposed.field_wrappers) + or set(dict(exposed.field_wrappers)) != set(exposed.fields) + or not set(exposed.nullable_fields).issubset(exposed.fields) + or not exposed.key_id + ): + raise ValueError("exposure operation differs from admitted inventory") + result[exposed.ref] = exposed + routes.add(exposed.host_operation) + return MappingProxyType(result) + + +def check_prepared_command_routes( + host: Host, + config: ExposureConfig, + operations: Mapping[OperationRef, ExposureOperation], + prepared: AdmittedPreparedApi | None, +) -> None: + """Require every exposed command to join an admitted native Host mutation.""" + command_profile = any( + key in config.capabilities for key in ("command.outcome", "command.observe") + ) + if not command_profile: + return + if ( + prepared is None + or prepared.api_digest != config.api_digest + or not prepared.commands + ): + raise ValueError("prepared command profile requires admitted command metadata") + for command in prepared.commands: + route = operations.get(command.operation) + if route is None or not host.operations[route.host_operation].mutation: + raise ValueError( + "prepared command does not match an admitted Host mutation" + ) + expected = json.dumps( + (command.operation.module, command.operation.id), + ensure_ascii=False, + separators=(",", ":"), + ) + if ( + host.config.selected_capabilities.get( + f"command.operation/{route.host_operation}" + ) + != expected + or host.config.selected_capabilities.get("command.outcome") != "1" + or host.config.selected_capabilities.get("command.observe") != "1" + ): + raise ValueError("prepared command differs from selected native Host route") + + +def check_prepared_relationship_routes( + host: Host, + config: ExposureConfig, + operations: Mapping[OperationRef, ExposureOperation], + prepared: AdmittedPreparedApi | None, +) -> None: + if config.capabilities.get("relationship.batch") != "to-one-1": + return + if ( + prepared is None + or prepared.api_digest != config.api_digest + or not prepared.relationships + or host.config.selected_capabilities.get("relationship.batch") != "to-one-1" + ): + raise ValueError("relationship requires an admitted prepared API and provider") + for relationship in prepared.relationships: + route = operations.get(relationship.operation) + if ( + route is None + or route.parent_record != relationship.source + or route.related_target != relationship.target + or route.record != relationship.target + or "related_many" not in route.selection_kinds + ): + raise ValueError("prepared relationship differs from Host exposure") + expected = json.dumps( + (*relationship.relationship, *relationship.target), + ensure_ascii=False, + separators=(",", ":"), + ) + if ( + host.config.selected_capabilities.get( + f"relationship.operation/{route.host_operation}" + ) + != expected + ): + raise ValueError("prepared relationship differs from native Host route") diff --git a/packages/batten-local/src/batten/lintel/_connections.py b/packages/batten-local/src/batten/lintel/_connections.py new file mode 100644 index 0000000..53c968d --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_connections.py @@ -0,0 +1,366 @@ +"""Compose admitted prepared connection metadata into native and Host routes.""" + +from __future__ import annotations + +import json +from collections.abc import Mapping +from dataclasses import dataclass +from hashlib import sha256 +from types import MappingProxyType +from typing import TYPE_CHECKING, cast + +from batten.contracts import connection_routes_digest +from batten.lintel._config import ExposureConfig +from batten.lintel._record_root import ExposureRecordRoot + +from lintel.ports import ElementRef, OperationRef + +_READ_PROFILES = { + "lintel.prepared-api/3": "weft.generated-read-algebra/5", + "lintel.prepared-api/4": "weft.generated-read-algebra/7", + "lintel.prepared-api/5": "weft.generated-read-algebra/8", +} +_CONNECTION_PROFILE = "connection.forward=edge-cursor-1" + +if TYPE_CHECKING: + from umf_access.generated import GeneratedConnectionRoute + from umf_access_generated_executor import AdmittedNativeTable, GeneratedExecutor + + from lintel.projection import AdmittedPreparedApi, PreparedConnection + + +@dataclass(frozen=True, slots=True) +class ConnectionAdmission: + """Prepared API admission and native routes, ready before Host creation.""" + + prepared_api: AdmittedPreparedApi + native_routes: Mapping[str, GeneratedConnectionRoute] + prepared_by_name: Mapping[str, PreparedConnection] + host_operation_by_lookup: Mapping[OperationRef, str] + max_connections: int + max_page: int + cursor_bytes: int + response_bytes: int + selected_capabilities: Mapping[str, str] + + +def prepare_connection_admission( + config: ExposureConfig, + prepared_api: AdmittedPreparedApi, + native: AdmittedNativeTable, + executor: GeneratedExecutor, +) -> ConnectionAdmission: + """Join prepared roots to opaque Host operation IDs before constructing Host.""" + + _check_admission_pins(config, prepared_api, native, executor) + roots = {root.ref: root for root in config.record_roots} + if len(roots) != len(config.record_roots): + raise ValueError("prepared API Record root references are duplicated") + limits = _mapping(prepared_api.host_profile.get("limits")) + max_aliases = _positive_limit(limits.get("maxAliases")) + max_fields = _positive_limit(limits.get("maxFieldOccurrences")) + max_page = _positive_limit(limits.get("maxPage")) + cursor_bytes = _positive_limit(limits.get("cursorBytes")) + response_bytes = _positive_limit(limits.get("responseBytes")) + prepared_connections = prepared_api.generated_connections + if not prepared_connections or len(prepared_connections) > min( + max_aliases, max_fields + ): + raise ValueError("prepared API connection count exceeds admitted limits") + algebra_roots = _mapping( + _mapping(json.loads(executor.read_algebra_json)).get("roots") + ) + native_operations = {operation for operation, _kind in native.operations} + config_operations = {item.host_operation for item in config.operations} + routes: dict[str, GeneratedConnectionRoute] = {} + by_name: dict[str, PreparedConnection] = {} + operation_by_lookup: dict[OperationRef, str] = {} + route_pins: list[tuple[str, str, str, str]] = [] + for connection in prepared_connections: + route, root = _connection_route( + config, + connection, + roots, + algebra_roots, + native_operations, + config_operations, + routes, + by_name, + ) + routes[root.host_operation] = route + by_name[connection.name] = connection + operation_by_lookup[connection.lookup] = root.host_operation + route_pins.append(( + root.host_operation, + connection.lookup.module, + connection.lookup.id, + connection.profile_digest, + )) + route_pins.sort() + selected_capabilities = _generated_pins(config, native, executor, route_pins) + return ConnectionAdmission( + prepared_api, + MappingProxyType(routes), + MappingProxyType(by_name), + MappingProxyType(operation_by_lookup), + min(max_aliases, max_fields), + max_page, + cursor_bytes, + response_bytes, + MappingProxyType(selected_capabilities), + ) + + +def _check_admission_pins( + config: ExposureConfig, + prepared_api: AdmittedPreparedApi, + native: AdmittedNativeTable, + executor: GeneratedExecutor, +) -> None: + from umf_access_generated_executor import ( + AdmittedNativeTable, + is_verified_executor_for, + ) + + from lintel.projection import AdmittedPreparedApi + + if ( + type(prepared_api) is not AdmittedPreparedApi + or type(native) is not AdmittedNativeTable + or not is_verified_executor_for(executor, native) + or prepared_api.version not in _READ_PROFILES + or executor.read_profile != _READ_PROFILES.get(prepared_api.version) + or any( + _connection_read_profile(connection, prepared_api.version) + != _READ_PROFILES[prepared_api.version] + for connection in prepared_api.generated_connections + ) + or config.application.id != prepared_api.application + or config.api_digest != prepared_api.api_digest + or config.source_digest != native.source_digest + or config.capabilities.get("connection.forward") != "edge-cursor-1" + or dict(prepared_api.capabilities).get("connection.forward") != "edge-cursor-1" + or dict(prepared_api.capabilities).get("read.consistency") + != "request-snapshot-1" + or config.source_digest + not in {digest for _identity, digest in prepared_api.source_digests} + ): + raise ValueError("prepared API connection admission pins differ") + + +def _connection_route( + config: ExposureConfig, + connection: PreparedConnection, + roots: Mapping[OperationRef, ExposureRecordRoot], + algebra_roots: Mapping[str, object], + native_operations: set[str], + config_operations: set[str], + routes: Mapping[str, GeneratedConnectionRoute], + by_name: Mapping[str, PreparedConnection], +) -> tuple[GeneratedConnectionRoute, ExposureRecordRoot]: + from umf_access.generated import ( + AllowedConnectionFieldProfile, + GeneratedConnectionRoute, + GeneratedCursorScope, + ) + + from lintel.projection import PreparedConnection, allowed_field_profile_to_dict + + if type(connection) is not PreparedConnection: + raise ValueError("prepared API connection metadata type differs") + root = roots.get(connection.lookup) + if ( + connection.lookup.kind != "record" + or root is None + or connection.name in by_name + or root.host_operation in routes + or root.host_operation in native_operations + or root.host_operation in config_operations + ): + raise ValueError( + "prepared API connection does not join one exposed Record root" + ) + algebra_root = algebra_roots.get( + connection_root_id(connection.lookup.module, connection.lookup.id) + ) + if not isinstance(algebra_root, Mapping): + raise ValueError( + "prepared API connection Record is absent from generated algebra" + ) + profile_body = allowed_field_profile_to_dict(connection) + profile = AllowedConnectionFieldProfile.from_body(profile_body) + if profile.digest != connection.profile_digest: + raise ValueError("prepared API allowed Field profile digest differs") + validate_connection_profile( + connection, root, cast(Mapping[str, object], algebra_root), profile_body + ) + route_scope = GeneratedCursorScope( + config.application.id, + config.application.digest, + config.api_digest, + root.host_operation, + profile.digest, + ) + return ( + GeneratedConnectionRoute( + connection.lookup.module, connection.lookup.id, route_scope, profile + ), + root, + ) + + +def _generated_pins( + config: ExposureConfig, + native: AdmittedNativeTable, + executor: GeneratedExecutor, + connection_pins: list[tuple[str, str, str, str]], +) -> dict[str, str]: + trust = executor.trusted_artifact + algebra_digest = sha256(executor.read_algebra_json).hexdigest() + records = sorted( + [root.host_operation, root.ref.module, root.ref.id, root.primary_key_id] + for root in config.record_roots + ) + required = { + "read.consistency": "request-snapshot-1", + "read.profile": _required_read_profile(executor), + "connection.forward": "edge-cursor-1", + "source.digest": native.source_digest, + "binding.digest": executor.target.binding_digest, + "algebra.digest": algebra_digest, + "artifact.digest": trust.artifact_digest, + "receipt.digest": trust.receipt_digest, + "records.digest": _digest(records), + "connection.routes.digest": connection_routes_digest( + config.application.id, + config.application.digest, + config.api_digest, + trust.artifact_digest, + tuple(connection_pins), + ), + } + return required + + +def validate_connection_profile( + connection: PreparedConnection, + exposed: ExposureRecordRoot, + root: Mapping[str, object], + profile: Mapping[str, object], +) -> None: + raw_fields = profile.get("fields") + if type(raw_fields) is not list: + raise ValueError("prepared API allowed Field profile is unavailable") + entries = tuple(cast(list[object], raw_fields)) + by_id: dict[str, Mapping[str, object]] = {} + by_source: dict[ElementRef, str] = {} + for value in entries: + item = _mapping(value) + field_id = item.get("fieldId") + source = _mapping(item.get("sourceField")) + module, element = source.get("module"), source.get("element") + if ( + type(field_id) is not str + or type(module) is not str + or type(element) is not str + ): + raise ValueError( + "prepared API allowed Field descriptor differs from issued algebra" + ) + reference = ElementRef(module, element) + if field_id in by_id or reference in by_source: + raise ValueError("prepared API allowed Field descriptors are duplicated") + by_id[field_id] = item + by_source[reference] = field_id + visible = set(connection.field_refs) + key_reference = connection.primary_key_field + exposed_fields = set(exposed.fields) + if ( + not visible.issubset(exposed_fields) + or key_reference not in _primary_fields(root) + or set(by_source) != visible | {key_reference} + or len(by_source) != len(visible | {key_reference}) + ): + raise ValueError( + "prepared API connection Fields or Key differ from Record exposure" + ) + fields = _mapping(root.get("fields")) + forward = _mapping(root.get("forwardConnection")) + outputs = { + cast(str, item["fieldId"]): _mapping(item["output"]) + for value in cast(tuple[object, ...], forward["fieldOutputs"]) + for item in (_mapping(value),) + } + for field_id, item in by_id.items(): + issued = _mapping(fields.get(field_id)) + output = outputs.get(field_id) + if ( + output is None + or item.get("sourceField") != issued.get("sourceField") + or item.get("output") != output + or item.get("scalar") != output.get("carrier") + or item.get("nullable") != output.get("nullable") + ): + raise ValueError( + "prepared API allowed Field descriptor differs from issued algebra" + ) + + +def connection_root_id(module: str, record: str) -> str: + """Build the issued algebra root key from escaped JSON Pointer components.""" + return f"{_escape_component(module)}/{_escape_component(record)}" + + +def _escape_component(value: str) -> str: + return value.replace("~", "~0").replace("/", "~1") + + +def _primary_fields(root: Mapping[str, object]) -> tuple[ElementRef, ...]: + fields = _mapping(root.get("fields")) + result: list[ElementRef] = [] + for value in cast(tuple[object, ...], root["primaryKey"]): + field_id = cast(str, _mapping(value)["fieldId"]) + field = _mapping(fields.get(field_id)) + source = _mapping(field["sourceField"]) + result.append( + ElementRef(cast(str, source["module"]), cast(str, source["element"])) + ) + return tuple(result) + + +def _mapping(value: object) -> Mapping[str, object]: + if not isinstance(value, Mapping): + raise ValueError("prepared API connection metadata is unavailable") + return cast(Mapping[str, object], value) + + +def _connection_read_profile(connection: object, api_version: str) -> object: + profile = getattr(connection, "read_profile", None) + if profile is None and api_version == "lintel.prepared-api/3": + return "weft.generated-read-algebra/5" + return profile + + +def _required_read_profile(executor: GeneratedExecutor) -> str: + profile = executor.read_profile + if type(profile) is not str or profile not in _READ_PROFILES.values(): + raise ValueError("generated connection read profile differs") + return profile + + +def _positive_limit(value: object) -> int: + if type(value) is not str or not value.isascii() or not value.isdecimal(): + raise ValueError("prepared API connection limit is unavailable") + result = int(value) + if result <= 0: + raise ValueError("prepared API connection limit is unavailable") + return result + + +def _digest(rows: list[list[str]]) -> str: + return sha256( + json.dumps(rows, ensure_ascii=False, separators=(",", ":")).encode() + ).hexdigest() + + +__all__ = ["ConnectionAdmission", "prepare_connection_admission"] diff --git a/packages/batten-local/src/batten/lintel/_decode.py b/packages/batten-local/src/batten/lintel/_decode.py new file mode 100644 index 0000000..3c723c8 --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_decode.py @@ -0,0 +1,150 @@ +"""Strict safe projection of versioned provider outcomes into Lintel values.""" + +from collections.abc import Mapping +from types import MappingProxyType +from typing import cast + +from batten.lintel._config import ExposureOperation + +from lintel.ports import ( + ConnectionPage, + Edge, + ElementRef, + ExecutionError, + NodeKey, + NodeValue, +) + + +def object_value(value: object, keys: set[str]) -> Mapping[str, object]: + if not isinstance(value, Mapping): + raise ExecutionError("INVALID") + result = cast(Mapping[str, object], value) + if set(result) != keys: + raise ExecutionError("INVALID") + return result + + +def sequence(value: object) -> tuple[object, ...]: + if not isinstance(value, (tuple, list)): + raise ExecutionError("INVALID") + return tuple(cast(tuple[object, ...] | list[object], value)) + + +def reference(value: object) -> ElementRef: + parts = sequence(value) + if len(parts) != 2 or not all(isinstance(item, str) and item for item in parts): + raise ExecutionError("INVALID") + return ElementRef(cast(str, parts[0]), cast(str, parts[1])) + + +def literal(value: object, wrapper: str | None = None) -> Mapping[str, object]: + if not isinstance(value, Mapping) or len(cast(Mapping[object, object], value)) != 1: + raise ExecutionError("INVALID") + result = cast(Mapping[object, object], value) + name, inner = next(iter(result.items())) + allowed = { + "boolean", + "string", + "integerToken", + "decimalToken", + "uuid", + "date", + "timestamp", + } + if name not in allowed or (wrapper is not None and name != wrapper): + raise ExecutionError("UNSUPPORTED") + if type(inner) is not (bool if name == "boolean" else str): + raise ExecutionError("INVALID") + return MappingProxyType(dict(cast(Mapping[str, object], result))) + + +def key(value: object, exposure: ExposureOperation) -> NodeKey: + item = object_value(value, {"record", "keyId", "components"}) + if reference(item["record"]) != exposure.record or item["keyId"] != exposure.key_id: + raise ExecutionError("INVALID") + components = sequence(item["components"]) + if len(components) != len(exposure.key_wrappers): + raise ExecutionError("INVALID") + return NodeKey( + exposure.record, + exposure.key_id, + tuple( + literal(part, wrapper) + for part, wrapper in zip(components, exposure.key_wrappers, strict=True) + ), + ) + + +def node( + value: object, exposure: ExposureOperation, fields: tuple[ElementRef, ...] +) -> NodeValue: + item = object_value(value, {"key", "fields"}) + values: dict[ElementRef, Mapping[str, object] | None] = {} + for entry in sequence(item["fields"]): + field = object_value(entry, {"field", "value"}) + ref = reference(field["field"]) + if ref not in fields or ref in values: + raise ExecutionError("INVALID") + values[ref] = ( + None + if field["value"] is None and ref in exposure.nullable_fields + else literal(field["value"], dict(exposure.field_wrappers)[ref]) + ) + if set(values) != set(fields): + raise ExecutionError("INVALID") + return NodeValue(key(item["key"], exposure), MappingProxyType(values)) + + +def items( + result: Mapping[str, object], + kind: str, + exposure: ExposureOperation, + fields: tuple[ElementRef, ...], + requested: tuple[NodeKey, ...], +) -> tuple[NodeValue | None, ...]: + payload = object_value(result, {"version", "kind", "items"}) + if payload["version"] != "batten.selected-result/1" or payload["kind"] != kind: + raise ExecutionError("INVALID") + rows = sequence(payload["items"]) + if len(rows) != len(requested): + raise ExecutionError("INVALID") + values = tuple(None if row is None else node(row, exposure, fields) for row in rows) + if kind == "get_many" and any( + value is not None and value.key != expected + for value, expected in zip(values, requested, strict=True) + ): + raise ExecutionError("INVALID") + return values + + +def connection( + result: Mapping[str, object], + exposure: ExposureOperation, + fields: tuple[ElementRef, ...], + first: int, +) -> ConnectionPage: + payload = object_value( + result, {"version", "kind", "edges", "hasNextPage", "hasPreviousPage"} + ) + if ( + payload["version"] != "batten.selected-result/1" + or payload["kind"] != "connection" + or type(payload["hasNextPage"]) is not bool + or type(payload["hasPreviousPage"]) is not bool + ): + raise ExecutionError("INVALID") + edges: list[Edge] = [] + for entry in sequence(payload["edges"]): + edge = object_value(entry, {"cursor", "node"}) + cursor = edge["cursor"] + if not isinstance(cursor, str) or not cursor: + raise ExecutionError("INVALID_CURSOR") + edges.append(Edge(cursor, node(edge["node"], exposure, fields))) + if len(edges) > first or len({edge.cursor for edge in edges}) != len(edges): + raise ExecutionError("INVALID") + return ConnectionPage( + tuple(edges), + payload["hasNextPage"], + payload["hasPreviousPage"], + ) diff --git a/packages/batten-local/src/batten/lintel/_failure.py b/packages/batten-local/src/batten/lintel/_failure.py new file mode 100644 index 0000000..fe43a76 --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_failure.py @@ -0,0 +1,52 @@ +"""Whitelist safe host errors without echoing provider diagnostics.""" + +import sys +from typing import cast + +from lintel.ports import ExecutionError, ExecutionErrorCode + + +def failure(status: str, code: str | None) -> ExecutionError: + aliases = { + "not_admitted": "API_MISMATCH", + "scope_invalid": "DENIED", + "deadline_exceeded": "LIMIT_EXCEEDED", + "limit_exceeded": "LIMIT_EXCEEDED", + "invalid_selection": "INVALID", + "unsupported_selection": "UNSUPPORTED", + "invalid_key": "INVALID", + "timeout": "BUSY", + "SCHEMA_MISMATCH": "API_MISMATCH", + } + public = aliases.get(code or "", (code or "").upper()) + try: + return ExecutionError(cast(ExecutionErrorCode, public)) + except ValueError: + return ExecutionError("DENIED" if status == "denied" else "BUSY") + + +def native_failure(error: BaseException) -> ExecutionError: + """Consume only the public nominal native error class and its fixed code.""" + kind: object = getattr( + sys.modules.get("umf_access.unified"), "GeneratedNativeError", None + ) + current: BaseException | None = error + for _ in range(8): + if current is None: + break + if isinstance(kind, type) and type(current) is kind: + code: object = getattr(current, "code", None) + if type(code) is str and code in { + "DENIED", + "INVALID", + "UNSUPPORTED", + "LIMIT_EXCEEDED", + "SCHEMA_MISMATCH", + "PRECONDITION_FAILED", + "BUSY", + }: + return failure("denied" if code == "DENIED" else "unavailable", code) + if isinstance(current, TimeoutError): + return ExecutionError("LIMIT_EXCEEDED") + current = current.__cause__ + return ExecutionError("BUSY") diff --git a/packages/batten-local/src/batten/lintel/_record_config.py b/packages/batten-local/src/batten/lintel/_record_config.py new file mode 100644 index 0000000..c7680cd --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_record_config.py @@ -0,0 +1,250 @@ +"""Join explicit Record exposures to the upstream verifier's immutable metadata.""" + +from __future__ import annotations + +import hashlib +import json +from collections.abc import Mapping +from types import MappingProxyType +from typing import TYPE_CHECKING, cast + +from batten.lintel._config import ExposureConfig, ExposureOperation +from batten.lintel._record_root import ExposureRecordRoot +from batten.runtime import Host + +from lintel.ports import ElementRef, OperationRef + +if TYPE_CHECKING: + from umf_access_generated_executor import AdmittedNativeTable, GeneratedExecutor + +_WRAPPERS = { + "string": "string", + "boolean": "boolean", + "integer": "integerToken", + "decimal": "decimalToken", + "date": "date", + "timestamp": "timestamp", + "uuid": "uuid", +} + + +def _mapping(value: object) -> Mapping[str, object]: + if not isinstance(value, Mapping): + raise ValueError("verified Record metadata is unavailable") + return cast(Mapping[str, object], value) + + +def _sequence(value: object) -> tuple[object, ...]: + if type(value) not in {list, tuple}: + raise ValueError("verified Record sequence is unavailable") + return tuple(cast(list[object] | tuple[object, ...], value)) + + +def _reference(value: object) -> ElementRef: + ref = _mapping(value) + if set(ref) != {"module", "element"} or any( + type(part) is not str or not part for part in ref.values() + ): + raise ValueError("verified Field reference differs") + return ElementRef(cast(str, ref["module"]), cast(str, ref["element"])) + + +def _fields(root: Mapping[str, object], exposed: ExposureRecordRoot) -> None: + fields = { + _reference(item["sourceField"]): _mapping(item["output"]) + for value in _mapping(root["fields"]).values() + for item in (_mapping(value),) + } + wrappers = dict(exposed.field_wrappers) + if ( + len(set(exposed.fields)) != len(exposed.fields) + or len(wrappers) != len(exposed.field_wrappers) + or set(wrappers) != set(exposed.fields) + or not set(exposed.fields).issubset(fields) + ): + raise ValueError("Record exposed Fields differ") + for field in exposed.fields: + output = fields[field] + if wrappers[field] != _WRAPPERS.get(cast(str, output["carrier"])): + raise ValueError("Record Field carrier differs") + if set(exposed.nullable_fields) != { + field for field in exposed.fields if fields[field]["nullable"] is True + }: + raise ValueError("Record Field presence differs") + + +def _key(root: Mapping[str, object], exposed: ExposureRecordRoot) -> None: + batch = _mapping(root["getMany"]) + keys = tuple(_mapping(value) for value in _sequence(batch["keyFields"])) + originals = tuple( + _mapping(value)["fieldId"] for value in _sequence(root["primaryKey"]) + ) + wrappers = tuple( + _mapping(_sequence(_mapping(component["codec"])["steps"])[0]) + for component in keys + ) + if ( + batch["keyId"] != exposed.primary_key_id + or root["primaryKeyId"] != exposed.primary_key_id + or tuple(component["fieldId"] for component in keys) != originals + or not 1 <= len(keys) <= 16 + or exposed.key_wrappers != ("string",) * len(keys) + or any( + step.get("op") != "require-exact-wrapper" + or step.get("wrapper") != "string" + or step.get("nullable") is not False + for step in wrappers + ) + ): + raise ValueError( + "Record primary Key differs from the selected string identity profile" + ) + + +def _required_record_read_profile( + connection_lookups: Mapping[OperationRef, str] | None, + connection_capabilities: Mapping[str, str] | None, + connection_api_version: str | None, +) -> str | None: + if connection_lookups is None: + return "weft.generated-read-algebra/4" + if connection_api_version == "lintel.prepared-api/3": + profile = "weft.generated-read-algebra/5" + elif connection_api_version == "lintel.prepared-api/4": + profile = "weft.generated-read-algebra/7" + elif connection_api_version == "lintel.prepared-api/5": + profile = "weft.generated-read-algebra/8" + else: + return None + if ( + connection_capabilities is None + or connection_capabilities.get("read.profile") != profile + ): + return None + return profile + + +def checked_record_roots( + host: Host, + config: ExposureConfig, + native: AdmittedNativeTable, + executor: GeneratedExecutor, + *, + connection_lookups: Mapping[OperationRef, str] | None = None, + connection_capabilities: Mapping[str, str] | None = None, + connection_api_version: str | None = None, +) -> Mapping[OperationRef, ExposureOperation]: + from umf_access_generated_executor import is_verified_executor_for + + profile = ( + _required_record_read_profile( + connection_lookups, connection_capabilities, connection_api_version + ) + or "" + ) + if ( + not is_verified_executor_for(executor, native) + or executor.read_profile != profile + or ( + connection_lookups is None + and config.capabilities.get("identity.codec") + != "lintel.node-id.string-key/1" + ) + or config.capabilities.get("read.consistency") != "request-snapshot-1" + ): + raise ValueError("Record roots require the verified batch profile") + trust = executor.trusted_artifact + algebra_digest = hashlib.sha256(executor.read_algebra_json).hexdigest() + routes = sorted( + [item.host_operation, item.ref.module, item.ref.id, item.primary_key_id] + for item in config.record_roots + ) + required = { + "read.consistency": "request-snapshot-1", + "read.profile": executor.read_profile, + "source.digest": native.source_digest, + "binding.digest": executor.target.binding_digest, + "algebra.digest": algebra_digest, + "artifact.digest": trust.artifact_digest, + "receipt.digest": trust.receipt_digest, + "records.digest": hashlib.sha256( + json.dumps(routes, ensure_ascii=False, separators=(",", ":")).encode( + "utf-8" + ) + ).hexdigest(), + } + if any( + host.config.selected_capabilities.get(key) != value + for key, value in required.items() + ): + raise ValueError("Record roots differ from selected Host pins") + if connection_lookups is not None and ( + connection_capabilities is None + or any( + host.config.selected_capabilities.get(key) != value + for key, value in connection_capabilities.items() + ) + ): + raise ValueError("connection routes differ from selected Host pins") + roots = tuple( + _mapping(value) + for value in _mapping( + _mapping(json.loads(executor.read_algebra_json))["roots"] + ).values() + ) + operations: dict[OperationRef, ExposureOperation] = {} + seen = {item.host_operation for item in config.operations} | set( + dict(native.operations) + ) + for exposed in config.record_roots: + operation = host.operations.get(exposed.host_operation) + matches = [ + root + for root in roots + if (root["module"], root["record"]) == (exposed.ref.module, exposed.ref.id) + ] + if ( + cast(str, exposed.ref.kind) != "record" + or exposed.ref in operations + or exposed.host_operation in seen + or operation is None + or operation.mutation + or "get_many" not in operation.selection_kinds + or ( + exposed.ref in (connection_lookups or {}) + and "connection" not in operation.selection_kinds + ) + or len(matches) != 1 + or ( + exposed.source_digest, + exposed.artifact_digest, + exposed.receipt_digest, + exposed.binding_digest, + exposed.algebra_sha256, + ) + != ( + native.source_digest, + trust.artifact_digest, + trust.receipt_digest, + executor.target.binding_digest, + algebra_digest, + ) + ): + raise ValueError("Record root differs from admitted inventory") + _key(matches[0], exposed) + _fields(matches[0], exposed) + operations[exposed.ref] = ExposureOperation( + exposed.ref, + exposed.host_operation, + ("get_many", "connection") + if exposed.ref in (connection_lookups or {}) + else ("get_many",), + ElementRef(exposed.ref.module, exposed.ref.id), + exposed.primary_key_id, + exposed.fields, + exposed.key_wrappers, + exposed.field_wrappers, + nullable_fields=exposed.nullable_fields, + ) + seen.add(exposed.host_operation) + return MappingProxyType(operations) diff --git a/packages/batten-local/src/batten/lintel/_record_root.py b/packages/batten-local/src/batten/lintel/_record_root.py new file mode 100644 index 0000000..cc62f79 --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_record_root.py @@ -0,0 +1,34 @@ +"""Explicit Record-root exposure pins, separate from source commands.""" + +from dataclasses import dataclass + +from lintel.ports import ElementRef, OperationRef + + +@dataclass(frozen=True) +class ExposureRecordRoot: + ref: OperationRef + host_operation: str + source_digest: str + artifact_digest: str + receipt_digest: str + binding_digest: str + algebra_sha256: str + primary_key_id: str + fields: tuple[ElementRef, ...] + key_wrappers: tuple[str, ...] + field_wrappers: tuple[tuple[ElementRef, str], ...] + nullable_fields: tuple[ElementRef, ...] = () + + def __post_init__(self) -> None: + if type(self.ref) is not OperationRef: + raise ValueError("Record exposure requires an exact qualified reference") + for name in ("fields", "nullable_fields"): + values = tuple(getattr(self, name)) + if any(type(value) is not ElementRef for value in values): + raise ValueError("Record exposure requires qualified Field references") + object.__setattr__(self, name, values) + object.__setattr__(self, "key_wrappers", tuple(self.key_wrappers)) + object.__setattr__( + self, "field_wrappers", tuple(tuple(pair) for pair in self.field_wrappers) + ) diff --git a/packages/batten-local/src/batten/lintel/_response.py b/packages/batten-local/src/batten/lintel/_response.py new file mode 100644 index 0000000..cb42ab3 --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_response.py @@ -0,0 +1,46 @@ +"""Bound one HTTP response until the ingress-owned Host scope closes.""" + +from starlette.types import Message, Send + + +class BufferedResponse: + def __init__(self, maximum: int): + self.maximum = maximum + self.start: Message | None = None + self.body = bytearray() + self.complete = False + self.used = 0 + + async def capture(self, message: Message) -> None: + kind = message.get("type") + if kind == "http.response.start": + if self.start is not None or type(message.get("status")) is not int: + raise ValueError("invalid response start") + headers = [ + (bytes(key), bytes(value)) for key, value in message.get("headers", []) + ] + self.used += sum(len(key) + len(value) for key, value in headers) + self.start = {"type": kind, "status": message["status"], "headers": headers} + elif kind == "http.response.body": + if self.start is None or self.complete: + raise ValueError("invalid response body") + chunk = message.get("body", b"") + if ( + type(chunk) is not bytes + or type(message.get("more_body", False)) is not bool + ): + raise ValueError("invalid response chunk") + self.used += len(chunk) + if self.used <= self.maximum: + self.body.extend(chunk) + self.complete = not message.get("more_body", False) + else: + raise ValueError("unsupported response event") + if self.used > self.maximum: + raise ValueError("response capacity exceeded") + + async def flush(self, send: Send) -> None: + if self.start is None or not self.complete: + raise ValueError("response did not complete") + await send(self.start) + await send({"type": "http.response.body", "body": bytes(self.body)}) diff --git a/packages/batten-local/src/batten/lintel/_session.py b/packages/batten-local/src/batten/lintel/_session.py new file mode 100644 index 0000000..beb2e8a --- /dev/null +++ b/packages/batten-local/src/batten/lintel/_session.py @@ -0,0 +1,354 @@ +"""Neutral Lintel calls translated exclusively through public Batten dispatch.""" + +from __future__ import annotations + +import asyncio +import json +from collections.abc import Mapping +from dataclasses import replace +from typing import TYPE_CHECKING, NoReturn, cast + +from batten.contracts import ExecutionScope, OperationCall, SelectedKey, Selection +from batten.lintel import _decode +from batten.lintel._command import command_result +from batten.lintel._config import ExposureOperation +from batten.lintel._failure import failure +from batten.runtime import Host + +from lintel.ports import ( + Arguments, + CommandResult, + ConnectionPage, + ElementRef, + ExecutionError, + ExecutionErrorCode, + NodeKey, + NodeValue, + OperationRef, +) + +if TYPE_CHECKING: + from lintel.ports import ConnectionIntent + + +def selected_key(value: NodeKey) -> SelectedKey: + return SelectedKey( + (value.record.module, value.record.element), + value.key_id, + tuple(_decode.literal(component) for component in value.components), + ) + + +def checked_keys( + keys: tuple[NodeKey, ...], exposure: ExposureOperation +) -> tuple[NodeKey, ...]: + return tuple( + _decode.key( + { + "record": value.record, + "keyId": value.key_id, + "components": value.components, + }, + exposure, + ) + for value in keys + ) + + +def _arguments(values: Arguments) -> Mapping[str, object]: + return { + name: selected_key(value) + if isinstance(value, NodeKey) + else (None if value is None else _decode.literal(value)) + for name, value in values.items() + } + + +class Session: + def __init__( + self, + host: Host, + scope: ExecutionScope, + kind: str, + operations: Mapping[OperationRef, ExposureOperation], + *, + planned_intents: tuple[ConnectionIntent, ...] = (), + connection_operations: Mapping[OperationRef, str] | None = None, + result_budget: int | None = None, + planned_mode: bool = False, + ): + self.host, self.scope, self.kind, self.operations = ( + host, + scope, + kind, + operations, + ) + self.active = True + self._planned = list(planned_intents) + self._planned_used: set[int] = set() + self._connection_operations = connection_operations or {} + self._budget_limit = result_budget + self._planned_mode = planned_mode + self._budget_used = 0 + self._budget_failed = False + self._selected_failure: ExecutionError | None = None + self._selected_lock = asyncio.Lock() + + def ensure_budget(self) -> None: + if self._budget_failed: + raise ExecutionError("LIMIT_EXCEEDED") + if self._selected_failure is not None: + raise self._selected_failure + + def _remember_failure(self, error: ExecutionError) -> None: + if self._planned_mode and self._selected_failure is None: + self._selected_failure = error + + def _refuse(self, code: ExecutionErrorCode) -> NoReturn: + error = ExecutionError(code) + self._remember_failure(error) + raise error + + @property + def budget_exceeded(self) -> bool: + return self._budget_failed + + def _charge(self, result: Mapping[str, object]) -> None: + if self._budget_limit is None: + return + remaining = self._budget_limit - self._budget_used + encoder = json.JSONEncoder( + ensure_ascii=False, + sort_keys=True, + separators=(",", ":"), + allow_nan=False, + default=_json_default, + ) + size = 0 + for chunk in encoder.iterencode(dict(result)): + size += len(chunk.encode("utf-8", errors="strict")) + if size > remaining: + self._budget_failed = True + self._refuse("LIMIT_EXCEEDED") + if size > remaining: + self._budget_failed = True + self._refuse("LIMIT_EXCEEDED") + self._budget_used += size + + def _exposure( + self, operation: OperationRef, fields: tuple[ElementRef, ...] = () + ) -> ExposureOperation: + if not self.active or not self.host.scope_active(self.scope): + self._refuse("DENIED") + exposure = self.operations.get(operation) + if ( + exposure is None + or len(set(fields)) != len(fields) + or not set(fields).issubset(exposure.fields) + ): + self._refuse("UNSUPPORTED") + return exposure + + async def _dispatch( + self, + exposure: ExposureOperation, + values: Mapping[str, object], + selection: Selection, + ) -> Mapping[str, object]: + if selection.kind not in exposure.selection_kinds: + self._refuse("UNSUPPORTED") + result = await self.host.invoke( + OperationCall( + exposure.host_operation, values, self.scope.principal, scope=self.scope + ), + selection=selection, + ) + if result.status != "succeeded": + error = failure(result.status, result.code) + self._remember_failure(error) + raise error + return result.result + + async def get_many( + self, + operation: OperationRef, + keys: tuple[NodeKey, ...], + fields: tuple[ElementRef, ...], + ) -> tuple[NodeValue | None, ...]: + try: + exposure = self._exposure(operation, fields) + keys = checked_keys(keys, exposure) + selection = Selection( + "get_many", + tuple((field.module, field.element) for field in fields), + tuple(selected_key(value) for value in keys), + ) + async with self._selected_lock: + self.ensure_budget() + result = await self._dispatch(exposure, {}, selection) + self._charge(result) + return _decode.items(result, "get_many", exposure, fields, keys) + except ExecutionError as error: + self._remember_failure(error) + raise + + async def connection( + self, + operation: OperationRef, + arguments: Arguments, + first: int, + after: str | None, + fields: tuple[ElementRef, ...], + ) -> ConnectionPage: + if self._planned_mode: + self._refuse("UNSUPPORTED") + try: + exposure = self._exposure(operation, fields) + selection = Selection( + "connection", + tuple((field.module, field.element) for field in fields), + first=first, + after=after, + ) + async with self._selected_lock: + self.ensure_budget() + result = await self._dispatch( + exposure, _arguments(arguments), selection + ) + self._charge(result) + return _decode.connection(result, exposure, fields, first) + except ExecutionError as error: + self._remember_failure(error) + raise + + async def planned_connection(self, intent: ConnectionIntent) -> ConnectionPage: + if not self.active or not self._planned_mode: + self._refuse("UNSUPPORTED") + index = next( + ( + position + for position, planned in enumerate(self._planned) + if position not in self._planned_used and planned == intent + ), + None, + ) + if index is None: + self._refuse("UNSUPPORTED") + self._planned_used.add(index) + try: + operation = self._connection_operations.get(intent.lookup) + exposure = self._exposure(intent.lookup, intent.fields) + if operation != exposure.host_operation: + self._refuse("UNSUPPORTED") + selection = Selection( + "connection", + tuple((field.module, field.element) for field in intent.fields), + first=intent.first, + after=intent.after, + ) + async with self._selected_lock: + self.ensure_budget() + result = await self._dispatch(exposure, {}, selection) + self._charge(result) + return _decode.connection(result, exposure, intent.fields, intent.first) + except ExecutionError as error: + self._remember_failure(error) + raise + + async def related_many( + self, + operation: OperationRef, + parents: tuple[NodeKey, ...], + target: ElementRef, + fields: tuple[ElementRef, ...], + ) -> tuple[NodeValue | None, ...]: + exposure = self._exposure(operation, fields) + if target != exposure.related_target: + raise ExecutionError("UNSUPPORTED") + if exposure.parent_record is None or exposure.parent_key_id is None: + raise ExecutionError("UNSUPPORTED") + parents = checked_keys( + parents, + replace( + exposure, + record=exposure.parent_record, + key_id=exposure.parent_key_id, + key_wrappers=exposure.parent_key_wrappers, + ), + ) + selection = Selection( + "related_many", + tuple((field.module, field.element) for field in fields), + parents=tuple(selected_key(value) for value in parents), + target=(target.module, target.element), + ) + async with self._selected_lock: + self.ensure_budget() + result = await self._dispatch(exposure, {}, selection) + self._charge(result) + return _decode.items(result, "related_many", exposure, fields, parents) + + async def _command( + self, + operation: OperationRef, + values: Arguments, + invocation_key: str, + phase: str, + confirmation: str | None, + ) -> CommandResult: + exposure = self._exposure(operation) + if phase == "invoke" and self.kind != "mutation": + raise ExecutionError("DENIED") + if not self.host.operations[exposure.host_operation].mutation: + raise ExecutionError("UNSUPPORTED") + result = await self.host.invoke( + OperationCall( + exposure.host_operation, + _arguments(values), + self.scope.principal, + invocation_key, + phase, + self.scope, + confirmation, + ) + ) + if result.status == "uncertain": + return CommandResult( + "unknown", invocation_key, "unknown", (), None, None, None + ) + if result.status != "succeeded": + raise failure(result.status, result.code) + try: + if result.invocation != invocation_key: + raise ExecutionError("INVALID") + return command_result(result.result, exposure, invocation_key, phase) + except ExecutionError: + return CommandResult( + "unknown", invocation_key, "unknown", (), None, None, None + ) + + async def invoke( + self, + operation: OperationRef, + arguments: Arguments, + invocation_key: str, + confirmation: str | None, + ) -> CommandResult: + return await self._command( + operation, arguments, invocation_key, "invoke", confirmation + ) + + async def observe( + self, operation: OperationRef, arguments: Arguments, invocation_key: str + ) -> CommandResult: + return await self._command( + operation, arguments, invocation_key, "observe", None + ) + + +def _json_default(value: object) -> object: + if isinstance(value, Mapping): + return dict(cast(Mapping[str, object], value)) + if type(value) is tuple: + return list(cast(tuple[object, ...], value)) + raise TypeError("selected result contains a non-JSON value") diff --git a/packages/batten-local/src/batten/lintel/asgi.py b/packages/batten-local/src/batten/lintel/asgi.py new file mode 100644 index 0000000..01832fb --- /dev/null +++ b/packages/batten-local/src/batten/lintel/asgi.py @@ -0,0 +1,162 @@ +"""Host-owned ASGI scope custody for an independently mounted Lintel router.""" + +from __future__ import annotations + +import asyncio +import math +import uuid +from collections.abc import Awaitable, Callable, Mapping +from typing import cast + +from batten.contracts import Actor, ExecutionScope, ShutdownReport +from batten.runtime import Host +from starlette.requests import Request +from starlette.responses import JSONResponse +from starlette.types import ASGIApp, Receive, Scope, Send + +from lintel.ports import ExecutionError, RequestScope + +from ._response import BufferedResponse + + +class HostScopeIngress: + def __init__( + self, + host: Host, + *, + api_digest: str, + resolve_actor: Callable[[Request], Awaitable[Actor | None]], + max_response_bytes: int, + close_scope: Callable[[ExecutionScope], Awaitable[ShutdownReport]] + | None = None, + ): + if ( + not api_digest + or type(max_response_bytes) is not int + or max_response_bytes < 1 + ): + raise ValueError("explicit API and response bound required") + self.host, self.api_digest = host, api_digest + self.resolve_actor, self.maximum = resolve_actor, max_response_bytes + self.close_scope = close_scope + self._state_key = "batten.lintel." + uuid.uuid4().hex + + async def resolve_context(self, request: object, api_digest: str) -> RequestScope: + if not isinstance(request, Request) or api_digest != self.api_digest: + raise ExecutionError("API_MISMATCH") + state: object = request.scope.get("state") + authority: object = ( + cast(Mapping[str, object], state).get(self._state_key) + if isinstance(state, Mapping) + else None + ) + if ( + type(authority) is not ExecutionScope + or not self.host.scope_active(authority) + or authority.api_digest != self.api_digest + or authority.consistency != "request-snapshot-1" + ): + raise ExecutionError("API_MISMATCH") + return RequestScope( + authority.application.id, + self.api_digest, + "query", + authority, + authority.request_id, + authority.deadline_monotonic, + ) + + def wrap(self, app: ASGIApp) -> ASGIApp: + return _ScopedApp(self, app, self._state_key) + + +async def _error( + code: str, scope: Scope, receive: Receive, send: Send, status: int = 503 +) -> None: + await JSONResponse( + {"errors": [{"message": code, "extensions": {"code": code}}]}, + status_code=status, + )(scope, receive, send) + + +class _ScopedApp: + def __init__(self, ingress: HostScopeIngress, app: ASGIApp, state_key: str): + self.ingress, self.app = ingress, app + self._state_key = state_key + + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: + if scope["type"] == "http": + await self._http(scope, receive, send) + else: + await self.app(scope, receive, send) + + async def _http(self, scope: Scope, receive: Receive, send: Send) -> None: + owner = self.ingress + deadline = owner.host.services.monotonic() + owner.host.config.timeout_seconds + authority: ExecutionScope | None = None + response = BufferedResponse(owner.maximum) + failure: str | None = None + try: + if not math.isfinite(deadline): + raise ValueError("invalid request deadline") + async with asyncio.timeout(owner.host.config.timeout_seconds): + actor = await owner.resolve_actor(Request(scope, receive)) + if actor is None: + await _error("DENIED", scope, receive, send, 401) + return + authority = await owner.host.open_scope( + actor, + uuid.uuid4().hex, + deadline_monotonic=deadline, + api_digest=owner.api_digest, + consistency="request-snapshot-1", + ) + request_scope = dict(scope) + request_scope["state"] = { + **scope.get("state", {}), + self._state_key: authority, + } + remaining = authority.deadline_monotonic - owner.host.services.monotonic() + async with asyncio.timeout(remaining): + await self.app(request_scope, receive, response.capture) + except TimeoutError: + failure = "LIMIT_EXCEEDED" + except Exception: + failure = "BUSY" + finally: + if authority is not None: + if not await _close_scope(owner, authority): + failure = "BUSY" + if failure is not None or not response.complete: + await _error(failure or "BUSY", scope, receive, send) + else: + await response.flush(send) + + +async def _close_scope(owner: HostScopeIngress, authority: ExecutionScope) -> bool: + closer = owner.close_scope or owner.host.close_scope + + async def close() -> ShutdownReport: + return await closer(authority) + + task = asyncio.create_task(close()) + cancellation: asyncio.CancelledError | None = None + while True: + try: + report = await asyncio.shield(task) + break + except asyncio.CancelledError as error: + cancellation = error + if task.done(): + report = task.result() + break + except Exception: + if cancellation is not None: + raise cancellation + return False + if cancellation is not None: + raise cancellation + return report.state == "closed" + + +__all__ = ["HostScopeIngress"] diff --git a/packages/batten-local/src/batten/umf_postgres/__init__.py b/packages/batten-local/src/batten/umf_postgres/__init__.py index 2c2bd7b..87638a4 100644 --- a/packages/batten-local/src/batten/umf_postgres/__init__.py +++ b/packages/batten-local/src/batten/umf_postgres/__init__.py @@ -4,11 +4,49 @@ import asyncio from collections.abc import Callable, Mapping -from typing import Protocol +from typing import TYPE_CHECKING, Protocol from batten.contracts import Actor, Identity from umf_access.unified import SessionIdentity +if TYPE_CHECKING: + from .generated_batch import ( + GeneratedBatchBinding, + GeneratedBatchExecution, + GeneratedBatchRequest, + ) + from .generated_command import GeneratedCommandExecution, GeneratedCommandRoute + from .generated_relationship import ( + GeneratedRelationshipRoute, + GeneratedRelationships, + ) + from .generated_table import GeneratedTableBinding, GeneratedTableExecution + + +def __getattr__(name: str) -> object: + """Resolve generated exports only when the generated provider is selected.""" + if name in { + "GeneratedBatchBinding", + "GeneratedBatchExecution", + "GeneratedBatchRequest", + }: + from . import generated_batch + + return getattr(generated_batch, name) + if name in {"GeneratedCommandExecution", "GeneratedCommandRoute"}: + from . import generated_command + + return getattr(generated_command, name) + if name in {"GeneratedRelationshipRoute", "GeneratedRelationships"}: + from . import generated_relationship + + return getattr(generated_relationship, name) + if name in {"GeneratedTableBinding", "GeneratedTableExecution"}: + from . import generated_table + + return getattr(generated_table, name) + raise AttributeError(name) + class AuthenticatedTransport(Protocol): async def execute(self, request: dict[str, object]) -> dict[str, object]: ... @@ -72,6 +110,15 @@ def create_umf_provider( __all__ = [ "AuthenticatedTransport", + "GeneratedBatchBinding", + "GeneratedBatchExecution", + "GeneratedBatchRequest", + "GeneratedCommandExecution", + "GeneratedCommandRoute", + "GeneratedRelationshipRoute", + "GeneratedRelationships", + "GeneratedTableBinding", + "GeneratedTableExecution", "NativeBinding", "UmfTableProvider", "create_umf_provider", diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_batch_routes.py b/packages/batten-local/src/batten/umf_postgres/_generated_batch_routes.py new file mode 100644 index 0000000..c9b3c18 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_batch_routes.py @@ -0,0 +1,104 @@ +"""Snapshot checked Record exposure pins before selected request execution.""" + +from dataclasses import dataclass +from typing import Protocol + + +class _Ref(Protocol): + @property + def module(self) -> str: ... + @property + def id(self) -> str: ... + + +class _Field(Protocol): + @property + def module(self) -> str: ... + @property + def element(self) -> str: ... + + +class RecordRoot(Protocol): + @property + def ref(self) -> _Ref: ... + @property + def host_operation(self) -> str: ... + @property + def source_digest(self) -> str: ... + @property + def artifact_digest(self) -> str: ... + @property + def receipt_digest(self) -> str: ... + @property + def binding_digest(self) -> str: ... + @property + def algebra_sha256(self) -> str: ... + @property + def primary_key_id(self) -> str: ... + @property + def fields(self) -> tuple[_Field, ...]: ... + @property + def key_wrappers(self) -> tuple[str, ...]: ... + @property + def field_wrappers(self) -> tuple[tuple[_Field, str], ...]: ... + + +@dataclass(frozen=True) +class RecordRoute: + host_operation: str + module: str + record: str + source_digest: str + artifact_digest: str + receipt_digest: str + binding_digest: str + algebra_sha256: str + primary_key_id: str + fields: tuple[tuple[str, str], ...] + key_wrappers: tuple[str, ...] + field_wrappers: tuple[tuple[tuple[str, str], str], ...] + + +def snapshot_route(operation: str, root: RecordRoot) -> RecordRoute: + module, record = root.ref.module, root.ref.id + fields = tuple((field.module, field.element) for field in root.fields) + wrappers = tuple( + ((field.module, field.element), wrapper) + for field, wrapper in root.field_wrappers + ) + values = ( + operation, + root.host_operation, + module, + record, + root.source_digest, + root.artifact_digest, + root.receipt_digest, + root.binding_digest, + root.algebra_sha256, + root.primary_key_id, + *root.key_wrappers, + *(value for ref, wrapper in wrappers for value in (*ref, wrapper)), + *(value for ref in fields for value in ref), + ) + if any(type(value) is not str or not value for value in values): + raise ValueError("Record root identity or pins differ") + if operation != root.host_operation: + raise ValueError("Record operation differs from route") + return RecordRoute( + operation, + module, + record, + root.source_digest, + root.artifact_digest, + root.receipt_digest, + root.binding_digest, + root.algebra_sha256, + root.primary_key_id, + fields, + tuple(root.key_wrappers), + wrappers, + ) + + +__all__ = ["RecordRoot", "RecordRoute", "snapshot_route"] diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_batch_validation.py b/packages/batten-local/src/batten/umf_postgres/_generated_batch_validation.py new file mode 100644 index 0000000..088581b --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_batch_validation.py @@ -0,0 +1,100 @@ +"""Join selected Record exposure pins to the issued generated algebra.""" + +from collections.abc import Mapping +from typing import cast + +from ._generated_batch_routes import RecordRoute + +_WRAPPERS = { + "boolean": "boolean", + "string": "string", + "integer": "integerToken", + "decimal": "decimalToken", + "date": "date", + "timestamp": "timestamp", + "uuid": "uuid", +} + + +def source_ref(value: object) -> tuple[str, str]: + if not isinstance(value, Mapping): + raise ValueError("issued Field reference differs") + ref = cast(Mapping[str, object], value) + if set(ref) != {"module", "element"}: + raise ValueError("issued Field reference differs") + module, element = ref["module"], ref["element"] + if type(module) is not str or not module or type(element) is not str or not element: + raise ValueError("issued Field reference differs") + return module, element + + +def key_wrapper(field: Mapping[str, object]) -> str: + codec = field.get("codec") + if not isinstance(codec, Mapping): + raise ValueError("issued Key codec differs") + codec_map = cast(Mapping[str, object], codec) + if codec_map.get("profile") != "weft.query-codec-instructions/1": + raise ValueError("issued Key codec differs") + steps = codec_map.get("steps") + if type(steps) is not list: + raise ValueError("issued Key codec differs") + step_items = cast(list[object], steps) + if len(step_items) != 4: + raise ValueError("issued Key codec differs") + first = step_items[0] + if not isinstance(first, Mapping): + raise ValueError("issued Key codec differs") + first_map = cast(Mapping[str, object], first) + if ( + first_map.get("op") != "require-exact-wrapper" + or first_map.get("nullable") is not False + or type(first_map.get("wrapper")) is not str + ): + raise ValueError("issued Key codec differs") + return cast(str, first_map["wrapper"]) + + +def check_root(issued: Mapping[str, object], root: RecordRoute) -> None: + key_id = root.primary_key_id + batch = issued.get("getMany") + batch_map = ( + cast(Mapping[str, object], batch) if isinstance(batch, Mapping) else None + ) + key_fields = batch_map.get("keyFields") if batch_map is not None else None + if ( + issued.get("primaryKeyId") != key_id + or batch_map is None + or batch_map.get("keyId") != key_id + or type(key_fields) is not list + or not key_fields + or tuple( + key_wrapper(cast(Mapping[str, object], item)) + for item in cast(list[object], key_fields) + ) + != root.key_wrappers + or any(wrapper not in set(_WRAPPERS.values()) for wrapper in root.key_wrappers) + ): + raise ValueError("Record primary Key differs from issued algebra") + fields = issued.get("fields") + if not isinstance(fields, Mapping): + raise ValueError("Record Fields are unavailable") + issued_fields: dict[tuple[str, str], tuple[str, Mapping[str, object]]] = {} + for field_id, value in cast(Mapping[str, object], fields).items(): + item = cast(Mapping[str, object], value) + issued_fields[source_ref(item.get("sourceField"))] = (field_id, item) + exposed = root.fields + wrappers = dict(root.field_wrappers) + if ( + len(set(exposed)) != len(exposed) + or len(wrappers) != len(root.field_wrappers) + or set(wrappers) != set(exposed) + or not set(exposed).issubset(issued_fields) + ): + raise ValueError("Record exposed Fields differ from issued algebra") + for ref in exposed: + output = cast(Mapping[str, object], issued_fields[ref][1]["output"]) + if wrappers[ref] != _WRAPPERS.get(cast(str, output["carrier"])): + raise ValueError("Record Field codec differs from issued output") + + +__all__ = ["check_root", "key_wrapper", "source_ref"] diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_connection.py b/packages/batten-local/src/batten/umf_postgres/_generated_connection.py new file mode 100644 index 0000000..44e56a0 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_connection.py @@ -0,0 +1,326 @@ +"""One-use prepared connection plans and their closed selected-result mapping.""" + +from __future__ import annotations + +import json +from collections.abc import Mapping +from dataclasses import dataclass +from typing import cast + +from batten.contracts import ( + OperationCall, + OperationOutcome, + SelectedCallSpec, + SelectedRequestError, + Selection, +) +from umf_access.unified import GeneratedNativeError + +from ._generated_table_routes import ConnectionRoute +from ._generated_values import native_read_refusal +from ._read_result import cell_size, result_sequence + +_PLAN_ISSUER = object() + + +@dataclass(frozen=True) +class PlannedConnection: + spec: SelectedCallSpec + native: object + module: str + record: str + source_digest: str + binding_digest: str + key_id: str + key_wrappers: tuple[str, ...] + field_descriptors: tuple[Mapping[str, object], ...] + field_ids: tuple[str, ...] + + +class GeneratedTablePlan: + """Nominal scope-bound plan; duplicate specs retain distinct occurrences.""" + + def __init__( + self, + owner: object, + scope: object, + calls: tuple[SelectedCallSpec, ...], + identity: object, + generated_scope: object, + items: tuple[PlannedConnection, ...], + *, + issuer: object, + ): + if issuer is not _PLAN_ISSUER: + raise ValueError("generated table plan must be provider issued") + self.owner, self.scope, self.calls = owner, scope, calls + self.identity, self.generated_scope, self.items = ( + identity, + generated_scope, + items, + ) + self.used: set[int] = set() + self.opened = False + + +def issue_table_plan( + owner: object, + scope: object, + calls: tuple[SelectedCallSpec, ...], + identity: object, + generated_scope: object, + items: tuple[PlannedConnection, ...], +) -> GeneratedTablePlan: + return GeneratedTablePlan( + owner, + scope, + calls, + identity, + generated_scope, + items, + issuer=_PLAN_ISSUER, + ) + + +def table_plan_from(value: object, owner: object, scope: object) -> GeneratedTablePlan: + if ( + type(value) is not GeneratedTablePlan + or value.owner is not owner + or value.scope is not scope + or value.opened + ): + raise ValueError("generated table plan scope or issuer differs") + value.opened = True + return value + + +def consume_connection( + plan: GeneratedTablePlan, call: OperationCall, selection: Selection +) -> tuple[int, PlannedConnection] | None: + for index, item in enumerate(plan.items): + if ( + index not in plan.used + and item.spec.call == call + and item.spec.selection == selection + ): + plan.used.add(index) + return index, item + return None + + +def connection_result( + result: object, item: PlannedConnection, maximum: int = 8_388_608 +) -> dict[str, object] | None: + try: + if not isinstance(result, Mapping): + raise ValueError("native connection frame is not a mapping") + frame = cast(Mapping[str, object], result) + expected_refs = tuple( + { + "module": cast( + str, cast(Mapping[str, object], value["sourceField"])["module"] + ), + "element": cast( + str, cast(Mapping[str, object], value["sourceField"])["element"] + ), + } + for value in item.field_descriptors + ) + raw_page = frame.get("pageInfo") + page = ( + cast(Mapping[str, object], raw_page) + if isinstance(raw_page, Mapping) + else None + ) + if ( + set(frame) + != { + "version", + "sourceDigest", + "bindingDigest", + "module", + "record", + "fields", + "edges", + "pageInfo", + } + or frame.get("version") != "umf.generated-forward-connection-result/1" + or frame.get("sourceDigest") != item.source_digest + or frame.get("bindingDigest") != item.binding_digest + or frame.get("module") != item.module + or frame.get("record") != item.record + or list(result_sequence(frame["fields"])) != list(expected_refs) + or page is None + or set(page) != {"hasNextPage", "hasPreviousPage"} + or type(page.get("hasNextPage")) is not bool + or type(page.get("hasPreviousPage")) is not bool + ): + raise ValueError("native connection frame pins differ") + edges = result_sequence(frame["edges"]) + if len(edges) > cast(int, item.spec.selection.first): + raise ValueError("native connection page exceeds first") + translated = _edges(edges, item) + value: dict[str, object] = { + "version": "batten.selected-result/1", + "kind": "connection", + "edges": translated, + "hasNextPage": page["hasNextPage"], + "hasPreviousPage": page["hasPreviousPage"], + } + if _json_size(value, maximum) > maximum: + raise ValueError("selected connection result exceeds capacity") + return value + except (KeyError, ValueError, TypeError, UnicodeError): + return None + + +def _json_size(value: object, maximum: int) -> int: + encoder = json.JSONEncoder( + ensure_ascii=False, + allow_nan=False, + separators=(",", ":"), + default=_json_default, + ) + size = 0 + for chunk in encoder.iterencode(value): + size += len(chunk.encode("utf-8", errors="strict")) + if size > maximum: + return size + return size + + +def _json_default(value: object) -> object: + if isinstance(value, Mapping): + return dict(cast(Mapping[str, object], value)) + if type(value) is tuple: + return list(cast(tuple[object, ...], value)) + raise TypeError("selected result contains a non-JSON value") + + +def _edges( + edges: tuple[object, ...], item: PlannedConnection +) -> list[dict[str, object]]: + seen: set[str] = set() + output: list[dict[str, object]] = [] + selection = item.spec.selection + for raw_edge in edges: + edge = _mapping(raw_edge, {"cursor", "node"}) + cursor = edge["cursor"] + if ( + type(cursor) is not str + or not cursor + or len(cursor.encode("utf-8")) > 2_000_000 + ): + raise ValueError("native edge cursor differs") + if cursor in seen: + raise ValueError("native edge cursors are duplicated") + seen.add(cursor) + node = _mapping(edge["node"], {"key", "fields"}) + key = _mapping(node["key"], {"keyId", "components"}) + components = result_sequence(key["components"]) + if key["keyId"] != item.key_id or len(components) != len(item.key_wrappers): + raise ValueError("native edge Key differs") + for component, wrapper in zip(components, item.key_wrappers, strict=True): + tagged = _mapping(component, {wrapper}) + if type(tagged[wrapper]) is not str: + raise ValueError("native edge Key scalar differs") + values = _mapping(node["fields"], set(item.field_ids)) + selected: dict[tuple[str, str], object] = {} + for descriptor, field_id in zip( + item.field_descriptors, item.field_ids, strict=True + ): + source = cast(Mapping[str, object], descriptor["sourceField"]) + reference = (cast(str, source["module"]), cast(str, source["element"])) + cell_size( + values[field_id], cast(Mapping[str, object], descriptor["output"]) + ) + selected[reference] = values[field_id] + fields = [ + {"field": list(reference), "value": selected[reference]} + for reference in selection.fields + ] + output.append({ + "cursor": cursor, + "node": { + "key": { + "record": [item.module, item.record], + "keyId": item.key_id, + "components": list(components), + }, + "fields": fields, + }, + }) + return output + + +def _mapping(value: object, members: set[str]) -> Mapping[str, object]: + if not isinstance(value, Mapping): + raise ValueError("native connection object shape differs") + mapping = cast(Mapping[str, object], value) + if set(mapping) != members: + raise ValueError("native connection object shape differs") + return mapping + + +def connection_fields( + route: ConnectionRoute, requested: tuple[tuple[str, str], ...] +) -> tuple[tuple[Mapping[str, object], ...], tuple[str, ...]]: + body = route.allowed_field_profile.body + descriptors = body.get("fields") + if ( + body.get("version") != "umf.allowed-connection-fields/1" + or type(descriptors) is not tuple + ): + raise ValueError("connection Field profile is unavailable") + by_ref: dict[tuple[str, str], tuple[str, Mapping[str, object]]] = {} + for raw in cast(tuple[object, ...], descriptors): + item = cast(Mapping[str, object], raw) + source = cast(Mapping[str, object], item["sourceField"]) + reference = (cast(str, source["module"]), cast(str, source["element"])) + by_ref[reference] = (cast(str, item["fieldId"]), item) + if len(set(requested)) != len(requested) or not set(requested).issubset(by_ref): + raise ValueError("connection Fields exceed the admitted profile") + chosen = tuple(by_ref[field] for field in requested) + return tuple(item for _field_id, item in chosen), tuple( + field_id for field_id, _item in chosen + ) + + +def field_reference(value: Mapping[str, object]) -> tuple[str, str]: + source = cast(Mapping[str, object], value["sourceField"]) + return cast(str, source["module"]), cast(str, source["element"]) + + +def connection_preflight_error(error: Exception, schema: str) -> SelectedRequestError: + if type(error) is GeneratedNativeError: + code = error.code + if code == "UNSUPPORTED": + return SelectedRequestError("invalid", "unsupported") + refusal = native_read_refusal( + {"schema": schema, "error": {"code": code}}, schema + ) + return SelectedRequestError(refusal.status, refusal.code) + return SelectedRequestError("unavailable", "native_refused") + + +def native_connection_error(error: Exception, schema: str) -> OperationOutcome | None: + if type(error) is not GeneratedNativeError: + return None + code = error.code + if code == "UNSUPPORTED": + return OperationOutcome("invalid", "", {}, "unsupported") + return native_read_refusal({"schema": schema, "error": {"code": code}}, schema) + + +__all__ = [ + "GeneratedTablePlan", + "PlannedConnection", + "connection_result", + "consume_connection", + "connection_fields", + "connection_preflight_error", + "issue_table_plan", + "field_reference", + "native_connection_error", + "table_plan_from", +] diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_join.py b/packages/batten-local/src/batten/umf_postgres/_generated_join.py new file mode 100644 index 0000000..4048ee4 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_join.py @@ -0,0 +1,234 @@ +"""Optional required-inner joined reads over one verified ``/8`` artifact.""" + +from __future__ import annotations + +from collections.abc import Awaitable, Callable, Mapping +from dataclasses import dataclass +from types import MappingProxyType +from typing import Literal, Protocol, cast + +from batten.contracts import ExecutionScope, Identity, OperationCall, OperationOutcome +from umf_access.unified import GeneratedNativeError, SessionIdentity +from umf_access_generated_executor import ( + ExecutionScope as GeneratedScope, +) +from umf_access_generated_executor import ( + GeneratedExecutionError, + GeneratedExecutor, + GeneratedJoinedReadCall, + GeneratedJoinedReadRoot, +) + +from ._generated_values import native_read_refusal, read_refusal +from ._read_binding import ReadBindingMetadata + +_PROFILE8 = "weft.generated-read-algebra/8" +_Route = tuple[str, str, str, str] + + +class GeneratedJoinBinding(ReadBindingMetadata, Protocol): + """Public native operations needed by the joined-read route.""" + + @property + def artifact_digest(self) -> str: ... + @property + def receipt_digest(self) -> str: ... + @property + def algebra_json(self) -> bytes: ... + @property + def joined_read_roots(self) -> tuple[GeneratedJoinedReadRoot, ...]: ... + + def joined_read_identity(self, call: GeneratedJoinedReadCall) -> str: ... + def validate_joined_read_result( + self, result: object, call: GeneratedJoinedReadCall + ) -> bool: ... + async def execute_joined_read( + self, + call: GeneratedJoinedReadCall, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: ... + + +@dataclass(frozen=True) +class _Invocation: + native: GeneratedJoinBinding + call: GeneratedJoinedReadCall + identity: SessionIdentity + scope: GeneratedScope + + +class GeneratedJoinExecution: + """Admit disjoint operations pinned to issuer-owned root/Relationship pairs.""" + + def __init__( + self, + executor: GeneratedExecutor, + factory: Callable[[], Awaitable[GeneratedJoinBinding]], + authority: Identity, + routes: Mapping[str, _Route], + ) -> None: + if ( + executor.read_profile != _PROFILE8 + or not routes + or any( + type(operation) is not str + or not operation + or type(route) is not tuple + or len(route) != 4 + or any(type(part) is not str or not part for part in route) + for operation, route in routes.items() + ) + ): + raise ValueError("generated joined-read profile and routes required") + self._executor, self._factory, self._authority = executor, factory, authority + self._routes = MappingProxyType(dict(routes)) + self._native: GeneratedJoinBinding | None = None + self._roots: Mapping[str, _Route] = MappingProxyType({}) + + async def prepare(self) -> None: + if self._native is not None: + return + native = await self._factory() + methods = ( + "joined_read_identity", + "execute_joined_read", + "validate_joined_read_result", + ) + if any(not callable(getattr(native, method, None)) for method in methods): + raise ValueError("native joined-read binding is incomplete") + if ( + native.schema != self._executor.native_table.source_digest + or native.read_profile != _PROFILE8 + or native.target_binding_digest != self._executor.target.binding_digest + or native.artifact_digest != self._executor.trusted_artifact.artifact_digest + or native.receipt_digest != self._executor.trusted_artifact.receipt_digest + or native.algebra_json != self._executor.read_algebra_json + ): + raise ValueError( + "native joined-read binding differs from verified artifact" + ) + roots = self._executor.joined_read_roots + if native.joined_read_roots != roots or len({ + (root.module, root.record, root.relationship_module, root.relationship_id) + for root in roots + }) != len(roots): + raise ValueError("verified joined-read root inventory is ambiguous") + issued = { + (root.module, root.record, root.relationship_module, root.relationship_id) + for root in roots + } + admitted: dict[str, _Route] = {} + for operation, route in self._routes.items(): + if route not in issued or route[0] != native.module: + raise ValueError("configured joined-read route is not verified") + admitted[operation] = route + self._native = native + self._roots = MappingProxyType(admitted) + + def capabilities(self) -> Mapping[str, str]: + if self._native is None or not self._roots: + return MappingProxyType({}) + return MappingProxyType({"read.joined": "statement-1"}) + + async def invoke(self, call: OperationCall) -> OperationOutcome: + refused = read_refusal(call) + if refused is not None: + return refused + prepared = self._prepare(call.snapshot()) + if isinstance(prepared, OperationOutcome): + return prepared + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + result = await prepared.native.execute_joined_read( + prepared.call, identity=prepared.identity, scope=prepared.scope + ) + if not prepared.native.validate_joined_read_result(result, prepared.call): + return OperationOutcome("unavailable", "", {}, "native_refused") + return _joined_outcome(result, prepared.native.schema) + + def _prepare(self, call: OperationCall) -> _Invocation | OperationOutcome: + native = self._native + route = self._roots.get(call.operation) + if native is None or route is None: + return OperationOutcome( + "unavailable" if native is None else "invalid", + "", + {}, + "not_prepared" if native is None else "unsupported", + ) + scope = cast(ExecutionScope, call.scope) + try: + if set(call.inputs) != {"join"}: + raise ValueError("joined-read envelope differs") + joined = GeneratedJoinedReadCall.from_mapping(call.inputs["join"]) + if ( + joined.root_module, + joined.root_record, + joined.relationship_module, + joined.relationship_id, + ) != route: + raise ValueError("joined-read route differs") + identity = SessionIdentity( + cast(Literal["person", "batch"], call.actor.kind), call.actor.subject + ) + generated_scope = GeneratedScope( + scope.application, + identity, + scope.request_id, + scope.deadline_monotonic, + scope.lease_id, + scope.api_digest, + scope.consistency, + ) + call_identity = native.joined_read_identity(joined) + if type(call_identity) is not str or not call_identity: + raise ValueError("joined-read identity is malformed") + except GeneratedNativeError as error: + return _joined_refusal(error.code, native.schema) + except GeneratedExecutionError as error: + return _joined_refusal(error.code, native.schema) + except (ValueError, TypeError, UnicodeError): + return OperationOutcome("invalid", "", {}, "invalid") + return _Invocation(native, joined, identity, generated_scope) + + async def aclose(self) -> None: + self._native = None + self._roots = MappingProxyType({}) + + +def _joined_refusal(code: str, schema: str) -> OperationOutcome: + outcomes = { + "DENIED": ("denied", "denied"), + "CONFLICT": ("precondition_failed", "precondition_failed"), + "INVALID": ("invalid", "invalid"), + "INVALID_CURSOR": ("invalid", "invalid_cursor"), + "UNSUPPORTED": ("invalid", "unsupported"), + "LIMIT_EXCEEDED": ("unavailable", "limit_exceeded"), + "TOO_MANY_ROWS": ("unavailable", "limit_exceeded"), + "SCHEMA_MISMATCH": ("unavailable", "schema_mismatch"), + "PRECONDITION_FAILED": ("precondition_failed", "precondition_failed"), + "BUSY": ("unavailable", "busy"), + } + if code in outcomes: + status, reason = outcomes[code] + return OperationOutcome(status, "", {}, reason) + return native_read_refusal({"schema": schema, "error": {"code": code}}, schema) + + +def _joined_outcome(result: Mapping[str, object], schema: str) -> OperationOutcome: + if set(result) == {"schema", "table"}: + return OperationOutcome("succeeded", "", result) + error = result.get("error") + if isinstance(error, Mapping): + error_mapping = cast(Mapping[str, object], error) + else: + error_mapping: Mapping[str, object] = {} + if set(error_mapping) == {"code"}: + value = error_mapping["code"] + return _joined_refusal(cast(str, value), schema) + return native_read_refusal(result, schema) + + +__all__ = ["GeneratedJoinBinding", "GeneratedJoinExecution"] diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_page.py b/packages/batten-local/src/batten/umf_postgres/_generated_page.py new file mode 100644 index 0000000..d965bb2 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_page.py @@ -0,0 +1,211 @@ +"""Ordinary Page calls over the verified combined generated read artifact.""" + +from __future__ import annotations + +from collections.abc import Awaitable, Callable, Mapping +from dataclasses import dataclass +from types import MappingProxyType +from typing import Literal, Protocol, cast + +from batten.contracts import ( + ExecutionScope, + Identity, + OperationCall, + OperationOutcome, +) +from umf_access.unified import GeneratedNativeError, SessionIdentity +from umf_access_generated_executor import ( + ExecutionScope as GeneratedScope, +) +from umf_access_generated_executor import ( + GeneratedExecutionError, + GeneratedExecutor, + GeneratedOrdinaryPageCall, + GeneratedOrdinaryPageRoot, +) + +from ._generated_values import native_read_refusal, read_refusal +from ._read_binding import ReadBindingMetadata + +_PROFILES = {"weft.generated-read-algebra/7", "weft.generated-read-algebra/8"} + + +class GeneratedPageBinding(ReadBindingMetadata, Protocol): + """Public native adapter operations used by the Page route.""" + + @property + def ordinary_page_roots(self) -> tuple[GeneratedOrdinaryPageRoot, ...]: ... + + @property + def artifact_digest(self) -> str: ... + @property + def receipt_digest(self) -> str: ... + @property + def algebra_json(self) -> bytes: ... + + def ordinary_page_identity(self, call: GeneratedOrdinaryPageCall) -> bytes: ... + + def validate_ordinary_page_result( + self, result: object, call: GeneratedOrdinaryPageCall + ) -> bool: ... + + async def execute_ordinary_page( + self, + call: GeneratedOrdinaryPageCall, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: ... + + +@dataclass(frozen=True) +class _PageInvocation: + native: GeneratedPageBinding + call: GeneratedOrdinaryPageCall + identity: SessionIdentity + scope: GeneratedScope + + +class GeneratedPageExecution: + """Prepare operation-to-eligible-root pins and execute ordinary Pages.""" + + def __init__( + self, + executor: GeneratedExecutor, + factory: Callable[[], Awaitable[GeneratedPageBinding]], + authority: Identity, + routes: Mapping[str, tuple[str, str]], + ) -> None: + if ( + executor.read_profile not in _PROFILES + or not routes + or any( + type(operation) is not str + or not operation + or type(root) is not tuple + or len(root) != 2 + or any(type(part) is not str or not part for part in root) + for operation, root in routes.items() + ) + ): + raise ValueError("combined generated Page profile required") + self._executor, self._factory, self._authority = executor, factory, authority + self._routes = MappingProxyType(dict(routes)) + self._roots: Mapping[str, str] = MappingProxyType({}) + self._native: GeneratedPageBinding | None = None + + async def prepare(self) -> None: + if self._native is not None: + return + native = await self._factory() + if any( + not callable(getattr(native, method, None)) + for method in ( + "ordinary_page_identity", + "execute_ordinary_page", + "validate_ordinary_page_result", + ) + ): + raise ValueError("native Page binding is incomplete") + if ( + native.schema != self._executor.native_table.source_digest + or native.read_profile not in _PROFILES + or native.target_binding_digest != self._executor.target.binding_digest + or native.artifact_digest != self._executor.trusted_artifact.artifact_digest + or native.receipt_digest != self._executor.trusted_artifact.receipt_digest + or native.algebra_json != self._executor.read_algebra_json + ): + raise ValueError("native Page binding differs from verified artifact") + verified_roots = self._executor.ordinary_page_roots + native_roots = native.ordinary_page_roots + if ( + len({root.root_id for root in verified_roots}) != len(verified_roots) + or len({(root.module, root.record) for root in verified_roots}) + != len(verified_roots) + or native_roots != verified_roots + ): + raise ValueError("verified Page root inventory is ambiguous") + issued = {(root.module, root.record): root.root_id for root in verified_roots} + admitted: dict[str, str] = {} + for operation, root in self._routes.items(): + root_id = issued.get(root) + if root_id is None or root[0] != native.module: + raise ValueError("configured Page route is not verified") + admitted[operation] = root_id + self._native = native + self._roots = MappingProxyType(admitted) + + def capabilities(self) -> Mapping[str, str]: + if self._native is None or not self._roots: + return MappingProxyType({}) + return MappingProxyType({"page.ordinary": "statement-1"}) + + async def invoke(self, call: OperationCall) -> OperationOutcome: + snapshot = call.snapshot() + prepared = self._prepare(snapshot) + if isinstance(prepared, OperationOutcome): + return prepared + if not await self._authority.check(snapshot.actor, snapshot.operation): + return OperationOutcome("denied", "", {}, "denied") + result = await prepared.native.execute_ordinary_page( + prepared.call, identity=prepared.identity, scope=prepared.scope + ) + if not prepared.native.validate_ordinary_page_result(result, prepared.call): + return native_read_refusal(result, prepared.native.schema) + return OperationOutcome("succeeded", "", result) + + def _prepare(self, call: OperationCall) -> _PageInvocation | OperationOutcome: + refused = read_refusal(call) + if refused is not None: + return refused + native = self._native + route_root = self._roots.get(call.operation) + if native is None or route_root is None: + return OperationOutcome( + "unavailable" if native is None else "invalid", + "", + {}, + "not_prepared" if native is None else "unsupported", + ) + scope = cast(ExecutionScope, call.scope) + try: + if set(call.inputs) != {"page"}: + raise ValueError("Page input envelope differs") + page = GeneratedOrdinaryPageCall.from_mapping(call.inputs["page"]) + if page.root_id != route_root: + raise ValueError("Page root differs from configured route") + identity = SessionIdentity( + cast(Literal["person", "batch"], call.actor.kind), call.actor.subject + ) + generated_scope = GeneratedScope( + scope.application, + identity, + scope.request_id, + scope.deadline_monotonic, + scope.lease_id, + scope.api_digest, + scope.consistency, + ) + page_identity = native.ordinary_page_identity(page) + if type(page_identity) is not bytes or len(page_identity) != 32: + raise ValueError("Page identity is malformed") + except GeneratedNativeError as error: + return _page_native_refusal(error.code, native.schema) + except GeneratedExecutionError as error: + return _page_native_refusal(error.code, native.schema) + except (ValueError, TypeError, UnicodeError): + return OperationOutcome("invalid", "", {}, "invalid") + return _PageInvocation(native, page, identity, generated_scope) + + async def aclose(self) -> None: + self._native = None + self._roots = MappingProxyType({}) + + +__all__ = ["GeneratedPageBinding", "GeneratedPageExecution"] + + +def _page_native_refusal(code: str, schema: str) -> OperationOutcome: + if code == "UNSUPPORTED": + return OperationOutcome("invalid", "", {}, "unsupported") + return native_read_refusal({"schema": schema, "error": {"code": code}}, schema) diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_table_binding.py b/packages/batten-local/src/batten/umf_postgres/_generated_table_binding.py new file mode 100644 index 0000000..48d6929 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_table_binding.py @@ -0,0 +1,75 @@ +"""Native provider port for generated table reads.""" + +from __future__ import annotations + +from collections.abc import Mapping +from contextlib import AbstractAsyncContextManager +from typing import Protocol + +from umf_access.unified import AsyncSession, SessionIdentity +from umf_access_generated_executor import ExecutionScope as GeneratedScope +from umf_access_generated_executor import ( + GeneratedOrdinaryPageCall, + GeneratedOrdinaryPageRoot, +) + +from ._generated_table_routes import ConnectionRoute as _ConnectionRoute + + +class _GeneratedTableRequest(Protocol): + async def execute_get_many(self, call: object) -> dict[str, object]: ... + async def execute_forward_connection( + self, prepared: object + ) -> dict[str, object]: ... + + +class GeneratedTableBinding(Protocol): + """One source/profile-bound native table adapter for all generated routes.""" + + @property + def connection_routes(self) -> Mapping[str, _ConnectionRoute]: ... + @property + def schema(self) -> str: ... + @property + def module(self) -> str: ... + @property + def target_binding_digest(self) -> str: ... + @property + def artifact_digest(self) -> str: ... + @property + def receipt_digest(self) -> str: ... + @property + def algebra_json(self) -> bytes: ... + @property + def read_profile(self) -> str | None: ... + + def open_request( + self, + identity: SessionIdentity, + scope: GeneratedScope, + *, + data_session: AsyncSession, + ) -> AbstractAsyncContextManager[_GeneratedTableRequest]: ... + + def prepare_forward_connection( + self, + request: object, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> object: ... + + @property + def ordinary_page_roots(self) -> tuple[GeneratedOrdinaryPageRoot, ...]: ... + + def ordinary_page_identity(self, call: GeneratedOrdinaryPageCall) -> bytes: ... + def validate_ordinary_page_result( + self, result: object, call: GeneratedOrdinaryPageCall + ) -> bool: ... + async def execute_ordinary_page( + self, + call: GeneratedOrdinaryPageCall, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: ... diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_table_routes.py b/packages/batten-local/src/batten/umf_postgres/_generated_table_routes.py new file mode 100644 index 0000000..bf307c6 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_table_routes.py @@ -0,0 +1,48 @@ +"""Read-only protocols for immutable generated connection route values.""" + +from __future__ import annotations + +from collections.abc import Mapping +from typing import Protocol + + +class ConnectionCursorScope(Protocol): + @property + def application_id(self) -> str: ... + + @property + def application_digest(self) -> str: ... + + @property + def api_digest(self) -> str: ... + + @property + def host_operation_id(self) -> str: ... + + @property + def allowed_field_profile_digest(self) -> str: ... + + +class AllowedFieldProfile(Protocol): + @property + def body(self) -> Mapping[str, object]: ... + + @property + def digest(self) -> str: ... + + +class ConnectionRoute(Protocol): + @property + def module(self) -> str: ... + + @property + def record(self) -> str: ... + + @property + def cursor_scope(self) -> ConnectionCursorScope: ... + + @property + def allowed_field_profile(self) -> AllowedFieldProfile: ... + + +__all__ = ["AllowedFieldProfile", "ConnectionCursorScope", "ConnectionRoute"] diff --git a/packages/batten-local/src/batten/umf_postgres/_generated_values.py b/packages/batten-local/src/batten/umf_postgres/_generated_values.py new file mode 100644 index 0000000..13631fc --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_generated_values.py @@ -0,0 +1,71 @@ +"""Shared generated-provider input snapshots and read-profile refusals.""" + +from collections.abc import Mapping +from typing import cast + +from batten.contracts import OperationCall, OperationOutcome + + +def snapshot_inputs(values: Mapping[str, object], maximum: int) -> dict[str, object]: + """Snapshot exact scalar wire values before awaiting authority or native I/O.""" + copied: dict[str, object] = {} + used = 0 + for name, value in values.items(): + if type(name) is not str or not name: + raise ValueError("invalid input identity") + used += len(name.encode("utf-8")) + if used > maximum or len(copied) >= 4096: + raise ValueError("input capacity exceeded") + if value is None: + copied[name] = None + continue + if ( + not isinstance(value, Mapping) + or len(cast(Mapping[object, object], value)) != 1 + ): + raise ValueError("unsupported input shape") + wrapper, scalar = next(iter(cast(Mapping[object, object], value).items())) + if not isinstance(wrapper, str) or type(scalar) not in {str, bool}: + raise ValueError("unsupported input shape") + used += len(wrapper.encode("utf-8")) + len(str(scalar).encode("utf-8")) + if used > maximum or len(copied) >= 4096: + raise ValueError("input capacity exceeded") + copied[name] = {wrapper: scalar} + return copied + + +def read_refusal(call: OperationCall) -> OperationOutcome | None: + if call.scope is None or call.scope.principal != call.actor: + return OperationOutcome("denied", "", {}, "scope_invalid") + if call.phase != "invoke" or call.key is not None or call.confirmation is not None: + return OperationOutcome("invalid", "", {}, "unsupported") + if call.scope.consistency not in {None, "statement"}: + return OperationOutcome("invalid", "", {}, "unsupported") + if call.actor.kind not in {"person", "batch"} or call.actor.delegation is not None: + return OperationOutcome("denied", "", {}, "authority_unsupported") + return None + + +def native_read_refusal(result: Mapping[str, object], schema: str) -> OperationOutcome: + """Preserve the upstream fixed error vocabulary without exposing diagnostics.""" + status, code = "unavailable", "native_refused" + error = result.get("error") + if ( + set(result) == {"schema", "error"} + and result["schema"] == schema + and isinstance(error, Mapping) + ): + value = cast(Mapping[str, object], error) + native_code = value.get("code") + if set(value) == {"code"} and type(native_code) is str: + status, code = { + "DENIED": ("denied", "denied"), + "INVALID": ("invalid", "invalid"), + "INVALID_CURSOR": ("invalid", "invalid_cursor"), + "PRECONDITION_FAILED": ("precondition_failed", "precondition_failed"), + "LIMIT_EXCEEDED": ("unavailable", "limit_exceeded"), + "TOO_MANY_ROWS": ("unavailable", "limit_exceeded"), + "SCHEMA_MISMATCH": ("unavailable", "schema_mismatch"), + "BUSY": ("unavailable", "busy"), + }.get(native_code, (status, code)) + return OperationOutcome(status, "", {}, code) diff --git a/packages/batten-local/src/batten/umf_postgres/_key_batch_result.py b/packages/batten-local/src/batten/umf_postgres/_key_batch_result.py new file mode 100644 index 0000000..0c09df7 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_key_batch_result.py @@ -0,0 +1,99 @@ +"""Translate only an exact upstream Key batch frame into selected node slots.""" + +import json +from collections.abc import Mapping +from typing import Protocol, cast + +from ._read_result import cell_size, result_sequence + + +class KeyBatchPins(Protocol): + @property + def source_digest(self) -> str: ... + @property + def target_digest(self) -> str: ... + @property + def root(self) -> Mapping[str, str]: ... + @property + def key_id(self) -> str: ... + @property + def keys(self) -> tuple[tuple[Mapping[str, object], ...], ...]: ... + @property + def fields(self) -> tuple[Mapping[str, object], ...]: ... + @property + def outputs(self) -> tuple[Mapping[str, object], ...]: ... + + +def selected_batch_result( + result: Mapping[str, object], bound: KeyBatchPins, maximum: int = 8_388_608 +) -> dict[str, object] | None: + try: + pins: dict[str, object] = { + "version": "umf.generated-key-batch-result/1", + "sourceDigest": bound.source_digest, + "bindingDigest": bound.target_digest, + "module": bound.root["module"], + "record": bound.root["record"], + "keyId": bound.key_id, + "fields": [dict(field) for field in bound.fields], + } + if set(result) != set(pins) | {"items"} or any( + result.get(key) != value for key, value in pins.items() + ): + raise ValueError("batch result provenance differs") + slots = result_sequence(result["items"]) + if len(slots) != len(bound.keys): + raise ValueError("batch slot count differs") + translated: dict[str, object] = { + "version": "batten.selected-result/1", + "kind": "get_many", + "items": [ + _slot(item, key, bound) + for item, key in zip(slots, bound.keys, strict=True) + ], + } + if ( + len( + json.dumps( + translated, + ensure_ascii=False, + allow_nan=False, + separators=(",", ":"), + ).encode("utf-8") + ) + > maximum + ): + raise ValueError("selected result capacity exceeded") + return translated + except (KeyError, ValueError, TypeError, UnicodeError): + return None + + +def _slot( + item: object, key: tuple[Mapping[str, object], ...], bound: KeyBatchPins +) -> dict[str, object] | None: + if item is None: + return None + if not isinstance(item, Mapping): + raise ValueError("batch slot must be a mapping") + node = cast(Mapping[str, object], item) + if set(node) != {"key", "values"} or list(result_sequence(node["key"])) != list( + key + ): + raise ValueError("batch key differs from requested slot") + values = result_sequence(node["values"]) + if len(values) != len(bound.outputs): + raise ValueError("batch selected values differ") + for value, output in zip(values, bound.outputs, strict=True): + cell_size(value, output) + return { + "key": { + "record": [bound.root["module"], bound.root["record"]], + "keyId": bound.key_id, + "components": [dict(component) for component in key], + }, + "fields": [ + {"field": [field["module"], field["element"]], "value": value} + for field, value in zip(bound.fields, values, strict=True) + ], + } diff --git a/packages/batten-local/src/batten/umf_postgres/_read_binding.py b/packages/batten-local/src/batten/umf_postgres/_read_binding.py new file mode 100644 index 0000000..788538f --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_read_binding.py @@ -0,0 +1,14 @@ +"""Host-only metadata shared by generated native read implementations.""" + +from typing import Protocol + + +class ReadBindingMetadata(Protocol): + @property + def schema(self) -> str: ... + @property + def module(self) -> str: ... + @property + def target_binding_digest(self) -> str: ... + @property + def read_profile(self) -> str | None: ... diff --git a/packages/batten-local/src/batten/umf_postgres/_read_result.py b/packages/batten-local/src/batten/umf_postgres/_read_result.py new file mode 100644 index 0000000..35a0e98 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_read_result.py @@ -0,0 +1,127 @@ +"""Bounded structural result gate; upstream native codecs own value semantics.""" + +import json +from collections.abc import Mapping +from typing import cast + +from umf_access_generated_executor import BoundReadProgram, GeneratedReadCall + +_WRAPPERS = { + "boolean": "boolean", + "string": "string", + "integer": "integerToken", + "decimal": "decimalToken", + "float": "floatToken", + "date": "date", + "timestamp": "timestamp", + "uuid": "uuid", + "bits128": "bits128Hex", +} + + +def result_sequence(value: object) -> tuple[object, ...]: + if not isinstance(value, (tuple, list)): + raise ValueError("native result list required") + return tuple(cast(tuple[object, ...] | list[object], value)) + + +def cell_size(value: object, output: Mapping[str, object]) -> int: + if value is None: + if output["nullable"] is not True: + raise ValueError("native result nullability differs") + return 4 + wrapper = _WRAPPERS.get(cast(str, output["carrier"])) + if not isinstance(value, Mapping): + raise ValueError("native result literal required") + literal = cast(Mapping[str, object], value) + if wrapper is None or set(literal) != {wrapper}: + raise ValueError("native result wrapper differs") + scalar = literal[wrapper] + expected = bool if wrapper == "boolean" else str + if type(scalar) is not expected: + raise ValueError("native result scalar differs") + return len( + json.dumps( + {wrapper: scalar}, + ensure_ascii=False, + separators=(",", ":"), + allow_nan=False, + ).encode("utf-8") + ) + + +def valid_read_result( + result: Mapping[str, object], + source: str, + call: GeneratedReadCall, + bound: BoundReadProgram, + maximum: int = 8_388_608, +) -> bool: + try: + _check_result(result, source, call, bound, maximum) + except (ValueError, KeyError, TypeError, UnicodeError): + return False + return True + + +def _check_result( + result: Mapping[str, object], + source: str, + call: GeneratedReadCall, + bound: BoundReadProgram, + maximum: int, +) -> None: + if set(result) != {"schema", "table"} or result["schema"] != source: + raise ValueError("native envelope differs") + raw = result["table"] + if not isinstance(raw, Mapping): + raise ValueError("native frame required") + frame = cast(Mapping[str, object], raw) + pins = { + "version": "umf.generated-read-result/1", + "kind": "many", + "sourceDigest": source, + "module": call.module, + "record": call.record, + "cursor": None, + } + if set(frame) != set(pins) | {"columns", "rows"} or any( + frame[key] != value for key, value in pins.items() + ): + raise ValueError("native frame pins differ") + columns = result_sequence(frame["columns"]) + expected = [ + {"field": dict(field), "output": dict(output)} + for field, output in zip(bound.fields, bound.outputs, strict=True) + ] + if list(columns) != expected: + raise ValueError("native columns differ") + rows = result_sequence(frame["rows"]) + if len(rows) > call.limit: + raise ValueError("native row capacity exceeded") + empty = {"schema": source, "table": {**pins, "columns": expected, "rows": []}} + used = len( + json.dumps( + empty, ensure_ascii=False, separators=(",", ":"), allow_nan=False + ).encode("utf-8") + ) + check_rows(rows, bound.outputs, used, maximum) + + +def check_rows( + rows: tuple[object, ...], + outputs: tuple[Mapping[str, object], ...], + used: int, + maximum: int, +) -> None: + if used > maximum: + raise ValueError("native result capacity exceeded") + for row_index, raw_row in enumerate(rows): + row = result_sequence(raw_row) + if len(row) != len(outputs): + raise ValueError("native row arity differs") + used += 2 + int(row_index > 0) + for column_index, (value, output) in enumerate(zip(row, outputs, strict=True)): + used += cell_size(value, output) + int(column_index > 0) + if used > maximum: + raise ValueError("native result capacity exceeded") diff --git a/packages/batten-local/src/batten/umf_postgres/_read_result_v2.py b/packages/batten-local/src/batten/umf_postgres/_read_result_v2.py new file mode 100644 index 0000000..1c3918b --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_read_result_v2.py @@ -0,0 +1,119 @@ +"""Exact terminal/frame shape checks around the upstream native G3 reader.""" + +import json +import re +from collections.abc import Mapping +from typing import cast + +from umf_access_generated_executor import BoundReadProgramV2, GeneratedReadCallV2 + +from ._read_result import cell_size, check_rows, result_sequence + + +def _mapping(value: object) -> Mapping[str, object]: + if not isinstance(value, Mapping): + raise ValueError("generated result mapping required") + return cast(Mapping[str, object], value) + + +def valid_read_result_v2( + result: Mapping[str, object], + source: str, + call: GeneratedReadCallV2, + bound: BoundReadProgramV2, + maximum: int = 8_388_608, +) -> bool: + try: + _check(result, source, call, bound, maximum) + except (KeyError, ValueError, TypeError, UnicodeError): + return False + return True + + +def _check( + result: Mapping[str, object], + source: str, + call: GeneratedReadCallV2, + bound: BoundReadProgramV2, + maximum: int, +) -> None: + if set(result) != {"schema", "table"} or result["schema"] != source: + raise ValueError("generated result envelope differs") + frame = _mapping(result["table"]) + pins = { + "version": "umf.generated-read-result/2", + "kind": bound.result_kind, + "terminal": call.terminal, + "sourceDigest": source, + "module": call.module, + "record": call.record, + } + if bound.terminal != call.terminal or any( + frame.get(key) != value for key, value in pins.items() + ): + raise ValueError("generated result terminal pins differ") + if bound.result_kind == "scalar": + _scalar(frame, pins, bound, maximum) + else: + _rows(frame, pins, bound, maximum) + + +def _scalar( + frame: Mapping[str, object], + pins: Mapping[str, object], + bound: BoundReadProgramV2, + maximum: int, +) -> None: + if set(frame) != set(pins) | {"value"} or bound.scalar_output is None: + raise ValueError("generated scalar result differs") + value = frame["value"] + used = cell_size(value, bound.scalar_output) + if bound.terminal == "count": + token = _mapping(value).get("integerToken") + if type(token) is not str or re.fullmatch(r"0|[1-9][0-9]*", token) is None: + raise ValueError("generated count result is not canonical nonnegative text") + if ( + used + len(json.dumps(dict(pins), ensure_ascii=False).encode("utf-8")) + 128 + > maximum + ): + raise ValueError("generated scalar result capacity exceeded") + + +def _rows( + frame: Mapping[str, object], + pins: Mapping[str, object], + bound: BoundReadProgramV2, + maximum: int, +) -> None: + if ( + set(frame) != set(pins) | {"columns", "rows", "cursor"} + or frame["cursor"] is not None + ): + raise ValueError("generated row frame differs") + columns = result_sequence(frame["columns"]) + expected = [ + {"field": dict(field), "output": dict(output)} + for field, output in zip(bound.fields, bound.outputs, strict=True) + ] + if list(columns) != expected: + raise ValueError("generated row columns differ") + rows = result_sequence(frame["rows"]) + if bound.row_limit is None or len(rows) > bound.row_limit: + raise ValueError("generated row count exceeds issued bound") + if bound.cardinality == "exactly-one" and len(rows) != 1: + raise ValueError("generated row count differs from exact terminal") + empty = { + "schema": frame["sourceDigest"], + "table": { + **pins, + "columns": expected, + "rows": [], + "cursor": None, + }, + } + used = len( + json.dumps( + empty, ensure_ascii=False, separators=(",", ":"), allow_nan=False + ).encode("utf-8") + ) + check_rows(rows, bound.outputs, used, maximum) diff --git a/packages/batten-local/src/batten/umf_postgres/_read_wire.py b/packages/batten-local/src/batten/umf_postgres/_read_wire.py new file mode 100644 index 0000000..302c35c --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/_read_wire.py @@ -0,0 +1,72 @@ +"""Exact portable data envelope for the upstream generated read binder.""" + +from collections.abc import Mapping +from typing import cast + +from umf_access_generated_executor import GeneratedReadCall, GeneratedReadFilter + +from ._generated_values import snapshot_inputs + + +def _object(value: object, keys: set[str]) -> Mapping[str, object]: + if not isinstance(value, Mapping): + raise ValueError("read envelope must be a mapping") + value = cast(Mapping[str, object], value) + if set(value) != keys: + raise ValueError("read envelope members differ") + return value + + +def _array(value: object, maximum: int = 64) -> tuple[object, ...]: + if not isinstance(value, (tuple, list)): + raise ValueError("read list required") + items = cast(tuple[object, ...] | list[object], value) + if len(items) > maximum: + raise ValueError("read list capacity exceeded") + return tuple(items) + + +def _ids(value: object) -> tuple[str, ...]: + items = _array(value) + if any(type(item) is not str or not item for item in items): + raise ValueError("read identity must be nonempty text") + return cast(tuple[str, ...], items) + + +def _filter(value: object, maximum: int) -> GeneratedReadFilter: + item = _object(value, {"predicate", "values"}) + predicate = _ids([item["predicate"]])[0] + values = _array(item["values"], 1) + copied = snapshot_inputs( + {str(index): part for index, part in enumerate(values)}, maximum + ) + return GeneratedReadFilter(predicate, tuple(copied.values())) + + +def read_call(inputs: Mapping[str, object], maximum: int) -> GeneratedReadCall: + envelope = _object(inputs, {"read"}) + value = _object( + envelope["read"], {"module", "record", "fields", "filters", "order", "limit"} + ) + module, record = _ids([value["module"], value["record"]]) + selection = None if value["fields"] is None else _ids(value["fields"]) + orders = _ids(value["order"]) + filters = _array(value["filters"]) + limit = value["limit"] + if type(limit) is not int or not 1 <= limit <= 1000: + raise ValueError("read row capacity exceeded") + # Each scalar is bounded before copying; the aggregate is bounded as well. + terms = tuple(_filter(item, maximum) for item in filters) + size = sum(len(text.encode("utf-8")) for text in (module, record, *orders)) + size += sum(len(text.encode("utf-8")) for text in selection or ()) + for term in terms: + size += len(term.predicate_id.encode("utf-8")) + for literal in term.values: + if literal is not None: + for wrapper, scalar in cast(Mapping[str, object], literal).items(): + size += len(wrapper.encode("utf-8")) + len( + str(scalar).encode("utf-8") + ) + if size > maximum: + raise ValueError("read input capacity exceeded") + return GeneratedReadCall(module, record, selection, terms, orders, limit) diff --git a/packages/batten-local/src/batten/umf_postgres/generated.py b/packages/batten-local/src/batten/umf_postgres/generated.py new file mode 100644 index 0000000..f201763 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated.py @@ -0,0 +1,116 @@ +"""Generated native execution through issued host scopes and upstream guards.""" + +from collections.abc import Awaitable, Callable, Mapping +from typing import Literal, Protocol, cast + +from batten.contracts import ExecutionScope, Identity, OperationCall, OperationOutcome +from umf_access.unified import SessionIdentity +from umf_access_generated_executor import ExecutionScope as GeneratedScope + +from ._generated_values import native_read_refusal, read_refusal, snapshot_inputs + + +class GeneratedNativeBinding(Protocol): + schema: str + module: str + + async def execute( + self, + request: dict[str, object], + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: ... + + +def _result_valid( + result: Mapping[str, object], native: GeneratedNativeBinding, operation: str +) -> bool: + table = result.get("table") + if ( + set(result) != {"schema", "table"} + or result.get("schema") != native.schema + or not isinstance(table, Mapping) + ): + return False + frame = cast(Mapping[str, object], table) + common = {"kind", "version", "module", "operation", "sourceDigest"} + fields = {"count"} if frame.get("kind") == "count" else {"rows", "cursor"} + return ( + set(frame) == common | fields + and frame.get("version") == "umf.table-read-result/0.1" + and frame.get("module") == native.module + and frame.get("operation") == operation + and frame.get("sourceDigest") == native.schema + and frame.get("kind") in ("count", "many", "one", "optional") + ) + + +class GeneratedUmfExecution: + def __init__( + self, + factory: Callable[[], Awaitable[GeneratedNativeBinding]], + authority: Identity, + *, + max_input_bytes: int = 8_388_608, + ): + if type(max_input_bytes) is not int or max_input_bytes < 1: + raise ValueError("positive input capacity required") + self._factory, self._authority = factory, authority + self._max_input_bytes = max_input_bytes + self._native: GeneratedNativeBinding | None = None + + async def prepare(self) -> None: + if self._native is None: + self._native = await self._factory() + + async def invoke(self, call: OperationCall) -> OperationOutcome: + refused = read_refusal(call) + if refused is not None: + return refused + scope = cast(ExecutionScope, call.scope) + try: + inputs = snapshot_inputs(call.inputs, self._max_input_bytes) + except (ValueError, UnicodeError): + return OperationOutcome("invalid", "", {}, "invalid") + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + native = self._native + if native is None: + return OperationOutcome("unavailable", "", {}, "not_prepared") + identity = SessionIdentity( + cast(Literal["person", "batch"], call.actor.kind), call.actor.subject + ) + generated_scope = GeneratedScope( + scope.application, + identity, + scope.request_id, + scope.deadline_monotonic, + scope.lease_id, + scope.api_digest, + scope.consistency, + ) + result = await native.execute( + { + "contract": "umf.access/1", + "schema": native.schema, + "kind": "table", + "module": native.module, + "operation": call.operation, + "call": {"kind": "single", "inputs": inputs}, + "phase": call.phase, + "mutation": False, + "idempotency_key": call.key, + }, + identity=identity, + scope=generated_scope, + ) + if not _result_valid(result, native, call.operation): + return native_read_refusal(result, native.schema) + return OperationOutcome("succeeded", "", result) + + async def aclose(self) -> None: + self._native = None + + +__all__ = ["GeneratedNativeBinding", "GeneratedUmfExecution"] diff --git a/packages/batten-local/src/batten/umf_postgres/generated_batch.py b/packages/batten-local/src/batten/umf_postgres/generated_batch.py new file mode 100644 index 0000000..051f104 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated_batch.py @@ -0,0 +1,487 @@ +"""Request-scoped selected primary-Key batches over issued UMF read artifacts.""" + +from __future__ import annotations + +import asyncio +import hashlib +import json +import math +import time +from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping +from contextlib import AbstractAsyncContextManager, asynccontextmanager +from dataclasses import dataclass +from types import MappingProxyType +from typing import Literal, Protocol, cast + +from batten.contracts import ( + ExecutionScope, + Identity, + OperationCall, + OperationOutcome, + Selection, +) +from umf_access import unified as native_runtime +from umf_access.unified import AsyncSession, SessionIdentity +from umf_access_generated_executor import ( + BoundKeyBatchProgram, + GeneratedExecutionError, + GeneratedExecutor, + GeneratedGetManyCall, +) +from umf_access_generated_executor import ( + ExecutionScope as GeneratedScope, +) + +from ._generated_batch_routes import RecordRoot, RecordRoute, snapshot_route +from ._generated_batch_validation import check_root, key_wrapper, source_ref +from ._generated_values import native_read_refusal +from ._key_batch_result import selected_batch_result + +_PROFILES = frozenset({ + "weft.generated-read-algebra/4", + "weft.generated-read-algebra/5", + "weft.generated-read-algebra/7", + "weft.generated-read-algebra/8", +}) +_CONSISTENCY = "request-snapshot-1" +_GENERATED_CONSISTENCY = "request-snapshot/1" + + +class GeneratedBatchRequest(Protocol): + async def execute_get_many( + self, call: GeneratedGetManyCall + ) -> dict[str, object]: ... + + +class GeneratedBatchBinding(Protocol): + schema: str + module: str + + @property + def read_profile(self) -> str | None: ... + @property + def target_binding_digest(self) -> str: ... + @property + def artifact_digest(self) -> str: ... + @property + def receipt_digest(self) -> str: ... + @property + def algebra_json(self) -> bytes: ... + def open_request( + self, + identity: SessionIdentity, + scope: GeneratedScope, + *, + data_session: AsyncSession, + ) -> AbstractAsyncContextManager[GeneratedBatchRequest]: ... + + +class _GeneratedConnectionRequest(Protocol): + async def execute_forward_connection( + self, prepared: object + ) -> dict[str, object]: ... + + +@dataclass(frozen=True) +class _Request: + host_scope: ExecutionScope + identity: SessionIdentity + generated_scope: GeneratedScope + native_request: GeneratedBatchRequest + + +def _digest(value: bytes) -> str: + return hashlib.sha256(value).hexdigest() + + +class GeneratedBatchExecution: + """Bind selected calls to one host-issued request snapshot and UMF v4 root.""" + + def __init__( + self, + executor: GeneratedExecutor, + factory: Callable[[], Awaitable[GeneratedBatchBinding]], + *, + data_session: AsyncSession, + authority: Identity, + roots: Mapping[str, RecordRoot], + ) -> None: + if ( + executor.read_profile not in _PROFILES + or type(data_session) is not AsyncSession + or not roots + or any(type(name) is not str or not name for name in roots) + ): + raise ValueError("verified v4 batch profile required") + self._executor, self._factory = executor, factory + self._profile = executor.read_profile + self._data_session, self._authority = data_session, authority + self._roots = MappingProxyType({ + operation: snapshot_route(operation, root) + for operation, root in roots.items() + }) + self._native: GeneratedBatchBinding | None = None + self._requests: dict[str, _Request] = {} + self._opening: set[str] = set() + self._lock = asyncio.Lock() + self._algebra = cast(dict[str, object], json.loads(executor.read_algebra_json)) + self._algebra_digest = _digest(executor.read_algebra_json) + self._source = executor.native_table.source_digest + self._target = executor.target.binding_digest + trust = executor.trusted_artifact + self._artifact, self._receipt = trust.artifact_digest, trust.receipt_digest + roots_rows: list[list[str]] = [] + algebra_roots = self._algebra.get("roots") + if not isinstance(algebra_roots, Mapping): + raise ValueError("verified Record roots are unavailable") + algebra_roots_map = cast(Mapping[str, object], algebra_roots) + for operation, root in self._roots.items(): + module, record = root.module, root.record + if ( + operation != root.host_operation + or root.source_digest != self._source + or root.artifact_digest != self._artifact + or root.receipt_digest != self._receipt + or root.binding_digest != self._target + or root.algebra_sha256 != self._algebra_digest + ): + raise ValueError("Record route provenance differs") + matches = [ + item + for value in algebra_roots_map.values() + for item in (cast(Mapping[str, object], value),) + if (item.get("module"), item.get("record")) == (module, record) + ] + if len(matches) != 1: + raise ValueError("Record route is absent from issued algebra") + check_root(matches[0], root) + roots_rows.append([operation, module, record, root.primary_key_id]) + roots_rows.sort() + self._records_digest = _digest( + json.dumps(roots_rows, ensure_ascii=False, separators=(",", ":")).encode() + ) + + def connection_key_profile( + self, module: str, record: str + ) -> tuple[str, tuple[str, ...], tuple[str, ...]]: + roots = cast(Mapping[str, object], self._algebra["roots"]) + matches = [ + cast(Mapping[str, object], value) + for value in roots.values() + if isinstance(value, Mapping) + and ( + cast(Mapping[str, object], value).get("module"), + cast(Mapping[str, object], value).get("record"), + ) + == (module, record) + ] + if len(matches) != 1: + raise ValueError("connection Record is absent from issued algebra") + root = matches[0] + batch = root.get("getMany") + if not isinstance(batch, Mapping): + raise ValueError("connection Key profile is unavailable") + key_fields = cast(Mapping[str, object], batch).get("keyFields") + key_id = root.get("primaryKeyId") + if type(key_id) is not str or type(key_fields) is not list or not key_fields: + raise ValueError("connection Key profile differs") + key_descriptors = tuple( + cast(Mapping[str, object], field) + for field in cast(list[object], key_fields) + ) + wrappers = tuple(key_wrapper(field) for field in key_descriptors) + if cast(Mapping[str, object], batch).get("keyId") != key_id: + raise ValueError("connection Key identity differs") + field_ids = tuple(cast(str, field["fieldId"]) for field in key_descriptors) + return key_id, wrappers, field_ids + + def capabilities(self) -> Mapping[str, str]: + return MappingProxyType({ + "read.consistency": _CONSISTENCY, + "read.profile": self._profile, + "source.digest": self._source, + "binding.digest": self._target, + "algebra.digest": self._algebra_digest, + "artifact.digest": self._artifact, + "receipt.digest": self._receipt, + "records.digest": self._records_digest, + }) + + async def prepare(self) -> None: + if self._native is not None: + return + native = await self._factory() + if ( + native.schema != self._source + or native.read_profile != self._profile + or native.target_binding_digest != self._target + or native.artifact_digest != self._artifact + or native.receipt_digest != self._receipt + or native.algebra_json != self._executor.read_algebra_json + or any(root.module != native.module for root in self._roots.values()) + ): + raise ValueError("native batch binding differs from verified artifact") + self._native = native + + @asynccontextmanager + async def open_request(self, scope: ExecutionScope) -> AsyncGenerator[None, None]: + identity, generated_scope = self.prepared_scope(scope) + async with self.open_prepared_request(scope, identity, generated_scope): + yield + + def prepared_scope( + self, scope: ExecutionScope + ) -> tuple[SessionIdentity, GeneratedScope]: + native = self._native + actor = scope.principal if type(scope) is ExecutionScope else None + if ( + native is None + or actor is None + or actor.kind not in {"person", "batch"} + or actor.delegation is not None + or scope.consistency != _CONSISTENCY + or not math.isfinite(scope.deadline_monotonic) + or time.monotonic() >= scope.deadline_monotonic + ): + raise ValueError("host request snapshot is unavailable") + identity = SessionIdentity( + cast(Literal["person", "batch"], actor.kind), actor.subject + ) + generated_scope = GeneratedScope( + scope.application, + identity, + scope.request_id, + scope.deadline_monotonic, + scope.lease_id, + scope.api_digest, + _GENERATED_CONSISTENCY, + ) + return identity, generated_scope + + def prepare_connection( + self, + request: object, + identity: SessionIdentity, + generated_scope: GeneratedScope, + ) -> object: + native = self._native + if native is None or not callable( + getattr(native, "prepare_forward_connection", None) + ): + raise ValueError("native connection profile is unavailable") + return cast( + Callable[..., object], getattr(native, "prepare_forward_connection") + )(request, identity=identity, scope=generated_scope) + + async def execute_connection( + self, + scope: ExecutionScope, + identity: SessionIdentity, + generated_scope: GeneratedScope, + prepared: object, + ) -> dict[str, object]: + context = self._requests.get(scope.lease_id) + execute = ( + getattr(context.native_request, "execute_forward_connection", None) + if context is not None + else None + ) + if ( + context is None + or context.host_scope is not scope + or context.identity is not identity + or context.generated_scope is not generated_scope + or not callable(execute) + ): + raise ValueError("prepared native request is inactive") + connection_request = cast(_GeneratedConnectionRequest, context.native_request) + return await connection_request.execute_forward_connection(prepared) + + async def authorize_connection(self, call: OperationCall) -> bool: + return await self._authority.check(call.actor, call.operation) + + @asynccontextmanager + async def open_prepared_request( + self, + scope: ExecutionScope, + identity: SessionIdentity, + generated_scope: GeneratedScope, + ) -> AsyncGenerator[None, None]: + native = self._native + if ( + native is None + or generated_scope.principal is not identity + or generated_scope.application != scope.application + or generated_scope.request_id != scope.request_id + or generated_scope.lease_id != scope.lease_id + or generated_scope.api_digest != scope.api_digest + or generated_scope.consistency != _GENERATED_CONSISTENCY + ): + raise ValueError("prepared native request scope differs") + async with self._lock: + if scope.lease_id in self._requests or scope.lease_id in self._opening: + raise ValueError("request lease is already open") + self._opening.add(scope.lease_id) + try: + async with native.open_request( + identity, generated_scope, data_session=self._data_session + ) as request: + async with self._lock: + self._opening.remove(scope.lease_id) + self._requests[scope.lease_id] = _Request( + scope, identity, generated_scope, request + ) + try: + yield + finally: + async with self._lock: + self._requests.pop(scope.lease_id, None) + finally: + async with self._lock: + self._opening.discard(scope.lease_id) + + async def invoke(self, call: OperationCall) -> OperationOutcome: + return OperationOutcome("invalid", "", {}, "unsupported") + + async def invoke_selected( + self, call: OperationCall, selection: Selection + ) -> OperationOutcome: + snapshot = call.snapshot() + scope = snapshot.scope + if self._invalid_selected(snapshot, selection) or scope is None: + return OperationOutcome("invalid", "", {}, "unsupported") + try: + generated_call, context, bound = self._bound_selected(snapshot, selection) + except (GeneratedExecutionError, KeyError, ValueError, TypeError, UnicodeError): + return OperationOutcome("invalid", "", {}, "invalid") + return await self._execute_selected(snapshot, generated_call, context, bound) + + def _invalid_selected(self, call: OperationCall, selection: Selection) -> bool: + scope = call.scope + return ( + selection.kind != "get_many" + or scope is None + or scope.principal != call.actor + or call.phase != "invoke" + or call.key is not None + or call.confirmation is not None + or call.actor.kind not in {"person", "batch"} + or call.actor.delegation is not None + or bool(call.inputs) + or scope.consistency != _CONSISTENCY + ) + + def _bound_selected( + self, call: OperationCall, selection: Selection + ) -> tuple[GeneratedGetManyCall, _Request, BoundKeyBatchProgram]: + scope = cast(ExecutionScope, call.scope) + route = self._roots.get(call.operation) + if route is None: + raise ValueError("Record operation is not exposed") + if not 1 <= len(selection.keys) <= 100 or len(selection.fields) > 8: + raise ValueError("selected batch capacity differs") + module, record = route.module, route.record + keys: list[tuple[object, ...]] = [] + for key in selection.keys: + if (key.record, key.key_id) != ((module, record), route.primary_key_id): + raise ValueError("selected Key root differs") + if len(key.components) != len(route.key_wrappers): + raise ValueError("selected Key arity differs") + for component, wrapper in zip( + key.components, route.key_wrappers, strict=True + ): + if set(component) != {wrapper}: + raise ValueError("selected Key wrapper differs") + keys.append(tuple(dict(component) for component in key.components)) + fields = self._field_ids(route, selection.fields) + generated_call = GeneratedGetManyCall( + module, record, route.primary_key_id, tuple(keys), fields + ) + context = self._requests.get(scope.lease_id) + if context is None or context.host_scope is not scope: + raise ValueError("request snapshot is inactive") + bound = self._executor.bind_get_many(generated_call, context.generated_scope) + return generated_call, context, bound + + async def _execute_selected( + self, + call: OperationCall, + generated_call: GeneratedGetManyCall, + context: _Request, + bound: BoundKeyBatchProgram, + ) -> OperationOutcome: + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + native = self._native + if native is None: + return OperationOutcome("unavailable", "", {}, "not_prepared") + try: + frame = await context.native_request.execute_get_many(generated_call) + except Exception as error: + error_type = getattr(native_runtime, "GeneratedNativeError", None) + code = getattr(error, "code", None) + if ( + not isinstance(error_type, type) + or type(error) is not error_type + or type(code) is not str + or code + not in { + "DENIED", + "LIMIT_EXCEEDED", + "SCHEMA_MISMATCH", + "INVALID", + "UNSUPPORTED", + "PRECONDITION_FAILED", + "BUSY", + } + ): + raise + if code == "UNSUPPORTED": + return OperationOutcome("invalid", "", {}, "unsupported") + return native_read_refusal( + {"schema": native.schema, "error": {"code": code}}, native.schema + ) + translated = selected_batch_result(frame, bound) + if translated is None: + return OperationOutcome("unavailable", "", {}, "native_refused") + return OperationOutcome("succeeded", "", translated) + + def _field_ids( + self, root: RecordRoute, requested: tuple[tuple[str, str], ...] + ) -> tuple[str, ...]: + if len(requested) > 8 or len(set(requested)) != len(requested): + raise ValueError("selected Field list differs") + algebra_roots = cast(Mapping[str, object], self._algebra["roots"]) + module, record = root.module, root.record + issued = next( + cast(Mapping[str, object], item) + for item in algebra_roots.values() + if isinstance(item, Mapping) + and ( + cast(Mapping[str, object], item).get("module"), + cast(Mapping[str, object], item).get("record"), + ) + == (module, record) + ) + fields = cast(Mapping[str, object], issued["fields"]) + by_ref = { + source_ref(cast(Mapping[str, object], value)["sourceField"]): field_id + for field_id, value in fields.items() + } + exposed = set(root.fields) + if not set(requested).issubset(exposed): + raise ValueError("selected Fields are outside exposed Record root") + return tuple(by_ref[field] for field in requested) + + async def aclose(self) -> None: + async with self._lock: + if self._requests: + raise RuntimeError("request snapshots must close before provider") + self._native = None + + +__all__ = [ + "GeneratedBatchBinding", + "GeneratedBatchExecution", + "GeneratedBatchRequest", +] diff --git a/packages/batten-local/src/batten/umf_postgres/generated_command.py b/packages/batten-local/src/batten/umf_postgres/generated_command.py new file mode 100644 index 0000000..b2af039 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated_command.py @@ -0,0 +1,395 @@ +"""Declared table commands bound to a generated artifact's PostgreSQL inventory.""" + +from __future__ import annotations + +import json +import re +from collections.abc import Awaitable, Callable, Mapping +from dataclasses import dataclass +from hashlib import sha256 +from types import MappingProxyType +from typing import Any, Literal, Protocol, cast + +from batten.contracts import Identity, OperationCall, OperationOutcome +from umf_access.unified import AsyncSession, SessionIdentity +from umf_access_generated_executor import GeneratedExecutor + +from ._generated_values import native_read_refusal, snapshot_inputs + +_WRITE_KINDS = frozenset({"insert", "update", "delete", "upsert"}) +_RECEIPT = re.compile(r"[0-9a-f]{64}") + + +class _NativeCommand(Protocol): + async def execute( + self, request: dict[str, object], *, identity: SessionIdentity + ) -> dict[str, object]: ... + + +@dataclass(frozen=True, slots=True) +class GeneratedCommandRoute: + """A declared table command and its single returned string Key.""" + + operation: str + record: tuple[str, str] + key_id: str + key_field: str + + +class GeneratedCommandExecution: + """Run commands using UMF's owned transaction and authenticated receipt ledger.""" + + def __init__( + self, + executor: GeneratedExecutor, + session: AsyncSession, + bundle: dict[str, object], + installation_reference: dict[str, object], + prepared_writes: bytes, + *, + prepared_sha256: str, + routes: Mapping[str, GeneratedCommandRoute], + authority: Identity, + confirm: Callable[[OperationCall], Awaitable[bool]], + outcome_secret: bytes, + ) -> None: + from umf_access.unified.prepared_writes import PreparedPostgresWrites + + table = executor.native_table + if ( + not routes + or session.transaction_owner != "adapter" + or bundle.get("sourceDigest") != table.source_digest + or bundle.get("bundleDigest") != table.bundle_digest + or bundle.get("configurationDigest") != table.configuration_digest + ): + raise ValueError("command binding differs from admitted generated table") + self._module = _text(_object(table.native_source["configuration"])["module"]) + self._schema = table.source_digest + self._bundle_digest = table.bundle_digest + self._artifact_digest = executor.trusted_artifact.artifact_digest + self._routes = MappingProxyType(dict(routes)) + _validate_routes(self._routes, self._module, bundle, dict(table.operations)) + self._authority = authority + self._confirm = confirm + native = PreparedPostgresWrites( + session, + table, + installation_reference, + prepared_writes, + expected_sha256=prepared_sha256, + outcome_secret=outcome_secret, + ) + if native.operations != frozenset(route.operation for route in routes.values()): + raise ValueError("prepared commands differ from configured routes") + self._native: _NativeCommand = native + + @property + def operations(self) -> frozenset[str]: + return frozenset(self._routes) + + @property + def artifact_digest(self) -> str: + return self._artifact_digest + + def capabilities(self) -> Mapping[str, str]: + return { + "command.outcome": "1", + "command.observe": "1", + **{ + f"command.operation/{host_id}": json.dumps( + (self._module, route.operation), + ensure_ascii=False, + separators=(",", ":"), + ) + for host_id, route in self._routes.items() + }, + } + + async def invoke(self, call: OperationCall) -> OperationOutcome: + route = self._routes.get(call.operation) + refused = _refusal(call, route) + if refused is not None: + return refused + assert route is not None + key = cast(str, call.key) + try: + inputs = snapshot_inputs(call.inputs, 1_048_576) + except ValueError: + return OperationOutcome("invalid", "", {}, "invalid") + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + if call.phase == "invoke" and not await self._confirm(call): + return _outcome(key, "rejected", code="CONFIRMATION_REQUIRED") + native_key = _native_key(call, key) + response = await self._native.execute( + _request( + self._schema, + self._module, + route.operation, + call.phase, + native_key, + inputs, + ), + identity=SessionIdentity( + cast(Literal["person", "batch"], call.actor.kind), call.actor.subject + ), + ) + return _translate( + response, self._schema, self._bundle_digest, call, route, native_key + ) + + +def _validate_routes( + routes: Mapping[str, GeneratedCommandRoute], + module: str, + bundle: Mapping[str, object], + inventory: Mapping[str, str], +) -> None: + raw = _text(_object(bundle["source"])["utf8"]) + if sha256(raw.encode("utf-8")).hexdigest() != bundle["sourceDigest"]: + raise ValueError("command source bytes differ from the admitted digest") + source = json.loads(raw) + owner = next(item for item in source["modules"] if item["id"] == module) + tables = owner["extensions"]["umf.tables"] + declarations = {item["id"]: item for item in tables["commands"]} + records = { + item["id"]: item for item in owner["elements"] if item["kind"] == "record" + } + if len({route.operation for route in routes.values()}) != len(routes): + raise ValueError("duplicate command declaration") + for host_id, route in routes.items(): + if not host_id or inventory.get(route.operation) not in _WRITE_KINDS: + raise ValueError("command is outside the admitted inventory") + _validate_declaration( + route, module, declarations[route.operation], tables, records + ) + + +def _validate_declaration( + route: GeneratedCommandRoute, module: str, declared: Any, tables: Any, records: Any +) -> None: + body = declared["body"] + target = next(row for row in tables["tables"] if row["id"] == body["table"]) + ref = {"module": module, "element": route.key_field} + key = next( + ( + item + for item in records[route.record[1]]["keys"] + if item["id"] == route.key_id + ), + None, + ) + if ( + route.record[0] != module + or target["record"] != {"module": module, "element": route.record[1]} + or key is None + or key["fields"] != [ref] + or ref not in body.get("returning", []) + or body.get("maxRows") != 1 + or declared.get("batch") is not None + or declared.get("replay") != "caller-key-required" + or declared.get("consistency") != "transaction" + ): + raise ValueError( + "command does not match its recoverable single-Key declaration" + ) + + +def _refusal( + call: OperationCall, route: GeneratedCommandRoute | None +) -> OperationOutcome | None: + if ( + call.scope is None + or not call.scope.api_digest + or call.scope.principal != call.actor + or call.actor.kind not in {"person", "batch"} + or call.actor.delegation is not None + ): + return OperationOutcome("denied", "", {}, "scope_invalid") + if ( + route is None + or call.phase not in {"invoke", "observe"} + or (call.phase == "observe" and call.confirmation is not None) + or not _valid_invocation_key(call.key) + ): + return OperationOutcome("invalid", "", {}, "invalid") + return None + + +def _valid_invocation_key(key: str | None) -> bool: + try: + return ( + key is not None + and 0 < len(key.encode("utf-8")) <= 128 + and "\x00" not in key + ) + except UnicodeError: + return False + + +def _native_key(call: OperationCall, key: str) -> str: + scope = call.scope + assert scope is not None + fields = [ + scope.application.id, + scope.application.digest, + scope.api_digest, + call.operation, + key, + ] + return sha256(json.dumps(fields, separators=(",", ":")).encode("utf-8")).hexdigest() + + +def _request( + schema: str, + module: str, + operation: str, + phase: str, + key: str, + inputs: dict[str, object], +) -> dict[str, object]: + return { + "contract": "umf.access/1", + "schema": schema, + "kind": "table", + "module": module, + "operation": operation, + "call": {"kind": "single", "inputs": inputs}, + "phase": phase, + "mutation": True, + "idempotency_key": key, + } + + +def _translate( + response: Mapping[str, object], + schema: str, + bundle_digest: str, + call: OperationCall, + route: GeneratedCommandRoute, + native_key: str, +) -> OperationOutcome: + if "error" in response: + refusal = native_read_refusal(response, schema) + if refusal.status in {"invalid", "denied", "precondition_failed"}: + return refusal + return OperationOutcome("uncertain", "", {}, "native_refused") + key = cast(str, call.key) + try: + if set(response) != {"schema", "table"} or response["schema"] != schema: + raise ValueError("native command envelope differs") + table = _object(response["table"]) + return _receipt_outcome( + table, key, native_key, schema, bundle_digest, route, call.phase + ) + except (KeyError, ValueError): + return OperationOutcome("uncertain", "", {}, "native_refused") + + +def _receipt_outcome( + table: Mapping[str, object], + key: str, + native_key: str, + schema: str, + bundle_digest: str, + route: GeneratedCommandRoute, + phase: str, +) -> OperationOutcome: + if table["version"] != "umf.table-write-result/0.1" or table["key"] != native_key: + raise ValueError("native command identity differs") + status = _text(table["status"]) + if status == "not-observed" and phase == "observe": + if ( + table["durability"] != "not-observed" + or "result" in table + or "receipt" in table + ): + raise ValueError("unexpected unobserved outcome") + return _outcome(key, status) + if status not in {"applied", "recovered"} or ( + phase == "observe" and status != "recovered" + ): + raise ValueError("unexpected command status") + if table["commitResponsibility"] != "adapter" or table["durability"] != "committed": + raise ValueError("native command was not durably committed") + receipt = _object(table["receipt"]) + if ( + receipt["version"] != "umf.table-outcome/0.1" + or receipt["sourceDigest"] != schema + or receipt["bundleDigest"] != bundle_digest + or receipt["module"] != route.record[0] + or receipt["operation"] != route.operation + ): + raise ValueError("native command receipt differs") + reference = _text(receipt["invocationDigest"]) + if _RECEIPT.fullmatch(reference) is None: + raise ValueError("invalid receipt reference") + affected = _affected(table, route) if status == "applied" else [] + return _outcome(key, status, receipt=reference, affected=affected) + + +def _affected( + table: Mapping[str, object], route: GeneratedCommandRoute +) -> list[object]: + result = _object(table["result"]) + frames = _array(result["items"]) + if len(frames) != 1: + raise ValueError("native command returned multiple items") + frame = _object(frames[0]) + rows = _array(frame["rows"]) + if len(rows) > 1 or frame["affectedCount"] != {"integerToken": str(len(rows))}: + raise ValueError("native command effect count differs from returned Keys") + return [ + { + "record": route.record, + "keyId": route.key_id, + "components": [{"string": _text(_object(row)[route.key_field])}], + } + for row in rows + ] + + +def _outcome( + key: str, + status: str, + *, + receipt: str | None = None, + affected: list[object] | None = None, + code: str | None = None, +) -> OperationOutcome: + return OperationOutcome( + "succeeded", + key, + { + "version": "batten.command-result/1", + "status": status, + "durability": "committed" if receipt is not None else "none", + "invocationKey": key, + "affected": affected or [], + "receipt": receipt, + "code": code, + "confirmation": None, + }, + ) + + +def _object(value: object) -> Mapping[str, object]: + if not isinstance(value, Mapping): + raise ValueError("expected object") + return cast(Mapping[str, object], value) + + +def _array(value: object) -> list[object]: + if type(value) is not list: + raise ValueError("expected array") + return cast(list[object], value) + + +def _text(value: object) -> str: + if type(value) is not str or not value: + raise ValueError("expected non-empty text") + return value + + +__all__ = ["GeneratedCommandExecution", "GeneratedCommandRoute"] diff --git a/packages/batten-local/src/batten/umf_postgres/generated_read.py b/packages/batten-local/src/batten/umf_postgres/generated_read.py new file mode 100644 index 0000000..1be2775 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated_read.py @@ -0,0 +1,136 @@ +"""Read-only generated algebra provider behind the universal Batten host gates.""" + +from collections.abc import Awaitable, Callable, Mapping +from types import MappingProxyType +from typing import Literal, Protocol, cast + +from batten.contracts import ExecutionScope, Identity, OperationCall, OperationOutcome +from umf_access.unified import SessionIdentity +from umf_access_generated_executor import ( + AdmittedNativeTable, + GeneratedExecutionError, + GeneratedExecutor, + GeneratedReadCall, +) +from umf_access_generated_executor import ExecutionScope as GeneratedScope + +from ._generated_values import native_read_refusal, read_refusal +from ._read_binding import ReadBindingMetadata +from ._read_result import valid_read_result +from ._read_wire import read_call + + +class GeneratedReadBinding(ReadBindingMetadata, Protocol): + async def execute_read( + self, + call: GeneratedReadCall, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: ... + + +def _records( + native: AdmittedNativeTable, read_profile: str | None +) -> frozenset[tuple[str, str]]: + if type(native) is not AdmittedNativeTable: + raise ValueError("verified native artifact required") + version = "3" if read_profile == "weft.generated-read-algebra/8" else "2" + if native.native_source["version"] != f"umf.native-table-source/{version}": + raise ValueError(f"generated read requires native source version {version}") + catalog = cast(Mapping[str, object], native.native_source["expectedCatalog"]) + records: set[tuple[str, str]] = set() + for table in cast(tuple[Mapping[str, object], ...], catalog["tables"]): + record = cast(Mapping[str, str], table["record"]) + records.add((record["module"], record["element"])) + return frozenset(records) + + +class GeneratedReadExecution: + _read_profile = "weft.generated-read-algebra/1" + _accepted_read_profiles: frozenset[str] = frozenset() + + def __init__( + self, + factory: Callable[[], Awaitable[ReadBindingMetadata]], + authority: Identity, + executor: GeneratedExecutor, + routes: Mapping[str, tuple[str, str]], + *, + max_input_bytes: int = 8_388_608, + ): + if executor.read_profile not in self._accepted_read_profiles: + raise ValueError("server-guarded generated read profile required") + admitted = executor.native_table + records = _records(admitted, executor.read_profile) + if not routes or any( + type(name) is not str + or not name + or type(record) is not tuple + or len(record) != 2 + or any(type(part) is not str for part in record) + or record not in records + for name, record in routes.items() + ): + raise ValueError("read routes differ from admitted Records") + if type(max_input_bytes) is not int or max_input_bytes < 1: + raise ValueError("positive input capacity required") + self._factory, self._authority = factory, authority + self._executor = executor + self._routes = MappingProxyType(dict(routes)) + self._source, self._maximum = admitted.source_digest, max_input_bytes + self._native: ReadBindingMetadata | None = None + + async def prepare(self) -> None: + if self._native is None: + native = await self._factory() + if ( + native.schema != self._source + or native.read_profile not in self._accepted_read_profiles + or native.target_binding_digest != self._executor.target.binding_digest + or any(record[0] != native.module for record in self._routes.values()) + ): + raise ValueError("read binding differs from admitted artifact") + self._native = native + + async def invoke(self, call: OperationCall) -> OperationOutcome: + refused = read_refusal(call) + if refused is not None: + return refused + scope = cast(ExecutionScope, call.scope) + identity = SessionIdentity( + cast(Literal["person", "batch"], call.actor.kind), call.actor.subject + ) + context = GeneratedScope( + scope.application, + identity, + scope.request_id, + scope.deadline_monotonic, + scope.lease_id, + scope.api_digest, + scope.consistency, + ) + try: + read = read_call(call.inputs, self._maximum) + if self._routes.get(call.operation) != (read.module, read.record): + raise ValueError("read operation differs from configured root") + bound = self._executor.bind_read(read, context) + except (GeneratedExecutionError, ValueError, TypeError, UnicodeError): + return OperationOutcome("invalid", "", {}, "invalid") + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + native = self._native + if native is None: + return OperationOutcome("unavailable", "", {}, "not_prepared") + result = await cast(GeneratedReadBinding, native).execute_read( + read, identity=identity, scope=context + ) + if not valid_read_result(result, native.schema, read, bound): + return native_read_refusal(result, native.schema) + return OperationOutcome("succeeded", "", result) + + async def aclose(self) -> None: + self._native = None + + +__all__ = ["GeneratedReadBinding", "GeneratedReadExecution"] diff --git a/packages/batten-local/src/batten/umf_postgres/generated_read_v2.py b/packages/batten-local/src/batten/umf_postgres/generated_read_v2.py new file mode 100644 index 0000000..eb28c6b --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated_read_v2.py @@ -0,0 +1,89 @@ +"""Versioned Boolean/read-terminal adapter; all native meaning remains upstream.""" + +import json +from typing import Literal, Protocol, cast, runtime_checkable + +from batten.contracts import ExecutionScope, OperationCall, OperationOutcome +from umf_access.unified import SessionIdentity +from umf_access_generated_executor import ExecutionScope as GeneratedScope +from umf_access_generated_executor import GeneratedExecutionError, GeneratedReadCallV2 + +from ._generated_values import native_read_refusal, read_refusal +from ._read_result_v2 import valid_read_result_v2 +from .generated_read import GeneratedReadBinding, GeneratedReadExecution + + +@runtime_checkable +class GeneratedReadBindingV2(GeneratedReadBinding, Protocol): + async def execute_read_v2( + self, + call: GeneratedReadCallV2, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: ... + + +class GeneratedReadExecutionV2(GeneratedReadExecution): + _read_profile = "weft.generated-read-algebra/2" + + async def prepare(self) -> None: + await super().prepare() + if not isinstance(self._native, GeneratedReadBindingV2): + self._native = None + raise ValueError("generated v2 native execution is unavailable") + + async def invoke(self, call: OperationCall) -> OperationOutcome: + refused = read_refusal(call) + if refused is not None: + return refused + scope = cast(ExecutionScope, call.scope) + identity = SessionIdentity( + cast(Literal["person", "batch"], call.actor.kind), call.actor.subject + ) + context = GeneratedScope( + scope.application, + identity, + scope.request_id, + scope.deadline_monotonic, + scope.lease_id, + scope.api_digest, + scope.consistency, + ) + try: + inputs = call.snapshot().inputs + if ( + set(inputs) != {"read"} + or len( + json.dumps( + dict(inputs), + ensure_ascii=False, + allow_nan=False, + separators=(",", ":"), + ).encode("utf-8") + ) + > self._maximum + ): + raise ValueError("generated v2 input envelope differs") + read = GeneratedReadCallV2.from_mapping(inputs["read"]) + if self._routes.get(call.operation) != (read.module, read.record): + raise ValueError("read operation differs from configured root") + bound = self._executor.bind_read_v2(read, context) + except (GeneratedExecutionError, ValueError, TypeError, UnicodeError): + return OperationOutcome("invalid", "", {}, "invalid") + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + native = self._native + if native is None: + return OperationOutcome("unavailable", "", {}, "not_prepared") + result = await cast(GeneratedReadBindingV2, native).execute_read_v2( + read, + identity=identity, + scope=context, + ) + if not valid_read_result_v2(result, native.schema, read, bound): + return native_read_refusal(result, native.schema) + return OperationOutcome("succeeded", "", result) + + +__all__ = ["GeneratedReadBindingV2", "GeneratedReadExecutionV2"] diff --git a/packages/batten-local/src/batten/umf_postgres/generated_read_v3.py b/packages/batten-local/src/batten/umf_postgres/generated_read_v3.py new file mode 100644 index 0000000..a2f0d8c --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated_read_v3.py @@ -0,0 +1,97 @@ +"""Server-guarded Boolean/read-terminal adapter; all native meaning remains upstream.""" + +import json +from typing import Literal, Protocol, cast, runtime_checkable + +from batten.contracts import ExecutionScope, OperationCall, OperationOutcome +from umf_access.unified import SessionIdentity +from umf_access_generated_executor import ExecutionScope as GeneratedScope +from umf_access_generated_executor import GeneratedExecutionError, GeneratedReadCallV2 + +from ._generated_values import native_read_refusal, read_refusal +from ._read_binding import ReadBindingMetadata +from ._read_result_v2 import valid_read_result_v2 +from .generated_read import GeneratedReadExecution + + +@runtime_checkable +class GeneratedReadBindingV3(ReadBindingMetadata, Protocol): + async def execute_read_v3( + self, + call: GeneratedReadCallV2, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: ... + + +class GeneratedReadExecutionV3(GeneratedReadExecution): + _read_profile = "weft.generated-read-algebra/3" + _accepted_read_profiles = frozenset({ + "weft.generated-read-algebra/3", + "weft.generated-read-algebra/4", + "weft.generated-read-algebra/5", + "weft.generated-read-algebra/7", + "weft.generated-read-algebra/8", + }) + + async def prepare(self) -> None: + await super().prepare() + if not isinstance(self._native, GeneratedReadBindingV3): + self._native = None + raise ValueError("generated v3 native execution is unavailable") + + async def invoke(self, call: OperationCall) -> OperationOutcome: + refused = read_refusal(call) + if refused is not None: + return refused + scope = cast(ExecutionScope, call.scope) + identity = SessionIdentity( + cast(Literal["person", "batch"], call.actor.kind), call.actor.subject + ) + context = GeneratedScope( + scope.application, + identity, + scope.request_id, + scope.deadline_monotonic, + scope.lease_id, + scope.api_digest, + scope.consistency, + ) + try: + inputs = call.snapshot().inputs + if ( + set(inputs) != {"read"} + or len( + json.dumps( + dict(inputs), + ensure_ascii=False, + allow_nan=False, + separators=(",", ":"), + ).encode("utf-8") + ) + > self._maximum + ): + raise ValueError("generated v3 input envelope differs") + read = GeneratedReadCallV2.from_mapping(inputs["read"]) + if self._routes.get(call.operation) != (read.module, read.record): + raise ValueError("read operation differs from configured root") + bound = self._executor.bind_read_v3(read, context) + except (GeneratedExecutionError, ValueError, TypeError, UnicodeError): + return OperationOutcome("invalid", "", {}, "invalid") + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + native = self._native + if native is None: + return OperationOutcome("unavailable", "", {}, "not_prepared") + result = await cast(GeneratedReadBindingV3, native).execute_read_v3( + read, + identity=identity, + scope=context, + ) + if not valid_read_result_v2(result, native.schema, read, bound): + return native_read_refusal(result, native.schema) + return OperationOutcome("succeeded", "", result) + + +__all__ = ["GeneratedReadBindingV3", "GeneratedReadExecutionV3"] diff --git a/packages/batten-local/src/batten/umf_postgres/generated_relationship.py b/packages/batten-local/src/batten/umf_postgres/generated_relationship.py new file mode 100644 index 0000000..6e772b5 --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated_relationship.py @@ -0,0 +1,182 @@ +"""Bound one-hop lookups through two authorized batches in the same snapshot.""" + +from __future__ import annotations + +import json +from collections.abc import Mapping +from dataclasses import dataclass, replace +from types import MappingProxyType +from typing import Any, cast + +from batten.contracts import ( + Identity, + OperationCall, + OperationOutcome, + SelectedKey, + Selection, +) +from umf_access_generated_executor import GeneratedExecutor + +from ._generated_batch_routes import RecordRoot +from .generated_batch import GeneratedBatchExecution + + +@dataclass(frozen=True, slots=True) +class GeneratedRelationshipRoute: + relationship: tuple[str, str] + parent_operation: str + target_operation: str + + +@dataclass(frozen=True, slots=True) +class _Route: + declaration: GeneratedRelationshipRoute + source_field: tuple[str, str] + target: tuple[str, str] + target_key: str + + +class GeneratedRelationships: + def __init__( + self, + executor: GeneratedExecutor, + roots: Mapping[str, RecordRoot], + routes: Mapping[str, GeneratedRelationshipRoute], + authority: Identity, + ) -> None: + if not routes or executor.read_profile != "weft.generated-read-algebra/8": + raise ValueError("admitted /8 relationship inventory required") + rows = cast( + tuple[Mapping[str, Any], ...], + executor.native_table.native_source["relationships"], + ) + inventory = { + (row["logicalIdentity"]["module"], row["logicalIdentity"]["id"]): row + for row in rows + if row["status"] == "admitted" + } + self._routes = MappingProxyType({ + name: _admit(route, roots, inventory[route.relationship]) + for name, route in routes.items() + }) + self._authority = authority + self.artifact_digest = executor.trusted_artifact.artifact_digest + + @property + def operations(self) -> frozenset[str]: + return frozenset(self._routes) + + def capabilities(self) -> Mapping[str, str]: + return { + "relationship.batch": "to-one-1", + **{ + f"relationship.operation/{name}": json.dumps( + (*route.declaration.relationship, *route.target), + ensure_ascii=False, + separators=(",", ":"), + ) + for name, route in self._routes.items() + }, + } + + async def invoke( + self, + records: GeneratedBatchExecution, + call: OperationCall, + selection: Selection, + ) -> OperationOutcome: + route = self._routes.get(call.operation) + if ( + route is None + or selection.kind != "related_many" + or selection.target != route.target + or not 1 <= len(selection.parents) <= 100 + ): + return OperationOutcome("invalid", "", {}, "unsupported") + if not await self._authority.check(call.actor, call.operation): + return OperationOutcome("denied", "", {}, "denied") + parents = await records.invoke_selected( + replace(call, operation=route.declaration.parent_operation), + Selection("get_many", (route.source_field,), keys=selection.parents), + ) + if parents.status == "denied": + return _result([None] * len(selection.parents)) + if parents.status != "succeeded": + return parents + keys = _target_keys(parents.result, route) + return await _targets(records, call, selection, route, keys) + + +def _admit( + route: GeneratedRelationshipRoute, + roots: Mapping[str, RecordRoot], + row: Mapping[str, Any], +) -> _Route: + parent, target = roots[route.parent_operation], roots[route.target_operation] + binding = row["binding"] + declaration = row["declaration"] + target_record = (target.ref.module, target.ref.id) + if ( + tuple(binding["sourceRecord"]) != (parent.ref.module, parent.ref.id) + or tuple(binding["targetRecord"]) != target_record + or declaration["target"][0]["key"] != target.primary_key_id + or target.key_wrappers != ("string",) + or len(binding["pairs"]) != 1 + ): + raise ValueError("relationship differs from admitted Record roots") + field = binding["pairs"][0]["sourceField"] + source_field = (cast(str, field["module"]), cast(str, field["element"])) + if not any( + (ref.module, ref.element) == source_field and wrapper == "string" + for ref, wrapper in parent.field_wrappers + ): + raise ValueError("relationship source Key field is outside the Record route") + return _Route(route, source_field, target_record, target.primary_key_id) + + +def _target_keys( + result: Mapping[str, object], route: _Route +) -> list[SelectedKey | None]: + keys: list[SelectedKey | None] = [] + for row in cast(list[Any], result["items"]): + value = row["fields"][0]["value"] if row is not None else None + keys.append( + None + if value is None + else SelectedKey(route.target, route.target_key, (value,)) + ) + return keys + + +async def _targets( + records: GeneratedBatchExecution, + call: OperationCall, + selection: Selection, + route: _Route, + keys: list[SelectedKey | None], +) -> OperationOutcome: + present = tuple(key for key in keys if key is not None) + items: list[object] = [None] * len(keys) + if present: + targets = await records.invoke_selected( + replace(call, operation=route.declaration.target_operation), + Selection("get_many", selection.fields, keys=present), + ) + if targets.status == "denied": + return _result(items) + if targets.status != "succeeded": + return targets + rows = iter(cast(list[object], targets.result["items"])) + items = [next(rows) if key is not None else None for key in keys] + return _result(items) + + +def _result(items: list[object]) -> OperationOutcome: + return OperationOutcome( + "succeeded", + "", + {"version": "batten.selected-result/1", "kind": "related_many", "items": items}, + ) + + +__all__ = ["GeneratedRelationshipRoute", "GeneratedRelationships"] diff --git a/packages/batten-local/src/batten/umf_postgres/generated_table.py b/packages/batten-local/src/batten/umf_postgres/generated_table.py new file mode 100644 index 0000000..364a32c --- /dev/null +++ b/packages/batten-local/src/batten/umf_postgres/generated_table.py @@ -0,0 +1,466 @@ +"""Disjoint ordinary, Key-batch and planned connection routes on one binding.""" + +from __future__ import annotations + +import asyncio +from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping +from contextlib import AbstractAsyncContextManager, asynccontextmanager +from itertools import combinations +from types import MappingProxyType +from typing import cast + +import umf_access.generated as generated_api +from batten.contracts import ( + ExecutionScope, + Identity, + OperationCall, + OperationOutcome, + SelectedCallSpec, + SelectedRequestError, + Selection, + connection_routes_digest, +) +from umf_access.unified import AsyncSession, SessionIdentity +from umf_access_generated_executor import ExecutionScope as GeneratedScope +from umf_access_generated_executor import ( + GeneratedExecutor, +) + +from ._generated_batch_routes import RecordRoot +from ._generated_connection import ( + GeneratedTablePlan, + PlannedConnection, + connection_fields, + connection_preflight_error, + connection_result, + consume_connection, + field_reference, + issue_table_plan, + native_connection_error, + table_plan_from, +) +from ._generated_join import GeneratedJoinBinding, GeneratedJoinExecution +from ._generated_page import GeneratedPageBinding, GeneratedPageExecution +from ._generated_table_binding import GeneratedTableBinding +from ._generated_table_routes import ConnectionRoute as _ConnectionRoute +from ._read_binding import ReadBindingMetadata +from .generated_batch import GeneratedBatchBinding, GeneratedBatchExecution +from .generated_command import GeneratedCommandExecution +from .generated_read_v3 import GeneratedReadExecutionV3 +from .generated_relationship import GeneratedRelationships + +_PROFILE4 = "weft.generated-read-algebra/4" +_PROFILE5 = "weft.generated-read-algebra/5" +_PROFILE7 = "weft.generated-read-algebra/7" +_PROFILE8 = "weft.generated-read-algebra/8" +_MAX_PLANNED_CALLS = 256 + + +class GeneratedTableExecution: + """Route reads and both selected families through one held native request.""" + + def __init__( + self, + executor: GeneratedExecutor, + factory: Callable[[], Awaitable[GeneratedTableBinding]], + *, + data_session: AsyncSession, + authority: Identity, + read_routes: Mapping[str, tuple[str, str]], + record_routes: Mapping[str, RecordRoot], + connection_routes: Mapping[str, _ConnectionRoute] | None = None, + page_routes: Mapping[str, tuple[str, str]] | None = None, + joined_read_routes: Mapping[str, tuple[str, str, str, str]] | None = None, + commands: GeneratedCommandExecution | None = None, + relationships: GeneratedRelationships | None = None, + ) -> None: + profile = executor.read_profile + routes = dict(connection_routes or {}) + pages = dict(page_routes or {}) + joined = dict(joined_read_routes or {}) + route_groups = ( + set(read_routes), + set(record_routes) | routes.keys(), + set(pages), + set(joined), + commands.operations if commands is not None else frozenset[str](), + relationships.operations if relationships is not None else frozenset[str](), + ) + if ( + profile not in {_PROFILE4, _PROFILE5, _PROFILE7, _PROFILE8} + or not read_routes + or not record_routes + or any(left & right for left, right in combinations(route_groups, 2)) + or (profile == _PROFILE4 and (routes or pages)) + or (profile == _PROFILE5 and (not routes or pages)) + or (joined and profile != _PROFILE8) + ): + raise ValueError("disjoint generated routes and profile required") + if any( + type(operation) is not str + or not operation + or route.cursor_scope.host_operation_id != operation + for operation, route in routes.items() + ): + raise ValueError("connection operation route differs") + if any( + (record_routes[operation].ref.module, record_routes[operation].ref.id) + != (route.module, route.record) + for operation, route in routes.items() + if operation in record_routes + ): + raise ValueError("connection route differs from its Record route") + if commands is not None and ( + type(commands) is not GeneratedCommandExecution + or commands.artifact_digest != executor.trusted_artifact.artifact_digest + ): + raise ValueError("command routes differ from the admitted artifact") + if relationships is not None and ( + type(relationships) is not GeneratedRelationships + or relationships.artifact_digest + != executor.trusted_artifact.artifact_digest + ): + raise ValueError("relationship routes differ from the admitted artifact") + self._relationships = relationships + self._commands = commands + self._factory = factory + self._native: GeneratedTableBinding | None = None + self._factory_lock = asyncio.Lock() + self._read_routes = MappingProxyType(dict(read_routes)) + self._record_routes = MappingProxyType(dict(record_routes)) + self._connection_routes = MappingProxyType(routes) + self._page_routes = MappingProxyType(pages) + self._joined_read_routes = MappingProxyType(joined) + self._profile = profile + self._connections_admitted = False + self._connection_routes_digest: str | None = None + self._plans: dict[str, GeneratedTablePlan] = {} + self._read = GeneratedReadExecutionV3( + cast(Callable[[], Awaitable[ReadBindingMetadata]], self._shared_factory), + authority, + executor, + read_routes, + ) + self._records = GeneratedBatchExecution( + executor, + cast(Callable[[], Awaitable[GeneratedBatchBinding]], self._shared_factory), + data_session=data_session, + authority=authority, + roots=record_routes, + ) + self._pages = ( + GeneratedPageExecution( + executor, + cast( + Callable[[], Awaitable[GeneratedPageBinding]], self._shared_factory + ), + authority, + pages, + ) + if pages + else None + ) + self._joined_reads: GeneratedJoinExecution | None = None + if joined: + self._joined_reads = GeneratedJoinExecution( + executor, + cast( + Callable[[], Awaitable[GeneratedJoinBinding]], self._shared_factory + ), + authority, + joined, + ) + + async def _shared_factory(self) -> GeneratedTableBinding: + async with self._factory_lock: + if self._native is None: + self._native = await self._factory() + return self._native + + async def prepare(self) -> None: + await self._read.prepare() + await self._records.prepare() + if self._connection_routes: + native = await self._shared_factory() + if native.read_profile not in {_PROFILE5, _PROFILE7, _PROFILE8} or dict( + native.connection_routes + ) != dict(self._connection_routes): + raise ValueError("native connection routes differ from host pins") + for route in self._connection_routes.values(): + key_id, wrappers, key_fields = self._records.connection_key_profile( + route.module, route.record + ) + allowed = { + cast(str, item["fieldId"]) + for item in cast( + tuple[Mapping[str, object], ...], + route.allowed_field_profile.body["fields"], + ) + } + if ( + not key_id + or wrappers != ("string",) + or not set(key_fields).issubset(allowed) + ): + raise ValueError( + "connection Key is outside the admitted Field profile" + ) + first_route = next(iter(self._connection_routes.values())) + scope_pins = first_route.cursor_scope + route_rows = tuple( + ( + operation, + route.module, + route.record, + route.allowed_field_profile.digest, + ) + for operation, route in self._connection_routes.items() + ) + if any( + ( + route.cursor_scope.application_id, + route.cursor_scope.application_digest, + route.cursor_scope.api_digest, + ) + != ( + scope_pins.application_id, + scope_pins.application_digest, + scope_pins.api_digest, + ) + for route in self._connection_routes.values() + ): + raise ValueError("connection route scopes differ") + self._connection_routes_digest = connection_routes_digest( + scope_pins.application_id, + scope_pins.application_digest, + scope_pins.api_digest, + self._records.capabilities()["artifact.digest"], + route_rows, + ) + self._connections_admitted = True + if self._pages is not None: + await self._pages.prepare() + if self._joined_reads is not None: + await self._joined_reads.prepare() + + def capabilities(self) -> Mapping[str, str]: + capabilities = dict(self._records.capabilities()) + if self._connections_admitted: + capabilities["connection.forward"] = "edge-cursor-1" + if self._connection_routes_digest is None: + raise RuntimeError("connection route pin is unavailable") + capabilities["connection.routes.digest"] = self._connection_routes_digest + if self._pages is not None: + capabilities.update(self._pages.capabilities()) + if self._joined_reads is not None: + capabilities.update(self._joined_reads.capabilities()) + if self._commands is not None: + capabilities.update(self._commands.capabilities()) + if self._relationships is not None: + capabilities.update(self._relationships.capabilities()) + return MappingProxyType(capabilities) + + async def invoke(self, call: OperationCall) -> OperationOutcome: + if call.operation in self._read_routes: + return await self._read.invoke(call) + if self._pages is not None and call.operation in self._page_routes: + return await self._pages.invoke(call) + if ( + self._joined_reads is not None + and call.operation in self._joined_read_routes + ): + return await self._joined_reads.invoke(call) + if self._commands is not None and call.operation in self._commands.operations: + return await self._commands.invoke(call) + return OperationOutcome("invalid", "", {}, "unsupported") + + async def invoke_selected( + self, call: OperationCall, selection: Selection + ) -> OperationOutcome: + if selection.kind == "related_many" and self._relationships is not None: + return await self._relationships.invoke(self._records, call, selection) + if selection.kind != "connection": + if call.operation not in self._record_routes: + return OperationOutcome("invalid", "", {}, "unsupported") + return await self._records.invoke_selected(call, selection) + return await self._invoke_connection(call, selection) + + def prepare_selected( + self, scope: ExecutionScope, calls: tuple[SelectedCallSpec, ...] + ) -> object: + if ( + not self._connections_admitted + or type(scope) is not ExecutionScope + or type(calls) is not tuple + or not calls + or len(calls) > _MAX_PLANNED_CALLS + ): + raise SelectedRequestError("invalid", "unsupported") + identity, generated_scope = self._records.prepared_scope(scope) + planned = tuple( + self._prepare_connection(item, scope, identity, generated_scope) + for item in calls + ) + return issue_table_plan(self, scope, calls, identity, generated_scope, planned) + + def _prepare_connection( + self, + spec: SelectedCallSpec, + scope: ExecutionScope, + identity: SessionIdentity, + generated_scope: GeneratedScope, + ) -> PlannedConnection: + call, selection = spec.call, spec.selection + route = self._connection_routes.get(call.operation) + cursor_scope = route.cursor_scope if route is not None else None + if ( + route is None + or call.scope is not scope + or call.actor != scope.principal + or call.phase != "invoke" + or call.key is not None + or call.confirmation is not None + or bool(call.inputs) + or call.actor.kind not in {"person", "batch"} + or call.actor.delegation is not None + or cursor_scope is None + or cursor_scope.application_id != scope.application.id + or cursor_scope.application_digest != scope.application.digest + or cursor_scope.api_digest != scope.api_digest + or selection.kind != "connection" + or selection.keys + or selection.parents + or selection.target is not None + or not 0 <= len(selection.fields) <= 8 + or type(selection.first) is not int + or not 0 <= selection.first <= 100 + ): + raise SelectedRequestError("invalid", "unsupported") + key_id, key_wrappers, key_field_ids = self._records.connection_key_profile( + route.module, route.record + ) + if key_wrappers != ("string",): + raise ValueError("connection Key profile is unsupported") + native_fields = selection.fields + if not native_fields: + key_descriptor = next( + ( + field_reference(value) + for value in cast( + tuple[Mapping[str, object], ...], + route.allowed_field_profile.body["fields"], + ) + if value["fieldId"] == key_field_ids[0] + ), + None, + ) + if key_descriptor is None: + raise SelectedRequestError("invalid", "unsupported") + native_fields = (key_descriptor,) + try: + field_descriptors, field_ids = connection_fields(route, native_fields) + except ValueError: + raise SelectedRequestError("invalid", "unsupported") from None + request_type = getattr(generated_api, "GeneratedForwardConnectionRequest", None) + if not callable(request_type): + raise ValueError("native generated connection API is unavailable") + request = request_type( + call.operation, + route.module, + route.record, + field_ids, + None, + selection.first, + selection.after, + ) + native = self._native + if native is None: + raise ValueError("native connection binding is unavailable") + try: + native_plan = self._records.prepare_connection( + request, identity, generated_scope + ) + except Exception as error: + raise connection_preflight_error(error, native.schema) from None + return PlannedConnection( + spec, + native_plan, + route.module, + route.record, + native.schema, + native.target_binding_digest, + key_id, + key_wrappers, + field_descriptors, + field_ids, + ) + + @asynccontextmanager + async def open_prepared_request( + self, scope: ExecutionScope, prepared: object + ) -> AsyncGenerator[None, None]: + plan = table_plan_from(prepared, self, scope) + if scope.lease_id in self._plans: + raise ValueError("generated table plan is already active") + completed = False + async with self._records.open_prepared_request( + scope, + cast(SessionIdentity, plan.identity), + cast(GeneratedScope, plan.generated_scope), + ): + self._plans[scope.lease_id] = plan + try: + yield + completed = True + finally: + self._plans.pop(scope.lease_id, None) + if completed and len(plan.used) != len(plan.items): + raise RuntimeError("planned connection calls were not consumed") + + def open_request(self, scope: ExecutionScope) -> AbstractAsyncContextManager[None]: + return self._records.open_request(scope) + + async def _invoke_connection( + self, call: OperationCall, selection: Selection + ) -> OperationOutcome: + scope = call.scope + plan = self._plans.get(scope.lease_id) if scope is not None else None + if plan is None or scope is None or plan.scope is not scope: + return OperationOutcome("invalid", "", {}, "unplanned_connection") + match = consume_connection(plan, call, selection) + if match is None: + return OperationOutcome("invalid", "", {}, "unplanned_connection") + _index, item = match + if not await self._records.authorize_connection(call): + return OperationOutcome("denied", "", {}, "denied") + try: + frame = await self._records.execute_connection( + scope, + cast(SessionIdentity, plan.identity), + cast(GeneratedScope, plan.generated_scope), + item.native, + ) + except Exception as error: + outcome = native_connection_error(error, item.source_digest) + if outcome is None: + raise + return outcome + translated = connection_result(frame, item) + if translated is None: + return OperationOutcome("unavailable", "", {}, "native_refused") + return OperationOutcome("succeeded", "", translated) + + async def aclose(self) -> None: + if self._plans: + raise RuntimeError("prepared requests must close before provider") + await self._records.aclose() + await self._read.aclose() + if self._pages is not None: + await self._pages.aclose() + if self._joined_reads is not None: + await self._joined_reads.aclose() + self._native = None + self._connections_admitted = False + + +__all__ = ["GeneratedTableBinding", "GeneratedTableExecution"] diff --git a/packages/batten/src/batten/asgi/__init__.py b/packages/batten/src/batten/asgi/__init__.py index b76f9fe..c850730 100644 --- a/packages/batten/src/batten/asgi/__init__.py +++ b/packages/batten/src/batten/asgi/__init__.py @@ -10,9 +10,10 @@ from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint from starlette.requests import Request from starlette.responses import JSONResponse, Response -from starlette.routing import Mount, Route +from starlette.routing import BaseRoute, Mount, Route from starlette.staticfiles import StaticFiles +from ._identities import LocalIdentities from ._ports import LocalSessions from ._registry import AppListing, registry_app from ._routes import Routes @@ -25,6 +26,7 @@ def create_app( *, origin: str, max_body_bytes: int, + additional_routes: tuple[BaseRoute, ...] = (), ) -> Starlette: if not origin.startswith("http://127.0.0.1:") or max_body_bytes < 1: raise ValueError("explicit loopback origin and request bound required") @@ -37,6 +39,7 @@ def create_app( Route("/api/local-session", routes.login, methods=["POST"]), Route("/api/logout", routes.logout, methods=["POST"]), Route("/api/operations/{operation}", routes.invoke, methods=["POST"]), + *additional_routes, Mount("/assets", StaticFiles(directory=assets, check_dir=False)), ], ) @@ -76,4 +79,10 @@ async def guard(request: Request, call_next: RequestResponseEndpoint) -> Respons return app -__all__ = ["AppListing", "LocalSessions", "create_app", "create_registry"] +__all__ = [ + "AppListing", + "LocalIdentities", + "LocalSessions", + "create_app", + "create_registry", +] diff --git a/packages/batten/src/batten/asgi/_identities.py b/packages/batten/src/batten/asgi/_identities.py new file mode 100644 index 0000000..0dceab1 --- /dev/null +++ b/packages/batten/src/batten/asgi/_identities.py @@ -0,0 +1,72 @@ +"""Explicit local-only stub identities; session references never come from app input.""" + +from __future__ import annotations + +import copy +import math +import secrets +import time +from collections.abc import Mapping +from typing import cast + +from batten.contracts import Actor + + +class LocalIdentities: + def __init__( + self, + people: Mapping[str, Mapping[str, object]], + *, + max_sessions: int, + ttl_seconds: float, + ): + if ( + type(max_sessions) is not int + or max_sessions < 1 + or type(ttl_seconds) not in {int, float} + or not math.isfinite(ttl_seconds) + or ttl_seconds <= 0 + ): + raise ValueError("finite positive local session limits required") + self._people = copy.deepcopy(dict(people)) + self.max_sessions, self.ttl = max_sessions, ttl_seconds + self.sessions: dict[str, tuple[str, float]] = {} + self.revoked: set[str] = set() + + def login(self, subject: str) -> str | None: + self.sessions = { + key: value + for key, value in self.sessions.items() + if value[1] > time.monotonic() + } + if ( + subject not in self._people + or subject in self.revoked + or len(self.sessions) >= self.max_sessions + ): + return None + cookie = secrets.token_urlsafe(32) + self.sessions[cookie] = (subject, time.monotonic() + self.ttl) + return cookie + + def resolve(self, cookie: str | None) -> Actor | None: + value = self.sessions.get(cookie or "") + if value is None or value[1] <= time.monotonic() or value[0] in self.revoked: + return None + return Actor(value[0], cookie) + + def logout(self, cookie: str | None) -> None: + self.sessions.pop(cookie or "", None) + + def revoke(self, subject: str) -> None: + self.revoked.add(subject) + + def profile(self, actor: Actor) -> Mapping[str, object]: + profile = cast(Mapping[str, object], self._people[actor.subject]["profile"]) + return {**profile, "id": actor.subject} + + async def check(self, actor: Actor, operation: str) -> bool: + resolved = self.resolve(actor.session) + if resolved is None or resolved != actor: + return False + return operation in cast(list[str], self._people[actor.subject]["operations"]) diff --git a/packages/batten/src/batten/contracts/__init__.py b/packages/batten/src/batten/contracts/__init__.py index bacd98b..0e97beb 100644 --- a/packages/batten/src/batten/contracts/__init__.py +++ b/packages/batten/src/batten/contracts/__init__.py @@ -2,16 +2,23 @@ from __future__ import annotations -from collections.abc import Mapping +import time +from collections.abc import Callable, Mapping from contextlib import AbstractAsyncContextManager -from dataclasses import dataclass, field -from typing import Protocol +from dataclasses import dataclass, field, replace +from types import MappingProxyType +from typing import Literal, Protocol, cast, runtime_checkable + +from batten.contracts._connection_routes import connection_routes_digest +from batten.contracts._values import freeze_value, snapshot_transport @dataclass(frozen=True) class Actor: subject: str session: str | None = field(default=None, repr=False) + kind: Literal["person", "service", "batch"] = "person" + delegation: str | None = field(default=None, repr=False) @dataclass(frozen=True) @@ -24,6 +31,128 @@ class ArtifactRef: class Operation: id: str mutation: bool + selection_kinds: tuple[str, ...] = () + + +@dataclass(frozen=True) +class SelectedKey: + record: tuple[str, str] + key_id: str + components: tuple[Mapping[str, object], ...] + + def __post_init__(self) -> None: + if ( + type(self.record) is not tuple + or len(self.record) != 2 + or any(type(part) is not str or not part for part in self.record) + or type(self.key_id) is not str + or not self.key_id + ): + raise ValueError("selected key requires exact Record and Key identity") + budget = [4096] + components = tuple(freeze_value(item, budget) for item in self.components) + if not all(isinstance(item, Mapping) for item in components): + raise ValueError("selected key components require tagged mappings") + object.__setattr__(self, "components", components) + + +@dataclass(frozen=True) +class Selection: + kind: Literal["get_many", "connection", "related_many"] + fields: tuple[tuple[str, str], ...] = () + keys: tuple[SelectedKey, ...] = () + parents: tuple[SelectedKey, ...] = () + target: tuple[str, str] | None = None + first: int | None = None + after: str | None = None + + +@dataclass(frozen=True) +class SelectedCallSpec: + """Owned immutable call and selection for one prepared selected request.""" + + call: OperationCall + selection: Selection + + def __post_init__(self) -> None: + if ( + type(self.call) is not OperationCall + or type(self.selection) is not Selection + ): + raise ValueError("selected call spec requires contract values") + call = self.call.snapshot() + selection = self.selection + if type(selection.fields) is not tuple or any( + type(field) is not tuple + or len(field) != 2 + or any(type(part) is not str or not part for part in field) + for field in selection.fields + ): + raise ValueError("selected fields require immutable references") + if len(selection.fields) > 1024: + raise ValueError("selected fields exceed limits") + if ( + type(selection.kind) is not str + or (selection.first is not None and type(selection.first) is not int) + or (selection.after is not None and type(selection.after) is not str) + ): + raise ValueError("selected call requires immutable selection values") + if type(selection.keys) is not tuple or type(selection.parents) is not tuple: + raise ValueError("selected keys require immutable tuples") + if len(selection.keys) + len(selection.parents) > 4096: + raise ValueError("selected keys exceed limits") + keys = tuple( + SelectedKey(key.record, key.key_id, key.components) + for key in selection.keys + if type(key) is SelectedKey + ) + parents = tuple( + SelectedKey(key.record, key.key_id, key.components) + for key in selection.parents + if type(key) is SelectedKey + ) + if len(keys) != len(selection.keys) or len(parents) != len(selection.parents): + raise ValueError("selected keys require contract values") + target = ( + None + if selection.target is None + else tuple(selection.target) + if type(selection.target) is tuple + else selection.target + ) + if target is not None and ( + type(target) is not tuple + or len(target) != 2 + or any(type(part) is not str or not part for part in target) + ): + raise ValueError("selected target requires an immutable reference") + object.__setattr__(self, "call", call) + object.__setattr__( + self, + "selection", + Selection( + selection.kind, + tuple( + cast(tuple[str, str], tuple(field)) for field in selection.fields + ), + keys, + parents, + target, + selection.first, + selection.after, + ), + ) + + +@dataclass(frozen=True) +class ExecutionScope: + application: ArtifactRef + principal: Actor + request_id: str + deadline_monotonic: float + lease_id: str + api_digest: str | None = None + consistency: str | None = None @dataclass(frozen=True) @@ -33,6 +162,12 @@ class OperationCall: actor: Actor key: str | None = None phase: str = "invoke" + scope: ExecutionScope | None = None + confirmation: str | None = None + + def snapshot(self) -> OperationCall: + """Own bounded JSON transport data before any asynchronous host gate.""" + return replace(self, inputs=snapshot_transport(self.inputs, SelectedKey)) @dataclass(frozen=True) @@ -43,6 +178,14 @@ class OperationOutcome: code: str | None = None +class SelectedRequestError(RuntimeError): + """A selected request had a refusal; its earlier data cannot be released.""" + + def __init__(self, status: str, code: str | None): + super().__init__("selected request failed") + self.status, self.code = status, code + + class Identity(Protocol): async def check(self, actor: Actor, operation: str) -> bool: ... @@ -62,12 +205,49 @@ async def invoke(self, call: OperationCall) -> OperationOutcome: ... async def aclose(self) -> None: ... +@runtime_checkable +class SelectedExecution(Protocol): + async def invoke_selected( + self, call: OperationCall, selection: Selection + ) -> OperationOutcome: ... + + +@runtime_checkable +class RequestScopedSelectedExecution(SelectedExecution, Protocol): + def capabilities(self) -> Mapping[str, str]: ... + def open_request( + self, scope: ExecutionScope + ) -> AbstractAsyncContextManager[None]: ... + + +@runtime_checkable +class PreparedSelectedExecution(RequestScopedSelectedExecution, Protocol): + def prepare_selected( + self, scope: ExecutionScope, calls: tuple[SelectedCallSpec, ...] + ) -> object: ... + def open_prepared_request( + self, scope: ExecutionScope, prepared: object + ) -> AbstractAsyncContextManager[None]: ... + + @dataclass(frozen=True) class HostConfig: artifact: ArtifactRef operations: tuple[Operation, ...] max_concurrency: int timeout_seconds: float + selected_capabilities: Mapping[str, str] = field( + default_factory=lambda: dict[str, str]() + ) + + def __post_init__(self) -> None: + values = dict(self.selected_capabilities) + if any( + type(key) is not str or type(value) is not str + for key, value in values.items() + ): + raise ValueError("selected capability pins require strings") + object.__setattr__(self, "selected_capabilities", MappingProxyType(values)) @dataclass(frozen=True) @@ -76,6 +256,7 @@ class HostServices: observations: Observations execution: Execution ownership: str = "borrowed" + monotonic: Callable[[], float] = field(default=time.monotonic, repr=False) @dataclass(frozen=True) @@ -89,6 +270,7 @@ class ShutdownReport: "Actor", "ArtifactRef", "Execution", + "ExecutionScope", "HostConfig", "HostServices", "Identity", @@ -96,5 +278,13 @@ class ShutdownReport: "Operation", "OperationCall", "OperationOutcome", + "PreparedSelectedExecution", + "RequestScopedSelectedExecution", + "SelectedExecution", + "SelectedKey", + "SelectedCallSpec", + "SelectedRequestError", + "connection_routes_digest", + "Selection", "ShutdownReport", ] diff --git a/packages/batten/src/batten/contracts/_connection_routes.py b/packages/batten/src/batten/contracts/_connection_routes.py new file mode 100644 index 0000000..ddbdbf2 --- /dev/null +++ b/packages/batten/src/batten/contracts/_connection_routes.py @@ -0,0 +1,61 @@ +"""Canonical metadata pin for an admitted set of generated connection routes.""" + +import json +import re +from collections.abc import Iterable +from hashlib import sha256 + +_DIGEST = re.compile(r"[0-9a-f]{64}\Z") + + +def connection_routes_digest( + application_id: str, + application_digest: str, + api_digest: str, + artifact_digest: str, + routes: Iterable[tuple[str, str, str, str]], +) -> str: + """Hash immutable route pins using the Batten connection-routes/1 preimage.""" + pins = tuple(tuple(route) for route in routes) + values = (application_id, application_digest, api_digest, artifact_digest) + if any(not _valid_text(value) for value in values): + raise ValueError("connection route scope pins require valid text") + if any( + len(route) != 4 + or any(not _valid_text(value) for value in route) + or not _DIGEST.fullmatch(route[3]) + for route in pins + ): + raise ValueError("connection route pins require valid immutable rows") + ordered = tuple(sorted(pins)) + if not ordered or len({route[0] for route in ordered}) != len(ordered): + raise ValueError("connection routes require distinct Host operations") + payload = { + "version": "batten.connection-routes/1", + "applicationId": application_id, + "applicationDigest": application_digest, + "apiDigest": api_digest, + "artifactDigest": artifact_digest, + "routes": [list(route) for route in ordered], + } + encoded = json.dumps( + payload, + ensure_ascii=False, + sort_keys=True, + separators=(",", ":"), + allow_nan=False, + ).encode("utf-8", errors="strict") + return sha256(encoded).hexdigest() + + +def _valid_text(value: object) -> bool: + if type(value) is not str or not value: + return False + try: + value.encode("utf-8", errors="strict") + except UnicodeEncodeError: + return False + return True + + +__all__ = ["connection_routes_digest"] diff --git a/packages/batten/src/batten/contracts/_values.py b/packages/batten/src/batten/contracts/_values.py new file mode 100644 index 0000000..8c444a1 --- /dev/null +++ b/packages/batten/src/batten/contracts/_values.py @@ -0,0 +1,125 @@ +"""Owned immutable snapshots of bounded transport values.""" + +import json +import math +from collections.abc import Mapping +from types import MappingProxyType +from typing import Protocol, cast + + +def _consume_text(value: str, budget: list[int]) -> None: + if len(budget) > 1: + if len(value) > budget[1]: + raise ValueError("transport byte capacity exceeded") + budget[1] -= len(value.encode("utf-8", errors="strict")) + if budget[1] < 0: + raise ValueError("transport byte capacity exceeded") + + +def _owned(value: object) -> object: + if isinstance(value, Mapping): + return { + key: _owned(item) for key, item in cast(Mapping[str, object], value).items() + } + if type(value) is tuple: + return [_owned(item) for item in cast(tuple[object, ...], value)] + return value + + +class StructuredKey(Protocol): + def __init__( + self, + record: tuple[str, str], + key_id: str, + components: tuple[Mapping[str, object], ...], + ) -> None: ... + + @property + def record(self) -> tuple[str, str]: ... + @property + def key_id(self) -> str: ... + @property + def components(self) -> tuple[Mapping[str, object], ...]: ... + + +def _key_json(item: StructuredKey) -> dict[str, object]: + return {"record": item.record, "keyId": item.key_id, "components": item.components} + + +def snapshot_transport( + value: Mapping[str, object], key_type: type[StructuredKey] +) -> Mapping[str, object]: + if not isinstance(cast(object, value), Mapping): + raise ValueError("transport inputs require a mapping") + frozen = freeze_value(value, [16_384, 8_388_608], key_type=key_type) + + def mapping(item: object) -> dict[str, object]: + if type(item) is key_type: + return _key_json(item) + if isinstance(item, Mapping): + return dict(cast(Mapping[str, object], item)) + raise ValueError("unsupported transport value") + + encoded = json.dumps( + frozen, + ensure_ascii=False, + allow_nan=False, + separators=(",", ":"), + default=mapping, + ).encode("utf-8", errors="strict") + if len(encoded) > 8_388_608: + raise ValueError("transport byte capacity exceeded") + return cast(Mapping[str, object], _owned(frozen)) + + +def _primitive(value: object, budget: list[int]) -> object: + if type(value) is str: + _consume_text(value, budget) + return value + if value is None or type(value) in {bool, int}: + return value + if type(value) is float and math.isfinite(value): + return value + raise ValueError("selection value is not a finite transport value") + + +def freeze_value( + value: object, + budget: list[int], + depth: int = 0, + *, + key_type: type[StructuredKey] | None = None, +) -> object: + + budget[0] -= 1 + if budget[0] < 0 or depth > 32: + raise ValueError("selection value exceeds limits") + if key_type is not None and type(value) is key_type: + key = cast( + Mapping[str, object], + freeze_value( + _key_json(value), + budget, + depth + 1, + key_type=key_type, + ), + ) + return key_type( + cast(tuple[str, str], key["record"]), + cast(str, key["keyId"]), + cast(tuple[Mapping[str, object], ...], key["components"]), + ) + if isinstance(value, Mapping): + result: dict[str, object] = {} + for key, item in cast(Mapping[object, object], value).items(): + if not isinstance(key, str): + raise ValueError("selection value requires string keys") + _consume_text(key, budget) + result[key] = freeze_value(item, budget, depth + 1, key_type=key_type) + return MappingProxyType(result) + if isinstance(value, (tuple, list)): + return tuple( + freeze_value(item, budget, depth + 1, key_type=key_type) + for item in cast(tuple[object, ...] | list[object], value) + ) + return _primitive(value, budget) diff --git a/packages/batten/src/batten/runtime/__init__.py b/packages/batten/src/batten/runtime/__init__.py index 4d64414..334bc42 100644 --- a/packages/batten/src/batten/runtime/__init__.py +++ b/packages/batten/src/batten/runtime/__init__.py @@ -3,24 +3,45 @@ from __future__ import annotations import asyncio +import math import re import uuid +from collections.abc import AsyncGenerator +from contextlib import asynccontextmanager from dataclasses import replace from types import TracebackType from batten.contracts import ( + Actor, ArtifactRef, + ExecutionScope, HostConfig, HostServices, + Operation, OperationCall, OperationOutcome, + SelectedCallSpec, + SelectedExecution, + Selection, ShutdownReport, ) +from batten.runtime._selected_session import SelectedSession, open_selected_session +from batten.runtime._selection import selection_failure, valid_selection + + +class _MutationAuthorityRevoked(Exception): + pass class Host: def __init__(self, config: HostConfig, services: HostServices): - if config.max_concurrency < 1 or config.timeout_seconds <= 0: + if ( + type(config.max_concurrency) is not int + or config.max_concurrency < 1 + or type(config.timeout_seconds) not in {int, float} + or not math.isfinite(config.timeout_seconds) + or config.timeout_seconds <= 0 + ): raise ValueError("positive host limits required") operations = {op.id: op for op in config.operations} if len(operations) != len(config.operations) or services.ownership not in { @@ -31,7 +52,13 @@ def __init__(self, config: HostConfig, services: HostServices): self.config, self.services, self.operations = config, services, operations self.state = "new" self.admitted = False - self.active: set[asyncio.Task[object]] = set() + self.active: dict[asyncio.Future[None], asyncio.Task[object]] = {} + self._scopes: dict[str, ExecutionScope] = {} + self._scope_calls: dict[ + str, dict[asyncio.Future[None], asyncio.Task[object]] + ] = {} + self._draining_scopes: set[str] = set() + self._scope_resources: dict[str, SelectedSession] = {} async def start(self) -> None: if self.state == "running": @@ -53,28 +80,155 @@ async def admit(self, artifact: ArtifactRef) -> bool: async def readiness(self) -> str: return self.state - async def _run(self, call: OperationCall, invocation: str) -> OperationOutcome: - op = self.operations[call.operation] - try: + async def open_scope( + self, + actor: Actor, + request_id: str, + *, + deadline_monotonic: float | None = None, + api_digest: str | None = None, + consistency: str | None = None, + ) -> ExecutionScope: + if self.state != "running" or not self.admitted: + raise RuntimeError("host is not admitted") + now = self.services.monotonic() + deadline = now + self.config.timeout_seconds + if deadline_monotonic is not None: + if not math.isfinite(deadline_monotonic): + raise ValueError("invalid scope request") + deadline = min(deadline, deadline_monotonic) + if not request_id or not math.isfinite(deadline) or deadline <= now: + raise ValueError("invalid scope request") + if len(self._scopes) >= self.config.max_concurrency: + raise RuntimeError("scope limit exceeded") + scope = ExecutionScope( + self.config.artifact, + actor, + request_id, + deadline, + uuid.uuid4().hex, + api_digest, + consistency, + ) + self._scopes[scope.lease_id] = scope + self._scope_calls[scope.lease_id] = {} + return scope + + def scope_active(self, scope: ExecutionScope) -> bool: + """Check this host's issued lease; operation authority is checked at dispatch.""" + return ( + self.state == "running" + and self.admitted + and self._scopes.get(scope.lease_id) is scope + and scope.lease_id not in self._draining_scopes + and scope.application == self.config.artifact + and math.isfinite(scope.deadline_monotonic) + and scope.deadline_monotonic > self.services.monotonic() + ) + + @asynccontextmanager + async def open_selected_session( + self, + scope: ExecutionScope, + *, + consistency: str, + calls: tuple[SelectedCallSpec, ...] | None = None, + ) -> AsyncGenerator[None]: + async with open_selected_session( + self, + scope, + consistency=consistency, + calls=calls, + resources=self._scope_resources, + draining_scopes=self._draining_scopes, + drain_scope=lambda: self._drain_scope(scope), + ): + yield + + async def _drain_scope(self, scope: ExecutionScope) -> bool: + self._draining_scopes.add(scope.lease_id) + calls = { + finished: task + for finished, task in self._scope_calls.get(scope.lease_id, {}).items() + if task is not asyncio.current_task() + } + for task in set(calls.values()): + task.cancel() + if calls: + _done, pending = await asyncio.wait( + calls, timeout=self.config.timeout_seconds + ) + return not pending + return True + + async def close_scope(self, scope: ExecutionScope) -> ShutdownReport: + if self._scopes.get(scope.lease_id) is not scope: + raise ValueError("scope is not issued by this host") + if not await self._drain_scope(scope): + return ShutdownReport( + "draining", (self.config.artifact.id,), ("scope_cleanup_pending",) + ) + resource = self._scope_resources.get(scope.lease_id) + if resource is not None and not await resource.close( + self.config.timeout_seconds + ): + return ShutdownReport( + "draining", (self.config.artifact.id,), ("scope_cleanup_pending",) + ) + self._scope_resources.pop(scope.lease_id, None) + self._scope_calls.pop(scope.lease_id, None) + self._scopes.pop(scope.lease_id, None) + self._draining_scopes.discard(scope.lease_id) + return ShutdownReport("closed", (), ()) + + async def _capture( + self, + actor: Actor, + operation: str, + invocation: str, + status: str, + mutation: bool, + ) -> None: + async with asyncio.timeout(self.config.timeout_seconds): await self.services.observations.capture( - call.actor, op.id, invocation, "started", op.mutation + actor, operation, invocation, status, mutation ) + + async def _run( + self, call: OperationCall, invocation: str, selection: Selection | None + ) -> OperationOutcome: + op = self.operations[call.operation] + try: + await self._capture(call.actor, op.id, invocation, "started", op.mutation) except Exception: return OperationOutcome( "unavailable", invocation, {}, "capture_unavailable" ) try: async with self.services.observations.scope(call.actor, op.id, invocation): - result = await self.services.execution.invoke(call) - if not await self.services.identity.check(call.actor, op.id): + await self._check_mutation_authority(call, op) + if selection is None: + result = await self.services.execution.invoke(call) + elif isinstance(self.services.execution, SelectedExecution): + result = await self.services.execution.invoke_selected( + call, selection + ) + else: + return OperationOutcome( + "invalid", invocation, {}, "unsupported_selection" + ) + failure = await self._post_failure(call) + if failure is not None: result = OperationOutcome( - "uncertain" if op.mutation else "denied", + "uncertain" if op.mutation else failure[0], invocation, {}, - "authority_revoked", + failure[1], ) + except _MutationAuthorityRevoked: + result = OperationOutcome("denied", invocation, {}, "authority_revoked") except asyncio.CancelledError: - await self.services.observations.capture( + await self._capture( call.actor, op.id, invocation, @@ -90,7 +244,7 @@ async def _run(self, call: OperationCall, invocation: str) -> OperationOutcome: "provider_unavailable", ) try: - await self.services.observations.capture( + await self._capture( call.actor, op.id, invocation, result.status, op.mutation ) except Exception: @@ -102,12 +256,23 @@ async def _run(self, call: OperationCall, invocation: str) -> OperationOutcome: ) return replace(result, invocation=invocation) + async def _check_mutation_authority( + self, call: OperationCall, op: Operation + ) -> None: + if op.mutation and not await self.services.identity.check(call.actor, op.id): + raise _MutationAuthorityRevoked + + async def _post_failure(self, call: OperationCall) -> tuple[str, str] | None: + if not await self.services.identity.check(call.actor, call.operation): + return "denied", "authority_revoked" + return self._scope_limits(call)[1] + async def _refuse( self, call: OperationCall, invocation: str, status: str, code: str ) -> OperationOutcome: operation = self.operations.get(call.operation) try: - await self.services.observations.capture( + await self._capture( call.actor, operation.id if operation else "unknown", invocation, @@ -115,31 +280,140 @@ async def _refuse( bool(operation and operation.mutation), ) except Exception: - return OperationOutcome( - "unavailable", invocation, {}, "capture_unavailable" + return self._selected_result( + call, + OperationOutcome("unavailable", invocation, {}, "capture_unavailable"), ) - return OperationOutcome(status, invocation, {}, code) + return self._selected_result( + call, OperationOutcome(status, invocation, {}, code) + ) - async def invoke(self, call: OperationCall) -> OperationOutcome: - invocation = call.key or uuid.uuid4().hex - if call.key is not None and not re.fullmatch(r"[a-f0-9-]{32,36}", call.key): - return await self._refuse(call, uuid.uuid4().hex, "invalid", "invalid_key") + async def _admission_failure(self, call: OperationCall) -> tuple[str, str] | None: if ( self.state != "running" or not self.admitted or call.operation not in self.operations ): - return await self._refuse(call, invocation, "denied", "not_admitted") + return "denied", "not_admitted" if not await self.services.identity.check(call.actor, call.operation): - return await self._refuse(call, invocation, "denied", "denied") + return "denied", "denied" + if self.state != "running" or not self.admitted: + return "denied", "not_admitted" if len(self.active) >= self.config.max_concurrency: - return await self._refuse(call, invocation, "unavailable", "limit_exceeded") + return "unavailable", "limit_exceeded" + return None + + def _scope_limits( + self, call: OperationCall + ) -> tuple[float, tuple[str, str] | None]: + timeout = self.config.timeout_seconds + scope = call.scope + if self.state != "running" or not self.admitted: + return timeout, ("denied", "not_admitted") + now = self.services.monotonic() + if scope is None: + failure = None if math.isfinite(now) else ("unavailable", "clock_invalid") + return timeout, failure + if ( + self._scopes.get(scope.lease_id) is not scope + or scope.lease_id in self._draining_scopes + ): + return timeout, ("denied", "scope_invalid") + if ( + scope.application != self.config.artifact + or scope.principal != call.actor + or not scope.request_id + or not scope.lease_id + or not math.isfinite(scope.deadline_monotonic) + ): + return timeout, ("denied", "scope_invalid") + remaining = scope.deadline_monotonic - now + if remaining <= 0 or not math.isfinite(remaining): + code = "deadline_exceeded" if math.isfinite(remaining) else "clock_invalid" + return timeout, ("unavailable", code) + failure = None + if scope.consistency == "request-snapshot-1" and ( + scope.lease_id not in self._scope_resources + or not self._scope_resources[scope.lease_id].active + ): + failure = ("invalid", "selected_session_inactive") + return min(timeout, remaining), failure + + async def _call_limits( + self, call: OperationCall, selection: Selection | None + ) -> tuple[float, tuple[str, str] | None]: + failure = await self._admission_failure(call) + timeout = self.config.timeout_seconds + if failure is None: + timeout, failure = self._scope_limits(call) + if failure is None and selection is not None: + failure = selection_failure( + self.operations[call.operation], self.services.execution, selection + ) + return timeout, failure + + async def invoke( + self, call: OperationCall, *, selection: Selection | None = None + ) -> OperationOutcome: + invocation = call.key or uuid.uuid4().hex + if selection is not None and not valid_selection(selection): + return await self._refuse(call, invocation, "invalid", "invalid_selection") + if call.key is not None and not re.fullmatch(r"[a-f0-9-]{32,36}", call.key): + return await self._refuse(call, uuid.uuid4().hex, "invalid", "invalid_key") + try: + call = call.snapshot() + except (ValueError, TypeError, UnicodeError): + return await self._refuse(call, invocation, "invalid", "invalid_inputs") + timeout, failure = self._scope_limits(call) + deadline = self.services.monotonic() + timeout + remaining = timeout + if failure is None: + try: + async with asyncio.timeout(timeout): + timeout, failure = await self._call_limits(call, selection) + except TimeoutError: + failure = ("unavailable", "deadline_exceeded") + if failure is None: + remaining = deadline - self.services.monotonic() + if not math.isfinite(remaining) or remaining <= 0: + failure = ("unavailable", "deadline_exceeded") + remaining = min(timeout, remaining) + if failure is not None: + result = await self._refuse(call, invocation, *failure) + else: + result = await self._dispatch(call, invocation, selection, remaining) + return self._selected_result(call, result) + + def _selected_result( + self, call: OperationCall, result: OperationOutcome + ) -> OperationOutcome: + scope = call.scope + if scope is not None: + resource = self._scope_resources.get(scope.lease_id) + if ( + resource is not None + and resource.active + and self._scopes.get(scope.lease_id) is scope + ): + resource.record(result) + return result + + async def _dispatch( + self, + call: OperationCall, + invocation: str, + selection: Selection | None, + timeout: float, + ) -> OperationOutcome: task = asyncio.current_task() + finished = asyncio.get_running_loop().create_future() if task is not None: - self.active.add(task) + self.active[finished] = task + if call.scope is not None: + self._scope_calls[call.scope.lease_id][finished] = task try: - async with asyncio.timeout(self.config.timeout_seconds): - return await self._run(call, invocation) + async with asyncio.timeout(timeout): + return await self._run(call, invocation, selection) except TimeoutError: return OperationOutcome( "uncertain" @@ -150,26 +424,48 @@ async def invoke(self, call: OperationCall) -> OperationOutcome: "timeout", ) finally: - if task is not None: - self.active.discard(task) + self.active.pop(finished, None) + if call.scope is not None: + self._scope_calls.get(call.scope.lease_id, {}).pop(finished, None) + finished.set_result(None) async def aclose(self) -> ShutdownReport: if self.state == "closed": return ShutdownReport("closed", (self.config.artifact.id,), ()) self.state, self.admitted = "draining", False - tasks = self.active - {asyncio.current_task()} + current = asyncio.current_task() + invocations = self.active.copy() + tasks = set(invocations.values()) - {current} for task in tasks: task.cancel() - if tasks: + pending_invocations = { + completion + for completion, task in invocations.items() + if task is not current + } + if pending_invocations: _done, pending = await asyncio.wait( - tasks, timeout=self.config.timeout_seconds + pending_invocations, timeout=self.config.timeout_seconds ) if pending: return ShutdownReport( "draining", (self.config.artifact.id,), ("cleanup_pending",) ) + if any(task is current for task in invocations.values()): + return ShutdownReport( + "draining", (self.config.artifact.id,), ("cleanup_pending",) + ) + for resource in self._scope_resources.values(): + if not await resource.close(self.config.timeout_seconds): + return ShutdownReport( + "draining", (self.config.artifact.id,), ("cleanup_pending",) + ) + self._scope_resources.clear() if self.services.ownership == "owned": await self.services.execution.aclose() + self._scopes.clear() + self._scope_calls.clear() + self._draining_scopes.clear() self.state = "closed" return ShutdownReport("closed", (self.config.artifact.id,), ()) diff --git a/packages/batten/src/batten/runtime/_selected_session.py b/packages/batten/src/batten/runtime/_selected_session.py new file mode 100644 index 0000000..f6aae96 --- /dev/null +++ b/packages/batten/src/batten/runtime/_selected_session.py @@ -0,0 +1,258 @@ +"""Task-owned selected resources; context entry and exit share one task.""" + +from __future__ import annotations + +import asyncio +from collections.abc import AsyncGenerator, Awaitable, Callable +from contextlib import asynccontextmanager +from typing import Protocol, cast + +from batten.contracts import ( + ExecutionScope, + HostConfig, + HostServices, + Operation, + OperationOutcome, + PreparedSelectedExecution, + RequestScopedSelectedExecution, + SelectedCallSpec, + SelectedRequestError, +) +from batten.runtime._selection import selection_failure + +_MAX_PREPARED_CALLS = 256 + + +class _SelectedSessionHost(Protocol): + config: HostConfig + services: HostServices + operations: dict[str, Operation] + + def scope_active(self, scope: ExecutionScope) -> bool: ... + + +def _prepared_execution(execution: object) -> bool: + try: + return ( + isinstance(execution, PreparedSelectedExecution) + and callable(getattr(execution, "prepare_selected")) + and callable(getattr(execution, "open_prepared_request")) + ) + except AttributeError: + return False + + +def _prepared_plan( + host: _SelectedSessionHost, + execution: RequestScopedSelectedExecution, + scope: ExecutionScope, + prepared: object | None, +) -> tuple[object | None, bool]: + if prepared is None: + return None, False + raw_calls = cast(tuple[object, ...], prepared) + if ( + not _prepared_execution(execution) + or type(prepared) is not tuple + or not prepared + or len(raw_calls) > _MAX_PREPARED_CALLS + or any(type(item) is not SelectedCallSpec for item in raw_calls) + ): + raise ValueError("prepared selected calls are unavailable") + for item in cast(tuple[SelectedCallSpec, ...], prepared): + if ( + item.call.scope is not scope + or item.call.actor != scope.principal + or item.call.operation not in host.operations + or selection_failure( + host.operations[item.call.operation], execution, item.selection + ) + is not None + ): + raise ValueError("prepared selected calls are unavailable") + plan = cast(PreparedSelectedExecution, execution).prepare_selected( + scope, cast(tuple[SelectedCallSpec, ...], prepared) + ) + return plan, True + + +async def _authorize_prepared_calls( + host: _SelectedSessionHost, + scope: ExecutionScope, + calls: tuple[SelectedCallSpec, ...], +) -> None: + deadline = scope.deadline_monotonic - host.services.monotonic() + try: + async with asyncio.timeout(deadline): + for operation in dict.fromkeys(item.call.operation for item in calls): + if not await host.services.identity.check(scope.principal, operation): + raise SelectedRequestError("denied", "denied") + except TimeoutError: + raise SelectedRequestError("unavailable", "deadline_exceeded") from None + + +async def _admit_selected_session( + host: _SelectedSessionHost, + scope: ExecutionScope, + consistency: str, + calls: tuple[SelectedCallSpec, ...] | None, + resources: dict[str, SelectedSession], +) -> tuple[RequestScopedSelectedExecution, object | None, bool]: + execution = host.services.execution + if ( + consistency != "request-snapshot-1" + or scope.consistency != consistency + or not host.scope_active(scope) + or not scope.api_digest + or scope.lease_id in resources + or not isinstance(execution, RequestScopedSelectedExecution) + or host.config.selected_capabilities.get("read.consistency") != consistency + or dict(execution.capabilities()) != dict(host.config.selected_capabilities) + ): + raise ValueError("selected request profile is unavailable") + plan, prepared_selected = _prepared_plan(host, execution, scope, calls) + if prepared_selected and ( + plan is None + or not host.scope_active(scope) + or dict(execution.capabilities()) != dict(host.config.selected_capabilities) + ): + raise ValueError("prepared selected request is unavailable") + if calls is not None: + await _authorize_prepared_calls(host, scope, calls) + if not host.scope_active(scope) or scope.lease_id in resources: + raise ValueError("prepared selected request is unavailable") + return execution, plan, prepared_selected + + +@asynccontextmanager +async def open_selected_session( + host: _SelectedSessionHost, + scope: ExecutionScope, + *, + consistency: str, + calls: tuple[SelectedCallSpec, ...] | None = None, + resources: dict[str, SelectedSession], + draining_scopes: set[str], + drain_scope: Callable[[], Awaitable[bool]], +) -> AsyncGenerator[None]: + execution, plan, prepared_selected = await _admit_selected_session( + host, scope, consistency, calls, resources + ) + resource = SelectedSession( + execution, + scope, + scope.deadline_monotonic - host.services.monotonic(), + drain_scope, + plan, + prepared_selected, + ) + resources[scope.lease_id] = resource + completed = False + try: + await resource.start() + if not host.scope_active(scope) or not resource.active: + raise RuntimeError("selected request scope expired") + yield + completed = True + finally: + draining_scopes.add(scope.lease_id) + if not await asyncio.shield(resource.close(host.config.timeout_seconds)): + draining_scopes.add(scope.lease_id) + if completed: + raise RuntimeError("selected request cleanup pending") + elif not resource.failed: + draining_scopes.discard(scope.lease_id) + if resource.failed and completed: + raise RuntimeError("selected request failed") from resource.failure + if resource.refusal is not None and completed: + raise resource.refusal + + +class SelectedSession: + def __init__( + self, + execution: RequestScopedSelectedExecution, + scope: ExecutionScope, + timeout: float, + drain: Callable[[], Awaitable[bool]], + prepared: object | None = None, + prepared_selected: bool = False, + ): + self._execution, self._scope, self._timeout = execution, scope, timeout + self._prepared, self._prepared_selected = prepared, prepared_selected + self._drain = drain + self._ready, self._stop = asyncio.Event(), asyncio.Event() + self._task: asyncio.Task[None] | None = None + self.failed = False + self.refusal: SelectedRequestError | None = None + + def record(self, outcome: OperationOutcome) -> None: + if self.refusal is None and outcome.status != "succeeded": + self.refusal = SelectedRequestError(outcome.status, outcome.code) + + @property + def active(self) -> bool: + return ( + self._task is not None + and self._ready.is_set() + and not self._task.done() + and not self._stop.is_set() + ) + + @property + def failure(self) -> BaseException | None: + task = self._task + if task is None or not task.done(): + return None + return asyncio.CancelledError() if task.cancelled() else task.exception() + + async def _serve(self) -> None: + try: + async with asyncio.timeout(self._timeout): + context = ( + cast( + PreparedSelectedExecution, self._execution + ).open_prepared_request(self._scope, self._prepared) + if self._prepared_selected + else self._execution.open_request(self._scope) + ) + async with context: + self._ready.set() + try: + await self._stop.wait() + finally: + await self._drain_calls() + except BaseException: + self.failed = True + raise + finally: + self._ready.set() + + async def _drain_calls(self) -> None: + while True: + try: + if await self._drain(): + return + except asyncio.CancelledError: + self.failed = True + + async def start(self) -> None: + self._task = asyncio.create_task(self._serve()) + self._task.add_done_callback(lambda _task: self._ready.set()) + await self._ready.wait() + if self._task.done(): + self._task.result() + raise RuntimeError("selected request closed before admission") + + async def close(self, timeout: float) -> bool: + self._stop.set() + task = self._task + if task is None: + return True + _done, pending = await asyncio.wait({task}, timeout=timeout) + if pending: + task.cancel() + return False + if not task.cancelled(): + task.exception() + return True diff --git a/packages/batten/src/batten/runtime/_selection.py b/packages/batten/src/batten/runtime/_selection.py new file mode 100644 index 0000000..2817859 --- /dev/null +++ b/packages/batten/src/batten/runtime/_selection.py @@ -0,0 +1,80 @@ +"""Reject unsupported selected reads before provider acquisition or effects.""" + +from typing import cast + +from batten.contracts import Operation, SelectedExecution, SelectedKey, Selection + + +def _reference(value: object) -> bool: + return ( + isinstance(value, tuple) + and len(cast(tuple[object, ...], value)) == 2 + and all( + isinstance(item, str) and bool(item) + for item in cast(tuple[object, ...], value) + ) + ) + + +def _key(value: object) -> bool: + return ( + isinstance(value, SelectedKey) + and _reference(value.record) + and isinstance(cast(object, value.key_id), str) + and bool(value.key_id) + ) + + +def valid_selection(value: object) -> bool: + if not isinstance(value, Selection): + return False + fields, keys, parents = value.fields, value.keys, value.parents + return ( + isinstance(cast(object, value.kind), str) + and value.kind in {"get_many", "connection", "related_many"} + and type(fields) is tuple + and len(fields) <= 1024 + and all(_reference(item) for item in fields) + and type(keys) is tuple + and type(parents) is tuple + and len(keys) + len(parents) <= 4096 + and all(_key(item) for item in (*keys, *parents)) + and (value.target is None or _reference(value.target)) + and (value.after is None or isinstance(cast(object, value.after), str)) + ) + + +def selection_failure( + operation: Operation, execution: object, selection: Selection +) -> tuple[str, str] | None: + if ( + operation.mutation + or selection.kind not in operation.selection_kinds + or not isinstance(execution, SelectedExecution) + ): + return "invalid", "unsupported_selection" + if selection.kind == "get_many": + valid = ( + not selection.parents + and selection.target is None + and selection.first is None + and selection.after is None + ) + elif selection.kind == "connection": + valid = ( + not selection.keys + and not selection.parents + and selection.target is None + and type(selection.first) is int + and selection.first >= 0 + ) + elif selection.kind == "related_many": + valid = ( + not selection.keys + and selection.target is not None + and selection.first is None + and selection.after is None + ) + else: + valid = False + return None if valid else ("invalid", "invalid_selection") diff --git a/scripts/boundary_model.py b/scripts/boundary_model.py index 1994318..30d9b3f 100644 --- a/scripts/boundary_model.py +++ b/scripts/boundary_model.py @@ -27,6 +27,7 @@ "arras": ("contracts",), "tether": ("contracts",), "asgi": ("contracts", "runtime"), + "lintel": ("contracts", "runtime"), "umf_postgres": ("contracts", "tables"), "umf_postgres.local": ("contracts", "tables", "umf_postgres"), "hosting.local": ("contracts", "runtime", "asgi", "tables", "umf_postgres.local"), @@ -44,7 +45,13 @@ "arras": {"arras", "umf_core", "umf_access"}, "tether": {"tether"}, "asgi": {"starlette", "uvicorn"}, - "umf_postgres": {"umf_access", "umf_codegen", "psycopg"}, + "lintel": {"lintel", "starlette", "umf_access", "umf_access_generated_executor"}, + "umf_postgres": { + "umf_access", + "umf_codegen", + "umf_access_generated_executor", + "psycopg", + }, "umf_postgres.local": { "umf_access", "umf_codegen", diff --git a/scripts/public-api.json b/scripts/public-api.json index 343eb33..00ce8d6 100644 --- a/scripts/public-api.json +++ b/scripts/public-api.json @@ -45,6 +45,15 @@ ], "batten.umf_postgres": [ "AuthenticatedTransport", + "GeneratedBatchBinding", + "GeneratedBatchExecution", + "GeneratedBatchRequest", + "GeneratedCommandExecution", + "GeneratedCommandRoute", + "GeneratedRelationshipRoute", + "GeneratedRelationships", + "GeneratedTableBinding", + "GeneratedTableExecution", "NativeBinding", "UmfTableProvider", "create_umf_provider" @@ -56,6 +65,7 @@ ], "batten.asgi": [ "AppListing", + "LocalIdentities", "LocalSessions", "create_app", "create_registry" @@ -68,6 +78,7 @@ "Actor", "ArtifactRef", "Execution", + "ExecutionScope", "HostConfig", "HostServices", "Identity", @@ -75,6 +86,58 @@ "Operation", "OperationCall", "OperationOutcome", + "PreparedSelectedExecution", + "RequestScopedSelectedExecution", + "SelectedExecution", + "SelectedKey", + "SelectedCallSpec", + "SelectedRequestError", + "connection_routes_digest", + "Selection", "ShutdownReport" + ], + "batten.lintel": [ + "ExposureConfig", + "ExposureOperation", + "ExposureRecordRoot", + "ConnectionAdmission", + "LintelExecution", + "prepare_connection_admission" + ], + "batten.lintel.asgi": [ + "HostScopeIngress" + ], + "batten.umf_postgres.generated": [ + "GeneratedNativeBinding", + "GeneratedUmfExecution" + ], + "batten.umf_postgres.generated_batch": [ + "GeneratedBatchBinding", + "GeneratedBatchExecution", + "GeneratedBatchRequest" + ], + "batten.umf_postgres.generated_command": [ + "GeneratedCommandExecution", + "GeneratedCommandRoute" + ], + "batten.umf_postgres.generated_read": [ + "GeneratedReadBinding", + "GeneratedReadExecution" + ], + "batten.umf_postgres.generated_read_v2": [ + "GeneratedReadBindingV2", + "GeneratedReadExecutionV2" + ], + "batten.umf_postgres.generated_read_v3": [ + "GeneratedReadBindingV3", + "GeneratedReadExecutionV3" + ], + "batten.umf_postgres.generated_relationship": [ + "GeneratedRelationshipRoute", + "GeneratedRelationships" + ], + "batten.umf_postgres.generated_table": [ + "GeneratedTableBinding", + "GeneratedTableExecution" ] } diff --git a/tests/runtime/api3_connection_fixture.py b/tests/runtime/api3_connection_fixture.py new file mode 100644 index 0000000..03ca748 --- /dev/null +++ b/tests/runtime/api3_connection_fixture.py @@ -0,0 +1,475 @@ +"""Pure fixture builders for the captured strict API3 generated artifact.""" + +import json +from collections.abc import Mapping +from contextlib import AbstractAsyncContextManager +from dataclasses import dataclass, replace +from hashlib import sha256 +from pathlib import Path +from types import MappingProxyType +from typing import Any, Literal, NamedTuple, cast + +from batten.contracts import ArtifactRef, ExecutionScope, Operation +from batten.lintel import ( + ConnectionAdmission, + ExposureConfig, + ExposureRecordRoot, + LintelExecution, +) +from batten.umf_postgres import GeneratedTableExecution +from generated_batch_case import batch_case +from lintel.ports import ( + ConnectionIntent, + ElementRef, + OperationRef, + RequestScope, +) +from lintel.projection import ( + AdmittedPreparedApi, + PreparedConnection, + TrustedPreparedRef, + load_prepared_api, +) +from umf_access.unified import AsyncSession, SessionIdentity, SessionPolicy +from umf_access_generated_executor import GeneratedExecutor + + +def prepared_api_inputs() -> tuple[bytes, TrustedPreparedRef]: + folder = Path(__file__).with_name("fixtures") + artifact = (folder / "prepared-api-v3-four-fields-proof.json").read_bytes() + trusted = cast( + dict[str, object], + json.loads((folder / "prepared-api-v3-four-fields-trust.json").read_bytes()), + ) + return artifact, TrustedPreparedRef( + cast(str, trusted["artifactSha256"]), + cast(str, trusted["artifactDigest"]), + cast(str, trusted["application"]), + cast(str, trusted["apiDigest"]), + cast(str, trusted["exposureSha256"]), + tuple( + (item["identity"], item["sha256"]) + for item in cast(list[dict[str, str]], trusted["sources"]) + ), + tuple( + (pair[0], pair[1]) + for pair in cast(list[tuple[str, str]], trusted["capabilities"]) + ), + cast(str, trusted["bindingProfile"]), + cast(str, trusted["scalarCodecProfile"]), + tuple( + (pair[0], pair[1]) + for pair in cast(list[tuple[str, str]], trusted["limits"]) + ), + cast(str, trusted["generatedRootsSha256"]), + cast(str, trusted["generatedConnectionsSha256"]), + ) + + +def api3_case( + kind: Literal["person", "batch"], authority: object +) -> tuple[ + dict[str, Any], + GeneratedExecutor, + AdmittedPreparedApi, + ExposureConfig, + ConnectionAdmission, +]: + case = batch_case(kind, authority, composite="v5") + executor = cast(GeneratedExecutor, case["executor"]) + prepared = load_prepared_api(*prepared_api_inputs()) + config = exposure_config(executor) + admission = LintelExecution.prepare_connections( + config, prepared, executor.native_table, executor + ) + return case, executor, prepared, config, admission + + +class ConnectionAuthority: + """Allow only the explicitly configured fixture operations.""" + + async def check(self, actor: object, operation: str) -> bool: + return operation in {"records.note", "records.task"} + + +def profile7_base_routes_case(kind: Literal["person", "batch"]) -> tuple[Any, Any]: + """Prepare the issued v7 root with a protocol-only native binding double.""" + from generated_provider_cases import Native + from read_artifacts import read_executor + + executor, _root = read_executor("v7") + trust = executor.trusted_artifact + native: Any = Native(executor) + native.artifact_digest = trust.artifact_digest + native.receipt_digest = trust.receipt_digest + native.algebra_json = executor.read_algebra_json + fields = (ElementRef("demo", "owner"),) + root = ExposureRecordRoot( + OperationRef("demo", "Note", "record"), + "inspect", + executor.native_table.source_digest, + trust.artifact_digest, + trust.receipt_digest, + executor.target.binding_digest, + sha256(executor.read_algebra_json).hexdigest(), + "primary", + fields, + ("string",), + tuple((field, "string") for field in fields), + ) + + def unused_factory(_identity: SessionIdentity) -> AbstractAsyncContextManager[Any]: + raise AssertionError("base profile preparation must not open a native request") + + session = AsyncSession( + unused_factory, + SessionPolicy({"page7-fixture-user": "fixture_role"}, {}, "fixture_schema"), + ) + + async def factory() -> Any: + return native + + provider = GeneratedTableExecution( + executor, + factory, + data_session=session, + authority=ConnectionAuthority(), + read_routes={"ordinary": ("demo", "Note")}, + record_routes={"inspect": root}, + ) + return ( + provider, + native, + ) + + +@dataclass(frozen=True) +class RouteMismatchCases: + connection_provider: Any + connection_native: Any + page_provider: Any + page_native: Any + incomplete_page: Any + incomplete_page_native: Any + profile7_base_routes: Any + profile7_base_native: Any + + +def route_mismatch_cases(kind: Literal["person", "batch"]) -> RouteMismatchCases: + case, executor, _prepared, _config, _admission = api3_case( + kind, ConnectionAuthority() + ) + native = case["native"] + native.connection_routes = {} + connection_provider = case["provider_type"]( + executor, case["factory"], **case["provider_kwargs"] + ) + from generated_provider_cases import page_route_scenario + + page = page_route_scenario(kind, ("demo", "Task")) + incomplete = page_route_scenario(kind, missing_method="execute_ordinary_page") + profile7_provider, profile7_native = profile7_base_routes_case(kind) + return RouteMismatchCases( + connection_provider, + native, + page.provider, + page.native, + incomplete.provider, + incomplete.native, + profile7_provider, + profile7_native, + ) + + +def bind_api3_case( + case: dict[str, Any], config: ExposureConfig, admission: ConnectionAdmission +) -> None: + """Bind fake frames to immutable route metadata already derived from API3.""" + from generated_batch_case import connection_frame_fixture + + case["app"] = config.application + case["native"].connection_routes = dict(admission.native_routes) + case["provider_kwargs"]["connection_routes"] = admission.native_routes + case["provider_kwargs"]["record_routes"] = { + root.host_operation: root for root in config.record_roots + } + case["connection_call_trace"] = [] + + def execute_forward_connection(prepared_call: object) -> dict[str, Any]: + case["connection_call_trace"].append(case["request"]) + return connection_frame_fixture( + cast(tuple[object, object, object], prepared_call)[0], + admission.native_routes, + case["executor"], + ) + + case["request"].execute_forward_connection.side_effect = execute_forward_connection + result = { + "version": "umf.generated-key-batch-result/1", + "sourceDigest": case["executor"].native_table.source_digest, + "bindingDigest": case["executor"].target.binding_digest, + "module": "demo", + "record": "Note", + "keyId": "primary", + "fields": [], + "items": [{"key": [{"string": "n-1"}], "values": []}], + } + case["get_many_call_trace"] = [] + + def execute_get_many(_call: object) -> dict[str, Any]: + case["get_many_call_trace"].append(case["request"]) + return result + + case["request"].execute_get_many.side_effect = execute_get_many + + +def large_connection_frame( + prepared_call: object, routes: Mapping[str, Any], executor: Any, size: int +) -> dict[str, Any]: + from generated_batch_case import connection_frame_fixture + + call = cast(tuple[object, object, object], prepared_call)[0] + frame = connection_frame_fixture(call, routes, executor) + native_call = cast(Any, call) + if native_call.first and native_call.fields: + field = native_call.fields[0] + edge = cast(dict[str, Any], cast(list[Any], frame["edges"])[0]) + node = cast(dict[str, Any], edge["node"]) + cast(dict[str, Any], node["fields"])[field] = {"string": "x" * size} + return frame + + +def bind_large_connection_frames( + case: dict[str, Any], admission: ConnectionAdmission, size: int +) -> None: + def execute_forward_connection(prepared_call: object) -> dict[str, Any]: + case["connection_call_trace"].append(case["request"]) + return large_connection_frame( + prepared_call, admission.native_routes, case["executor"], size + ) + + case["request"].execute_forward_connection.side_effect = execute_forward_connection + + +class ConfiguredApi3Case(NamedTuple): + case: dict[str, Any] + executor: GeneratedExecutor + prepared: AdmittedPreparedApi + config: ExposureConfig + admission: ConnectionAdmission + provider: Any + + +def configured_api3_case( + kind: Literal["person", "batch"], mode: str +) -> ConfiguredApi3Case: + case, executor, prepared, config, admission = api3_case(kind, ConnectionAuthority()) + bind_api3_case(case, config, admission) + if mode == "aggregate_budget": + bind_large_connection_frames(case, admission, 4_300_000) + provider = case["provider_type"]( + executor, case["factory"], **case["provider_kwargs"] + ) + return ConfiguredApi3Case(case, executor, prepared, config, admission, provider) + + +def exposure_config(executor: GeneratedExecutor) -> ExposureConfig: + trust = executor.trusted_artifact + algebra_digest = sha256(executor.read_algebra_json).hexdigest() + roots: list[ExposureRecordRoot] = [] + for record, host_operation in (("Note", "records.note"), ("Task", "records.task")): + if record == "Note": + exposed = tuple( + ElementRef("demo", field) + for field in ("amount", "enabled", "owner", "payload") + ) + else: + exposed = (ElementRef("demo", "task_value"),) + roots.append( + ExposureRecordRoot( + OperationRef("demo", record, "record"), + host_operation, + executor.native_table.source_digest, + trust.artifact_digest, + trust.receipt_digest, + executor.target.binding_digest, + algebra_digest, + "primary", + exposed, + ("string",), + tuple( + ( + field, + "decimalToken" + if field.element == "amount" + else "boolean" + if field.element == "enabled" + else "string", + ) + for field in exposed + ), + ) + ) + return ExposureConfig( + ArtifactRef( + "fixture-app", + "cab24da3fcf113acc7a59c4c58d1a3f65d9c8c33802e43129792a53eb1f0bc11", + ), + "bf0a7712a0175cce95280a7dcd0f150604dba7e44bfbdae35f7db3a84b6ac105", + executor.native_table.source_digest, + (), + { + "connection.forward": "edge-cursor-1", + "read.consistency": "request-snapshot-1", + }, + tuple(roots), + ) + + +def connection_intents(api: AdmittedPreparedApi) -> tuple[ConnectionIntent, ...]: + note, task = api.generated_connections + return ( + ConnectionIntent( + "noteAlias", + note.name, + note.lookup, + MappingProxyType({}), + 1, + None, + (ElementRef("demo", "owner"),), + ), + ConnectionIntent( + "taskAlias", + task.name, + task.lookup, + MappingProxyType({}), + 1, + None, + (ElementRef("demo", "task_value"),), + ), + ConnectionIntent( + "emptyZero", + note.name, + note.lookup, + MappingProxyType({}), + 0, + None, + (), + ), + ConnectionIntent( + "emptyOne", + note.name, + note.lookup, + MappingProxyType({}), + 1, + None, + (), + ), + ConnectionIntent( + "noteAliasTwin", + note.name, + note.lookup, + MappingProxyType({}), + 1, + None, + (ElementRef("demo", "owner"),), + ), + ) + + +def refusal_intents( + intents: tuple[ConnectionIntent, ...], +) -> tuple[tuple[ConnectionIntent, str], ...]: + return ( + ( + replace(intents[0], response_key="badCursor", after="invalid-cursor"), + "INVALID_CURSOR", + ), + (replace(intents[0], arguments={"filter": {}}), "UNSUPPORTED"), + ) + + +def escaped_profile_case( + config: ExposureConfig, +) -> tuple[ + PreparedConnection, + ExposureRecordRoot, + dict[str, object], + dict[str, object], + dict[str, object], +]: + module, record = "demo/~module", "Note/Part~" + lookup = OperationRef(module, record, "record") + visible = ElementRef(module, "owner/id~") + key = ElementRef(module, "id/~") + visible_id = "demo~1~0module/owner~1id~0" + key_id = "demo~1~0module/id~1~0" + visible_output = {"carrier": "string", "nullable": False} + key_output = {"carrier": "string", "nullable": False} + field_rows: tuple[dict[str, object], ...] = ( + { + "fieldId": visible_id, + "sourceField": {"module": module, "element": visible.element}, + "output": visible_output, + "scalar": "string", + "nullable": False, + }, + { + "fieldId": key_id, + "sourceField": {"module": module, "element": key.element}, + "output": key_output, + "scalar": "string", + "nullable": False, + }, + ) + connection = PreparedConnection( + lookup, "escaped", (visible,), key, "0" * 64, {"fields": list(field_rows)} + ) + exposed = replace(config.record_roots[0], ref=lookup, fields=(visible,)) + root: dict[str, object] = { + "fields": { + visible_id: {"sourceField": {"module": module, "element": visible.element}}, + key_id: {"sourceField": {"module": module, "element": key.element}}, + }, + "forwardConnection": { + "fieldOutputs": [ + {"fieldId": visible_id, "output": visible_output}, + {"fieldId": key_id, "output": key_output}, + ] + }, + "primaryKey": [{"fieldId": key_id}], + } + good_profile: dict[str, object] = { + "fields": [dict(field_rows[0]), dict(field_rows[1])] + } + bad_fields: list[dict[str, object]] = [dict(field_rows[0]), dict(field_rows[1])] + bad_fields[0]["fieldId"] = "demo/~module/owner/id~" + bad_profile: dict[str, object] = {"fields": bad_fields} + return connection, exposed, root, good_profile, bad_profile + + +def budget_intents( + intents: tuple[ConnectionIntent, ...], +) -> tuple[ConnectionIntent, ...]: + return tuple( + replace(intents[0], response_key=f"budget{index}") for index in range(3) + ) + + +def request_scope(api: AdmittedPreparedApi, authority: ExecutionScope) -> RequestScope: + return RequestScope( + api.application, + api.api_digest, + "query", + authority, + authority.request_id, + authority.deadline_monotonic, + ) + + +def host_operations() -> tuple[Operation, ...]: + return ( + Operation("records.note", False, ("get_many", "connection")), + Operation("records.task", False, ("get_many", "connection")), + Operation("ordinary", False), + ) diff --git a/tests/runtime/api3_connection_scenarios.py b/tests/runtime/api3_connection_scenarios.py new file mode 100644 index 0000000..604fe87 --- /dev/null +++ b/tests/runtime/api3_connection_scenarios.py @@ -0,0 +1,222 @@ +"""Pure scenario and observation data for the API3 selected-session workflow.""" + +from __future__ import annotations + +from collections.abc import Mapping +from dataclasses import dataclass, replace +from types import MappingProxyType +from typing import Any, cast + +from api3_connection_fixture import budget_intents +from lintel.ports import Arguments, ConnectionIntent, ElementRef, NodeKey + + +@dataclass(frozen=True) +class SessionStep: + name: str + method: str + arguments: tuple[object, ...] + expected_error: str | None = None + + +@dataclass(frozen=True) +class RequestObservation: + opened: int + get_many_calls: int + connection_calls: int + get_many_trace_ids: tuple[int, ...] + connection_trace_ids: tuple[int, ...] + prepared_identity_ids: tuple[int, ...] + prepared_scope_ids: tuple[int, ...] + opened_identity_id: int + opened_scope_id: int + + +@dataclass(frozen=True) +class RouteObservation: + provider_digest: str + admission_digest: str + + +@dataclass(frozen=True) +class ResultObservation: + node_fields: tuple[Mapping[str, object] | None, ...] + page_edge_counts: tuple[int, ...] + page_node_fields: tuple[tuple[Mapping[str, object], ...], ...] + page_record_refs: tuple[ElementRef, ...] + + +def request_observation(case: Mapping[str, Any]) -> RequestObservation: + native = case["native"] + request = case["request"] + identities = [entry[0] for entry in native.prepared_connection_scopes] + scopes = [entry[1] for entry in native.prepared_connection_scopes] + opened = native.open_request.call_args + return RequestObservation( + native.open_request.call_count, + request.execute_get_many.await_count, + request.execute_forward_connection.await_count, + tuple(id(value) for value in case["get_many_call_trace"]), + tuple(id(value) for value in case["connection_call_trace"]), + tuple(id(value) for value in identities), + tuple(id(value) for value in scopes), + id(opened.args[0]), + id(opened.args[1]), + ) + + +def route_observation(provider: Any, admission: Any) -> RouteObservation: + key = "connection.routes.digest" + return RouteObservation( + provider.capabilities()[key], admission.selected_capabilities[key] + ) + + +def result_observation(results: list[object]) -> ResultObservation: + nodes = cast(tuple[Any | None, ...], results[0]) + pages = cast(list[Any], results[1:]) + return ResultObservation( + tuple(node.fields if node is not None else None for node in nodes), + tuple(len(page.edges) for page in pages), + tuple(tuple(edge.node.fields for edge in page.edges) for page in pages), + tuple(edge.node.key.record for page in pages for edge in page.edges), + ) + + +def session_workflow( + mode: str, intents: tuple[ConnectionIntent, ...] +) -> tuple[ + tuple[ConnectionIntent, ...], + tuple[SessionStep, ...], + str, + int, + int, + int, +]: + if mode in {"complete", "complete_then_replay"}: + steps = [ + SessionStep( + "getMany", + "get_many", + ( + intents[0].lookup, + ( + NodeKey( + ElementRef(intents[0].lookup.module, intents[0].lookup.id), + "primary", + ({"string": "n-1"},), + ), + ), + (), + ), + ) + ] + steps.extend( + SessionStep(f"connection:{index}", "planned_connection", (intent,)) + for index, intent in enumerate(intents) + ) + if mode == "complete_then_replay": + steps.append( + SessionStep( + "replay", "planned_connection", (intents[0],), "UNSUPPORTED" + ) + ) + return intents, tuple(steps), "UNSUPPORTED", 5, 1, 5 + if mode == "ordinary_refusal": + arguments: Arguments = MappingProxyType({}) + return ( + (intents[0],), + ( + SessionStep( + "ordinary connection", + "connection", + ( + intents[0].lookup, + arguments, + 1, + None, + intents[0].fields, + ), + "UNSUPPORTED", + ), + SessionStep( + "post-refusal getMany", + "get_many", + ( + intents[0].lookup, + ( + NodeKey( + ElementRef( + intents[0].lookup.module, intents[0].lookup.id + ), + "primary", + ({"string": "n-1"},), + ), + ), + (), + ), + "UNSUPPORTED", + ), + ), + "UNSUPPORTED", + 0, + 0, + 1, + ) + if mode == "alias_refusal": + return ( + (intents[0],), + ( + SessionStep( + "wrong response key", + "planned_connection", + (replace(intents[0], response_key="differentAlias"),), + "UNSUPPORTED", + ), + SessionStep( + "post-refusal getMany", + "get_many", + ( + intents[0].lookup, + ( + NodeKey( + ElementRef( + intents[0].lookup.module, intents[0].lookup.id + ), + "primary", + ({"string": "n-1"},), + ), + ), + (), + ), + "UNSUPPORTED", + ), + ), + "UNSUPPORTED", + 0, + 0, + 1, + ) + budget = budget_intents(intents) + return ( + budget, + ( + SessionStep("first page", "planned_connection", (budget[0],)), + SessionStep( + "aggregate overrun", + "planned_connection", + (budget[1],), + "LIMIT_EXCEEDED", + ), + SessionStep( + "third dispatch refused", + "planned_connection", + (budget[2],), + "LIMIT_EXCEEDED", + ), + ), + "LIMIT_EXCEEDED", + 2, + 0, + 3, + ) diff --git a/tests/runtime/api4_profile7_fixture.py b/tests/runtime/api4_profile7_fixture.py new file mode 100644 index 0000000..89d09ff --- /dev/null +++ b/tests/runtime/api4_profile7_fixture.py @@ -0,0 +1,78 @@ +"""Pure value loaders for genuine prepared API4 and generated profile7 data.""" + +import hashlib +import json +from pathlib import Path + +from batten.contracts import ArtifactRef +from batten.lintel import ExposureConfig, ExposureRecordRoot +from lintel.projection import AdmittedPreparedApi, TrustedPreparedRef, load_prepared_api +from read_artifacts import read_executor +from umf_access_generated_executor import GeneratedExecutor + + +def prepared_api4_inputs() -> tuple[bytes, TrustedPreparedRef]: + folder = Path(__file__).parent / "fixtures/generated-page7-rich" + artifact = (folder / "prepared-api-v4-rich-proof.json").read_bytes() + trust = json.loads((folder / "prepared-api-v4-rich-trust.json").read_bytes()) + return artifact, TrustedPreparedRef( + trust["artifactSha256"], + trust["artifactDigest"], + trust["application"], + trust["apiDigest"], + trust["exposureSha256"], + tuple((item["identity"], item["sha256"]) for item in trust["sources"]), + tuple(map(tuple, trust["capabilities"])), + trust["bindingProfile"], + trust["scalarCodecProfile"], + tuple(map(tuple, trust["limits"])), + trust["generatedRootsSha256"], + trust["generatedConnectionsSha256"], + ) + + +def prepared_api4_exposure( + prepared: AdmittedPreparedApi, executor: GeneratedExecutor +) -> ExposureConfig: + trust = executor.trusted_artifact + algebra_sha256 = hashlib.sha256(executor.read_algebra_json).hexdigest() + host_ids = {"Note": "records.note", "Task": "records.task"} + roots = tuple( + ExposureRecordRoot( + record.lookup, + host_ids[record.type_name], + executor.native_table.source_digest, + trust.artifact_digest, + trust.receipt_digest, + executor.target.binding_digest, + algebra_sha256, + record.key_id, + tuple(field.source for field in record.fields), + ("string",), + tuple( + ( + field.source, + "decimalToken" if field.scalar == "decimal" else field.scalar, + ) + for field in record.fields + ), + ) + for record in prepared.records + ) + return ExposureConfig( + ArtifactRef(prepared.application, prepared.artifact_digest), + prepared.api_digest, + executor.native_table.source_digest, + (), + dict(prepared.capabilities), + roots, + ) + + +def api4_constructor_case() -> tuple[ + AdmittedPreparedApi, GeneratedExecutor, ExposureConfig +]: + executor, _root = read_executor("v7-rich") + prepared = load_prepared_api(*prepared_api4_inputs()) + config = prepared_api4_exposure(prepared, executor) + return prepared, executor, config diff --git a/tests/runtime/artifacts.py b/tests/runtime/artifacts.py new file mode 100644 index 0000000..c085e88 --- /dev/null +++ b/tests/runtime/artifacts.py @@ -0,0 +1,146 @@ +"""Fabricated externally pinned artifact for public adapter boundary scenarios.""" + +import hashlib +import json + +from umf_access_generated_executor import ( + AdmittedNativeTable, + GeneratedFiles, + GeneratedManifest, + TargetBinding, + TrustedArtifactRef, + prepare_generated, +) + + +def canonical(value: object) -> bytes: + return json.dumps( + value, sort_keys=True, separators=(",", ":"), ensure_ascii=False + ).encode() + + +def digest(value: object) -> str: + return hashlib.sha256(canonical(value)).hexdigest() + + +def native_fixture() -> AdmittedNativeTable: + """No executable program: this scenario tests host/port wiring, never SQL.""" + configuration: dict[str, object] = { + "schema": "fabricated", + "module": "fabricated", + "ownerRole": "fixture_owner", + "personRole": "fixture_person", + "batchRole": "fixture_batch", + "groupRoles": {}, + } + native: dict[str, object] = { + "version": "umf.native-table-source/1", + "bundleDigest": "c" * 64, + "sourceDigest": "b" * 64, + "configurationDigest": digest(configuration), + "configuration": configuration, + "expectedCatalog": {"tables": [], "checks": []}, + "operations": [{"id": "inspect", "kind": "query"}], + } + program: dict[str, object] = { + "status": "compiled", + "version": "weft.table-operation/0.1", + "module": "fabricated", + "operation": "inspect", + "binding": {"modelSha256": "b" * 64}, + "modelSha256": "b" * 64, + "transport": {}, + "dbapiSql": "SELECT 1", + "nativeDescriptionSql": "SELECT 1", + "dbapiParameterOrder": [], + "parameterSources": [], + "outputs": [], + "result": {"kind": "many"}, + "obligations": {}, + } + exported: dict[str, object] = { + "version": "weft.generated-query-program/1", + "readiness": "export-only", + "programDigest": digest(program), + "program": program, + "source": { + "modelSha256": "b" * 64, + "module": "fabricated", + "operation": "inspect", + }, + "target": {"id": "postgresql18", "modelSha256": "b" * 64}, + "parameterOrder": [], + "parameters": [], + "parameterSources": [], + "outputs": [], + "obligations": {}, + "template": {}, + } + files = GeneratedFiles.from_mapping({ + "native/native-table-source.json": canonical(native), + "programs/inspect.json": canonical(exported), + }) + target = TargetBinding("postgresql18", "pg18/1", "18", "d" * 64) + payload = { + "version": "weft.generated-execution/1", + "artifactId": "fabricated-app", + "source": { + "documentId": "fabricated", + "coreVersion": "0.10.0", + "sha256": "b" * 64, + "moduleIds": ["fabricated"], + "bundleInputDigest": "e" * 64, + }, + "generator": { + "umfDistribution": "umf-core", + "umfVersion": "0.10.0", + "umfSourceDigest": "1" * 64, + "weftDistribution": "weft-sql", + "weftVersion": "0.4.54", + "weftSourceDigest": "2" * 64, + "abi": "weft.generated-execution/1", + }, + "executor": { + "abiMajor": 1, + "minMinor": 0, + "maxMinor": 0, + "packageId": "umf-access-generated-executor", + }, + "target": { + "id": target.id, + "profile": target.profile, + "version": target.version, + "bindingDigest": target.binding_digest, + }, + "algebra": {}, + "programs": { + "inspect": {"kind": "query", "programPath": "programs/inspect.json"} + }, + "inventory": dict(files.inventory), + } + payload_digest = digest(payload) + manifest = { + **payload, + "provenance": { + "receiptDigest": "3" * 64, + "issuer": "fabricated-build", + "buildId": "fixture", + }, + } + artifact_digest = digest(manifest) + manifest["artifactDigest"] = artifact_digest + trusted = TrustedArtifactRef( + "fabricated-app", + artifact_digest, + "3" * 64, + payload_digest, + "b" * 64, + target.binding_digest, + files.inventory, + "fabricated-build", + "fixture", + ) + executor = prepare_generated( + GeneratedManifest.from_json(canonical(manifest)), files, trusted, target + ) + return executor.native_table diff --git a/tests/runtime/fixtures/generated-page7-combined/PROVENANCE.md b/tests/runtime/fixtures/generated-page7-combined/PROVENANCE.md new file mode 100644 index 0000000..2dcb9aa --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-combined/PROVENANCE.md @@ -0,0 +1,27 @@ +# Combined generated-read `/7` fixture + +This fixture is an exact copy of the task-local issued artifact at +`umf/python/umf_access_generated_executor/tests/fixtures/generated-page7-combined`. +The artifact was produced through UMF codegen 0.1.0a8, UMF build 0.1.0.dev27, +and Weft SQL 0.4.66.dev1, then prepared through the public executor API. Its +receipt is task-local; it is source-admission and routing test data, not evidence +of live native PostgreSQL authority or deployment. + +The artifact contains one `demo/Note` root. Its generated algebra marks both +ordinary Page and forward connection eligibility. The Batten base-route test +uses the genuine verified executor projection and a protocol-native binding +double; it deliberately configures no Page or connection Host routes and checks +that base read and Record capabilities prepare without advertising either +extension. + +Pinned fixture identities: + +- source digest: `0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f` +- artifact digest: `bd6a87dd7dcff4c35467f402ae5d4a79c736b64a642a7b3060798050895e259f` +- receipt digest: `55fb4d4d5bf10ea173ed21b5e094578c425183b18d518c697f734ad3ba679d3e` +- algebra SHA-256: `9250d00b34aebc24ed2e2151c2c2279cc423639cc80a8594c797ac3ec0043c3b` + +The copied `target.json`, `trusted-artifact.json`, `build-report.json`, manifest, +algebra, and native source bytes are retained unchanged. Their source SHA-256 +values are recorded by the upstream fixture build report and can be checked +against this directory. diff --git a/tests/runtime/fixtures/generated-page7-combined/artifact/algebra/read.json b/tests/runtime/fixtures/generated-page7-combined/artifact/algebra/read.json new file mode 100644 index 0000000..e9e7878 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-combined/artifact/algebra/read.json @@ -0,0 +1 @@ +{"executorAbi":{"major":1,"minor":7},"readiness":"weft.generated-read-executable/7","roots":{"demo/Note":{"defaultSelection":["demo/id","demo/owner"],"fields":{"demo/id":{"frameSelectSql":"f.\"__weft_field_0\"","output":{"carrier":"string","name":"__weft_field_0","nullable":false},"selectSql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_field_0\"","sourceField":{"element":"id","module":"demo"}},"demo/owner":{"frameSelectSql":"f.\"__weft_field_1\"","output":{"carrier":"string","name":"__weft_field_1","nullable":false},"selectSql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" AS \"__weft_field_1\"","sourceField":{"element":"owner","module":"demo"}}},"forwardConnection":{"fieldOutputs":[{"fieldId":"demo/id","output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25}},{"fieldId":"demo/owner","output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25}}],"forward":{"dbapiParameterOrder":["after","after","limit"],"filterParameterGroup":"filterValues","keyOutput":{"carrier":"string","name":"__weft_connection_key","nativeType":{"kind":"text"},"nullable":false,"oid":25},"parameterOrder":["filterValues","after","after","limit"],"sourceSqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_connection_key\"{{SELECT_COLUMNS}} FROM \"plugin_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > $2::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT $3::pg_catalog.int8), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","sourceTemplateSha256":"87cef0d3137dc7569c0cc75afc9ef1b36fd5c3858cb7fae50a992ddd8cbb9700","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_connection_key\"{{SELECT_COLUMNS}} FROM \"plugin_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT %s::pg_catalog.int8), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"6eb2e8f20ac1eee1d89ff51e445ee6f09e4063627ed881b8cc3583f7292cd18a"},"key":{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"collation":"pg_catalog.\"C\"","direction":"asc","fieldId":"demo/id","nulls":"last","output":{"carrier":"string","name":"__weft_connection_key","nativeType":{"kind":"text"},"nullable":false,"oid":25}},"keyId":"primary","lookaheadRows":1,"maxFirst":100,"nativeCollation":"pg_catalog.\"C\"","nativeCollationPrecondition":"umf.generated-table-collation-c/1","previous":{"dbapiParameterOrder":["after","after"],"filterParameterGroup":"filterValues","output":{"carrier":"boolean","name":"__weft_previous","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"parameterOrder":["filterValues","after","after"],"sourceSqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \"__weft_ordinal\", EXISTS (SELECT 1 FROM \"plugin_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NOT NULL AND \"r\".\"id\" COLLATE pg_catalog.\"C\" <= $2::pg_catalog.text COLLATE pg_catalog.\"C\") LIMIT 1) AS \"__weft_previous\"), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.\"__weft_previous\" FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","sourceTemplateSha256":"900f7252adbefda901907d4487ad461dc58e6128b8810a4c4170cd37ebe3ce53","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \"__weft_ordinal\", EXISTS (SELECT 1 FROM \"plugin_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NOT NULL AND \"r\".\"id\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text COLLATE pg_catalog.\"C\") LIMIT 1) AS \"__weft_previous\"), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.\"__weft_previous\" FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"5e461f59b191d1ced46c4f99b719b6c242422418d54652cb6961ff1d812a3e07"},"profile":"weft.generated-forward-connection/1","zeroFirstProbeRows":1},"forwardConnectionSupport":{"profile":"weft.generated-forward-connection/1","status":"eligible"},"frameOrdinalSql":"ROW_NUMBER() OVER (ORDER BY {{ORDER_SQL}}) AS \"__weft_ordinal\"","frameScalarOrdinalSql":"1::pg_catalog.int8 AS \"__weft_ordinal\"","fromSql":"FROM \"plugin_demo\".\"notes\" AS \"r\"","getMany":{"keyFields":[{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id"}],"keyId":"primary","keyTupleSql":"(%s::pg_catalog.int8, %s::pg_catalog.text)","maxKeys":100,"ordinalOutput":{"carrier":"integer","name":"__weft_ordinal","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"presentOutput":{"carrier":"boolean","name":"__weft_present","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"profile":"weft.generated-key-batch/1","sourceSqlTemplate":"WITH \"__weft_key_rows\" (\"__weft_ordinal\", \"__weft_key_0\") AS (VALUES {{KEY_ROWS}}) SELECT k.\"__weft_ordinal\" AS \"__weft_ordinal\", (\"r\".\"id\" IS NOT NULL) AS \"__weft_present\"{{SELECT_COLUMNS}} FROM \"__weft_key_rows\" AS k LEFT JOIN \"plugin_demo\".\"notes\" AS \"r\" ON \"r\".\"id\" COLLATE pg_catalog.\"C\" = k.\"__weft_key_0\" COLLATE pg_catalog.\"C\" ORDER BY k.\"__weft_ordinal\"","sourceTemplateSha256":"84f51c50843bbc931cb277e1a9ce523a7f66d45078f778534fbe60ee1f6b67e6"},"keyTieOrder":["o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1"],"maxRows":1000,"module":"demo","nativeReadGuard":{"byteMetric":"pg18-row-json-utf8/1","maxNativeBytes":8388608,"partialFrames":false,"profile":"pg18-composed-native-frame/1","sqlstate":"22012","template":{"sha256":"8e77d3b07a72ced53b0a9155201072669b88971129569c0a5c7228f8319bab9a","sql":"WITH \"__weft_source\" AS MATERIALIZED ({{SOURCE_SQL}}), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT {{RETURN_COLUMNS}} FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","version":"weft.pg18-composed-frame-template/1"}},"obligations":{"baseTablesOnly":true,"noBypassRls":true,"principal":"caller-connection-role","rls":"native-caller-role","rowCap":1000,"schema":"plugin_demo","searchPath":["pg_catalog"],"tableLifecycle":{"configurationDigest":"8f4193509162607f8a69627f6f86038ad22806b7d8e76f9db98287b409225496","cursorScope":["module","sourceDigest","configurationDigest","deploymentDigest","ledgerHeadDigest","principal","roleScopeDigest"],"deploymentDigest":"4788ddf2c6b796a5e6fc375a173aff1ad84c2e5f01af3ba1451668f14b3f61fe","generationLock":"shared-before-admission-through-transaction","installedAuthority":"approved-forward-ledger-and-source-derived-native-witness","module":"demo","nativeExecutionQualified":false,"policy":"source-command-policy-and-native-forced-rls","principal":"verified-person-or-batch","privileges":"source-grants-and-native-effective-closure","roleScope":"native-transitive-current","sourceDigest":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f","sourceInterpretation":"original-umf-deployment-compiler","tables":[{"command":"select","id":"notes","native":"notes","policySourcePath":"/modules/0/extensions/umf.tables/tables/0/policy","record":{"element":"Note","module":"demo"}}],"version":"umf.table-lifecycle/0.1"},"timeout":"per-call","transaction":"read-only"},"orders":{"o_0b8d9a7134c985cecf97062bb7bc25d2100f0200012300c3f7e2d5bc3fc22b29":{"direction":"asc","fieldId":"demo/owner","nulls":"last","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"},"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1":{"direction":"asc","fieldId":"demo/id","nulls":"last","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"},"o_7f089caf246c21027d14b1336adf78a49fbd458b954cd8993c53259a7ceb5cac":{"direction":"desc","fieldId":"demo/owner","nulls":"last","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"},"o_bf4f32c943a3f3a0bdd9b050f5bba7dbb9d0ca1320334e64fccad3a1a11290a5":{"direction":"desc","fieldId":"demo/id","nulls":"last","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"}},"ordinaryPage":{"continuation":{"exactFullPageYieldsContinuation":true,"fixed":{"bindingDigest":"3dc296a0e8c4b4243d4427dc8971a89fc3c3895fe11a10ab128ae5a269b9f740","issuedPageTemplateSha256":"3ef5a4821c610b206de2f31e2489e534a12b8ce910c1cf1643ca6625e74a9b37","issuedProgramDigest":"c2e025feb7b328786b91fa9d784c72d8f672b642b3c2b1c59313fb1e156aa389","keyFieldId":"demo/id","keyId":"primary","module":"demo","record":"Note","sourceModelSha256":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f","targetId":"postgresql18","targetModelSha256":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f"},"ownerCursor":null,"profile":"weft.generated-ordinary-page-continuation-identity/1","requestInputs":{"filterProgram":{"emptyExpression":null,"emptySql":"TRUE","identity":"canonical-exact-tree","operators":["predicate","and","or","not"],"predicateIdSet":"predicateIds.allowed","profile":"weft.generated-page-filter-program/1","valueOrder":"depth-first-left-to-right"},"normalizedPredicateValues":{"exactCodecNormalization":true,"identity":true,"occurrenceOrder":"depth-first-left-to-right-arity-one-predicate-leaves"},"predicateIds":{"allowed":["p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263","p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60","p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470","p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3","p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a","p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33","p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864","p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9","p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8","p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76","p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5","p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559","p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8","p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060","p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9","p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44"],"identity":true,"ordered":true},"predicateInputs":[{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44","operator":"gt"}],"selectedFieldIds":{"allowed":["demo/id","demo/owner"],"identity":true,"ordered":true},"size":{"exactInteger":true,"identity":true,"maximum":1000,"minimum":1}},"snapshotVersions":[]},"key":{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"collation":"pg_catalog.\"C\"","direction":"asc","fieldId":"demo/id","id":"primary","nulls":"last","output":{"carrier":"string","name":"__weft_page_key","nativeType":{"kind":"text"},"nullable":false,"oid":25}},"maxSize":1000,"nativeCollationPrecondition":{"dbapiParameterOrder":["schema","table","column"],"expected":{"deterministic":true,"name":"C","schema":"pg_catalog"},"parameterOrder":["schema","table","column"],"parameterSources":["binding.schema","binding.table.native","binding.keyColumn.native"],"profile":"weft.generated-table-collation-c/1","required":true,"sourceSqlTemplate":"SELECT cn.nspname, co.collname, co.collisdeterministic FROM pg_catalog.pg_attribute AS a JOIN pg_catalog.pg_class AS c ON c.oid = a.attrelid JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace JOIN pg_catalog.pg_collation AS co ON co.oid = a.attcollation JOIN pg_catalog.pg_namespace AS cn ON cn.oid = co.collnamespace WHERE n.nspname = $1::pg_catalog.text AND c.relname = $2::pg_catalog.text AND a.attname = $3::pg_catalog.text AND a.attnum > 0 AND NOT a.attisdropped","sqlTemplate":"SELECT cn.nspname, co.collname, co.collisdeterministic FROM pg_catalog.pg_attribute AS a JOIN pg_catalog.pg_class AS c ON c.oid = a.attrelid JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace JOIN pg_catalog.pg_collation AS co ON co.oid = a.attcollation JOIN pg_catalog.pg_namespace AS cn ON cn.oid = co.collnamespace WHERE n.nspname = %s::pg_catalog.text AND c.relname = %s::pg_catalog.text AND a.attname = %s::pg_catalog.text AND a.attnum > 0 AND NOT a.attisdropped"},"page":{"dbapiParameterOrder":["after","after","size"],"fieldOutputs":[{"fieldId":"demo/id","nativeColumn":"id","output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"id","module":"demo"}},{"fieldId":"demo/owner","nativeColumn":"owner","output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"owner","module":"demo"}}],"filterParameterGroup":"filterValues","hiddenKeyOutput":{"carrier":"string","name":"__weft_page_key","nativeType":{"kind":"text"},"nullable":false,"oid":25},"lookaheadRows":1,"ordinalOutput":{"carrier":"integer","name":"__weft_ordinal","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"parameterOrder":["filterValues","after","after","size"],"projectionSlot":{"emptyValue":"","name":"PUBLIC_PROJECTION","nonemptyPrefix":", "},"serverByteGuard":true,"sourceSqlTemplate":"SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_page_key\"{{PUBLIC_PROJECTION}} FROM \"plugin_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > $2::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT ($3::pg_catalog.int8 + 1)","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_page_key\"{{PUBLIC_PROJECTION}} FROM \"plugin_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT (%s::pg_catalog.int8 + 1)), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"3ef5a4821c610b206de2f31e2489e534a12b8ce910c1cf1643ca6625e74a9b37"},"profile":"weft.generated-ordinary-page/1","size":{"carrier":"int64","identity":true,"maximum":1000,"minimum":1,"slot":"size"},"snapshot":{"supported":false,"trueOutcome":"UNSUPPORTED"},"status":"eligible"},"predicates":{"p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263":{"arity":0,"fieldId":"demo/id","operator":"is-null","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" IS NULL"},"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"le","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"eq","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3":{"arity":0,"fieldId":"demo/owner","operator":"is-not-null","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"gt","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"},"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"eq","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"le","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"lt","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"},"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"ge","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76":{"arity":0,"fieldId":"demo/owner","operator":"is-null","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" IS NULL"},"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"ne","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"},"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"ne","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"},"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"ge","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060":{"arity":0,"fieldId":"demo/id","operator":"is-not-null","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"lt","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"},"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"gt","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"}},"primaryKey":[{"fieldId":"demo/id","predicateId":"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33"}],"primaryKeyId":"primary","record":"Note","terminals":{"count":{"cardinality":"one-integer","frameSelectSql":"f.\"__weft_count\"","output":{"carrier":"integer","name":"__weft_count","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"selectSql":"pg_catalog.count(*) AS \"__weft_count\""},"exists":{"cardinality":"row-presence","frameSelectSql":"f.\"__weft_exists\"","limit":1,"output":{"carrier":"boolean","name":"__weft_exists","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"selectSql":"true AS \"__weft_exists\""},"first":{"cardinality":"zero-or-one","limit":1},"get":{"cardinality":"exactly-one","limit":2},"one":{"cardinality":"exactly-one","limit":2}}}},"source":{"modelSha256":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f","module":"demo"},"target":{"bindingDigest":"3dc296a0e8c4b4243d4427dc8971a89fc3c3895fe11a10ab128ae5a269b9f740","id":"postgresql18","modelSha256":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f"},"version":"weft.generated-read-algebra/7"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-combined/artifact/manifest.json b/tests/runtime/fixtures/generated-page7-combined/artifact/manifest.json new file mode 100644 index 0000000..725cea2 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-combined/artifact/manifest.json @@ -0,0 +1 @@ +{"algebra":{"algebraPath":"algebra/read.json","profile":"weft.generated-read-algebra/7"},"artifactDigest":"bd6a87dd7dcff4c35467f402ae5d4a79c736b64a642a7b3060798050895e259f","artifactId":"page7-build27-4788ddf2c6b796a5","executor":{"abiMajor":1,"maxMinor":7,"minMinor":7,"packageId":"umf-access-generated-executor"},"generator":{"abi":"weft.generated-execution/1","umfDistribution":"umf-codegen","umfSourceDigest":"1ee3ccce0c86aa53c15181ea31ecf9c495be8a0374c7ea22d9bdd7b5fa1124b3","umfVersion":"0.1.0a8","weftDistribution":"weft-sql","weftSourceDigest":"cd0fa27c9580742333d14e24d5ebfd74babb47d31720bb4c577278d05486f11d","weftVersion":"0.4.66.dev1"},"inventory":{"algebra/read.json":"9250d00b34aebc24ed2e2151c2c2279cc423639cc80a8594c797ac3ec0043c3b","native/native-table-source.json":"964c992d63f4e2153990824b74bc8707ae62b86eb1cd418ae2729ac8527df8bb"},"programs":{},"provenance":{"buildId":"page7-4788ddf2c6b796a5","issuer":"task-local-page7-fixture","receiptDigest":"55fb4d4d5bf10ea173ed21b5e094578c425183b18d518c697f734ad3ba679d3e"},"source":{"bundleInputDigest":"c2ece33667ff09cfc8c31dfc758beebdd06d6a42ed9d16462f2f7ff8a584a845","coreVersion":"0.10.0","documentId":"synthetic-table-lifecycle","moduleIds":["demo"],"sha256":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f"},"target":{"bindingDigest":"3dc296a0e8c4b4243d4427dc8971a89fc3c3895fe11a10ab128ae5a269b9f740","id":"postgresql18","profile":"pg18/1","version":"18"},"version":"weft.generated-execution/1"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-combined/artifact/native/native-table-source.json b/tests/runtime/fixtures/generated-page7-combined/artifact/native/native-table-source.json new file mode 100644 index 0000000..de89af1 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-combined/artifact/native/native-table-source.json @@ -0,0 +1 @@ +{"bundleDigest":"4788ddf2c6b796a5e6fc375a173aff1ad84c2e5f01af3ba1451668f14b3f61fe","configuration":{"batchRole":"page7_batch","groupRoles":{},"module":"demo","ownerRole":"page7_owner","personRole":"page7_person","schema":"plugin_demo"},"configurationDigest":"8f4193509162607f8a69627f6f86038ad22806b7d8e76f9db98287b409225496","expectedCatalog":{"checks":[],"tables":[{"columns":[{"field":{"element":"id","module":"demo"},"name":"id","nativeType":{"kind":"text"}},{"field":{"element":"owner","module":"demo"},"name":"owner","nativeType":{"kind":"text"}}],"id":"notes","name":"notes","record":{"element":"Note","module":"demo"}}]},"operations":[{"id":"read_many","kind":"read"},{"id":"read_one","kind":"read"},{"id":"read_optional","kind":"read"},{"id":"read_page","kind":"read"},{"id":"read_count","kind":"read"},{"id":"create","kind":"insert"},{"id":"rename","kind":"update"},{"id":"remove","kind":"delete"},{"id":"put_ignore","kind":"upsert"},{"id":"put_update","kind":"upsert"},{"id":"create_batch","kind":"insert"}],"sourceDigest":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f","version":"umf.native-table-source/2"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-combined/build-report.json b/tests/runtime/fixtures/generated-page7-combined/build-report.json new file mode 100644 index 0000000..cec1684 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-combined/build-report.json @@ -0,0 +1,28 @@ +{ + "status": "pass", + "scope": "UMF source deployment verification + genuine Weft66 /7 issuance; task-local receipt only; no native authority", + "python": "3.11.17 (main, Oct 3 2026, 00:54:14) [Clang 22.1.3 ]", + "codegenVersion": "0.1.0a8", + "codegenModule": "/private/tmp/umf-build-v6-dev-20261105/lib/python3.11/site-packages/umf_codegen/__init__.py", + "weftVersion": "0.4.66.dev1", + "weftModule": "/private/tmp/umf-page7-weft66-review-import-20261105/weft/__init__.py", + "weftWheelSha256": "1214a26beb73b351dcf7c684baf0465562e512798afe5138dce39d5ac1588660", + "inputRequestSha256": "9a785d95a9243c69a3fe85e4fcf974862fb33976c06cd22bd1b8716235c241da", + "sourceDigest": "0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f", + "bundleDigest": "4788ddf2c6b796a5e6fc375a173aff1ad84c2e5f01af3ba1451668f14b3f61fe", + "configurationDigest": "8f4193509162607f8a69627f6f86038ad22806b7d8e76f9db98287b409225496", + "targetBindingDigest": "3dc296a0e8c4b4243d4427dc8971a89fc3c3895fe11a10ab128ae5a269b9f740", + "artifactDigest": "bd6a87dd7dcff4c35467f402ae5d4a79c736b64a642a7b3060798050895e259f", + "receiptDigest": "55fb4d4d5bf10ea173ed21b5e094578c425183b18d518c697f734ad3ba679d3e", + "payloadDigest": "16830430280c929dff84b954e0307d9aed215fedaa2498efe6f3fb5d9f1f5490", + "algebraDigest": "9250d00b34aebc24ed2e2151c2c2279cc423639cc80a8594c797ac3ec0043c3b", + "algebraRootIds": [ + "demo/Note" + ], + "rootCapabilities": { + "demo/Note": { + "page": "eligible", + "forward": "eligible" + } + } +} diff --git a/tests/runtime/fixtures/generated-page7-combined/target.json b/tests/runtime/fixtures/generated-page7-combined/target.json new file mode 100644 index 0000000..271704f --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-combined/target.json @@ -0,0 +1 @@ +{"bindingDigest":"3dc296a0e8c4b4243d4427dc8971a89fc3c3895fe11a10ab128ae5a269b9f740","id":"postgresql18","profile":"pg18/1","version":"18"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-combined/trusted-artifact.json b/tests/runtime/fixtures/generated-page7-combined/trusted-artifact.json new file mode 100644 index 0000000..69b1ec7 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-combined/trusted-artifact.json @@ -0,0 +1 @@ +{"artifactDigest":"bd6a87dd7dcff4c35467f402ae5d4a79c736b64a642a7b3060798050895e259f","artifactId":"page7-build27-4788ddf2c6b796a5","buildId":"page7-4788ddf2c6b796a5","inventory":[["algebra/read.json","9250d00b34aebc24ed2e2151c2c2279cc423639cc80a8594c797ac3ec0043c3b"],["native/native-table-source.json","964c992d63f4e2153990824b74bc8707ae62b86eb1cd418ae2729ac8527df8bb"]],"issuer":"task-local-page7-fixture","payloadDigest":"16830430280c929dff84b954e0307d9aed215fedaa2498efe6f3fb5d9f1f5490","receiptDigest":"55fb4d4d5bf10ea173ed21b5e094578c425183b18d518c697f734ad3ba679d3e","sourceDigest":"0a508516d89051e3d34d0203db278c6ad1f5a5b7651a04ffc8cfeaa76aed686f","targetBindingDigest":"3dc296a0e8c4b4243d4427dc8971a89fc3c3895fe11a10ab128ae5a269b9f740"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-rich/PROVENANCE.md b/tests/runtime/fixtures/generated-page7-rich/PROVENANCE.md new file mode 100644 index 0000000..da787cf --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/PROVENANCE.md @@ -0,0 +1,9 @@ +# Rich combined generated `/7` constructor fixture + +This directory contains fabricated immutable artifact data copied without modification from the reviewed task-local issuer outputs. It is source/admission and constructor-join test data; it does not contain UMF, Weft, Lintel, or Batten engine code and it is not evidence of native PostgreSQL execution. + +The UMF artifact data comes from `/private/tmp/batten-profile7-native-20261105/umf-rich-source-final/`. It was produced through the public UMF codegen 0.1.0a8, build 0.1.0.dev27, and Weft SQL 0.4.66.dev1 pipeline. Pinned UMF values: source `76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7`, artifact `ac137c89d2b30ba26a09e183140bba01f7301499efa0fb11926c47e220ec53cb`, receipt `327afbccd4287fa5ce52c2090833e42d29ffcb9f6543b949a2b18b789142bb2e`, binding `4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4`, read algebra `7248713150673a9707d646daa4b0b8b248d119769619646cc00163a017d6f935`. + +The prepared API proof and trust pin are copied from Lintel's `prepared-api-v4-rich-weft7-proof.json` and `prepared-api-v4-rich-weft7-trust.json`, issued/admitted through Lintel build 0.1.0a4 and runtime 0.1.0a5. API digest `86281b7304b6bdbd64c15a858d72187bc2615696a4bbc50934294975761de59b`; proof SHA-256 `f13945c7e8fcb1b981a8c3d3a2977c3f85589825373e3992d8481ec371f5d084`; trust SHA-256 `be7e3fdd4d6b5070f0c0f9f644314b447bdb65fca8e5fb21a420a318b3aa9e42`. + +The API contains Note and Task Record roots, each eligible for ordinary Page and Relay connections under prepared-api/4 and read profile `/7`. Batten assigns opaque test Host IDs `records.note` and `records.task` in the visible test composition; those identifiers are not asserted as a universal naming rule. diff --git a/tests/runtime/fixtures/generated-page7-rich/artifact/algebra/read.json b/tests/runtime/fixtures/generated-page7-rich/artifact/algebra/read.json new file mode 100644 index 0000000..55039dd --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/artifact/algebra/read.json @@ -0,0 +1 @@ +{"executorAbi":{"major":1,"minor":7},"readiness":"weft.generated-read-executable/7","roots":{"demo/Note":{"defaultSelection":["demo/id","demo/owner","demo/enabled","demo/amount","demo/payload"],"fields":{"demo/amount":{"frameSelectSql":"f.\"__weft_field_3\"","output":{"carrier":"decimal","name":"__weft_field_3","nullable":false},"selectSql":"\"r\".\"amount\" AS \"__weft_field_3\"","sourceField":{"element":"amount","module":"demo"}},"demo/enabled":{"frameSelectSql":"f.\"__weft_field_2\"","output":{"carrier":"boolean","name":"__weft_field_2","nullable":false},"selectSql":"\"r\".\"enabled\" AS \"__weft_field_2\"","sourceField":{"element":"enabled","module":"demo"}},"demo/id":{"frameSelectSql":"f.\"__weft_field_0\"","output":{"carrier":"string","name":"__weft_field_0","nullable":false},"selectSql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_field_0\"","sourceField":{"element":"id","module":"demo"}},"demo/owner":{"frameSelectSql":"f.\"__weft_field_1\"","output":{"carrier":"string","name":"__weft_field_1","nullable":false},"selectSql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" AS \"__weft_field_1\"","sourceField":{"element":"owner","module":"demo"}},"demo/payload":{"frameSelectSql":"f.\"__weft_field_4\"","output":{"carrier":"string","name":"__weft_field_4","nullable":false},"selectSql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" AS \"__weft_field_4\"","sourceField":{"element":"payload","module":"demo"}}},"forwardConnection":{"fieldOutputs":[{"fieldId":"demo/amount","output":{"carrier":"decimal","name":"__weft_field_3","nativeType":{"kind":"numeric","precision":8,"scale":2},"nullable":false,"oid":1700}},{"fieldId":"demo/enabled","output":{"carrier":"boolean","name":"__weft_field_2","nativeType":{"kind":"boolean"},"nullable":false,"oid":16}},{"fieldId":"demo/id","output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25}},{"fieldId":"demo/owner","output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25}},{"fieldId":"demo/payload","output":{"carrier":"string","name":"__weft_field_4","nativeType":{"kind":"text"},"nullable":false,"oid":25}}],"forward":{"dbapiParameterOrder":["after","after","limit"],"filterParameterGroup":"filterValues","keyOutput":{"carrier":"string","name":"__weft_connection_key","nativeType":{"kind":"text"},"nullable":false,"oid":25},"parameterOrder":["filterValues","after","after","limit"],"sourceSqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_connection_key\"{{SELECT_COLUMNS}} FROM \"batten7_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > $2::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT $3::pg_catalog.int8), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","sourceTemplateSha256":"ecf7010dde6ea36d2651810b53a28e72ea4298cd0eb8d948cbdbd2bd62e886d2","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_connection_key\"{{SELECT_COLUMNS}} FROM \"batten7_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT %s::pg_catalog.int8), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"55f50eda33138139d097cefe42a4c08eeb1187d2505dfee10b9dd381fc824392"},"key":{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"collation":"pg_catalog.\"C\"","direction":"asc","fieldId":"demo/id","nulls":"last","output":{"carrier":"string","name":"__weft_connection_key","nativeType":{"kind":"text"},"nullable":false,"oid":25}},"keyId":"primary","lookaheadRows":1,"maxFirst":100,"nativeCollation":"pg_catalog.\"C\"","nativeCollationPrecondition":"umf.generated-table-collation-c/1","previous":{"dbapiParameterOrder":["after","after"],"filterParameterGroup":"filterValues","output":{"carrier":"boolean","name":"__weft_previous","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"parameterOrder":["filterValues","after","after"],"sourceSqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \"__weft_ordinal\", EXISTS (SELECT 1 FROM \"batten7_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NOT NULL AND \"r\".\"id\" COLLATE pg_catalog.\"C\" <= $2::pg_catalog.text COLLATE pg_catalog.\"C\") LIMIT 1) AS \"__weft_previous\"), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.\"__weft_previous\" FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","sourceTemplateSha256":"fcf3f6abeb887dba8eeda9ddb3f7c5bc5afc6a9fe7217a8d90c8e92692a811da","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \"__weft_ordinal\", EXISTS (SELECT 1 FROM \"batten7_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NOT NULL AND \"r\".\"id\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text COLLATE pg_catalog.\"C\") LIMIT 1) AS \"__weft_previous\"), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.\"__weft_previous\" FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"bba99f7d74bd3cdd3e6af866a70a9b720d5c20f61b22496cb7c20e9e716b484d"},"profile":"weft.generated-forward-connection/1","zeroFirstProbeRows":1},"forwardConnectionSupport":{"profile":"weft.generated-forward-connection/1","status":"eligible"},"frameOrdinalSql":"ROW_NUMBER() OVER (ORDER BY {{ORDER_SQL}}) AS \"__weft_ordinal\"","frameScalarOrdinalSql":"1::pg_catalog.int8 AS \"__weft_ordinal\"","fromSql":"FROM \"batten7_demo\".\"notes\" AS \"r\"","getMany":{"keyFields":[{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id"}],"keyId":"primary","keyTupleSql":"(%s::pg_catalog.int8, %s::pg_catalog.text)","maxKeys":100,"ordinalOutput":{"carrier":"integer","name":"__weft_ordinal","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"presentOutput":{"carrier":"boolean","name":"__weft_present","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"profile":"weft.generated-key-batch/1","sourceSqlTemplate":"WITH \"__weft_key_rows\" (\"__weft_ordinal\", \"__weft_key_0\") AS (VALUES {{KEY_ROWS}}) SELECT k.\"__weft_ordinal\" AS \"__weft_ordinal\", (\"r\".\"id\" IS NOT NULL) AS \"__weft_present\"{{SELECT_COLUMNS}} FROM \"__weft_key_rows\" AS k LEFT JOIN \"batten7_demo\".\"notes\" AS \"r\" ON \"r\".\"id\" COLLATE pg_catalog.\"C\" = k.\"__weft_key_0\" COLLATE pg_catalog.\"C\" ORDER BY k.\"__weft_ordinal\"","sourceTemplateSha256":"b583583600d89eb0ef65ca2eac5112bc2794ed98354781f48925983d37e46299"},"keyTieOrder":["o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1"],"maxRows":1000,"module":"demo","nativeReadGuard":{"byteMetric":"pg18-row-json-utf8/1","maxNativeBytes":8388608,"partialFrames":false,"profile":"pg18-composed-native-frame/1","sqlstate":"22012","template":{"sha256":"8e77d3b07a72ced53b0a9155201072669b88971129569c0a5c7228f8319bab9a","sql":"WITH \"__weft_source\" AS MATERIALIZED ({{SOURCE_SQL}}), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT {{RETURN_COLUMNS}} FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","version":"weft.pg18-composed-frame-template/1"}},"obligations":{"baseTablesOnly":true,"noBypassRls":true,"principal":"caller-connection-role","rls":"native-caller-role","rowCap":1000,"schema":"batten7_demo","searchPath":["pg_catalog"],"tableLifecycle":{"configurationDigest":"87e78860b98bb7fbfbf1535b85806e10691f10700f9906985f7952879efe7161","cursorScope":["module","sourceDigest","configurationDigest","deploymentDigest","ledgerHeadDigest","principal","roleScopeDigest"],"deploymentDigest":"60857a91268e2e4c2819206cb1dbe49ba67546a3519f301897da0a96e366407e","generationLock":"shared-before-admission-through-transaction","installedAuthority":"approved-forward-ledger-and-source-derived-native-witness","module":"demo","nativeExecutionQualified":false,"policy":"source-command-policy-and-native-forced-rls","principal":"verified-person-or-batch","privileges":"source-grants-and-native-effective-closure","roleScope":"native-transitive-current","sourceDigest":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7","sourceInterpretation":"original-umf-deployment-compiler","tables":[{"command":"select","id":"notes","native":"notes","policySourcePath":"/modules/0/extensions/umf.tables/tables/0/policy","record":{"element":"Note","module":"demo"}}],"version":"umf.table-lifecycle/0.1"},"timeout":"per-call","transaction":"read-only"},"orders":{"o_0b8d9a7134c985cecf97062bb7bc25d2100f0200012300c3f7e2d5bc3fc22b29":{"direction":"asc","fieldId":"demo/owner","nulls":"last","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"},"o_48f82d564f190f6fced51ad685ec82d46d05cccb4595aa64f8af2ca580383712":{"direction":"asc","fieldId":"demo/payload","nulls":"last","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"},"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1":{"direction":"asc","fieldId":"demo/id","nulls":"last","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"},"o_5a0fa7505aa54d61a046902644ae78f61e540c0c9f160cac6312e98032ffcaf8":{"direction":"asc","fieldId":"demo/enabled","nulls":"last","sql":"\"r\".\"enabled\" ASC NULLS LAST"},"o_6f9c8ccfbee4bb080d50ffb7532961cddac6c71693c3ef8a2c1e56dfaf696e83":{"direction":"desc","fieldId":"demo/enabled","nulls":"last","sql":"\"r\".\"enabled\" DESC NULLS LAST"},"o_71c99cd89f02a63fdeab9bb29c0659ecb541a2679bdcef79df7d7c1a87f78cd9":{"direction":"asc","fieldId":"demo/amount","nulls":"last","sql":"\"r\".\"amount\" ASC NULLS LAST"},"o_7f089caf246c21027d14b1336adf78a49fbd458b954cd8993c53259a7ceb5cac":{"direction":"desc","fieldId":"demo/owner","nulls":"last","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"},"o_99765136a4dbe11c46bfde088a8f862ea25e3267e4a5ade1c2f1cf5d07c79e00":{"direction":"desc","fieldId":"demo/payload","nulls":"last","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"},"o_bf4f32c943a3f3a0bdd9b050f5bba7dbb9d0ca1320334e64fccad3a1a11290a5":{"direction":"desc","fieldId":"demo/id","nulls":"last","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"},"o_f44a4a5a9eb548d37bd03712a543820ba6e5f6e3b2c492ab0d2c48135fe9b6f1":{"direction":"desc","fieldId":"demo/amount","nulls":"last","sql":"\"r\".\"amount\" DESC NULLS LAST"}},"ordinaryPage":{"continuation":{"exactFullPageYieldsContinuation":true,"fixed":{"bindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4","issuedPageTemplateSha256":"4f4d16229242eb8178b4320e857443af1f64a90d5bc0b17411a65402952b2360","issuedProgramDigest":"eb210fd96101a0e1251b062acbc65c04f6a7c7aeb5ee9b46e9ab1fa73b99b742","keyFieldId":"demo/id","keyId":"primary","module":"demo","record":"Note","sourceModelSha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7","targetId":"postgresql18","targetModelSha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"},"ownerCursor":null,"profile":"weft.generated-ordinary-page-continuation-identity/1","requestInputs":{"filterProgram":{"emptyExpression":null,"emptySql":"TRUE","identity":"canonical-exact-tree","operators":["predicate","and","or","not"],"predicateIdSet":"predicateIds.allowed","profile":"weft.generated-page-filter-program/1","valueOrder":"depth-first-left-to-right"},"normalizedPredicateValues":{"exactCodecNormalization":true,"identity":true,"occurrenceOrder":"depth-first-left-to-right-arity-one-predicate-leaves"},"predicateIds":{"allowed":["p_050a1af83ccde7526057f4e1a055cb67f4c5fe1306c718db11bbfb6b6cae8bd6","p_09e3ecc035702ec5f0d50ce2e15e306f3bdbacf8253788717e691cadd9cb8a28","p_111c63c2b10dd5cdad120b20e6eba866d30bcd1563b115b4add95c22c74de89a","p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263","p_157eac546305ab315b4e0796772e3baf4fce901a33a03f95ba927c9ffc1391d0","p_203358b59727d1c8ee9a4c25db6bba08c7943316a2aefe3450a3052cb454e6c3","p_22b0327e2c19305617f40c361bbdc1073a94b1645bbf398b3453e8b0e7573bd2","p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60","p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470","p_3548c3f371660103886c401d41ccfa5ac10e6e4c5478fa0e97c9ec1f2d9087e8","p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3","p_39d05177a444f0016a41bd27e4aa65e0272e75b407627ddfca6f1298d3781ef5","p_3d57a5cdf8cf9a8172dd7d1c89ba84a156444e2b1e0b9096e52605b6e6534fea","p_400a727eb67b40961d789da7ff5948cca469189f1d51940e9a88a7312e253fcf","p_420d683fa8d3ccc76d0c2367d68ed35b7a49cdec3a57596a96cde7099535d2f3","p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a","p_45bf6b74fc696f7fa4b5b6318b05615c2bd9606d79aa49a9b0a31c03ef098791","p_4b89f6512c45818ecdd7de767aa66d592ffe59b053e76a5e6b9a10618867b814","p_5418967f8687f66e8309d33c4d4ab0fb17eb57c35e4419dd0aed0ebafbf9f9b1","p_567b3cd186376556dcd709955569967f03ba658873c7a58bb691aa507461fef6","p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33","p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864","p_77402cd6b700e4ce0f3eac348e264d0e10b815d173f2592eac3fd59fea334188","p_7a91b5bfdbcbbcaa85d8058c5cc7b0553d5a6717d4ca65c8057c515501dd2859","p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9","p_99897869bd3e174611ef5db55cfb560c213c08e5118c8a045b20636a0ce98a3c","p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8","p_a80fa9a7d9b8ed0f2cff0c32a92484a27d021887d0a24b111ea22ab99ea9825b","p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76","p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5","p_ba3ac0cba39f891efb4a92e1f74fbf91a644064e2dccd832a42a90ad0e097db0","p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559","p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8","p_cf74f652fba0ab001f58905ac36f0ca215dfe77499aacb56a04f172281206e1a","p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060","p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9","p_f48b4887cc27a6fb296c1689e1474142c716a77c6c54b53e41ad021504ca772d","p_f82fd7bb7da02f71377cc3b97f319dd5586b7cdf2774204b97da69799df99dc3","p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44","p_ff6fa097f64094454ca9657d0d6f9ed65827e0ddcd0c1e8275c0d72e125289da"],"identity":true,"ordered":true},"predicateInputs":[{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","id":"p_111c63c2b10dd5cdad120b20e6eba866d30bcd1563b115b4add95c22c74de89a","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","id":"p_157eac546305ab315b4e0796772e3baf4fce901a33a03f95ba927c9ffc1391d0","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","id":"p_203358b59727d1c8ee9a4c25db6bba08c7943316a2aefe3450a3052cb454e6c3","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","id":"p_22b0327e2c19305617f40c361bbdc1073a94b1645bbf398b3453e8b0e7573bd2","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","id":"p_3548c3f371660103886c401d41ccfa5ac10e6e4c5478fa0e97c9ec1f2d9087e8","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","id":"p_400a727eb67b40961d789da7ff5948cca469189f1d51940e9a88a7312e253fcf","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","id":"p_420d683fa8d3ccc76d0c2367d68ed35b7a49cdec3a57596a96cde7099535d2f3","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","id":"p_45bf6b74fc696f7fa4b5b6318b05615c2bd9606d79aa49a9b0a31c03ef098791","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","id":"p_4b89f6512c45818ecdd7de767aa66d592ffe59b053e76a5e6b9a10618867b814","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","id":"p_77402cd6b700e4ce0f3eac348e264d0e10b815d173f2592eac3fd59fea334188","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","id":"p_7a91b5bfdbcbbcaa85d8058c5cc7b0553d5a6717d4ca65c8057c515501dd2859","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","id":"p_99897869bd3e174611ef5db55cfb560c213c08e5118c8a045b20636a0ce98a3c","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","id":"p_a80fa9a7d9b8ed0f2cff0c32a92484a27d021887d0a24b111ea22ab99ea9825b","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","id":"p_ba3ac0cba39f891efb4a92e1f74fbf91a644064e2dccd832a42a90ad0e097db0","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","id":"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","id":"p_cf74f652fba0ab001f58905ac36f0ca215dfe77499aacb56a04f172281206e1a","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","id":"p_f48b4887cc27a6fb296c1689e1474142c716a77c6c54b53e41ad021504ca772d","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","id":"p_f82fd7bb7da02f71377cc3b97f319dd5586b7cdf2774204b97da69799df99dc3","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","id":"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","id":"p_ff6fa097f64094454ca9657d0d6f9ed65827e0ddcd0c1e8275c0d72e125289da","operator":"ne"}],"selectedFieldIds":{"allowed":["demo/amount","demo/enabled","demo/id","demo/owner","demo/payload"],"identity":true,"ordered":true},"size":{"exactInteger":true,"identity":true,"maximum":1000,"minimum":1}},"snapshotVersions":[]},"key":{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"collation":"pg_catalog.\"C\"","direction":"asc","fieldId":"demo/id","id":"primary","nulls":"last","output":{"carrier":"string","name":"__weft_page_key","nativeType":{"kind":"text"},"nullable":false,"oid":25}},"maxSize":1000,"nativeCollationPrecondition":{"dbapiParameterOrder":["schema","table","column"],"expected":{"deterministic":true,"name":"C","schema":"pg_catalog"},"parameterOrder":["schema","table","column"],"parameterSources":["binding.schema","binding.table.native","binding.keyColumn.native"],"profile":"weft.generated-table-collation-c/1","required":true,"sourceSqlTemplate":"SELECT cn.nspname, co.collname, co.collisdeterministic FROM pg_catalog.pg_attribute AS a JOIN pg_catalog.pg_class AS c ON c.oid = a.attrelid JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace JOIN pg_catalog.pg_collation AS co ON co.oid = a.attcollation JOIN pg_catalog.pg_namespace AS cn ON cn.oid = co.collnamespace WHERE n.nspname = $1::pg_catalog.text AND c.relname = $2::pg_catalog.text AND a.attname = $3::pg_catalog.text AND a.attnum > 0 AND NOT a.attisdropped","sqlTemplate":"SELECT cn.nspname, co.collname, co.collisdeterministic FROM pg_catalog.pg_attribute AS a JOIN pg_catalog.pg_class AS c ON c.oid = a.attrelid JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace JOIN pg_catalog.pg_collation AS co ON co.oid = a.attcollation JOIN pg_catalog.pg_namespace AS cn ON cn.oid = co.collnamespace WHERE n.nspname = %s::pg_catalog.text AND c.relname = %s::pg_catalog.text AND a.attname = %s::pg_catalog.text AND a.attnum > 0 AND NOT a.attisdropped"},"page":{"dbapiParameterOrder":["after","after","size"],"fieldOutputs":[{"fieldId":"demo/amount","nativeColumn":"amount","output":{"carrier":"decimal","name":"__weft_field_3","nativeType":{"kind":"numeric","precision":8,"scale":2},"nullable":false,"oid":1700},"sourceField":{"element":"amount","module":"demo"}},{"fieldId":"demo/enabled","nativeColumn":"enabled","output":{"carrier":"boolean","name":"__weft_field_2","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"sourceField":{"element":"enabled","module":"demo"}},{"fieldId":"demo/id","nativeColumn":"id","output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"id","module":"demo"}},{"fieldId":"demo/owner","nativeColumn":"owner","output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"owner","module":"demo"}},{"fieldId":"demo/payload","nativeColumn":"payload","output":{"carrier":"string","name":"__weft_field_4","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"payload","module":"demo"}}],"filterParameterGroup":"filterValues","hiddenKeyOutput":{"carrier":"string","name":"__weft_page_key","nativeType":{"kind":"text"},"nullable":false,"oid":25},"lookaheadRows":1,"ordinalOutput":{"carrier":"integer","name":"__weft_ordinal","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"parameterOrder":["filterValues","after","after","size"],"projectionSlot":{"emptyValue":"","name":"PUBLIC_PROJECTION","nonemptyPrefix":", "},"serverByteGuard":true,"sourceSqlTemplate":"SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_page_key\"{{PUBLIC_PROJECTION}} FROM \"batten7_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > $2::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT ($3::pg_catalog.int8 + 1)","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"id\" COLLATE pg_catalog.\"C\" AS \"__weft_page_key\"{{PUBLIC_PROJECTION}} FROM \"batten7_demo\".\"notes\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \"r\".\"id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"id\" COLLATE pg_catalog.\"C\" ASC LIMIT (%s::pg_catalog.int8 + 1)), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"4f4d16229242eb8178b4320e857443af1f64a90d5bc0b17411a65402952b2360"},"profile":"weft.generated-ordinary-page/1","size":{"carrier":"int64","identity":true,"maximum":1000,"minimum":1,"slot":"size"},"snapshot":{"supported":false,"trueOutcome":"UNSUPPORTED"},"status":"eligible"},"predicates":{"p_050a1af83ccde7526057f4e1a055cb67f4c5fe1306c718db11bbfb6b6cae8bd6":{"arity":0,"fieldId":"demo/enabled","operator":"is-null","sql":"\"r\".\"enabled\" IS NULL"},"p_09e3ecc035702ec5f0d50ce2e15e306f3bdbacf8253788717e691cadd9cb8a28":{"arity":0,"fieldId":"demo/amount","operator":"is-null","sql":"\"r\".\"amount\" IS NULL"},"p_111c63c2b10dd5cdad120b20e6eba866d30bcd1563b115b4add95c22c74de89a":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","operator":"le","sql":"\"r\".\"enabled\" <= %s::pg_catalog.bool"},"p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263":{"arity":0,"fieldId":"demo/id","operator":"is-null","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" IS NULL"},"p_157eac546305ab315b4e0796772e3baf4fce901a33a03f95ba927c9ffc1391d0":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","operator":"le","sql":"\"r\".\"amount\" <= %s::pg_catalog.numeric"},"p_203358b59727d1c8ee9a4c25db6bba08c7943316a2aefe3450a3052cb454e6c3":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","operator":"ge","sql":"\"r\".\"enabled\" >= %s::pg_catalog.bool"},"p_22b0327e2c19305617f40c361bbdc1073a94b1645bbf398b3453e8b0e7573bd2":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","operator":"gt","sql":"\"r\".\"amount\" > %s::pg_catalog.numeric"},"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"le","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"eq","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_3548c3f371660103886c401d41ccfa5ac10e6e4c5478fa0e97c9ec1f2d9087e8":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","operator":"eq","sql":"\"r\".\"enabled\" = %s::pg_catalog.bool"},"p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3":{"arity":0,"fieldId":"demo/owner","operator":"is-not-null","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_39d05177a444f0016a41bd27e4aa65e0272e75b407627ddfca6f1298d3781ef5":{"arity":0,"fieldId":"demo/amount","operator":"is-not-null","sql":"\"r\".\"amount\" IS NOT NULL"},"p_3d57a5cdf8cf9a8172dd7d1c89ba84a156444e2b1e0b9096e52605b6e6534fea":{"arity":0,"fieldId":"demo/payload","operator":"is-null","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" IS NULL"},"p_400a727eb67b40961d789da7ff5948cca469189f1d51940e9a88a7312e253fcf":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","operator":"ge","sql":"\"r\".\"amount\" >= %s::pg_catalog.numeric"},"p_420d683fa8d3ccc76d0c2367d68ed35b7a49cdec3a57596a96cde7099535d2f3":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","operator":"lt","sql":"\"r\".\"enabled\" < %s::pg_catalog.bool"},"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"gt","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"},"p_45bf6b74fc696f7fa4b5b6318b05615c2bd9606d79aa49a9b0a31c03ef098791":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","operator":"gt","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"},"p_4b89f6512c45818ecdd7de767aa66d592ffe59b053e76a5e6b9a10618867b814":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","operator":"ne","sql":"\"r\".\"amount\" <> %s::pg_catalog.numeric"},"p_5418967f8687f66e8309d33c4d4ab0fb17eb57c35e4419dd0aed0ebafbf9f9b1":{"arity":0,"fieldId":"demo/enabled","operator":"is-not-null","sql":"\"r\".\"enabled\" IS NOT NULL"},"p_567b3cd186376556dcd709955569967f03ba658873c7a58bb691aa507461fef6":{"arity":0,"fieldId":"demo/payload","operator":"is-not-null","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"eq","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"le","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_77402cd6b700e4ce0f3eac348e264d0e10b815d173f2592eac3fd59fea334188":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","operator":"le","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_7a91b5bfdbcbbcaa85d8058c5cc7b0553d5a6717d4ca65c8057c515501dd2859":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","operator":"eq","sql":"\"r\".\"amount\" = %s::pg_catalog.numeric"},"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"lt","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"},"p_99897869bd3e174611ef5db55cfb560c213c08e5118c8a045b20636a0ce98a3c":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","operator":"lt","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"},"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"ge","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_a80fa9a7d9b8ed0f2cff0c32a92484a27d021887d0a24b111ea22ab99ea9825b":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"decimalToken"},{"carrier":"decimal","maxTokenBytes":4000000,"op":"parse-carrier","precision":8,"profile":"weft.exact-coefficient/1","scale":2},{"allowedIdentities":null,"carrier":"decimal","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"decimal","mode":"canonical-scaled-decimal","op":"normalize-native-query-value"}]},"fieldId":"demo/amount","operator":"lt","sql":"\"r\".\"amount\" < %s::pg_catalog.numeric"},"p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76":{"arity":0,"fieldId":"demo/owner","operator":"is-null","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" IS NULL"},"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"ne","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"},"p_ba3ac0cba39f891efb4a92e1f74fbf91a644064e2dccd832a42a90ad0e097db0":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","operator":"ne","sql":"\"r\".\"enabled\" <> %s::pg_catalog.bool"},"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"ne","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"},"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/owner","operator":"ge","sql":"\"r\".\"owner\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_cf74f652fba0ab001f58905ac36f0ca215dfe77499aacb56a04f172281206e1a":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"boolean"},{"carrier":"boolean","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.boolean/1","scale":null},{"allowedIdentities":null,"carrier":"boolean","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"boolean","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/enabled","operator":"gt","sql":"\"r\".\"enabled\" > %s::pg_catalog.bool"},"p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060":{"arity":0,"fieldId":"demo/id","operator":"is-not-null","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"lt","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"},"p_f48b4887cc27a6fb296c1689e1474142c716a77c6c54b53e41ad021504ca772d":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","operator":"eq","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_f82fd7bb7da02f71377cc3b97f319dd5586b7cdf2774204b97da69799df99dc3":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","operator":"ge","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/id","operator":"gt","sql":"\"r\".\"id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"},"p_ff6fa097f64094454ca9657d0d6f9ed65827e0ddcd0c1e8275c0d72e125289da":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/payload","operator":"ne","sql":"\"r\".\"payload\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"}},"primaryKey":[{"fieldId":"demo/id","predicateId":"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33"}],"primaryKeyId":"primary","record":"Note","terminals":{"count":{"cardinality":"one-integer","frameSelectSql":"f.\"__weft_count\"","output":{"carrier":"integer","name":"__weft_count","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"selectSql":"pg_catalog.count(*) AS \"__weft_count\""},"exists":{"cardinality":"row-presence","frameSelectSql":"f.\"__weft_exists\"","limit":1,"output":{"carrier":"boolean","name":"__weft_exists","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"selectSql":"true AS \"__weft_exists\""},"first":{"cardinality":"zero-or-one","limit":1},"get":{"cardinality":"exactly-one","limit":2},"one":{"cardinality":"exactly-one","limit":2}}},"demo/Task":{"defaultSelection":["demo/taskId","demo/taskOwner","demo/taskValue"],"fields":{"demo/taskId":{"frameSelectSql":"f.\"__weft_field_0\"","output":{"carrier":"string","name":"__weft_field_0","nullable":false},"selectSql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" AS \"__weft_field_0\"","sourceField":{"element":"taskId","module":"demo"}},"demo/taskOwner":{"frameSelectSql":"f.\"__weft_field_1\"","output":{"carrier":"string","name":"__weft_field_1","nullable":false},"selectSql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" AS \"__weft_field_1\"","sourceField":{"element":"taskOwner","module":"demo"}},"demo/taskValue":{"frameSelectSql":"f.\"__weft_field_2\"","output":{"carrier":"string","name":"__weft_field_2","nullable":false},"selectSql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" AS \"__weft_field_2\"","sourceField":{"element":"taskValue","module":"demo"}}},"forwardConnection":{"fieldOutputs":[{"fieldId":"demo/taskId","output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25}},{"fieldId":"demo/taskOwner","output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25}},{"fieldId":"demo/taskValue","output":{"carrier":"string","name":"__weft_field_2","nativeType":{"kind":"text"},"nullable":false,"oid":25}}],"forward":{"dbapiParameterOrder":["after","after","limit"],"filterParameterGroup":"filterValues","keyOutput":{"carrier":"string","name":"__weft_connection_key","nativeType":{"kind":"text"},"nullable":false,"oid":25},"parameterOrder":["filterValues","after","after","limit"],"sourceSqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"task_id\" COLLATE pg_catalog.\"C\" AS \"__weft_connection_key\"{{SELECT_COLUMNS}} FROM \"batten7_demo\".\"tasks\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \"r\".\"task_id\" COLLATE pg_catalog.\"C\" > $2::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC LIMIT $3::pg_catalog.int8), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","sourceTemplateSha256":"c3952ba5328074c1a7251f8a8051b4bd4f9b837e8cdef8b1019f7c264c4650dc","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"task_id\" COLLATE pg_catalog.\"C\" AS \"__weft_connection_key\"{{SELECT_COLUMNS}} FROM \"batten7_demo\".\"tasks\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \"r\".\"task_id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC LIMIT %s::pg_catalog.int8), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"c6ea7db8bbbfd777abdefc672473b874c7c0c682a9b887a039331d08d4b4c0cd"},"key":{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"collation":"pg_catalog.\"C\"","direction":"asc","fieldId":"demo/taskId","nulls":"last","output":{"carrier":"string","name":"__weft_connection_key","nativeType":{"kind":"text"},"nullable":false,"oid":25}},"keyId":"primary","lookaheadRows":1,"maxFirst":100,"nativeCollation":"pg_catalog.\"C\"","nativeCollationPrecondition":"umf.generated-table-collation-c/1","previous":{"dbapiParameterOrder":["after","after"],"filterParameterGroup":"filterValues","output":{"carrier":"boolean","name":"__weft_previous","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"parameterOrder":["filterValues","after","after"],"sourceSqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \"__weft_ordinal\", EXISTS (SELECT 1 FROM \"batten7_demo\".\"tasks\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NOT NULL AND \"r\".\"task_id\" COLLATE pg_catalog.\"C\" <= $2::pg_catalog.text COLLATE pg_catalog.\"C\") LIMIT 1) AS \"__weft_previous\"), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.\"__weft_previous\" FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","sourceTemplateSha256":"adaaa45295287ca2999e71c256ed39a4c5e33ae4bb287db3be2c0000671fd408","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \"__weft_ordinal\", EXISTS (SELECT 1 FROM \"batten7_demo\".\"tasks\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NOT NULL AND \"r\".\"task_id\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text COLLATE pg_catalog.\"C\") LIMIT 1) AS \"__weft_previous\"), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.\"__weft_previous\" FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"a006a0ba5a521e26ce25563639b3362ae88148501b88fbd96564d26f7c4becba"},"profile":"weft.generated-forward-connection/1","zeroFirstProbeRows":1},"forwardConnectionSupport":{"profile":"weft.generated-forward-connection/1","status":"eligible"},"frameOrdinalSql":"ROW_NUMBER() OVER (ORDER BY {{ORDER_SQL}}) AS \"__weft_ordinal\"","frameScalarOrdinalSql":"1::pg_catalog.int8 AS \"__weft_ordinal\"","fromSql":"FROM \"batten7_demo\".\"tasks\" AS \"r\"","getMany":{"keyFields":[{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId"}],"keyId":"primary","keyTupleSql":"(%s::pg_catalog.int8, %s::pg_catalog.text)","maxKeys":100,"ordinalOutput":{"carrier":"integer","name":"__weft_ordinal","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"presentOutput":{"carrier":"boolean","name":"__weft_present","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"profile":"weft.generated-key-batch/1","sourceSqlTemplate":"WITH \"__weft_key_rows\" (\"__weft_ordinal\", \"__weft_key_0\") AS (VALUES {{KEY_ROWS}}) SELECT k.\"__weft_ordinal\" AS \"__weft_ordinal\", (\"r\".\"task_id\" IS NOT NULL) AS \"__weft_present\"{{SELECT_COLUMNS}} FROM \"__weft_key_rows\" AS k LEFT JOIN \"batten7_demo\".\"tasks\" AS \"r\" ON \"r\".\"task_id\" COLLATE pg_catalog.\"C\" = k.\"__weft_key_0\" COLLATE pg_catalog.\"C\" ORDER BY k.\"__weft_ordinal\"","sourceTemplateSha256":"fd083d34308b24439a14d9fa2c79bd76a1fc8e1e0720e2316ae180d41e6b0ba2"},"keyTieOrder":["o_3429573858cba8fbda94eaaa3000ffa3e5ef64b1b98696bc98cc21d592c936a0"],"maxRows":1000,"module":"demo","nativeReadGuard":{"byteMetric":"pg18-row-json-utf8/1","maxNativeBytes":8388608,"partialFrames":false,"profile":"pg18-composed-native-frame/1","sqlstate":"22012","template":{"sha256":"8e77d3b07a72ced53b0a9155201072669b88971129569c0a5c7228f8319bab9a","sql":"WITH \"__weft_source\" AS MATERIALIZED ({{SOURCE_SQL}}), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT {{RETURN_COLUMNS}} FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","version":"weft.pg18-composed-frame-template/1"}},"obligations":{"baseTablesOnly":true,"noBypassRls":true,"principal":"caller-connection-role","rls":"native-caller-role","rowCap":1000,"schema":"batten7_demo","searchPath":["pg_catalog"],"tableLifecycle":{"configurationDigest":"87e78860b98bb7fbfbf1535b85806e10691f10700f9906985f7952879efe7161","cursorScope":["module","sourceDigest","configurationDigest","deploymentDigest","ledgerHeadDigest","principal","roleScopeDigest"],"deploymentDigest":"60857a91268e2e4c2819206cb1dbe49ba67546a3519f301897da0a96e366407e","generationLock":"shared-before-admission-through-transaction","installedAuthority":"approved-forward-ledger-and-source-derived-native-witness","module":"demo","nativeExecutionQualified":false,"policy":"source-command-policy-and-native-forced-rls","principal":"verified-person-or-batch","privileges":"source-grants-and-native-effective-closure","roleScope":"native-transitive-current","sourceDigest":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7","sourceInterpretation":"original-umf-deployment-compiler","tables":[{"command":"select","id":"tasks","native":"tasks","policySourcePath":"/modules/0/extensions/umf.tables/tables/1/policy","record":{"element":"Task","module":"demo"}}],"version":"umf.table-lifecycle/0.1"},"timeout":"per-call","transaction":"read-only"},"orders":{"o_1bf738ef2601bd2d5adb0601355e03846abf2e275ddcafb0439349f03be20a18":{"direction":"desc","fieldId":"demo/taskValue","nulls":"last","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"},"o_27f039dd9fd2fa377bdedbe930304939a6a2ffbb226ac3048ed717a60f3791d6":{"direction":"asc","fieldId":"demo/taskOwner","nulls":"last","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"},"o_3429573858cba8fbda94eaaa3000ffa3e5ef64b1b98696bc98cc21d592c936a0":{"direction":"asc","fieldId":"demo/taskId","nulls":"last","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"},"o_808c375d10e016eef911730a1e8c0e9a30c7f23bccb558c522ac6d8258d3663a":{"direction":"desc","fieldId":"demo/taskId","nulls":"last","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"},"o_9777f7e9937ffe0a82ab80d0e51a5bd8e0ac581e2a5c9c4b500f4da908befe7f":{"direction":"desc","fieldId":"demo/taskOwner","nulls":"last","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" DESC NULLS LAST"},"o_d07e8b9124102857ad5cb13f036a987255f5c1286966d3889a46ed806d06d057":{"direction":"asc","fieldId":"demo/taskValue","nulls":"last","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" ASC NULLS LAST"}},"ordinaryPage":{"continuation":{"exactFullPageYieldsContinuation":true,"fixed":{"bindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4","issuedPageTemplateSha256":"cb434594682efe5dc8d9b83c26ffdf5737f466f98b48fb1bc428573d8d98c61b","issuedProgramDigest":"fc980330ffaf4c997e91827a529608838790010a8e5f72d9d53cc73050b82f21","keyFieldId":"demo/taskId","keyId":"primary","module":"demo","record":"Task","sourceModelSha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7","targetId":"postgresql18","targetModelSha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"},"ownerCursor":null,"profile":"weft.generated-ordinary-page-continuation-identity/1","requestInputs":{"filterProgram":{"emptyExpression":null,"emptySql":"TRUE","identity":"canonical-exact-tree","operators":["predicate","and","or","not"],"predicateIdSet":"predicateIds.allowed","profile":"weft.generated-page-filter-program/1","valueOrder":"depth-first-left-to-right"},"normalizedPredicateValues":{"exactCodecNormalization":true,"identity":true,"occurrenceOrder":"depth-first-left-to-right-arity-one-predicate-leaves"},"predicateIds":{"allowed":["p_086923e8a7ab696ebc75450b95862006119fc12a3dcebef810cf7c1e705236f1","p_3a0b08e455ed457dfad17122d53af47c9d7b53447dcc427b7412713f78b03d12","p_3d4ec96e39e4208c0d5259ba1233a03567efe7b264572fcc835236cc93bce89b","p_578564d1c39a998e13b17f17b60f01f9837d68c3973e426d9249335c54bbea55","p_6b3b0b19657645a8247cb277d2ee2e0f392a0a6e1ee63d9eb32426c44a3745e3","p_6b5c6d0c022beaf397b729548f719d9b841ad7598df19419a8bf665d64c5e0a7","p_6fbf0cf780d85383730d67980a14ea5810276690fbd7c70a881972085d93bd23","p_7ee01bd9d8db1f417b64843fc9231baf2bb7726f310927836325040554c43308","p_93e99879963d2a453549c1668b16640c8cfce89798ad7815007786331f208e6c","p_94a994ffeafc1a5458e33c6665dd17528f587f92d2352ba3598d5114bbf088c3","p_99e8cd9ffc3e2911655909af984616e6a99700103f0f93937eb0e04922eb73d3","p_a4e89d20a237bb77a93c3a930e36b423f10e66cd80f3846b53fdf0f39b803223","p_a51f69b3310bf9da30d32b639beb6170b95e360ec66b684d25ece370422d5202","p_b9f57facd83a820f6a69805a7be170be2f84980bf39c677e5dc0aed74c5d88a5","p_be4ef5b5c5e2a56d740e2ab46c59412353406e8fd5b57334d4df3058c430ae89","p_c7427f821ac9e8738c289bc6cb6eb946e4ba579c53435cc7f38b0dd0a812247c","p_c8a6500536dbff69a57ed75d79db2db1449f6c0d9d18f461e9f3c13a23972bd7","p_da7cfa480bf9567ecc0b3427905c2bb96101d1d8e9b6f2c2bbb5c719742cd7da","p_dcef25f775ba54e4fb45c64cf2b9c199419ea46eed5632b240951f8d67bcb7b8","p_de87dc72b49945c5551491af2569615d461f24b898deecb1674cba7170acac62","p_e1a9e815a62668db1f9ff78d55bbf9bb4e9d37cbe5345ce8907445daa4255ebb","p_e39f49fb5eccbe656baa42e6e80e12068f390624667466ec9c62a3fa14241c22","p_f0d08b82d7c92464f8d288656bb43a4d5e07f7a2dc05604b9d34d415c77bc3b3","p_feed2ae258de4ac49c981f4de7bd3765e6d18be5ccbf3bba28d04004d42e452a"],"identity":true,"ordered":true},"predicateInputs":[{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","id":"p_086923e8a7ab696ebc75450b95862006119fc12a3dcebef810cf7c1e705236f1","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","id":"p_3a0b08e455ed457dfad17122d53af47c9d7b53447dcc427b7412713f78b03d12","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","id":"p_3d4ec96e39e4208c0d5259ba1233a03567efe7b264572fcc835236cc93bce89b","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","id":"p_6fbf0cf780d85383730d67980a14ea5810276690fbd7c70a881972085d93bd23","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","id":"p_7ee01bd9d8db1f417b64843fc9231baf2bb7726f310927836325040554c43308","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","id":"p_93e99879963d2a453549c1668b16640c8cfce89798ad7815007786331f208e6c","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","id":"p_94a994ffeafc1a5458e33c6665dd17528f587f92d2352ba3598d5114bbf088c3","operator":"lt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","id":"p_a4e89d20a237bb77a93c3a930e36b423f10e66cd80f3846b53fdf0f39b803223","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","id":"p_a51f69b3310bf9da30d32b639beb6170b95e360ec66b684d25ece370422d5202","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","id":"p_b9f57facd83a820f6a69805a7be170be2f84980bf39c677e5dc0aed74c5d88a5","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","id":"p_be4ef5b5c5e2a56d740e2ab46c59412353406e8fd5b57334d4df3058c430ae89","operator":"gt"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","id":"p_c7427f821ac9e8738c289bc6cb6eb946e4ba579c53435cc7f38b0dd0a812247c","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","id":"p_c8a6500536dbff69a57ed75d79db2db1449f6c0d9d18f461e9f3c13a23972bd7","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","id":"p_da7cfa480bf9567ecc0b3427905c2bb96101d1d8e9b6f2c2bbb5c719742cd7da","operator":"eq"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","id":"p_de87dc72b49945c5551491af2569615d461f24b898deecb1674cba7170acac62","operator":"le"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","id":"p_e1a9e815a62668db1f9ff78d55bbf9bb4e9d37cbe5345ce8907445daa4255ebb","operator":"ge"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","id":"p_e39f49fb5eccbe656baa42e6e80e12068f390624667466ec9c62a3fa14241c22","operator":"ne"},{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","id":"p_feed2ae258de4ac49c981f4de7bd3765e6d18be5ccbf3bba28d04004d42e452a","operator":"lt"}],"selectedFieldIds":{"allowed":["demo/taskId","demo/taskOwner","demo/taskValue"],"identity":true,"ordered":true},"size":{"exactInteger":true,"identity":true,"maximum":1000,"minimum":1}},"snapshotVersions":[]},"key":{"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"collation":"pg_catalog.\"C\"","direction":"asc","fieldId":"demo/taskId","id":"primary","nulls":"last","output":{"carrier":"string","name":"__weft_page_key","nativeType":{"kind":"text"},"nullable":false,"oid":25}},"maxSize":1000,"nativeCollationPrecondition":{"dbapiParameterOrder":["schema","table","column"],"expected":{"deterministic":true,"name":"C","schema":"pg_catalog"},"parameterOrder":["schema","table","column"],"parameterSources":["binding.schema","binding.table.native","binding.keyColumn.native"],"profile":"weft.generated-table-collation-c/1","required":true,"sourceSqlTemplate":"SELECT cn.nspname, co.collname, co.collisdeterministic FROM pg_catalog.pg_attribute AS a JOIN pg_catalog.pg_class AS c ON c.oid = a.attrelid JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace JOIN pg_catalog.pg_collation AS co ON co.oid = a.attcollation JOIN pg_catalog.pg_namespace AS cn ON cn.oid = co.collnamespace WHERE n.nspname = $1::pg_catalog.text AND c.relname = $2::pg_catalog.text AND a.attname = $3::pg_catalog.text AND a.attnum > 0 AND NOT a.attisdropped","sqlTemplate":"SELECT cn.nspname, co.collname, co.collisdeterministic FROM pg_catalog.pg_attribute AS a JOIN pg_catalog.pg_class AS c ON c.oid = a.attrelid JOIN pg_catalog.pg_namespace AS n ON n.oid = c.relnamespace JOIN pg_catalog.pg_collation AS co ON co.oid = a.attcollation JOIN pg_catalog.pg_namespace AS cn ON cn.oid = co.collnamespace WHERE n.nspname = %s::pg_catalog.text AND c.relname = %s::pg_catalog.text AND a.attname = %s::pg_catalog.text AND a.attnum > 0 AND NOT a.attisdropped"},"page":{"dbapiParameterOrder":["after","after","size"],"fieldOutputs":[{"fieldId":"demo/taskId","nativeColumn":"task_id","output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"taskId","module":"demo"}},{"fieldId":"demo/taskOwner","nativeColumn":"task_owner","output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"taskOwner","module":"demo"}},{"fieldId":"demo/taskValue","nativeColumn":"task_value","output":{"carrier":"string","name":"__weft_field_2","nativeType":{"kind":"text"},"nullable":false,"oid":25},"sourceField":{"element":"taskValue","module":"demo"}}],"filterParameterGroup":"filterValues","hiddenKeyOutput":{"carrier":"string","name":"__weft_page_key","nativeType":{"kind":"text"},"nullable":false,"oid":25},"lookaheadRows":1,"ordinalOutput":{"carrier":"integer","name":"__weft_ordinal","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"parameterOrder":["filterValues","after","after","size"],"projectionSlot":{"emptyValue":"","name":"PUBLIC_PROJECTION","nonemptyPrefix":", "},"serverByteGuard":true,"sourceSqlTemplate":"SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"task_id\" COLLATE pg_catalog.\"C\" AS \"__weft_page_key\"{{PUBLIC_PROJECTION}} FROM \"batten7_demo\".\"tasks\" AS \"r\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \"r\".\"task_id\" COLLATE pg_catalog.\"C\" > $2::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC LIMIT ($3::pg_catalog.int8 + 1)","sqlTemplate":"WITH \"__weft_source\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC) AS \"__weft_ordinal\", \"r\".\"task_id\" COLLATE pg_catalog.\"C\" AS \"__weft_page_key\"{{PUBLIC_PROJECTION}} FROM \"batten7_demo\".\"tasks\" AS \"r\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \"r\".\"task_id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text COLLATE pg_catalog.\"C\") ORDER BY \"r\".\"task_id\" COLLATE pg_catalog.\"C\" ASC LIMIT (%s::pg_catalog.int8 + 1)), \"__weft_guard\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \"__weft_source\" AS f) SELECT f.* FROM \"__weft_source\" AS f ORDER BY f.\"__weft_ordinal\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \"__weft_guard\")","templateSha256":"cb434594682efe5dc8d9b83c26ffdf5737f466f98b48fb1bc428573d8d98c61b"},"profile":"weft.generated-ordinary-page/1","size":{"carrier":"int64","identity":true,"maximum":1000,"minimum":1,"slot":"size"},"snapshot":{"supported":false,"trueOutcome":"UNSUPPORTED"},"status":"eligible"},"predicates":{"p_086923e8a7ab696ebc75450b95862006119fc12a3dcebef810cf7c1e705236f1":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","operator":"le","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_3a0b08e455ed457dfad17122d53af47c9d7b53447dcc427b7412713f78b03d12":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","operator":"le","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_3d4ec96e39e4208c0d5259ba1233a03567efe7b264572fcc835236cc93bce89b":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","operator":"gt","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"},"p_578564d1c39a998e13b17f17b60f01f9837d68c3973e426d9249335c54bbea55":{"arity":0,"fieldId":"demo/taskOwner","operator":"is-null","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" IS NULL"},"p_6b3b0b19657645a8247cb277d2ee2e0f392a0a6e1ee63d9eb32426c44a3745e3":{"arity":0,"fieldId":"demo/taskId","operator":"is-null","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" IS NULL"},"p_6b5c6d0c022beaf397b729548f719d9b841ad7598df19419a8bf665d64c5e0a7":{"arity":0,"fieldId":"demo/taskId","operator":"is-not-null","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_6fbf0cf780d85383730d67980a14ea5810276690fbd7c70a881972085d93bd23":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","operator":"ge","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_7ee01bd9d8db1f417b64843fc9231baf2bb7726f310927836325040554c43308":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","operator":"lt","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"},"p_93e99879963d2a453549c1668b16640c8cfce89798ad7815007786331f208e6c":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","operator":"ne","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"},"p_94a994ffeafc1a5458e33c6665dd17528f587f92d2352ba3598d5114bbf088c3":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","operator":"lt","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"},"p_99e8cd9ffc3e2911655909af984616e6a99700103f0f93937eb0e04922eb73d3":{"arity":0,"fieldId":"demo/taskOwner","operator":"is-not-null","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_a4e89d20a237bb77a93c3a930e36b423f10e66cd80f3846b53fdf0f39b803223":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","operator":"eq","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_a51f69b3310bf9da30d32b639beb6170b95e360ec66b684d25ece370422d5202":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","operator":"gt","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"},"p_b9f57facd83a820f6a69805a7be170be2f84980bf39c677e5dc0aed74c5d88a5":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","operator":"eq","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_be4ef5b5c5e2a56d740e2ab46c59412353406e8fd5b57334d4df3058c430ae89":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","operator":"gt","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" > %s::pg_catalog.text"},"p_c7427f821ac9e8738c289bc6cb6eb946e4ba579c53435cc7f38b0dd0a812247c":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","operator":"ge","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_c8a6500536dbff69a57ed75d79db2db1449f6c0d9d18f461e9f3c13a23972bd7":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","operator":"ne","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"},"p_da7cfa480bf9567ecc0b3427905c2bb96101d1d8e9b6f2c2bbb5c719742cd7da":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskValue","operator":"eq","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" = %s::pg_catalog.text"},"p_dcef25f775ba54e4fb45c64cf2b9c199419ea46eed5632b240951f8d67bcb7b8":{"arity":0,"fieldId":"demo/taskValue","operator":"is-null","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" IS NULL"},"p_de87dc72b49945c5551491af2569615d461f24b898deecb1674cba7170acac62":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","operator":"le","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" <= %s::pg_catalog.text"},"p_e1a9e815a62668db1f9ff78d55bbf9bb4e9d37cbe5345ce8907445daa4255ebb":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskOwner","operator":"ge","sql":"\"r\".\"task_owner\" COLLATE pg_catalog.\"C\" >= %s::pg_catalog.text"},"p_e39f49fb5eccbe656baa42e6e80e12068f390624667466ec9c62a3fa14241c22":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","operator":"ne","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" <> %s::pg_catalog.text"},"p_f0d08b82d7c92464f8d288656bb43a4d5e07f7a2dc05604b9d34d415c77bc3b3":{"arity":0,"fieldId":"demo/taskValue","operator":"is-not-null","sql":"\"r\".\"task_value\" COLLATE pg_catalog.\"C\" IS NOT NULL"},"p_feed2ae258de4ac49c981f4de7bd3765e6d18be5ccbf3bba28d04004d42e452a":{"arity":1,"codec":{"profile":"weft.query-codec-instructions/1","steps":[{"nullable":false,"op":"require-exact-wrapper","wrapper":"string"},{"carrier":"string","maxTokenBytes":null,"op":"parse-carrier","precision":null,"profile":"weft.string/1","scale":null},{"allowedIdentities":null,"carrier":"string","integerWidth":null,"length":null,"op":"check-refinements","range":null},{"carrier":"string","mode":"identity","op":"normalize-native-query-value"}]},"fieldId":"demo/taskId","operator":"lt","sql":"\"r\".\"task_id\" COLLATE pg_catalog.\"C\" < %s::pg_catalog.text"}},"primaryKey":[{"fieldId":"demo/taskId","predicateId":"p_b9f57facd83a820f6a69805a7be170be2f84980bf39c677e5dc0aed74c5d88a5"}],"primaryKeyId":"primary","record":"Task","terminals":{"count":{"cardinality":"one-integer","frameSelectSql":"f.\"__weft_count\"","output":{"carrier":"integer","name":"__weft_count","nativeType":{"kind":"int8"},"nullable":false,"oid":20},"selectSql":"pg_catalog.count(*) AS \"__weft_count\""},"exists":{"cardinality":"row-presence","frameSelectSql":"f.\"__weft_exists\"","limit":1,"output":{"carrier":"boolean","name":"__weft_exists","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"selectSql":"true AS \"__weft_exists\""},"first":{"cardinality":"zero-or-one","limit":1},"get":{"cardinality":"exactly-one","limit":2},"one":{"cardinality":"exactly-one","limit":2}}}},"source":{"modelSha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7","module":"demo"},"target":{"bindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4","id":"postgresql18","modelSha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"},"version":"weft.generated-read-algebra/7"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-rich/artifact/manifest.json b/tests/runtime/fixtures/generated-page7-rich/artifact/manifest.json new file mode 100644 index 0000000..08ec737 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/artifact/manifest.json @@ -0,0 +1 @@ +{"algebra":{"algebraPath":"algebra/read.json","profile":"weft.generated-read-algebra/7"},"artifactDigest":"ac137c89d2b30ba26a09e183140bba01f7301499efa0fb11926c47e220ec53cb","artifactId":"batten-profile7-provenance-60857a91268e2e4c","executor":{"abiMajor":1,"maxMinor":7,"minMinor":7,"packageId":"umf-access-generated-executor"},"generator":{"abi":"weft.generated-execution/1","umfDistribution":"umf-codegen","umfSourceDigest":"8c01f37b5b28a17cacf632cbb6f0cd83a1c99120f3d1926924be2396f9664fdb","umfVersion":"0.1.0a8","weftDistribution":"weft-sql","weftSourceDigest":"b0655f857be2aa81754cc549917b1f90dd9b63f5ed59b998a6802104558592e7","weftVersion":"0.4.66.dev1"},"inventory":{"algebra/read.json":"7248713150673a9707d646daa4b0b8b248d119769619646cc00163a017d6f935","native/native-table-source.json":"d6acc1f919b2df759a1bbe1f88569373bfc30275c297f7c63a531417563e10a1"},"programs":{},"provenance":{"buildId":"batten7-prov-60857a91268e2e4c","issuer":"task-local-fabricated-pg18-fixture","receiptDigest":"327afbccd4287fa5ce52c2090833e42d29ffcb9f6543b949a2b18b789142bb2e"},"source":{"bundleInputDigest":"6bf7d2b0128c95b9149bcaa055f606e7726dcebd2cd92411db6191cc1099064d","coreVersion":"0.10.0","documentId":"synthetic-table-lifecycle","moduleIds":["demo"],"sha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"},"target":{"bindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4","id":"postgresql18","profile":"pg18/1","version":"18"},"version":"weft.generated-execution/1"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-rich/artifact/native/native-table-source.json b/tests/runtime/fixtures/generated-page7-rich/artifact/native/native-table-source.json new file mode 100644 index 0000000..951bc80 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/artifact/native/native-table-source.json @@ -0,0 +1 @@ +{"bundleDigest":"60857a91268e2e4c2819206cb1dbe49ba67546a3519f301897da0a96e366407e","configuration":{"batchRole":"batten7_batch","groupRoles":{},"module":"demo","ownerRole":"batten7_owner","personRole":"batten7_person","schema":"batten7_demo"},"configurationDigest":"87e78860b98bb7fbfbf1535b85806e10691f10700f9906985f7952879efe7161","expectedCatalog":{"checks":[{"id":"domain:demo.amount"}],"tables":[{"columns":[{"field":{"element":"id","module":"demo"},"name":"id","nativeType":{"kind":"text"}},{"field":{"element":"owner","module":"demo"},"name":"owner","nativeType":{"kind":"text"}},{"field":{"element":"enabled","module":"demo"},"name":"enabled","nativeType":{"kind":"boolean"}},{"field":{"element":"amount","module":"demo"},"name":"amount","nativeType":{"kind":"numeric","precision":8,"scale":2}},{"field":{"element":"payload","module":"demo"},"name":"payload","nativeType":{"kind":"text"}}],"id":"notes","name":"notes","record":{"element":"Note","module":"demo"}},{"columns":[{"field":{"element":"taskId","module":"demo"},"name":"task_id","nativeType":{"kind":"text"}},{"field":{"element":"taskOwner","module":"demo"},"name":"task_owner","nativeType":{"kind":"text"}},{"field":{"element":"taskValue","module":"demo"},"name":"task_value","nativeType":{"kind":"text"}}],"id":"tasks","name":"tasks","record":{"element":"Task","module":"demo"}}]},"operations":[],"sourceDigest":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7","version":"umf.native-table-source/2"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-rich/prepared-api-v4-rich-proof.json b/tests/runtime/fixtures/generated-page7-rich/prepared-api-v4-rich-proof.json new file mode 100644 index 0000000..9fd0638 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/prepared-api-v4-rich-proof.json @@ -0,0 +1 @@ +{"apiDigest":"86281b7304b6bdbd64c15a858d72187bc2615696a4bbc50934294975761de59b","application":"fixture-app","artifactDigest":"f55270456afbbac1a308a236d30bb9865a0c34a09a01fc95bdcf98394b77ebe6","artifactId":"86281b7304b6bdbd64c15a858d72187bc2615696a4bbc50934294975761de59b","bindingProfile":"pg18/1","capabilities":[["binding.profile","pg18/1"],["connection.forward","edge-cursor-1"],["connection.forward.binding.profile","pg18/1"],["identity.codec","lintel.node-id.string-key/1"],["identity.codec.binding.profile","pg18/1"],["limit.cursorBytes","4096"],["limit.cursorBytes.binding.profile","pg18/1"],["limit.deadlineMs","30000"],["limit.deadlineMs.binding.profile","pg18/1"],["limit.defaultPage","25"],["limit.defaultPage.binding.profile","pg18/1"],["limit.documentBytes","262144"],["limit.documentBytes.binding.profile","pg18/1"],["limit.invocationKeyBytes","128"],["limit.invocationKeyBytes.binding.profile","pg18/1"],["limit.maxAliases","32"],["limit.maxAliases.binding.profile","pg18/1"],["limit.maxConcurrentDispatch","8"],["limit.maxConcurrentDispatch.binding.profile","pg18/1"],["limit.maxCost","10000"],["limit.maxCost.binding.profile","pg18/1"],["limit.maxDepth","8"],["limit.maxDepth.binding.profile","pg18/1"],["limit.maxFieldOccurrences","256"],["limit.maxFieldOccurrences.binding.profile","pg18/1"],["limit.maxLookup","100"],["limit.maxLookup.binding.profile","pg18/1"],["limit.maxMutationFields","4"],["limit.maxMutationFields.binding.profile","pg18/1"],["limit.maxPage","100"],["limit.maxPage.binding.profile","pg18/1"],["limit.maxRelationshipHops","1"],["limit.maxRelationshipHops.binding.profile","pg18/1"],["limit.nodeIdBytes","2048"],["limit.nodeIdBytes.binding.profile","pg18/1"],["limit.relationshipBatch","100"],["limit.relationshipBatch.binding.profile","pg18/1"],["limit.requestBytes","1048576"],["limit.requestBytes.binding.profile","pg18/1"],["limit.responseBytes","8388608"],["limit.responseBytes.binding.profile","pg18/1"],["lintel.execution","1"],["lintel.execution.binding.profile","pg18/1"],["node.refetch","1"],["node.refetch.binding.profile","pg18/1"],["operation.binding/demo/Note/record","pg18/1"],["operation.binding/demo/Task/record","pg18/1"],["read.consistency","request-snapshot-1"],["read.consistency.binding.profile","pg18/1"],["scalar.codec.profile","lintel.scalars/1"],["scalar.codec.profile.binding.profile","pg18/1"]],"exposureBase64":"eyJhcHBsaWNhdGlvbiI6ImZpeHR1cmUtYXBwIiwiY29ubmVjdGlvbnMiOlt7Im5hbWUiOiJub3RlcyIsInJlY29yZCI6eyJlbGVtZW50IjoiTm90ZSIsIm1vZHVsZSI6ImRlbW8ifX0seyJuYW1lIjoidGFza3MiLCJyZWNvcmQiOnsiZWxlbWVudCI6IlRhc2siLCJtb2R1bGUiOiJkZW1vIn19XSwiZm9ybWF0IjoibGludGVsLmV4cG9zdXJlLzMiLCJpZGVudGl0eU5hbWVzcGFjZSI6ImZpeHR1cmUuZGVtby52MSIsIm11dGF0aW9ucyI6W10sInJlY29yZHMiOlt7ImZpZWxkcyI6W3siZmllbGQiOnsiZWxlbWVudCI6Im93bmVyIiwibW9kdWxlIjoiZGVtbyJ9LCJuYW1lIjoib3duZXIifSx7ImZpZWxkIjp7ImVsZW1lbnQiOiJlbmFibGVkIiwibW9kdWxlIjoiZGVtbyJ9LCJuYW1lIjoiZW5hYmxlZCJ9LHsiZmllbGQiOnsiZWxlbWVudCI6ImFtb3VudCIsIm1vZHVsZSI6ImRlbW8ifSwibmFtZSI6ImFtb3VudCJ9LHsiZmllbGQiOnsiZWxlbWVudCI6InBheWxvYWQiLCJtb2R1bGUiOiJkZW1vIn0sIm5hbWUiOiJwYXlsb2FkIn1dLCJrZXkiOiJwcmltYXJ5IiwibG9va3VwIjp7ImlkIjoiTm90ZSIsImtpbmQiOiJyZWNvcmQiLCJtb2R1bGUiOiJkZW1vIn0sInJlY29yZCI6eyJlbGVtZW50IjoiTm90ZSIsIm1vZHVsZSI6ImRlbW8ifSwicmVsYXRpb25zaGlwcyI6W10sInR5cGVOYW1lIjoiTm90ZSJ9LHsiZmllbGRzIjpbeyJmaWVsZCI6eyJlbGVtZW50IjoidGFza1ZhbHVlIiwibW9kdWxlIjoiZGVtbyJ9LCJuYW1lIjoidGFza1ZhbHVlIn1dLCJrZXkiOiJwcmltYXJ5IiwibG9va3VwIjp7ImlkIjoiVGFzayIsImtpbmQiOiJyZWNvcmQiLCJtb2R1bGUiOiJkZW1vIn0sInJlY29yZCI6eyJlbGVtZW50IjoiVGFzayIsIm1vZHVsZSI6ImRlbW8ifSwicmVsYXRpb25zaGlwcyI6W10sInR5cGVOYW1lIjoiVGFzayJ9XX0=","exposureSha256":"55cc8be0dce551437a08eaac854eaaada72d4dab3213e1efa2d937599d38a810","generatedConnections":[{"fieldRefs":[{"element":"amount","module":"demo"},{"element":"enabled","module":"demo"},{"element":"owner","module":"demo"},{"element":"payload","module":"demo"}],"lookup":{"id":"Note","kind":"record","module":"demo"},"primaryKeyField":{"element":"id","module":"demo"},"profile":{"allowedFieldProfile":{"body":{"fields":[{"fieldId":"demo/amount","nullable":false,"output":{"carrier":"decimal","name":"__weft_field_3","nativeType":{"kind":"numeric","precision":8,"scale":2},"nullable":false,"oid":1700},"scalar":"decimal","sourceField":{"element":"amount","module":"demo"}},{"fieldId":"demo/enabled","nullable":false,"output":{"carrier":"boolean","name":"__weft_field_2","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"scalar":"boolean","sourceField":{"element":"enabled","module":"demo"}},{"fieldId":"demo/id","nullable":false,"output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"id","module":"demo"}},{"fieldId":"demo/owner","nullable":false,"output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"owner","module":"demo"}},{"fieldId":"demo/payload","nullable":false,"output":{"carrier":"string","name":"__weft_field_4","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"payload","module":"demo"}}],"scalarCodecProfile":"lintel.scalars/1","version":"umf.allowed-connection-fields/1"},"digest":"6ab92fc7b512a12224182563da9fd3eeffaa5ee02c3e21292cbaebe959f61f5f","version":"umf.allowed-connection-fields/1"},"connectionProfile":"connection.forward=edge-cursor-1","readProfile":"weft.generated-read-algebra/7"}},{"fieldRefs":[{"element":"taskValue","module":"demo"}],"lookup":{"id":"Task","kind":"record","module":"demo"},"primaryKeyField":{"element":"taskId","module":"demo"},"profile":{"allowedFieldProfile":{"body":{"fields":[{"fieldId":"demo/taskId","nullable":false,"output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"taskId","module":"demo"}},{"fieldId":"demo/taskValue","nullable":false,"output":{"carrier":"string","name":"__weft_field_2","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"taskValue","module":"demo"}}],"scalarCodecProfile":"lintel.scalars/1","version":"umf.allowed-connection-fields/1"},"digest":"0ceed8e5cb3ab216a18614d981054a8349f163f561e20767ed9a63af8ddcdd2c","version":"umf.allowed-connection-fields/1"},"connectionProfile":"connection.forward=edge-cursor-1","readProfile":"weft.generated-read-algebra/7"}}],"generatedRoots":[{"algebraSha256":"7248713150673a9707d646daa4b0b8b248d119769619646cc00163a017d6f935","artifactDigest":"ac137c89d2b30ba26a09e183140bba01f7301499efa0fb11926c47e220ec53cb","bindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4","lookup":{"id":"Note","kind":"record","module":"demo"},"primaryKeyId":"primary","receiptDigest":"327afbccd4287fa5ce52c2090833e42d29ffcb9f6543b949a2b18b789142bb2e","sourceDigest":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"},{"algebraSha256":"7248713150673a9707d646daa4b0b8b248d119769619646cc00163a017d6f935","artifactDigest":"ac137c89d2b30ba26a09e183140bba01f7301499efa0fb11926c47e220ec53cb","bindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4","lookup":{"id":"Task","kind":"record","module":"demo"},"primaryKeyId":"primary","receiptDigest":"327afbccd4287fa5ce52c2090833e42d29ffcb9f6543b949a2b18b789142bb2e","sourceDigest":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"}],"hostProfile":{"introspection":true,"limits":[["cursorBytes","4096"],["deadlineMs","30000"],["defaultPage","25"],["documentBytes","262144"],["invocationKeyBytes","128"],["maxAliases","32"],["maxConcurrentDispatch","8"],["maxCost","10000"],["maxDepth","8"],["maxFieldOccurrences","256"],["maxLookup","100"],["maxMutationFields","4"],["maxPage","100"],["maxRelationshipHops","1"],["nodeIdBytes","2048"],["relationshipBatch","100"],["requestBytes","1048576"],["responseBytes","8388608"]],"mount":"/graphql"},"identityNamespace":"fixture.demo.v1","records":[{"fields":[{"name":"amount","nullable":false,"scalar":"decimal","source":{"element":"amount","module":"demo"}},{"name":"enabled","nullable":false,"scalar":"boolean","source":{"element":"enabled","module":"demo"}},{"name":"owner","nullable":false,"scalar":"string","source":{"element":"owner","module":"demo"}},{"name":"payload","nullable":false,"scalar":"string","source":{"element":"payload","module":"demo"}}],"keyFields":[{"element":"id","module":"demo"}],"keyId":"primary","lookup":{"id":"Note","kind":"record","module":"demo"},"source":{"element":"Note","module":"demo"},"typeName":"Note"},{"fields":[{"name":"taskValue","nullable":false,"scalar":"string","source":{"element":"taskValue","module":"demo"}}],"keyFields":[{"element":"taskId","module":"demo"}],"keyId":"primary","lookup":{"id":"Task","kind":"record","module":"demo"},"source":{"element":"Task","module":"demo"},"typeName":"Task"}],"scalarCodecProfile":"lintel.scalars/1","schemaDigest":"73a79839011d5d249ef399b51a431d475fa8bb4e22befd33597feaabf122aa3c","sdl":"scalar Decimal\n\ninterface Node {\n id: ID!\n}\n\ntype Note implements Node {\n amount: Decimal!\n enabled: Boolean!\n id: ID!\n owner: String!\n payload: String!\n}\n\ntype NoteConnection {\n edges: [NoteEdge!]!\n pageInfo: PageInfo!\n}\n\ntype NoteEdge {\n cursor: String!\n node: Note!\n}\n\ntype PageInfo {\n endCursor: String\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n startCursor: String\n}\n\ntype Query {\n node(id: ID!): Node\n nodes(ids: [ID!]!): [Node]!\n notes(after: String, first: Int = 25): NoteConnection!\n tasks(after: String, first: Int = 25): TaskConnection!\n}\n\ntype Task implements Node {\n id: ID!\n taskValue: String!\n}\n\ntype TaskConnection {\n edges: [TaskEdge!]!\n pageInfo: PageInfo!\n}\n\ntype TaskEdge {\n cursor: String!\n node: Task!\n}\n","sources":[{"identity":"synthetic-table-lifecycle","sha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"}],"version":"lintel.prepared-api/4"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-rich/prepared-api-v4-rich-trust.json b/tests/runtime/fixtures/generated-page7-rich/prepared-api-v4-rich-trust.json new file mode 100644 index 0000000..5d08f43 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/prepared-api-v4-rich-trust.json @@ -0,0 +1 @@ +{"apiDigest":"86281b7304b6bdbd64c15a858d72187bc2615696a4bbc50934294975761de59b","application":"fixture-app","artifactDigest":"f55270456afbbac1a308a236d30bb9865a0c34a09a01fc95bdcf98394b77ebe6","artifactSha256":"f13945c7e8fcb1b981a8c3d3a2977c3f85589825373e3992d8481ec371f5d084","bindingProfile":"pg18/1","capabilities":[["binding.profile","pg18/1"],["connection.forward","edge-cursor-1"],["connection.forward.binding.profile","pg18/1"],["identity.codec","lintel.node-id.string-key/1"],["identity.codec.binding.profile","pg18/1"],["limit.cursorBytes","4096"],["limit.cursorBytes.binding.profile","pg18/1"],["limit.deadlineMs","30000"],["limit.deadlineMs.binding.profile","pg18/1"],["limit.defaultPage","25"],["limit.defaultPage.binding.profile","pg18/1"],["limit.documentBytes","262144"],["limit.documentBytes.binding.profile","pg18/1"],["limit.invocationKeyBytes","128"],["limit.invocationKeyBytes.binding.profile","pg18/1"],["limit.maxAliases","32"],["limit.maxAliases.binding.profile","pg18/1"],["limit.maxConcurrentDispatch","8"],["limit.maxConcurrentDispatch.binding.profile","pg18/1"],["limit.maxCost","10000"],["limit.maxCost.binding.profile","pg18/1"],["limit.maxDepth","8"],["limit.maxDepth.binding.profile","pg18/1"],["limit.maxFieldOccurrences","256"],["limit.maxFieldOccurrences.binding.profile","pg18/1"],["limit.maxLookup","100"],["limit.maxLookup.binding.profile","pg18/1"],["limit.maxMutationFields","4"],["limit.maxMutationFields.binding.profile","pg18/1"],["limit.maxPage","100"],["limit.maxPage.binding.profile","pg18/1"],["limit.maxRelationshipHops","1"],["limit.maxRelationshipHops.binding.profile","pg18/1"],["limit.nodeIdBytes","2048"],["limit.nodeIdBytes.binding.profile","pg18/1"],["limit.relationshipBatch","100"],["limit.relationshipBatch.binding.profile","pg18/1"],["limit.requestBytes","1048576"],["limit.requestBytes.binding.profile","pg18/1"],["limit.responseBytes","8388608"],["limit.responseBytes.binding.profile","pg18/1"],["lintel.execution","1"],["lintel.execution.binding.profile","pg18/1"],["node.refetch","1"],["node.refetch.binding.profile","pg18/1"],["operation.binding/demo/Note/record","pg18/1"],["operation.binding/demo/Task/record","pg18/1"],["read.consistency","request-snapshot-1"],["read.consistency.binding.profile","pg18/1"],["scalar.codec.profile","lintel.scalars/1"],["scalar.codec.profile.binding.profile","pg18/1"]],"exposureSha256":"55cc8be0dce551437a08eaac854eaaada72d4dab3213e1efa2d937599d38a810","generatedConnectionsSha256":"7b59b2ab094197aee51093b14c47848d69ee8d4f10dc585e15b65341da5172f1","generatedRootsSha256":"c37557e4f809a40838c365a6e887b66d42609d730f269c2f06d9359bc8132c4e","limits":[["cursorBytes","4096"],["deadlineMs","30000"],["defaultPage","25"],["documentBytes","262144"],["invocationKeyBytes","128"],["maxAliases","32"],["maxConcurrentDispatch","8"],["maxCost","10000"],["maxDepth","8"],["maxFieldOccurrences","256"],["maxLookup","100"],["maxMutationFields","4"],["maxPage","100"],["maxRelationshipHops","1"],["nodeIdBytes","2048"],["relationshipBatch","100"],["requestBytes","1048576"],["responseBytes","8388608"]],"scalarCodecProfile":"lintel.scalars/1","sources":[{"identity":"synthetic-table-lifecycle","sha256":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7"}]} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-rich/target.json b/tests/runtime/fixtures/generated-page7-rich/target.json new file mode 100644 index 0000000..40a985a --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/target.json @@ -0,0 +1 @@ +{"bindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4","id":"postgresql18","profile":"pg18/1","version":"18"} \ No newline at end of file diff --git a/tests/runtime/fixtures/generated-page7-rich/trusted-artifact.json b/tests/runtime/fixtures/generated-page7-rich/trusted-artifact.json new file mode 100644 index 0000000..d0535c3 --- /dev/null +++ b/tests/runtime/fixtures/generated-page7-rich/trusted-artifact.json @@ -0,0 +1 @@ +{"artifactDigest":"ac137c89d2b30ba26a09e183140bba01f7301499efa0fb11926c47e220ec53cb","artifactId":"batten-profile7-provenance-60857a91268e2e4c","buildId":"batten7-prov-60857a91268e2e4c","inventory":[["algebra/read.json","7248713150673a9707d646daa4b0b8b248d119769619646cc00163a017d6f935"],["native/native-table-source.json","d6acc1f919b2df759a1bbe1f88569373bfc30275c297f7c63a531417563e10a1"]],"issuer":"task-local-fabricated-pg18-fixture","payloadDigest":"0823215fc0ddea06a8e3440fd4824160427b164fec9e02738caa574c10522cb2","receiptDigest":"327afbccd4287fa5ce52c2090833e42d29ffcb9f6543b949a2b18b789142bb2e","sourceDigest":"76d0ecb0697900a0ed3ec8170f21dedc414349e0d38c40ecedaf8bfdefb8d7f7","targetBindingDigest":"4aea9e1e017313807286d666178f23439a66e492277b9f120a791308fddc3fe4"} \ No newline at end of file diff --git a/tests/runtime/fixtures/prepared-api-v3-four-fields-proof.json b/tests/runtime/fixtures/prepared-api-v3-four-fields-proof.json new file mode 100644 index 0000000..c81db83 --- /dev/null +++ b/tests/runtime/fixtures/prepared-api-v3-four-fields-proof.json @@ -0,0 +1 @@ +{"apiDigest":"bf0a7712a0175cce95280a7dcd0f150604dba7e44bfbdae35f7db3a84b6ac105","application":"fixture-app","artifactDigest":"cab24da3fcf113acc7a59c4c58d1a3f65d9c8c33802e43129792a53eb1f0bc11","artifactId":"bf0a7712a0175cce95280a7dcd0f150604dba7e44bfbdae35f7db3a84b6ac105","bindingProfile":"pg18/1","capabilities":[["binding.profile","pg18/1"],["connection.forward","edge-cursor-1"],["connection.forward.binding.profile","pg18/1"],["identity.codec","lintel.node-id.string-key/1"],["identity.codec.binding.profile","pg18/1"],["limit.cursorBytes","4096"],["limit.cursorBytes.binding.profile","pg18/1"],["limit.deadlineMs","30000"],["limit.deadlineMs.binding.profile","pg18/1"],["limit.defaultPage","25"],["limit.defaultPage.binding.profile","pg18/1"],["limit.documentBytes","262144"],["limit.documentBytes.binding.profile","pg18/1"],["limit.invocationKeyBytes","128"],["limit.invocationKeyBytes.binding.profile","pg18/1"],["limit.maxAliases","32"],["limit.maxAliases.binding.profile","pg18/1"],["limit.maxConcurrentDispatch","8"],["limit.maxConcurrentDispatch.binding.profile","pg18/1"],["limit.maxCost","10000"],["limit.maxCost.binding.profile","pg18/1"],["limit.maxDepth","8"],["limit.maxDepth.binding.profile","pg18/1"],["limit.maxFieldOccurrences","256"],["limit.maxFieldOccurrences.binding.profile","pg18/1"],["limit.maxLookup","100"],["limit.maxLookup.binding.profile","pg18/1"],["limit.maxMutationFields","4"],["limit.maxMutationFields.binding.profile","pg18/1"],["limit.maxPage","100"],["limit.maxPage.binding.profile","pg18/1"],["limit.maxRelationshipHops","1"],["limit.maxRelationshipHops.binding.profile","pg18/1"],["limit.nodeIdBytes","2048"],["limit.nodeIdBytes.binding.profile","pg18/1"],["limit.relationshipBatch","100"],["limit.relationshipBatch.binding.profile","pg18/1"],["limit.requestBytes","1048576"],["limit.requestBytes.binding.profile","pg18/1"],["limit.responseBytes","8388608"],["limit.responseBytes.binding.profile","pg18/1"],["lintel.execution","1"],["lintel.execution.binding.profile","pg18/1"],["node.refetch","1"],["node.refetch.binding.profile","pg18/1"],["operation.binding/demo/Note/record","pg18/1"],["operation.binding/demo/Task/record","pg18/1"],["read.consistency","request-snapshot-1"],["read.consistency.binding.profile","pg18/1"],["scalar.codec.profile","lintel.scalars/1"],["scalar.codec.profile.binding.profile","pg18/1"]],"exposureBase64":"eyJmb3JtYXQiOiJsaW50ZWwuZXhwb3N1cmUvMyIsImFwcGxpY2F0aW9uIjoiZml4dHVyZS1hcHAiLCJpZGVudGl0eU5hbWVzcGFjZSI6ImZpeHR1cmUuZGVtby52MSIsInJlY29yZHMiOlt7InJlY29yZCI6eyJtb2R1bGUiOiJkZW1vIiwiZWxlbWVudCI6Ik5vdGUifSwia2V5IjoicHJpbWFyeSIsInR5cGVOYW1lIjoiTm90ZSIsImxvb2t1cCI6eyJtb2R1bGUiOiJkZW1vIiwiaWQiOiJOb3RlIiwia2luZCI6InJlY29yZCJ9LCJmaWVsZHMiOlt7ImZpZWxkIjp7Im1vZHVsZSI6ImRlbW8iLCJlbGVtZW50Ijoib3duZXIifSwibmFtZSI6Im93bmVyIn0seyJmaWVsZCI6eyJtb2R1bGUiOiJkZW1vIiwiZWxlbWVudCI6ImVuYWJsZWQifSwibmFtZSI6ImVuYWJsZWQifSx7ImZpZWxkIjp7Im1vZHVsZSI6ImRlbW8iLCJlbGVtZW50IjoiYW1vdW50In0sIm5hbWUiOiJhbW91bnQifSx7ImZpZWxkIjp7Im1vZHVsZSI6ImRlbW8iLCJlbGVtZW50IjoicGF5bG9hZCJ9LCJuYW1lIjoicGF5bG9hZCJ9XSwicmVsYXRpb25zaGlwcyI6W119LHsicmVjb3JkIjp7Im1vZHVsZSI6ImRlbW8iLCJlbGVtZW50IjoiVGFzayJ9LCJrZXkiOiJwcmltYXJ5IiwidHlwZU5hbWUiOiJUYXNrIiwibG9va3VwIjp7Im1vZHVsZSI6ImRlbW8iLCJpZCI6IlRhc2siLCJraW5kIjoicmVjb3JkIn0sImZpZWxkcyI6W3siZmllbGQiOnsibW9kdWxlIjoiZGVtbyIsImVsZW1lbnQiOiJ0YXNrX3ZhbHVlIn0sIm5hbWUiOiJ0YXNrX3ZhbHVlIn1dLCJyZWxhdGlvbnNoaXBzIjpbXX1dLCJjb25uZWN0aW9ucyI6W3sibmFtZSI6Im5vdGVzIiwicmVjb3JkIjp7Im1vZHVsZSI6ImRlbW8iLCJlbGVtZW50IjoiTm90ZSJ9fSx7Im5hbWUiOiJ0YXNrcyIsInJlY29yZCI6eyJtb2R1bGUiOiJkZW1vIiwiZWxlbWVudCI6IlRhc2sifX1dLCJtdXRhdGlvbnMiOltdfQ==","exposureSha256":"ea5664b9e8d5f4373de89bbb5ba9939951e0c0033b841440ec52a32058e654ca","generatedConnections":[{"fieldRefs":[{"element":"amount","module":"demo"},{"element":"enabled","module":"demo"},{"element":"owner","module":"demo"},{"element":"payload","module":"demo"}],"lookup":{"id":"Note","kind":"record","module":"demo"},"primaryKeyField":{"element":"id","module":"demo"},"profile":{"allowedFieldProfile":{"body":{"fields":[{"fieldId":"demo/amount","nullable":false,"output":{"carrier":"decimal","name":"__weft_field_4","nativeType":{"kind":"numeric","precision":8,"scale":2},"nullable":false,"oid":1700},"scalar":"decimal","sourceField":{"element":"amount","module":"demo"}},{"fieldId":"demo/enabled","nullable":false,"output":{"carrier":"boolean","name":"__weft_field_2","nativeType":{"kind":"boolean"},"nullable":false,"oid":16},"scalar":"boolean","sourceField":{"element":"enabled","module":"demo"}},{"fieldId":"demo/id","nullable":false,"output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"id","module":"demo"}},{"fieldId":"demo/owner","nullable":false,"output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"owner","module":"demo"}},{"fieldId":"demo/payload","nullable":false,"output":{"carrier":"string","name":"__weft_field_8","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"payload","module":"demo"}}],"scalarCodecProfile":"lintel.scalars/1","version":"umf.allowed-connection-fields/1"},"digest":"0f5b277bc12f5fc4cf5a46e2f102528e2c6dd379c579f639ad9cc4d482208fe1","version":"umf.allowed-connection-fields/1"},"connectionProfile":"connection.forward=edge-cursor-1","readProfile":"weft.generated-read-algebra/5"}},{"fieldRefs":[{"element":"task_value","module":"demo"}],"lookup":{"id":"Task","kind":"record","module":"demo"},"primaryKeyField":{"element":"task_id","module":"demo"},"profile":{"allowedFieldProfile":{"body":{"fields":[{"fieldId":"demo/task_id","nullable":false,"output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"task_id","module":"demo"}},{"fieldId":"demo/task_value","nullable":false,"output":{"carrier":"string","name":"__weft_field_2","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"task_value","module":"demo"}}],"scalarCodecProfile":"lintel.scalars/1","version":"umf.allowed-connection-fields/1"},"digest":"493a58e4dccd7444433c73a23b7cb78c092b91c11f2d36785f536261b38d03a5","version":"umf.allowed-connection-fields/1"},"connectionProfile":"connection.forward=edge-cursor-1","readProfile":"weft.generated-read-algebra/5"}}],"generatedRoots":[{"algebraSha256":"23a2838e9786f0e78e4163b81fb2054c5c3e4f8e076cd66edd3b27a46a99a2b2","artifactDigest":"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda","bindingDigest":"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf","lookup":{"id":"Note","kind":"record","module":"demo"},"primaryKeyId":"primary","receiptDigest":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","sourceDigest":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"},{"algebraSha256":"23a2838e9786f0e78e4163b81fb2054c5c3e4f8e076cd66edd3b27a46a99a2b2","artifactDigest":"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda","bindingDigest":"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf","lookup":{"id":"Task","kind":"record","module":"demo"},"primaryKeyId":"primary","receiptDigest":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","sourceDigest":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"}],"hostProfile":{"introspection":true,"limits":[["cursorBytes","4096"],["deadlineMs","30000"],["defaultPage","25"],["documentBytes","262144"],["invocationKeyBytes","128"],["maxAliases","32"],["maxConcurrentDispatch","8"],["maxCost","10000"],["maxDepth","8"],["maxFieldOccurrences","256"],["maxLookup","100"],["maxMutationFields","4"],["maxPage","100"],["maxRelationshipHops","1"],["nodeIdBytes","2048"],["relationshipBatch","100"],["requestBytes","1048576"],["responseBytes","8388608"]],"mount":"/graphql"},"identityNamespace":"fixture.demo.v1","records":[{"fields":[{"name":"amount","nullable":false,"scalar":"decimal","source":{"element":"amount","module":"demo"}},{"name":"enabled","nullable":false,"scalar":"boolean","source":{"element":"enabled","module":"demo"}},{"name":"owner","nullable":false,"scalar":"string","source":{"element":"owner","module":"demo"}},{"name":"payload","nullable":false,"scalar":"string","source":{"element":"payload","module":"demo"}}],"keyFields":[{"element":"id","module":"demo"}],"keyId":"primary","lookup":{"id":"Note","kind":"record","module":"demo"},"source":{"element":"Note","module":"demo"},"typeName":"Note"},{"fields":[{"name":"task_value","nullable":false,"scalar":"string","source":{"element":"task_value","module":"demo"}}],"keyFields":[{"element":"task_id","module":"demo"}],"keyId":"primary","lookup":{"id":"Task","kind":"record","module":"demo"},"source":{"element":"Task","module":"demo"},"typeName":"Task"}],"scalarCodecProfile":"lintel.scalars/1","schemaDigest":"927a32ca59a8abe64c69afbc1e6658ef8c47b7b2ce6786d2702e3d4a4186cf9b","sdl":"scalar Decimal\n\ninterface Node {\n id: ID!\n}\n\ntype Note implements Node {\n amount: Decimal!\n enabled: Boolean!\n id: ID!\n owner: String!\n payload: String!\n}\n\ntype NoteConnection {\n edges: [NoteEdge!]!\n pageInfo: PageInfo!\n}\n\ntype NoteEdge {\n cursor: String!\n node: Note!\n}\n\ntype PageInfo {\n endCursor: String\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n startCursor: String\n}\n\ntype Query {\n node(id: ID!): Node\n nodes(ids: [ID!]!): [Node]!\n notes(after: String, first: Int = 25): NoteConnection!\n tasks(after: String, first: Int = 25): TaskConnection!\n}\n\ntype Task implements Node {\n id: ID!\n task_value: String!\n}\n\ntype TaskConnection {\n edges: [TaskEdge!]!\n pageInfo: PageInfo!\n}\n\ntype TaskEdge {\n cursor: String!\n node: Task!\n}\n","sources":[{"identity":"synthetic-table-lifecycle","sha256":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"}],"version":"lintel.prepared-api/3"} \ No newline at end of file diff --git a/tests/runtime/fixtures/prepared-api-v3-four-fields-trust.json b/tests/runtime/fixtures/prepared-api-v3-four-fields-trust.json new file mode 100644 index 0000000..5b5f682 --- /dev/null +++ b/tests/runtime/fixtures/prepared-api-v3-four-fields-trust.json @@ -0,0 +1 @@ +{"apiDigest":"bf0a7712a0175cce95280a7dcd0f150604dba7e44bfbdae35f7db3a84b6ac105","application":"fixture-app","artifactDigest":"cab24da3fcf113acc7a59c4c58d1a3f65d9c8c33802e43129792a53eb1f0bc11","artifactSha256":"89a90a95e80c4b104f3f6e25ff3f62ab258b903b7f9c8e39dfb7a9bf641c52d2","bindingProfile":"pg18/1","capabilities":[["binding.profile","pg18/1"],["connection.forward","edge-cursor-1"],["connection.forward.binding.profile","pg18/1"],["identity.codec","lintel.node-id.string-key/1"],["identity.codec.binding.profile","pg18/1"],["limit.cursorBytes","4096"],["limit.cursorBytes.binding.profile","pg18/1"],["limit.deadlineMs","30000"],["limit.deadlineMs.binding.profile","pg18/1"],["limit.defaultPage","25"],["limit.defaultPage.binding.profile","pg18/1"],["limit.documentBytes","262144"],["limit.documentBytes.binding.profile","pg18/1"],["limit.invocationKeyBytes","128"],["limit.invocationKeyBytes.binding.profile","pg18/1"],["limit.maxAliases","32"],["limit.maxAliases.binding.profile","pg18/1"],["limit.maxConcurrentDispatch","8"],["limit.maxConcurrentDispatch.binding.profile","pg18/1"],["limit.maxCost","10000"],["limit.maxCost.binding.profile","pg18/1"],["limit.maxDepth","8"],["limit.maxDepth.binding.profile","pg18/1"],["limit.maxFieldOccurrences","256"],["limit.maxFieldOccurrences.binding.profile","pg18/1"],["limit.maxLookup","100"],["limit.maxLookup.binding.profile","pg18/1"],["limit.maxMutationFields","4"],["limit.maxMutationFields.binding.profile","pg18/1"],["limit.maxPage","100"],["limit.maxPage.binding.profile","pg18/1"],["limit.maxRelationshipHops","1"],["limit.maxRelationshipHops.binding.profile","pg18/1"],["limit.nodeIdBytes","2048"],["limit.nodeIdBytes.binding.profile","pg18/1"],["limit.relationshipBatch","100"],["limit.relationshipBatch.binding.profile","pg18/1"],["limit.requestBytes","1048576"],["limit.requestBytes.binding.profile","pg18/1"],["limit.responseBytes","8388608"],["limit.responseBytes.binding.profile","pg18/1"],["lintel.execution","1"],["lintel.execution.binding.profile","pg18/1"],["node.refetch","1"],["node.refetch.binding.profile","pg18/1"],["operation.binding/demo/Note/record","pg18/1"],["operation.binding/demo/Task/record","pg18/1"],["read.consistency","request-snapshot-1"],["read.consistency.binding.profile","pg18/1"],["scalar.codec.profile","lintel.scalars/1"],["scalar.codec.profile.binding.profile","pg18/1"]],"exposureSha256":"ea5664b9e8d5f4373de89bbb5ba9939951e0c0033b841440ec52a32058e654ca","generatedConnectionsSha256":"a2bd39d9d7f01328cc2c7ec71c39731d9aff9becdd3a31b1d0c8ab96d2c73ad1","generatedRootsSha256":"5c1ba934ee8526d2dc6bb6f89f1d6a6c2cf44069c0c796052af4bc53ebc3315c","limits":[["cursorBytes","4096"],["deadlineMs","30000"],["defaultPage","25"],["documentBytes","262144"],["invocationKeyBytes","128"],["maxAliases","32"],["maxConcurrentDispatch","8"],["maxCost","10000"],["maxDepth","8"],["maxFieldOccurrences","256"],["maxLookup","100"],["maxMutationFields","4"],["maxPage","100"],["maxRelationshipHops","1"],["nodeIdBytes","2048"],["relationshipBatch","100"],["requestBytes","1048576"],["responseBytes","8388608"]],"scalarCodecProfile":"lintel.scalars/1","sourceSha256":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8","sources":[{"identity":"synthetic-table-lifecycle","sha256":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"}],"targetBindingDigest":"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf","upstreamArtifactDigest":"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda"} diff --git a/tests/runtime/fixtures/prepared-api-v3-strict5-proof.json b/tests/runtime/fixtures/prepared-api-v3-strict5-proof.json new file mode 100644 index 0000000..594f4fc --- /dev/null +++ b/tests/runtime/fixtures/prepared-api-v3-strict5-proof.json @@ -0,0 +1 @@ +{"apiDigest":"df8642490abd76e8e3597b96080bf4e7609aeaecb0fbab6b6848076bce52c303","application":"fixture-app","artifactDigest":"01d6b671d3352cf90eb9f9ce0db9597809af5122185377697fd74cd728eedb34","artifactId":"df8642490abd76e8e3597b96080bf4e7609aeaecb0fbab6b6848076bce52c303","bindingProfile":"pg18/1","capabilities":[["binding.profile","pg18/1"],["connection.forward","edge-cursor-1"],["connection.forward.binding.profile","pg18/1"],["identity.codec","lintel.node-id.string-key/1"],["identity.codec.binding.profile","pg18/1"],["limit.cursorBytes","4096"],["limit.cursorBytes.binding.profile","pg18/1"],["limit.deadlineMs","30000"],["limit.deadlineMs.binding.profile","pg18/1"],["limit.defaultPage","25"],["limit.defaultPage.binding.profile","pg18/1"],["limit.documentBytes","262144"],["limit.documentBytes.binding.profile","pg18/1"],["limit.invocationKeyBytes","128"],["limit.invocationKeyBytes.binding.profile","pg18/1"],["limit.maxAliases","32"],["limit.maxAliases.binding.profile","pg18/1"],["limit.maxConcurrentDispatch","8"],["limit.maxConcurrentDispatch.binding.profile","pg18/1"],["limit.maxCost","10000"],["limit.maxCost.binding.profile","pg18/1"],["limit.maxDepth","8"],["limit.maxDepth.binding.profile","pg18/1"],["limit.maxFieldOccurrences","256"],["limit.maxFieldOccurrences.binding.profile","pg18/1"],["limit.maxLookup","100"],["limit.maxLookup.binding.profile","pg18/1"],["limit.maxMutationFields","4"],["limit.maxMutationFields.binding.profile","pg18/1"],["limit.maxPage","100"],["limit.maxPage.binding.profile","pg18/1"],["limit.maxRelationshipHops","1"],["limit.maxRelationshipHops.binding.profile","pg18/1"],["limit.nodeIdBytes","2048"],["limit.nodeIdBytes.binding.profile","pg18/1"],["limit.relationshipBatch","100"],["limit.relationshipBatch.binding.profile","pg18/1"],["limit.requestBytes","1048576"],["limit.requestBytes.binding.profile","pg18/1"],["limit.responseBytes","8388608"],["limit.responseBytes.binding.profile","pg18/1"],["lintel.execution","1"],["lintel.execution.binding.profile","pg18/1"],["node.refetch","1"],["node.refetch.binding.profile","pg18/1"],["operation.binding/demo/Note/record","pg18/1"],["operation.binding/demo/Task/record","pg18/1"],["read.consistency","request-snapshot-1"],["read.consistency.binding.profile","pg18/1"],["scalar.codec.profile","lintel.scalars/1"],["scalar.codec.profile.binding.profile","pg18/1"]],"exposureBase64":"eyJhcHBsaWNhdGlvbiI6ImZpeHR1cmUtYXBwIiwiY29ubmVjdGlvbnMiOlt7Im5hbWUiOiJub3RlcyIsInJlY29yZCI6eyJlbGVtZW50IjoiTm90ZSIsIm1vZHVsZSI6ImRlbW8ifX0seyJuYW1lIjoidGFza3MiLCJyZWNvcmQiOnsiZWxlbWVudCI6IlRhc2siLCJtb2R1bGUiOiJkZW1vIn19XSwiZm9ybWF0IjoibGludGVsLmV4cG9zdXJlLzMiLCJpZGVudGl0eU5hbWVzcGFjZSI6ImZpeHR1cmUuZGVtby52MSIsIm11dGF0aW9ucyI6W10sInJlY29yZHMiOlt7ImZpZWxkcyI6W3siZmllbGQiOnsiZWxlbWVudCI6Im93bmVyIiwibW9kdWxlIjoiZGVtbyJ9LCJuYW1lIjoib3duZXIifSx7ImZpZWxkIjp7ImVsZW1lbnQiOiJhbW91bnQiLCJtb2R1bGUiOiJkZW1vIn0sIm5hbWUiOiJhbW91bnQifV0sImtleSI6InByaW1hcnkiLCJsb29rdXAiOnsiaWQiOiJOb3RlIiwia2luZCI6InJlY29yZCIsIm1vZHVsZSI6ImRlbW8ifSwicmVjb3JkIjp7ImVsZW1lbnQiOiJOb3RlIiwibW9kdWxlIjoiZGVtbyJ9LCJyZWxhdGlvbnNoaXBzIjpbXSwidHlwZU5hbWUiOiJOb3RlIn0seyJmaWVsZHMiOlt7ImZpZWxkIjp7ImVsZW1lbnQiOiJ0YXNrX3ZhbHVlIiwibW9kdWxlIjoiZGVtbyJ9LCJuYW1lIjoidmFsdWUifV0sImtleSI6InByaW1hcnkiLCJsb29rdXAiOnsiaWQiOiJUYXNrIiwia2luZCI6InJlY29yZCIsIm1vZHVsZSI6ImRlbW8ifSwicmVjb3JkIjp7ImVsZW1lbnQiOiJUYXNrIiwibW9kdWxlIjoiZGVtbyJ9LCJyZWxhdGlvbnNoaXBzIjpbXSwidHlwZU5hbWUiOiJUYXNrIn1dfQ==","exposureSha256":"13b38cdd2d14a41668a93bd20b5f97bd5da4043623470cd39e4285e644d29366","generatedConnections":[{"fieldRefs":[{"element":"amount","module":"demo"},{"element":"owner","module":"demo"}],"lookup":{"id":"Note","kind":"record","module":"demo"},"primaryKeyField":{"element":"id","module":"demo"},"profile":{"allowedFieldProfile":{"body":{"fields":[{"fieldId":"demo/amount","nullable":false,"output":{"carrier":"decimal","name":"__weft_field_4","nativeType":{"kind":"numeric","precision":8,"scale":2},"nullable":false,"oid":1700},"scalar":"decimal","sourceField":{"element":"amount","module":"demo"}},{"fieldId":"demo/id","nullable":false,"output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"id","module":"demo"}},{"fieldId":"demo/owner","nullable":false,"output":{"carrier":"string","name":"__weft_field_1","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"owner","module":"demo"}}],"scalarCodecProfile":"lintel.scalars/1","version":"umf.allowed-connection-fields/1"},"digest":"55e6b9ba726a92b40221d7f952e28acfd41d1995285ff8605c51657d30778a1d","version":"umf.allowed-connection-fields/1"},"connectionProfile":"connection.forward=edge-cursor-1","readProfile":"weft.generated-read-algebra/5"}},{"fieldRefs":[{"element":"task_value","module":"demo"}],"lookup":{"id":"Task","kind":"record","module":"demo"},"primaryKeyField":{"element":"task_id","module":"demo"},"profile":{"allowedFieldProfile":{"body":{"fields":[{"fieldId":"demo/task_id","nullable":false,"output":{"carrier":"string","name":"__weft_field_0","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"task_id","module":"demo"}},{"fieldId":"demo/task_value","nullable":false,"output":{"carrier":"string","name":"__weft_field_2","nativeType":{"kind":"text"},"nullable":false,"oid":25},"scalar":"string","sourceField":{"element":"task_value","module":"demo"}}],"scalarCodecProfile":"lintel.scalars/1","version":"umf.allowed-connection-fields/1"},"digest":"493a58e4dccd7444433c73a23b7cb78c092b91c11f2d36785f536261b38d03a5","version":"umf.allowed-connection-fields/1"},"connectionProfile":"connection.forward=edge-cursor-1","readProfile":"weft.generated-read-algebra/5"}}],"generatedRoots":[{"algebraSha256":"23a2838e9786f0e78e4163b81fb2054c5c3e4f8e076cd66edd3b27a46a99a2b2","artifactDigest":"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda","bindingDigest":"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf","lookup":{"id":"Note","kind":"record","module":"demo"},"primaryKeyId":"primary","receiptDigest":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","sourceDigest":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"},{"algebraSha256":"23a2838e9786f0e78e4163b81fb2054c5c3e4f8e076cd66edd3b27a46a99a2b2","artifactDigest":"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda","bindingDigest":"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf","lookup":{"id":"Task","kind":"record","module":"demo"},"primaryKeyId":"primary","receiptDigest":"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb","sourceDigest":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"}],"hostProfile":{"introspection":true,"limits":[["cursorBytes","4096"],["deadlineMs","30000"],["defaultPage","25"],["documentBytes","262144"],["invocationKeyBytes","128"],["maxAliases","32"],["maxConcurrentDispatch","8"],["maxCost","10000"],["maxDepth","8"],["maxFieldOccurrences","256"],["maxLookup","100"],["maxMutationFields","4"],["maxPage","100"],["maxRelationshipHops","1"],["nodeIdBytes","2048"],["relationshipBatch","100"],["requestBytes","1048576"],["responseBytes","8388608"]],"mount":"/graphql"},"identityNamespace":"fixture.demo.v1","records":[{"fields":[{"name":"amount","nullable":false,"scalar":"decimal","source":{"element":"amount","module":"demo"}},{"name":"owner","nullable":false,"scalar":"string","source":{"element":"owner","module":"demo"}}],"keyFields":[{"element":"id","module":"demo"}],"keyId":"primary","lookup":{"id":"Note","kind":"record","module":"demo"},"source":{"element":"Note","module":"demo"},"typeName":"Note"},{"fields":[{"name":"value","nullable":false,"scalar":"string","source":{"element":"task_value","module":"demo"}}],"keyFields":[{"element":"task_id","module":"demo"}],"keyId":"primary","lookup":{"id":"Task","kind":"record","module":"demo"},"source":{"element":"Task","module":"demo"},"typeName":"Task"}],"scalarCodecProfile":"lintel.scalars/1","schemaDigest":"dbfbca76b2ebac9312f0af5b5efde2a11036d06b5ae503dec9da417ae8fa2600","sdl":"scalar Decimal\n\ninterface Node {\n id: ID!\n}\n\ntype Note implements Node {\n amount: Decimal!\n id: ID!\n owner: String!\n}\n\ntype NoteConnection {\n edges: [NoteEdge!]!\n pageInfo: PageInfo!\n}\n\ntype NoteEdge {\n cursor: String!\n node: Note!\n}\n\ntype PageInfo {\n endCursor: String\n hasNextPage: Boolean!\n hasPreviousPage: Boolean!\n startCursor: String\n}\n\ntype Query {\n node(id: ID!): Node\n nodes(ids: [ID!]!): [Node]!\n notes(after: String, first: Int = 25): NoteConnection!\n tasks(after: String, first: Int = 25): TaskConnection!\n}\n\ntype Task implements Node {\n id: ID!\n value: String!\n}\n\ntype TaskConnection {\n edges: [TaskEdge!]!\n pageInfo: PageInfo!\n}\n\ntype TaskEdge {\n cursor: String!\n node: Task!\n}\n","sources":[{"identity":"synthetic-table-lifecycle","sha256":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"}],"version":"lintel.prepared-api/3"} \ No newline at end of file diff --git a/tests/runtime/fixtures/prepared-api-v3-strict5-trust.json b/tests/runtime/fixtures/prepared-api-v3-strict5-trust.json new file mode 100644 index 0000000..e3df4e9 --- /dev/null +++ b/tests/runtime/fixtures/prepared-api-v3-strict5-trust.json @@ -0,0 +1 @@ +{"apiDigest":"df8642490abd76e8e3597b96080bf4e7609aeaecb0fbab6b6848076bce52c303","application":"fixture-app","artifactDigest":"01d6b671d3352cf90eb9f9ce0db9597809af5122185377697fd74cd728eedb34","artifactSha256":"1126ea1bd72e2925bd994d0c80f645aa8d8f28229d3d66e666c4b66f5767e053","bindingProfile":"pg18/1","capabilities":[["binding.profile","pg18/1"],["connection.forward","edge-cursor-1"],["connection.forward.binding.profile","pg18/1"],["identity.codec","lintel.node-id.string-key/1"],["identity.codec.binding.profile","pg18/1"],["limit.cursorBytes","4096"],["limit.cursorBytes.binding.profile","pg18/1"],["limit.deadlineMs","30000"],["limit.deadlineMs.binding.profile","pg18/1"],["limit.defaultPage","25"],["limit.defaultPage.binding.profile","pg18/1"],["limit.documentBytes","262144"],["limit.documentBytes.binding.profile","pg18/1"],["limit.invocationKeyBytes","128"],["limit.invocationKeyBytes.binding.profile","pg18/1"],["limit.maxAliases","32"],["limit.maxAliases.binding.profile","pg18/1"],["limit.maxConcurrentDispatch","8"],["limit.maxConcurrentDispatch.binding.profile","pg18/1"],["limit.maxCost","10000"],["limit.maxCost.binding.profile","pg18/1"],["limit.maxDepth","8"],["limit.maxDepth.binding.profile","pg18/1"],["limit.maxFieldOccurrences","256"],["limit.maxFieldOccurrences.binding.profile","pg18/1"],["limit.maxLookup","100"],["limit.maxLookup.binding.profile","pg18/1"],["limit.maxMutationFields","4"],["limit.maxMutationFields.binding.profile","pg18/1"],["limit.maxPage","100"],["limit.maxPage.binding.profile","pg18/1"],["limit.maxRelationshipHops","1"],["limit.maxRelationshipHops.binding.profile","pg18/1"],["limit.nodeIdBytes","2048"],["limit.nodeIdBytes.binding.profile","pg18/1"],["limit.relationshipBatch","100"],["limit.relationshipBatch.binding.profile","pg18/1"],["limit.requestBytes","1048576"],["limit.requestBytes.binding.profile","pg18/1"],["limit.responseBytes","8388608"],["limit.responseBytes.binding.profile","pg18/1"],["lintel.execution","1"],["lintel.execution.binding.profile","pg18/1"],["node.refetch","1"],["node.refetch.binding.profile","pg18/1"],["operation.binding/demo/Note/record","pg18/1"],["operation.binding/demo/Task/record","pg18/1"],["read.consistency","request-snapshot-1"],["read.consistency.binding.profile","pg18/1"],["scalar.codec.profile","lintel.scalars/1"],["scalar.codec.profile.binding.profile","pg18/1"]],"exposureSha256":"13b38cdd2d14a41668a93bd20b5f97bd5da4043623470cd39e4285e644d29366","generatedConnectionsSha256":"e7e9b319fac52646b243c18e660892b95735f259366a2fd03f79f042364a5d8b","generatedRootsSha256":"5c1ba934ee8526d2dc6bb6f89f1d6a6c2cf44069c0c796052af4bc53ebc3315c","limits":[["cursorBytes","4096"],["deadlineMs","30000"],["defaultPage","25"],["documentBytes","262144"],["invocationKeyBytes","128"],["maxAliases","32"],["maxConcurrentDispatch","8"],["maxCost","10000"],["maxDepth","8"],["maxFieldOccurrences","256"],["maxLookup","100"],["maxMutationFields","4"],["maxPage","100"],["maxRelationshipHops","1"],["nodeIdBytes","2048"],["relationshipBatch","100"],["requestBytes","1048576"],["responseBytes","8388608"]],"scalarCodecProfile":"lintel.scalars/1","sources":[{"identity":"synthetic-table-lifecycle","sha256":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8"}],"upstreamArtifactDigest":"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda","upstreamSourceSha256":"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8","upstreamTargetBindingDigest":"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf"} diff --git a/tests/runtime/generated_batch_case.py b/tests/runtime/generated_batch_case.py new file mode 100644 index 0000000..7e4ff5b --- /dev/null +++ b/tests/runtime/generated_batch_case.py @@ -0,0 +1,473 @@ +"""Build fixture values for generated v4 provider workflows.""" + +import hashlib +import json +import time +from collections.abc import Mapping +from contextlib import AbstractAsyncContextManager +from dataclasses import replace +from types import SimpleNamespace +from typing import Any, Literal, cast +from unittest.mock import AsyncMock, Mock + +import umf_access.generated as generated_api +from batten.contracts import ( + Actor, + ArtifactRef, + ExecutionScope, + Operation, + OperationCall, + OperationOutcome, + SelectedCallSpec, + SelectedKey, + Selection, +) +from batten.lintel import ExposureConfig, ExposureRecordRoot +from batten.umf_postgres.generated_batch import GeneratedBatchExecution +from batten.umf_postgres.generated_table import GeneratedTableExecution +from lintel.ports import ElementRef, OperationRef +from read_artifacts import read_executor +from umf_access.unified import ( + AsyncSession, + GeneratedNativeError, + SessionIdentity, + SessionPolicy, +) +from umf_access_generated_executor import ExecutionScope as GeneratedScope +from umf_access_generated_executor import GeneratedGetManyCall, GeneratedReadCallV2 + + +def _provider_case( + kind: Literal["person", "batch", "service"], authority: Any, composite: bool | str +) -> dict[str, Any]: + profile = "v5" if composite == "v5" else "v4" + executor, _source_root = read_executor(profile) + trust = executor.trusted_artifact + refs = (ElementRef("demo", "id"), ElementRef("demo", "owner")) + root = ExposureRecordRoot( + OperationRef("demo", "Note", "record"), + "inspect", + executor.native_table.source_digest, + trust.artifact_digest, + trust.receipt_digest, + executor.target.binding_digest, + hashlib.sha256(executor.read_algebra_json).hexdigest(), + "primary", + refs, + ("string",), + tuple((ref, "string") for ref in refs), + ) + actor = Actor("fixture-user", kind=kind) + app, deadline = ( + ArtifactRef( + "fixture-app", "a" * 64 if composite == "v5" else "fixture-app-digest" + ), + time.monotonic() + 30, + ) + scope = ExecutionScope(app, actor, "r", deadline, "l", "", "request-snapshot-1") + request = SimpleNamespace(execute_get_many=AsyncMock()) + request_context = AsyncMock() + request_context.__aenter__.return_value = request + native = SimpleNamespace( + schema=executor.native_table.source_digest, + module="demo", + read_profile=executor.read_profile, + target_binding_digest=executor.target.binding_digest, + artifact_digest=trust.artifact_digest, + receipt_digest=trust.receipt_digest, + algebra_json=executor.read_algebra_json, + execute_read_v3=AsyncMock(), + open_request=Mock(return_value=request_context), + ) + policy = SessionPolicy({"fixture-user": "fixture_role"}, {}, "fixture_schema") + + def unused_factory(_identity: SessionIdentity) -> AbstractAsyncContextManager[Any]: + raise AssertionError("the boundary test does not open a database lease") + + session = AsyncSession(unused_factory, policy) + factory = AsyncMock(return_value=native) + kwargs: dict[str, Any] = {"data_session": session, "authority": authority} + bad_kwargs: tuple[tuple[dict[str, Any], str], ...] = () + if composite: + provider_type: Any = GeneratedTableExecution + kwargs.update({ + "read_routes": {"ordinary": ("demo", "Note")}, + "record_routes": {"inspect": root}, + }) + if composite == "v5": + kwargs["connection_routes"] = _v5_connection_binding( + native, request, executor, _source_root + ) + bad_kwargs = ( + ({**kwargs, "read_routes": {"inspect": ("demo", "Note")}}, "disjoint"), + ) + else: + provider_type = GeneratedBatchExecution + kwargs["roots"] = {"inspect": root} + + identity = SessionIdentity("person" if kind == "service" else kind, actor.subject) + generated_scope = GeneratedScope( + app, identity, "r", deadline, "l", "", "request-snapshot/1" + ) + generated_call = GeneratedGetManyCall( + "demo", "Note", "primary", (({"string": "n-1"},),), ("demo/id",) + ) + bound = executor.bind_get_many(generated_call, generated_scope) + request.execute_get_many.return_value = { + "version": "umf.generated-key-batch-result/1", + "sourceDigest": bound.source_digest, + "bindingDigest": bound.target_digest, + "module": "demo", + "record": "Note", + "keyId": "primary", + "fields": [dict(field) for field in bound.fields], + "items": [{"key": [{"string": "n-1"}], "values": [{"string": "n-1"}]}], + } + case = { + "executor": executor, + "_source_root": _source_root, + "root": root, + "actor": actor, + "app": app, + "deadline": deadline, + "scope": scope, + "request": request, + "native": native, + "factory": factory, + "provider_type": provider_type, + "provider_kwargs": kwargs, + "bad_kwargs": bad_kwargs, + "identity": identity, + "generated_scope": generated_scope, + "generated_call": generated_call, + "bound": bound, + } + if composite == "v5": + case["connection_calls"] = _connection_calls(scope, actor) + return case + + +def _v5_connection_binding( + native: Any, request: Any, executor: Any, note_root: Mapping[str, Any] +) -> dict[str, Any]: + routes = _connection_routes(executor, note_root) + native.connection_routes = routes + request.execute_forward_connection = AsyncMock() + native.prepared_connection_scopes = [] + + def prepare(call: Any, **kwargs: Any) -> tuple[Any, Any, Any]: + if call.after == "invalid-cursor": + raise cast(Any, GeneratedNativeError)("INVALID_CURSOR") + native.prepared_connection_scopes.append((kwargs["identity"], kwargs["scope"])) + return call, kwargs["identity"], kwargs["scope"] + + native.prepare_forward_connection = Mock(side_effect=prepare) + + def execute(prepared: object) -> dict[str, object]: + call = cast(tuple[object, object, object], prepared)[0] + return connection_frame_fixture(call, routes, executor) + + request.execute_forward_connection.side_effect = execute + return routes + + +def _connection_routes(executor: Any, _note_root: Mapping[str, Any]) -> dict[str, Any]: + algebra = json.loads(executor.read_algebra_json) + routes: dict[str, Any] = {} + for operation, record, selected_fields in ( + ("Query.notes", "Note", ("demo/id", "demo/owner")), + ("Query.tasks", "Task", ("demo/task_id", "demo/task_value")), + ): + root = algebra["roots"][f"demo/{record}"] + outputs = { + entry["fieldId"]: entry + for entry in root["forwardConnection"]["fieldOutputs"] + } + body = { + "version": "umf.allowed-connection-fields/1", + "scalarCodecProfile": "fixture.scalar-codec/1", + "fields": [ + { + "fieldId": field, + "sourceField": root["fields"][field]["sourceField"], + "output": outputs[field]["output"], + "scalar": outputs[field]["output"]["carrier"], + "nullable": outputs[field]["output"]["nullable"], + } + for field in selected_fields + ], + } + api = cast(Any, generated_api) + profile = api.AllowedConnectionFieldProfile.from_body(body) + scope = api.GeneratedCursorScope( + "fixture-app", "a" * 64, "b" * 64, operation, profile.digest + ) + routes[operation] = api.GeneratedConnectionRoute("demo", record, scope, profile) + return routes + + +def _connection_calls( + scope: ExecutionScope, actor: Actor +) -> tuple[SelectedCallSpec, ...]: + calls: list[SelectedCallSpec] = [] + for operation, fields, first in ( + ("Query.notes", (("demo", "owner"),), 2), + ("Query.tasks", (("demo", "task_value"),), 2), + ("Query.notes", (), 0), + ("Query.notes", (), 1), + ): + call = OperationCall(operation, {}, actor, scope=scope) + calls.append( + SelectedCallSpec(call, Selection("connection", fields=fields, first=first)) + ) + return tuple(calls) + + +def prepared_connection_inputs( + calls: tuple[SelectedCallSpec, ...], scope: ExecutionScope, actor: Actor +) -> tuple[ + tuple[SelectedCallSpec, ...], + SelectedCallSpec, + SelectedCallSpec, +]: + bound = tuple( + SelectedCallSpec( + OperationCall(item.call.operation, {}, actor, scope=scope), item.selection + ) + for item in calls + ) + filtered = SelectedCallSpec( + OperationCall( + bound[0].call.operation, + {"filter": {"owner": "value"}}, + actor, + scope=scope, + ), + bound[0].selection, + ) + bad_cursor = SelectedCallSpec( + bound[0].call, replace(bound[0].selection, after="invalid-cursor") + ) + return bound, filtered, bad_cursor + + +def connection_nodes( + results: list[OperationOutcome], +) -> tuple[ + Mapping[str, object], + Mapping[str, object], + Mapping[str, object], + Mapping[str, object], +]: + def node(index: int) -> Mapping[str, object]: + result = results[index].result + edges = cast(list[Mapping[str, object]], result["edges"]) + return cast(Mapping[str, object], edges[0]["node"]) + + return node(0), node(1), results[2].result, node(3) + + +def prepared_owners(native: Any, offset: int) -> tuple[list[object], list[object]]: + entries = native.prepared_connection_scopes[offset:] + return [entry[0] for entry in entries], [entry[1] for entry in entries] + + +def connection_frame_fixture( + call: Any, routes: Mapping[str, Any], executor: Any +) -> dict[str, Any]: + route = routes[call.operation_id] + algebra = json.loads(executor.read_algebra_json) + root = algebra["roots"][f"{call.module}/{call.record}"] + key_id = root["primaryKeyId"] + key_field = root["getMany"]["keyFields"][0]["fieldId"] + key_value = "n-1" if call.record == "Note" else "t-1" + field_rows: list[dict[str, object]] = [] + values = {} + for descriptor in route.allowed_field_profile.body["fields"]: + field_id = descriptor["fieldId"] + values[field_id] = {"string": key_value if field_id == key_field else "value"} + if call.first: + field_rows = [ + { + "cursor": f"{call.record}-cursor", + "node": { + "key": {"keyId": key_id, "components": [{"string": key_value}]}, + "fields": { + field: values[field] for field in call.fields or (key_field,) + }, + }, + } + ] + return { + "version": "umf.generated-forward-connection-result/1", + "sourceDigest": executor.native_table.source_digest, + "bindingDigest": executor.target.binding_digest, + "module": call.module, + "record": call.record, + "fields": [ + descriptor["sourceField"] + for descriptor in route.allowed_field_profile.body["fields"] + if descriptor["fieldId"] in (call.fields or (key_field,)) + ], + "edges": field_rows, + "pageInfo": {"hasNextPage": False, "hasPreviousPage": False}, + } + + +def _ordinary_read(base: dict[str, Any]) -> OperationCall: + executor = base["executor"] + source_root = base["_source_root"] + predicates = cast(dict[str, dict[str, object]], source_root["predicates"]) + predicate = next( + identity + for identity, item in predicates.items() + if item["fieldId"] == "demo/owner" and item["operator"] == "eq" + ) + wire: dict[str, object] = { + "version": "umf.generated-read-call/2", + "root": {"module": "demo", "record": "Note"}, + "selection": None, + "where": { + "op": "atom", + "predicateId": predicate, + "values": [{"string": "n-1"}], + }, + "orders": [], + "limit": 10, + "terminal": "all", + "key": None, + } + native_scope = GeneratedScope( + base["app"], + base["identity"], + "r-read", + base["deadline"], + "l-read", + "", + "statement", + ) + read_call = GeneratedReadCallV2.from_mapping(wire) + bound = executor.bind_read_v3(read_call, native_scope) + examples = { + "string": {"string": "n-1"}, + "boolean": {"boolean": True}, + "integer": {"integerToken": "1"}, + "decimal": {"decimalToken": "1"}, + "date": {"date": "2026-01-01"}, + "timestamp": {"timestamp": "2026-01-01T00:00:00.000000Z"}, + "uuid": {"uuid": "00000000-0000-0000-0000-000000000001"}, + } + frame = { + "version": "umf.generated-read-result/2", + "kind": bound.result_kind, + "terminal": "all", + "sourceDigest": executor.native_table.source_digest, + "module": "demo", + "record": "Note", + "columns": [ + {"field": dict(field), "output": dict(output)} + for field, output in zip(bound.fields, bound.outputs, strict=True) + ], + "rows": [[examples[cast(str, output["carrier"])] for output in bound.outputs]], + "cursor": None, + } + result = {"schema": executor.native_table.source_digest, "table": frame} + base["native"].execute_read_v3 = AsyncMock(return_value=result) + return OperationCall( + "ordinary", + {"read": wire}, + base["actor"], + scope=replace(base["scope"], consistency="statement"), + ) + + +def batch_case( + kind: Literal["person", "batch", "service"], + authority: Any, + composite: bool | str = False, +) -> dict[str, Any]: + case = _provider_case(kind, authority, composite) + case["read_call"] = _ordinary_read(case) if composite else None + root, actor, scope = case["root"], case["actor"], case["scope"] + selected_call = OperationCall("inspect", {}, actor, scope=scope) + selection = Selection( + "get_many", + fields=(("demo", "id"),), + keys=(SelectedKey(("demo", "Note"), "primary", ({"string": "n-1"},)),), + ) + config = ExposureConfig( + case["app"], + "api-digest", + root.source_digest, + (), + { + "identity.codec": "lintel.node-id.string-key/1", + "read.consistency": "request-snapshot-1", + }, + (root,), + ) + actions: list[tuple[Any, ...]] = [] + if composite: + read_call = cast(OperationCall, case["read_call"]) + actions.extend([ + ( + "invoke", + read_call, + None, + ( + ("denied" if kind == "service" else "succeeded"), + case["native"].execute_read_v3.return_value + if kind != "service" + else {}, + ), + None, + ), + ( + "invoke", + replace(read_call, scope=scope), + None, + ("invalid", {}), + None, + ), + ]) + selected_result = { + "version": "batten.selected-result/1", + "kind": "get_many", + "items": [ + { + "key": { + "record": ["demo", "Note"], + "keyId": "primary", + "components": [{"string": "n-1"}], + }, + "fields": [{"field": ["demo", "id"], "value": {"string": "n-1"}}], + } + ], + } + actions.append(( + "open_error" if kind == "service" else "selected", + selected_call, + selection, + None if kind == "service" else ("succeeded", selected_result), + "snapshot" if kind == "service" else None, + )) + case.update({ + "selected_call": selected_call, + "selection": selection, + "config": config, + "actions": tuple(actions), + }) + case["expected_capture"] = ( + 1, + 0 if kind == "service" or not composite else 1, + 0 if kind == "service" else 1, + 0 if kind == "service" else 1, + ) + return case + + +def record_root_host(capabilities: Mapping[str, str]) -> Any: + return SimpleNamespace( + config=SimpleNamespace(selected_capabilities=capabilities), + operations={"inspect": Operation("inspect", False, ("get_many",))}, + ) diff --git a/tests/runtime/generated_join_fixture.py b/tests/runtime/generated_join_fixture.py new file mode 100644 index 0000000..8135ffc --- /dev/null +++ b/tests/runtime/generated_join_fixture.py @@ -0,0 +1,121 @@ +"""Protocol fixture for the joined route mode in generated Host checks.""" + +from __future__ import annotations + +from collections.abc import Awaitable, Callable, Mapping +from types import SimpleNamespace +from typing import Any, Literal, cast + +from batten.contracts import Actor, ArtifactRef, ExecutionScope, OperationCall +from batten.umf_postgres._generated_join import ( + GeneratedJoinBinding, + GeneratedJoinExecution, +) +from generated_provider_cases import Authority +from umf_access_generated_executor import ( + GeneratedExecutor, + GeneratedJoinedReadCall, + GeneratedJoinedReadRoot, +) + + +async def joined_route_observation( + kind: Literal["person", "batch"], +) -> tuple[object, ...]: + """Exercise route pins, value frames and fixed refusals on one binding.""" + root = GeneratedJoinedReadRoot("root-key", "demo", "Task", "demo", "TaskNote") + executor = cast( + GeneratedExecutor, + SimpleNamespace( + read_profile="weft.generated-read-algebra/8", + native_table=SimpleNamespace(source_digest="s" * 64), + target=SimpleNamespace(binding_digest="b" * 64), + trusted_artifact=SimpleNamespace( + artifact_digest="a" * 64, receipt_digest="r" * 64 + ), + read_algebra_json=b"{}", + joined_read_roots=(root,), + ), + ) + frame: dict[str, object] = {"schema": "s" * 64, "table": {"rows": []}} + native = SimpleNamespace( + schema="s" * 64, + module="demo", + read_profile="weft.generated-read-algebra/8", + target_binding_digest="b" * 64, + artifact_digest="a" * 64, + receipt_digest="r" * 64, + algebra_json=b"{}", + joined_read_roots=(root,), + executions=[], + response=frame, + ) + + def identity(call: GeneratedJoinedReadCall) -> str: + return "call-digest" if call.root_record == "Task" else "" + + async def execute( + call: GeneratedJoinedReadCall, *, identity: object, scope: object + ) -> dict[str, object]: + native.executions.append((call, identity, scope)) + return cast(dict[str, object], native.response) + + def validate(result: object, _call: GeneratedJoinedReadCall) -> bool: + return result is native.response + + native.joined_read_identity = identity + native.execute_joined_read = execute + native.validate_joined_read_result = validate + + async def factory() -> Any: + return native + + route = ("demo", "Task", "demo", "TaskNote") + provider = GeneratedJoinExecution( + executor, + cast(Callable[[], Awaitable[GeneratedJoinBinding]], factory), + Authority({"amount": {"string": "unchanged"}}), + {"Query.joined": route}, + ) + await provider.prepare() + actor = Actor("reviewer", kind=kind) + scope = ExecutionScope( + ArtifactRef("app", "d" * 64), actor, "request", 9999999999.0, "lease" + ) + valid = GeneratedJoinedReadCall( + "demo", "Task", "demo", "TaskNote", None, None, (), 10 + ) + wrong = GeneratedJoinedReadCall( + "demo", "Other", "demo", "TaskNote", None, None, (), 10 + ) + outcomes = [ + await provider.invoke( + OperationCall( + "Query.joined", {"join": wrong.to_mapping()}, actor, scope=scope + ) + ), + await provider.invoke( + OperationCall( + "Query.joined", {"join": valid.to_mapping()}, actor, scope=scope + ) + ), + ] + responses: tuple[Mapping[str, object], ...] = ( + {"schema": "s" * 64, "error": {"code": "UNSUPPORTED"}}, + {"schema": "s" * 64, "error": {"code": "CONFLICT"}}, + {"schema": "s" * 64, "diagnostic": "not a public frame"}, + ) + for response in responses: + native.response = dict(response) + outcomes.append( + await provider.invoke( + OperationCall( + "Query.joined", {"join": valid.to_mapping()}, actor, scope=scope + ) + ) + ) + result = tuple( + (outcome.status, outcome.code, outcome.result) for outcome in outcomes + ) + await provider.aclose() + return (*result, len(native.executions), frame) diff --git a/tests/runtime/generated_provider_cases.py b/tests/runtime/generated_provider_cases.py new file mode 100644 index 0000000..75ab92f --- /dev/null +++ b/tests/runtime/generated_provider_cases.py @@ -0,0 +1,420 @@ +"""Pure fixture builders for generated provider boundary workflows.""" + +import time +from collections.abc import Mapping +from dataclasses import dataclass, replace +from types import SimpleNamespace +from typing import Any, Literal, cast + +from batten.contracts import Actor, ArtifactRef, ExecutionScope, OperationCall +from batten.umf_postgres._generated_page import GeneratedPageExecution +from batten.umf_postgres.generated import GeneratedUmfExecution +from batten.umf_postgres.generated_read import GeneratedReadExecution +from batten.umf_postgres.generated_read_v2 import GeneratedReadExecutionV2 +from batten.umf_postgres.generated_read_v3 import GeneratedReadExecutionV3 +from read_artifacts import read_executor +from umf_access.unified import SessionIdentity +from umf_access_generated_executor import ExecutionScope as GeneratedScope +from umf_access_generated_executor import ( + GeneratedExecutor, + GeneratedOrdinaryPageCall, + GeneratedOrdinaryPageRoot, + GeneratedReadAtom, + GeneratedReadCallV2, +) + + +class Authority: + def __init__(self, inputs: dict[str, dict[str, str]]): + self.inputs = inputs + + async def check(self, actor: Actor, operation: str) -> bool: + self.inputs["amount"][next(iter(self.inputs["amount"]))] = "2" + return operation in {"inspect", "ordinary"} or operation.startswith("Query.") + + +@dataclass(frozen=True) +class PageRouteCase: + provider: GeneratedPageExecution + native: Any + artifact: ArtifactRef + actor: Actor + page: GeneratedOrdinaryPageCall + + +def page_route_scenario( + kind: Literal["person", "batch", "service"], + route: tuple[str, str] = ("demo", "Note"), + *, + missing_method: str | None = None, +) -> PageRouteCase: + """Build a protocol-only route case, not a verified combined-v7 artifact.""" + base, _root = read_executor("v5") + roots = (GeneratedOrdinaryPageRoot("demo/Note", "demo", "Note"),) + executor = cast( + GeneratedExecutor, + SimpleNamespace( + read_profile="weft.generated-read-algebra/7", + native_table=base.native_table, + target=base.target, + trusted_artifact=base.trusted_artifact, + read_algebra_json=base.read_algebra_json, + ordinary_page_roots=roots, + ), + ) + result: dict[str, object] = { + "schema": base.native_table.source_digest, + "page": {"rootId": "demo/Note", "rows": []}, + } + native = SimpleNamespace( + schema=base.native_table.source_digest, + module="demo", + read_profile=executor.read_profile, + target_binding_digest=base.target.binding_digest, + artifact_digest=base.trusted_artifact.artifact_digest, + receipt_digest=base.trusted_artifact.receipt_digest, + algebra_json=base.read_algebra_json, + ordinary_page_roots=roots, + identities=[], + calls=[], + result=result, + ) + + def identify(call: GeneratedOrdinaryPageCall) -> bytes: + native.identities.append(call) + return b"p" * 32 + + async def execute( + call: GeneratedOrdinaryPageCall, *, identity: object, scope: object + ) -> dict[str, object]: + native.calls.append((call, identity, scope)) + return result + + def validate(result_value: object, call: GeneratedOrdinaryPageCall) -> bool: + return ( + result_value is result + and bool(native.calls) + and native.calls[-1][0] == call + ) + + native.ordinary_page_identity = identify + native.execute_ordinary_page = execute + native.validate_ordinary_page_result = validate + if missing_method is not None: + delattr(native, missing_method) + + async def factory() -> Any: + return native + + actor = Actor(f"page-{kind}", kind=kind) + provider = GeneratedPageExecution( + executor, + factory, + Authority({"amount": {"string": "unchanged"}}), + {"ordinary": route}, + ) + return PageRouteCase( + provider, + native, + ArtifactRef("page-fixture", "d" * 64), + actor, + GeneratedOrdinaryPageCall("demo/Note", (), None, 1), + ) + + +class Native: + schema = "b" * 64 + module = "fabricated" + + def __init__(self, executor: GeneratedExecutor | None = None) -> None: + self.executor = executor + self.read_profile = executor.read_profile if executor is not None else None + self.target_binding_digest = "" + if executor is not None: + self.schema = executor.native_table.source_digest + self.module = "demo" + self.target_binding_digest = executor.target.binding_digest + self.calls: list[ + tuple[Mapping[str, object], SessionIdentity, GeneratedScope] + ] = [] + self.response: dict[str, object] | None = None + + async def execute( + self, + request: dict[str, object], + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: + self.calls.append((request, identity, scope)) + return ( + self.response + if self.response is not None + else { + "schema": self.schema, + "table": { + "version": "umf.table-read-result/0.1", + "kind": "many", + "module": self.module, + "operation": request["operation"], + "sourceDigest": self.schema, + "rows": [], + "cursor": None, + }, + } + ) + + async def execute_read_v3( + self, + call: GeneratedReadCallV2, + *, + identity: SessionIdentity, + scope: GeneratedScope, + ) -> dict[str, object]: + bound = cast(GeneratedExecutor, self.executor).bind_read_v3(call, scope) + values = ( + call.key + if call.key is not None + else cast(GeneratedReadAtom, call.where).values + ) + self.calls.append(( + {"call": {"kind": "single", "inputs": {"amount": values[0]}}}, + identity, + scope, + )) + frame: dict[str, object] = { + "version": "umf.generated-read-result/2", + "kind": bound.result_kind, + "terminal": call.terminal, + "sourceDigest": self.schema, + "module": call.module, + "record": call.record, + } + if bound.result_kind == "scalar": + frame["value"] = ( + {"integerToken": "1"} if call.terminal == "count" else {"boolean": True} + ) + else: + frame.update({ + "columns": [ + {"field": dict(field), "output": dict(output)} + for field, output in zip(bound.fields, bound.outputs, strict=True) + ], + "rows": [[example_literal(output) for output in bound.outputs]], + "cursor": None, + }) + return ( + self.response + if self.response is not None + else {"schema": self.schema, "table": frame} + ) + + +def example_literal(output: Mapping[str, object]) -> Mapping[str, object]: + values: dict[str, Mapping[str, object]] = { + "string": {"string": "fabricated"}, + "boolean": {"boolean": True}, + "integer": {"integerToken": "9007199254740993"}, + "decimal": {"decimalToken": "1.23"}, + "date": {"date": "2026-11-04"}, + "timestamp": {"timestamp": "2026-11-04T00:00:00.000000Z"}, + "uuid": {"uuid": "00000000-0000-0000-0000-000000000001"}, + } + return values[cast(str, output["carrier"])] + + +def malformed_results(result: Mapping[str, object]) -> tuple[dict[str, object], ...]: + frame = cast(Mapping[str, object], result["table"]) + edits: list[dict[str, object]] + if frame["kind"] == "scalar": + edits = [ + {"value": None}, + {"value": {"string": "invalid"}}, + {"value": {"integerToken": "-1"}}, + ] + else: + columns = cast(list[Mapping[str, object]], frame["columns"]) + row = [ + example_literal(cast(Mapping[str, object], column["output"])) + for column in columns + ] + edits = [ + {"rows": [[None, *row[1:]]]}, + {"rows": [[{"integerToken": "1"}, *row[1:]]]}, + {"rows": [row] * 1001}, + {"rows": [[{"string": "\x01" * 1_400_000}, *row[1:]]]}, + ] + if frame.get("terminal") in ("one", "get"): + edits.extend([{"rows": []}, {"rows": [row, row]}]) + return tuple( + {"schema": result["schema"], "table": {**frame, **edit}} for edit in edits + ) + + +def malformed_cases( + profile: str, kind: str, result: Mapping[str, object] +) -> tuple[dict[str, object], ...]: + return ( + malformed_results(result) + if (profile, kind) not in {("fixed", kind), (profile, "service")} + else () + ) + + +def wrong_root_call(profile: str, call: OperationCall) -> OperationCall: + return ( + replace(call, inputs={"read": {"module": "foreign"}}) + if profile != "fixed" + else replace(call, scope=None) + ) + + +def scenario( + profile: str, kind: Literal["person", "batch", "service"] = "person" +) -> tuple[ + Native, + GeneratedReadExecution | GeneratedUmfExecution, + Mapping[str, object], + dict[str, str], + Actor, + ExecutionScope, + OperationCall, +]: + executor, root = ( + read_executor( + "v3" + if profile.startswith("v3_") + else ("v2" if profile.startswith("v2_") else "v1") + ) + if profile != "fixed" + else (None, {}) + ) + native = Native(executor) + expected = ( + {"string": "generated_fixture_actor"} + if executor + else {"integerToken": "9007199254740993"} + ) + values = {"amount": dict(expected)} + authority = Authority(values) + actor = Actor("fabricated-actor", kind=kind) + scope = ExecutionScope( + ArtifactRef("fabricated", "fixture"), + actor, + "request", + time.monotonic() + 60, + "lease", + ) + + async def factory() -> Native: + return native + + inputs: Mapping[str, object] = values + if executor is not None: + predicates = cast(Mapping[str, Mapping[str, object]], root["predicates"]) + predicate = next( + identity + for identity, descriptor in predicates.items() + if descriptor["fieldId"] == "demo/owner" and descriptor["operator"] == "eq" + ) + inputs = { + "read": { + "module": "demo", + "record": "Note", + "fields": None, + "filters": [{"predicate": predicate, "values": [values["amount"]]}], + "order": [], + "limit": 10, + } + } + if profile == "read": + provider = GeneratedReadExecution( + factory, authority, executor, {"inspect": ("demo", "Note")} + ) + call = OperationCall("inspect", inputs, actor, scope=scope) + return native, provider, inputs, expected, actor, scope, call + if profile.startswith(("v2_", "v3_")): + terminal = cast( + Literal["all", "first", "one", "get", "count", "exists"], + profile.split("_")[1], + ) + values_wire: dict[str, object] = { + "version": "umf.generated-read-call/2", + "root": {"module": "demo", "record": "Note"}, + "selection": None, + "where": { + "op": "atom", + "predicateId": predicate, + "values": [values["amount"]], + }, + "orders": [], + "limit": 10 + if terminal == "all" and not profile.endswith("complete") + else None, + "terminal": terminal, + "key": None, + } + if terminal == "get": + values_wire.update({"where": None, "key": [values["amount"]]}) + inputs = {"read": values_wire} + provider_type = ( + GeneratedReadExecutionV3 + if profile.startswith("v3_") + else GeneratedReadExecutionV2 + ) + provider = provider_type( + factory, authority, executor, {"inspect": ("demo", "Note")} + ) + else: + raise ValueError("unknown read profile") + else: + provider = GeneratedUmfExecution(factory, authority) + call = OperationCall("inspect", inputs, actor, scope=scope) + return native, provider, inputs, expected, actor, scope, call + + +def invalid_read_inputs( + call: OperationCall, + actor: Actor, + scope: ExecutionScope, + kind: str, + denial: object, + limit: object, + precondition: object, + private: object, +) -> tuple[tuple[OperationCall, object, set[str]], ...]: + """Return malformed request/response data; no provider calls or assertions.""" + return ( + (call, denial, {"denied"}), + (call, limit, {"denied"} if kind == "service" else {"unavailable"}), + ( + call, + precondition, + {"denied"} if kind == "service" else {"precondition_failed"}, + ), + (call, private, {"denied"} if kind == "service" else {"unavailable"}), + (replace(call, scope=None), None, {"invalid", "denied"}), + ( + replace(call, scope=replace(scope, principal=Actor("foreign"))), + None, + {"invalid", "denied"}, + ), + (replace(call, phase="observe"), None, {"invalid", "denied"}), + (replace(call, key="f" * 32), None, {"invalid", "denied"}), + (replace(call, confirmation="unverified"), None, {"invalid", "denied"}), + ( + replace(call, scope=replace(scope, consistency="request-snapshot-1")), + None, + {"invalid", "denied"}, + ), + ( + replace(call, scope=replace(scope, consistency="unknown")), + None, + {"invalid", "denied"}, + ), + ( + replace(call, actor=replace(actor, delegation="unverified")), + None, + {"invalid", "denied"}, + ), + ) diff --git a/tests/runtime/generated_read_fixture.json b/tests/runtime/generated_read_fixture.json new file mode 100644 index 0000000..7db7b0e --- /dev/null +++ b/tests/runtime/generated_read_fixture.json @@ -0,0 +1,13 @@ +{ + "provenance": { + "role": "Fabricated Rust-issued generated artifact for host boundary tests; no database behavior is claimed.", + "note": "The local test receipt is intentionally fabricated; it is never production trust." + }, + "entries": { + "trusted-artifact.json": "{\"artifactId\": \"generated-fixture-artifact-1\", \"artifactDigest\": \"08c1079de4bf5bff10c627ca046c099da796c913ebcad8312a3b62c8e439a6a3\", \"receiptDigest\": \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"sourceDigest\": \"fa4c1349f0dac9189d207eae6a6335a7ac052a524da778a10a6b2dbeace6562b\", \"targetBindingDigest\": \"c327d2ffed6b77fcbd31947abba0ab4e968653802e626ee1444495a451046fc4\", \"inventory\": [[\"algebra/read.json\", \"cf290fbaf70c863ddadf33ae9a58b6e411cd934f2953ccf02da396d2a5e5e90d\"], [\"native/native-table-source.json\", \"f85e857e3102a530eccbcac02665cb0ec9bd750d9ee58ebd31f69b66a70cbd47\"]], \"issuer\": \"isolated-local-fixture\", \"buildId\": \"pg18-e2e-1\"}", + "manifest.json": "{\"algebra\":{\"algebraPath\":\"algebra/read.json\",\"profile\":\"weft.generated-read-algebra/1\"},\"artifactDigest\":\"08c1079de4bf5bff10c627ca046c099da796c913ebcad8312a3b62c8e439a6a3\",\"artifactId\":\"generated-fixture-artifact-1\",\"executor\":{\"abiMajor\":1,\"maxMinor\":1,\"minMinor\":1,\"packageId\":\"umf-access-generated-executor\"},\"generator\":{\"abi\":\"weft.generated-execution/1\",\"umfDistribution\":\"umf-core\",\"umfSourceDigest\":\"3612aa65750c97914833be50cb1f207556e52cec0db0da107fa2c516da219419\",\"umfVersion\":\"0.10.0\",\"weftDistribution\":\"weft-sql\",\"weftSourceDigest\":\"cd0fa27c9580742333d14e24d5ebfd74babb47d31720bb4c577278d05486f11d\",\"weftVersion\":\"0.4.58.dev1\"},\"inventory\":{\"algebra/read.json\":\"cf290fbaf70c863ddadf33ae9a58b6e411cd934f2953ccf02da396d2a5e5e90d\",\"native/native-table-source.json\":\"f85e857e3102a530eccbcac02665cb0ec9bd750d9ee58ebd31f69b66a70cbd47\"},\"programs\":{},\"provenance\":{\"buildId\":\"pg18-e2e-1\",\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},\"source\":{\"bundleInputDigest\":\"cda50ae9e5da1526aedcdf538d379809ca310c27309b2e1ac7c6b2574255bf84\",\"coreVersion\":\"0.10.0\",\"documentId\":\"synthetic-table-lifecycle\",\"moduleIds\":[\"demo\"],\"sha256\":\"fa4c1349f0dac9189d207eae6a6335a7ac052a524da778a10a6b2dbeace6562b\"},\"target\":{\"bindingDigest\":\"c327d2ffed6b77fcbd31947abba0ab4e968653802e626ee1444495a451046fc4\",\"id\":\"postgresql18\",\"profile\":\"pg18/1\",\"version\":\"18\"},\"version\":\"weft.generated-execution/1\"}", + "receipt.json": "{\"payloadDigest\": \"2225b3ed051fcc1833c0e9a1aa0d1729883264c9c585ecc2934c4178c1b82a6d\"}", + "native/native-table-source.json": "{\"bundleDigest\":\"dab711cd1a45368f55ec2ab34eae9e662ed65a29ed6c033a8c742bbd1eb3852b\",\"configuration\":{\"batchRole\":\"generated_fixture_batch\",\"groupRoles\":{},\"module\":\"demo\",\"ownerRole\":\"generated_fixture_owner\",\"personRole\":\"generated_fixture_person\",\"schema\":\"generated_fixture_schema\"},\"configurationDigest\":\"226271891f7fb96a8bb537b47de9aea2e6f24ded310be1f0170bc974f17fab52\",\"expectedCatalog\":{\"checks\":[],\"tables\":[{\"columns\":[{\"field\":{\"element\":\"id\",\"module\":\"demo\"},\"name\":\"id\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"owner\",\"module\":\"demo\"},\"name\":\"owner\",\"nativeType\":{\"kind\":\"text\"}}],\"id\":\"notes\",\"name\":\"notes\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}]},\"operations\":[],\"sourceDigest\":\"fa4c1349f0dac9189d207eae6a6335a7ac052a524da778a10a6b2dbeace6562b\",\"version\":\"umf.native-table-source/2\"}", + "algebra/read.json": "{\"readiness\":\"weft.generated-read-executable/1\",\"roots\":{\"demo/Note\":{\"defaultSelection\":[\"demo/id\",\"demo/owner\"],\"fields\":{\"demo/id\":{\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_0\\\"\",\"sourceField\":{\"element\":\"id\",\"module\":\"demo\"}},\"demo/owner\":{\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_1\\\"\",\"sourceField\":{\"element\":\"owner\",\"module\":\"demo\"}}},\"fromSql\":\"FROM \\\"generated_fixture_schema\\\".\\\"notes\\\" AS \\\"r\\\"\",\"keyTieOrder\":[\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\"],\"maxRows\":1000,\"module\":\"demo\",\"nativeReadGuard\":{\"includesLookahead\":true,\"maxNativeBytes\":8388608,\"partialFrames\":false,\"profile\":\"pg18-read-frame/0.1\",\"sqlstate\":\"22012\"},\"obligations\":{\"baseTablesOnly\":true,\"noBypassRls\":true,\"principal\":\"caller-connection-role\",\"rls\":\"native-caller-role\",\"rowCap\":1000,\"schema\":\"generated_fixture_schema\",\"searchPath\":[\"pg_catalog\"],\"tableLifecycle\":{\"configurationDigest\":\"226271891f7fb96a8bb537b47de9aea2e6f24ded310be1f0170bc974f17fab52\",\"cursorScope\":[\"module\",\"sourceDigest\",\"configurationDigest\",\"deploymentDigest\",\"ledgerHeadDigest\",\"principal\",\"roleScopeDigest\"],\"deploymentDigest\":\"dab711cd1a45368f55ec2ab34eae9e662ed65a29ed6c033a8c742bbd1eb3852b\",\"generationLock\":\"shared-before-admission-through-transaction\",\"installedAuthority\":\"approved-forward-ledger-and-source-derived-native-witness\",\"module\":\"demo\",\"nativeExecutionQualified\":false,\"policy\":\"source-command-policy-and-native-forced-rls\",\"principal\":\"verified-person-or-batch\",\"privileges\":\"source-grants-and-native-effective-closure\",\"roleScope\":\"native-transitive-current\",\"sourceDigest\":\"fa4c1349f0dac9189d207eae6a6335a7ac052a524da778a10a6b2dbeace6562b\",\"sourceInterpretation\":\"original-umf-deployment-compiler\",\"tables\":[{\"command\":\"select\",\"id\":\"notes\",\"native\":\"notes\",\"policySourcePath\":\"/modules/0/extensions/umf.tables/tables/0/policy\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}],\"version\":\"umf.table-lifecycle/0.1\"},\"timeout\":\"per-call\",\"transaction\":\"read-only\"},\"orders\":{\"o_0b8d9a7134c985cecf97062bb7bc25d2100f0200012300c3f7e2d5bc3fc22b29\":{\"direction\":\"asc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\":{\"direction\":\"asc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_7f089caf246c21027d14b1336adf78a49fbd458b954cd8993c53259a7ceb5cac\":{\"direction\":\"desc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_bf4f32c943a3f3a0bdd9b050f5bba7dbb9d0ca1320334e64fccad3a1a11290a5\":{\"direction\":\"desc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"}},\"predicates\":{\"p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"}},\"record\":\"Note\"}},\"source\":{\"modelSha256\":\"fa4c1349f0dac9189d207eae6a6335a7ac052a524da778a10a6b2dbeace6562b\",\"module\":\"demo\"},\"target\":{\"bindingDigest\":\"c327d2ffed6b77fcbd31947abba0ab4e968653802e626ee1444495a451046fc4\",\"id\":\"postgresql18\",\"modelSha256\":\"fa4c1349f0dac9189d207eae6a6335a7ac052a524da778a10a6b2dbeace6562b\"},\"version\":\"weft.generated-read-algebra/1\"}" + } +} diff --git a/tests/runtime/generated_read_v2_fixture.json b/tests/runtime/generated_read_v2_fixture.json new file mode 100644 index 0000000..190a053 --- /dev/null +++ b/tests/runtime/generated_read_v2_fixture.json @@ -0,0 +1,14 @@ +{ + "provenance": { + "role": "Rust-issued G3 artifact for fabricated host boundary tests; no database behavior claimed.", + "weftWheelSha256": "b54c32b0f7c9d09f891803a7fa4288e1e4e26ca29bd2779ca7343077e520eb78", + "receipt": "Explicit local test trust, not a production issuer." + }, + "entries": { + "trusted-artifact.json": "{\"artifactDigest\":\"5583e22f0475ad8fd6a349393f2e91d34b27c82a3eed1dd983ee385ef87291a5\",\"artifactId\":\"generated-read-fixture-8832ad7f\",\"buildId\":\"pg18-generated-read-8832ad7f\",\"inventory\":[[\"algebra/read.json\",\"329d7060882a2797c0ee284e8c5c5cbe4cbe942d27907adcd11c84d1b6256e51\"],[\"native/native-table-source.json\",\"bf4fd2f6a4d588d95a32c4e2a52d669b62c9a457614e2fd38fa0d5fede9fe06c\"]],\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"sourceDigest\":\"6316416d9fd7a6a96616d1bc4a13f5b37ec2dc311f9d27a3c1f56ce6666d07af\",\"targetBindingDigest\":\"5ca97fa23f8740d9a8b189b31a8d401136551c5857d36eff50245488b5cb7e22\"}", + "manifest.json": "{\"algebra\":{\"algebraPath\":\"algebra/read.json\",\"profile\":\"weft.generated-read-algebra/2\"},\"artifactDigest\":\"5583e22f0475ad8fd6a349393f2e91d34b27c82a3eed1dd983ee385ef87291a5\",\"artifactId\":\"generated-read-fixture-8832ad7f\",\"executor\":{\"abiMajor\":1,\"maxMinor\":2,\"minMinor\":2,\"packageId\":\"umf-access-generated-executor\"},\"generator\":{\"abi\":\"weft.generated-execution/1\",\"umfDistribution\":\"umf-core\",\"umfSourceDigest\":\"1ee3ccce0c86aa53c15181ea31ecf9c495be8a0374c7ea22d9bdd7b5fa1124b3\",\"umfVersion\":\"0.10.0\",\"weftDistribution\":\"weft-sql\",\"weftSourceDigest\":\"cd0fa27c9580742333d14e24d5ebfd74babb47d31720bb4c577278d05486f11d\",\"weftVersion\":\"0.4.59.dev1\"},\"inventory\":{\"algebra/read.json\":\"329d7060882a2797c0ee284e8c5c5cbe4cbe942d27907adcd11c84d1b6256e51\",\"native/native-table-source.json\":\"bf4fd2f6a4d588d95a32c4e2a52d669b62c9a457614e2fd38fa0d5fede9fe06c\"},\"programs\":{},\"provenance\":{\"buildId\":\"pg18-generated-read-8832ad7f\",\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"},\"source\":{\"bundleInputDigest\":\"7458d61a03fcda803dcbe8050476501145e46601838a8bf9ff69e4e592047018\",\"coreVersion\":\"0.10.0\",\"documentId\":\"synthetic-table-lifecycle\",\"moduleIds\":[\"demo\"],\"sha256\":\"6316416d9fd7a6a96616d1bc4a13f5b37ec2dc311f9d27a3c1f56ce6666d07af\"},\"target\":{\"bindingDigest\":\"5ca97fa23f8740d9a8b189b31a8d401136551c5857d36eff50245488b5cb7e22\",\"id\":\"postgresql18\",\"profile\":\"pg18/1\",\"version\":\"18\"},\"version\":\"weft.generated-execution/1\"}", + "receipt.json": "{\"payloadDigest\":\"efddf5f7198a87a83e7d4776ab0079edd6b24b784365a901f06f55540a2e0bb0\"}", + "native/native-table-source.json": "{\"bundleDigest\":\"357bb5e70da389534aeb426daed3a2ee0dae07d79351b59a040723d14d1e92e6\",\"configuration\":{\"batchRole\":\"generated_batch_8832ad7f\",\"groupRoles\":{},\"module\":\"demo\",\"ownerRole\":\"generated_owner_8832ad7f\",\"personRole\":\"generated_person_8832ad7f\",\"schema\":\"generated_fixture_8832ad7f\"},\"configurationDigest\":\"ba3f1039b93596e6749daf673b44ccd69d3e25b5823cf4716f21796be7377645\",\"expectedCatalog\":{\"checks\":[{\"id\":\"domain:demo.amount\"},{\"id\":\"domain:demo.day\"},{\"id\":\"domain:demo.observed\"}],\"tables\":[{\"columns\":[{\"field\":{\"element\":\"id\",\"module\":\"demo\"},\"name\":\"id\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"owner\",\"module\":\"demo\"},\"name\":\"owner\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"enabled\",\"module\":\"demo\"},\"name\":\"enabled\",\"nativeType\":{\"kind\":\"boolean\"}},{\"field\":{\"element\":\"attempts\",\"module\":\"demo\"},\"name\":\"attempts\",\"nativeType\":{\"kind\":\"int8\"}},{\"field\":{\"element\":\"amount\",\"module\":\"demo\"},\"name\":\"amount\",\"nativeType\":{\"kind\":\"numeric\",\"precision\":8,\"scale\":2}},{\"field\":{\"element\":\"day\",\"module\":\"demo\"},\"name\":\"day\",\"nativeType\":{\"kind\":\"date\"}},{\"field\":{\"element\":\"observed\",\"module\":\"demo\"},\"name\":\"observed\",\"nativeType\":{\"kind\":\"timestamptz\"}},{\"field\":{\"element\":\"guid\",\"module\":\"demo\"},\"name\":\"guid\",\"nativeType\":{\"kind\":\"uuid\"}}],\"id\":\"notes\",\"name\":\"notes\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}]},\"operations\":[],\"sourceDigest\":\"6316416d9fd7a6a96616d1bc4a13f5b37ec2dc311f9d27a3c1f56ce6666d07af\",\"version\":\"umf.native-table-source/2\"}", + "algebra/read.json": "{\"readiness\":\"weft.generated-read-executable/2\",\"roots\":{\"demo/Note\":{\"defaultSelection\":[\"demo/id\",\"demo/owner\",\"demo/enabled\",\"demo/attempts\",\"demo/amount\",\"demo/day\",\"demo/observed\",\"demo/guid\"],\"fields\":{\"demo/amount\":{\"output\":{\"carrier\":\"decimal\",\"name\":\"__weft_field_4\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"amount\\\" AS \\\"__weft_field_4\\\"\",\"sourceField\":{\"element\":\"amount\",\"module\":\"demo\"}},\"demo/attempts\":{\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_field_3\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"attempts\\\" AS \\\"__weft_field_3\\\"\",\"sourceField\":{\"element\":\"attempts\",\"module\":\"demo\"}},\"demo/day\":{\"output\":{\"carrier\":\"date\",\"name\":\"__weft_field_5\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"day\\\" AS \\\"__weft_field_5\\\"\",\"sourceField\":{\"element\":\"day\",\"module\":\"demo\"}},\"demo/enabled\":{\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_field_2\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"enabled\\\" AS \\\"__weft_field_2\\\"\",\"sourceField\":{\"element\":\"enabled\",\"module\":\"demo\"}},\"demo/guid\":{\"output\":{\"carrier\":\"uuid\",\"name\":\"__weft_field_7\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"guid\\\" AS \\\"__weft_field_7\\\"\",\"sourceField\":{\"element\":\"guid\",\"module\":\"demo\"}},\"demo/id\":{\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_0\\\"\",\"sourceField\":{\"element\":\"id\",\"module\":\"demo\"}},\"demo/observed\":{\"output\":{\"carrier\":\"timestamp\",\"name\":\"__weft_field_6\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"observed\\\" AS \\\"__weft_field_6\\\"\",\"sourceField\":{\"element\":\"observed\",\"module\":\"demo\"}},\"demo/owner\":{\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_1\\\"\",\"sourceField\":{\"element\":\"owner\",\"module\":\"demo\"}}},\"fromSql\":\"FROM \\\"generated_fixture_8832ad7f\\\".\\\"notes\\\" AS \\\"r\\\"\",\"keyTieOrder\":[\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\"],\"maxRows\":1000,\"module\":\"demo\",\"nativeReadGuard\":{\"includesLookahead\":true,\"maxNativeBytes\":8388608,\"partialFrames\":false,\"profile\":\"pg18-read-frame/0.1\",\"sqlstate\":\"22012\"},\"obligations\":{\"baseTablesOnly\":true,\"noBypassRls\":true,\"principal\":\"caller-connection-role\",\"rls\":\"native-caller-role\",\"rowCap\":1000,\"schema\":\"generated_fixture_8832ad7f\",\"searchPath\":[\"pg_catalog\"],\"tableLifecycle\":{\"configurationDigest\":\"ba3f1039b93596e6749daf673b44ccd69d3e25b5823cf4716f21796be7377645\",\"cursorScope\":[\"module\",\"sourceDigest\",\"configurationDigest\",\"deploymentDigest\",\"ledgerHeadDigest\",\"principal\",\"roleScopeDigest\"],\"deploymentDigest\":\"357bb5e70da389534aeb426daed3a2ee0dae07d79351b59a040723d14d1e92e6\",\"generationLock\":\"shared-before-admission-through-transaction\",\"installedAuthority\":\"approved-forward-ledger-and-source-derived-native-witness\",\"module\":\"demo\",\"nativeExecutionQualified\":false,\"policy\":\"source-command-policy-and-native-forced-rls\",\"principal\":\"verified-person-or-batch\",\"privileges\":\"source-grants-and-native-effective-closure\",\"roleScope\":\"native-transitive-current\",\"sourceDigest\":\"6316416d9fd7a6a96616d1bc4a13f5b37ec2dc311f9d27a3c1f56ce6666d07af\",\"sourceInterpretation\":\"original-umf-deployment-compiler\",\"tables\":[{\"command\":\"select\",\"id\":\"notes\",\"native\":\"notes\",\"policySourcePath\":\"/modules/0/extensions/umf.tables/tables/0/policy\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}],\"version\":\"umf.table-lifecycle/0.1\"},\"timeout\":\"per-call\",\"transaction\":\"read-only\"},\"orders\":{\"o_00eae1be71508ce30cd4821e6497756f3f63b6e0412041f8183e8d3747970581\":{\"direction\":\"desc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" DESC NULLS LAST\"},\"o_09612a020dc0b9aa368e5fafec4455f78ba488d92556c655723e7ae2814623e6\":{\"direction\":\"desc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" DESC NULLS LAST\"},\"o_0b8d9a7134c985cecf97062bb7bc25d2100f0200012300c3f7e2d5bc3fc22b29\":{\"direction\":\"asc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_43ccf2bfa659d03559ce77fbdfe6db17ed665c79e93dbf7e7dc10e795c584752\":{\"direction\":\"asc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" ASC NULLS LAST\"},\"o_4eaa395ffe6ab47f937ca98ee6a76e38c7b58903805f5ef9520535abec78e841\":{\"direction\":\"desc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" DESC NULLS LAST\"},\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\":{\"direction\":\"asc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_5a0fa7505aa54d61a046902644ae78f61e540c0c9f160cac6312e98032ffcaf8\":{\"direction\":\"asc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" ASC NULLS LAST\"},\"o_6f9c8ccfbee4bb080d50ffb7532961cddac6c71693c3ef8a2c1e56dfaf696e83\":{\"direction\":\"desc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" DESC NULLS LAST\"},\"o_71c99cd89f02a63fdeab9bb29c0659ecb541a2679bdcef79df7d7c1a87f78cd9\":{\"direction\":\"asc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" ASC NULLS LAST\"},\"o_7f089caf246c21027d14b1336adf78a49fbd458b954cd8993c53259a7ceb5cac\":{\"direction\":\"desc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_808213c3613705a667d9b264780950ff2f12afb77d20ec6f633e34722343d848\":{\"direction\":\"asc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" ASC NULLS LAST\"},\"o_b3a5c63f47353c307a80d6e232dd9cd903b727fc9b0762643fb68c9236c1421d\":{\"direction\":\"asc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" ASC NULLS LAST\"},\"o_bf4f32c943a3f3a0bdd9b050f5bba7dbb9d0ca1320334e64fccad3a1a11290a5\":{\"direction\":\"desc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_e2f88c3bc6af3ddb3265f65c3a2ae4de4ad2570ed3a6898381ccf93789ad3de1\":{\"direction\":\"desc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" DESC NULLS LAST\"},\"o_f44a4a5a9eb548d37bd03712a543820ba6e5f6e3b2c492ab0d2c48135fe9b6f1\":{\"direction\":\"desc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" DESC NULLS LAST\"},\"o_ff961ab1d167afd75187b865cadd8aed2f0300eeb223fd70f8f9d66908c8e2bc\":{\"direction\":\"asc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" ASC NULLS LAST\"}},\"predicates\":{\"p_03d638d2c92b093c2c7fa3437b8d02a5baecd9845b3d5f57835324d9ea52fda1\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NOT NULL\"},\"p_050a1af83ccde7526057f4e1a055cb67f4c5fe1306c718db11bbfb6b6cae8bd6\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NULL\"},\"p_09e3ecc035702ec5f0d50ce2e15e306f3bdbacf8253788717e691cadd9cb8a28\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NULL\"},\"p_0cf943489f3cad52b9ee8725744965fed6a420d718782a8887e4fd983f932234\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NOT NULL\"},\"p_0e978acebbaad0eed202c4f5d1f9482c090525ee94847d2c7671479fdc12bb99\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NULL\"},\"p_0fc44a60adf722277fd4eca446daa4fcaa091ced17a03edaef394f9be11f3abe\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" = %s::pg_catalog.numeric\"},\"p_111c63c2b10dd5cdad120b20e6eba866d30bcd1563b115b4add95c22c74de89a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <= %s::pg_catalog.bool\"},\"p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_157eac546305ab315b4e0796772e3baf4fce901a33a03f95ba927c9ffc1391d0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <= %s::pg_catalog.numeric\"},\"p_203358b59727d1c8ee9a4c25db6bba08c7943316a2aefe3450a3052cb454e6c3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" >= %s::pg_catalog.bool\"},\"p_22b0327e2c19305617f40c361bbdc1073a94b1645bbf398b3453e8b0e7573bd2\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" > %s::pg_catalog.numeric\"},\"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_3548c3f371660103886c401d41ccfa5ac10e6e4c5478fa0e97c9ec1f2d9087e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" = %s::pg_catalog.bool\"},\"p_381f7fa6395aca5f24ca8e7f7768665df3a156c67d18fada637ed6310d32f8ae\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NOT NULL\"},\"p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_39d05177a444f0016a41bd27e4aa65e0272e75b407627ddfca6f1298d3781ef5\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NOT NULL\"},\"p_3fdb92db3db597dde503d73dce1ef660bd3c2ffcbe99e1ab404ee17e5fb7cecc\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <= %s::pg_catalog.numeric\"},\"p_400a727eb67b40961d789da7ff5948cca469189f1d51940e9a88a7312e253fcf\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"amount\\\" >= %s::pg_catalog.numeric\"},\"p_420d683fa8d3ccc76d0c2367d68ed35b7a49cdec3a57596a96cde7099535d2f3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" < %s::pg_catalog.bool\"},\"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_4b89f6512c45818ecdd7de767aa66d592ffe59b053e76a5e6b9a10618867b814\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <> %s::pg_catalog.numeric\"},\"p_5418967f8687f66e8309d33c4d4ab0fb17eb57c35e4419dd0aed0ebafbf9f9b1\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NOT NULL\"},\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_7a91b5bfdbcbbcaa85d8058c5cc7b0553d5a6717d4ca65c8057c515501dd2859\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"amount\\\" = %s::pg_catalog.numeric\"},\"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_a5e5dc0faad2aa98813081e26fe9dcd7b9f8f51fe3463578dfb99ae36e6437d1\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" < %s::pg_catalog.numeric\"},\"p_a6f77d22ddf5fdf1610271ccd1f093d1180c0f3a78bf754b0fae5d09fd9411e4\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" > %s::pg_catalog.numeric\"},\"p_a80fa9a7d9b8ed0f2cff0c32a92484a27d021887d0a24b111ea22ab99ea9825b\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" < %s::pg_catalog.numeric\"},\"p_af638d02728b0039045dd0f34b815841c1c33f2409e76193fa0b274c28e603aa\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <> %s::pg_catalog.numeric\"},\"p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_b095c1238e10e5dc695c3cc2f91e557f8ffb5f64c6f125b4f95ff14063ae61d4\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NOT NULL\"},\"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_ba3ac0cba39f891efb4a92e1f74fbf91a644064e2dccd832a42a90ad0e097db0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <> %s::pg_catalog.bool\"},\"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_c0c6f3b8d227000f2be0e579df5600a920a009ab83fbb2fb59344788e5a6956c\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NULL\"},\"p_cab6533d8c6e88bdc66b5bc8dcb6b7c5220e7655fddaa61cd4f1973a84da7265\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" >= %s::pg_catalog.numeric\"},\"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_cf74f652fba0ab001f58905ac36f0ca215dfe77499aacb56a04f172281206e1a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" > %s::pg_catalog.bool\"},\"p_dbea0f6e9f2eba7a14c4a30b19eae79157cbb8df96b8c59c8ce76a2f50119469\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NULL\"},\"p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_f3b93102e4865e28e14070143d84f0b551d3cd55752acdbbc16460e6ef98c440\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NULL\"},\"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"}},\"primaryKey\":[{\"fieldId\":\"demo/id\",\"predicateId\":\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\"}],\"primaryKeyId\":\"primary\",\"record\":\"Note\",\"terminals\":{\"count\":{\"cardinality\":\"one-integer\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_count\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"selectSql\":\"pg_catalog.count(*) AS \\\"__weft_count\\\"\"},\"exists\":{\"cardinality\":\"row-presence\",\"limit\":1,\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_exists\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"selectSql\":\"true AS \\\"__weft_exists\\\"\"},\"first\":{\"cardinality\":\"zero-or-one\",\"limit\":1},\"get\":{\"cardinality\":\"exactly-one\",\"limit\":2},\"one\":{\"cardinality\":\"exactly-one\",\"limit\":2}}}},\"source\":{\"modelSha256\":\"6316416d9fd7a6a96616d1bc4a13f5b37ec2dc311f9d27a3c1f56ce6666d07af\",\"module\":\"demo\"},\"target\":{\"bindingDigest\":\"5ca97fa23f8740d9a8b189b31a8d401136551c5857d36eff50245488b5cb7e22\",\"id\":\"postgresql18\",\"modelSha256\":\"6316416d9fd7a6a96616d1bc4a13f5b37ec2dc311f9d27a3c1f56ce6666d07af\"},\"version\":\"weft.generated-read-algebra/2\"}" + } +} diff --git a/tests/runtime/generated_read_v3_fixture.json b/tests/runtime/generated_read_v3_fixture.json new file mode 100644 index 0000000..dd1bcdb --- /dev/null +++ b/tests/runtime/generated_read_v3_fixture.json @@ -0,0 +1,14 @@ +{ + "provenance": { + "role": "Rust-issued guarded v3 artifact for fabricated host boundary tests; no database behavior claimed.", + "weftWheelSha256": "91c94d2831cd39e37b6b274b4e5a62914e54c163b3fdc81aeff9457faf215aab", + "receipt": "Explicit local test trust; no production issuer or installation reference." + }, + "entries": { + "trusted-artifact.json": "{\"artifactDigest\":\"6e8ee1e7709366d9df45230426f34683700852736141710c379d3d598e47984d\",\"artifactId\":\"generated-read-fixture-2c88ebbb\",\"buildId\":\"pg18-generated-read-2c88ebbb\",\"inventory\":[[\"algebra/read.json\",\"a8db4ef32c4067592c1262a040276e1ffd5352ecb8172fae28c5c008db5b4af9\"],[\"native/native-table-source.json\",\"e232cfa169ce83959b4c309217bda7f8b3fe912905ffd70c426bc23262b6499a\"]],\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"sourceDigest\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\",\"targetBindingDigest\":\"92824a93c50760776504ecd65f7b0b7e689e43b1b66e1ce0750e82a84ca5f8b6\"}", + "manifest.json": "{\"algebra\":{\"algebraPath\":\"algebra/read.json\",\"profile\":\"weft.generated-read-algebra/3\"},\"artifactDigest\":\"6e8ee1e7709366d9df45230426f34683700852736141710c379d3d598e47984d\",\"artifactId\":\"generated-read-fixture-2c88ebbb\",\"executor\":{\"abiMajor\":1,\"maxMinor\":3,\"minMinor\":3,\"packageId\":\"umf-access-generated-executor\"},\"generator\":{\"abi\":\"weft.generated-execution/1\",\"umfDistribution\":\"umf-core\",\"umfSourceDigest\":\"1ee3ccce0c86aa53c15181ea31ecf9c495be8a0374c7ea22d9bdd7b5fa1124b3\",\"umfVersion\":\"0.10.0\",\"weftDistribution\":\"weft-sql\",\"weftSourceDigest\":\"cd0fa27c9580742333d14e24d5ebfd74babb47d31720bb4c577278d05486f11d\",\"weftVersion\":\"0.4.60.dev1\"},\"inventory\":{\"algebra/read.json\":\"a8db4ef32c4067592c1262a040276e1ffd5352ecb8172fae28c5c008db5b4af9\",\"native/native-table-source.json\":\"e232cfa169ce83959b4c309217bda7f8b3fe912905ffd70c426bc23262b6499a\"},\"programs\":{},\"provenance\":{\"buildId\":\"pg18-generated-read-2c88ebbb\",\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"},\"source\":{\"bundleInputDigest\":\"a43f1b7938e916a00063ce21f8dfb4b226b0e284d9eb036fe3a5b8b4974ea147\",\"coreVersion\":\"0.10.0\",\"documentId\":\"synthetic-table-lifecycle\",\"moduleIds\":[\"demo\"],\"sha256\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\"},\"target\":{\"bindingDigest\":\"92824a93c50760776504ecd65f7b0b7e689e43b1b66e1ce0750e82a84ca5f8b6\",\"id\":\"postgresql18\",\"profile\":\"pg18/1\",\"version\":\"18\"},\"version\":\"weft.generated-execution/1\"}", + "receipt.json": "{\"payloadDigest\":\"da130a6baf752042281c7ec9679783018c5c786a68993c4940945d9bc78578d3\"}", + "native/native-table-source.json": "{\"bundleDigest\":\"cb4d87b9371434807f350c2aeca610f0da9382bea115a5013a578a23a28b56e7\",\"configuration\":{\"batchRole\":\"generated_batch_2c88ebbb\",\"groupRoles\":{},\"module\":\"demo\",\"ownerRole\":\"generated_owner_2c88ebbb\",\"personRole\":\"generated_person_2c88ebbb\",\"schema\":\"generated_fixture_2c88ebbb\"},\"configurationDigest\":\"1d8b4dbd685997e80264e001d9c91cffaab791f23a898536120b269cd383c828\",\"expectedCatalog\":{\"checks\":[{\"id\":\"domain:demo.amount\"},{\"id\":\"domain:demo.day\"},{\"id\":\"domain:demo.observed\"}],\"tables\":[{\"columns\":[{\"field\":{\"element\":\"id\",\"module\":\"demo\"},\"name\":\"id\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"owner\",\"module\":\"demo\"},\"name\":\"owner\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"enabled\",\"module\":\"demo\"},\"name\":\"enabled\",\"nativeType\":{\"kind\":\"boolean\"}},{\"field\":{\"element\":\"attempts\",\"module\":\"demo\"},\"name\":\"attempts\",\"nativeType\":{\"kind\":\"int8\"}},{\"field\":{\"element\":\"amount\",\"module\":\"demo\"},\"name\":\"amount\",\"nativeType\":{\"kind\":\"numeric\",\"precision\":8,\"scale\":2}},{\"field\":{\"element\":\"day\",\"module\":\"demo\"},\"name\":\"day\",\"nativeType\":{\"kind\":\"date\"}},{\"field\":{\"element\":\"observed\",\"module\":\"demo\"},\"name\":\"observed\",\"nativeType\":{\"kind\":\"timestamptz\"}},{\"field\":{\"element\":\"guid\",\"module\":\"demo\"},\"name\":\"guid\",\"nativeType\":{\"kind\":\"uuid\"}},{\"field\":{\"element\":\"payload\",\"module\":\"demo\"},\"name\":\"payload\",\"nativeType\":{\"kind\":\"text\"}}],\"id\":\"notes\",\"name\":\"notes\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}]},\"operations\":[],\"sourceDigest\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\",\"version\":\"umf.native-table-source/2\"}", + "algebra/read.json": "{\"readiness\":\"weft.generated-read-executable/3\",\"roots\":{\"demo/Note\":{\"defaultSelection\":[\"demo/id\",\"demo/owner\",\"demo/enabled\",\"demo/attempts\",\"demo/amount\",\"demo/day\",\"demo/observed\",\"demo/guid\",\"demo/payload\"],\"fields\":{\"demo/amount\":{\"frameSelectSql\":\"f.\\\"__weft_field_4\\\"\",\"output\":{\"carrier\":\"decimal\",\"name\":\"__weft_field_4\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"amount\\\" AS \\\"__weft_field_4\\\"\",\"sourceField\":{\"element\":\"amount\",\"module\":\"demo\"}},\"demo/attempts\":{\"frameSelectSql\":\"f.\\\"__weft_field_3\\\"\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_field_3\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"attempts\\\" AS \\\"__weft_field_3\\\"\",\"sourceField\":{\"element\":\"attempts\",\"module\":\"demo\"}},\"demo/day\":{\"frameSelectSql\":\"f.\\\"__weft_field_5\\\"\",\"output\":{\"carrier\":\"date\",\"name\":\"__weft_field_5\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"day\\\" AS \\\"__weft_field_5\\\"\",\"sourceField\":{\"element\":\"day\",\"module\":\"demo\"}},\"demo/enabled\":{\"frameSelectSql\":\"f.\\\"__weft_field_2\\\"\",\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_field_2\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"enabled\\\" AS \\\"__weft_field_2\\\"\",\"sourceField\":{\"element\":\"enabled\",\"module\":\"demo\"}},\"demo/guid\":{\"frameSelectSql\":\"f.\\\"__weft_field_7\\\"\",\"output\":{\"carrier\":\"uuid\",\"name\":\"__weft_field_7\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"guid\\\" AS \\\"__weft_field_7\\\"\",\"sourceField\":{\"element\":\"guid\",\"module\":\"demo\"}},\"demo/id\":{\"frameSelectSql\":\"f.\\\"__weft_field_0\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_0\\\"\",\"sourceField\":{\"element\":\"id\",\"module\":\"demo\"}},\"demo/observed\":{\"frameSelectSql\":\"f.\\\"__weft_field_6\\\"\",\"output\":{\"carrier\":\"timestamp\",\"name\":\"__weft_field_6\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"observed\\\" AS \\\"__weft_field_6\\\"\",\"sourceField\":{\"element\":\"observed\",\"module\":\"demo\"}},\"demo/owner\":{\"frameSelectSql\":\"f.\\\"__weft_field_1\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_1\\\"\",\"sourceField\":{\"element\":\"owner\",\"module\":\"demo\"}},\"demo/payload\":{\"frameSelectSql\":\"f.\\\"__weft_field_8\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_8\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_8\\\"\",\"sourceField\":{\"element\":\"payload\",\"module\":\"demo\"}}},\"frameOrdinalSql\":\"ROW_NUMBER() OVER (ORDER BY {{ORDER_SQL}}) AS \\\"__weft_ordinal\\\"\",\"frameScalarOrdinalSql\":\"1::pg_catalog.int8 AS \\\"__weft_ordinal\\\"\",\"fromSql\":\"FROM \\\"generated_fixture_2c88ebbb\\\".\\\"notes\\\" AS \\\"r\\\"\",\"keyTieOrder\":[\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\"],\"maxRows\":1000,\"module\":\"demo\",\"nativeReadGuard\":{\"byteMetric\":\"pg18-row-json-utf8/1\",\"maxNativeBytes\":8388608,\"partialFrames\":false,\"profile\":\"pg18-composed-native-frame/1\",\"sqlstate\":\"22012\",\"template\":{\"sha256\":\"8e77d3b07a72ced53b0a9155201072669b88971129569c0a5c7228f8319bab9a\",\"sql\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED ({{SOURCE_SQL}}), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT {{RETURN_COLUMNS}} FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"version\":\"weft.pg18-composed-frame-template/1\"}},\"obligations\":{\"baseTablesOnly\":true,\"noBypassRls\":true,\"principal\":\"caller-connection-role\",\"rls\":\"native-caller-role\",\"rowCap\":1000,\"schema\":\"generated_fixture_2c88ebbb\",\"searchPath\":[\"pg_catalog\"],\"tableLifecycle\":{\"configurationDigest\":\"1d8b4dbd685997e80264e001d9c91cffaab791f23a898536120b269cd383c828\",\"cursorScope\":[\"module\",\"sourceDigest\",\"configurationDigest\",\"deploymentDigest\",\"ledgerHeadDigest\",\"principal\",\"roleScopeDigest\"],\"deploymentDigest\":\"cb4d87b9371434807f350c2aeca610f0da9382bea115a5013a578a23a28b56e7\",\"generationLock\":\"shared-before-admission-through-transaction\",\"installedAuthority\":\"approved-forward-ledger-and-source-derived-native-witness\",\"module\":\"demo\",\"nativeExecutionQualified\":false,\"policy\":\"source-command-policy-and-native-forced-rls\",\"principal\":\"verified-person-or-batch\",\"privileges\":\"source-grants-and-native-effective-closure\",\"roleScope\":\"native-transitive-current\",\"sourceDigest\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\",\"sourceInterpretation\":\"original-umf-deployment-compiler\",\"tables\":[{\"command\":\"select\",\"id\":\"notes\",\"native\":\"notes\",\"policySourcePath\":\"/modules/0/extensions/umf.tables/tables/0/policy\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}],\"version\":\"umf.table-lifecycle/0.1\"},\"timeout\":\"per-call\",\"transaction\":\"read-only\"},\"orders\":{\"o_00eae1be71508ce30cd4821e6497756f3f63b6e0412041f8183e8d3747970581\":{\"direction\":\"desc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" DESC NULLS LAST\"},\"o_09612a020dc0b9aa368e5fafec4455f78ba488d92556c655723e7ae2814623e6\":{\"direction\":\"desc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" DESC NULLS LAST\"},\"o_0b8d9a7134c985cecf97062bb7bc25d2100f0200012300c3f7e2d5bc3fc22b29\":{\"direction\":\"asc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_43ccf2bfa659d03559ce77fbdfe6db17ed665c79e93dbf7e7dc10e795c584752\":{\"direction\":\"asc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" ASC NULLS LAST\"},\"o_48f82d564f190f6fced51ad685ec82d46d05cccb4595aa64f8af2ca580383712\":{\"direction\":\"asc\",\"fieldId\":\"demo/payload\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_4eaa395ffe6ab47f937ca98ee6a76e38c7b58903805f5ef9520535abec78e841\":{\"direction\":\"desc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" DESC NULLS LAST\"},\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\":{\"direction\":\"asc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_5a0fa7505aa54d61a046902644ae78f61e540c0c9f160cac6312e98032ffcaf8\":{\"direction\":\"asc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" ASC NULLS LAST\"},\"o_6f9c8ccfbee4bb080d50ffb7532961cddac6c71693c3ef8a2c1e56dfaf696e83\":{\"direction\":\"desc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" DESC NULLS LAST\"},\"o_71c99cd89f02a63fdeab9bb29c0659ecb541a2679bdcef79df7d7c1a87f78cd9\":{\"direction\":\"asc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" ASC NULLS LAST\"},\"o_7f089caf246c21027d14b1336adf78a49fbd458b954cd8993c53259a7ceb5cac\":{\"direction\":\"desc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_808213c3613705a667d9b264780950ff2f12afb77d20ec6f633e34722343d848\":{\"direction\":\"asc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" ASC NULLS LAST\"},\"o_99765136a4dbe11c46bfde088a8f862ea25e3267e4a5ade1c2f1cf5d07c79e00\":{\"direction\":\"desc\",\"fieldId\":\"demo/payload\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_b3a5c63f47353c307a80d6e232dd9cd903b727fc9b0762643fb68c9236c1421d\":{\"direction\":\"asc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" ASC NULLS LAST\"},\"o_bf4f32c943a3f3a0bdd9b050f5bba7dbb9d0ca1320334e64fccad3a1a11290a5\":{\"direction\":\"desc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_e2f88c3bc6af3ddb3265f65c3a2ae4de4ad2570ed3a6898381ccf93789ad3de1\":{\"direction\":\"desc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" DESC NULLS LAST\"},\"o_f44a4a5a9eb548d37bd03712a543820ba6e5f6e3b2c492ab0d2c48135fe9b6f1\":{\"direction\":\"desc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" DESC NULLS LAST\"},\"o_ff961ab1d167afd75187b865cadd8aed2f0300eeb223fd70f8f9d66908c8e2bc\":{\"direction\":\"asc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" ASC NULLS LAST\"}},\"predicates\":{\"p_03d638d2c92b093c2c7fa3437b8d02a5baecd9845b3d5f57835324d9ea52fda1\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NOT NULL\"},\"p_050a1af83ccde7526057f4e1a055cb67f4c5fe1306c718db11bbfb6b6cae8bd6\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NULL\"},\"p_09e3ecc035702ec5f0d50ce2e15e306f3bdbacf8253788717e691cadd9cb8a28\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NULL\"},\"p_0cf943489f3cad52b9ee8725744965fed6a420d718782a8887e4fd983f932234\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NOT NULL\"},\"p_0e978acebbaad0eed202c4f5d1f9482c090525ee94847d2c7671479fdc12bb99\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NULL\"},\"p_0fc44a60adf722277fd4eca446daa4fcaa091ced17a03edaef394f9be11f3abe\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" = %s::pg_catalog.numeric\"},\"p_111c63c2b10dd5cdad120b20e6eba866d30bcd1563b115b4add95c22c74de89a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <= %s::pg_catalog.bool\"},\"p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_157eac546305ab315b4e0796772e3baf4fce901a33a03f95ba927c9ffc1391d0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <= %s::pg_catalog.numeric\"},\"p_203358b59727d1c8ee9a4c25db6bba08c7943316a2aefe3450a3052cb454e6c3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" >= %s::pg_catalog.bool\"},\"p_22b0327e2c19305617f40c361bbdc1073a94b1645bbf398b3453e8b0e7573bd2\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" > %s::pg_catalog.numeric\"},\"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_3548c3f371660103886c401d41ccfa5ac10e6e4c5478fa0e97c9ec1f2d9087e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" = %s::pg_catalog.bool\"},\"p_381f7fa6395aca5f24ca8e7f7768665df3a156c67d18fada637ed6310d32f8ae\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NOT NULL\"},\"p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_39d05177a444f0016a41bd27e4aa65e0272e75b407627ddfca6f1298d3781ef5\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NOT NULL\"},\"p_3d57a5cdf8cf9a8172dd7d1c89ba84a156444e2b1e0b9096e52605b6e6534fea\":{\"arity\":0,\"fieldId\":\"demo/payload\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_3fdb92db3db597dde503d73dce1ef660bd3c2ffcbe99e1ab404ee17e5fb7cecc\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <= %s::pg_catalog.numeric\"},\"p_400a727eb67b40961d789da7ff5948cca469189f1d51940e9a88a7312e253fcf\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"amount\\\" >= %s::pg_catalog.numeric\"},\"p_420d683fa8d3ccc76d0c2367d68ed35b7a49cdec3a57596a96cde7099535d2f3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" < %s::pg_catalog.bool\"},\"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_45bf6b74fc696f7fa4b5b6318b05615c2bd9606d79aa49a9b0a31c03ef098791\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_4b89f6512c45818ecdd7de767aa66d592ffe59b053e76a5e6b9a10618867b814\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <> %s::pg_catalog.numeric\"},\"p_5418967f8687f66e8309d33c4d4ab0fb17eb57c35e4419dd0aed0ebafbf9f9b1\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NOT NULL\"},\"p_567b3cd186376556dcd709955569967f03ba658873c7a58bb691aa507461fef6\":{\"arity\":0,\"fieldId\":\"demo/payload\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_77402cd6b700e4ce0f3eac348e264d0e10b815d173f2592eac3fd59fea334188\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_7a91b5bfdbcbbcaa85d8058c5cc7b0553d5a6717d4ca65c8057c515501dd2859\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"amount\\\" = %s::pg_catalog.numeric\"},\"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_99897869bd3e174611ef5db55cfb560c213c08e5118c8a045b20636a0ce98a3c\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_a5e5dc0faad2aa98813081e26fe9dcd7b9f8f51fe3463578dfb99ae36e6437d1\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" < %s::pg_catalog.numeric\"},\"p_a6f77d22ddf5fdf1610271ccd1f093d1180c0f3a78bf754b0fae5d09fd9411e4\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" > %s::pg_catalog.numeric\"},\"p_a80fa9a7d9b8ed0f2cff0c32a92484a27d021887d0a24b111ea22ab99ea9825b\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" < %s::pg_catalog.numeric\"},\"p_af638d02728b0039045dd0f34b815841c1c33f2409e76193fa0b274c28e603aa\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <> %s::pg_catalog.numeric\"},\"p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_b095c1238e10e5dc695c3cc2f91e557f8ffb5f64c6f125b4f95ff14063ae61d4\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NOT NULL\"},\"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_ba3ac0cba39f891efb4a92e1f74fbf91a644064e2dccd832a42a90ad0e097db0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <> %s::pg_catalog.bool\"},\"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_c0c6f3b8d227000f2be0e579df5600a920a009ab83fbb2fb59344788e5a6956c\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NULL\"},\"p_cab6533d8c6e88bdc66b5bc8dcb6b7c5220e7655fddaa61cd4f1973a84da7265\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" >= %s::pg_catalog.numeric\"},\"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_cf74f652fba0ab001f58905ac36f0ca215dfe77499aacb56a04f172281206e1a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" > %s::pg_catalog.bool\"},\"p_dbea0f6e9f2eba7a14c4a30b19eae79157cbb8df96b8c59c8ce76a2f50119469\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NULL\"},\"p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_f3b93102e4865e28e14070143d84f0b551d3cd55752acdbbc16460e6ef98c440\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NULL\"},\"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_f48b4887cc27a6fb296c1689e1474142c716a77c6c54b53e41ad021504ca772d\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_f82fd7bb7da02f71377cc3b97f319dd5586b7cdf2774204b97da69799df99dc3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_ff6fa097f64094454ca9657d0d6f9ed65827e0ddcd0c1e8275c0d72e125289da\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"}},\"primaryKey\":[{\"fieldId\":\"demo/id\",\"predicateId\":\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\"}],\"primaryKeyId\":\"primary\",\"record\":\"Note\",\"terminals\":{\"count\":{\"cardinality\":\"one-integer\",\"frameSelectSql\":\"f.\\\"__weft_count\\\"\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_count\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"selectSql\":\"pg_catalog.count(*) AS \\\"__weft_count\\\"\"},\"exists\":{\"cardinality\":\"row-presence\",\"frameSelectSql\":\"f.\\\"__weft_exists\\\"\",\"limit\":1,\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_exists\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"selectSql\":\"true AS \\\"__weft_exists\\\"\"},\"first\":{\"cardinality\":\"zero-or-one\",\"limit\":1},\"get\":{\"cardinality\":\"exactly-one\",\"limit\":2},\"one\":{\"cardinality\":\"exactly-one\",\"limit\":2}}}},\"source\":{\"modelSha256\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\",\"module\":\"demo\"},\"target\":{\"bindingDigest\":\"92824a93c50760776504ecd65f7b0b7e689e43b1b66e1ce0750e82a84ca5f8b6\",\"id\":\"postgresql18\",\"modelSha256\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\"},\"version\":\"weft.generated-read-algebra/3\"}" + } +} diff --git a/tests/runtime/generated_read_v4_fixture.json b/tests/runtime/generated_read_v4_fixture.json new file mode 100644 index 0000000..7653ded --- /dev/null +++ b/tests/runtime/generated_read_v4_fixture.json @@ -0,0 +1,10 @@ +{ + "provenance": "Rust-issued v4 artifact for provider boundary tests; local synthetic receipt only", + "entries": { + "algebra/read.json": "{\"readiness\":\"weft.generated-read-executable/4\",\"roots\":{\"demo/Note\":{\"defaultSelection\":[\"demo/id\",\"demo/owner\",\"demo/enabled\",\"demo/attempts\",\"demo/amount\",\"demo/day\",\"demo/observed\",\"demo/guid\",\"demo/payload\"],\"fields\":{\"demo/amount\":{\"frameSelectSql\":\"f.\\\"__weft_field_4\\\"\",\"output\":{\"carrier\":\"decimal\",\"name\":\"__weft_field_4\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"amount\\\" AS \\\"__weft_field_4\\\"\",\"sourceField\":{\"element\":\"amount\",\"module\":\"demo\"}},\"demo/attempts\":{\"frameSelectSql\":\"f.\\\"__weft_field_3\\\"\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_field_3\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"attempts\\\" AS \\\"__weft_field_3\\\"\",\"sourceField\":{\"element\":\"attempts\",\"module\":\"demo\"}},\"demo/day\":{\"frameSelectSql\":\"f.\\\"__weft_field_5\\\"\",\"output\":{\"carrier\":\"date\",\"name\":\"__weft_field_5\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"day\\\" AS \\\"__weft_field_5\\\"\",\"sourceField\":{\"element\":\"day\",\"module\":\"demo\"}},\"demo/enabled\":{\"frameSelectSql\":\"f.\\\"__weft_field_2\\\"\",\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_field_2\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"enabled\\\" AS \\\"__weft_field_2\\\"\",\"sourceField\":{\"element\":\"enabled\",\"module\":\"demo\"}},\"demo/guid\":{\"frameSelectSql\":\"f.\\\"__weft_field_7\\\"\",\"output\":{\"carrier\":\"uuid\",\"name\":\"__weft_field_7\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"guid\\\" AS \\\"__weft_field_7\\\"\",\"sourceField\":{\"element\":\"guid\",\"module\":\"demo\"}},\"demo/id\":{\"frameSelectSql\":\"f.\\\"__weft_field_0\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_0\\\"\",\"sourceField\":{\"element\":\"id\",\"module\":\"demo\"}},\"demo/observed\":{\"frameSelectSql\":\"f.\\\"__weft_field_6\\\"\",\"output\":{\"carrier\":\"timestamp\",\"name\":\"__weft_field_6\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"observed\\\" AS \\\"__weft_field_6\\\"\",\"sourceField\":{\"element\":\"observed\",\"module\":\"demo\"}},\"demo/owner\":{\"frameSelectSql\":\"f.\\\"__weft_field_1\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_1\\\"\",\"sourceField\":{\"element\":\"owner\",\"module\":\"demo\"}},\"demo/payload\":{\"frameSelectSql\":\"f.\\\"__weft_field_8\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_8\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_8\\\"\",\"sourceField\":{\"element\":\"payload\",\"module\":\"demo\"}}},\"frameOrdinalSql\":\"ROW_NUMBER() OVER (ORDER BY {{ORDER_SQL}}) AS \\\"__weft_ordinal\\\"\",\"frameScalarOrdinalSql\":\"1::pg_catalog.int8 AS \\\"__weft_ordinal\\\"\",\"fromSql\":\"FROM \\\"generated_fixture_schema\\\".\\\"notes\\\" AS \\\"r\\\"\",\"getMany\":{\"keyFields\":[{\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\"}],\"keyId\":\"primary\",\"keyTupleSql\":\"(%s::pg_catalog.int8, %s::pg_catalog.text)\",\"maxKeys\":100,\"ordinalOutput\":{\"carrier\":\"integer\",\"name\":\"__weft_ordinal\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"presentOutput\":{\"carrier\":\"boolean\",\"name\":\"__weft_present\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"profile\":\"weft.generated-key-batch/1\",\"sourceSqlTemplate\":\"WITH \\\"__weft_key_rows\\\" (\\\"__weft_ordinal\\\", \\\"__weft_key_0\\\") AS (VALUES {{KEY_ROWS}}) SELECT k.\\\"__weft_ordinal\\\" AS \\\"__weft_ordinal\\\", (\\\"r\\\".\\\"id\\\" IS NOT NULL) AS \\\"__weft_present\\\"{{SELECT_COLUMNS}} FROM \\\"__weft_key_rows\\\" AS k LEFT JOIN \\\"generated_fixture_schema\\\".\\\"notes\\\" AS \\\"r\\\" ON \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" = k.\\\"__weft_key_0\\\" COLLATE pg_catalog.\\\"C\\\" ORDER BY k.\\\"__weft_ordinal\\\"\",\"sourceTemplateSha256\":\"93e065cdec1b13e4d4721e41fb98c6c4cf485dfece8f26404500a6787894d102\"},\"keyTieOrder\":[\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\"],\"maxRows\":1000,\"module\":\"demo\",\"nativeReadGuard\":{\"byteMetric\":\"pg18-row-json-utf8/1\",\"maxNativeBytes\":8388608,\"partialFrames\":false,\"profile\":\"pg18-composed-native-frame/1\",\"sqlstate\":\"22012\",\"template\":{\"sha256\":\"8e77d3b07a72ced53b0a9155201072669b88971129569c0a5c7228f8319bab9a\",\"sql\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED ({{SOURCE_SQL}}), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT {{RETURN_COLUMNS}} FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"version\":\"weft.pg18-composed-frame-template/1\"}},\"obligations\":{\"baseTablesOnly\":true,\"noBypassRls\":true,\"principal\":\"caller-connection-role\",\"rls\":\"native-caller-role\",\"rowCap\":1000,\"schema\":\"generated_fixture_schema\",\"searchPath\":[\"pg_catalog\"],\"tableLifecycle\":{\"configurationDigest\":\"226271891f7fb96a8bb537b47de9aea2e6f24ded310be1f0170bc974f17fab52\",\"cursorScope\":[\"module\",\"sourceDigest\",\"configurationDigest\",\"deploymentDigest\",\"ledgerHeadDigest\",\"principal\",\"roleScopeDigest\"],\"deploymentDigest\":\"832e711af4fb7bccb23048ed4b92061a6f5a6ffbfbc20e306dd6a9f6abff2ecd\",\"generationLock\":\"shared-before-admission-through-transaction\",\"installedAuthority\":\"approved-forward-ledger-and-source-derived-native-witness\",\"module\":\"demo\",\"nativeExecutionQualified\":false,\"policy\":\"source-command-policy-and-native-forced-rls\",\"principal\":\"verified-person-or-batch\",\"privileges\":\"source-grants-and-native-effective-closure\",\"roleScope\":\"native-transitive-current\",\"sourceDigest\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\",\"sourceInterpretation\":\"original-umf-deployment-compiler\",\"tables\":[{\"command\":\"select\",\"id\":\"notes\",\"native\":\"notes\",\"policySourcePath\":\"/modules/0/extensions/umf.tables/tables/0/policy\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}],\"version\":\"umf.table-lifecycle/0.1\"},\"timeout\":\"per-call\",\"transaction\":\"read-only\"},\"orders\":{\"o_00eae1be71508ce30cd4821e6497756f3f63b6e0412041f8183e8d3747970581\":{\"direction\":\"desc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" DESC NULLS LAST\"},\"o_09612a020dc0b9aa368e5fafec4455f78ba488d92556c655723e7ae2814623e6\":{\"direction\":\"desc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" DESC NULLS LAST\"},\"o_0b8d9a7134c985cecf97062bb7bc25d2100f0200012300c3f7e2d5bc3fc22b29\":{\"direction\":\"asc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_43ccf2bfa659d03559ce77fbdfe6db17ed665c79e93dbf7e7dc10e795c584752\":{\"direction\":\"asc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" ASC NULLS LAST\"},\"o_48f82d564f190f6fced51ad685ec82d46d05cccb4595aa64f8af2ca580383712\":{\"direction\":\"asc\",\"fieldId\":\"demo/payload\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_4eaa395ffe6ab47f937ca98ee6a76e38c7b58903805f5ef9520535abec78e841\":{\"direction\":\"desc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" DESC NULLS LAST\"},\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\":{\"direction\":\"asc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_5a0fa7505aa54d61a046902644ae78f61e540c0c9f160cac6312e98032ffcaf8\":{\"direction\":\"asc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" ASC NULLS LAST\"},\"o_6f9c8ccfbee4bb080d50ffb7532961cddac6c71693c3ef8a2c1e56dfaf696e83\":{\"direction\":\"desc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" DESC NULLS LAST\"},\"o_71c99cd89f02a63fdeab9bb29c0659ecb541a2679bdcef79df7d7c1a87f78cd9\":{\"direction\":\"asc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" ASC NULLS LAST\"},\"o_7f089caf246c21027d14b1336adf78a49fbd458b954cd8993c53259a7ceb5cac\":{\"direction\":\"desc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_808213c3613705a667d9b264780950ff2f12afb77d20ec6f633e34722343d848\":{\"direction\":\"asc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" ASC NULLS LAST\"},\"o_99765136a4dbe11c46bfde088a8f862ea25e3267e4a5ade1c2f1cf5d07c79e00\":{\"direction\":\"desc\",\"fieldId\":\"demo/payload\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_b3a5c63f47353c307a80d6e232dd9cd903b727fc9b0762643fb68c9236c1421d\":{\"direction\":\"asc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" ASC NULLS LAST\"},\"o_bf4f32c943a3f3a0bdd9b050f5bba7dbb9d0ca1320334e64fccad3a1a11290a5\":{\"direction\":\"desc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_e2f88c3bc6af3ddb3265f65c3a2ae4de4ad2570ed3a6898381ccf93789ad3de1\":{\"direction\":\"desc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" DESC NULLS LAST\"},\"o_f44a4a5a9eb548d37bd03712a543820ba6e5f6e3b2c492ab0d2c48135fe9b6f1\":{\"direction\":\"desc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" DESC NULLS LAST\"},\"o_ff961ab1d167afd75187b865cadd8aed2f0300eeb223fd70f8f9d66908c8e2bc\":{\"direction\":\"asc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" ASC NULLS LAST\"}},\"predicates\":{\"p_03d638d2c92b093c2c7fa3437b8d02a5baecd9845b3d5f57835324d9ea52fda1\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NOT NULL\"},\"p_050a1af83ccde7526057f4e1a055cb67f4c5fe1306c718db11bbfb6b6cae8bd6\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NULL\"},\"p_09e3ecc035702ec5f0d50ce2e15e306f3bdbacf8253788717e691cadd9cb8a28\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NULL\"},\"p_0cf943489f3cad52b9ee8725744965fed6a420d718782a8887e4fd983f932234\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NOT NULL\"},\"p_0e978acebbaad0eed202c4f5d1f9482c090525ee94847d2c7671479fdc12bb99\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NULL\"},\"p_0fc44a60adf722277fd4eca446daa4fcaa091ced17a03edaef394f9be11f3abe\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" = %s::pg_catalog.numeric\"},\"p_111c63c2b10dd5cdad120b20e6eba866d30bcd1563b115b4add95c22c74de89a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <= %s::pg_catalog.bool\"},\"p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_157eac546305ab315b4e0796772e3baf4fce901a33a03f95ba927c9ffc1391d0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <= %s::pg_catalog.numeric\"},\"p_203358b59727d1c8ee9a4c25db6bba08c7943316a2aefe3450a3052cb454e6c3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" >= %s::pg_catalog.bool\"},\"p_22b0327e2c19305617f40c361bbdc1073a94b1645bbf398b3453e8b0e7573bd2\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" > %s::pg_catalog.numeric\"},\"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_3548c3f371660103886c401d41ccfa5ac10e6e4c5478fa0e97c9ec1f2d9087e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" = %s::pg_catalog.bool\"},\"p_381f7fa6395aca5f24ca8e7f7768665df3a156c67d18fada637ed6310d32f8ae\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NOT NULL\"},\"p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_39d05177a444f0016a41bd27e4aa65e0272e75b407627ddfca6f1298d3781ef5\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NOT NULL\"},\"p_3d57a5cdf8cf9a8172dd7d1c89ba84a156444e2b1e0b9096e52605b6e6534fea\":{\"arity\":0,\"fieldId\":\"demo/payload\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_3fdb92db3db597dde503d73dce1ef660bd3c2ffcbe99e1ab404ee17e5fb7cecc\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <= %s::pg_catalog.numeric\"},\"p_400a727eb67b40961d789da7ff5948cca469189f1d51940e9a88a7312e253fcf\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"amount\\\" >= %s::pg_catalog.numeric\"},\"p_420d683fa8d3ccc76d0c2367d68ed35b7a49cdec3a57596a96cde7099535d2f3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" < %s::pg_catalog.bool\"},\"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_45bf6b74fc696f7fa4b5b6318b05615c2bd9606d79aa49a9b0a31c03ef098791\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_4b89f6512c45818ecdd7de767aa66d592ffe59b053e76a5e6b9a10618867b814\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <> %s::pg_catalog.numeric\"},\"p_5418967f8687f66e8309d33c4d4ab0fb17eb57c35e4419dd0aed0ebafbf9f9b1\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NOT NULL\"},\"p_567b3cd186376556dcd709955569967f03ba658873c7a58bb691aa507461fef6\":{\"arity\":0,\"fieldId\":\"demo/payload\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_77402cd6b700e4ce0f3eac348e264d0e10b815d173f2592eac3fd59fea334188\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_7a91b5bfdbcbbcaa85d8058c5cc7b0553d5a6717d4ca65c8057c515501dd2859\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"amount\\\" = %s::pg_catalog.numeric\"},\"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_99897869bd3e174611ef5db55cfb560c213c08e5118c8a045b20636a0ce98a3c\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_a5e5dc0faad2aa98813081e26fe9dcd7b9f8f51fe3463578dfb99ae36e6437d1\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" < %s::pg_catalog.numeric\"},\"p_a6f77d22ddf5fdf1610271ccd1f093d1180c0f3a78bf754b0fae5d09fd9411e4\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" > %s::pg_catalog.numeric\"},\"p_a80fa9a7d9b8ed0f2cff0c32a92484a27d021887d0a24b111ea22ab99ea9825b\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" < %s::pg_catalog.numeric\"},\"p_af638d02728b0039045dd0f34b815841c1c33f2409e76193fa0b274c28e603aa\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <> %s::pg_catalog.numeric\"},\"p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_b095c1238e10e5dc695c3cc2f91e557f8ffb5f64c6f125b4f95ff14063ae61d4\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NOT NULL\"},\"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_ba3ac0cba39f891efb4a92e1f74fbf91a644064e2dccd832a42a90ad0e097db0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <> %s::pg_catalog.bool\"},\"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_c0c6f3b8d227000f2be0e579df5600a920a009ab83fbb2fb59344788e5a6956c\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NULL\"},\"p_cab6533d8c6e88bdc66b5bc8dcb6b7c5220e7655fddaa61cd4f1973a84da7265\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" >= %s::pg_catalog.numeric\"},\"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_cf74f652fba0ab001f58905ac36f0ca215dfe77499aacb56a04f172281206e1a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" > %s::pg_catalog.bool\"},\"p_dbea0f6e9f2eba7a14c4a30b19eae79157cbb8df96b8c59c8ce76a2f50119469\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NULL\"},\"p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_f3b93102e4865e28e14070143d84f0b551d3cd55752acdbbc16460e6ef98c440\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NULL\"},\"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_f48b4887cc27a6fb296c1689e1474142c716a77c6c54b53e41ad021504ca772d\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_f82fd7bb7da02f71377cc3b97f319dd5586b7cdf2774204b97da69799df99dc3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_ff6fa097f64094454ca9657d0d6f9ed65827e0ddcd0c1e8275c0d72e125289da\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"}},\"primaryKey\":[{\"fieldId\":\"demo/id\",\"predicateId\":\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\"}],\"primaryKeyId\":\"primary\",\"record\":\"Note\",\"terminals\":{\"count\":{\"cardinality\":\"one-integer\",\"frameSelectSql\":\"f.\\\"__weft_count\\\"\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_count\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"selectSql\":\"pg_catalog.count(*) AS \\\"__weft_count\\\"\"},\"exists\":{\"cardinality\":\"row-presence\",\"frameSelectSql\":\"f.\\\"__weft_exists\\\"\",\"limit\":1,\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_exists\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"selectSql\":\"true AS \\\"__weft_exists\\\"\"},\"first\":{\"cardinality\":\"zero-or-one\",\"limit\":1},\"get\":{\"cardinality\":\"exactly-one\",\"limit\":2},\"one\":{\"cardinality\":\"exactly-one\",\"limit\":2}}}},\"source\":{\"modelSha256\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\",\"module\":\"demo\"},\"target\":{\"bindingDigest\":\"9e32b7188dcb0c564aae288bec54cd313094498e926ef9121e7ee376a9bf29ce\",\"id\":\"postgresql18\",\"modelSha256\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\"},\"version\":\"weft.generated-read-algebra/4\"}", + "manifest.json": "{\"algebra\":{\"algebraPath\":\"algebra/read.json\",\"profile\":\"weft.generated-read-algebra/4\"},\"artifactDigest\":\"7e29c0928b36ea1f99f7c77d908852b56d802018910f904075b0fc675f67ec9f\",\"artifactId\":\"generated-fixture-artifact-1\",\"executor\":{\"abiMajor\":1,\"maxMinor\":4,\"minMinor\":4,\"packageId\":\"umf-access-generated-executor\"},\"generator\":{\"abi\":\"weft.generated-execution/1\",\"umfDistribution\":\"umf-core\",\"umfSourceDigest\":\"1ee3ccce0c86aa53c15181ea31ecf9c495be8a0374c7ea22d9bdd7b5fa1124b3\",\"umfVersion\":\"0.10.0\",\"weftDistribution\":\"weft-sql\",\"weftSourceDigest\":\"cd0fa27c9580742333d14e24d5ebfd74babb47d31720bb4c577278d05486f11d\",\"weftVersion\":\"0.4.63.dev1\"},\"inventory\":{\"algebra/read.json\":\"8c8e91bbd942ad9a04bcaf966fec2a482d1c4b4a5705a722c31c7ac0369b4c13\",\"native/native-table-source.json\":\"7791206b9644aaa930408b3cfcafa1d4d8f4989ab7f980a03edb7aefd7c87656\"},\"programs\":{},\"provenance\":{\"buildId\":\"pg18-e2e-1\",\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"},\"source\":{\"bundleInputDigest\":\"b18d181b1554561c7694365a08072b215e483f68862659a69bca437eb668ba61\",\"coreVersion\":\"0.10.0\",\"documentId\":\"synthetic-table-lifecycle\",\"moduleIds\":[\"demo\"],\"sha256\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\"},\"target\":{\"bindingDigest\":\"9e32b7188dcb0c564aae288bec54cd313094498e926ef9121e7ee376a9bf29ce\",\"id\":\"postgresql18\",\"profile\":\"pg18/1\",\"version\":\"18\"},\"version\":\"weft.generated-execution/1\"}", + "native/native-table-source.json": "{\"bundleDigest\":\"832e711af4fb7bccb23048ed4b92061a6f5a6ffbfbc20e306dd6a9f6abff2ecd\",\"configuration\":{\"batchRole\":\"generated_fixture_batch\",\"groupRoles\":{},\"module\":\"demo\",\"ownerRole\":\"generated_fixture_owner\",\"personRole\":\"generated_fixture_person\",\"schema\":\"generated_fixture_schema\"},\"configurationDigest\":\"226271891f7fb96a8bb537b47de9aea2e6f24ded310be1f0170bc974f17fab52\",\"expectedCatalog\":{\"checks\":[{\"id\":\"domain:demo.amount\"},{\"id\":\"domain:demo.day\"},{\"id\":\"domain:demo.observed\"}],\"tables\":[{\"columns\":[{\"field\":{\"element\":\"id\",\"module\":\"demo\"},\"name\":\"id\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"owner\",\"module\":\"demo\"},\"name\":\"owner\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"enabled\",\"module\":\"demo\"},\"name\":\"enabled\",\"nativeType\":{\"kind\":\"boolean\"}},{\"field\":{\"element\":\"attempts\",\"module\":\"demo\"},\"name\":\"attempts\",\"nativeType\":{\"kind\":\"int8\"}},{\"field\":{\"element\":\"amount\",\"module\":\"demo\"},\"name\":\"amount\",\"nativeType\":{\"kind\":\"numeric\",\"precision\":8,\"scale\":2}},{\"field\":{\"element\":\"day\",\"module\":\"demo\"},\"name\":\"day\",\"nativeType\":{\"kind\":\"date\"}},{\"field\":{\"element\":\"observed\",\"module\":\"demo\"},\"name\":\"observed\",\"nativeType\":{\"kind\":\"timestamptz\"}},{\"field\":{\"element\":\"guid\",\"module\":\"demo\"},\"name\":\"guid\",\"nativeType\":{\"kind\":\"uuid\"}},{\"field\":{\"element\":\"payload\",\"module\":\"demo\"},\"name\":\"payload\",\"nativeType\":{\"kind\":\"text\"}}],\"id\":\"notes\",\"name\":\"notes\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}]},\"operations\":[],\"sourceDigest\":\"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\",\"version\":\"umf.native-table-source/2\"}", + "receipt.json": "{\"payloadDigest\": \"1339b1a6c6179184cbc5c79ef6681926a8cfefee34d8e2a5084bbdce92170bab\"}", + "trusted-artifact.json": "{\"artifactId\": \"generated-fixture-artifact-1\", \"artifactDigest\": \"7e29c0928b36ea1f99f7c77d908852b56d802018910f904075b0fc675f67ec9f\", \"receiptDigest\": \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"sourceDigest\": \"856c0e5907aa16c77769e7ad75536b7b06bfe2fb7690a547a32f51249931dbbd\", \"targetBindingDigest\": \"9e32b7188dcb0c564aae288bec54cd313094498e926ef9121e7ee376a9bf29ce\", \"inventory\": [[\"algebra/read.json\", \"8c8e91bbd942ad9a04bcaf966fec2a482d1c4b4a5705a722c31c7ac0369b4c13\"], [\"native/native-table-source.json\", \"7791206b9644aaa930408b3cfcafa1d4d8f4989ab7f980a03edb7aefd7c87656\"]], \"issuer\": \"isolated-local-fixture\", \"buildId\": \"pg18-e2e-1\"}" + } +} diff --git a/tests/runtime/generated_read_v5_fixture.json b/tests/runtime/generated_read_v5_fixture.json new file mode 100644 index 0000000..907e514 --- /dev/null +++ b/tests/runtime/generated_read_v5_fixture.json @@ -0,0 +1 @@ +{"provenance":"Issued local test fixture through UMF generated-artifact build and receipt flow. UMF codegen 0.1.0a8; Weft 0.4.64.dev1; artifact generated-read-fixture-0ddce7f5, source digest 9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8, artifact digest bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda. Local fixture issuer isolated-local-fixture, build pg18-generated-read-0ddce7f5; PostgreSQL target postgresql18/18. Exact entry bytes are preserved from the issued artifact.","entries":{"algebra/read.json":"{\"executorAbi\":{\"major\":1,\"minor\":5},\"readiness\":\"weft.generated-read-executable/5\",\"roots\":{\"demo/Note\":{\"defaultSelection\":[\"demo/id\",\"demo/owner\",\"demo/enabled\",\"demo/attempts\",\"demo/amount\",\"demo/day\",\"demo/observed\",\"demo/guid\",\"demo/payload\"],\"fields\":{\"demo/amount\":{\"frameSelectSql\":\"f.\\\"__weft_field_4\\\"\",\"output\":{\"carrier\":\"decimal\",\"name\":\"__weft_field_4\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"amount\\\" AS \\\"__weft_field_4\\\"\",\"sourceField\":{\"element\":\"amount\",\"module\":\"demo\"}},\"demo/attempts\":{\"frameSelectSql\":\"f.\\\"__weft_field_3\\\"\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_field_3\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"attempts\\\" AS \\\"__weft_field_3\\\"\",\"sourceField\":{\"element\":\"attempts\",\"module\":\"demo\"}},\"demo/day\":{\"frameSelectSql\":\"f.\\\"__weft_field_5\\\"\",\"output\":{\"carrier\":\"date\",\"name\":\"__weft_field_5\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"day\\\" AS \\\"__weft_field_5\\\"\",\"sourceField\":{\"element\":\"day\",\"module\":\"demo\"}},\"demo/enabled\":{\"frameSelectSql\":\"f.\\\"__weft_field_2\\\"\",\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_field_2\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"enabled\\\" AS \\\"__weft_field_2\\\"\",\"sourceField\":{\"element\":\"enabled\",\"module\":\"demo\"}},\"demo/guid\":{\"frameSelectSql\":\"f.\\\"__weft_field_7\\\"\",\"output\":{\"carrier\":\"uuid\",\"name\":\"__weft_field_7\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"guid\\\" AS \\\"__weft_field_7\\\"\",\"sourceField\":{\"element\":\"guid\",\"module\":\"demo\"}},\"demo/id\":{\"frameSelectSql\":\"f.\\\"__weft_field_0\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_0\\\"\",\"sourceField\":{\"element\":\"id\",\"module\":\"demo\"}},\"demo/observed\":{\"frameSelectSql\":\"f.\\\"__weft_field_6\\\"\",\"output\":{\"carrier\":\"timestamp\",\"name\":\"__weft_field_6\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"observed\\\" AS \\\"__weft_field_6\\\"\",\"sourceField\":{\"element\":\"observed\",\"module\":\"demo\"}},\"demo/owner\":{\"frameSelectSql\":\"f.\\\"__weft_field_1\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_1\\\"\",\"sourceField\":{\"element\":\"owner\",\"module\":\"demo\"}},\"demo/payload\":{\"frameSelectSql\":\"f.\\\"__weft_field_8\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_8\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_8\\\"\",\"sourceField\":{\"element\":\"payload\",\"module\":\"demo\"}}},\"forwardConnection\":{\"fieldOutputs\":[{\"fieldId\":\"demo/amount\",\"output\":{\"carrier\":\"decimal\",\"name\":\"__weft_field_4\",\"nativeType\":{\"kind\":\"numeric\",\"precision\":8,\"scale\":2},\"nullable\":false,\"oid\":1700}},{\"fieldId\":\"demo/attempts\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_field_3\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20}},{\"fieldId\":\"demo/day\",\"output\":{\"carrier\":\"date\",\"name\":\"__weft_field_5\",\"nativeType\":{\"kind\":\"date\"},\"nullable\":false,\"oid\":1082}},{\"fieldId\":\"demo/enabled\",\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_field_2\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16}},{\"fieldId\":\"demo/guid\",\"output\":{\"carrier\":\"uuid\",\"name\":\"__weft_field_7\",\"nativeType\":{\"kind\":\"uuid\"},\"nullable\":false,\"oid\":2950}},{\"fieldId\":\"demo/id\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}},{\"fieldId\":\"demo/observed\",\"output\":{\"carrier\":\"timestamp\",\"name\":\"__weft_field_6\",\"nativeType\":{\"kind\":\"timestamptz\"},\"nullable\":false,\"oid\":1184}},{\"fieldId\":\"demo/owner\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}},{\"fieldId\":\"demo/payload\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_8\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}}],\"forward\":{\"dbapiParameterOrder\":[\"after\",\"after\",\"limit\"],\"filterParameterGroup\":\"filterValues\",\"keyOutput\":{\"carrier\":\"string\",\"name\":\"__weft_connection_key\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25},\"parameterOrder\":[\"filterValues\",\"after\",\"after\",\"limit\"],\"sourceSqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC) AS \\\"__weft_ordinal\\\", \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_connection_key\\\"{{SELECT_COLUMNS}} FROM \\\"generated_fixture_0ddce7f5\\\".\\\"notes\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" > $2::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") ORDER BY \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC LIMIT $3::pg_catalog.int8), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.* FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"sourceTemplateSha256\":\"adf18845a923fc17b4b55fcc4976eab78b01538c431f47cbcb6733e1585ca0fb\",\"sqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC) AS \\\"__weft_ordinal\\\", \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_connection_key\\\"{{SELECT_COLUMNS}} FROM \\\"generated_fixture_0ddce7f5\\\".\\\"notes\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") ORDER BY \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC LIMIT %s::pg_catalog.int8), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.* FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"templateSha256\":\"a286a122f4c674bd51a08101bb571dc285a259aaa9151db96b0cc8157d5e7f14\"},\"key\":{\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"collation\":\"pg_catalog.\\\"C\\\"\",\"direction\":\"asc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_connection_key\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}},\"keyId\":\"primary\",\"lookaheadRows\":1,\"maxFirst\":100,\"nativeCollation\":\"pg_catalog.\\\"C\\\"\",\"nativeCollationPrecondition\":\"umf.generated-table-collation-c/1\",\"previous\":{\"dbapiParameterOrder\":[\"after\",\"after\"],\"filterParameterGroup\":\"filterValues\",\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_previous\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"parameterOrder\":[\"filterValues\",\"after\",\"after\"],\"sourceSqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \\\"__weft_ordinal\\\", EXISTS (SELECT 1 FROM \\\"generated_fixture_0ddce7f5\\\".\\\"notes\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NOT NULL AND \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <= $2::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") LIMIT 1) AS \\\"__weft_previous\\\"), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.\\\"__weft_previous\\\" FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"sourceTemplateSha256\":\"b0a176fac23ab9fb8be13506212eeba7759523059812dbcfdee50dfc6fb5ee72\",\"sqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \\\"__weft_ordinal\\\", EXISTS (SELECT 1 FROM \\\"generated_fixture_0ddce7f5\\\".\\\"notes\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NOT NULL AND \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") LIMIT 1) AS \\\"__weft_previous\\\"), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.\\\"__weft_previous\\\" FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"templateSha256\":\"c5b98c8a5dbe136bd81b4c0c6973aa97cdfa01f66f20164fa368b411366cc023\"},\"profile\":\"weft.generated-forward-connection/1\",\"zeroFirstProbeRows\":1},\"forwardConnectionSupport\":{\"profile\":\"weft.generated-forward-connection/1\",\"status\":\"eligible\"},\"frameOrdinalSql\":\"ROW_NUMBER() OVER (ORDER BY {{ORDER_SQL}}) AS \\\"__weft_ordinal\\\"\",\"frameScalarOrdinalSql\":\"1::pg_catalog.int8 AS \\\"__weft_ordinal\\\"\",\"fromSql\":\"FROM \\\"generated_fixture_0ddce7f5\\\".\\\"notes\\\" AS \\\"r\\\"\",\"getMany\":{\"keyFields\":[{\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\"}],\"keyId\":\"primary\",\"keyTupleSql\":\"(%s::pg_catalog.int8, %s::pg_catalog.text)\",\"maxKeys\":100,\"ordinalOutput\":{\"carrier\":\"integer\",\"name\":\"__weft_ordinal\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"presentOutput\":{\"carrier\":\"boolean\",\"name\":\"__weft_present\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"profile\":\"weft.generated-key-batch/1\",\"sourceSqlTemplate\":\"WITH \\\"__weft_key_rows\\\" (\\\"__weft_ordinal\\\", \\\"__weft_key_0\\\") AS (VALUES {{KEY_ROWS}}) SELECT k.\\\"__weft_ordinal\\\" AS \\\"__weft_ordinal\\\", (\\\"r\\\".\\\"id\\\" IS NOT NULL) AS \\\"__weft_present\\\"{{SELECT_COLUMNS}} FROM \\\"__weft_key_rows\\\" AS k LEFT JOIN \\\"generated_fixture_0ddce7f5\\\".\\\"notes\\\" AS \\\"r\\\" ON \\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" = k.\\\"__weft_key_0\\\" COLLATE pg_catalog.\\\"C\\\" ORDER BY k.\\\"__weft_ordinal\\\"\",\"sourceTemplateSha256\":\"9ad6e3cc0d026d6ac8a4bdb61e8774476b60f158ec314de51ef1777f7b80796c\"},\"keyTieOrder\":[\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\"],\"maxRows\":1000,\"module\":\"demo\",\"nativeReadGuard\":{\"byteMetric\":\"pg18-row-json-utf8/1\",\"maxNativeBytes\":8388608,\"partialFrames\":false,\"profile\":\"pg18-composed-native-frame/1\",\"sqlstate\":\"22012\",\"template\":{\"sha256\":\"8e77d3b07a72ced53b0a9155201072669b88971129569c0a5c7228f8319bab9a\",\"sql\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED ({{SOURCE_SQL}}), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT {{RETURN_COLUMNS}} FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"version\":\"weft.pg18-composed-frame-template/1\"}},\"obligations\":{\"baseTablesOnly\":true,\"noBypassRls\":true,\"principal\":\"caller-connection-role\",\"rls\":\"native-caller-role\",\"rowCap\":1000,\"schema\":\"generated_fixture_0ddce7f5\",\"searchPath\":[\"pg_catalog\"],\"tableLifecycle\":{\"configurationDigest\":\"fa96b999f708723aa3c26caedd94661bbb72176c2d28706ee948a0ebc782fcb5\",\"cursorScope\":[\"module\",\"sourceDigest\",\"configurationDigest\",\"deploymentDigest\",\"ledgerHeadDigest\",\"principal\",\"roleScopeDigest\"],\"deploymentDigest\":\"90cfe814f1ee130c1f9ea8003301b06113c6f2cdf3912978743e0da3bd7ccd67\",\"generationLock\":\"shared-before-admission-through-transaction\",\"installedAuthority\":\"approved-forward-ledger-and-source-derived-native-witness\",\"module\":\"demo\",\"nativeExecutionQualified\":false,\"policy\":\"source-command-policy-and-native-forced-rls\",\"principal\":\"verified-person-or-batch\",\"privileges\":\"source-grants-and-native-effective-closure\",\"roleScope\":\"native-transitive-current\",\"sourceDigest\":\"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8\",\"sourceInterpretation\":\"original-umf-deployment-compiler\",\"tables\":[{\"command\":\"select\",\"id\":\"notes\",\"native\":\"notes\",\"policySourcePath\":\"/modules/0/extensions/umf.tables/tables/0/policy\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}}],\"version\":\"umf.table-lifecycle/0.1\"},\"timeout\":\"per-call\",\"transaction\":\"read-only\"},\"orders\":{\"o_00eae1be71508ce30cd4821e6497756f3f63b6e0412041f8183e8d3747970581\":{\"direction\":\"desc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" DESC NULLS LAST\"},\"o_09612a020dc0b9aa368e5fafec4455f78ba488d92556c655723e7ae2814623e6\":{\"direction\":\"desc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" DESC NULLS LAST\"},\"o_0b8d9a7134c985cecf97062bb7bc25d2100f0200012300c3f7e2d5bc3fc22b29\":{\"direction\":\"asc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_43ccf2bfa659d03559ce77fbdfe6db17ed665c79e93dbf7e7dc10e795c584752\":{\"direction\":\"asc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" ASC NULLS LAST\"},\"o_48f82d564f190f6fced51ad685ec82d46d05cccb4595aa64f8af2ca580383712\":{\"direction\":\"asc\",\"fieldId\":\"demo/payload\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_4eaa395ffe6ab47f937ca98ee6a76e38c7b58903805f5ef9520535abec78e841\":{\"direction\":\"desc\",\"fieldId\":\"demo/day\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"day\\\" DESC NULLS LAST\"},\"o_554cc0ae4d09627b729a85979e5496a662f928b0f4a181c5edf2400a67aa54b1\":{\"direction\":\"asc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_5a0fa7505aa54d61a046902644ae78f61e540c0c9f160cac6312e98032ffcaf8\":{\"direction\":\"asc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" ASC NULLS LAST\"},\"o_6f9c8ccfbee4bb080d50ffb7532961cddac6c71693c3ef8a2c1e56dfaf696e83\":{\"direction\":\"desc\",\"fieldId\":\"demo/enabled\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" DESC NULLS LAST\"},\"o_71c99cd89f02a63fdeab9bb29c0659ecb541a2679bdcef79df7d7c1a87f78cd9\":{\"direction\":\"asc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" ASC NULLS LAST\"},\"o_7f089caf246c21027d14b1336adf78a49fbd458b954cd8993c53259a7ceb5cac\":{\"direction\":\"desc\",\"fieldId\":\"demo/owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_808213c3613705a667d9b264780950ff2f12afb77d20ec6f633e34722343d848\":{\"direction\":\"asc\",\"fieldId\":\"demo/attempts\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" ASC NULLS LAST\"},\"o_99765136a4dbe11c46bfde088a8f862ea25e3267e4a5ade1c2f1cf5d07c79e00\":{\"direction\":\"desc\",\"fieldId\":\"demo/payload\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_b3a5c63f47353c307a80d6e232dd9cd903b727fc9b0762643fb68c9236c1421d\":{\"direction\":\"asc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" ASC NULLS LAST\"},\"o_bf4f32c943a3f3a0bdd9b050f5bba7dbb9d0ca1320334e64fccad3a1a11290a5\":{\"direction\":\"desc\",\"fieldId\":\"demo/id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_e2f88c3bc6af3ddb3265f65c3a2ae4de4ad2570ed3a6898381ccf93789ad3de1\":{\"direction\":\"desc\",\"fieldId\":\"demo/guid\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"guid\\\" DESC NULLS LAST\"},\"o_f44a4a5a9eb548d37bd03712a543820ba6e5f6e3b2c492ab0d2c48135fe9b6f1\":{\"direction\":\"desc\",\"fieldId\":\"demo/amount\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"amount\\\" DESC NULLS LAST\"},\"o_ff961ab1d167afd75187b865cadd8aed2f0300eeb223fd70f8f9d66908c8e2bc\":{\"direction\":\"asc\",\"fieldId\":\"demo/observed\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"observed\\\" ASC NULLS LAST\"}},\"predicates\":{\"p_03d638d2c92b093c2c7fa3437b8d02a5baecd9845b3d5f57835324d9ea52fda1\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NOT NULL\"},\"p_050a1af83ccde7526057f4e1a055cb67f4c5fe1306c718db11bbfb6b6cae8bd6\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NULL\"},\"p_09e3ecc035702ec5f0d50ce2e15e306f3bdbacf8253788717e691cadd9cb8a28\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NULL\"},\"p_0cf943489f3cad52b9ee8725744965fed6a420d718782a8887e4fd983f932234\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NOT NULL\"},\"p_0e978acebbaad0eed202c4f5d1f9482c090525ee94847d2c7671479fdc12bb99\":{\"arity\":0,\"fieldId\":\"demo/guid\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"guid\\\" IS NULL\"},\"p_0fc44a60adf722277fd4eca446daa4fcaa091ced17a03edaef394f9be11f3abe\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" = %s::pg_catalog.numeric\"},\"p_111c63c2b10dd5cdad120b20e6eba866d30bcd1563b115b4add95c22c74de89a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <= %s::pg_catalog.bool\"},\"p_12aaa655fe2777a7a05810cb8a724b9444b315ecca5ffc4178c2b98121179263\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_157eac546305ab315b4e0796772e3baf4fce901a33a03f95ba927c9ffc1391d0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <= %s::pg_catalog.numeric\"},\"p_203358b59727d1c8ee9a4c25db6bba08c7943316a2aefe3450a3052cb454e6c3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" >= %s::pg_catalog.bool\"},\"p_22b0327e2c19305617f40c361bbdc1073a94b1645bbf398b3453e8b0e7573bd2\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" > %s::pg_catalog.numeric\"},\"p_257245f8dbd621d0672f565b9a12dc5629703d0848d9581cd34f5e3c51c33d60\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_329441547f886898ab3a9d5b22bdd5bde7e080a268fe93d626426c4b18454470\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_3548c3f371660103886c401d41ccfa5ac10e6e4c5478fa0e97c9ec1f2d9087e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" = %s::pg_catalog.bool\"},\"p_381f7fa6395aca5f24ca8e7f7768665df3a156c67d18fada637ed6310d32f8ae\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NOT NULL\"},\"p_383f684ebea093bd10977547b3593b8955f1bd903b5bf52174738b287d6097b3\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_39d05177a444f0016a41bd27e4aa65e0272e75b407627ddfca6f1298d3781ef5\":{\"arity\":0,\"fieldId\":\"demo/amount\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"amount\\\" IS NOT NULL\"},\"p_3d57a5cdf8cf9a8172dd7d1c89ba84a156444e2b1e0b9096e52605b6e6534fea\":{\"arity\":0,\"fieldId\":\"demo/payload\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_3fdb92db3db597dde503d73dce1ef660bd3c2ffcbe99e1ab404ee17e5fb7cecc\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <= %s::pg_catalog.numeric\"},\"p_400a727eb67b40961d789da7ff5948cca469189f1d51940e9a88a7312e253fcf\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"amount\\\" >= %s::pg_catalog.numeric\"},\"p_420d683fa8d3ccc76d0c2367d68ed35b7a49cdec3a57596a96cde7099535d2f3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" < %s::pg_catalog.bool\"},\"p_44352c199f66e860e0137e7a07403f02b079b2cb4d30e0d1c8240902f0edd36a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_45bf6b74fc696f7fa4b5b6318b05615c2bd9606d79aa49a9b0a31c03ef098791\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_4b89f6512c45818ecdd7de767aa66d592ffe59b053e76a5e6b9a10618867b814\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"amount\\\" <> %s::pg_catalog.numeric\"},\"p_5418967f8687f66e8309d33c4d4ab0fb17eb57c35e4419dd0aed0ebafbf9f9b1\":{\"arity\":0,\"fieldId\":\"demo/enabled\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" IS NOT NULL\"},\"p_567b3cd186376556dcd709955569967f03ba658873c7a58bb691aa507461fef6\":{\"arity\":0,\"fieldId\":\"demo/payload\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_6f2c5f5b84006ab29061f77ad8e1cd0a5da4de65195be49c41cad453246d4864\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_77402cd6b700e4ce0f3eac348e264d0e10b815d173f2592eac3fd59fea334188\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_7a91b5bfdbcbbcaa85d8058c5cc7b0553d5a6717d4ca65c8057c515501dd2859\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"amount\\\" = %s::pg_catalog.numeric\"},\"p_80a9e5bd207890362f8d919d2a727c58edc8fe90bcd13b71e96d440aab2cd9c9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_99897869bd3e174611ef5db55cfb560c213c08e5118c8a045b20636a0ce98a3c\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_9c9dabe311dd932247aff0be5716b77285220a49029de5640b00694da3ebcad8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_a5e5dc0faad2aa98813081e26fe9dcd7b9f8f51fe3463578dfb99ae36e6437d1\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" < %s::pg_catalog.numeric\"},\"p_a6f77d22ddf5fdf1610271ccd1f093d1180c0f3a78bf754b0fae5d09fd9411e4\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" > %s::pg_catalog.numeric\"},\"p_a80fa9a7d9b8ed0f2cff0c32a92484a27d021887d0a24b111ea22ab99ea9825b\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"decimalToken\"},{\"carrier\":\"decimal\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":8,\"profile\":\"weft.exact-coefficient/1\",\"scale\":2},{\"allowedIdentities\":null,\"carrier\":\"decimal\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"decimal\",\"mode\":\"canonical-scaled-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/amount\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"amount\\\" < %s::pg_catalog.numeric\"},\"p_af638d02728b0039045dd0f34b815841c1c33f2409e76193fa0b274c28e603aa\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" <> %s::pg_catalog.numeric\"},\"p_b0377434190fe0d302e2ec3adc03431a7cc76a97cc4b7c5cbc3cf71f3e9f3a76\":{\"arity\":0,\"fieldId\":\"demo/owner\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_b095c1238e10e5dc695c3cc2f91e557f8ffb5f64c6f125b4f95ff14063ae61d4\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NOT NULL\"},\"p_b3b40393fa29495d1deb30dea3c82188f40104008bb7bc962396b6f268a018b5\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_ba3ac0cba39f891efb4a92e1f74fbf91a644064e2dccd832a42a90ad0e097db0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" <> %s::pg_catalog.bool\"},\"p_baa8c087a649b2cb8726126c69f4d0f619a707ffd1e14c0736079ec00fa4a559\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_c0c6f3b8d227000f2be0e579df5600a920a009ab83fbb2fb59344788e5a6956c\":{\"arity\":0,\"fieldId\":\"demo/observed\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"observed\\\" IS NULL\"},\"p_cab6533d8c6e88bdc66b5bc8dcb6b7c5220e7655fddaa61cd4f1973a84da7265\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"integerToken\"},{\"carrier\":\"integer\",\"maxTokenBytes\":4000000,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.exact-coefficient/1\",\"scale\":0},{\"allowedIdentities\":null,\"carrier\":\"integer\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"integer\",\"mode\":\"canonical-integer-decimal\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/attempts\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" >= %s::pg_catalog.numeric\"},\"p_cb08688a078bd5cd578fe699fbba5ea82bac9856f647e470a74abf6878d9f1e8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/owner\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"owner\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_cf74f652fba0ab001f58905ac36f0ca215dfe77499aacb56a04f172281206e1a\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"boolean\"},{\"carrier\":\"boolean\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.boolean/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"boolean\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"boolean\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/enabled\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"enabled\\\" > %s::pg_catalog.bool\"},\"p_dbea0f6e9f2eba7a14c4a30b19eae79157cbb8df96b8c59c8ce76a2f50119469\":{\"arity\":0,\"fieldId\":\"demo/day\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"day\\\" IS NULL\"},\"p_effdf46e6d5418e00d2a955b9b723ca39b5b952cc28f84ac02b640b9575b5060\":{\"arity\":0,\"fieldId\":\"demo/id\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_f3b93102e4865e28e14070143d84f0b551d3cd55752acdbbc16460e6ef98c440\":{\"arity\":0,\"fieldId\":\"demo/attempts\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"attempts\\\" IS NULL\"},\"p_f433cf613182638aeb9527f18d6206fda1e096865650b275eaacdc1b9ed203d9\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_f48b4887cc27a6fb296c1689e1474142c716a77c6c54b53e41ad021504ca772d\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_f82fd7bb7da02f71377cc3b97f319dd5586b7cdf2774204b97da69799df99dc3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_f8a7e62348b9010cb9054aa5ff863125c4eb9c4a5123d7e6880bda27ee2acf44\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/id\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_ff6fa097f64094454ca9657d0d6f9ed65827e0ddcd0c1e8275c0d72e125289da\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/payload\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"payload\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"}},\"primaryKey\":[{\"fieldId\":\"demo/id\",\"predicateId\":\"p_6a3355807726b005ca93b856d5921ad52451767d4244b960cbf9fed70783eb33\"}],\"primaryKeyId\":\"primary\",\"record\":\"Note\",\"terminals\":{\"count\":{\"cardinality\":\"one-integer\",\"frameSelectSql\":\"f.\\\"__weft_count\\\"\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_count\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"selectSql\":\"pg_catalog.count(*) AS \\\"__weft_count\\\"\"},\"exists\":{\"cardinality\":\"row-presence\",\"frameSelectSql\":\"f.\\\"__weft_exists\\\"\",\"limit\":1,\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_exists\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"selectSql\":\"true AS \\\"__weft_exists\\\"\"},\"first\":{\"cardinality\":\"zero-or-one\",\"limit\":1},\"get\":{\"cardinality\":\"exactly-one\",\"limit\":2},\"one\":{\"cardinality\":\"exactly-one\",\"limit\":2}}},\"demo/Task\":{\"defaultSelection\":[\"demo/task_id\",\"demo/task_owner\",\"demo/task_value\"],\"fields\":{\"demo/task_id\":{\"frameSelectSql\":\"f.\\\"__weft_field_0\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_0\\\"\",\"sourceField\":{\"element\":\"task_id\",\"module\":\"demo\"}},\"demo/task_owner\":{\"frameSelectSql\":\"f.\\\"__weft_field_1\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_1\\\"\",\"sourceField\":{\"element\":\"task_owner\",\"module\":\"demo\"}},\"demo/task_value\":{\"frameSelectSql\":\"f.\\\"__weft_field_2\\\"\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_2\",\"nullable\":false},\"selectSql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_field_2\\\"\",\"sourceField\":{\"element\":\"task_value\",\"module\":\"demo\"}}},\"forwardConnection\":{\"fieldOutputs\":[{\"fieldId\":\"demo/task_id\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_0\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}},{\"fieldId\":\"demo/task_owner\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_1\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}},{\"fieldId\":\"demo/task_value\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_field_2\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}}],\"forward\":{\"dbapiParameterOrder\":[\"after\",\"after\",\"limit\"],\"filterParameterGroup\":\"filterValues\",\"keyOutput\":{\"carrier\":\"string\",\"name\":\"__weft_connection_key\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25},\"parameterOrder\":[\"filterValues\",\"after\",\"after\",\"limit\"],\"sourceSqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" ASC) AS \\\"__weft_ordinal\\\", \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_connection_key\\\"{{SELECT_COLUMNS}} FROM \\\"generated_fixture_0ddce7f5\\\".\\\"tasks\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NULL OR \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" > $2::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") ORDER BY \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" ASC LIMIT $3::pg_catalog.int8), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.* FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"sourceTemplateSha256\":\"46a782e39855e39f8f3044f0552c20df9b428b86e700a1fae31073e454c20a47\",\"sqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT ROW_NUMBER() OVER (ORDER BY \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" ASC) AS \\\"__weft_ordinal\\\", \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" AS \\\"__weft_connection_key\\\"{{SELECT_COLUMNS}} FROM \\\"generated_fixture_0ddce7f5\\\".\\\"tasks\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NULL OR \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") ORDER BY \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" ASC LIMIT %s::pg_catalog.int8), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.* FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"templateSha256\":\"c246801de0000f22e6655dfbac0f5fef5defb8c5f5bf5acafc2235e4f4525655\"},\"key\":{\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"collation\":\"pg_catalog.\\\"C\\\"\",\"direction\":\"asc\",\"fieldId\":\"demo/task_id\",\"nulls\":\"last\",\"output\":{\"carrier\":\"string\",\"name\":\"__weft_connection_key\",\"nativeType\":{\"kind\":\"text\"},\"nullable\":false,\"oid\":25}},\"keyId\":\"primary\",\"lookaheadRows\":1,\"maxFirst\":100,\"nativeCollation\":\"pg_catalog.\\\"C\\\"\",\"nativeCollationPrecondition\":\"umf.generated-table-collation-c/1\",\"previous\":{\"dbapiParameterOrder\":[\"after\",\"after\"],\"filterParameterGroup\":\"filterValues\",\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_previous\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"parameterOrder\":[\"filterValues\",\"after\",\"after\"],\"sourceSqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \\\"__weft_ordinal\\\", EXISTS (SELECT 1 FROM \\\"generated_fixture_0ddce7f5\\\".\\\"tasks\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND ($1::pg_catalog.text IS NOT NULL AND \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" <= $2::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") LIMIT 1) AS \\\"__weft_previous\\\"), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.\\\"__weft_previous\\\" FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"sourceTemplateSha256\":\"5bd036c00b1b65a233573502433dd8767ab95b1c902ef938db14f99ccfa25197\",\"sqlTemplate\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED (SELECT 1::pg_catalog.int8 AS \\\"__weft_ordinal\\\", EXISTS (SELECT 1 FROM \\\"generated_fixture_0ddce7f5\\\".\\\"tasks\\\" AS \\\"r\\\" WHERE ({{FILTER}}) AND (%s::pg_catalog.text IS NOT NULL AND \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text COLLATE pg_catalog.\\\"C\\\") LIMIT 1) AS \\\"__weft_previous\\\"), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT f.\\\"__weft_previous\\\" FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"templateSha256\":\"91269cb1bd5771c5815db8c1f2415c77930680bc4820937c58f3be750d1df918\"},\"profile\":\"weft.generated-forward-connection/1\",\"zeroFirstProbeRows\":1},\"forwardConnectionSupport\":{\"profile\":\"weft.generated-forward-connection/1\",\"status\":\"eligible\"},\"frameOrdinalSql\":\"ROW_NUMBER() OVER (ORDER BY {{ORDER_SQL}}) AS \\\"__weft_ordinal\\\"\",\"frameScalarOrdinalSql\":\"1::pg_catalog.int8 AS \\\"__weft_ordinal\\\"\",\"fromSql\":\"FROM \\\"generated_fixture_0ddce7f5\\\".\\\"tasks\\\" AS \\\"r\\\"\",\"getMany\":{\"keyFields\":[{\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_id\"}],\"keyId\":\"primary\",\"keyTupleSql\":\"(%s::pg_catalog.int8, %s::pg_catalog.text)\",\"maxKeys\":100,\"ordinalOutput\":{\"carrier\":\"integer\",\"name\":\"__weft_ordinal\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"presentOutput\":{\"carrier\":\"boolean\",\"name\":\"__weft_present\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"profile\":\"weft.generated-key-batch/1\",\"sourceSqlTemplate\":\"WITH \\\"__weft_key_rows\\\" (\\\"__weft_ordinal\\\", \\\"__weft_key_0\\\") AS (VALUES {{KEY_ROWS}}) SELECT k.\\\"__weft_ordinal\\\" AS \\\"__weft_ordinal\\\", (\\\"r\\\".\\\"task_id\\\" IS NOT NULL) AS \\\"__weft_present\\\"{{SELECT_COLUMNS}} FROM \\\"__weft_key_rows\\\" AS k LEFT JOIN \\\"generated_fixture_0ddce7f5\\\".\\\"tasks\\\" AS \\\"r\\\" ON \\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" = k.\\\"__weft_key_0\\\" COLLATE pg_catalog.\\\"C\\\" ORDER BY k.\\\"__weft_ordinal\\\"\",\"sourceTemplateSha256\":\"bd03712a13b7b58ed768c0ad1914b86d8db33749b392708f9a7bb9402daf54ec\"},\"keyTieOrder\":[\"o_5977ea255ee31a2ad03e0402c0ddfa2c2058160f0ba76d119b6fed2926cad9ee\"],\"maxRows\":1000,\"module\":\"demo\",\"nativeReadGuard\":{\"byteMetric\":\"pg18-row-json-utf8/1\",\"maxNativeBytes\":8388608,\"partialFrames\":false,\"profile\":\"pg18-composed-native-frame/1\",\"sqlstate\":\"22012\",\"template\":{\"sha256\":\"8e77d3b07a72ced53b0a9155201072669b88971129569c0a5c7228f8319bab9a\",\"sql\":\"WITH \\\"__weft_source\\\" AS MATERIALIZED ({{SOURCE_SQL}}), \\\"__weft_guard\\\" AS MATERIALIZED (SELECT CASE WHEN COALESCE(pg_catalog.sum(pg_catalog.octet_length(pg_catalog.convert_to(pg_catalog.row_to_json(f)::pg_catalog.text, 'UTF8'))),0) <= 8388608 THEN 1::pg_catalog.int8 ELSE 1::pg_catalog.int8 / (pg_catalog.count(*) - pg_catalog.count(*)) END AS ok FROM \\\"__weft_source\\\" AS f) SELECT {{RETURN_COLUMNS}} FROM \\\"__weft_source\\\" AS f ORDER BY f.\\\"__weft_ordinal\\\" LIMIT ALL OFFSET (SELECT 1 - ok FROM \\\"__weft_guard\\\")\",\"version\":\"weft.pg18-composed-frame-template/1\"}},\"obligations\":{\"baseTablesOnly\":true,\"noBypassRls\":true,\"principal\":\"caller-connection-role\",\"rls\":\"native-caller-role\",\"rowCap\":1000,\"schema\":\"generated_fixture_0ddce7f5\",\"searchPath\":[\"pg_catalog\"],\"tableLifecycle\":{\"configurationDigest\":\"fa96b999f708723aa3c26caedd94661bbb72176c2d28706ee948a0ebc782fcb5\",\"cursorScope\":[\"module\",\"sourceDigest\",\"configurationDigest\",\"deploymentDigest\",\"ledgerHeadDigest\",\"principal\",\"roleScopeDigest\"],\"deploymentDigest\":\"90cfe814f1ee130c1f9ea8003301b06113c6f2cdf3912978743e0da3bd7ccd67\",\"generationLock\":\"shared-before-admission-through-transaction\",\"installedAuthority\":\"approved-forward-ledger-and-source-derived-native-witness\",\"module\":\"demo\",\"nativeExecutionQualified\":false,\"policy\":\"source-command-policy-and-native-forced-rls\",\"principal\":\"verified-person-or-batch\",\"privileges\":\"source-grants-and-native-effective-closure\",\"roleScope\":\"native-transitive-current\",\"sourceDigest\":\"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8\",\"sourceInterpretation\":\"original-umf-deployment-compiler\",\"tables\":[{\"command\":\"select\",\"id\":\"tasks\",\"native\":\"tasks\",\"policySourcePath\":\"/modules/0/extensions/umf.tables/tables/1/policy\",\"record\":{\"element\":\"Task\",\"module\":\"demo\"}}],\"version\":\"umf.table-lifecycle/0.1\"},\"timeout\":\"per-call\",\"transaction\":\"read-only\"},\"orders\":{\"o_2cf8c16783b96c127f299c73f11e67c0d52151bf61543aeedd64a9a81360d823\":{\"direction\":\"asc\",\"fieldId\":\"demo/task_owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_4a4b93d52647c5665ce56a9a3d06ed7db482c7e779912e2c9baa02dcf9ccef1b\":{\"direction\":\"desc\",\"fieldId\":\"demo/task_owner\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_5977ea255ee31a2ad03e0402c0ddfa2c2058160f0ba76d119b6fed2926cad9ee\":{\"direction\":\"asc\",\"fieldId\":\"demo/task_id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_95ba4c35b8fedcc69875691e6e609fd302c28151ca75699b7992a39bf0f407ab\":{\"direction\":\"desc\",\"fieldId\":\"demo/task_value\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"},\"o_a86e41285ff383770b5491f1bdd9fb39d06ba90660f5f1ea4c682e64620e05b8\":{\"direction\":\"asc\",\"fieldId\":\"demo/task_value\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" ASC NULLS LAST\"},\"o_f74b41538f55e63df418745334a24f0e7bc9d5ee47f004489efc914784690424\":{\"direction\":\"desc\",\"fieldId\":\"demo/task_id\",\"nulls\":\"last\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" DESC NULLS LAST\"}},\"predicates\":{\"p_15db23aad5be133798aff2c0f24e19ce914b9541d1e01689c2871d9b79aaabb6\":{\"arity\":0,\"fieldId\":\"demo/task_owner\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_2701dd12265a1c616647344bc5a61213b6746af13ae579c405e5f0cbeef769c8\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_value\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_3fda0f8540388961770e2a848cfc1e45691dbef24731b8ada6a0f1208621ca1d\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_id\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_7e84acf1375d021dde8cd7e2a9d0acb2436dd1ff821c5441eaa52bb39df706a2\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_value\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_8bc38b02eec00f2ecaa9728e5b2f61fdb369d2259638fdf7643391b0c43d64f2\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_owner\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_91c2389f287a46a68fd63c6e633d7d031ba48e56f23b7d73c2ea5e2f9a22da97\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_value\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_925c0c5233a5d77190c0c97200dbe9a6db54f448f7d045693d7518ca43c6311a\":{\"arity\":0,\"fieldId\":\"demo/task_id\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_a11000feacf92064e23350ca11ddedc77d7792746e4a2ac70b85a5adafed17b0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_id\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_a53383b358628ccb8154b1fad80eb3e18c0ea5bec793a244a54802a4c6d88317\":{\"arity\":0,\"fieldId\":\"demo/task_id\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_c0ad807f356a8be05557490e2a6dbc7ed67ab870cb7c43ded8a9b94f715297e0\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_id\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_c5d686f0df4501202fc5eef7424205785d9f1d4c8beb5db88d878b90cd67f43f\":{\"arity\":0,\"fieldId\":\"demo/task_value\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_c6c5be692050cfc32b5185cc673aecd09990e88f218f55c78f68b2e2869a655d\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_owner\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_cff4ced79c12dadf58b21fe1062e641edb6d782348359835f5e96f35a0ee1575\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_id\",\"operator\":\"gt\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" > %s::pg_catalog.text\"},\"p_d38145287a4892098d6ab625a14a2b0adadd6dde199ea59bd8000690f714b623\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_value\",\"operator\":\"ge\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" >= %s::pg_catalog.text\"},\"p_d6ec837dc329f6a3998227c0aba83111ddcb66ca50159b6e152204302fe49410\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_id\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_dc32252e06dcf37ec44a69f0e9aec517e5c13b2c9468dd51127f1e2a07fbf60d\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_owner\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_e0a3192fd6cf667398037ef443242a9defb3dbfdeea999e18cf88486c5c01965\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_value\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_e48b4564ebc594e0d76e93e4440c944a23d980cab5949d44ecbd7be9b8361b8e\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_value\",\"operator\":\"eq\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" = %s::pg_catalog.text\"},\"p_e6721bf261b97178246fa2565dc8e7c52df38ff058c234a13a721cd535f16448\":{\"arity\":0,\"fieldId\":\"demo/task_value\",\"operator\":\"is-null\",\"sql\":\"\\\"r\\\".\\\"task_value\\\" COLLATE pg_catalog.\\\"C\\\" IS NULL\"},\"p_e82f30745c3ad44d97b4184b7249b17a5fe8c48c187105694a3039d4022ce7d3\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_owner\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"},\"p_f0fc56418df0e8af83e2d00308779e217b67234edab9e59c44b70d8404538916\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_owner\",\"operator\":\"lt\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" < %s::pg_catalog.text\"},\"p_f4a225303490c5d0211e1dcf1211e6268edef0d3cb17b91a126c8d63e749a4b4\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_owner\",\"operator\":\"ne\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" <> %s::pg_catalog.text\"},\"p_fe411470e4373ce886c01e732fa9474ed29ab07adf5745b34c8c56d5fec3f6a7\":{\"arity\":0,\"fieldId\":\"demo/task_owner\",\"operator\":\"is-not-null\",\"sql\":\"\\\"r\\\".\\\"task_owner\\\" COLLATE pg_catalog.\\\"C\\\" IS NOT NULL\"},\"p_fe85af0b4698286badb008063435517fe4c39b4789eebd6645a6f8ea8490e396\":{\"arity\":1,\"codec\":{\"profile\":\"weft.query-codec-instructions/1\",\"steps\":[{\"nullable\":false,\"op\":\"require-exact-wrapper\",\"wrapper\":\"string\"},{\"carrier\":\"string\",\"maxTokenBytes\":null,\"op\":\"parse-carrier\",\"precision\":null,\"profile\":\"weft.string/1\",\"scale\":null},{\"allowedIdentities\":null,\"carrier\":\"string\",\"integerWidth\":null,\"length\":null,\"op\":\"check-refinements\",\"range\":null},{\"carrier\":\"string\",\"mode\":\"identity\",\"op\":\"normalize-native-query-value\"}]},\"fieldId\":\"demo/task_id\",\"operator\":\"le\",\"sql\":\"\\\"r\\\".\\\"task_id\\\" COLLATE pg_catalog.\\\"C\\\" <= %s::pg_catalog.text\"}},\"primaryKey\":[{\"fieldId\":\"demo/task_id\",\"predicateId\":\"p_3fda0f8540388961770e2a848cfc1e45691dbef24731b8ada6a0f1208621ca1d\"}],\"primaryKeyId\":\"primary\",\"record\":\"Task\",\"terminals\":{\"count\":{\"cardinality\":\"one-integer\",\"frameSelectSql\":\"f.\\\"__weft_count\\\"\",\"output\":{\"carrier\":\"integer\",\"name\":\"__weft_count\",\"nativeType\":{\"kind\":\"int8\"},\"nullable\":false,\"oid\":20},\"selectSql\":\"pg_catalog.count(*) AS \\\"__weft_count\\\"\"},\"exists\":{\"cardinality\":\"row-presence\",\"frameSelectSql\":\"f.\\\"__weft_exists\\\"\",\"limit\":1,\"output\":{\"carrier\":\"boolean\",\"name\":\"__weft_exists\",\"nativeType\":{\"kind\":\"boolean\"},\"nullable\":false,\"oid\":16},\"selectSql\":\"true AS \\\"__weft_exists\\\"\"},\"first\":{\"cardinality\":\"zero-or-one\",\"limit\":1},\"get\":{\"cardinality\":\"exactly-one\",\"limit\":2},\"one\":{\"cardinality\":\"exactly-one\",\"limit\":2}}}},\"source\":{\"modelSha256\":\"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8\",\"module\":\"demo\"},\"target\":{\"bindingDigest\":\"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf\",\"id\":\"postgresql18\",\"modelSha256\":\"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8\"},\"version\":\"weft.generated-read-algebra/5\"}","manifest.json":"{\"algebra\":{\"algebraPath\":\"algebra/read.json\",\"profile\":\"weft.generated-read-algebra/5\"},\"artifactDigest\":\"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda\",\"artifactId\":\"generated-read-fixture-0ddce7f5\",\"executor\":{\"abiMajor\":1,\"maxMinor\":5,\"minMinor\":5,\"packageId\":\"umf-access-generated-executor\"},\"generator\":{\"abi\":\"weft.generated-execution/1\",\"umfDistribution\":\"umf-codegen\",\"umfSourceDigest\":\"8c01f37b5b28a17cacf632cbb6f0cd83a1c99120f3d1926924be2396f9664fdb\",\"umfVersion\":\"0.1.0a8\",\"weftDistribution\":\"weft-sql\",\"weftSourceDigest\":\"78e497aa478b2a1d0845cbe4e06a21df57697cb3338a2dfe552288e52df1205f\",\"weftVersion\":\"0.4.64.dev1\"},\"inventory\":{\"algebra/read.json\":\"23a2838e9786f0e78e4163b81fb2054c5c3e4f8e076cd66edd3b27a46a99a2b2\",\"native/native-table-source.json\":\"830493868bc0f099f93f19adc7207bb9d00e43473731564ab0747331ed1f09f7\"},\"programs\":{},\"provenance\":{\"buildId\":\"pg18-generated-read-0ddce7f5\",\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\"},\"source\":{\"bundleInputDigest\":\"64ed1b62a0baac8cb3faf2a27b968b6c2e6c826f7a68b6bc8be61dccd248aac0\",\"coreVersion\":\"0.10.0\",\"documentId\":\"synthetic-table-lifecycle\",\"moduleIds\":[\"demo\"],\"sha256\":\"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8\"},\"target\":{\"bindingDigest\":\"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf\",\"id\":\"postgresql18\",\"profile\":\"pg18/1\",\"version\":\"18\"},\"version\":\"weft.generated-execution/1\"}","native/native-table-source.json":"{\"bundleDigest\":\"90cfe814f1ee130c1f9ea8003301b06113c6f2cdf3912978743e0da3bd7ccd67\",\"configuration\":{\"batchRole\":\"generated_batch_0ddce7f5\",\"groupRoles\":{},\"module\":\"demo\",\"ownerRole\":\"generated_owner_0ddce7f5\",\"personRole\":\"generated_person_0ddce7f5\",\"schema\":\"generated_fixture_0ddce7f5\"},\"configurationDigest\":\"fa96b999f708723aa3c26caedd94661bbb72176c2d28706ee948a0ebc782fcb5\",\"expectedCatalog\":{\"checks\":[{\"id\":\"domain:demo.amount\"},{\"id\":\"domain:demo.day\"},{\"id\":\"domain:demo.observed\"}],\"tables\":[{\"columns\":[{\"field\":{\"element\":\"id\",\"module\":\"demo\"},\"name\":\"id\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"owner\",\"module\":\"demo\"},\"name\":\"owner\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"enabled\",\"module\":\"demo\"},\"name\":\"enabled\",\"nativeType\":{\"kind\":\"boolean\"}},{\"field\":{\"element\":\"attempts\",\"module\":\"demo\"},\"name\":\"attempts\",\"nativeType\":{\"kind\":\"int8\"}},{\"field\":{\"element\":\"amount\",\"module\":\"demo\"},\"name\":\"amount\",\"nativeType\":{\"kind\":\"numeric\",\"precision\":8,\"scale\":2}},{\"field\":{\"element\":\"day\",\"module\":\"demo\"},\"name\":\"day\",\"nativeType\":{\"kind\":\"date\"}},{\"field\":{\"element\":\"observed\",\"module\":\"demo\"},\"name\":\"observed\",\"nativeType\":{\"kind\":\"timestamptz\"}},{\"field\":{\"element\":\"guid\",\"module\":\"demo\"},\"name\":\"guid\",\"nativeType\":{\"kind\":\"uuid\"}},{\"field\":{\"element\":\"payload\",\"module\":\"demo\"},\"name\":\"payload\",\"nativeType\":{\"kind\":\"text\"}}],\"id\":\"notes\",\"name\":\"notes\",\"record\":{\"element\":\"Note\",\"module\":\"demo\"}},{\"columns\":[{\"field\":{\"element\":\"task_id\",\"module\":\"demo\"},\"name\":\"task_id\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"task_owner\",\"module\":\"demo\"},\"name\":\"task_owner\",\"nativeType\":{\"kind\":\"text\"}},{\"field\":{\"element\":\"task_value\",\"module\":\"demo\"},\"name\":\"task_value\",\"nativeType\":{\"kind\":\"text\"}}],\"id\":\"tasks\",\"name\":\"tasks\",\"record\":{\"element\":\"Task\",\"module\":\"demo\"}}]},\"operations\":[],\"sourceDigest\":\"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8\",\"version\":\"umf.native-table-source/2\"}","receipt.json":"{\"payloadDigest\":\"b67f0a60204a7f24ec74e930f76899cd735a2161bd8e032eece21b443762a0c8\"}","trusted-artifact.json":"{\"artifactDigest\":\"bf85f3e7008cb073cb9c757277556aba6c0e121d509e389cd0b14952762bbeda\",\"artifactId\":\"generated-read-fixture-0ddce7f5\",\"buildId\":\"pg18-generated-read-0ddce7f5\",\"inventory\":[[\"algebra/read.json\",\"23a2838e9786f0e78e4163b81fb2054c5c3e4f8e076cd66edd3b27a46a99a2b2\"],[\"native/native-table-source.json\",\"830493868bc0f099f93f19adc7207bb9d00e43473731564ab0747331ed1f09f7\"]],\"issuer\":\"isolated-local-fixture\",\"receiptDigest\":\"bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\",\"sourceDigest\":\"9201dd239991e6bc42385edffaae94712dd12e8cbecd3706d172e127b2e0e4d8\",\"targetBindingDigest\":\"01c128ba39a73ca7d7cbb72c3fef5aee41770b2649aed40688c45f72e9726baf\"}"}} diff --git a/tests/runtime/read_artifacts.py b/tests/runtime/read_artifacts.py new file mode 100644 index 0000000..214870d --- /dev/null +++ b/tests/runtime/read_artifacts.py @@ -0,0 +1,72 @@ +"""Load a frozen fabricated generated artifact without a compiler dependency.""" + +import json +from collections.abc import Mapping +from pathlib import Path +from typing import cast + +from umf_access_generated_executor import ( + GeneratedExecutor, + GeneratedFiles, + GeneratedManifest, + TargetBinding, + TrustedArtifactRef, + prepare_generated, +) + + +def read_executor(version: str = "v1") -> tuple[GeneratedExecutor, dict[str, object]]: + if version in {"v7", "v7-rich"}: + folder_name = ( + "generated-page7-rich" + if version == "v7-rich" + else "generated-page7-combined" + ) + folder = Path(__file__).parent / "fixtures" / folder_name + captured = { + "manifest.json": (folder / "artifact/manifest.json").read_text(), + "algebra/read.json": (folder / "artifact/algebra/read.json").read_text(), + "native/native-table-source.json": ( + folder / "artifact/native/native-table-source.json" + ).read_text(), + } + trust = json.loads((folder / "trusted-artifact.json").read_bytes()) + payload_digest = trust["payloadDigest"] + else: + name = { + "v1": "generated_read_fixture.json", + "v2": "generated_read_v2_fixture.json", + "v3": "generated_read_v3_fixture.json", + "v4": "generated_read_v4_fixture.json", + "v5": "generated_read_v5_fixture.json", + }[version] + captured = json.loads(Path(__file__).with_name(name).read_bytes())["entries"] + trust = json.loads(captured["trusted-artifact.json"]) + receipt = json.loads(captured["receipt.json"]) + payload_digest = receipt["payloadDigest"] + manifest = GeneratedManifest.from_json(captured["manifest.json"]) + target = cast(Mapping[str, str], manifest.value["target"]) + executor = prepare_generated( + manifest, + GeneratedFiles.from_mapping({ + path: content.encode() + for path, content in captured.items() + if path not in {"manifest.json", "trusted-artifact.json", "receipt.json"} + }), + TrustedArtifactRef( + trust["artifactId"], + trust["artifactDigest"], + trust["receiptDigest"], + payload_digest, + trust["sourceDigest"], + trust["targetBindingDigest"], + tuple(map(tuple, trust["inventory"])), + trust["issuer"], + trust["buildId"], + ), + TargetBinding( + target["id"], target["profile"], target["version"], target["bindingDigest"] + ), + ) + + return executor, json.loads(captured["algebra/read.json"])["roots"]["demo/Note"] diff --git a/tests/runtime/test_generated.py b/tests/runtime/test_generated.py new file mode 100644 index 0000000..2209b16 --- /dev/null +++ b/tests/runtime/test_generated.py @@ -0,0 +1,171 @@ +"""Public generated provider preserves scope, exact input wires and safe outcomes.""" + +from contextlib import nullcontext +from dataclasses import replace +from typing import Literal, cast + +import pytest +from batten.contracts import ( + OperationCall, +) +from batten.lintel._record_config import checked_record_roots +from batten.runtime import Host +from generated_batch_case import batch_case, record_root_host +from generated_provider_cases import ( + Authority, + invalid_read_inputs, + malformed_cases, + scenario, + wrong_root_call, +) +from umf_access.unified import SessionIdentity + + +@pytest.mark.parametrize( + "profile", + [ + "fixed", + "read", + "v2_all", + "v3_all", + "v3_all_complete", + "v3_first", + "v3_one", + "v3_get", + "v3_count", + "v3_exists", + "v4_batch", + "v4_composite", + ], +) +@pytest.mark.parametrize("kind", ["person", "batch", "service"]) +async def test_generated_provider_preserves_exact_scope_and_read_profile( + kind: Literal["person", "batch", "service"], + profile: str, +) -> None: + if profile in {"v4_batch", "v4_composite"}: + case = batch_case( + kind, + Authority({"amount": {"string": "unchanged"}}), + composite=profile == "v4_composite", + ) + for bad_kwargs, message in case["bad_kwargs"]: + with pytest.raises(ValueError, match=message): + case["provider_type"](case["executor"], case["factory"], **bad_kwargs) + provider, call = ( + case["provider_type"]( + case["executor"], case["factory"], **case["provider_kwargs"] + ), + cast(OperationCall, case["selected_call"]), + ) + await provider.prepare() + for _mode, call, selection, expected, error in case["actions"]: + if error is not None: + with pytest.raises(ValueError, match=error): + async with provider.open_request(case["scope"]): + pass + else: + async with ( + provider.open_request(case["scope"]) + if selection is not None + else nullcontext() + ): + result = ( + await provider.invoke_selected(call, selection) + if selection is not None + else await provider.invoke(call) + ) + assert (result.status, result.result) == expected + assert ( + case["factory"].await_count, + case["native"].execute_read_v3.await_count, + case["request"].execute_get_many.await_count, + case["native"].open_request.call_count, + ) == case["expected_capture"] + assert len(provider.capabilities()) == 8 + host = cast(Host, record_root_host(provider.capabilities())) + assert case["root"].ref in checked_record_roots( + host, + case["config"], + case["executor"].native_table, + case["executor"], + ) + with pytest.raises(ValueError, match="inventory"): + checked_record_roots( + host, + replace( + case["config"], + record_roots=(replace(case["root"], receipt_digest="b" * 64),), + ), + case["executor"].native_table, + case["executor"], + ) + elif profile in {"read", "v2_all"}: + with pytest.raises(ValueError, match="server-guarded"): + scenario(profile) + return + else: + native, provider, _inputs, expected, actor, scope, call = scenario( + profile, kind + ) + await provider.prepare() + assert ((result := await provider.invoke(call)).status, len(native.calls)) == ( + "denied" if kind == "service" else "succeeded", + 0 if kind == "service" else 1, + ) + capture = native.calls[0] if native.calls else None + assert ( + capture is not None, + capture[0]["call"] if capture else None, + capture[1] + == SessionIdentity(cast(Literal["person", "batch"], kind), actor.subject) + if capture + else False, + capture[2].principal == capture[1] if capture else False, + (capture[2].application, capture[2].request_id, capture[2].lease_id) + if capture + else None, + ) == ( + kind != "service", + {"kind": "single", "inputs": {"amount": expected}} + if kind != "service" + else None, + kind != "service", + kind != "service", + (scope.application, scope.request_id, scope.lease_id) + if kind != "service" + else None, + ) + for malformed in malformed_cases(profile, kind, result.result): + native.response = malformed + assert ( + (refused := await provider.invoke(call)).result, + refused.code, + ) == ({}, "native_refused") + before, wrong_root = len(native.calls), wrong_root_call(profile, call) + assert ( + (await provider.invoke(wrong_root)).status, + len(native.calls), + ) in (("invalid", before), ("denied", before)) + denial, limit, precondition, private = ( + {"schema": native.schema, "error": error} + for error in ( + {"code": "DENIED"}, + {"code": "LIMIT_EXCEEDED"}, + {"code": "PRECONDITION_FAILED"}, + "private provider diagnostic", + ) + ) + checks = invalid_read_inputs( + call, actor, scope, kind, denial, limit, precondition, private + ) + for invalid, response, statuses in checks: + native.response = cast(dict[str, object] | None, response) + assert ( + (refused := await provider.invoke(invalid)).status in statuses, + refused.result, + ) == (True, {}) + assert ( + await provider.aclose(), + (await provider.invoke(call)).status != "succeeded", + ) == (None, True) diff --git a/tests/runtime/test_generated_connections.py b/tests/runtime/test_generated_connections.py new file mode 100644 index 0000000..e530e05 --- /dev/null +++ b/tests/runtime/test_generated_connections.py @@ -0,0 +1,170 @@ +"""Public API3 staging keeps generated connections on the Host request owner.""" + +from __future__ import annotations + +from collections.abc import Awaitable +from typing import Any, Literal, cast + +import pytest +from api3_connection_fixture import ( + configured_api3_case, + connection_intents, + host_operations, + request_scope, +) +from api3_connection_scenarios import ( + RequestObservation, + RouteObservation, + request_observation, + result_observation, + route_observation, + session_workflow, +) +from batten.contracts import ( + Actor, + HostConfig, + HostServices, +) +from batten.lintel import LintelExecution +from batten.runtime import create_host +from lintel.ports import ( + Arguments, + ConnectionIntent, + ElementRef, + ExecutionError, + NodeKey, + OperationRef, +) + +from tests.runtime.test_lintel_host import Capture + + +@pytest.mark.parametrize("kind", ["person", "batch"]) +@pytest.mark.parametrize( + "mode", + ["complete_then_replay", "ordinary_refusal", "alias_refusal", "aggregate_budget"], +) +async def test_generated_v5_host_prepares_mixed_roots_on_one_request( + kind: Literal["person", "batch"], + mode: Literal[ + "complete_then_replay", "ordinary_refusal", "alias_refusal", "aggregate_budget" + ], +) -> None: + configured = configured_api3_case(kind, mode) + case = configured.case + await configured.provider.prepare() + host = create_host( + HostConfig( + case["app"], host_operations(), 8, 10, configured.provider.capabilities() + ), + HostServices( + case["provider_kwargs"]["authority"], Capture(), configured.provider + ), + ) + execution = LintelExecution( + host, + configured.config, + configured.executor.native_table, + generated=configured.executor, + connection_admission=configured.admission, + ) + async with host: + assert await host.admit(case["app"]) + authority = await host.open_scope( + cast(Actor, case["actor"]), + "prepared-connections", + api_digest=configured.prepared.api_digest, + consistency="request-snapshot-1", + ) + lintel_scope = request_scope(configured.prepared, authority) + intents = connection_intents(configured.prepared) + ( + planned, + steps, + global_error, + expected_connections, + expected_get_many, + expected_plan, + ) = session_workflow(mode, intents) + assert ( + mode != "aggregate_budget" + or 4_300_000 < configured.admission.response_bytes + ) + results: list[object] = [] + stages: list[str] = [] + with pytest.raises(ExecutionError, match=global_error): + async with execution.session_planned(lintel_scope, planned) as session: + for step in steps: + if step.method == "get_many": + pending: Awaitable[object] = session.get_many( + *cast( + tuple[ + OperationRef, + tuple[NodeKey, ...], + tuple[ElementRef, ...], + ], + step.arguments, + ) + ) + elif step.method == "connection": + pending = session.connection( + *cast( + tuple[ + OperationRef, + Arguments, + int, + str | None, + tuple[ElementRef, ...], + ], + step.arguments, + ) + ) + else: + pending = session.planned_connection( + *cast(tuple[ConnectionIntent], step.arguments) + ) + if step.expected_error is None: + results.append(await pending) + else: + with pytest.raises(ExecutionError, match=step.expected_error): + await pending + stages.append(step.name) + assert ( + stages, + route_observation(configured.provider, configured.admission), + ) == ( + [step.name for step in steps], + RouteObservation( + "96a3699160b47a5741e923d3fa134025318a20018b5563c46dde43873f7caf05", + "96a3699160b47a5741e923d3fa134025318a20018b5563c46dde43873f7caf05", + ), + ) + observed_request = request_observation(case) + assert observed_request == RequestObservation( + 1, + expected_get_many, + expected_connections, + (id(case["request"]),) * expected_get_many, + (id(case["request"]),) * expected_connections, + (observed_request.prepared_identity_ids[0],) * expected_plan, + (observed_request.prepared_scope_ids[0],) * expected_plan, + observed_request.prepared_identity_ids[0], + observed_request.prepared_scope_ids[0], + ) + if mode == "complete_then_replay": + observed_result = result_observation(results) + assert observed_result.node_fields == ({},) + assert observed_result.page_edge_counts == (1, 1, 0, 1, 1) + assert observed_result.page_node_fields[3] == ({},) + assert observed_result.page_record_refs == ( + ElementRef("demo", "Note"), + ElementRef("demo", "Task"), + ElementRef("demo", "Note"), + ElementRef("demo", "Note"), + ) + assert ( + observed_result.page_node_fields[4] + == observed_result.page_node_fields[0] + ) + if mode == "aggregate_budget": + assert len(cast(Any, results[0]).edges) == 1 diff --git a/tests/runtime/test_host.py b/tests/runtime/test_host.py index c15b9dc..4246691 100644 --- a/tests/runtime/test_host.py +++ b/tests/runtime/test_host.py @@ -29,11 +29,11 @@ def __init__(self) -> None: self.allowed = True self.after_run = True self.calls = 0 + self.admission_checks = 1 async def check(self, actor: Actor, operation: str) -> bool: self.calls += 1 - # The first check admits the call; a later one models revocation mid-flight. - return self.allowed if self.calls == 1 else self.after_run + return self.allowed if self.calls <= self.admission_checks else self.after_run class Observations: @@ -159,13 +159,21 @@ async def test_unknown_operation_malformed_key_and_denied_actor_are_refused() -> @pytest.mark.parametrize( - ("operation", "status"), [("read", "denied"), ("write", "uncertain")] + ("operation", "admission_checks", "status", "dispatched"), + [("read", 1, "denied", 1), ("write", 1, "denied", 0), ("write", 2, "uncertain", 1)], ) -async def test_authority_revoked_during_a_call(operation: str, status: str) -> None: +async def test_authority_revoked_during_a_call( + operation: str, admission_checks: int, status: str, dispatched: int +) -> None: fixture = Fixture() + fixture.identity.admission_checks = admission_checks fixture.identity.after_run = False outcome = await (await fixture.running()).invoke(call(operation)) - assert (outcome.status, outcome.code) == (status, "authority_revoked") + assert (outcome.status, outcome.code, fixture.execution.peak) == ( + status, + "authority_revoked", + dispatched, + ) @pytest.mark.parametrize( diff --git a/tests/runtime/test_lintel_host.py b/tests/runtime/test_lintel_host.py new file mode 100644 index 0000000..07d128c --- /dev/null +++ b/tests/runtime/test_lintel_host.py @@ -0,0 +1,435 @@ +"""Public invocation scopes preserve actor attribution and refuse stale authority.""" + +from __future__ import annotations + +import asyncio +from collections.abc import AsyncGenerator, Mapping +from contextlib import asynccontextmanager +from dataclasses import replace +from pathlib import Path +from typing import cast + +import pytest +from batten.asgi import AppListing +from batten.contracts import ( + Actor, + ArtifactRef, + HostConfig, + HostServices, + Operation, + OperationCall, + OperationOutcome, + SelectedKey, + Selection, +) +from batten.hosting.local import LocalApplication, LocalRuntime, LocalSettings +from batten.lintel import ExposureConfig, ExposureOperation, LintelExecution +from batten.runtime import Host, create_host +from lintel.ports import ElementRef, ExecutionError, NodeKey, OperationRef, RequestScope +from starlette.types import ASGIApp, Message, Scope + +from tests.runtime.artifacts import native_fixture + + +async def asgi_post( + app: ASGIApp, + path: str, + body: bytes, + *, + headers: list[tuple[bytes, bytes]] | None = None, + receive_observation: list[int] | None = None, +) -> tuple[int, bytes]: + messages: list[Message] = [ + {"type": "http.request", "body": body, "more_body": False} + ] + response: list[Message] = [] + + async def receive() -> Message: + if receive_observation is not None: + receive_observation.append(1) + return messages.pop() if messages else {"type": "http.disconnect"} + + async def send(message: Message) -> None: + response.append(message) + + scope: Scope = { + "type": "http", + "asgi": {"version": "3.0", "spec_version": "2.3"}, + "http_version": "1.1", + "method": "POST", + "scheme": "http", + "path": path, + "raw_path": path.encode(), + "query_string": b"", + "root_path": "", + "headers": headers or [(b"content-type", b"application/json")], + "client": ("127.0.0.1", 1), + "server": ("testserver", 80), + } + await app(scope, receive, send) + status = next( + message["status"] + for message in response + if message["type"] == "http.response.start" + ) + payload = b"".join( + cast(bytes, message.get("body", b"")) + for message in response + if message["type"] == "http.response.body" + ) + return cast(int, status), payload + + +class Authority: + revoked = False + inputs: dict[str, object] | None = None + wait: asyncio.Event | None = None + + async def check(self, actor: Actor, operation: str) -> bool: + if self.inputs is not None: + cast(dict[str, object], self.inputs["value"])["nested"] = ( + "changed during authority" + ) + if self.wait is not None: + await self.wait.wait() + return not self.revoked and operation == "inspect" and bool(actor.subject) + + +class Capture: + def __init__(self) -> None: + self.outcomes: list[tuple[str, str, str]] = [] + + @asynccontextmanager + async def scope( + self, actor: Actor, operation: str, invocation: str + ) -> AsyncGenerator[None]: + yield + + async def capture( + self, actor: Actor, operation: str, invocation: str, status: str, mutation: bool + ) -> None: + self.outcomes.append((actor.kind, actor.subject, status)) + + +class Inspect: + calls = 0 + + async def prepare(self) -> None: + pass + + async def invoke(self, call: OperationCall) -> OperationOutcome: + self.calls += 1 + return OperationOutcome( + "succeeded", + "", + { + "inputs": dict(call.inputs), + "kind": call.actor.kind, + "subject": call.actor.subject, + "request": call.scope.request_id if call.scope else None, + }, + ) + + async def aclose(self) -> None: + pass + + +class NestedInspect: + def __init__(self) -> None: + self.host: Host | None = None + self.inner_started, self.inner_release = asyncio.Event(), asyncio.Event() + self.outer_started, self.outer_release = asyncio.Event(), asyncio.Event() + self.cancelled = asyncio.Event() + self.closes = 0 + self.received: list[OperationCall] = [] + + async def prepare(self) -> None: + pass + + async def invoke(self, call: OperationCall) -> OperationOutcome: + self.received.append(call) + mode = call.inputs.get("mode") + if mode == "outer_capacity": + await cast(Host, self.host).invoke( + OperationCall("inspect", {"mode": "inner"}, call.actor) + ) + elif mode == "inner": + self.inner_started.set() + await self.inner_release.wait() + elif mode == "outer_drain": + await cast(Host, self.host).invoke( + OperationCall("inspect", {"mode": "inner_done"}, call.actor) + ) + self.outer_started.set() + try: + await self.outer_release.wait() + except asyncio.CancelledError: + self.cancelled.set() + while not self.outer_release.is_set(): + try: + await asyncio.shield(self.outer_release.wait()) + except asyncio.CancelledError: + pass + return OperationOutcome("succeeded", "", {}) + + async def aclose(self) -> None: + self.closes += 1 + + +class SelectedInspect(Inspect): + def __init__(self, label: str | None = "fabricated") -> None: + self.value: Mapping[str, object] | None = ( + None if label is None else {"string": label} + ) + + async def invoke_selected( + self, call: OperationCall, selection: Selection + ) -> OperationOutcome: + return OperationOutcome( + "succeeded", + "", + { + "version": "batten.selected-result/1", + "kind": selection.kind, + "items": [ + None + if index == 1 + else { + "key": { + "record": key.record, + "keyId": key.key_id, + "components": key.components, + }, + "fields": [ + {"field": field, "value": self.value} + for field in selection.fields + ], + } + for index, key in enumerate(selection.keys) + ], + }, + ) + + +@pytest.fixture +def lintel_exposure() -> ExposureOperation: + record, label = ( + ElementRef("fabricated", "record"), + ElementRef("fabricated", "label"), + ) + return ExposureOperation( + OperationRef("fabricated", "inspect", "table"), + "inspect", + ("get_many",), + record, + "id", + (label,), + ("string",), + ((label, "string"),), + nullable_fields=(label,), + ) + + +@pytest.fixture +def lintel_key(lintel_exposure: ExposureOperation) -> NodeKey: + return NodeKey(lintel_exposure.record, "id", ({"string": "fabricated-key"},)) + + +@pytest.fixture +def local_runtime(tmp_path: Path) -> LocalRuntime: + application = LocalApplication( + AppListing( + "fabricated", "Fabricated", "Fabricated authority fixture", "icon.svg" + ), + ArtifactRef("fabricated-app", "fabricated-digest"), + tmp_path / "model.json", + tmp_path, + (Operation("inspect", False),), + {"fabricated-actor": {"profile": {}, "operations": ["inspect"]}}, + {"fabricated-actor": "fixture_role"}, + {}, + {}, + lambda _tables, _subjects: Inspect(), + ) + return LocalRuntime(application, LocalSettings(tmp_path, 8820, 2, 10, 1024, 4, 60)) + + +@pytest.mark.parametrize( + "execution", [Inspect(), SelectedInspect(), SelectedInspect(None)] +) +async def test_invocation_scope_preserves_authority_and_attribution( + local_runtime: LocalRuntime, + execution: Inspect, + lintel_exposure: ExposureOperation, + lintel_key: NodeKey, +) -> None: + """@covers HOST-01 @covers HOST-04 @covers HOST-05""" + artifact = ArtifactRef("fabricated-app", "fabricated-digest") + authority, capture, clock = Authority(), Capture(), [1000.0] + verified = Actor( + "fabricated-actor", local_runtime.identities.login("fabricated-actor") + ) + for candidate in ( + verified, + replace(verified, kind="batch"), + replace(verified, kind="service"), + replace(verified, delegation="unverified-reference"), + ): + assert await local_runtime.host.services.identity.check( + candidate, "inspect" + ) == (candidate == verified) + host = create_host( + HostConfig(artifact, (Operation("inspect", False, ("get_many",)),), 2, 10), + HostServices(authority, capture, execution, monotonic=lambda: clock[0]), + ) + async with host: + assert await host.admit(artifact) + + api = LintelExecution( + host, + ExposureConfig(artifact, "a" * 64, "b" * 64, (lintel_exposure,), {}), + native_fixture(), + ) + for kind in ("person", "batch", "service"): + actor = Actor("fabricated-actor", kind=kind) + scope = await host.open_scope(actor, kind, api_digest="a" * 64) + authority.inputs = { + "value": {"nested": "original"}, + "key": SelectedKey( + ("fabricated", "record"), "id", ({"string": "fabricated-key"},) + ), + } + call = OperationCall("inspect", authority.inputs, actor, scope=scope) + result = await host.invoke(call) + assert result.status == "succeeded" and result.result == { + "inputs": { + "value": {"nested": "original"}, + "key": SelectedKey( + ("fabricated", "record"), "id", ({"string": "fabricated-key"},) + ), + }, + "kind": kind, + "subject": actor.subject, + "request": kind, + } + async with api.session( + RequestScope( + artifact.id, + "a" * 64, + "query", + scope, + kind, + scope.deadline_monotonic, + ) + ) as session: + if isinstance(execution, SelectedInspect): + rows = await session.get_many( + lintel_exposure.ref, + (lintel_key, lintel_key, lintel_key), + lintel_exposure.fields, + ) + assert ( + rows[0] == rows[2] + and rows[1] is None + and rows[0] is not None + and rows[0].fields + == {lintel_exposure.fields[0]: execution.value} + ) + else: + with pytest.raises(ExecutionError, match="UNSUPPORTED"): + await session.get_many( + lintel_exposure.ref, (lintel_key,), lintel_exposure.fields + ) + assert ( + await host.invoke(call, selection=Selection("connection", first=0)) + ).code == "unsupported_selection" + invalid = ( + replace(scope, application=ArtifactRef("foreign", "different")), + replace(scope, principal=replace(actor, subject="other")), + replace(scope, lease_id=""), + replace(scope, deadline_monotonic=float("nan")), + replace(scope), + ) + for candidate in invalid: + assert not host.scope_active(candidate) + outcome = await host.invoke(replace(call, scope=candidate)) + assert (outcome.status, outcome.code, outcome.result) == ( + "denied", + "scope_invalid", + {}, + ) + for revoked, advance, status, code in ( + (True, 0, "denied", "denied"), + (False, 11, "unavailable", "deadline_exceeded"), + ): + authority.revoked = revoked + clock[0] += advance + denied = await host.invoke(call) + assert (denied.status, denied.code, denied.result) == (status, code, {}) + assert not host.scope_active(scope) + assert (await host.close_scope(scope)).state == "closed" and ( + await host.invoke(call) + ).code == "scope_invalid" + scope = await host.open_scope( + actor, "authority-timeout", deadline_monotonic=clock[0] + 0.01 + ) + before, authority.wait = execution.calls, asyncio.Event() + outcome = await host.invoke(replace(call, scope=scope)) + assert (outcome.status, outcome.code, outcome.result, execution.calls) == ( + "unavailable", + "deadline_exceeded", + {}, + before, + ) + assert (await host.close_scope(scope)).state == "closed" and [ + entry for entry in capture.outcomes if entry[2] == "succeeded" + ] == [ + (kind, "fabricated-actor", "succeeded") + for kind in ("person", "batch", "service") + for _ in range(2 if isinstance(execution, SelectedInspect) else 1) + ] + assert (await host.invoke(call)).code == "not_admitted" + + +async def test_nested_invocations_count_and_drain_independently() -> None: + artifact = ArtifactRef("nested-app", "nested-digest") + executor = NestedInspect() + host = create_host( + HostConfig(artifact, (Operation("inspect", False),), 2, 1), + HostServices(Authority(), Capture(), executor, ownership="owned"), + ) + executor.host = host + async with host: + assert await host.admit(artifact) + actor = Actor("nested-actor") + wide_mapping = {"items": tuple(range(5_000))} + page_wire_call = OperationCall("inspect", wide_mapping, actor) + assert (await host.invoke(page_wire_call)).status == "succeeded" + assert executor.received[-1].inputs == {"items": list(range(5_000))} + provider_call_count = len(executor.received) + oversized_call = OperationCall( + "inspect", {"too_many": tuple(range(16_400))}, actor + ) + refused = await host.invoke(oversized_call) + assert (refused.status, refused.code) == ("invalid", "invalid_inputs") + assert len(executor.received) == provider_call_count + outer = asyncio.create_task( + host.invoke(OperationCall("inspect", {"mode": "outer_capacity"}, actor)) + ) + await executor.inner_started.wait() + limited = await host.invoke(OperationCall("inspect", {"mode": "idle"}, actor)) + assert (limited.status, limited.code) == ("unavailable", "limit_exceeded") + executor.inner_release.set() + assert (await outer).status == "succeeded" + + draining = asyncio.create_task( + host.invoke(OperationCall("inspect", {"mode": "outer_drain"}, actor)) + ) + await executor.outer_started.wait() + report = await host.aclose() + assert report.state == "draining" + assert executor.cancelled.is_set() and executor.closes == 0 + executor.outer_release.set() + assert (await draining).status == "denied" + assert (await host.aclose()).state == "closed" + assert executor.closes == 1 diff --git a/tests/runtime/test_selected_session.py b/tests/runtime/test_selected_session.py new file mode 100644 index 0000000..c34d93a --- /dev/null +++ b/tests/runtime/test_selected_session.py @@ -0,0 +1,354 @@ +"""Selected resources are admitted independently and cleaned by their owner task.""" + +from __future__ import annotations + +import asyncio +import time +from collections.abc import AsyncGenerator, Awaitable, Callable, Mapping +from contextlib import asynccontextmanager, nullcontext +from dataclasses import replace +from typing import cast + +import pytest +from batten.contracts import ( + Actor, + ArtifactRef, + ExecutionScope, + HostConfig, + HostServices, + Operation, + OperationCall, + OperationOutcome, + SelectedCallSpec, + SelectedRequestError, + Selection, +) +from batten.runtime import Host, create_host + +from tests.runtime.test_lintel_host import Authority, Capture, Inspect + +PINS = {"read.consistency": "request-snapshot-1", "binding": "fabricated-binding"} +REFUSALS = { + "host_revoked": ("denied", "authority_revoked"), + "admission_revoked": ("denied", "not_admitted"), + "clock_expired": ("unavailable", "deadline_exceeded"), +} + + +class RequestInspect(Inspect): + def __init__( + self, + mode: str, + authority: Authority, + clock: list[float], + invalidate: Callable[[], Awaitable[bool]], + ): + self.mode, self.authority = mode, authority + self.clock, self.invalidate = clock, invalidate + self.calls = 0 + self.events: list[tuple[str, object]] = [] + self.prepared_calls: tuple[SelectedCallSpec, ...] | None = None + self.prepared_scope: ExecutionScope | None = None + self.release = asyncio.Event() + self.started = asyncio.Event() + + def capabilities(self) -> Mapping[str, str]: + return { + **PINS, + **({"extra": "unconfigured"} if self.mode == "extra" else {}), + **({"binding": "different"} if self.mode == "mismatch" else {}), + } + + def __getattribute__(self, name: str) -> object: + if object.__getattribute__(self, "mode") == "prepared_missing" and name in { + "prepare_selected", + "open_prepared_request", + }: + raise AttributeError(name) + return object.__getattribute__(self, name) + + def prepare_selected( + self, scope: ExecutionScope, calls: tuple[SelectedCallSpec, ...] + ) -> object: + self.prepared_calls = calls + self.prepared_scope = scope + if self.mode == "prepared_replay": + return (scope, calls, "replayed") + if self.mode == "prepared_none": + return None + if self.mode == "prepared_clock_expired": + self.clock[0] += 11 + return (scope, calls) + + @asynccontextmanager + async def open_prepared_request( + self, scope: ExecutionScope, prepared: object + ) -> AsyncGenerator[None]: + if prepared == (scope, self.prepared_calls, "replayed"): + raise ValueError("prepared request was already consumed") + assert prepared == (scope, self.prepared_calls) + async with self.open_request(scope): + yield + + @asynccontextmanager + async def open_request(self, scope: ExecutionScope) -> AsyncGenerator[None]: + self.events.append(("enter", asyncio.current_task())) + if self.mode == "enter": + raise RuntimeError("fabricated admission refusal") + if self.mode == "cancel": + raise asyncio.CancelledError + if self.mode == "deadline": + await self.release.wait() + try: + yield + finally: + if self.mode == "cleanup": + while not self.release.is_set(): + try: + await self.release.wait() + except asyncio.CancelledError: + self.events.append(("cancelled", asyncio.current_task())) + self.events.append(("exit", asyncio.current_task())) + + async def invoke_selected( + self, call: OperationCall, selection: Selection + ) -> OperationOutcome: + self.calls += 1 + if self.calls == 2: + if self.mode == "host_revoked": + self.authority.revoked = True + elif self.mode == "admission_revoked": + await self.invalidate() + elif self.mode == "clock_expired": + self.clock[0] += 11 + if self.mode.startswith("active"): + self.events.append(("read.enter", asyncio.current_task())) + self.started.set() + try: + await self.release.wait() + finally: + self.events.append(("read.exit", asyncio.current_task())) + return OperationOutcome("succeeded", "", {"selected": selection.kind}) + + +def prepared_calls_for( + mode: str, scope: ExecutionScope +) -> tuple[tuple[SelectedCallSpec, ...] | None, dict[str, object]]: + owned_inputs: dict[str, object] = {"filter": {"key": "before"}} + if not mode.startswith("prepared"): + return None, owned_inputs + call = OperationCall("inspect", owned_inputs, scope.principal, scope=scope) + if mode == "prepared_wrong_scope": + call = replace(call, scope=replace(scope)) + count = 257 if mode == "prepared_too_many_calls" else 1 + return tuple( + SelectedCallSpec(call, Selection("get_many")) for _ in range(count) + ), owned_inputs + + +def selected_refusal( + mode: str, +) -> type[BaseException] | tuple[type[BaseException], ...]: + if mode in { + "missing", + "extra", + "mismatch", + "wrong", + "prepared_missing", + "prepared_wrong_scope", + "prepared_replay", + "prepared_none", + "prepared_clock_expired", + "prepared_too_many_calls", + }: + return ValueError + if mode == "prepared_denied": + return SelectedRequestError + if mode == "cancel": + return asyncio.CancelledError + if mode == "active_deadline": + return RuntimeError, asyncio.CancelledError + if mode == "deadline": + return TimeoutError + return RuntimeError + + +def selected_services( + mode: str, + artifact: ArtifactRef, + authority: Authority, + clock: list[float], + invalidate: Callable[[], Awaitable[bool]], +) -> tuple[HostConfig, HostServices, RequestInspect]: + authority.revoked = mode == "prepared_denied" + execution = RequestInspect(mode, authority, clock, invalidate) + config = HostConfig( + artifact, + (Operation("inspect", False, ("get_many",)),), + 1, + 0.25 + if mode in {"deadline", "active_deadline"} + else 0.05 + if mode == "cleanup" + else 10, + {} if mode == "missing" else PINS, + ) + services = HostServices( + authority, + Capture(), + execution, + monotonic=(lambda: clock[0]) + if mode in {"clock_expired", "prepared_clock_expired"} + else time.monotonic, + ) + return config, services, execution + + +@pytest.mark.parametrize( + "mode", + [ + "ready", + "prepared", + "prepared_denied", + "prepared_missing", + "prepared_wrong_scope", + "prepared_replay", + "prepared_none", + "prepared_clock_expired", + "prepared_too_many_calls", + "missing", + "extra", + "mismatch", + "wrong", + "enter", + "cancel", + "deadline", + "cleanup", + "active", + "active_deadline", + "host_revoked", + "admission_revoked", + "clock_expired", + ], +) +async def test_selected_session_admission_and_owner_cleanup(mode: str) -> None: + """@covers HOST-04 @covers HOST-05 @covers generated request snapshot admission""" + artifact, authority, clock = ( + ArtifactRef("fabricated", "digest"), + Authority(), + [time.monotonic()], + ) + host_ref: dict[str, Host] = {} + config, services, execution = selected_services( + mode, + artifact, + authority, + clock, + lambda: host_ref["host"].admit(ArtifactRef("foreign", "digest")), + ) + async with create_host(config, services) as host: + host_ref["host"] = host + assert await host.admit(artifact) + scope = await host.open_scope( + Actor("fabricated"), + "request", + api_digest="api", + consistency="statement" if mode == "wrong" else "request-snapshot-1", + ) + call = OperationCall("inspect", {}, scope.principal, scope=scope) + assert ( + await host.invoke(replace(call, scope=replace(scope))) + ).code == "scope_invalid" + assert ( + mode == "wrong" + or (await host.invoke(call)).code == "selected_session_inactive" + ) + expected = selected_refusal(mode) + invocation: Awaitable[OperationOutcome] | None = None + with ( + nullcontext() + if mode in {"ready", "active", "prepared"} + else pytest.raises(expected) + ) as refused: + prepared_calls, inputs = prepared_calls_for(mode, scope) + cast(dict[str, str], inputs["filter"])["key"] = "after" + async with host.open_selected_session( + scope, + consistency="request-snapshot-1", + calls=prepared_calls, + ): + for index in range(2 if mode in REFUSALS else 1): + invocation = ( + host.invoke(call, selection=Selection("get_many")) + if mode == "active_deadline" + else asyncio.create_task( + host.invoke(call, selection=Selection("get_many")) + ) + ) + if mode == "active": + await execution.started.wait() + else: + outcome = await invocation + assert ( + (outcome.status, outcome.result) == ("unavailable", {}) + and outcome.code in {"timeout", "deadline_exceeded"} + if mode == "active_deadline" + else (outcome.status, outcome.code, outcome.result) + == ( + (*REFUSALS[mode], {}) + if index + else ("succeeded", None, {"selected": "get_many"}) + ) + ) + with pytest.raises(ValueError): + async with host.open_selected_session( + scope, consistency="request-snapshot-1" + ): + pass + assert mode != "cleanup" or (await host.close_scope(scope)).state == "draining" + execution.release.set() + assert mode not in REFUSALS or ( + refused is not None + and isinstance(refused.value, SelectedRequestError) + and (refused.value.status, refused.value.code) == REFUSALS[mode] + ) + if isinstance(invocation, asyncio.Task) and invocation.cancelled(): + with pytest.raises(asyncio.CancelledError): + await invocation + assert ((await host.close_scope(scope)).state, execution.calls) == ( + "closed", + 2 + if mode in REFUSALS + else 1 + if mode in {"ready", "prepared", "cleanup", "active", "active_deadline"} + else 0, + ) + assert ( + mode == "prepared" + and execution.prepared_calls is not None + and cast( + Mapping[str, object], + execution.prepared_calls[0].call.inputs["filter"], + )["key"] + == "before" + or mode in {"prepared_missing", "prepared_too_many_calls"} + and execution.prepared_calls is None + or mode not in {"prepared", "prepared_missing"} + ) + if ( + mode + in {"ready", "prepared", "cleanup", "active", "active_deadline"} + | REFUSALS.keys() + ): + assert ( + execution.events[0][0] == "enter" + and execution.events[-1][0] == "exit" + and execution.events[0][1] is execution.events[-1][1] + ) + assert not mode.startswith("active") or [ + event for event, _task in execution.events + ] == ["enter", "read.enter", "read.exit", "exit"] + else: + assert [event for event, _task in execution.events] == ( + ["enter"] if mode in {"enter", "cancel", "deadline"} else [] + ) diff --git a/tests/storage/test_expiry_cancellation.py b/tests/storage/test_expiry_cancellation.py index 9a71a32..fd3d807 100644 --- a/tests/storage/test_expiry_cancellation.py +++ b/tests/storage/test_expiry_cancellation.py @@ -12,49 +12,26 @@ from conftest import Grant -async def test_upload_and_cursor_expiry( - local: tuple[LocalProvider, Grant], monkeypatch: pytest.MonkeyPatch -) -> None: - provider, grant = local - store = provider.bind(grant) - session = await store.begin_upload("expires") - await store.write_part(session.upload, 1, b"expiry staging") - await store.write("one", b"1") - await store.write("two", b"2") - page = await store.list(limit=1) - assert page.next_cursor is not None - wall, monotonic = time.time(), time.monotonic() - monkeypatch.setattr( - time, "time", lambda: wall + provider.limits.upload_ttl_seconds + 1 - ) - monkeypatch.setattr( - time, "monotonic", lambda: monotonic + provider.limits.cursor_ttl_seconds + 1 - ) - assert (await store.upload_status(session.upload)).state == "expired" - with pytest.raises(StorageError, match="upload_expired"): - await store.write_part(session.upload, 1, b"too late") - with pytest.raises(StorageError, match="cursor_expired"): - await store.list(limit=1, cursor=page.next_cursor) - fresh = await store.begin_upload("fresh") - assert fresh.state == "open" - assert len(list((provider.root / "blobs").iterdir())) == 2 +async def staged_source( + started: asyncio.Event, hold: asyncio.Event +) -> AsyncIterator[bytes]: + yield b"partial" + started.set() + await hold.wait() + yield b"rest" -async def test_cancellation_closes_staging_without_publishing( - local: tuple[LocalProvider, Grant], +async def test_abandoned_staging_and_cursor_expiry( + local: tuple[LocalProvider, Grant], monkeypatch: pytest.MonkeyPatch ) -> None: provider, grant = local store = provider.bind(grant) started = asyncio.Event() hold = asyncio.Event() - async def source() -> AsyncIterator[bytes]: - yield b"partial" - started.set() - await hold.wait() - yield b"rest" - - transfer = asyncio.create_task(store.write("cancelled", source())) + transfer = asyncio.create_task( + store.write("cancelled", staged_source(started, hold)) + ) await started.wait() transfer.cancel() with pytest.raises(asyncio.CancelledError): @@ -66,7 +43,9 @@ async def source() -> AsyncIterator[bytes]: started.clear() session = await store.begin_upload("abort-active") - transfer = asyncio.create_task(store.write_part(session.upload, 1, source())) + transfer = asyncio.create_task( + store.write_part(session.upload, 1, staged_source(started, hold)) + ) await started.wait() assert (await store.abort_upload(session.upload)).outcome == "unknown" hold.set() @@ -74,3 +53,28 @@ async def source() -> AsyncIterator[bytes]: await transfer assert (await store.upload_status(session.upload)).state == "aborted" assert list((provider.root / "blobs").iterdir()) == [] + session = await store.begin_upload("expires") + await store.write_part(session.upload, 1, b"expiry staging") + await store.write("one", b"1") + await store.write("two", b"2") + page = await store.list(limit=1) + assert page.next_cursor is not None + expire(provider, monkeypatch) + assert (await store.upload_status(session.upload)).state == "expired" + with pytest.raises(StorageError, match="upload_expired"): + await store.write_part(session.upload, 1, b"too late") + with pytest.raises(StorageError, match="cursor_expired"): + await store.list(limit=1, cursor=page.next_cursor) + fresh = await store.begin_upload("fresh") + assert fresh.state == "open" + assert len(list((provider.root / "blobs").iterdir())) == 2 + + +def expire(provider: LocalProvider, monkeypatch: pytest.MonkeyPatch) -> None: + wall, monotonic = time.time(), time.monotonic() + monkeypatch.setattr( + time, "time", lambda: wall + provider.limits.upload_ttl_seconds + 1 + ) + monkeypatch.setattr( + time, "monotonic", lambda: monotonic + provider.limits.cursor_ttl_seconds + 1 + ) diff --git a/tests/storage/test_listing_uploads.py b/tests/storage/test_listing_uploads.py index 08c32a7..8f32eae 100644 --- a/tests/storage/test_listing_uploads.py +++ b/tests/storage/test_listing_uploads.py @@ -48,7 +48,7 @@ async def test_listing_projection_progress_and_scoped_cursors( assert sorted(found) == ["a", "c"] -async def test_upload_manifest_and_completion_condition( +async def test_upload_manifest_completion_and_reattachment( local: tuple[LocalProvider, Grant], ) -> None: provider, grant = local @@ -73,13 +73,6 @@ async def test_upload_manifest_and_completion_condition( with pytest.raises(StorageError, match="precondition_failed"): await store.complete_upload(conflicting.upload, [part]) assert (await store.abort_upload(conflicting.upload)).outcome == "aborted" - - -async def test_upload_reattachment_restart_and_stale_parts( - local: tuple[LocalProvider, Grant], -) -> None: - provider, grant = local - store = provider.bind(grant) session = await store.begin_upload("resume") old = await store.write_part(session.upload, 1, b"old") current = await store.write_part(session.upload, 1, b"current") @@ -94,27 +87,3 @@ async def test_upload_reattachment_restart_and_stale_parts( receipt = await rebound.complete_upload(session.upload, [current]) assert receipt.info.size_bytes == 7 await restarted.aclose() - - -async def test_closed_handle_preserves_borrower_and_data( - local: tuple[LocalProvider, Grant], -) -> None: - provider, grant = local - closed, borrower = provider.bind(grant), provider.bind(grant) - await closed.write("keep", b"retained") - await closed.aclose() - with pytest.raises(StorageError, match="denied"): - await closed.stat("keep") - assert (await borrower.stat("keep")).size_bytes == 8 - session = await borrower.begin_upload("unpublished") - await borrower.write_part(session.upload, 1, b"private") - assert [item.key for item in (await borrower.list(limit=2)).items] == ["keep"] - await borrower.abort_upload(session.upload) - assert (await borrower.upload_status(session.upload)).state == "aborted" - grant.features = {"multipart_upload", "create_only"} - transient = await borrower.begin_upload("transient") - await borrower.write_part(transient.upload, 1, b"temporary") - await borrower.aclose() - assert len(list((provider.root / "blobs").iterdir())) == 1 - with pytest.raises(StorageError, match="denied"): - await provider.bind(grant).upload_status(transient.upload) diff --git a/tests/storage/test_objects.py b/tests/storage/test_objects.py index 0be0a9b..df56cd1 100644 --- a/tests/storage/test_objects.py +++ b/tests/storage/test_objects.py @@ -12,9 +12,11 @@ from batten.storage.local import LocalProvider, create_store, initialize from conftest import Grant, process_results +WRONG_DIGEST = Digest("sha256", hashlib.sha256(b"wrong").hexdigest()) + @pytest.mark.parametrize("body", [b"", b"Fabricated review", b"fabricated" * 1000]) -async def test_roundtrip_and_reload( +async def test_roundtrip_borrower_close_and_reload( local: tuple[LocalProvider, Grant], body: bytes ) -> None: provider, grant = local @@ -26,7 +28,27 @@ async def test_roundtrip_and_reload( assert b"".join([chunk async for chunk in stream]) == body await store.aclose() other = provider.bind(grant) - assert (await other.stat(written.info.key)).version == written.info.version + borrowed = await other.stat(written.info.key) + assert borrowed.version == written.info.version + assert borrowed.size_bytes == len(body) + with pytest.raises(StorageError, match="denied"): + await store.stat(written.info.key) + session = await other.begin_upload("reviews/unpublished") + await other.write_part(session.upload, 1, b"private") + assert [ + item.key for item in (await other.list(prefix="reviews/", limit=2)).items + ] == [written.info.key] + await other.abort_upload(session.upload) + assert (await other.upload_status(session.upload)).state == "aborted" + original_features = grant.features + grant.features = {"multipart_upload", "create_only"} + transient = await other.begin_upload("transient") + await other.write_part(transient.upload, 1, b"temporary") + await other.aclose() + assert len(list((provider.root / "blobs").iterdir())) == 1 + with pytest.raises(StorageError, match="denied"): + await provider.bind(grant).upload_status(transient.upload) + grant.features = original_features await provider.aclose() reloaded = create_store(provider.root, provider.limits) await reloaded.prepare() @@ -102,7 +124,7 @@ async def test_key_and_root_containment( @pytest.mark.parametrize("processes", [False, True]) -async def test_conditional_competing_publication( +async def test_conditional_publication_and_observation_failure( local: tuple[LocalProvider, Grant], processes: bool ) -> None: provider, grant = local @@ -137,9 +159,15 @@ async def test_conditional_competing_publication( with pytest.raises(StorageError, match="precondition_failed"): await stores[0].delete("review", condition=condition) await stores[0].write("review", b"explicit", condition=Any()) + grant.sink_fails = True + with pytest.raises(StorageError, match="unavailable") as failure: + await stores[0].write("observed", b"published") + assert failure.value.effect == "unknown" + grant.sink_fails = False + assert (await stores[0].stat("observed")).size_bytes == 9 -async def test_pinned_read_ranges_integrity_and_partial_close( +async def test_transfer_verification_ranges_and_limits( local: tuple[LocalProvider, Grant], ) -> None: provider, grant = local @@ -147,7 +175,6 @@ async def test_pinned_read_ranges_integrity_and_partial_close( body = b"0123456789" * 8 digest = Digest("sha256", hashlib.sha256(body).hexdigest()) receipt = await store.write("verified", body, expected_digest=digest) - info = receipt.info assert receipt.verification is not None and receipt.verification.scope == "source" async with store.open_read("verified", expected_digest=digest) as stream: assert b"".join([part async for part in stream]) == body @@ -155,7 +182,7 @@ async def test_pinned_read_ranges_integrity_and_partial_close( stream.verification is not None and stream.verification.scope == "delivered" ) async with store.open_read( - "verified", offset=2, length=4, condition=Matches(info.version) + "verified", offset=2, length=4, condition=Matches(receipt.info.version) ) as stream: assert b"".join([part async for part in stream]) == b"2345" assert stream.selection.length == 4 @@ -167,24 +194,17 @@ async def test_pinned_read_ranges_integrity_and_partial_close( async with store.open_read("verified", expected_digest=digest) as stream: await anext(stream.__aiter__()) assert stream.verification is None - wrong = Digest("sha256", hashlib.sha256(b"wrong").hexdigest()) with pytest.raises(StorageError, match="integrity_mismatch"): - await store.write("bad", body, expected_digest=wrong) + await store.write("bad", body, expected_digest=WRONG_DIGEST) with pytest.raises(StorageError, match="not_found"): await store.stat("bad") with pytest.raises(StorageError, match="integrity_mismatch"): - async with store.open_read("verified", expected_digest=wrong) as stream: + async with store.open_read("verified", expected_digest=WRONG_DIGEST) as stream: [part async for part in stream] await store.write("verified", b"changed", condition=Any()) with pytest.raises(StorageError, match="precondition_failed"): - async with store.open_read("verified", condition=Matches(info.version)): + async with store.open_read("verified", condition=Matches(receipt.info.version)): pass - - -async def test_transfer_limits_preserve_destination( - local: tuple[LocalProvider, Grant], -) -> None: - provider, grant = local bounded = create_store(provider.root, replace(provider.limits, max_object_bytes=3)) await bounded.prepare() store = bounded.bind(grant) @@ -194,16 +214,3 @@ async def test_transfer_limits_preserve_destination( async with store.open_read("small") as stream: assert b"".join([part async for part in stream]) == b"old" await bounded.aclose() - - -async def test_observation_failure_retains_possible_effect( - local: tuple[LocalProvider, Grant], -) -> None: - provider, grant = local - store = provider.bind(grant) - grant.sink_fails = True - with pytest.raises(StorageError, match="unavailable") as failure: - await store.write("observed", b"published") - assert failure.value.effect == "unknown" - grant.sink_fails = False - assert (await store.stat("observed")).size_bytes == 9