cpm_planner/lib.rs
1// T26 — restriction-category lint on production code only.
2// `#[cfg(test)]` modules inside production sources DO see this when
3// invoked via `cargo build`, but `cargo test` evaluates `not(test)`
4// as false (test cfg is on) and silences the warning everywhere —
5// which is what we want: tests panic deliberately via unwrap, prod
6// code should `.expect("invariant: ...")` or propagate.
7#![cfg_attr(not(test), warn(clippy::unwrap_used))]
8
9//! cpm-planner: a textbook Critical Path Method (CPM) planner, exposed as a
10//! standalone MCP server.
11//!
12//! The CPM kernel does the forward pass (earliest start/finish), backward pass
13//! (latest start/finish), slack computation, critical-path identification,
14//! parallel batch grouping, and bottleneck (ROI) analysis.
15//!
16//! On top of that kernel, [`BasicCpmPlanner`] implements the lock-aware
17//! [`Planner`](ports::Planner) trait: callers submit a [`PlanGraph`](plan::PlanGraph),
18//! then acquire / heartbeat / release locks on disjoint cohorts of deliverables
19//! so that multiple workers can run in parallel without stepping on each other.
20//! [`PlanServer`] surfaces those operations as MCP tools (`plan.submit`,
21//! `plan.acquire_cohort`, …) over stdio, so any MCP-speaking client — Claude
22//! Code, Cursor, a custom orchestrator, or an mcp-flowgate workflow `connection`
23//! — can drive it.
24//!
25//! # Layout
26//!
27//! - [`plan`] — the wire/domain model (deliverables, cohorts, locks, errors).
28//! - [`ports`] — the [`Planner`](ports::Planner) trait.
29//! - [`algorithm`] / [`task`] — the pure CPM kernel and its internal model
30//! (the `Task` types carry ES/EF/LS/LF/slack/batching state the wire model
31//! doesn't need to expose).
32//! - [`planner`] — [`BasicCpmPlanner`], the lock-aware implementation.
33//! - [`server`] — the MCP tool façade.
34//! - [`audit`] — the lock-lifecycle audit surface.
35//!
36//! This crate has no dependency on mcp-flowgate; it is consumed purely over the
37//! MCP protocol.
38
39pub mod algorithm;
40pub mod audit;
41pub mod estimator;
42mod locks;
43pub mod plan;
44pub mod planner;
45pub mod ports;
46pub mod server;
47pub mod task;
48
49pub use algorithm::CpmAlgorithm;
50pub use estimator::{EffortEstimator, EstimationConfig};
51pub use planner::{BasicCpmPlanner, ClockFn, DEFAULT_EFFORT_HOURS, DEFAULT_TTL};
52pub use server::{
53 plan_tool_definitions, PlanServer, PLAN_TOOL_NAMES, TOOL_ACQUIRE_COHORT, TOOL_FORCE_RELEASE,
54 TOOL_HEARTBEAT, TOOL_MARK_STATUS, TOOL_STATUS, TOOL_SUBMIT,
55};
56pub use task::{Bottleneck, CriticalPathResult, Task, TaskBatch, TaskKind, TaskStatus};