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;
17mod types;
18
19pub use capability::{
20    LeanWorkerBootstrapCheck, LeanWorkerBootstrapDiagnosticCode, LeanWorkerBootstrapReport,
21    LeanWorkerBootstrapSeverity, LeanWorkerCapability, LeanWorkerCapabilityBuilder, LeanWorkerChild,
22};
23pub use planning::{
24    LeanWorkerBatchFingerprint, LeanWorkerImportPlanConfig, LeanWorkerImportPlanError, LeanWorkerImportPlanner,
25    LeanWorkerModuleWork, LeanWorkerPlanMetadataExpectation, LeanWorkerPlannedBatch,
26};
27pub use pool::{
28    LeanWorkerPool, LeanWorkerPoolConfig, LeanWorkerPoolSnapshot, LeanWorkerRestartPolicyClass, LeanWorkerSessionKey,
29    LeanWorkerSessionLease,
30};
31pub use session::{
32    LeanWorkerCancellationToken, LeanWorkerDataRow, LeanWorkerDataSink, LeanWorkerDiagnosticEvent,
33    LeanWorkerDiagnosticSink, LeanWorkerJsonCommand, LeanWorkerProgressEvent, LeanWorkerProgressSink,
34    LeanWorkerRuntimeMetadata, LeanWorkerSession, LeanWorkerSessionConfig, LeanWorkerStreamSummary,
35    LeanWorkerStreamingCommand, LeanWorkerTypedDataRow, LeanWorkerTypedDataSink, LeanWorkerTypedStreamSummary,
36};
37pub use supervisor::{
38    LEAN_WORKER_REQUEST_TIMEOUT_DEFAULT, LEAN_WORKER_REQUEST_TIMEOUT_LONG_RUNNING, LeanWorker, LeanWorkerConfig,
39    LeanWorkerError, LeanWorkerExit, LeanWorkerRestartPolicy, LeanWorkerRestartReason, LeanWorkerStats,
40    LeanWorkerStatus,
41};
42pub use types::{
43    LeanWorkerCapabilityFact, LeanWorkerCapabilityMetadata, LeanWorkerCommandInfo, LeanWorkerCommandMetadata,
44    LeanWorkerDeclarationFilter, LeanWorkerDeclarationRow, LeanWorkerDiagnostic, LeanWorkerDoctorDiagnostic,
45    LeanWorkerDoctorReport, LeanWorkerDoctorSeverity, LeanWorkerElabFailure, LeanWorkerElabOptions,
46    LeanWorkerElabResult, LeanWorkerKernelResult, LeanWorkerKernelStatus, LeanWorkerKernelSummary,
47    LeanWorkerMetaResult, LeanWorkerMetaTransparency, LeanWorkerNameRef, LeanWorkerProcessFileOutcome,
48    LeanWorkerProcessModuleOutcome, LeanWorkerProcessedFile, LeanWorkerRendered, LeanWorkerRendering,
49    LeanWorkerSourceRange, LeanWorkerTacticInfo, LeanWorkerTermInfo,
50};
51
52/// Run the worker child process on stdin/stdout.
53///
54/// Production applications can expose a tiny app-owned child binary:
55///
56/// ```ignore
57/// fn main() -> std::process::ExitCode {
58///     lean_rs_worker::run_worker_child_stdio()
59/// }
60/// ```
61///
62/// Parent processes should still use [`LeanWorker`],
63/// [`LeanWorkerCapabilityBuilder`], or [`LeanWorkerPool`]. This function is
64/// only the child-side binary entry point.
65pub fn run_worker_child_stdio() -> std::process::ExitCode {
66    child::run_stdio()
67}
68
69#[doc(hidden)]
70pub fn __run_child_stdio() -> std::process::ExitCode {
71    run_worker_child_stdio()
72}
73
74#[doc(hidden)]
75pub mod __test_support;