ticket: record worker adapter implementation

This commit is contained in:
Keisuke Hirata 2026-06-28 05:51:18 +09:00
parent 1c4e7e5198
commit 2d275de3cc
No known key found for this signature in database
2 changed files with 72 additions and 1 deletions

View File

@ -2,7 +2,7 @@
title: 'embedded worker-runtimeをworker crate実行に接続する' title: 'embedded worker-runtimeをworker crate実行に接続する'
state: 'inprogress' state: 'inprogress'
created_at: '2026-06-27T18:26:46Z' created_at: '2026-06-27T18:26:46Z'
updated_at: '2026-06-27T20:12:31Z' updated_at: '2026-06-27T20:51:14Z'
assignee: null assignee: null
queued_by: 'workspace-panel' queued_by: 'workspace-panel'
queued_at: '2026-06-27T19:06:30Z' queued_at: '2026-06-27T19:06:30Z'

View File

@ -119,3 +119,74 @@ Implementation focus:
- leave downstream Workspace Companion real execution Ticket `00001KW55B33H` queued until this adapter is merged/validated - leave downstream Workspace Companion real execution Ticket `00001KW55B33H` queued until this adapter is merged/validated
--- ---
<!-- event: implementation_report author: yoi-coder-00001KW55B33B-worker-adapter at: 2026-06-27T20:51:14Z -->
## Implementation report
Implementation report:
実装完了。マージ / close / cleanup は未実施。
Commit:
- `18526ee36264610048f48b07b5db50ce86852fd2 feat: connect runtime worker execution adapter`
Adapter 配置方針:
- `worker` crate 側に `runtime-adapter` feature 付きで配置。
- 理由:
- `worker-runtime` は Runtime 境界 / 投影 / Backend trait を持つ下位境界として保ち、実 Worker 実装への依存を持たせない。
- `worker` crate は既存の `WorkerController` / `WorkerHandle` / `Method::Run` lifecycle を直接扱えるため、fake/canned 応答を挟まずに adapter を組める。
- `workspace-server``worker = { features = ["runtime-adapter"] }` を有効化して embedded Runtime に接続する形にし、crate dependency cycle を避けた。
変更概要:
### `worker` crate
- `crates/worker/src/runtime_adapter.rs` を追加。
- `WorkerRuntimeExecutionBackend` を追加し、`worker_runtime::execution::WorkerExecutionBackend` を実装。
- Runtime worker 作成時に `WorkerController` を spawn し、内部にのみ real `WorkerHandle` を保持。
- Runtime input は `Method::Run { input: vec![Segment::text(...)] }` へ変換して既存 Worker run lifecycle に投入。
- Worker の `protocol::Event` broadcast を購読し、`WorkerExecutionContext::publish_protocol_event` 経由で Runtime observation bus へ橋渡し。
- Provider/profile/config 不足などは spawn/create 時の typed error/rejection として返し、fake assistant text は生成しない。
- v0 double-run policy として queue は持たず、adapter 側 atomic busy flag + Worker status で二重 input を typed busy rejection。
- stop/cancel は既存 `Method::Shutdown` / `Method::Cancel` へ接続。
- Focused test を追加し、fake deterministic LLM client で Runtime input -> real Worker run lifecycle -> assistant output -> `protocol::Event` -> Runtime transcript projection の流れを検証。
### `worker-runtime`
- `observe_worker_event` で受けた real `protocol::Event` から transcript projection を更新。
- `TextDone` -> Assistant transcript
- `Error` -> System transcript
- `ToolResult` -> System transcript
- observation bus には既存 `protocol::Event` をそのまま保持し、subset output model は追加していない。
### `workspace-server`
- embedded Runtime 作成時に `WorkerRuntimeExecutionBackend` を接続。
- `EmbeddedWorkerRuntime::new_memory_with_execution_backend` を追加。
- Browser/API-facing projection に raw `worker::Worker` handle / raw execution handle / socket path / session path / credential / secret ref / manifest path は出していない。
### package/dependency
- `worker` に optional `worker-runtime` dependency + `runtime-adapter` feature を追加。
- `workspace-server``worker``runtime-adapter` feature を有効化。
- `Cargo.lock``package.nix``cargoHash` を更新。
Validation:
- `cargo fmt --all`: success
- `cargo fmt --all --check`: success
- `cargo test -p worker --features runtime-adapter runtime_adapter`: success
- `cargo test -p worker-runtime --features ws-server`: success
- `cargo test -p worker-runtime --features "ws-server fs-store"`: success
- `cargo test -p yoi-workspace-server`: success
- `cargo check -p yoi`: success
- `git diff --check`: success
- `nix build .#yoi --no-link`: success
Residual risks / review focus:
- Runtime worker profile 解決は production adapter が通常の Worker profile 解決を使う。workspace-server 起動直後に fake 応答へ fallback せず、profile/provider/config 不足は typed error になる。この挙動が downstream `00001KW55B33H` の Companion UX 設計と合っているか確認が必要。
- Transcript projection は現時点で `TextDone` / `Error` / `ToolResult` を投影。より細かい tool-call lifecycle や thinking block の Browser projection が必要なら downstream で拡張対象。
- Adapter は v0 non-queue policy。二重 input は busy rejection で、background queue/scheduler は実装していない。
- `workspace-server``worker` を feature 付きで依存するため、crate layering と public API leak が意図通りかを重点 review してほしい。
---