oxide-batch 0.6.0

Rust-native framework for reliable, restartable batch processing, inspired by Spring Batch
Documentation
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
//! The public facade for `OxideBatch`.
//!
//! `OxideBatch` models a batch job as a named definition launched with typed
//! parameters. Identifying parameters select a logical [`JobInstance`], while
//! each launch or restart receives a distinct [`JobExecutionId`].
//!
//! ```
//! use oxide_batch::{
//!     JobInstanceKey, JobName, JobParameter, JobParameters, ParameterName,
//!     ParameterRole, ParameterValue,
//! };
//!
//! let mut parameters = JobParameters::new();
//! parameters.insert(
//!     ParameterName::new("business_date")?,
//!     JobParameter::new(
//!         ParameterValue::string("2026-07-29")?,
//!         ParameterRole::Identifying,
//!     ),
//! )?;
//!
//! let key = JobInstanceKey::new(JobName::new("daily_import")?, &parameters);
//! assert_eq!(key.identifying_parameter_count(), 1);
//! # Ok::<(), oxide_batch::DomainError>(())
//! ```
//!
//! Parameter values are sensitive by default. Their [`Debug`](std::fmt::Debug)
//! representations expose the value kind, but not the underlying value.
//!
//! Repository operations run inside an explicit [`RepositoryUnitOfWork`].
//! Time and identifiers are injected into the reference
//! [`InMemoryJobRepository`], so tests do not depend on wall-clock time or
//! process-global identifier state. A unit of work publishes changes only
//! after [`RepositoryUnitOfWork::commit`] succeeds; dropping it rolls back its
//! staged metadata.
//!
//! [`JobLauncher`] runs one-step [`TaskletJob`] definitions on an
//! application-owned executor. Tasklets borrow their call-scoped
//! [`TaskletContext`], receive cooperative [`StopToken`] state, and persist
//! completed, failed, panicked, or stopped outcomes through the repository.
//! Synchronous bodies use [`BlockingTaskletAdapter`] with an explicit nonzero
//! concurrency bound.
//!
//! [`JobExecutionListener`] and [`StepExecutionListener`] callbacks nest around
//! tasklet work with deterministic ordering. [`LifecycleEvent`] values are
//! emitted after corresponding metadata commits through a non-authoritative
//! [`LifecycleEventSink`]. Their structured fields exclude parameters,
//! contexts, records, credentials, and arbitrary user error payloads.
//!
//! M2 chunk definitions use [`ChunkStep`], [`ChunkJob`], [`ItemReader`],
//! [`ItemProcessor`], [`ItemWriter`], and [`ChunkCompletion`]. The
//! [`JobLauncher::launch_chunk`] path reuses job/step lifecycle metadata while
//! [`ChunkTransaction`] isolates adapter-owned commit and rollback. End of
//! input, filtering, cooperative stopping, failures, unknown commit, and
//! post-commit acknowledgement remain distinct typed outcomes. An enlisted
//! writer borrows [`BusinessTransaction`] for only its call; no database-driver
//! type crosses the facade.
//!
//! [`ItemReader`], [`ItemProcessor`], and [`ItemWriter`] are plain `async fn`
//! contracts ([ADR-0008](https://github.com/luceat-lux-vestra/oxide-batch/blob/main/docs/architecture/decisions/0008-item-component-contract.md)):
//! an implementor writes a natural `async fn`, with no `BoxFuture`, `Pin`,
//! `Box::pin`, or named future type in sight, and [`ChunkStep`] drives it
//! monomorphized with no per-item allocation. [`BoxedReader`],
//! [`BoxedProcessor`], and [`BoxedWriter`] are the explicit, opt-in erasure
//! boundary for dynamic composition.
//!
//! ```
//! use oxide_batch::{ItemReader, ReadContext, ReadOutcome, ReaderError, StopSource};
//!
//! struct Counter(u64);
//!
//! impl ItemReader<u64> for Counter {
//!     async fn read(&mut self, _context: ReadContext<'_>) -> Result<ReadOutcome<u64>, ReaderError> {
//!         self.0 += 1;
//!         Ok(ReadOutcome::Item(self.0))
//!     }
//! }
//!
//! let mut counter = Counter(0);
//! let (_source, stop) = StopSource::new();
//! let outcome = futures_executor::block_on(counter.read(ReadContext::new(&stop)))?;
//! assert_eq!(outcome, ReadOutcome::Item(1));
//! # Ok::<(), ReaderError>(())
//! ```
//!
//! M3 adds runtime-neutral fault-tolerance values. [`FaultPolicy`] combines a
//! [`FaultClassifier`] over stable [`FaultPhase`] and [`FailureCategory`]
//! inputs with a bounded [`RetryLimit`], [`RetryStateLimit`], [`SkipLimit`],
//! and a deterministic [`BackoffPolicy`]. [`FaultPolicy::decide`] is a pure
//! function of the policy, a framework-owned [`FaultDescriptor`], and
//! [`FaultEvidence`], so a restart reproduces the same decision. Waiting uses
//! an injected [`BackoffSleeper`] rather than wall-clock time, and
//! [`RollbackDisposition::CommitSafeSkip`] still records a skip instead of
//! silently dropping an item.
//!
//! [`ItemListenerSet`] owns the M3 [`ReadListener`], [`ProcessListener`],
//! [`WriteListener`], [`RetryListener`], and [`SkipListener`] families. Before
//! callbacks run in registration order and stop at the first failure; the
//! matching completion callbacks run only the entered listeners in reverse
//! order and aggregate every failure. A panic is classified exactly like a
//! returned [`ListenerError`], and no callback receives an error payload.
//!
//! [`ChunkStep::with_fault_runtime`] installs a [`FaultRuntime`] and makes that
//! policy executable. A retryable fault rolls the chunk attempt back, reserves
//! its ordinal through a bounded [`FaultStateStore`], runs the retry scope,
//! waits the injected backoff, and replays the chunk from inputs it already
//! read, so a stateful reader never rewinds. An accepted skip is provisional
//! until the commit that records it, and a commit-safe skip additionally
//! requires [`ChunkDeliveryMode::AtomicSameResource`] and an enlisted
//! transaction. [`ChunkExecutionReport`] returns per-phase
//! [`RetryCounts`] and [`SkipCounts`], rollback and no-rollback counts, and
//! redacted [`ItemListenerFailure`] values.
//!
//! [`Checkpoint`] and [`ExecutionContext`] retain bounded versioned JSON through
//! application-owned [`VersionedStateCodec`] implementations. Codec signatures
//! exchange JSON object bytes, keeping serializer types out of the public
//! contract. Their `Debug` output never includes payloads.
//!
//! A codec declares its current schema version and the [`StateSchemaUpgrade`]
//! edges it can apply. Decoding an older recorded version walks one bounded,
//! deterministic chain of those edges and only then calls
//! [`VersionedStateCodec::decode`], so a codec parses exactly one shape. A
//! recorded version newer than the codec, or one with no declared path to the
//! current version, fails closed rather than being truncated, defaulted, or
//! reinterpreted.
//!
//! [`ItemStream`] restores a namespaced [`ComponentStateEnvelope`] before
//! item work begins, prepares a candidate at the commit boundary, and closes
//! after the step attempt's terminal outcome is known -- the M6
//! open/update/close contract, in the same ADR-0008 shape as
//! [`ItemReader`]/[`ItemProcessor`]/[`ItemWriter`]. A
//! [`ComponentStateCodec`] adds a codec identity/version axis distinct from
//! the application schema identity/version axis; any existing
//! [`VersionedStateCodec`] plugs into [`DefaultComponentCodec`] unchanged.
//!
//! ```
//! use std::sync::atomic::{AtomicU64, Ordering};
//!
//! use oxide_batch::{
//!     CodecId, CodecVersion, ComponentStateEnvelope, ComponentStreamIdentity,
//!     DefaultComponentCodec, ItemStream, RestartabilityDeclaration, StateCodecError, StateLimits,
//!     StateSchemaId, StateSchemaVersion, StopSource, StreamCloseContext, StreamCloseError,
//!     StreamCloseOutcome, StreamOpenContext, StreamOpenError, StreamOpenOutcome,
//!     StreamRuntimeOutcome, StreamUpdateContext, StreamUpdateError, VersionedStateCodec,
//! };
//!
//! struct RowCountSchema {
//!     schema: StateSchemaId,
//!     version: StateSchemaVersion,
//! }
//!
//! impl VersionedStateCodec<u64> for RowCountSchema {
//!     fn schema_id(&self) -> &StateSchemaId {
//!         &self.schema
//!     }
//!     fn current_version(&self) -> StateSchemaVersion {
//!         self.version
//!     }
//!     fn encode(&self, value: &u64) -> Result<Vec<u8>, StateCodecError> {
//!         serde_json::to_vec(&serde_json::json!({ "rows": value }))
//!             .map_err(|_| StateCodecError::InvalidPayload)
//!     }
//!     fn decode(&self, payload: &[u8]) -> Result<u64, StateCodecError> {
//!         let value: serde_json::Value =
//!             serde_json::from_slice(payload).map_err(|_| StateCodecError::InvalidPayload)?;
//!         value
//!             .get("rows")
//!             .and_then(serde_json::Value::as_u64)
//!             .ok_or(StateCodecError::InvalidPayload)
//!     }
//! }
//!
//! fn codec() -> Result<DefaultComponentCodec<RowCountSchema>, Box<dyn std::error::Error>> {
//!     Ok(DefaultComponentCodec::new(
//!         RowCountSchema {
//!             schema: StateSchemaId::new("example.row-count")?,
//!             version: StateSchemaVersion::new(1)?,
//!         },
//!         CodecId::new("example.row-count-codec")?,
//!         CodecVersion::new(1)?,
//!         RestartabilityDeclaration::Restartable,
//!     ))
//! }
//!
//! struct RowCount(AtomicU64);
//!
//! impl ItemStream for RowCount {
//!     async fn open(
//!         &self,
//!         context: StreamOpenContext<'_>,
//!     ) -> Result<StreamOpenOutcome, StreamOpenError> {
//!         let Some(inherited) = context.inherited_state() else {
//!             return Ok(StreamOpenOutcome::Initial);
//!         };
//!         let codec = codec().map_err(|_| StreamOpenError::new())?;
//!         let restored: u64 = inherited.decode(&codec).map_err(|_| StreamOpenError::new())?;
//!         self.0.store(restored, Ordering::SeqCst);
//!         Ok(StreamOpenOutcome::Restored)
//!     }
//!
//!     async fn update(
//!         &self,
//!         _context: StreamUpdateContext<'_>,
//!     ) -> Result<ComponentStateEnvelope, StreamUpdateError> {
//!         let rows = self.0.fetch_add(1, Ordering::SeqCst) + 1;
//!         let codec = codec().map_err(|_| StreamUpdateError::new())?;
//!         let namespace = ComponentStreamIdentity::new("reader.row_count")
//!             .map_err(|_| StreamUpdateError::new())?;
//!         ComponentStateEnvelope::encode(namespace, &rows, &codec, StateLimits::default())
//!             .map_err(|_| StreamUpdateError::new())
//!     }
//!
//!     async fn close(
//!         &self,
//!         context: StreamCloseContext<'_>,
//!     ) -> Result<StreamCloseOutcome, StreamCloseError> {
//!         assert!(matches!(context.outcome(), StreamRuntimeOutcome::Committed));
//!         Ok(StreamCloseOutcome::Closed)
//!     }
//! }
//!
//! let stream = RowCount(AtomicU64::new(0));
//! let (_source, stop) = StopSource::new();
//!
//! let opened = futures_executor::block_on(stream.open(StreamOpenContext::new(None, &stop)))?;
//! assert_eq!(opened, StreamOpenOutcome::Initial);
//!
//! let candidate = futures_executor::block_on(stream.update(StreamUpdateContext::new(&stop)))?;
//! assert_eq!(candidate.decode(&codec()?)?, 1u64);
//!
//! let closed = futures_executor::block_on(stream.close(StreamCloseContext::new(
//!     &stop,
//!     StreamRuntimeOutcome::Committed,
//! )))?;
//! assert_eq!(closed, StreamCloseOutcome::Closed);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! [`ChunkPipelineBuilder`] (#152) assembles a [`ChunkStep`] and its matching
//! [`ChunkComponentRevisions`] from one builder, so a stateful component's
//! [`ComponentStreamIdentity`] is typed once instead of separately into both
//! [`ChunkStep::with_item_stream`] and
//! [`ChunkComponentRevisions::with_stream_revision`], and an installed
//! [`CompletionPolicy`]'s restart-relevant revision is derived automatically
//! rather than hand-folded. It lowers to exactly the same [`ChunkStep`],
//! [`ChunkJob`], and [`FlowJob`] types every other construction path uses --
//! typed and [`BoxedReader`]/[`BoxedProcessor`]/[`BoxedWriter`] pipelines
//! share the identical builder with no special-casing, since both are the
//! same ADR-0008 chunk driver with different type arguments. See
//! [`ChunkPipelineBuilder`]'s own documentation for the typed-vs-boxed
//! guidance and runnable examples.
//!
//! [`item_components`] is the standard composition catalog (#146): basic
//! iterator/list-backed readers, composite/delegating readers, processors,
//! and writers, classifier-selected delegates, a validator and a filter
//! processor, peek and aggregate reader decorators, and synchronization
//! wrappers. Every component is a plain [`ItemReader`]/[`ItemProcessor`]/
//! [`ItemWriter`] implementation under the same contract as any
//! hand-written one; composition never introduces a second execution path
//! or per-item boxing.
//!
//! ```
//! use oxide_batch::item_components::FilterProcessor;
//! use oxide_batch::{ItemProcessor, ProcessContext, ProcessOutcome, StopSource};
//!
//! let evens = FilterProcessor::new(|item: &u64| item % 2 == 0);
//! let (_source, stop) = StopSource::new();
//! let context = ProcessContext::new(&stop);
//! let kept = futures_executor::block_on(evens.process(&4, context))?;
//! let dropped = futures_executor::block_on(evens.process(&5, context))?;
//! assert_eq!(kept, ProcessOutcome::Item(4));
//! assert_eq!(dropped, ProcessOutcome::Filtered);
//! # Ok::<(), oxide_batch::ProcessorError>(())
//! ```
//!
//! [`DefinitionManifest`] reads canonical definition bytes back without
//! guessing. A newer format, a non-canonical encoding, a floating-point value,
//! an out-of-bound graph, or a digest that does not match the supplied bytes
//! fails closed.
//!
//! ```
//! use oxide_batch::{
//!     ComponentRevision, DefinitionIdentity, DefinitionManifest, DefinitionRevision, JobName,
//!     StepName,
//! };
//!
//! let identity = DefinitionIdentity::tasklet(
//!     &JobName::new("daily_import")?,
//!     &StepName::new("import")?,
//!     DefinitionRevision::new("2026-07-31")?,
//!     &ComponentRevision::new("tasklet-v1")?,
//! )?;
//! let manifest = DefinitionManifest::read_verified(
//!     identity.canonical_manifest(),
//!     identity.manifest_digest(),
//! )?;
//! assert_eq!(manifest.format(), 1);
//! assert_eq!(manifest.node_count(), None);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! A multi-step definition is declared as a [`FlowGraph`] of [`FlowNode`]
//! values joined by exit-pattern [`FlowTransition`] edges and compiled into an
//! immutable [`CompiledExecutionPlan`] that owns the canonical manifest and
//! fingerprint:
//!
//! ```
//! use oxide_batch::{
//!     ComponentRevision, DefinitionRevision, ExitPattern, FlowGraph, FlowNode, FlowTarget,
//!     FlowTransition, JobName, NodeId, StepComponents, StepNode, StepName, TerminalKind,
//! };
//!
//! let load = NodeId::new("load")?;
//! let report = NodeId::new("report")?;
//! let plan = FlowGraph::new(load.clone())
//!     .with_node(FlowNode::step(StepNode::new(
//!         load.clone(),
//!         StepName::new("load")?,
//!         StepComponents::Tasklet(ComponentRevision::new("load-v1")?),
//!     )))
//!     .with_node(FlowNode::step(StepNode::new(
//!         report.clone(),
//!         StepName::new("report")?,
//!         StepComponents::Tasklet(ComponentRevision::new("report-v1")?),
//!     )))
//!     .with_sequence(load, FlowTarget::Node(report.clone()))?
//!     .with_sequence(report, FlowTarget::Terminal(TerminalKind::Complete))?
//!     .compile(&JobName::new("daily_import")?, DefinitionRevision::new("v1")?)?;
//!
//! assert_eq!(plan.manifest_format(), 2);
//! assert_eq!(plan.node_count(), 2);
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! [`ExitPattern`] selects one of those transitions from the bounded
//! [`ExitCode`] a step reports, never from a [`BatchStatus`]:
//!
//! ```
//! use oxide_batch::{ExitCode, ExitPattern};
//!
//! let failed = ExitPattern::new("FAILED")?;
//! let any = ExitPattern::new("*")?;
//! assert!(failed.matches(&ExitCode::new("FAILED")?));
//! assert!(!failed.matches(&ExitCode::new("COMPLETED")?));
//! assert!(any.matches(&ExitCode::new("COMPLETED")?));
//! assert!(failed.specificity() > any.specificity());
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! [`FaultPolicy::decide`] is a pure function of the policy, a
//! framework-owned [`FaultDescriptor`], and [`FaultEvidence`]:
//!
//! ```
//! use std::time::Duration;
//!
//! use oxide_batch::{
//!     BackoffPolicy, ChunkDeliveryMode, ClassifierRevision, FailureCategory, FailureId,
//!     FailureSummary, FaultAction, FaultClassifier, FaultDecision, FaultDescriptor,
//!     FaultEvidence, FaultPhase, FaultPolicy, FaultRule, RetryLimit, RetryOrdinal,
//!     RetryStateLimit, SkipCounts, SkipLimit,
//! };
//!
//! let classifier = FaultClassifier::new(
//!     ClassifierRevision::new("import_v1")?,
//!     [FaultRule::new(
//!         FaultPhase::Write,
//!         FailureCategory::Timeout,
//!         FaultAction::retry(),
//!     )?],
//! )?;
//! let policy = FaultPolicy::new(
//!     classifier,
//!     RetryLimit::new(3)?,
//!     RetryStateLimit::new(64)?,
//!     SkipLimit::NONE,
//!     BackoffPolicy::exponential(Duration::from_millis(50), 2, Duration::from_secs(5))?,
//! )?;
//!
//! let fault = FaultDescriptor::new(
//!     FaultPhase::Write,
//!     FailureSummary::new(FailureCategory::Timeout, FailureId::new(1)?),
//!     RetryOrdinal::INITIAL,
//!     SkipCounts::ZERO,
//!     true,
//!     ChunkDeliveryMode::AtomicSameResource,
//! );
//! assert_eq!(
//!     policy.decide(&fault, FaultEvidence::NONE),
//!     FaultDecision::Retry {
//!         ordinal: RetryOrdinal::new(1)?,
//!         delay: Duration::from_millis(50),
//!     }
//! );
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
//!
//! Run the complete in-memory example from the workspace root:
//!
//! ```text
//! cargo run -p oxide-batch --example first_job
//! ```
//!
//! The application supplies the async executor; public tasklet and repository
//! contracts use [`BoxFuture`] rather than executor- or database-driver types.

