refactor: rename llm worker crate to engine
This commit is contained in:
@@ -9,7 +9,7 @@ async-trait = { workspace = true }
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
libc = { workspace = true }
|
||||
lint-common = { workspace = true }
|
||||
llm-worker = { workspace = true }
|
||||
llm-engine = { workspace = true }
|
||||
manifest = { workspace = true }
|
||||
schemars = { workspace = true }
|
||||
serde = { workspace = true, features = ["derive"] }
|
||||
|
||||
@@ -17,7 +17,7 @@ Owns:
|
||||
Does not own:
|
||||
|
||||
- authoritative project records (`.yoi/tickets/`, git history)
|
||||
- normal Pod turn orchestration (`llm-worker`)
|
||||
- normal Pod turn orchestration (`llm-engine`)
|
||||
- product CLI command shape (`yoi`)
|
||||
- curated workflow definitions (`workflow`)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! consolidation sub-Worker への最初のユーザー入力を組み立てる。
|
||||
//! consolidation sub-Engine への最初のユーザー入力を組み立てる。
|
||||
//!
|
||||
//! extract (`extract::build_extract_input`) と同じ方針で、固定 schema の
|
||||
//! markdown セクション列にしてサブWorker に渡す。`docs/plan/memory.md`
|
||||
//! markdown セクション列にしてサブEngine に渡す。`docs/plan/memory.md`
|
||||
//! §Consolidation 入力 / §整理材料 の項目に従い:
|
||||
//!
|
||||
//! 1. consumed staging エントリ全文(`source` 込み)
|
||||
@@ -19,7 +19,7 @@ use crate::consolidate::tidy::TidyHints;
|
||||
use crate::usage::UsageReport;
|
||||
use crate::workspace::{RecordKind, WorkspaceLayout};
|
||||
|
||||
/// consolidation sub-Worker の最初の user 入力。
|
||||
/// consolidation sub-Engine の最初の user 入力。
|
||||
pub fn build_consolidate_input(
|
||||
layout: &WorkspaceLayout,
|
||||
staging: &[StagingEntry],
|
||||
|
||||
@@ -147,7 +147,7 @@ impl StagingLock {
|
||||
}
|
||||
|
||||
/// 占有ファイルだけ削除し、staging エントリには触らない。consolidation
|
||||
/// sub-Worker が途中で失敗した場合に使う: 入力 staging を残したまま
|
||||
/// sub-Engine が途中で失敗した場合に使う: 入力 staging を残したまま
|
||||
/// 次回再評価で再処理させる(`docs/plan/memory.md` §並走防止 の
|
||||
/// 「重複作成は同一 slug update に自然収束」運用)。
|
||||
pub fn release_only(self) {
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
//!
|
||||
//! extract が staging に残した活動ログを `memory/*` / `knowledge/*` に
|
||||
//! 統合し、続けて既存 record を `outdated | superseded | unused | noisy`
|
||||
//! の観点で整理する disposable Worker を、Pod 側が組み立てるための
|
||||
//! ヘルパー群を提供する。Pod は次の手順で sub-Worker を構築する:
|
||||
//! の観点で整理する disposable Engine を、Pod 側が組み立てるための
|
||||
//! ヘルパー群を提供する。Pod は次の手順で sub-Engine を構築する:
|
||||
//!
|
||||
//! - [`build_consolidate_input`] を sub-Worker の最初の user 入力に
|
||||
//! - [`build_consolidate_input`] を sub-Engine の最初の user 入力に
|
||||
//! - memory 専用 Tool (read / write / edit) と Knowledge / memory 検索ツールを登録
|
||||
//! - [`StagingLock::acquire`] で並走防止 + consumed ID 確定
|
||||
//! - sub-Worker run 完了後、[`StagingLock::release_with_cleanup`] で
|
||||
//! - sub-Engine run 完了後、[`StagingLock::release_with_cleanup`] で
|
||||
//! consumed ID 分の staging のみ削除し、占有ファイルを解放
|
||||
//!
|
||||
//! system prompt は Pod の `PromptCatalog`
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
//! extract sub-Worker への入力テキスト組み立て。
|
||||
//! extract sub-Engine への入力テキスト組み立て。
|
||||
//!
|
||||
//! `crates/pod/src/pod.rs::build_summary_prompt` と同じ方針で
|
||||
//! Item 列を flat な行に落とす(reasoning は省く、tool call は名前のみ、
|
||||
//! tool result は summary のみ)。conversation 全体を Markdown の単一
|
||||
//! セクションとして渡し、抽出指示は system prompt 側に寄せる。
|
||||
|
||||
use llm_worker::Item;
|
||||
use llm_engine::Item;
|
||||
|
||||
/// 与えられた `items` を extract sub-Worker の最初の user 入力に整形する。
|
||||
/// 与えられた `items` を extract sub-Engine の最初の user 入力に整形する。
|
||||
pub fn build_extract_input(items: &[Item]) -> String {
|
||||
let mut out = String::new();
|
||||
out.push_str(
|
||||
@@ -26,9 +26,9 @@ fn render_items(items: &[Item]) -> String {
|
||||
match item {
|
||||
Item::Message { role, content, .. } => {
|
||||
let role_label = match role {
|
||||
llm_worker::Role::User => "User",
|
||||
llm_worker::Role::Assistant => "Assistant",
|
||||
llm_worker::Role::System => "System",
|
||||
llm_engine::Role::User => "User",
|
||||
llm_engine::Role::Assistant => "Assistant",
|
||||
llm_engine::Role::System => "System",
|
||||
};
|
||||
let text: String = content
|
||||
.iter()
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
//! extract: 活動抽出。
|
||||
//!
|
||||
//! 通常 Pod の post-run hook で発火する disposable Worker と、その
|
||||
//! 通常 Pod の post-run hook で発火する disposable Engine と、その
|
||||
//! 出力を `<workspace>/.yoi/memory/_staging/<id>.json` に書き出す
|
||||
//! ヘルパーを提供する。Pod 側はこのモジュールから:
|
||||
//!
|
||||
//! - [`build_extract_input`] を sub-Worker の最初の user 入力に
|
||||
//! - [`build_extract_input`] を sub-Engine の最初の user 入力に
|
||||
//! - [`write_extracted_tool`] を唯一のツールとして
|
||||
//! - [`write_staging`] で受け取った JSON を staging に書き出し
|
||||
//!
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! `write_extracted` ツール実装と sub-Worker 用 context。
|
||||
//! `write_extracted` ツール実装と sub-Engine 用 context。
|
||||
//!
|
||||
//! sub-Worker からは extract worker が出した [`ExtractedPayload`] を
|
||||
//! sub-Engine からは extract worker が出した [`ExtractedPayload`] を
|
||||
//! 受け取って `Mutex` 越しに [`ExtractWorkerContext`] に置くだけ。
|
||||
//! Pod 側はランループ完了後に `take_payload()` で取り出して
|
||||
//! [`super::staging::write_staging`] に渡す。
|
||||
@@ -8,7 +8,7 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
|
||||
use crate::extract::payload::ExtractedPayload;
|
||||
|
||||
@@ -17,7 +17,7 @@ Pass an object with `decisions`, `discussions`, `attempts`, and `requests` array
|
||||
Call this exactly once and end the turn. Do not include `source`, session metadata, or free-form prose — \
|
||||
the wrapper attaches provenance mechanically.";
|
||||
|
||||
/// extract sub-Worker の出力受け口。`ExtractedPayload` 1 件をホストする。
|
||||
/// extract sub-Engine の出力受け口。`ExtractedPayload` 1 件をホストする。
|
||||
#[derive(Debug, Default)]
|
||||
pub struct ExtractWorkerContext {
|
||||
payload: Mutex<Option<ExtractedPayload>>,
|
||||
@@ -31,7 +31,7 @@ impl ExtractWorkerContext {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
/// sub-Worker 終了後に Pod が呼んで payload を取り出す。
|
||||
/// sub-Engine 終了後に Pod が呼んで payload を取り出す。
|
||||
/// 一度も `write_extracted` が呼ばれなければ `None`。
|
||||
pub fn take_payload(&self) -> Option<ExtractedPayload> {
|
||||
self.payload
|
||||
@@ -57,7 +57,7 @@ impl Tool for WriteExtractedTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let payload: ExtractedPayload = serde_json::from_str(input_json).map_err(|e| {
|
||||
ToolError::InvalidArgument(format!("invalid write_extracted input: {e}"))
|
||||
@@ -92,7 +92,7 @@ impl Tool for WriteExtractedTool {
|
||||
}
|
||||
}
|
||||
|
||||
/// sub-Worker に register する `write_extracted` ツール定義を返す。
|
||||
/// sub-Engine に register する `write_extracted` ツール定義を返す。
|
||||
pub fn write_extracted_tool(ctx: Arc<ExtractWorkerContext>) -> ToolDefinition {
|
||||
Arc::new(move || {
|
||||
let schema = schemars::schema_for!(ExtractedPayload);
|
||||
@@ -109,7 +109,7 @@ pub fn write_extracted_tool(ctx: Arc<ExtractWorkerContext>) -> ToolDefinition {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
use llm_worker::tool::Tool;
|
||||
use llm_engine::tool::Tool;
|
||||
|
||||
#[tokio::test]
|
||||
async fn write_extracted_records_payload() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::audit::{AuditStatus, RecordOperationAudit, append_record_operation, file_hash};
|
||||
@@ -32,7 +32,7 @@ impl Tool for MemoryDeleteTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: DeleteParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryDelete input: {e}")))?;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::audit::{
|
||||
@@ -50,7 +50,7 @@ impl Tool for EditTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: EditParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryEdit input: {e}")))?;
|
||||
|
||||
@@ -15,7 +15,7 @@ pub use delete::delete_tool;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use llm_worker::tool::ToolError;
|
||||
use llm_engine::tool::ToolError;
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::Slug;
|
||||
@@ -27,7 +27,7 @@ pub use read::{read_tool, read_tool_with_usage};
|
||||
pub use write::write_tool;
|
||||
|
||||
/// Kinds the memory tools accept as input. `Workflow` is intentionally
|
||||
/// excluded — workflows are sub-Worker context, not agent-editable.
|
||||
/// excluded — workflows are sub-Engine context, not agent-editable.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, schemars::JsonSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum MemoryToolKind {
|
||||
|
||||
@@ -21,7 +21,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::audit::{AuditStatus, RecordUsageAudit, append_record_usage};
|
||||
@@ -129,7 +129,7 @@ impl Tool for MemoryQueryTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: MemoryQueryParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryQuery input: {e}")))?;
|
||||
@@ -247,7 +247,7 @@ impl Tool for KnowledgeQueryTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: KnowledgeQueryParams = serde_json::from_str(input_json).map_err(|e| {
|
||||
ToolError::InvalidArgument(format!("invalid KnowledgeQuery input: {e}"))
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::audit::{AuditStatus, RecordUsageAudit, append_record_usage};
|
||||
@@ -48,7 +48,7 @@ impl Tool for ReadTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: ReadParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryRead input: {e}")))?;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use llm_worker::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use llm_engine::tool::{Tool, ToolDefinition, ToolError, ToolMeta, ToolOutput};
|
||||
use serde::Deserialize;
|
||||
|
||||
use crate::audit::{
|
||||
@@ -45,7 +45,7 @@ impl Tool for WriteTool {
|
||||
async fn execute(
|
||||
&self,
|
||||
input_json: &str,
|
||||
_ctx: llm_worker::tool::ToolExecutionContext,
|
||||
_ctx: llm_engine::tool::ToolExecutionContext,
|
||||
) -> Result<ToolOutput, ToolError> {
|
||||
let params: WriteParams = serde_json::from_str(input_json)
|
||||
.map_err(|e| ToolError::InvalidArgument(format!("invalid MemoryWrite input: {e}")))?;
|
||||
|
||||
Reference in New Issue
Block a user