~/bend-docscommunity

ordinary_query_declaration.bend checks

raw source on the hub · import 0x67fd5084c1da4adc13317822045bb11f/ordinary_query_declaration.bend as Ordinary_query_declaration

11 imports
import Base
import ./column.bend as Col
import ./component.bend as Cmp
import ./persistence_declaration.bend as Recipe
import ./ordinary_declaration.bend as Identity
import ./declared_family.bend as Family
import ./snapshot_leaf.bend as Leaf
import ./decode_data.bend as D
import ./compose.bend as Q
import ./capabilities.bend as Cap
import ./world.bend as W

Types

type Mode source · line 16 · raw

Data

One constructor owns both operational grant/matcher and detached syntax. Metadata is library-produced; the application supplies no metadata argument. Query clause kind used by declaration-derived inspection and access metadata.

type Clause source · line 25 · raw

@S:Data -> Data

Detached schema-scoped description of one component query requirement.

type Declaration source · line 30 · raw

@-S:Data -> @H:Type -> @G:Type -> Type

Typed query declaration: grants, row selection and debug clauses share one source. Build with read/write/filter constructors and pair; raw construction is a trusted adapter boundary. H is threaded affinely; G determines available operations.

Templates

template observe source · line 34 · raw

@-S:Data -> @-H:Type -> @-G:Type -> @declaration:Declaration<S, H, G> -> Pair(Declaration<S, H, G>, List<&2, Clause<S>>)

Return the declaration owner together with its detached debug clauses. Does not inspect a world, execute a query or advance a system cursor.

template grant source · line 39 · raw

@-S:Data -> @-H:Type -> @-G:Type -> @declaration:Declaration<S, H, G> -> G

Consume the declaration and extract its typed operations for a system body. This supplies only G; a read declaration cannot confer write operations.

template constructed_read source · line 47 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-save:(@_:P -> Pair(P, 0x67fd5084c1da4adc13317822045bb11f/decode_data.Raw)) -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Read<0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, V>>

Constructed-component counterpart of read, using the declaration-bound save recipe. take/put must preserve the matching Leaf.Component and all remaining storage. Requires presence and returns a detached V while retaining the affine payload. Reads return Found, ComponentAbsent or MissingEntity (including stale/foreign).

template constructed_write source · line 55 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-save:(@_:P -> Pair(P, 0x67fd5084c1da4adc13317822045bb11f/decode_data.Raw)) -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Write<0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, P, V>>

Constructed-component counterpart of write, using the declaration-bound save recipe. take/put must preserve the matching Leaf.Component and all remaining storage. Requires presence and grants transactional payload replacement, including rollback. Failed sets retain an error in Frame; Compose reports AccessError and rolls back. The set grant consumes P and does not return rejected input to the caller.

template constructed_optional source · line 62 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-save:(@_:P -> Pair(P, 0x67fd5084c1da4adc13317822045bb11f/decode_data.Raw)) -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Read<0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, V>>

Constructed-component counterpart of optional, using the declaration-bound save recipe. take/put must preserve the matching Leaf.Component and all remaining storage. Allows absence; reads return Found, ComponentAbsent or MissingEntity. Stale/foreign handles yield MissingEntity, never an optional matching row.

template constructed_with_component source · line 68 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-save:(@_:P -> Pair(P, 0x67fd5084c1da4adc13317822045bb11f/decode_data.Raw)) -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Constructed-component counterpart of with_component, using the declaration-bound save recipe. take/put must preserve the matching Leaf.Component and all remaining storage. Requires presence without granting payload access.

template constructed_without_component source · line 74 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-save:(@_:P -> Pair(P, 0x67fd5084c1da4adc13317822045bb11f/decode_data.Raw)) -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Constructed-component counterpart of without_component, using the declaration-bound save recipe. take/put must preserve the matching Leaf.Component and all remaining storage. Requires absence without granting payload access.

template constructed_added source · line 80 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-save:(@_:P -> Pair(P, 0x67fd5084c1da4adc13317822045bb11f/decode_data.Raw)) -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Constructed-component counterpart of added, using the declaration-bound save recipe. take/put must preserve the matching Leaf.Component and all remaining storage. Matches added stamps relative to the executing system cursor; grants no access.

template constructed_changed source · line 86 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-save:(@_:P -> Pair(P, 0x67fd5084c1da4adc13317822045bb11f/decode_data.Raw)) -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/snapshot_leaf.Component<S, P, identity, save> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Constructed-component counterpart of changed, using the declaration-bound save recipe. take/put must preserve the matching Leaf.Component and all remaining storage. Matches changed stamps relative to the executing system cursor; grants no access.

template execute_read source · line 93 · raw

@-S:Data -> @-H:Type -> @-V:Data -> @-declaration:Declaration<S, H, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Read<H, V>> -> @owner:H -> Pair(H, 0x67fd5084c1da4adc13317822045bb11f/component.Access<V>)

Read the selected component through a read declaration, returning owner H with Access<V>. The detached Data view does not copy the affine payload. Results are Found, ComponentAbsent or MissingEntity; stale/foreign handles produce MissingEntity. No payload owner is transferred to the reader.

