zenkey_model/lib.rs
1//! zk2 keys and contracts, without a Zenoh session.
2//!
3//! This is the static half of zk2 (epic #585, issue #608): everything that
4//! can be decided from files, and never needs a bus. The design of record is
5//! `docs/zk2/architecture.md` (r4), stated normatively by `spec/core.md`;
6//! the authoring format is draft 3
7//! (`examples/zk2/README.md`).
8//!
9//! Layer map:
10//! - [`chunk`]: the plain-chunk charset and the small lexical predicates.
11//! - [`slug`]: canonical, injective slugging of foreign values into chunks,
12//! ported unchanged from v1.
13//! - [`grammar`]: the zk2 key grammar. Data keys, instance and interface
14//! tokens, member tokens and contract keys, as typed values over
15//! `zenoh_keyexpr::OwnedKeyExpr`, with a parser that refuses anything
16//! outside the grammar; and §1.3's selectors: the ambient one, the exact
17//! kind selectors, and the verbatim chunks a selector cannot reach
18//! ([`grammar::blind_spots`], #614 FL4).
19//! - [`template`]: resource templates, with build, match, overlap and the
20//! most-literal-first precedence (r3.3 D1).
21//! - [`authoring`]: the TOML authoring format, draft 3, as serde types;
22//! `spec/contract.schema.json` is generated from them.
23//! - [`diag`]: diagnostics with stable codes, the conformance surface of
24//! the lints.
25//! - [`schema`]: schema artifacts (protobuf through `protox`, JSON Schema)
26//! and type resolution.
27//! - [`contract`]: the contract model: defaults expanded, types resolved,
28//! every lint run; or read back from a bundle
29//! ([`contract::Contract::from_bundle`], #611).
30//! - [`canonical`]: the canonical JSON form, its restrictions, and the
31//! fingerprint.
32//! - [`bundle`]: the bundle container, built and verified Merkle-style.
33//! - [`history`]: the append-only `.history` of published revisions.
34//! - [`compat`]: the FULL_TRANSITIVE compatibility classifier (spec §9.8),
35//! over revisions from contracts or bundles, and the retention rule's
36//! identity check.
37//! - [`budget`]: the population budget (core §2.7, 0.24; #735): a
38//! templated resource's bound in an instance, what an event's `rate`
39//! bounds, and the pure judgement of a reading against them. The reads
40//! are the tools'.
41//! - [`catalog`]: the deployment catalog (core §8.6; #980 C1a): its
42//! reading with §8.6's refusals, its id, append-only succession, and a
43//! reader's resolution of the catalog an owner names, through a
44//! successor below its predecessor's count. It holds the deployment
45//! epoch and each revision's index; provisioning it is the deployment's.
46//! - [`descriptor`]: the descriptor record an instance serves, checked
47//! against its contracts; `spec/descriptor.schema.json` is generated
48//! from it.
49//! - [`envelope`]: the error envelope of a failed call, decoded and
50//! checked by its Zenoh encoding (`spec/core/error.proto`).
51//! - [`decode`]: a payload decoded from a bundle alone, for tools (§7.2).
52//! - [`validate`]: a value checked against a JSON Schema type of a bundle,
53//! the §7.3 subset and nothing more, for tools that build a payload from
54//! JSON (#671).
55//! - [`hostid`]: `hostid.v1`'s derivation of a system from a machine id
56//! (`spec/profiles/hostid/v1.md`, #719). The inputs, the shared file and
57//! failing closed are the runtime's.
58//! - [`freshness`]: `freshness.v1`'s horizon and its pure judgement of a
59//! member's freshness (`spec/profiles/freshness/v1.md`, #720). The
60//! owner's re-puts are the runtime's.
61//! - [`seed`]: a late joiner's merge (core §4.2, 0.26; 0.27, #752): per
62//! key, which arriving sample replaces what is held, by the stamp — an
63//! unstamped sample ranked below every stamped one, equal times ordered
64//! by the id as zenoh orders it. The GET and the subscription are the
65//! tools'.
66//! - [`health`]: `health.v1`'s levels, fault codes, and its pure judgement
67//! of one reading of a service, on top of [`freshness`]
68//! (`spec/profiles/health/v1.md`, #721). The owner's puts and its
69//! `clock_ahead` fault are the runtime's.
70//! - [`config`]: `config.v1`'s wire types, its validators, the window,
71//! redaction, and a pure state machine of one owner's configuration
72//! (`spec/profiles/config/v1.md`, #768). The device, the persisted layer
73//! and the timers are the runtime's.
74//! - [`link`]: `link.v1`'s exposure, the face policy a deployment writes
75//! and its lints, the plan a generator derives from both (denies, one
76//! downsampling rule per concrete key, the attachment, window floors,
77//! liveness evidence), and the checks of a router's block
78//! (`spec/profiles/link/v1.md`, #769). The router's configuration is the
79//! generator's.
80//! - [`alarms`]: `alarms.v1`'s key recipe, byte for byte ZenSight's, with
81//! its sanitizing step; the document and its checks; one key's samples
82//! read into transitions; a reference to an alarm; and §5's questions,
83//! on top of [`freshness`] (`spec/profiles/alarms/v1.md`, #800). The
84//! owner's puts, its confirmations and its adoption at a restart are the
85//! runtime's.
86//! - [`telemetry`]: `telemetry.v1`'s vocabulary and standard schema, the
87//! declaration read from a resolved resource, one sample's conformance
88//! with the member's kind and unit, and a pair's continuity and rate, its
89//! epoch in-band or from presence (`spec/profiles/telemetry/v1.md`,
90//! #819). The owner's in-band epoch is the runtime's.
91//! - [`desired`]: `desired.v1`'s vocabulary and standard schema, the
92//! declaration read from a resolved resource, a requirement's binding and
93//! its slice's key, the standard `Report` with its reading and its
94//! consistency, a target's pure two-phase state machine (each version
95//! ordered by its author's stamp, acted on once, the same document
96//! adopted without an act, refused whole or reverted), and §5's four
97//! questions (`spec/profiles/desired/v1.md`,
98//! #840). The author's writes and record, and the target's subscription,
99//! seed and archive read, are the runtime's.
100//! - [`redundancy`]: `redundancy.v1`'s vocabulary, the declaration read
101//! from a contract (governed, its election `claim` or `external`), how
102//! instance ids compare, the descriptor's standby mark read and checked,
103//! the election's decision over one read and the heal's over two, one
104//! candidate's pure two-phase state machine (claim, stand by, take over,
105//! step down), and §5's four questions of an address and an instance
106//! (`spec/profiles/redundancy/v1.md`, #841). The reads, the watch, the
107//! timers, the lock and the acts in core §8.2's order are the runtime's.
108//! - [`timing`]: `timing.v1`'s vocabulary, the declaration read from a
109//! resolved resource (a stream's period, deadline and lifespan), a
110//! reader's deadline tracker for one provider and resource as a pure state
111//! machine (missed, met and ended, edge-triggered, its detection bound,
112//! the members it holds under the bound), one sample's lifespan on the
113//! deployment's stated bound, the period over a tool's window, and §5's
114//! three questions (`spec/profiles/timing/v1.md`, #908). The subscription,
115//! the timer, the presence it follows and the stamps it reads are the
116//! runtime's.
117//! - [`arbitration`]: `arbitration.v1`'s vocabulary, a role's declaration
118//! read from its contract's requirement and the revision of the required
119//! interface held (the first profile to read a requirement's
120//! annotations), the ranking of a binding's providers, one role's
121//! arbitration as a pure state machine (eligibility by the deadline and
122//! by withdrawals, re-admission by a token or a read, a move of the watch
123//! held back, the active provider and its switches, the dead-man), and
124//! §5's three questions (`spec/profiles/arbitration/v1.md`, #909). The
125//! subscription, the watch, the reads, the timer and the safe value are
126//! the runtime's and the application's.
127//! - [`packed`]: the `packed` type kind (core §7.6, 0.75; #979 B1): its
128//! schema file and lints (E038 to E045), each type's layout, its layout
129//! form and tag, and an interpreted codec over JSON values, exact in its
130//! fixed point: the source of truth generated code (B2) matches.
131//! - [`frame`]: frames (core §7.7, 0.83; #981 K1): a frame resource's
132//! `frame` table resolved (E048), its layout over a packed record type
133//! with no marker, the frame form and tag, and one body read and written
134//! back, with §7.7's refusals. A reader's field states across frames are
135//! K2's, the owner's writer K3's.
136//! - [`wire`]: the zk2c envelope (core §7.5, 0.72; #976): CH's form, run
137//! width and tag, the run and the seq, a put's mutation and a delete's
138//! attachment, parsed without a contract with §7.5's refusals and written
139//! back byte for byte. Defined ahead of its use: no rule adopts it yet,
140//! and nothing else in the workspace reads or writes one.
141//! - [`forms`]: a call's forms by its operation's types (core §5.1, §5.2,
142//! 0.94; #985's C4c): each type's tag and a packed type's layout, the
143//! request, value, summary and error written, and an owner's read of a
144//! request, refused `invalid_request`.
145//! - [`heartbeat`]: the zk2c envelope's form 6 (core §7.5, 0.81; #978's
146//! F1): a revision's collections (its `state` and `@state` resources with
147//! a horizon above 0) as a [`heartbeat::Layout`] with its tag, a body
148//! read and written with them and §7.5's refusals, and a collection's
149//! [`heartbeat::Digest`]. `freshness.v2` adopts it (core 0.82; #978's
150//! F3): [`freshness::uses_v2`], and a reader's [`freshness::View`].
151//! - [`collection`]: the zk2c envelope's form 7, a collection's snapshot
152//! (core §7.5, 0.97; #977's E1): a GET reply's page, its body read and
153//! written with §7.5's refusals, a snapshot cut into pages under a page
154//! size, and a complete set of pages assembled. Defined: no rule adopts
155//! it yet (E2 reads it, E3 has owners write it).
156//!
157//! No item here opens a session or depends on `zenoh`: build scripts, CI
158//! tools and the Python verifier's fixtures all stand on this crate.
159
160pub mod alarms;
161pub mod arbitration;
162pub mod authoring;
163pub mod budget;
164pub mod bundle;
165pub mod canonical;
166pub mod catalog;
167pub mod chunk;
168pub mod collection;
169pub mod compat;
170pub mod config;
171pub mod contract;
172pub mod decode;
173pub mod descriptor;
174pub mod desired;
175pub mod diag;
176pub mod envelope;
177pub mod forms;
178pub mod frame;
179pub mod freshness;
180pub mod grammar;
181pub mod health;
182pub mod heartbeat;
183pub mod history;
184pub mod hostid;
185pub mod link;
186pub mod packed;
187pub mod redundancy;
188pub mod schema;
189pub mod seed;
190pub mod slug;
191mod strict;
192pub mod telemetry;
193pub mod template;
194pub mod timing;
195mod toml10;
196mod unbundle;
197pub mod validate;
198pub mod wire;