1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// @generated by idiolect-codegen. do not edit.
// source: dev.idiolect.observation
//! A signed aggregate over a set of encounter-family records. Observations decouple ranking from the orchestrator (P6): many observers publish competing aggregates over the same traces, and users choose whom to trust.
#![allow(
missing_docs,
clippy::doc_markdown,
clippy::struct_excessive_bools,
clippy::derive_partial_eq_without_eq
)]
use serde::{Deserialize, Serialize};
/// An observer publishes a structured summary of encounters, corrections, and retrospections matching a declared scope, using a declared method.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Observation {
/// Grounding for the observation. Omit when the repo owner is the observer; set explicitly when a third party is attributing the observation (e.g. caching or relaying another observer's aggregate).
#[serde(default, skip_serializing_if = "Option::is_none")]
pub basis: Option<super::defs::Basis>,
/// Structured method descriptor (see dev.idiolect.observer for the conformance floor). Enables reproducibility and comparison.
pub method: ObservationMethod,
/// DID of the observer publishing this aggregate.
pub observer: String,
pub occurred_at: String,
/// The observation's payload. Shape is method-defined. Typical shapes include correction-rate rankings, quality scores, or structured diagnostic summaries.
pub output: serde_json::Value,
/// The set of records this observation aggregates over.
pub scope: ObservationScope,
/// Version of this observation method; different versions may produce non-comparable outputs.
pub version: String,
pub visibility: super::defs::Visibility,
}
impl crate::Record for Observation {
const NSID: &'static str = "dev.idiolect.observation";
}
/// Structured method descriptor (see dev.idiolect.observer for the conformance floor). Enables reproducibility and comparison.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ObservationMethod {
/// Optional reference to the method's source code or specification.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub code_ref: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
/// Short method identifier.
pub name: String,
/// Method parameters as a free-form JSON object; interpretation is observer-defined.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub parameters: Option<serde_json::Value>,
}
/// The set of records this observation aggregates over.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ObservationScope {
/// Communities whose records are in scope.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub communities: Option<Vec<String>>,
/// Which encounter kinds this observation weights and includes. Observer must disclose this or the claim is uninterpretable.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub encounter_kinds: Option<Vec<ObservationScopeEncounterKinds>>,
/// Lenses included in scope. Empty array or omitted means 'all'.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub lenses: Option<Vec<super::defs::LensRef>>,
/// Time window covered by the aggregation.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub window: Option<ObservationScopeWindow>,
}
/// ObservationScopeEncounterKinds.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum ObservationScopeEncounterKinds {
InvocationLog,
Curated,
RoundtripVerified,
Production,
Adversarial,
}
/// Time window covered by the aggregation.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ObservationScopeWindow {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub from: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub until: Option<String>,
}