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 extraction_results;
32pub mod generation;
33pub mod generation_result;
34pub mod grade;
35pub mod ids;
36pub mod judgment;
37pub mod limits;
38pub mod live;
39pub mod optimization;
40pub mod output;
41pub mod parameter;
42pub mod plan;
43pub mod plan_diff;
44pub mod profile;
45pub mod ranking;
46pub mod ranking_result;
47pub mod reason;
48pub mod redaction;
49pub mod remote;
50pub mod replay;
51pub mod request;
52pub mod retention;
53pub mod run;
54pub mod schema_emit;
55pub mod scope;
56pub mod screening;
57pub mod snapshot;
58pub mod source;
59pub mod time;
60pub mod trace;
61pub mod trace_fields;
62pub mod version;
63
64pub use decimal::Decimal;
65pub use document::{Document, DocumentError, Identified};
66pub use time::{DurationMs, Timestamp};
67
68/// Schema strings of every document (spec 002, 3.2.1, as amended by spec 003,
69/// 3.2: plans are at version 2; execution policies and run records are new;
70/// by spec 004, 5.1: replay, request and runtime-reason documents; and by
71/// spec 009, 3.10: the remote protocol documents; by spec 032, 3.1.1:
72/// the #76 track versions and source descriptors; and by spec 019: the
73/// dynamic question documents).
74pub mod schema {
75    pub const EXTRACT_RULES: &str = "rustev.extract-rules/1";
76    pub const EXTRACT_REQUEST: &str = "rustev.extract-request/1";
77    pub const GENERATE_REQUEST: &str = "rustev.generate-request/1";
78    pub const TEXT_RESULT: &str = "rustev.text-result/1";
79    pub const PROMPT_TEMPLATE: &str = "rustev.prompt-template/1";
80    /// Decision explanation record canonical document (spec 040, 3.3).
81    pub const EXPLANATION: &str = "rustev.explanation/1";
82    /// Profile document (spec 034, 3.5).
83    pub const PROFILE: &str = "rustev.profile/1";
84    /// Plan comparison (spec 034, 3.12).
85    pub const PLAN_DIFF: &str = "rustev.plan-diff/1";
86    pub const DEFINITION: &str = "rustev.definition/1";
87    pub const PLAN: &str = "rustev.plan/2";
88    pub const BACKEND: &str = "rustev.backend/1";
89    pub const CALIBRATION: &str = "rustev.calibration/1";
90    pub const SNAPSHOT: &str = "rustev.snapshot/1";
91    pub const BACKEND_OUTPUT: &str = "rustev.backend-output/1";
92    pub const JUDGMENT: &str = "rustev.judgment/1";
93    pub const EVIDENCE: &str = "rustev.evidence/1";
94    pub const EVAL_REPORT: &str = "rustev.eval-report/1";
95    pub const EXECUTION: &str = "rustev.execution/1";
96    pub const RUN: &str = "rustev.run/1";
97    /// `rustev.run/1` plus a bounded `remote_evidence` list (spec 020,
98    /// 3.2); emitted only for a sink that selects it.
99    pub const RUN_V2: &str = "rustev.run/2";
100    /// The exact-operator registry version a plan was compiled against.
101    pub const EXACT_REGISTRY: &str = "rustev.exact/1";
102    /// Replay bundles, request identities and retained runtime reasons
103    /// (spec 004, 3.2 and 3.4).
104    pub const REPLAY: &str = "rustev.replay/1";
105    pub const REPLAY_V2: &str = "rustev.replay/2";
106    pub const REQUEST: &str = "rustev.request/1";
107    pub const RUNTIME_REASON: &str = "rustev.runtime-reason/1";
108    /// The `rustev.remote/1` protocol documents and the exchange record
109    /// (spec 009, 3.9 and 3.10).
110    pub const REMOTE_DESCRIBE: &str = "rustev.remote-describe/1";
111    pub const REMOTE_INFER: &str = "rustev.remote-infer/1";
112    pub const REMOTE_CANCEL: &str = "rustev.remote-cancel/1";
113    pub const REMOTE_EXCHANGE: &str = "rustev.remote-exchange/1";
114    /// The #76 track versions (spec 032, 3.1.1). Each is a superset of its
115    /// predecessor; later #76 specs add optional members to these versions
116    /// instead of defining further ones (3.1.2).
117    pub const DEFINITION_V2: &str = "rustev.definition/2";
118    pub const PLAN_V3: &str = "rustev.plan/3";
119    pub const SNAPSHOT_V2: &str = "rustev.snapshot/2";
120    pub const EVIDENCE_V2: &str = "rustev.evidence/2";
121    pub const RUN_V3: &str = "rustev.run/3";
122    pub const EXACT_REGISTRY_V2: &str = "rustev.exact/2";
123    /// Judgments of plans with `actionability` (spec 033, 3.1.3).
124    pub const JUDGMENT_V2: &str = "rustev.judgment/2";
125    /// Acquisition request identity document (spec 036, 3.3.1).
126    pub const ACQUISITION_REQUEST: &str = "rustev.acquisition-request/1";
127    /// Acquisition response page (spec 036, 3.3.3).
128    pub const ACQUISITION_PAGE: &str = "rustev.acquisition-page/1";
129    /// Context source descriptors (spec 032, 3.3.1).
130    pub const SOURCE: &str = "rustev.source/1";
131    /// Live re-execution evidence (spec 026, 3.6).
132    pub const LIVE_REEXECUTION: &str = "rustev.live-reexecution/1";
133    /// Dynamic questions (spec 019, 3.2 to 3.6): the request, a backend's
134    /// opt-in capability, and the outcome. None is a plan document.
135    pub const DYNAMIC_QUESTION: &str = "rustev.dynamic-question/1";
136    pub const DYNAMIC_CAPABILITY: &str = "rustev.dynamic-capability/1";
137    pub const DYNAMIC_OUTCOME: &str = "rustev.dynamic-outcome/1";
138}
139
140pub mod plan_bundle;
141pub mod remote_context;
142pub mod remote_sink;
143pub mod serve;