scientific_workflow/lib.rs
1//! Rust primitives for reproducible scientific workflows.
2//!
3//! `scientific-workflow` provides the data and execution foundations needed to
4//! describe scientific systems, record their evolution, and organize scoped
5//! computational work. The crate is intentionally divided by responsibility:
6//! state representation, in-memory state time series, storage, dispatch, and
7//! language bridges remain separate modules rather than accumulating behind
8//! one monolithic interface.
9//!
10//! # Current modules
11//!
12//! [`configuration`] provides the standard `config/{fixed,sweep,paths}.json`
13//! project layout, deterministic Cartesian or explicit-case task expansion,
14//! complete cheap task-configuration handles, exact sweep-value selection,
15//! named path resolution, and byte-exact source export.
16//! [`project`] adds the mandatory conventional `config/state.json` schema as
17//! one immutable [`project::ScientificProject`]. [`execution`] creates
18//! collision-resistant or caller-named execution scopes and deterministic task
19//! recording paths without taking ownership away from storage writers.
20//! [`reporting`] provides parameter-identified parallel progress tracking and
21//! one process-wide human-facing terminal owner. [`rng_record`] provides only
22//! validated, persisted RNG provenance records; random generation remains an
23//! application responsibility.
24//!
25//! [`system_state`] provides:
26//!
27//! - JSON-defined, immutable field layouts;
28//! - optional natural-language field descriptions without persisted Rust types;
29//! - heterogeneous concrete Rust payloads behind a typed API;
30//! - clone-free payload insertion, mutation, and extraction;
31//! - explicit per-payload cloning of complete states;
32//! - mutable, checked time-point progression.
33//!
34//! Type erasure and boxing remain internal to that module. Downstream crates
35//! work with their original concrete payload types.
36//!
37//! [`time_series`] provides the in-memory analysis collection for complete,
38//! ordered states. It enforces shared-layout identity and increasing simulation
39//! indices, offers a lightweight borrowed view, and permits field-level
40//! mutation without exposing mutable state time. It deliberately performs no
41//! serialization, chunking, or filesystem IO.
42//!
43//! [`storage`] provides named partial-state streams with writer-owned sampling
44//! intervals, borrowed JSON encoding only when due, bounded asynchronous
45//! persistence through one worker per recording, byte-targeted chunking, atomic recording
46//! metadata, automatic operational timing, terminal summaries, per-key payload
47//! decoders, and verified full-series or latest-state reconstruction.
48//! Import [`prelude`] when an application wants the complete supported API in
49//! scope without listing each module separately.
50//!
51//! # Basic use
52//!
53//! ```no_run
54//! use scientific_workflow::prelude::*;
55//!
56//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
57//! let spec = SystemStateSchema::load_json_template("state.json")?;
58//! let mut state = spec.create_empty_state(SimulationTime::from_iteration(0));
59//!
60//! assert!(
61//! state
62//! .insert_payload("population", vec![10_u64, 20, 30])?
63//! .is_none()
64//! );
65//! state
66//! .payload_mut::<Vec<u64>>("population")?
67//! .push(40);
68//! let time = state.advance_simulation_time(None)?;
69//! assert_eq!(time.iteration(), 1);
70//! let population = state.take_payload::<Vec<u64>>("population")?;
71//!
72//! assert_eq!(population, vec![10, 20, 30, 40]);
73//! # Ok(())
74//! # }
75//! ```
76//!
77//! Future dispatcher functionality will organize scoped workflow execution
78//! without changing the public state-value ownership or storage contracts.
79
80mod clock;
81
82pub mod configuration;
83pub mod execution;
84pub mod prelude;
85pub mod project;
86pub mod reporting;
87pub mod rng_record;
88pub mod storage;
89pub mod system_state;
90pub mod time_series;