perspt_sdk/search/domain_types.rs
1//! Search-plane data types (PSP-10 system 19; minimal Phase 6 subset).
2//!
3//! This module currently holds only the data types the domain-package
4//! contract needs (`search_strategies`, `compare_branch_measurements`).
5//! Phase 7 expands it into the full forest: `SearchForest`,
6//! `SearchLimits`, budgets, selection, and frontier scheduling.
7
8use serde::{Deserialize, Serialize};
9
10use crate::residual::{ResidualClass, ResidualEvent};
11
12/// What a domain sees when proposing search strategies.
13#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
14pub struct SearchContext {
15 pub task: String,
16 /// Dominant residual classes of the failed attempt, most severe first.
17 pub dominant_residuals: Vec<ResidualClass>,
18 /// Strategy ids already tried this forest (duplicate suppression).
19 pub tried_strategies: Vec<String>,
20}
21
22/// One domain-proposed branch strategy. A strategy is a search prior; it
23/// carries no authority and no acceptance semantics.
24#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
25pub struct SearchStrategy {
26 pub strategy_id: String,
27 pub description: String,
28 /// Optional preferred route label; the runtime may ignore it.
29 #[serde(default, skip_serializing_if = "Option::is_none")]
30 pub route_preference: Option<String>,
31}
32
33/// The accepted root's measurement, for branch comparison.
34#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
35pub struct DomainMeasurement {
36 pub energy: f64,
37 pub hard_pass: bool,
38 pub residuals: Vec<ResidualEvent>,
39}
40
41/// One branch candidate's realized measurement (preview, not a decision).
42#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
43pub struct BranchMeasurement {
44 pub branch_id: String,
45 pub candidate_id: String,
46 pub energy: f64,
47 pub hard_pass: bool,
48 pub residuals: Vec<ResidualEvent>,
49 /// The immutable sensor-profile identity these numbers were measured
50 /// under; candidates with unequal profiles are never compared by
51 /// energy (Proposition 5).
52 pub sensor_profile: String,
53 /// Recorded cost (selection key 4).
54 pub cost: f64,
55}
56
57/// A domain's branch comparison verdict.
58#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
59pub enum BranchSelection {
60 Selected { branch_id: String },
61 NoneEligible,
62}