Skip to main content

rustev_contract/
lib.rs

1//! Rustev's versioned wire contract (spec 002).
2//!
3//! Every document Rustev reads or writes is defined here, with its schema
4//! string, its parse limits, its canonical form and, where it is identified,
5//! its identity. An outside project reads Rustev's records and reports by
6//! depending on this crate alone (spec 001, 3.4.5).
7//!
8//! Parsing supplied bytes is two-staged ([`bounded`]): a scan checks every
9//! resource bound before typed deserialization builds anything. Reading the
10//! bytes from a transport, and bounding that buffer, is the caller's job.
11#![forbid(unsafe_code)]
12
13pub mod acquisition;
14pub mod acquisition_record;
15pub mod acquisition_step;
16pub mod actionability;
17pub mod bounded;
18pub mod calibration;
19pub mod canonical;
20pub mod decimal;
21pub mod definition;
22pub mod descriptor;
23pub mod document;
24pub mod dynamic;
25pub mod eval_report;
26pub mod evidence;
27pub mod execution;
28pub mod explanation;
29pub mod extraction;
30pub mod extraction_documents;
31pub mod generation;
32pub mod generation_result;
33pub mod grade;
34pub mod ids;
35pub mod judgment;
36pub mod limits;
37pub mod live;
38pub mod optimization;
39pub mod output;
40pub mod parameter;
41pub mod plan;
42pub mod plan_diff;
43pub mod profile;
44pub mod reason;
45pub mod redaction;
46pub mod remote;
47pub mod replay;
48pub mod request;
49pub mod retention;
50pub mod run;
51pub mod schema_emit;
52pub mod scope;
53pub mod screening;
54pub mod snapshot;
55pub mod source;
56pub mod time;
57pub mod trace;
58pub mod trace_fields;
59pub mod version;
60
61pub use decimal::Decimal;
62pub use document::{Document, DocumentError, Identified};
63pub use time::{DurationMs, Timestamp};
64
65/// Schema strings of every document (spec 002, 3.2.1, as amended by spec 003,
66/// 3.2: plans are at version 2; execution policies and run records are new;
67/// by spec 004, 5.1: replay, request and runtime-reason documents; and by
68/// spec 009, 3.10: the remote protocol documents; by spec 032, 3.1.1:
69/// the #76 track versions and source descriptors; and by spec 019: the
70/// dynamic question documents).
71pub mod schema {
72    pub const EXTRACT_RULES: &str = "rustev.extract-rules/1";
73    pub const EXTRACT_REQUEST: &str = "rustev.extract-request/1";
74    pub const GENERATE_REQUEST: &str = "rustev.generate-request/1";
75    pub const TEXT_RESULT: &str = "rustev.text-result/1";
76    pub const PROMPT_TEMPLATE: &str = "rustev.prompt-template/1";
77    /// Decision explanation record canonical document (spec 040, 3.3).
78    pub const EXPLANATION: &str = "rustev.explanation/1";
79    /// Profile document (spec 034, 3.5).
80    pub const PROFILE: &str = "rustev.profile/1";
81    /// Plan comparison (spec 034, 3.12).
82    pub const PLAN_DIFF: &str = "rustev.plan-diff/1";
83    pub const DEFINITION: &str = "rustev.definition/1";
84    pub const PLAN: &str = "rustev.plan/2";
85    pub const BACKEND: &str = "rustev.backend/1";
86    pub const CALIBRATION: &str = "rustev.calibration/1";
87    pub const SNAPSHOT: &str = "rustev.snapshot/1";
88    pub const BACKEND_OUTPUT: &str = "rustev.backend-output/1";
89    pub const JUDGMENT: &str = "rustev.judgment/1";
90    pub const EVIDENCE: &str = "rustev.evidence/1";
91    pub const EVAL_REPORT: &str = "rustev.eval-report/1";
92    pub const EXECUTION: &str = "rustev.execution/1";
93    pub const RUN: &str = "rustev.run/1";
94    /// `rustev.run/1` plus a bounded `remote_evidence` list (spec 020,
95    /// 3.2); emitted only for a sink that selects it.
96    pub const RUN_V2: &str = "rustev.run/2";
97    /// The exact-operator registry version a plan was compiled against.
98    pub const EXACT_REGISTRY: &str = "rustev.exact/1";
99    /// Replay bundles, request identities and retained runtime reasons
100    /// (spec 004, 3.2 and 3.4).
101    pub const REPLAY: &str = "rustev.replay/1";
102    pub const REPLAY_V2: &str = "rustev.replay/2";
103    pub const REQUEST: &str = "rustev.request/1";
104    pub const RUNTIME_REASON: &str = "rustev.runtime-reason/1";
105    /// The `rustev.remote/1` protocol documents and the exchange record
106    /// (spec 009, 3.9 and 3.10).
107    pub const REMOTE_DESCRIBE: &str = "rustev.remote-describe/1";
108    pub const REMOTE_INFER: &str = "rustev.remote-infer/1";
109    pub const REMOTE_CANCEL: &str = "rustev.remote-cancel/1";
110    pub const REMOTE_EXCHANGE: &str = "rustev.remote-exchange/1";
111    /// The #76 track versions (spec 032, 3.1.1). Each is a superset of its
112    /// predecessor; later #76 specs add optional members to these versions
113    /// instead of defining further ones (3.1.2).
114    pub const DEFINITION_V2: &str = "rustev.definition/2";
115    pub const PLAN_V3: &str = "rustev.plan/3";
116    pub const SNAPSHOT_V2: &str = "rustev.snapshot/2";
117    pub const EVIDENCE_V2: &str = "rustev.evidence/2";
118    pub const RUN_V3: &str = "rustev.run/3";
119    pub const EXACT_REGISTRY_V2: &str = "rustev.exact/2";
120    /// Judgments of plans with `actionability` (spec 033, 3.1.3).
121    pub const JUDGMENT_V2: &str = "rustev.judgment/2";
122    /// Acquisition request identity document (spec 036, 3.3.1).
123    pub const ACQUISITION_REQUEST: &str = "rustev.acquisition-request/1";
124    /// Acquisition response page (spec 036, 3.3.3).
125    pub const ACQUISITION_PAGE: &str = "rustev.acquisition-page/1";
126    /// Context source descriptors (spec 032, 3.3.1).
127    pub const SOURCE: &str = "rustev.source/1";
128    /// Live re-execution evidence (spec 026, 3.6).
129    pub const LIVE_REEXECUTION: &str = "rustev.live-reexecution/1";
130    /// Dynamic questions (spec 019, 3.2 to 3.6): the request, a backend's
131    /// opt-in capability, and the outcome. None is a plan document.
132    pub const DYNAMIC_QUESTION: &str = "rustev.dynamic-question/1";
133    pub const DYNAMIC_CAPABILITY: &str = "rustev.dynamic-capability/1";
134    pub const DYNAMIC_OUTCOME: &str = "rustev.dynamic-outcome/1";
135}
136
137pub mod plan_bundle;
138pub mod remote_context;
139pub mod remote_sink;
140pub mod serve;