ADR 0025 — DQL link: standing queries over the tree, as a portable link
Status: accepted · 2026-10-30, built (owner request: bring DSA dslink-dart-dql into WYRM so that it runs in every mode and works as the scheduler does — a portable App, embedded in every wyrmd, also a WASM and a process package). Owner decisions D1 … D6 of 2026-10-30 are listed at the end. Built: crates/wyrm-dql, links/dql, wyr query, the Host API amendment; user guide docs/dql.md; plan docs/superpowers/plans/2026-10-30-dql-link.md. Where the build differs from the text below, the rulings at the end (B1 …) say why.
Context
DSA DQL (“distributed query language”, IOT-DSA/dslink-dart-dql 0.6.2, analysed 2026-10-30) is a responder and requester link with one action, /query {query}, whose result is a streaming table. A query is a pipeline of commands separated by |:
list /downstream/System/* | filter $type="number" @unit!="%" | subscribe :name value | expression double="row.value * 2"
list /downstream/System | filter :metric | subscribe | invoke /downstream/MongoDB/local/SystemValues/publish(Path=%path, Value=%value)
Each command takes the stream of row updates ({values, remove}, row id = path) and gives another: list/lista (reactive recursive list; * any depth, ? one segment; , for more roots; directive brokers), path (one node), sublist (a list relative to each row), filter/where (tests on $config, @attribute, :name, columns; = != < <= > >= ~ like contains anyContains in, and or xor not, function calls; a test on a column subscribes it by itself), subscribe/child (value, value.timestamp, a child’s value, $config, @attr, :name, :displayName, :children/:configs/:attributes, as column names), expression (a column from a script over row), rename, drop, option (qos, traverseBrokers, listActions, invokeAllowNull, brokersIncludeQuarantine) and invoke (call an action for each row with params from columns, %col, again when they change). Identical query texts share one running query (QueryManager); the link shows counts (uniqueQueryCount, totalQueryCount, virtualListCount, virtualSubscribeCount, actionInvokeCount) and getRunningQueries.
Kept: the pipeline language and its command names, row id = node path, columns in first-seen order, shared execution of identical texts, the counters, sinks that act on rows (invoke). Not kept, because they are its defects (read in the source):
- a query lives only while a requester holds its stream; nothing survives a restart, and a site without a client runs no query;
/queryis$invokable: read, andinvokeruns with the link’s own rights: whoever may read the link makes it call any action the link can reach (privilege escalation);- no bounds:
list *lists the whole network, onelistper visited node, one subscription per row and column, unbounded rows, columns and invokes; one query can stall the broker; expressionis a 5 600-line embedded JavaScript-like interpreter without a step or time bound;- the
>=test is an assignment (result = v = against), so it is always true for a non-null value;sublistremoves rows with the parent’s path instead of the child’s, so rows of a removed parent stay; - a removed row re-sends every row after it (
replace <id>-<len>), O(n) per removal; - an error in any stage closes the whole query with a stack trace as its message;
invokefires on every change with no rate limit and no bound on calls in flight.
WYRM already has what made DQL expensive in DSA: one key space with patterns (wy/<site>/downstream/plc/**), resolve (view=keys&match=) and pattern subscriptions for fan-in (spec 01). A query can be one subscription per root, not one per row.
Goals
- A query is configuration: stored, validated, running on the broker offline for months, back by itself after a restart (as a schedule, ADR 0022).
- One language core for every way DQL runs: the link (embedded, process, WASM) and the CLI.
- Results are ordinary nodes: anyone with
readsubscribes to a query’s table; a dataflow, the explorer, the MCP server and an upstream site use it with no new protocol. - Bounded cost: per query and per link limits on rows, lists, subscriptions and sink calls; zero messages at idle when nothing changes.
- A query cannot do more than its author may do; reading results never gives more rights than defining the query.
- DSA queries import with a converter (
/downstream/X/*→wy/<site>/downstream/X/**).
Non-goals
- SQL, joins between queries, aggregation over time (history has
Get Historywith rollups, ADR 0014; dataflows have windows). - Streaming action replies (ADR 0023 non-goal); the results are a node, not a stream on
~act. - Queries that write
sys/**or another site (owner decision 8, as flow sinks and scheduler targets).
Anti-goals (a failure even if it works)
- One query, however wide, stalls the router, another link or the other queries.
- A user who may only read a part of the tree reads more through DQL.
- An
invokerepeated after a restart that the author did not ask for. - Load at idle that grows with the number of rows.
Decision
Language core (crate wyrm-dql: no I/O, no async, no clock; builds for wasm32-unknown-unknown)
- Parser (hand-written, no parser generator): text →
Plan(stages, the columns each one adds or drops, sink targets, the roots), or an error with the stage index, the column and what was expected. At most 16 stages and 4 KiB of text. - Engine: a pure state machine. Input: list changes of listed nodes, value samples, sink replies,
tick(now). Output: row changes (upsert(path, columns),remove(path)) and the effects it wants (list,unlist,subscribe,unsubscribe,invoke,set). The host (link or CLI) performs the effects and feeds the results back. Every step is bounded; the same inputs give the same outputs (fixture tests, aswyrm-schedule). - Standards before our own code (D1): the pipeline syntax is DSA DQL’s (its users know it); paths are Zenoh key expressions (
*,**, the transport’s own standard); every expression and predicate is CEL (Common Expression Language, the Google specification used by Kubernetes, Envoy and Firebase rules), evaluated by the cratecel-interpreter(0.10, featuresregex,chrono; checked 2026-10-30 to build forwasm32-unknown-unknown); regular expressions are CELmatches()(RE2 syntax, crateregex). Our own code is only the pipeline parser and the row engine. CEL is not Turing-complete (no loops, no recursion; macros likeall/existsare bounded by their list), so its cost is bounded by the expression and the row; the link adds a bound on expression text (1 KiB) and on list sizes in a row. Amended 2026-10-31 (local review; a nest of 5maps over a 30-item literal took 4.8 s per row, and cel-rust cannot stop an evaluation): the bound is static, checked on the parsed expression (a scan of the text was fooled by spaces, raw strings and comments, and a chain like.map(b, b + b)doubled every step): no macro inside another macro’s body, at most 4 macros chained, no+and no list or map literal inside a macro’s body (only the expansion’s own@result + [x]), list literals ≤ 64 items, a bound value of more than 1 000 items or 16 KiB of text isnull. Row variables reach an evaluation only through a resolver that counts lookups (≤ 10 000) and, natively, watches a 20 ms deadline: past either the variables are gone and the evaluation stops withtoo costly(the only way to stop cel-rust). The dearest expression the static check allows, over the largest values, takes about 1 ms per row (debug build); cel-rust’s parser stops nesting at 96 levels, and every form within 1 KiB evaluates on a 2 MiB stack in release; the engine thread gets 8 MiB. - Keys are full keys (
wy/<site>/…, “full site names everywhere”); the core does not know its own site. Wildcards follow Zenoh, not DSA:*is one segment,**any depth. A DSA text goes throughconvert_dsa {text, site}(?→*, a trailing*→**,/downstream/…→wy/<site>/downstream/…).
The language (WYRM dialect; DSA names kept where they map)
| Command | WYRM meaning |
|---|---|
list <pattern>[, <pattern>…] | Rows for nodes under the patterns, reactive (added, changed, removed, link gone). Folders and values; actions are not nodes in WYRM (lista and listActions are dropped, see :actions). |
list sites | Rows for this site and the sites it sees (upstream/*, downstream/* brokers, attr.root); DSA brokers. A pattern under another site’s key (wy/plant/downstream/**) lists that site through the peer link within the ACL (ADR 0018) — in the first version (D4); DSA traverseBrokers is not needed, the key says where. |
path <key> | One row for one node. |
sublist <pattern> | A list relative to each row (./*, ./**); its rows replace the parent’s. |
where <CEL> | A CEL predicate over the row: type == "number" && attr.unit != "%", name.matches("^ahu[0-9]+$"), value > 20.0. Variables: the columns, and meta fields as type, unit, writable, is (profile), display, name, attr (map), actions (list of names), path. |
filter <DSA tests> | DSA syntax kept for imported queries ($type="number" @unit!="%" :name); the parser turns it into the same CEL ($x → x, @a → attr.a, a bare key → has(...), like → matches()), so there is one evaluator. A test on a column that no earlier stage made subscribes that column first (as DSA). |
subscribe [<key> [as <col>]]… / child | value (default), value.timestamp → the sample’s t, value.quality (new), a child’s value (./setpoint), $…, @…, :name, :display, :children. |
expression <col>="<CEL>"… | A column from a CEL expression over the row (value * 2.0, string(value) + " " + unit); DSA’s JavaScript-like row.value is accepted as row.value (the row is also bound as row). |
rename <a> as <b>, drop <cols>, option <k>=<v> | As DSA. Options: invoke_allow_null, throttle_ms, max_rows, timeout_s (see “Wide and deep trees”). qos is accepted and ignored (spec 03 QoS belongs to the point, cfg.qos). |
invoke <node>/~act/<action>(<p>=%<col>, <p>=<literal>…) | For each row, call the action when the referenced columns change. <node> is a full key or relative to the row (./, ../). |
set <node> = <expr> | New: write a value to a point for each row when it changes (~set; a write sink is more common in WYRM than an action). |
- Expressions: CEL as specified, with its standard functions and macros;
wyrm_core::Valuemaps to CEL values one to one (map, list, int, uint, double, string, bytes, bool, null; the sample time as a CELtimestamp). No functions of our own in the first version. An expression that fails on a row (a type error, a missing key) givesnullin that column and a count in the query’serrors, not the end of the query; a text that does not compile is refused atadd_query/runwith the stage and CEL’s message. - Rows: id = node key; columns in first-seen order; values are
wyrm_core::Value.
Host API: two additive changes (an amendment to ADR 0023)
DQL needs what the scheduler did not: to see the tree and to subscribe a subtree with one subscription.
Host::list(key, full) -> Result<SubId, AppError>(B2) — reactive one-level list (aswyrm-clientlist):App::on_list(sub, key, change)withchange = Refreshed(children) | Added(child) | Changed(child) | Removed(name) | Disconnected, a child =(name, NodeMeta). Needsreadon the key; ended byunsubscribe; counts toward a new boundmax_lists(2 000 per instance). A full queue coalesces a list’s changes into aRefreshed.Host::subscribe(key)accepts one final/**segment: one subscription for a subtree (fan-in);readon the prefix; each sample comes with its node key (on_valuealready has it). No other wildcard.- WIT:
wyrm:app@0.1.0stays frozen (ADR 0022 ruling 2), so components built on it keep loading. A newwyrm:app@0.2.0world is a superset: importlist, exporton-list; the WASM host tells the two worlds apart by their exports (as it tellspointfromdriver). The scheduler moves to 0.2.0 only when it is rebuilt.
The link (links/dql: an App, as links/scheduler)
<link>/ attrs: queries, rows, lists, subscriptions, sink_calls (DSA counters)
add_query {id, display?, text, enabled?, publish_ms?} (write; sinks need config) -> {id}
explain {text} (read) -> {stages, columns, roots, sinks, errors}
run {text, id?, ttl_s?} (write; sinks need config) -> {id, table} # ad-hoc, shared by identical text
import {json, id?, overwrite?} (config) # own export or a DSA text
convert_dsa {text, site} (read) -> {text}
<query>/ folder; attrs display, text, status (collecting | ready | error | disabled),
error, rows, columns, errors, created_by, expires (ad-hoc only),
progress: lists, lists_pending, depth, sites, collect_ms, last_publish
table the table: an array of row maps, columns order in attr `columns`
enabled writable bool; saved
get_table {from?, limit?} (read) -> rows
edit {display?, text?, publish_ms?} (as add_query); export (read) -> {json}; remove (write)
- Results as nodes:
tableis published when it changed, at most everypublish_ms(default 500 ms, 100 … 60 000) — coalesced, never per sample; with no change there is no message. Readers subscribe to it (explorer, flows, MCP, upstream sites);get_tablepages it (≤ 5 000 rows per reply). No per-row nodes: rows come and go faster than a tree should change, and the node budget would bound rows. - Ad-hoc queries (DSA
/query):runreturns the id and thetablekey of a temporary query withttl_s(default 300 s, ≤ 3 600);get_tableorrunagain with the same text renews it; identical text shares one (DSAQueryManager). Withidthe caller names it, so a dataflow can subscribe a fixed key (…/dql/<id>/table) in its definition. It is not stored: it ends with the instance. - Who asks (D2): engineers (explorer,
wyr, the agent through actions) and, later, dataflows: the broker collects data through the DQL link from a flow — a flowinvokesink callsrun {id, text}(or the engineer defines a standing query) and a flowsubscribesource reads<id>/table, waiting forstatus: readywhen it needs a complete table. A one-shotquery {text, timeout_ms} -> rowsthat answers when the table is complete needs deferred replies in the portable API (ADR 0023 non-goal today); it is left for the dataflow work. - Persistence: host store
index(the ids) andq/<id>(definition:{id, display, text, enabled, publish_ms, created_by}), written in the event that accepts the edit. Results are not stored; after a restart the query is evaluated again from the live tree (principle 3: what is not re-declared does not exist). - One subscription per root: the engine subscribes
<topmost fixed prefix>/**once for all value columns of a root and drops samples of keys that are not rows;listruns only on the levels the pattern can reach. - Bounds (constants of
links/dql, one place each, refused withresource_exhaustedbefore the host would fail the event): 200 queries; rows per querymax_rows(default 1 000, ≤ 5 000; over it the query showserror: max_rowsand keeps the first rows); lists 1 000 per query (B3) and 2 000 per link; subscriptions 1 000 per link; sink calls 50 in flight per link (the rest wait in a FIFO, as scheduler writes) and at most one in flight per row; at most 800 commands and 500 ms of batched work per event, the rest in0ms timer events (ADR 0022 ruling 5); nodes 5 per query (1 000 queries’ worth below the 10 000-node host bound). - Sinks (D3, D5):
setandinvokefire when the values they use change, and not for a row whose values are null (unlessinvoke_allow_null). After a start (a restart, an edit,enabledon, a row that appears) the first values seen are the baseline: neither sink fires until the state changes from it (D5: no write and no call repeated after a restart). There is no option to fire on start.throttle_ms(default 0) holds a row’s next call. A failed call is counted inerrorsand logged atinfo(ids only, never values); it is not retried (an action is not idempotent). - Rights (D2; as ADR 0022 ruling 6): a
ptokcarries one grant narrowed to the request key, so the link cannot see the caller’s rights on the keys a query lists; it does see the caller’s level on its own action key (SigningTokens::scopedkeeps the level). So:- a query without sinks (
add_query,run,edit,remove) iswrite: engineers, the agent (capped atwrite) and dataflows (the flow key is trusted atwrite; a deploy proof per target, ADR 0008) may define and run them; whoever haswriteon the DQL link may read what the link reads — the guide says so, and roles that must not see the whole site get nowriteon it; - a query with a sink (
set,invoke) needs the caller’s effective levelconfigon the action key: the app checkswhoand refuses withpermission_deniedotherwise. The SDK must give the app the effective level (the claim capped by aLimitedKey’s limit), so a flow or agent key never passes asconfig; the builder checkswho_ofand fixes it if it passes the raw claim. Flows therefore cannot create sink queries (they have their ownset/invokesinks). Switching a sink query on (enabled), editing it, replacing it byrunwith its id, and removing it needconfigtoo;writemay switch it off (stop its writes, as an operator stops a schedule), never start them again or drop an engineer’s query (review item 5, 2026-10-31); importisconfig(it may carry sinks); reading results (table,get_table,explain) isread. A query keeps running after its author loses rights (as flows and schedules);created_by=who.subject. The full-grants claim inptok(the scheduler’s open item) would allow checks against the author’s own rights on every key; not in this version.
- a query without sinks (
- Grants of the link: embedded —
readonwy/<site>/{downstream,dataflows,storage,upstream}andwriteonwy/<site>/downstream(sinks), signed with its own admin-made key (subjectlink:dql), trusted by links as aLimitedKeyatwrite, and not by itself (no query writing its own nodes in a loop, ADR 0022 ruling R21). Packages carry norequestergrants; an operator grants each root (sys/links/<id>/~act/grant, ADR 0013). A query on keys outside the grants showsstatus: errorwith the host’spermission_denied.
Wide and deep trees, other sites (D4)
Collecting a table can take time: one list round trip per level the pattern reaches, a peer hop per site (QUIC, ADR 0007), links that answer slowly. The link does not hide it, and the numbers tell us where the time goes once trees are big and deep:
status: collectinguntil every list the query started gave its firstRefreshed(or failed), thenready; a change later keepsready.timeout_s(default 30 s, ≤ 600) marks a queryreadywitherror: incomplete (<n> lists pending)when lists are still pending, and keeps waiting for them in the background.- Progress attributes on the query:
lists(running),lists_pending,depth(deepest level reached),sites(sites touched),collect_ms(start toready),last_publish. Counters on the link root:rows,lists,subscriptions,sink_calls,slowest_collect_ms. - The guide (
docs/dql.md) states the cost: a pattern with**near the top of a big site, or across sites, lists every level under it; prefer the narrowest fixed prefix (wy/plant/downstream/plc1/**, notwy/plant/**). - Lists of another site go through the router to that site’s links like any request from above (ADR 0018 read rules); the first-query timeout across peers in the backlog applies to them.
Run modes (one core, four hosts)
- Embedded in
wyrmd— the default, as the scheduler: one instance atwy/<site>/downstream/dql,dql: { enabled: true, store_mb: 16 }inwyrmd.json5; the iddqlreserved (validate_new_link_id,Daemon::openrefuses a stored link with it,peers.downstreamcannot name a sitedql); in the broker’s overlays; a failure to make its keys logs and the broker runs without it (ADR 0022 ruling R22). - Process package
dql-process—process::main::<Portable<Dql>>();wyrmd link dqlruns the same app as a process link. - WASM package
dql— the sameApp,--features wasm, worldwyrm:app@0.2.0,capabilities = { store_mb = 4 }. - CLI
wyr query "<text>"— the same engine overwyrm-clientwith the user’s own token: the ad-hoc, streaming DSA experience in a terminal (rows printed as they change,--json), rights checked by the router for the user, nothing stored. Later the same core can back an MCPquerytool and a flow source node (DSA “DQL as an embedded library”).
Tests and benchmarks
- Parser fixtures: DSA’s
statement_grammar.yamlcases converted, every example of the DSA README converted byconvert_dsaand parsed; errors name stage and column. - Engine fixtures (no host): list add/change/remove, link disconnected, sublist removal (the DSA bug),
>=(the DSA bug), filter that stops matching (row removed), auto-subscribe of filter columns, expression errors as null, sinks on change only and never on start (D5: a restart with the same values calls nothing), throttle, CEL errors as null, DSAfilter→ CEL translation. - The app on all three hosts with one scenario (as
scheduler_three_modes): a query overmock, its table, a restart (definition back, table rebuilt, no repeatedinvoke), a sink outside the grants. - Probe scenario
links/probe/scenarios/dql.json; user guidedocs/dql.md. - Benchmarks (targets on the reference board): 10 000 mock points,
list wy/<s>/downstream/mock/** | where type == "number" | subscribe— table complete < 2 s, one subscription; at 50k samples/s the query adds < 10 % of one core; table publication p99 <publish_ms+ 50 ms; idle: 0 messages. Deep and remote trees (D4), measured and recorded, not yet targets:collect_msfor depth 2, 4, 8 and fan-out 10, 100 under mock, on this site and across the demo chain (centralqueryingplantthroughedge).
Consequences
- ADR 0023 gains
Host::list,App::on_list, the/**subscribe pattern and thewyrm:app@0.2.0world;wyrm-link-api,wyrm-link-portable,wyrm-link-guest,wyrm-wasm-host,links/wasmchange; the 0.1.0 world and its components are untouched. - New crates
crates/wyrm-dql,links/dql;wyr query; the iddqlis reserved likestorageandscheduler. - Spec 02 does not change (existing value types and editors; the table is an array of maps).
examples/packages/build.shpacksdqlanddql-process.
Rulings of the build (B1 …)
- B1 — CEL crate:
cel0.15 (cel-rust, the maintained successor ofcel-interpreter), featuresregexonly.cel-interpreter0.10 panics on some invalid texts (1 +: an antlrunreachable!), which would restart the instance; 0.15 answers them as errors. Nochrono(its tz database is large in WASM): no CELtimestamp/duration; sample times are microseconds (value.timestamp). - B2 — full meta on demand:
view=listsummaries carry noattrand noactions, which DSA filters use (@mytag).Host::list(key, full): withfullthe host fetches each child’s whole~meta(one request more per child). A query asks for it only when a stage readsattr,actionsormeta(orlist sites). - B3 — lists per query: 1 000 (not 500): a site of 900 devices under one pattern fits; over it the query is
readywitherror: max_lists …. - B4 — other sites in the host:
BufferHostlet a portable link reach only its own site.subscribeandlistnow reach another site’s keys under an explicit grant;setandinvokestay on the link’s own site (owner decision 8). The embedded link getsreadondownstream,dataflows,storageof every sitePeers::reachablenames, per router build. - B5 — effective level in
Who: the portable runtime gave the app the rawptokgrants; it now caps each at the request’s effective level (Caller.perm, aLimitedKey’s limit), so a flow or agent token never showsconfig. - B6 — counters: the link root belongs to the host (ADR 0023), so the DQL counters are values under
stats/(statsis a reserved query id). - B7 — node ownership: the embedded DQL link does not trust its own key (as the scheduler, R21), so no query writes the DQL link’s own nodes.
- B8 — a fixed
sublist: aslist, a pattern without a wildcard lists that node’s children (sublist ./temp= the children oftemp). - B9 — not yet: a probe scenario on the demo, the three-mode e2e of the DQL link with its WASM and process packages, and benchmarks on the reference board. Tested: the engine and the link on
SimHost, both world versions inwyrm-wasm-host, and e2edql_embedded_queries_the_tree(the embedded link through a real router: a live table, its publication, asetsink only after a change);scheduler_three_modesandone_app_three_modespass with guests built on 0.2.0. - B10 — the grant a request carries: a
ptokcarries the first configured grant that covers its key, so areadgrant ondownstreamlisted before thewriteone sent sink writes atread(found by the e2e). The portable runtime now orders the link’s grants by level, highest first.
Owner decisions (2026-10-30)
- D1 — standards, fewer own solutions: CEL for expressions and predicates (
cel-interpreter), Zenoh key expressions for paths, RE2-style regex in CEL; DSA DQL pipeline syntax kept; no own expression language, norhaihere (not a standard). - D2 — who asks: engineers now and dataflows later (the broker collects data through the link): queries without sinks at
write, sink queries at effectiveconfig. - D3 —
setsink: added. - D4 — other sites: in the first version; collection time is shown (
collecting/ready, progress,collect_ms) and measured on deep and remote trees. - D5 — after a restart: wait for a change of state; no sink fires on start.
- D6 — WIT world (confirmed: a new
wyrm:app@0.2.0): a WASM link is built against a contract (WIT world) that lists what the broker gives it and what it must export. DQL needs one new broker function (list) and one new export (on-list). The scheduler’s WASM package, already installed on sites, is built onwyrm:app@0.1.0, which lackson-list. Changing 0.1.0 in place would make the broker expecton-listfrom every component and refuse the installed scheduler until it is rebuilt and reinstalled everywhere. A newwyrm:app@0.2.0beside 0.1.0 (proposed) lets old components keep running untouched and new ones (DQL, a rebuilt scheduler) use the new functions; the broker supports both.
Measured (2026-10-31, Apple M4 Max, loopback, release; dql_perf_local, dql_perf_chain)
- Collection of 1 000 points (
list …/** | where type == 'number' | subscribe,publish_ms100): the link’scollect_ms29–95 ms at depth 1–4 or fanout ≤ 100; 240 ms at fanout 2, depth 8 (511 lists); 871 ms at fanout 900 (901 lists); 5 000 points, fanout 50: 115 ms. A full table is published 1–2publish_mslater. - Across peers (1 000 points, fanout 10, depth 2):
collect_ms55 ms here, 61 ms one hop down, 69 ms two hops down. - A write on a point → the engine’s table: p50 4.9 ms, p99 12.3 ms (two hops down: p50 6.0 ms, p99 7.4 ms); a source write → the sink’s write of its target: p50 3.4 ms, p99 10.6 ms.
- Found by the first run: a 5 000-row subscription lost a value to the portable runtime’s overflow bound (256 + 4 096), and the refetch met the same bound. The overflow is now 16 384, and a subscription that lost values is opened again (at most 3 times) once the overflow has drained.
- Not yet: the reference board (4-core ARM64, 2 GB).
Item 4 — a query runs with its author’s rights (owner decision 2026-10-31)
Before, whoever had write on the DQL link defined a query over everything the link reads, and a sink wrote as link:dql: a user with a narrow read saw more through DQL (also found by the automated security review). Now:
-
The rights travel in the token. A
ptokon~act/*carries the optional claimauth(spec 04 0.2.10): the caller’s whole grant set on the site. It never authorizes the request; the SDK’s verifier caps each of its grants as the effective level (max,maxperm, the key’s cap) and to a limited key’s scopes (cap_auth), and the portable runtime hands it to the app asWho::authority. Owner decision: only on action tokens, so a link that is read or written never learns a caller’s grants. -
Kept with the definition.
add_query,run,importand aneditof the text store the caller’s rights (Rights {site, grants}) with the query, in the link’s store (not in the JSON export). The query keeps them after a restart and after its author’s grants change (as flows and schedules keep running). -
Applied while it runs. The engine (
Engine::with_rights) makes no row of a node its author may notread, takes no value of a key they may notread, and refuses a sink target they may notwritewhen it would fire (..may climb out of a root): the query’serrorscount it anderrornames the key. Keys of a downstream site are checked with the own-site grants rewritten to it, by the gateway’s rule (wyrm_core::ptok::grant_for_site). -
Unknown rights are refused (owner decision): a token without
auth(a flow, an old client) cannot define a query, and a stored query without kept rights showsstatus: erroruntil its text is edited or it is added again. -
Ad-hoc queries are shared only by callers with the same text and the same rights: a table made with one user’s rights is never handed to another through
run. -
wyr queryruns the engine without a bound: the user’s own token reads and writes there. -
Who reads a table (owner decision 2026-10-31):
get_tableanswers each caller with the rows it may read itself (its ownauth; noauthis refused), so the author’s rights make the table and the reader’s decide what of it they see. The live value<id>/tableexists only for a query withpublish: true(set withconfigonadd_query,run,editorimport): one value cannot be filtered per subscriber, so an engineer decides that a table is for whoever may read that node (the gateway filters it by the user’s grants, as any key). Dashboards and dataflows read published queries.