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, orchestration, 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, arbitrary nested fixed/sweep separation, deterministic
14//! Cartesian or explicit-case task expansion, complete task-configuration
15//! handles, exact sweep-value selection, named path resolution, and byte-exact
16//! source export.
17//! [`project`] combines task configuration with either a project-owned
18//! `config/state.json` schema or a canonical schema supplied by a fixed-model
19//! crate as one immutable [`project::ScientificProject`]. [`execution`] creates
20//! collision-resistant or caller-named execution scopes and deterministic task
21//! recording paths without taking ownership away from storage writers.
22//! [`artifact`] atomically publishes and verifies content-addressed immutable
23//! bytes while leaving their scientific representation to consumer crates.
24//! [`runtime`] provides phase-based bounded scheduling and one process-wide
25//! human-facing display for registered tasks. Task workloads retain ownership
26//! of all scientific I/O. [`rng_record`] provides only
27//! validated, persisted RNG provenance records; random generation remains an
28//! application responsibility.
29//!
30//! [`system_state`] provides:
31//!
32//! - JSON-defined, immutable field layouts;
33//! - optional natural-language field descriptions without persisted Rust types;
34//! - heterogeneous concrete Rust payloads behind a typed API;
35//! - clone-free payload insertion, mutation, and extraction;
36//! - explicit per-payload cloning of complete states;
37//! - mutable, checked time-point progression.
38//!
39//! Type erasure and boxing remain internal to that module. Consumer crates
40//! work with their original concrete payload types.
41//!
42//! [`time_series`] provides the in-memory analysis collection for complete,
43//! ordered states. It enforces shared-layout identity and increasing simulation
44//! indices, offers a lightweight borrowed view, and permits field-level
45//! mutation without exposing mutable state time. It deliberately performs no
46//! serialization, chunking, or filesystem IO.
47//!
48//! [`storage`] provides named partial-state streams with writer-owned sampling
49//! intervals, borrowed JSON encoding only when due, bounded asynchronous
50//! persistence through one worker per recording, byte-targeted chunking, atomic recording
51//! metadata, automatic operational timing, terminal summaries, name-selected payload
52//! decoders, and verified full-series or latest-state reconstruction.
53//! Import [`prelude::basics`] for these scientific primitives and
54//! [`prelude::runtime`] only at orchestration boundaries.
55//!
56//! # Basic use
57//!
58//! ```no_run
59//! use scientific_workflow::prelude::basics::*;
60//!
61//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
62//! let spec = SystemStateSchema::load_json_template("state.json")?;
63//! let mut state = spec.create_empty_state(SimulationTime::from_iteration(0));
64//!
65//! assert!(
66//! state
67//! .insert_payload("population", vec![10_u64, 20, 30])?
68//! .is_none()
69//! );
70//! state
71//! .payload_mut::<Vec<u64>>("population")?
72//! .push(40);
73//! let time = state.advance_simulation_time(None)?;
74//! assert_eq!(time.iteration(), 1);
75//! let population = state.take_payload::<Vec<u64>>("population")?;
76//!
77//! assert_eq!(population, vec![10, 20, 30, 40]);
78//! # Ok(())
79//! # }
80//! ```
81//!
82//! Future orchestration-layer features will organize scoped workflow execution
83//! without changing the public state-value ownership or storage contracts.
84
85mod clock;
86
87pub mod artifact;
88pub mod configuration;
89pub mod execution;
90pub mod prelude;
91pub mod project;
92pub mod rng_record;
93pub mod runtime;
94pub mod storage;
95pub mod system_state;
96pub mod time_series;