diff --git a/lib/crates/fabro-cli/src/commands/store/dump.rs b/lib/crates/fabro-cli/src/commands/store/dump.rs index 372199710..03fc1dcd0 100644 --- a/lib/crates/fabro-cli/src/commands/store/dump.rs +++ b/lib/crates/fabro-cli/src/commands/store/dump.rs @@ -4,7 +4,7 @@ use std::path::Path; use anyhow::{Context, Result}; #[cfg(test)] use fabro_store::NodeVisitRef; -use fabro_store::{RunState, SlateRunStore}; +use fabro_store::{RunProjection, SlateRunStore}; use fabro_workflow::run_dump::RunDump; use fabro_workflow::run_lookup::{resolve_run_combined, runs_base}; #[cfg(test)] @@ -79,7 +79,7 @@ pub(crate) async fn export_run(run_store: &SlateRunStore, output_dir: &Path) -> async fn export_run_to_dir( run_store: &SlateRunStore, - state: &RunState, + state: &RunProjection, output_dir: &Path, ) -> Result { let dump = RunDump::store_export(run_store, state).await?; diff --git a/lib/crates/fabro-cli/tests/it/cmd/support.rs b/lib/crates/fabro-cli/tests/it/cmd/support.rs index 2aca7d7c8..9d84ff0b6 100644 --- a/lib/crates/fabro-cli/tests/it/cmd/support.rs +++ b/lib/crates/fabro-cli/tests/it/cmd/support.rs @@ -4,7 +4,7 @@ use std::process::Output; use std::sync::Arc; use std::time::{Duration, Instant}; -use fabro_store::{EventEnvelope, RunState, SlateRunStore, SlateStore}; +use fabro_store::{EventEnvelope, RunProjection, SlateRunStore, SlateStore}; use fabro_test::TestContext; use fabro_types::RunId; use object_store::local::LocalFileSystem; @@ -492,7 +492,7 @@ fn run_store(run_dir: &Path) -> SlateRunStore { block_on(store.open_run_reader(&run_id)).expect("run store should exist") } -pub(crate) fn run_state(run_dir: &Path) -> RunState { +pub(crate) fn run_state(run_dir: &Path) -> RunProjection { let store = run_store(run_dir); block_on(store.state()).expect("run store state should exist") } diff --git a/lib/crates/fabro-cli/tests/it/scenario/mod.rs b/lib/crates/fabro-cli/tests/it/scenario/mod.rs index 4994fea73..f68870e79 100644 --- a/lib/crates/fabro-cli/tests/it/scenario/mod.rs +++ b/lib/crates/fabro-cli/tests/it/scenario/mod.rs @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::time::Duration; -use fabro_store::{RunState, SlateRunStore, SlateStore}; +use fabro_store::{RunProjection, SlateRunStore, SlateStore}; use fabro_types::RunId; use object_store::local::LocalFileSystem; pub(super) fn fixture(name: &str) -> PathBuf { @@ -47,7 +47,7 @@ fn run_store(run_dir: &Path) -> SlateRunStore { block_on(store.open_run_reader(&run_id)).expect("run store should exist") } -pub(super) fn run_state(run_dir: &Path) -> RunState { +pub(super) fn run_state(run_dir: &Path) -> RunProjection { let store = run_store(run_dir); block_on(store.state()).expect("run store state should exist") } diff --git a/lib/crates/fabro-store/src/lib.rs b/lib/crates/fabro-store/src/lib.rs index adb3bd993..b6f49dbce 100644 --- a/lib/crates/fabro-store/src/lib.rs +++ b/lib/crates/fabro-store/src/lib.rs @@ -10,7 +10,7 @@ mod slate; mod types; pub use error::{Result, StoreError}; -pub use run_state::{NodeState, RunState}; +pub use run_state::{NodeState, RunProjection}; pub use runtime::RuntimeState; pub use slate::{SlateRunStore, SlateStore}; pub use types::{CatalogRecord, EventEnvelope, EventPayload, NodeVisitRef, RunSummary}; diff --git a/lib/crates/fabro-store/src/run_state.rs b/lib/crates/fabro-store/src/run_state.rs index 29de59a23..2130e6626 100644 --- a/lib/crates/fabro-store/src/run_state.rs +++ b/lib/crates/fabro-store/src/run_state.rs @@ -14,7 +14,7 @@ use fabro_types::{ }; #[derive(Debug, Clone, Default)] -pub struct RunState { +pub struct RunProjection { pub run: Option, pub graph_source: Option, pub start: Option, @@ -50,10 +50,10 @@ pub struct NodeState { #[derive(Debug, Clone, Default)] pub(crate) struct EventProjectionCache { pub last_seq: u32, - pub state: RunState, + pub state: RunProjection, } -impl RunState { +impl RunProjection { pub(crate) fn apply_events(events: &[EventEnvelope]) -> Result { let mut state = Self::default(); for event in events { @@ -547,7 +547,7 @@ fn conclusion_from_failed( fn stage_visit( node_id: &str, properties: &serde_json::Map, - state: &RunState, + state: &RunProjection, ) -> Option { properties .get("node_visits") diff --git a/lib/crates/fabro-store/src/slate/run_store.rs b/lib/crates/fabro-store/src/slate/run_store.rs index bf9fc34d1..a1e19ced7 100644 --- a/lib/crates/fabro-store/src/slate/run_store.rs +++ b/lib/crates/fabro-store/src/slate/run_store.rs @@ -15,7 +15,7 @@ use tokio_stream::wrappers::UnboundedReceiverStream; use crate::keys; use crate::run_state::EventProjectionCache; use crate::{ - CatalogRecord, EventEnvelope, EventPayload, NodeVisitRef, Result, RunState, RunSummary, + CatalogRecord, EventEnvelope, EventPayload, NodeVisitRef, Result, RunProjection, RunSummary, StoreError, }; use fabro_types::RunId; @@ -147,11 +147,11 @@ impl SlateRunStore { R: DbRead + Sync, { let events = list_events_from(db, 1).await?; - let state = RunState::apply_events(&events)?; + let state = RunProjection::apply_events(&events)?; Ok(state.build_summary(catalog)) } - async fn projected_state(&self) -> Result { + async fn projected_state(&self) -> Result { let next_seq = { let cache = self.inner.projection_cache.lock().await; cache.last_seq.saturating_add(1) @@ -271,7 +271,7 @@ impl SlateRunStore { self.inner.db.list_all_assets().await } - pub async fn state(&self) -> Result { + pub async fn state(&self) -> Result { self.projected_state().await } } diff --git a/lib/crates/fabro-workflow/src/pipeline/pull_request.rs b/lib/crates/fabro-workflow/src/pipeline/pull_request.rs index 54c5ee42d..c88213d9c 100644 --- a/lib/crates/fabro-workflow/src/pipeline/pull_request.rs +++ b/lib/crates/fabro-workflow/src/pipeline/pull_request.rs @@ -1,5 +1,5 @@ use fabro_config::run::MergeStrategy; -use fabro_store::{RunState, SlateRunStore}; +use fabro_store::{RunProjection, SlateRunStore}; use fabro_types::PullRequestRecord; use tracing::{debug, info}; @@ -204,7 +204,7 @@ fn parse_dot_summary(dot: &str) -> (String, usize, usize) { /// Nodes are sorted alphabetically so `plan` is preferred over `planning`. /// For repeated visits, earlier visits sort first to match the prior on-disk /// directory scan behavior. -fn read_plan_text(state: &RunState) -> Option { +fn read_plan_text(state: &RunProjection) -> Option { let mut plan_nodes = state .nodes .iter() @@ -907,7 +907,7 @@ mod tests { #[test] fn read_plan_text_found() { - let mut state = RunState::default(); + let mut state = RunProjection::default(); state.nodes.insert( ("plan".to_string(), 1), fabro_store::NodeState { @@ -922,7 +922,7 @@ mod tests { #[test] fn read_plan_text_prefix_match() { - let mut state = RunState::default(); + let mut state = RunProjection::default(); state.nodes.insert( ("planning".to_string(), 1), fabro_store::NodeState { @@ -937,7 +937,7 @@ mod tests { #[test] fn read_plan_text_prefers_alphabetically_first_plan_node() { - let mut state = RunState::default(); + let mut state = RunProjection::default(); state.nodes.insert( ("planning".to_string(), 1), fabro_store::NodeState { @@ -959,7 +959,7 @@ mod tests { #[test] fn read_plan_text_not_found() { - let mut state = RunState::default(); + let mut state = RunProjection::default(); state.nodes.insert( ("implement".to_string(), 1), fabro_store::NodeState::default(), @@ -971,7 +971,7 @@ mod tests { #[test] fn read_plan_text_empty_state() { - let state = RunState::default(); + let state = RunProjection::default(); let result = read_plan_text(&state); assert_eq!(result, None); } diff --git a/lib/crates/fabro-workflow/src/run_dump.rs b/lib/crates/fabro-workflow/src/run_dump.rs index e730b64fd..007403038 100644 --- a/lib/crates/fabro-workflow/src/run_dump.rs +++ b/lib/crates/fabro-workflow/src/run_dump.rs @@ -2,7 +2,7 @@ use std::io::Write; use std::path::{Component, Path, PathBuf}; use anyhow::{Context, Result, bail}; -use fabro_store::{NodeVisitRef, RunState, SlateRunStore}; +use fabro_store::{NodeVisitRef, RunProjection, SlateRunStore}; use crate::git::MetadataStore; @@ -26,7 +26,7 @@ pub enum RunDumpContents { impl RunDump { #[must_use] - pub fn metadata_init(state: &RunState) -> Self { + pub fn metadata_init(state: &RunProjection) -> Self { let mut entries = Vec::new(); if let Some(record) = state.run.as_ref() { push_json_entry(&mut entries, "run.json", record); @@ -41,7 +41,7 @@ impl RunDump { } #[must_use] - pub fn metadata_checkpoint(state: &RunState) -> Self { + pub fn metadata_checkpoint(state: &RunProjection) -> Self { let mut entries = Vec::new(); let mut keys: Vec<_> = state.nodes.keys().collect(); keys.sort(); @@ -106,7 +106,7 @@ impl RunDump { } #[must_use] - pub fn metadata_finalize(state: &RunState) -> Self { + pub fn metadata_finalize(state: &RunProjection) -> Self { let mut dump = Self::metadata_checkpoint(state); if let Some(retro) = state.retro.as_ref() { push_json_entry(&mut dump.entries, "retro.json", retro); @@ -114,7 +114,7 @@ impl RunDump { dump } - pub async fn store_export(run_store: &SlateRunStore, state: &RunState) -> Result { + pub async fn store_export(run_store: &SlateRunStore, state: &RunProjection) -> Result { let mut entries = Vec::new(); if let Some(record) = state.run.as_ref() {