#![forbid(unsafe_code)]

mod chunk;
mod chunk_builder;
mod chunk_runtime;
mod completion;
mod diagnostics;
mod fault;
mod fault_state;
mod flow;
pub mod item_components;
mod item_listener;
mod item_stream;
mod listener;
mod repository;
mod runtime;
mod service;
mod shutdown;
mod telemetry;

pub use chunk::{
    BoxedProcessor, BoxedReader, BoxedWriter, BusinessStatement, BusinessTransaction,
    BusinessTransactionError, BusinessValue, BusinessValueKind, BusinessWriteResult,
    ChunkCommitReceipt, ChunkCompletion, ChunkCompletionContext, ChunkCompletionError,
    ChunkCompletionOutcome, ChunkFaultProgress, ChunkTransaction, ChunkTransactionContext,
    ChunkTransactionError, ChunkTransactionManager, InheritedStepProgress, ItemProcessor,
    ItemReader, ItemWriter, ProcessContext, ProcessOutcome, ProcessorError, ReadContext,
    ReadOutcome, ReaderError, WriteContext, WriteOutcome, WriterError,
};
pub use chunk_builder::{ChunkPipelineBuilder, NoopChunkCompletion};
pub use chunk_runtime::{
    ChunkAttemptOutcome, ChunkExecutionOutcome, ChunkExecutionReport, ChunkFailure, ChunkJob,
    ChunkLaunchReport, ChunkListener, ChunkListenerContext, ChunkListenerError,
    ChunkListenerFailure, ChunkListenerFailureKind, ChunkListenerPhase, ChunkStep,
    completion_policy_revision,
};
pub use completion::{
    AdaptiveBounds, AdaptiveCompletionPolicy, ChunkTimeThreshold, CompletionPolicy,
    CompletionPolicyError, CompositeCompletionPolicy, CompositeMode, ItemCountCompletionPolicy,
    MAX_COMPOSITE_DEPTH, MAX_COMPOSITE_MEMBERS, TimeCompletionPolicy,
};
pub use diagnostics::{
    DiagnosticField, EventComponent, EventSeverity, ExecutionAttempt, ExecutionCorrelation,
    LifecycleEvent, LifecycleEventKind, LifecycleEventSink, MetricLabel,
};
pub use fault::{BackoffOutcome, BackoffSleeper};
pub use fault_state::{
    FaultProgress, FaultRuntime, FaultStateEntry, FaultStateEnvelope, FaultStateError,
    FaultStateFormatError, FaultStateStore, InMemoryFaultState, RetryCounts, RetryKey,
    RetryReservation,
};
pub use flow::{
    DeciderError, DecisionInput, DecisionStepInput, FlowEvent, FlowEventKind, FlowEventSink,
    FlowExecutionOutcome, FlowFailure, FlowJob, FlowJobError, FlowLaunchReport, FlowLauncher,
    FlowRuntimeError, JobExecutionDecider, PartitionFactoryError, PartitionPlanFactory,
    PartitionPlanRequest, PartitionTaskletFactory, PartitionWorkerInput, TaskletStepFactory,
};
pub use item_listener::{
    BeforeCallbackOutcome, ItemListenerContext, ItemListenerError, ItemListenerFailure,
    ItemListenerPhase, ItemListenerSet, ProcessListener, ReadListener, RetryListener, RetryOutcome,
    SkipListener, WriteListener,
};
pub use item_stream::{
    BoxedStream, ItemStream, StreamCloseContext, StreamCloseError, StreamCloseOutcome,
    StreamOpenContext, StreamOpenError, StreamOpenOutcome, StreamRuntimeOutcome,
    StreamUpdateContext, StreamUpdateError,
};
pub use listener::{
    JobExecutionListener, ListenerContext, ListenerError, ListenerFailure, ListenerFailureKind,
    ListenerPhase, StepExecutionListener,
};
pub use oxide_batch_core::{
    BackoffKind, BackoffPolicy, BatchStatus, Checkpoint, ChecksumAlgorithm,
    ChunkComponentRevisions, ChunkCount, ChunkCounts, ChunkDeliveryMode, ChunkError, ChunkProgress,
    ChunkRestartContract, ChunkSize, ClassifierRevision, CodecId, CodecVersion,
    CodecVersionUpgrade, ComponentRevision, ComponentStateCodec, ComponentStateEnvelope,
    ComponentStateError, ComponentStatePayload, ComponentStreamIdentity, ContentIdentity,
    DefaultComponentCodec, DefinitionError, DefinitionIdentity, DefinitionManifest,
    DefinitionRevision, DefinitionTokenKind, DefinitionUpgrade, DefinitionUpgradeKey, DomainError,
    DurableStateKind, ExecutionContext, ExecutionCounts, ExecutionMetadata, ExecutionTimestamps,
    ExecutionVersion, ExitCode, ExitStatus, ExternalStateError, ExternalStateReference,
    ExternalStateStore, FailureCategory, FailureId, FailureSummary, FaultAction, FaultClassifier,
    FaultDecision, FaultDescriptor, FaultEvidence, FaultPhase, FaultPolicy, FaultPolicyError,
    FaultRule, FlowTarget, IdentifierKind, InFlightPolicy, JobExecution, JobExecutionId,
    JobInstance, JobInstanceId, JobInstanceKey, JobName, JobParameter, JobParameters,
    LifecycleError, LifecycleTransition, MAX_NODES, MAX_PARTITIONS, MAX_TRANSITIONS, ManifestError,
    NameKind, NodeId, OperatorRequestId, ParameterName, ParameterRole, ParameterValue,
    ParameterValueKind, RecoveryDecisionId, RestartabilityDeclaration, RetentionActionId,
    RetryLimit, RetryOrdinal, RetryStateLimit, RollbackDisposition, SkipCounts, SkipLimit,
    StartControls, StartLimit, StateCodecError, StateError, StateLimits, StateSchemaId,
    StateSchemaUpgrade, StateSchemaVersion, StateSensitivity, StepDefinitionUpgrade, StepExecution,
    StepExecutionId, StepName, StepPartitionId, StreamStateContract, TerminalKind,
    VersionedStateCodec,
};
pub use oxide_batch_plan::{
    CompiledExecutionPlan, DeciderRevision, DecisionInputVersion, DecisionNode, ExitPattern,
    FlowGraph, FlowNode, FlowSelectionError, FlowTransition, JoinNode, LocalFailurePolicy,
    MAX_BRANCH_STEPS, MAX_OUTGOING_TRANSITIONS, MAX_PARTITION_WORKERS, MAX_PATTERN_BYTES,
    MAX_SPLIT_BRANCHES, PartitionBudget, PartitionCount, PartitionedStepNode, PatternSpecificity,
    PlanError, SplitBranch, SplitBudget, SplitNode, StepComponents, StepNode,
};
pub use oxide_batch_repository::{
    ActorRef, AuthorizationClass, BoxFuture, Clock, Cursor, CursorError, CursorKey,
    DEFAULT_MAX_CLOCK_SKEW, DEFAULT_PAGE_SIZE, DEFAULT_PURGE_AGE, DEFAULT_STALE_THRESHOLD,
    DefinitionDescriptor, ExecutionControl, ExplorerError, ExplorerQuery, ExplorerRepository,
    FlowDecision, FlowDecisionId, FlowDecisionRequest, FlowDecisionSequence, FlowStepState,
    FlowTransitionKind, IdGenerationError, IdGenerator, JobExecutionProjection,
    JobInstanceProjection, JobInstanceSelection, JobRepository, MAX_ACTOR_REF_BYTES,
    MAX_CLOCK_SKEW, MAX_CURSOR_BYTES, MAX_OPERATION_ID_BYTES, MAX_PAGE_SIZE,
    MAX_PARTITION_CONTEXT_BYTES, MAX_PARTITION_KEY_BYTES, MAX_PURGE_BATCH, MAX_REASON_CODE_BYTES,
    MAX_RESPONSE_BYTES, MAX_STALE_THRESHOLD, MIN_CLOCK_SKEW, MIN_PURGE_AGE, MIN_STALE_THRESHOLD,
    MIN_UNRESOLVED_AGE, MaxClockSkew, MonotonicClock, MonotonicInstant, OperationId,
    OperatorAction, OperatorOutcomeClass, OperatorRecord, OperatorRecordDraft, OperatorRejection,
    OperatorRequest, OwnerObservation, OwnerToken, Page, PageRequest, PageSize,
    ParameterDescriptor, PartitionAggregate, PartitionAggregationError, PartitionKey,
    PartitionPlanEntry, PartitionResult, PartitionValueError, PurgeBatchBound, PurgeCandidate,
    PurgeCounts, PurgePlan, PurgePlanRequest, PurgeSurvey, QueryWindow, ReasonCode,
    RecoveryDecision, RecoveryDirective, RecoveryDisposition, RecoveryError, RecoveryEvidence,
    RecoveryField, RecoveryMarkers, RecoveryProposal, RecoveryRepository, RecoveryRequest,
    RecoveryRequestError, RecoveryResult, RecoverySnapshot, RecoveryStepEvidence,
    RepositoryCapability, RepositoryDescriptor, RepositoryError, RepositoryUnitOfWork,
    RequestDigest, RequestField, RequestFieldError, RetentionAction, RetentionError, RetentionHold,
    RetentionOutcome, RetentionRecord, RetentionRecordDraft, SequentialIdGenerator, StaleThreshold,
    StateEnvelopeDescriptor, StepExecutionProjection, StepPartition, StepPartitionProjection,
    SystemClock, SystemMonotonicClock, TerminalStatusSet, aggregate_step_partitions,
};
#[cfg(feature = "postgres")]
pub use repository::{
    CaCertificate, PostgresChunkStateError, PostgresChunkStateProvider,
    PostgresChunkTransactionManager, PostgresConfig, PostgresConfigError, PostgresDurableStepState,
    PostgresExplorer, PostgresFaultState, PostgresJobRepository, PostgresMigrator, TlsMode,
};
pub use repository::{InMemoryExplorer, InMemoryJobRepository};
pub use runtime::{
    BlockingTasklet, BlockingTaskletAdapter, BlockingTaskletContext, JobLauncher, LaunchError,
    LaunchReport, StopPollInterval, StopSource, StopTiming, StopToken, Tasklet, TaskletContext,
    TaskletError, TaskletExecutionOutcome, TaskletFailure, TaskletJob, TaskletOutcome, TaskletStep,
};
pub use service::{
    JobExplorer, JobOperator, OperatorError, OperatorOutcome, RecoveryProposer, RetentionReport,
    RetentionService,
};
pub use shutdown::{
    DEFAULT_SHUTDOWN_DEADLINE, DEFAULT_TELEMETRY_FLUSH_DEADLINE, DrainResult,
    MAX_SHUTDOWN_DEADLINE, MAX_TELEMETRY_FLUSH_DEADLINE, MIN_SHUTDOWN_DEADLINE,
    MIN_TELEMETRY_FLUSH_DEADLINE, ShutdownCoordinator, ShutdownDeadline, ShutdownError,
    ShutdownHookError, ShutdownHookStatus, ShutdownReport, ShutdownRequest, ShutdownSignal,
    ShutdownTaskPhase, TaskJoinDeadline, TelemetryFlushDeadline, TelemetryFlushStatus,
    UnjoinedPhase,
};
pub use telemetry::{
    DEFAULT_DROP_REPORT_WINDOW, DEFAULT_EXPORT_QUEUE_RECORDS, DEFAULT_RETAINED_EVENT_CAPACITY,
    DEFAULT_RETAINED_EVENTS_PER_EXECUTION, DropReportWindow, EnqueueResult, EventTiming,
    ExportError, ExportFlushReport, ExportQueueBound, ExporterConfigurationError,
    IncidentBufferConfigurationError, IncidentEventBuffer, MAX_DROP_REPORT_WINDOW,
    MAX_EXPORT_QUEUE_RECORDS, MAX_METRIC_NAME_ALLOWLIST, MAX_RETAINED_EVENTS_PER_EXECUTION,
    METRIC_CARDINALITY_BUDGET, MIN_DROP_REPORT_WINDOW, MIN_EXPORT_QUEUE_RECORDS,
    MetricCardinalityGuard, MetricConfigurationError, MetricDimensions, MetricFamily,
    MetricObservation, MetricUnit, OTHER_LABEL_VALUE, TELEMETRY_EVENT_CATALOG,
    TELEMETRY_SCHEMA_VERSION, TELEMETRY_SPAN_CATALOG, TelemetryEventKind, TelemetryEventSink,
    TelemetryExportSink, TelemetryExporter, TelemetryQueue, TelemetryRecord, TelemetrySpanKind,
    TelemetrySpanStatus,
};

/// The version of the `OxideBatch` facade crate.
pub const VERSION: &str = env!("CARGO_PKG_VERSION");