printobserver_supervisor_api/assessment.rs
1//! What a supervision turn answers with.
2//!
3//! [`AgentAssessment`] is the shape [`TurnOutcome`](crate::TurnOutcome)
4//! carries: the agent's written record of one turn, produced by the adapter
5//! behind this port against the schema this type generates — which is the one
6//! artifact the agent's answer may be constrained by. It is declared here,
7//! beside the port whose answer carries it, so that what an assessment says
8//! is the supervisor port's to change and nothing central's.
9
10use printobserver_types::contract::Sample;
11use printobserver_types::schemars::JsonSchema;
12use printobserver_types::serde::{Deserialize, Serialize};
13
14/// How sure the agent is.
15///
16/// A closed vocabulary rather than a number, because a number invites a
17/// precision the agent does not have.
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
19#[serde(
20 crate = "printobserver_types::serde",
21 rename_all = "snake_case",
22 deny_unknown_fields
23)]
24#[schemars(crate = "printobserver_types::schemars")]
25pub enum Confidence {
26 /// Not sure.
27 Low,
28 /// Fairly sure.
29 Medium,
30 /// Sure.
31 High,
32}
33
34/// What the agent's answer asks for next, in the vocabulary an
35/// acknowledgement's disposition is spelled in.
36///
37/// A turn that acknowledged nothing by command is acknowledged from its
38/// answer with this, so a quiet check records its judgement without a command
39/// of its own.
40#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
41#[serde(
42 crate = "printobserver_types::serde",
43 rename_all = "snake_case",
44 deny_unknown_fields
45)]
46#[schemars(crate = "printobserver_types::schemars")]
47pub enum Disposition {
48 /// Carry on printing.
49 Continue,
50 /// Carry on printing, watched more closely.
51 Watch,
52 /// The print should stop.
53 Stop,
54}
55
56/// The agent's written record of one supervision turn.
57///
58/// This is deliberately not how the agent acts: acting is a
59/// `PrintAction` that policy rules on.
60#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
61#[serde(crate = "printobserver_types::serde", deny_unknown_fields)]
62#[schemars(crate = "printobserver_types::schemars")]
63pub struct AgentAssessment {
64 /// One line saying what is happening.
65 pub summary: String,
66 /// How sure the agent is.
67 pub confidence: Confidence,
68 /// Whether the print should carry on.
69 pub should_continue: bool,
70 /// What the agent did.
71 pub did: String,
72 /// Why it did it.
73 pub why: String,
74 /// Whether the agent is escalating to a person.
75 pub escalating: bool,
76 /// What the turn's event is acknowledged with, when the turn acknowledged
77 /// nothing by command.
78 pub disposition: Disposition,
79}
80
81impl Sample for Confidence {
82 fn sample_full() -> Self {
83 Self::Medium
84 }
85}
86
87impl Sample for Disposition {
88 fn sample_full() -> Self {
89 Self::Watch
90 }
91}
92
93impl Sample for AgentAssessment {
94 fn sample_full() -> Self {
95 Self {
96 summary: "the first layer is down and adhesion looks even".to_owned(),
97 confidence: Confidence::Medium,
98 should_continue: true,
99 did: "slowed the feedrate to 80% for ten minutes".to_owned(),
100 why: "the extrusion width was widening on the long edges".to_owned(),
101 escalating: false,
102 disposition: Disposition::Watch,
103 }
104 }
105}