Skip to main content

fetchium_core/research/
mod.rs

1//! Research pipeline types and module root (PRD §10).
2
3pub mod amrs;
4pub mod decompose;
5pub mod pipeline;
6pub mod srp;
7pub mod srp_types;
8
9pub use pipeline::ResearchPipeline;
10pub use srp::run_srp_pipeline;
11pub use srp_types::{SrpChunk, SrpConfig, SrpEvent};
12
13use crate::citation::evidence_graph::EvidenceGraph;
14use crate::citation::types::{CitationStyle, FormattedCitation, SourceMeta};
15use crate::validate::types::{ValidationMode, ValidationResult};
16use serde::{Deserialize, Serialize};
17
18/// Configuration for a research pipeline run.
19#[derive(Debug, Clone)]
20pub struct ResearchConfig {
21    pub query: String,
22    pub max_sources: usize,
23    pub token_budget: Option<usize>,
24    pub citation_style: CitationStyle,
25    pub validation_mode: ValidationMode,
26    pub strict_evidence: bool,
27    pub evidence_graph: bool,
28    pub trace_sources: bool,
29    pub trust_verify: bool,
30    pub max_rar_loops: usize,
31    /// Use AI to synthesize the report (default: true). Disable with --no-ai.
32    pub ai_synthesis: bool,
33    /// Enable deep thinking mode for AI models that support it (Gemini 2.5+).
34    /// Default: false (fast mode ~5s). Use --think flag for deeper analysis (~15-25s).
35    pub thinking: bool,
36}
37
38impl Default for ResearchConfig {
39    fn default() -> Self {
40        Self {
41            query: String::new(),
42            max_sources: 10,
43            token_budget: None,
44            citation_style: CitationStyle::Inline,
45            validation_mode: ValidationMode::Standard,
46            strict_evidence: false,
47            evidence_graph: false,
48            trace_sources: false,
49            trust_verify: false,
50            max_rar_loops: 3,
51            ai_synthesis: true,
52            thinking: false,
53        }
54    }
55}
56
57/// The output of a complete research pipeline run.
58#[derive(Debug, Clone, Serialize, Deserialize)]
59pub struct ResearchReport {
60    pub query: String,
61    pub sub_queries: Vec<String>,
62    pub synthesis: String,
63    pub sources: Vec<SourceMeta>,
64    pub citations: Vec<FormattedCitation>,
65    pub reference_section: String,
66    pub validation: ValidationResult,
67    pub evidence_graph: Option<EvidenceGraph>,
68    pub rar_iterations: Vec<crate::validate::rar::RarIterationResult>,
69    pub meta: ResearchMeta,
70}
71
72/// Metadata about a research pipeline run.
73#[derive(Debug, Clone, Serialize, Deserialize)]
74pub struct ResearchMeta {
75    pub duration_ms: u64,
76    pub sources_fetched: usize,
77    pub sources_validated: usize,
78    pub validation_pass_rate: f64,
79    pub overall_confidence: f64,
80    pub rar_loops_executed: usize,
81}