1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//! Configuration-driven scientific workflow execution.
//!
//! An ordinary application defines registered [`task::basic::ScientificModel`]
//! implementations, writes `wf_configs/study.json`, its declared named
//! state-schema documents, and the central `wf_configs/parameters.json`, then
//! calls [`run`] with the project root. Workflow infers task
//! instances, phase membership, identities, output paths, progress boundaries,
//! recording lifecycle, and execution mechanics.
//!
//! # Ordinary use
//!
//! ```no_run
//! use std::path::Path;
//!
//! fn main() -> Result<(), scientific_workflow::WorkflowError> {
//! scientific_workflow::run(Path::new("."))
//! }
//! ```
//!
//! A model carries its stable manifest key at its implementation:
//!
//! ```
//! use serde::Deserialize;
//! use scientific_workflow::prelude::basic::*;
//!
//! #[derive(Deserialize)]
//! struct Constants { initial: u64, steps: u64 }
//!
//! struct Model { state: SystemState, target_iteration: u64 }
//!
//! #[scientific_workflow::model("example")]
//! impl ScientificModel for Model {
//! type Constants = Constants;
//!
//! fn initialize(constants: Constants, schema: &SystemStateSchema) -> TaskResult<Self> {
//! let mut state = schema.create_empty_state(StateTime::from_iteration(0));
//! state.initialize_payload("population", constants.initial)?;
//! state.initialize_payload("cumulative_births", 0_u64)?;
//! Ok(Self {
//! state,
//! target_iteration: constants.steps,
//! })
//! }
//!
//! fn state(&self) -> &SystemState { &self.state }
//! fn is_complete(&self) -> bool {
//! self.state.time().iteration() >= self.target_iteration
//! }
//! fn target_iteration(&self) -> Option<u64> { Some(self.target_iteration) }
//! fn step(&mut self) -> TaskResult {
//! let (population, cumulative_births) = self
//! .state
//! .borrow_payloads_mut::<(u64, u64)>(
//! ("population", "cumulative_births"),
//! )?;
//! *population += 1;
//! *cumulative_births += 1;
//! self.state.advance_time(None)?;
//! Ok(())
//! }
//! }
//! ```
//!
//! # Ownership boundaries
//!
//! - [`config`] alone reads and parses project JSON and supplies typed model
//! constants.
//! - [`study`] composes parsed declarations, state semantics, and compiled model
//! registrations into immutable, output-free intent.
//! - [`runtime`] consumes a completed Study and owns active execution/output.
//! - [`task`] owns the model contract and automatic observation boundaries.
//! - [`state`] owns canonical scientific state and schema.
//! - [`observation`] owns scientific observation meaning, not persistence mechanics.
//! - [`persistence`] owns automatic durable output and verified reading.
//! - [`ui`] owns automatic terminal presentation of Runtime facts.
//! - [`error`] owns complete-workflow Study/Runtime error composition.
//!
//! The crate-level [`run`] facade performs the sole ordinary transition from
//! project root to Study to Runtime. `Study` is the ultimate coordinator of
//! declared intent; runtime is the ultimate coordinator of active execution.
//! Advanced integrations use each module's `advanced` scope. [`prelude`] only
//! aggregates those module-owned APIs and crate conveniences.
//!
//! Persistence write construction and output allocation are internal and are
//! not available to model authors.
//!
//! This crate is pre-1.0 test software and may make coordinated API changes.
extern crate self as scientific_workflow;
pub use WorkflowError;
pub use model;
/// Loads, preflights, and executes the Workflow project rooted at
/// `project_root`.
///
/// This is the sole ordinary application entry point. Project loading and
/// Study compilation finish before Runtime receives the validated immutable
/// Study. Successful completion returns `()`; advanced integrations can load
/// a [`study::advanced::Study`] and call [`runtime::advanced::execute`] to
/// retain a read-only run summary.
/// Implementation details used by Workflow's declaration macros.
///
/// This namespace is public only because procedural macro expansion occurs in
/// the application crate. It is not a supported application API.