Skip to main content

trusty_code/task/
mod.rs

1//! Daemon-owned task execution: `task.run` + background agent-loop
2//! orchestration (#2056, M1 control-plane cut line).
3//!
4//! Why: this module is where a `task.run` (or a future `session.send`
5//! auto-trigger) call actually turns into a running PM -> engineer agent
6//! loop, streaming live `tool_started`/`tool_finished`/`tool_error` and
7//! session-lifecycle events (#2055) to any `session.attach`ed client (#2054),
8//! without blocking the triggering RPC. It is glue, not a fork: the engine
9//! itself (`crate::agent_loop`, `crate::runner`, `crate::tools`, `crate::llm`)
10//! is reused verbatim, extended (in #2056) with an optional tool-event sink
11//! and cancellation flag rather than duplicated.
12//! What: [`protocol::register`] wires the `task.run` JSON-RPC method;
13//! [`executor::spawn_task_run`] is the orchestration entry point it calls;
14//! [`sink::SessionToolEventSink`] is the concrete `agent_loop::ToolEventSink`
15//! forwarding to `session::SessionRegistry::record_tool_*`; [`mock_llm`]
16//! provides the offline-testable "echo" `InferenceAdapter` selected via
17//! `TCODE_MOCK_LLM=echo` so the whole flow is black-box testable without a
18//! live model.
19//! Test: `task::executor::tests::*`, `task::protocol::tests::*`,
20//! `task::sink::tests::*`, `task::mock_llm::tests::*`; the full flow
21//! end-to-end (a real subprocess) in `tests/task_e2e.rs`.
22//!
23//! [`protocol::register`]: crate::task::protocol::register
24//! [`executor::spawn_task_run`]: crate::task::executor::spawn_task_run
25//! [`sink::SessionToolEventSink`]: crate::task::sink::SessionToolEventSink
26//! [`mock_llm`]: crate::task::mock_llm
27
28pub mod executor;
29pub mod mock_llm;
30pub mod protocol;
31/// (#4351) Folds a finished run's terminal status and on-disk footprint into
32/// the `session::TaskResult` a caller reads back. Private to this module —
33/// `executor` is its only caller.
34mod result_capture;
35pub mod sink;
36/// (#8235) The `todo_write` tool's concrete `TodoStore` — writes a validated
37/// checklist onto one session's roster row.
38pub mod todo_store;
39
40pub use executor::{TaskRunParams, spawn_task_run};
41pub use sink::SessionToolEventSink;
42pub use todo_store::SessionTodoStore;