Skip to main content

schedr_model/
schema.rs

1//! The JSON Schemas generated from the model, committed to the repository and checked by CI
2//! (see archive/PROJECT.md, Rust/Python integration: shared model and schemas).
3
4use schemars::{Schema, schema_for};
5
6use crate::ctx::{CtxAnswer, CtxRequest};
7use crate::dag::Dag;
8use crate::runner::{AgentMessage, RunnerMessage};
9
10#[cfg(test)]
11mod tests;
12
13/// The JSON Schema of DAG JSON (one [`Dag`]).
14#[must_use]
15pub fn dag_schema() -> Schema {
16    schema_for!(Dag)
17}
18
19/// The JSON Schema of the agent <-> runner messages: one message in either direction.
20#[must_use]
21pub fn runner_schema() -> Schema {
22    schema_for!(RunnerChannelMessage)
23}
24
25/// The JSON Schema of a command task's context channel: one message in either direction.
26#[must_use]
27pub fn ctx_schema() -> Schema {
28    schema_for!(CtxChannelMessage)
29}
30
31/// Any message on a context connection (only used to generate one schema for both).
32#[derive(schemars::JsonSchema)]
33#[serde(untagged)]
34#[expect(dead_code, reason = "only its schema is used")]
35enum CtxChannelMessage {
36    /// From the task's process.
37    Request(CtxRequest),
38    /// From the agent.
39    Answer(CtxAnswer),
40}
41
42/// Any message on the agent <-> runner channel (only used to generate one schema for both).
43#[derive(schemars::JsonSchema)]
44#[serde(untagged)]
45#[expect(dead_code, reason = "only its schema is used")]
46enum RunnerChannelMessage {
47    /// From the runner.
48    Runner(RunnerMessage),
49    /// From the agent.
50    Agent(AgentMessage),
51}