refactor: rename pod crate to worker
This commit is contained in:
@@ -16,10 +16,10 @@ Owns:
|
||||
|
||||
Does not own:
|
||||
|
||||
- Pod names, sockets, process lifecycle, or scope delegation (`pod`)
|
||||
- Worker names, sockets, process lifecycle, or scope delegation (`worker`)
|
||||
- product CLI shape (`yoi`)
|
||||
- provider catalog and secret resolution (`provider`, `secrets`)
|
||||
- durable Pod current state (`pod-store`)
|
||||
- durable Worker current state (`pod-store`)
|
||||
|
||||
## Design notes
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ pub struct Engine<C: LlmClient, S: EngineState = Mutable> {
|
||||
/// stream events become visible.
|
||||
lifecycle_trace_cbs: Vec<Arc<dyn Fn(usize, usize, &str, &Value) + Send + Sync>>,
|
||||
/// Non-fatal warning callbacks. Invoked when the Engine wants to
|
||||
/// surface an advisory message to the upper layer (e.g. Pod) so it
|
||||
/// surface an advisory message to the upper layer (e.g. Worker) so it
|
||||
/// can be forwarded to the user — distinct from `tracing::warn!`,
|
||||
/// which is for developer-facing logs.
|
||||
warning_cbs: Vec<Box<dyn Fn(&str) + Send + Sync>>,
|
||||
@@ -253,7 +253,7 @@ pub struct Engine<C: LlmClient, S: EngineState = Mutable> {
|
||||
/// Plumbed into [`Request::cache_anchor`] at request build time.
|
||||
cache_anchor: Option<usize>,
|
||||
/// Conversation-scoped cache key, set by higher layers. Plumbed into
|
||||
/// [`Request::cache_key`] at request build time. Pod 側では
|
||||
/// [`Request::cache_key`] at request build time. Worker 側では
|
||||
/// `SegmentId` を渡す。
|
||||
cache_key: Option<String>,
|
||||
/// State marker
|
||||
@@ -487,7 +487,7 @@ impl<C: LlmClient, S: EngineState> Engine<C, S> {
|
||||
/// Fired after `post_tool_call` interceptors and any `content`
|
||||
/// truncation from `tool_output_limits`, so the callback observes
|
||||
/// exactly what is persisted to history. Intended for upper layers
|
||||
/// (e.g. Pod) to forward tool results to clients.
|
||||
/// (e.g. Worker) to forward tool results to clients.
|
||||
pub fn on_tool_result(&mut self, callback: impl Fn(&ToolResult) + Send + Sync + 'static) {
|
||||
self.tool_result_cbs.push(Box::new(callback));
|
||||
}
|
||||
@@ -1121,7 +1121,7 @@ impl<C: LlmClient, S: EngineState> Engine<C, S> {
|
||||
}
|
||||
|
||||
// Drain interceptor-side inputs that are meant to land in
|
||||
// history (notifications, cross-Pod events, system
|
||||
// history (notifications, cross-Worker events, system
|
||||
// reminders). These are committed *before* the per-request
|
||||
// clone so they participate in the LLM request below and
|
||||
// get persisted by the upper layer that owns history.json.
|
||||
@@ -1302,7 +1302,7 @@ impl<C: LlmClient, S: EngineState> Engine<C, S> {
|
||||
|
||||
// Collect and commit assistant items. Routed through
|
||||
// `append_history_items` so observers (e.g. the
|
||||
// Pod-side per-item session-log committer) see each item
|
||||
// Worker-side per-item session-log committer) see each item
|
||||
// as it lands.
|
||||
let reasoning_items = self.thinking_block_collector.take_collected();
|
||||
let text_blocks = self.text_block_collector.take_collected();
|
||||
@@ -1603,7 +1603,7 @@ impl<C: LlmClient, S: EngineState> Engine<C, S> {
|
||||
}
|
||||
Ok(ToolExecutionResult::Completed(results)) => {
|
||||
// Route per-result pushes through the callback path so
|
||||
// observers (e.g. the Pod-side per-item session-log
|
||||
// observers (e.g. the Worker-side per-item session-log
|
||||
// committer) see each tool result as it lands.
|
||||
let items = results.into_iter().map(|result| {
|
||||
Item::tool_result_item(
|
||||
@@ -1708,7 +1708,7 @@ impl<C: LlmClient> Engine<C, Mutable> {
|
||||
/// Install byte-size caps for tool execution `content`.
|
||||
///
|
||||
/// Passing `None` (the default) disables truncation. Higher layers
|
||||
/// (e.g. Pod) translate manifest configuration into a concrete
|
||||
/// (e.g. Worker) translate manifest configuration into a concrete
|
||||
/// [`ToolOutputLimits`] and install it here.
|
||||
pub fn set_tool_output_limits(&mut self, limits: Option<ToolOutputLimits>) {
|
||||
self.tool_output_limits = limits;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Interceptor - control flow delegation for the Engine execution loop
|
||||
//!
|
||||
//! Defines the [`Interceptor`] trait that upper layers (e.g. Pod) implement
|
||||
//! Defines the [`Interceptor`] trait that upper layers (e.g. Worker) implement
|
||||
//! to inject orchestration decisions (approval, skip, pause, abort)
|
||||
//! into the Engine's turn loop without the Engine knowing about
|
||||
//! higher-level concepts.
|
||||
@@ -132,7 +132,7 @@ pub struct ToolResultInfo {
|
||||
/// Intercepts the Engine execution loop at key decision points.
|
||||
///
|
||||
/// All methods have default implementations that let the Engine
|
||||
/// proceed without intervention. Upper layers (e.g. Pod) provide
|
||||
/// proceed without intervention. Upper layers (e.g. Worker) provide
|
||||
/// richer implementations for approval flows, permission checks, etc.
|
||||
#[async_trait]
|
||||
pub trait Interceptor: Send + Sync {
|
||||
@@ -149,7 +149,7 @@ pub trait Interceptor: Send + Sync {
|
||||
///
|
||||
/// Use this for inputs that arrive from outside the LLM and need
|
||||
/// to be reflected in the on-disk history — notifications,
|
||||
/// cross-Pod events, system reminders. Do **not** use
|
||||
/// cross-Worker events, system reminders. Do **not** use
|
||||
/// [`Self::pre_llm_request`] for that purpose: it mutates a
|
||||
/// per-request clone, so any committed assistant response that
|
||||
/// reacts to the injection would have no visible trigger on the
|
||||
|
||||
@@ -51,7 +51,7 @@ pub(crate) struct ResponsesRequest {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub top_p: Option<f32>,
|
||||
/// 会話単位の安定キー。ChatGPT backend (codex-oauth) は明示キーが
|
||||
/// 無いとプロンプトキャッシュがほぼ効かない。pod 側は `SegmentId`
|
||||
/// 無いとプロンプトキャッシュがほぼ効かない。worker 側は `SegmentId`
|
||||
/// を渡す。`Request::cache_key` が `None` のときはキー自体を送らない。
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub prompt_cache_key: Option<String>,
|
||||
|
||||
@@ -523,7 +523,7 @@ pub struct Request {
|
||||
/// 会話単位の安定キー。`prompt_cache_key` として送られる
|
||||
/// (OpenAI Responses)。ChatGPT backend (codex-oauth) は明示キーが
|
||||
/// 無いと org/project ハッシュ衝突でプロンプトキャッシュが
|
||||
/// ほぼヒットしないため、pod 側で `SegmentId` を渡す運用を想定。
|
||||
/// ほぼヒットしないため、worker 側で `SegmentId` を渡す運用を想定。
|
||||
/// `cache_anchor` と違い名前空間キーであり、`prefix anchor` とは
|
||||
/// 別の概念。`cache_anchor` を読まない provider と同じく、
|
||||
/// `prompt_cache_key` を持たない provider は無視する。
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
//!
|
||||
//! Prune は **コンテキスト射影** であり、history の変換ではない。
|
||||
//! この crate が提供するのは pure な候補抽出 [`prunable_indices`] のみで、
|
||||
//! 射影の適用は上位層(`pod::prune_hook` 等)が LLM に送る一時コンテキスト
|
||||
//! 射影の適用は上位層(`worker::prune_hook` 等)が LLM に送る一時コンテキスト
|
||||
//! に対してだけ行う。Engine の永続履歴は決して変更されない。
|
||||
//!
|
||||
//! 保護境界は末尾 token budget で決めるが、この crate は usage 履歴を
|
||||
@@ -75,7 +75,7 @@ pub enum PruneDecision {
|
||||
}
|
||||
|
||||
/// Optional observer invoked after each prune evaluation, regardless of
|
||||
/// branch. Pod 等の上位層が install して metrics を発行する。
|
||||
/// branch. Worker 等の上位層が install して metrics を発行する。
|
||||
pub type PruneObserver = Box<dyn Fn(&PruneEvaluation) + Send + Sync>;
|
||||
|
||||
/// Configuration for the Prune algorithm.
|
||||
|
||||
@@ -130,13 +130,13 @@ mod tests {
|
||||
let mut timeline = Timeline::new();
|
||||
timeline.on_tool_use_block(collector.clone());
|
||||
|
||||
timeline.dispatch(&Event::tool_use_start(0, "tool_empty", "ListPods"));
|
||||
timeline.dispatch(&Event::tool_use_start(0, "tool_empty", "ListWorkers"));
|
||||
timeline.dispatch(&Event::tool_use_stop(0));
|
||||
|
||||
let calls = collector.take_collected();
|
||||
assert_eq!(calls.len(), 1);
|
||||
assert_eq!(calls[0].id, "tool_empty");
|
||||
assert_eq!(calls[0].name, "ListPods");
|
||||
assert_eq!(calls[0].name, "ListWorkers");
|
||||
assert!(calls[0].input.is_object());
|
||||
assert_eq!(
|
||||
calls[0].input,
|
||||
|
||||
@@ -75,7 +75,7 @@ impl ToolServerHandle {
|
||||
/// Execute all pending factories and register the resulting tools.
|
||||
///
|
||||
/// Called implicitly by `Engine::lock()` before the first turn.
|
||||
/// Exposed as `pub` so higher layers (e.g. Pod) can force-materialise
|
||||
/// Exposed as `pub` so higher layers (e.g. Worker) can force-materialise
|
||||
/// tools earlier — for example when building a system-prompt template
|
||||
/// context that needs the list of registered tool names. Redundant
|
||||
/// calls are no-ops.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//!
|
||||
//! 1 リクエストの送信時点での「ある history prefix 長で計測した占有量」を
|
||||
//! 1 件分にまとめたもの。`UsageEvent` (provider stream イベント) を
|
||||
//! 受けて呼び出し側 (typically Pod) が組み立て、永続化層
|
||||
//! 受けて呼び出し側 (typically Worker) が組み立て、永続化層
|
||||
//! (session-store) に流したり、token accounting (`token_counter`) で
|
||||
//! 履歴として参照したりする。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user