Skip to main content

lean_rs_worker/
lib.rs

1//! Worker-process boundary for `lean-rs` host workloads.
2//!
3//! `LeanWorker` is the public process-boundary supervisor. It hides child
4//! spawning, pipe management, protocol framing, child exit parsing, and cleanup
5//! behind a small lifecycle API. The protocol module is private; callers should
6//! not learn frame bytes or restart bookkeeping. `LeanWorkerRestartPolicy`
7//! cycles the child process for memory reset; it does not change the
8//! in-process `lean-rs-host` memory contract.
9
10mod capability;
11mod child;
12mod planning;
13mod pool;
14mod protocol;
15mod session;
16mod supervisor;
17
18pub use capability::{
19    LeanWorkerBootstrapCheck, LeanWorkerBootstrapDiagnosticCode, LeanWorkerBootstrapReport,
20    LeanWorkerBootstrapSeverity, LeanWorkerCapability, LeanWorkerCapabilityBuilder, LeanWorkerChild,
21};
22pub use planning::{
23    LeanWorkerBatchFingerprint, LeanWorkerImportPlanConfig, LeanWorkerImportPlanError, LeanWorkerImportPlanner,
24    LeanWorkerModuleWork, LeanWorkerPlanMetadataExpectation, LeanWorkerPlannedBatch,
25};
26pub use pool::{
27    LeanWorkerPool, LeanWorkerPoolConfig, LeanWorkerPoolSnapshot, LeanWorkerRestartPolicyClass, LeanWorkerSessionKey,
28    LeanWorkerSessionLease,
29};
30pub use session::{
31    LeanWorkerCancellationToken, LeanWorkerCapabilityFact, LeanWorkerCapabilityMetadata, LeanWorkerCommandMetadata,
32    LeanWorkerDataRow, LeanWorkerDataSink, LeanWorkerDiagnostic, LeanWorkerDiagnosticEvent, LeanWorkerDiagnosticSink,
33    LeanWorkerDoctorDiagnostic, LeanWorkerDoctorReport, LeanWorkerDoctorSeverity, LeanWorkerElabOptions,
34    LeanWorkerElabResult, LeanWorkerJsonCommand, LeanWorkerKernelResult, LeanWorkerKernelStatus,
35    LeanWorkerProgressEvent, LeanWorkerProgressSink, LeanWorkerRuntimeMetadata, LeanWorkerSession,
36    LeanWorkerSessionConfig, LeanWorkerStreamSummary, LeanWorkerStreamingCommand, LeanWorkerTypedDataRow,
37    LeanWorkerTypedDataSink, LeanWorkerTypedStreamSummary,
38};
39pub use supervisor::{
40    LEAN_WORKER_REQUEST_TIMEOUT_DEFAULT, LEAN_WORKER_REQUEST_TIMEOUT_LONG_RUNNING, LeanWorker, LeanWorkerConfig,
41    LeanWorkerError, LeanWorkerExit, LeanWorkerRestartPolicy, LeanWorkerRestartReason, LeanWorkerStats,
42    LeanWorkerStatus,
43};
44
45/// Run the worker child process on stdin/stdout.
46///
47/// Production applications can expose a tiny app-owned child binary:
48///
49/// ```ignore
50/// fn main() -> std::process::ExitCode {
51///     lean_rs_worker::run_worker_child_stdio()
52/// }
53/// ```
54///
55/// Parent processes should still use [`LeanWorker`],
56/// [`LeanWorkerCapabilityBuilder`], or [`LeanWorkerPool`]. This function is
57/// only the child-side binary entry point.
58pub fn run_worker_child_stdio() -> std::process::ExitCode {
59    child::run_stdio()
60}
61
62#[doc(hidden)]
63pub fn __run_child_stdio() -> std::process::ExitCode {
64    run_worker_child_stdio()
65}
66
67#[doc(hidden)]
68pub mod __test_support;