use super::super::guard_registry::{GuardChain, guard_sets};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(in super::super) enum GuardSetPreset {
Full,
Cached,
Streaming,
None,
}
impl GuardSetPreset {
pub(in super::super) fn resolve(self) -> GuardChain {
match self {
Self::Full => guard_sets::full(),
Self::Cached => guard_sets::cached(),
Self::Streaming => guard_sets::streaming(),
Self::None => GuardChain::empty(),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(in super::super) enum SessionResolutionMode {
FromBody,
FromChannel {
platform: String,
},
Dedicated,
#[cfg(test)]
Provided { session_id: String },
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub(in super::super) enum AuthorityMode {
ApiClaim,
ChannelClaim,
SelfGenerated,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(in super::super) enum InferenceMode {
Standard,
Streaming,
}
#[derive(Debug, Clone)]
#[allow(dead_code)] pub(in super::super) struct PipelineConfig {
pub injection_defense: bool,
pub dedup_tracking: bool,
pub session_resolution: SessionResolutionMode,
pub decomposition_gate: bool,
pub delegated_execution: bool,
pub specialist_controls: bool,
pub shortcuts_enabled: bool,
pub skill_first_enabled: bool,
pub short_followup_expansion: bool,
pub inference_mode: InferenceMode,
pub guard_set: GuardSetPreset,
pub cache_guard_set: GuardSetPreset,
pub cache_enabled: bool,
pub authority_mode: AuthorityMode,
pub post_turn_ingest: bool,
pub nickname_refinement: bool,
pub inject_diagnostics: bool,
pub task_operating_state: bool,
pub channel_label: String,
pub session_nickname_override: Option<String>,
pub model_override: Option<String>,
pub background_budget: bool,
}
impl PipelineConfig {
pub fn api() -> Self {
Self {
injection_defense: true,
dedup_tracking: true,
session_resolution: SessionResolutionMode::FromBody,
decomposition_gate: true,
delegated_execution: true,
specialist_controls: false,
shortcuts_enabled: true,
skill_first_enabled: false,
short_followup_expansion: true,
inference_mode: InferenceMode::Standard,
guard_set: GuardSetPreset::Full,
cache_guard_set: GuardSetPreset::Cached,
cache_enabled: true,
authority_mode: AuthorityMode::ApiClaim,
post_turn_ingest: true,
nickname_refinement: true,
inject_diagnostics: true,
task_operating_state: true,
channel_label: "api".into(),
session_nickname_override: None,
model_override: None,
background_budget: false,
}
}
pub fn streaming() -> Self {
Self {
injection_defense: true,
dedup_tracking: true,
session_resolution: SessionResolutionMode::FromBody,
decomposition_gate: true,
delegated_execution: true,
specialist_controls: false,
shortcuts_enabled: true,
skill_first_enabled: false,
short_followup_expansion: true,
inference_mode: InferenceMode::Streaming,
guard_set: GuardSetPreset::Streaming,
cache_guard_set: GuardSetPreset::None,
cache_enabled: true,
authority_mode: AuthorityMode::ApiClaim,
post_turn_ingest: true,
nickname_refinement: false,
inject_diagnostics: true,
task_operating_state: true,
channel_label: "api-stream".into(),
session_nickname_override: None,
model_override: None,
background_budget: false,
}
}
pub fn channel(platform: &str) -> Self {
Self {
injection_defense: true,
dedup_tracking: true,
session_resolution: SessionResolutionMode::FromChannel {
platform: platform.to_string(),
},
decomposition_gate: true,
delegated_execution: true,
specialist_controls: true,
shortcuts_enabled: true,
skill_first_enabled: true,
short_followup_expansion: true,
inference_mode: InferenceMode::Standard,
guard_set: GuardSetPreset::Full,
cache_guard_set: GuardSetPreset::Cached,
cache_enabled: true,
authority_mode: AuthorityMode::ChannelClaim,
post_turn_ingest: true,
nickname_refinement: false,
inject_diagnostics: false,
task_operating_state: true,
channel_label: platform.to_string(),
session_nickname_override: None,
model_override: None,
background_budget: false,
}
}
pub fn cron() -> Self {
Self {
injection_defense: true, dedup_tracking: false,
session_resolution: SessionResolutionMode::Dedicated,
decomposition_gate: true,
delegated_execution: false, specialist_controls: false,
shortcuts_enabled: false, skill_first_enabled: false,
short_followup_expansion: false,
inference_mode: InferenceMode::Standard,
guard_set: GuardSetPreset::Full,
cache_guard_set: GuardSetPreset::Cached,
cache_enabled: true,
authority_mode: AuthorityMode::SelfGenerated,
post_turn_ingest: true,
nickname_refinement: false,
inject_diagnostics: false,
task_operating_state: true,
channel_label: "cron".into(),
session_nickname_override: None,
model_override: None,
background_budget: true, }
}
}
#[cfg(test)]
impl PipelineConfig {
pub fn is_standard_inference(&self) -> bool {
self.inference_mode == InferenceMode::Standard
}
pub fn is_streaming_inference(&self) -> bool {
self.inference_mode == InferenceMode::Streaming
}
pub fn enforces_authority(&self) -> bool {
matches!(
self.authority_mode,
AuthorityMode::ApiClaim | AuthorityMode::ChannelClaim
)
}
pub fn can_execute_tools(&self) -> bool {
self.inference_mode == InferenceMode::Standard
}
pub fn resolves_session_from_body(&self) -> bool {
matches!(self.session_resolution, SessionResolutionMode::FromBody)
}
pub fn is_channel(&self) -> bool {
matches!(
self.session_resolution,
SessionResolutionMode::FromChannel { .. }
)
}
pub fn is_cron(&self) -> bool {
matches!(self.session_resolution, SessionResolutionMode::Dedicated)
&& matches!(self.authority_mode, AuthorityMode::SelfGenerated)
}
}