template selector source · line 98 · raw

@-S:Data -> @-H:Type -> @-G:Type -> @declaration:Declaration<S, H, G> -> @_:H -> Pair(H, Bool)

Consume the declaration to obtain its owner-threading row predicate. Selection grants no additional component access and does not enumerate rows.

template clauses source · line 103 · raw

@-S:Data -> @-H:Type -> @-G:Type -> @declaration:Declaration<S, H, G> -> List<&2, Clause<S>>

Consume the declaration and return detached schema-scoped query metadata. Prefer observe when the caller also needs to retain the declaration.

template selected_right source · line 106 · raw

@-H:Type -> @selected:Bool -> @observed:Pair(H, Bool) -> Pair(H, Bool)

template selected_left source · line 109 · raw

@-H:Type -> @-right:(@_:H -> Pair(H, Bool)) -> @observed:Pair(H, Bool) -> Pair(H, Bool)

template both source · line 113 · raw

@-H:Type -> @-left:(@_:H -> Pair(H, Bool)) -> @-right:(@_:H -> Pair(H, Bool)) -> @owner:H -> Pair(H, Bool)

template pair_selected source · line 115 · raw

@-H:Type -> @right:(@_:H -> Pair(H, Bool)) -> @observed:Pair(H, Bool) -> Pair(H, Bool)

template pair_select source · line 119 · raw

@-H:Type -> @left:(@_:H -> Pair(H, Bool)) -> @right:(@_:H -> Pair(H, Bool)) -> @owner:H -> Pair(H, Bool)

template pair_parts source · line 121 · raw

@-S:Data -> @-H:Type -> @-L:Type -> @-R:Type -> @left:Declaration<S, H, L> -> @right:Declaration<S, H, R> -> Declaration<S, H, Pair(L, R)>

template pair source · line 129 · raw

@-S:Data -> @-H:Type -> @-L:Type -> @-R:Type -> @-left:Declaration<S, H, L> -> @-right:Declaration<S, H, R> -> Declaration<S, H, Pair(L, R)>

Compose two declarations for the same schema and owner into one query. Selection is conjunction, evaluated left then right with short circuiting; grants retain the nested (L & R) shape and clauses retain left-to-right order. Nest pair to combine more than two selections; it does not impose a row order. Example: examples/scheduled-health/registration.bend defines query().

template read source · line 138 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Read<0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, V>>

Require this component and grant read access to its detached Data view. identity and the storage binding must describe the same schema component. view consumes and returns P, including affine payloads; it must not discard the payload. This declaration neither visits rows nor changes the world. Reads return Found, ComponentAbsent or MissingEntity (including stale/foreign). Example bindings and query(): examples/scheduled-health/registration.bend.

template write source · line 147 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Write<0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, P, V>>

Require this component and grant typed read/write operations to the body. The set operation consumes replacement P and returns the affine owner. Failed sets retain an error in Frame; Compose reports AccessError and rolls back. Rejected replacement payloads are not returned through this grant. Reads expose V. Writes participate in the enclosing system transaction and its rollback; declaring access performs no write. See scheduled-health/registration.bend.

template optional source · line 154 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Read<0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, V>>

Grant read access without excluding rows where the component is absent. The body handles Found/ComponentAbsent/MissingEntity; optional fabricates no V. Stale/foreign handles yield MissingEntity and never match as live rows. Payload projection consumes and returns P, preserving affine ownership.

template with_component source · line 159 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Filter to entities with this component without granting its payload access. Produces Unit grants; combine with pair to add independently declared access.

template without_component source · line 164 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Filter to entities without this component, granting no payload access. Membership follows the executing query and explicit structural barriers.

template added source · line 170 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Filter by this component being added since the executing system cursor. Grants no payload access; combine with read/write to access matching values. Declaration creation and detached inspection do not consume lifecycle visibility.

template changed source · line 176 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, Unit>

Filter by this component changing since the executing system cursor. Grants no payload access; cursor advancement follows system success/skip/failure rules, not creation or inspection of this declaration.

template write_displayed source · line 183 · raw

@-S:Data -> @-P:Type -> @-Store:Type -> @-R:Type -> @-E:Data -> @-Rest:Type -> @-V:Data -> @-Token:Data -> @-identity:0x67fd5084c1da4adc13317822045bb11f/ordinary_declaration.Declaration<S, P> -> @-view:(@_:P -> Pair(P, V)) -> @-display:(@_:V -> String) -> @-take:(@_:Store -> Pair(Rest, 0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P>)) -> @-put:(@_:Rest -> @_:0x67fd5084c1da4adc13317822045bb11f/column.Column<S, P> -> Store) -> Declaration<S, 0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, 0x67fd5084c1da4adc13317822045bb11f/capabilities.Write<0x67fd5084c1da4adc13317822045bb11f/compose.Frame<S, Store, R, E>, P, V>>

Declare required write access and a display function for its Data view. display formats detached V for enabled debug output; it never owns P. Failed sets retain an error in Frame; Compose reports AccessError and rolls back. The set grant consumes P without returning rejected input; see write.