semantic_memory_forge/
v14.rs1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use stack_ids::{
4 ClaimId, CohortContractId, CounterfactualSliceId, EpisodeId, InterventionId, OutcomeSchemaId,
5 ScopeKey,
6};
7
8pub const INTERVENTION_BUNDLE_V1_SCHEMA: &str = "intervention_bundle_v1";
9pub const OUTCOME_SCHEMA_V1_SCHEMA: &str = "outcome_schema_v1";
10pub const COHORT_CONTRACT_V1_SCHEMA: &str = "cohort_contract_v1";
11pub const COUNTERFACTUAL_SLICE_V1_SCHEMA: &str = "counterfactual_slice_v1";
12
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
14pub struct InterventionBundleV1 {
15 pub schema_version: String,
16 pub intervention_id: InterventionId,
17 pub episode_id: EpisodeId,
18 pub unit_of_analysis: String,
19 pub treatment_definition: String,
20 pub baseline_treatment: String,
21 pub start_condition: String,
22 pub stop_condition: String,
23 #[serde(default, skip_serializing_if = "Option::is_none")]
24 pub allowed_scope: Option<ScopeKey>,
25 pub valid_from: String,
26 #[serde(default, skip_serializing_if = "Option::is_none")]
27 pub valid_to: Option<String>,
28 pub recorded_at: String,
29 #[serde(default, skip_serializing_if = "Vec::is_empty")]
30 pub related_claim_ids: Vec<ClaimId>,
31 #[serde(default, skip_serializing_if = "Vec::is_empty")]
32 pub policy_refs: Vec<String>,
33 #[serde(default, skip_serializing_if = "Vec::is_empty")]
34 pub approval_refs: Vec<String>,
35}
36
37#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
38pub struct OutcomeSchemaV1 {
39 pub schema_version: String,
40 pub outcome_schema_id: OutcomeSchemaId,
41 pub name: String,
42 pub measurement_definition: String,
43 pub time_window: String,
44 pub aggregation_rule: String,
45 pub degradation_behavior: String,
46 pub exactness_requirement: String,
47}
48
49#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
50pub struct CohortContractV1 {
51 pub schema_version: String,
52 pub cohort_contract_id: CohortContractId,
53 pub unit_definition: String,
54 #[serde(default, skip_serializing_if = "Vec::is_empty")]
55 pub inclusion_logic: Vec<String>,
56 #[serde(default, skip_serializing_if = "Vec::is_empty")]
57 pub exclusion_logic: Vec<String>,
58 pub scope_namespace: String,
59 pub workload_class: String,
60 #[serde(default, skip_serializing_if = "Vec::is_empty")]
61 pub environment_constraints: Vec<String>,
62 pub replay_linkage: String,
63}
64
65#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
66pub struct CounterfactualSliceV1 {
67 pub schema_version: String,
68 pub counterfactual_slice_id: CounterfactualSliceId,
69 pub intervention_id: InterventionId,
70 pub baseline_treatment: String,
71 pub cohort_contract_id: CohortContractId,
72 pub as_of_valid_time: String,
73 pub as_of_recorded_time: String,
74 pub replayable_data_slice: String,
75 pub exactness_target: String,
76 #[serde(default, skip_serializing_if = "Vec::is_empty")]
77 pub modeling_assumptions: Vec<String>,
78 #[serde(default, skip_serializing_if = "Vec::is_empty")]
79 pub expected_failure_modes: Vec<String>,
80}