ticket: plan embedded worker execution

This commit is contained in:
Keisuke Hirata 2026-06-28 03:29:57 +09:00
parent 2fb7514daa
commit d86b1fb06d
No known key found for this signature in database
11 changed files with 290 additions and 0 deletions

View File

@ -0,0 +1,72 @@
---
title: 'worker-runtimeにWorker実行Backend境界を追加する'
state: 'planning'
created_at: '2026-06-27T18:26:46Z'
updated_at: '2026-06-27T18:40:00Z'
assignee: null
---
## 背景
現在の `worker-runtime::Runtime` は Runtime / Worker identity、metadata、transcript projection、observation stream を持つが、既存 `worker` crate の実 LLM 実行に接続されていない。その結果、Backend / Web Console から見ると Worker として存在するが input を処理できない Worker が発生し得る。
これは Runtime/Worker model として不十分である。Worker として公開されるものは transcript / observation を読める必要があり、input を受け付ける Worker は実行 backend に接続されている必要がある。`can_stream_events` / `can_read_bounded_transcript` のような「中身を読めない Worker を表示するための capability」は正規 model に置かない。
この Ticket では、`worker-runtime` に実行 backend を差し込むための型境界と lifecycle contract を追加する。ここでは既存 `worker` crate への具体接続は後続 Ticket に残し、Runtime が「実行可能 Worker」と「実行 backend 未接続の placeholder」を混同しないための土台を作る。
## 目的
- Runtime が Worker execution backend を明示的に持てる。
- input を受け付ける Worker は execution backend に接続されていることを型・状態・テストで保証する。
- Worker transcript / observation は Worker の正規 contract として扱い、capability 扱いしない。
- fake / providerless assistant response を Runtime が生成しない。
- 後続で `worker` crate 実行 adapter を接続できる境界を作る。
## 要件
### Execution backend boundary
- `worker-runtime` に Worker execution backend の trait / handle / enum を追加する。
- execution backend は少なくとも以下を扱える形にする。
- Worker spawn / initialize 時の execution handle 作成。
- user input の実行 backend への dispatch。
- run state / busy / rejected / errored の typed 結果。
- stop / cancel が未実装の場合の typed rejection。
- protocol event を Runtime observation bus へ publish するための hook。
- execution backend 未接続の Worker に対して user input を accepted にしない。
- Runtime 自身が providerless text / canned assistant message を生成しない。
### Worker model invariant
- Worker として公開されるものは transcript projection / observation stream を読める。
- `can_stream_events` / `can_read_bounded_transcript` を public Worker capability として復活させない。
- input acceptance は capability 表示でごまかさず、execution backend 接続状態と runtime state に基づく typed operation result とする。
- execution backend がない Worker を UI の通常 input-capable Worker として見せない。
### API / compatibility
- RuntimeRegistry / Backend API が raw execution backend handle、socket path、credential、session path を Browser に露出しない。
- 既存 remote Runtime WS / Backend proxy model と矛盾しない。
- placeholder / not-connected 状態が必要な場合は diagnostic / state として表現し、fake assistant response で埋めない。
## Non-goals
- 既存 `worker` crate の実行 loop への具体接続。
- Workspace Companion を実 LLM 実行で動かすこと。
- Web Console UX の再設計。
- Full permission / auth / redaction policy。
- remote Runtime process の lifecycle 実装。
## 受け入れ条件
- `worker-runtime` に execution backend 境界がある。
- execution backend 未接続 Worker への input が accepted にならない。
- Runtime が fake / providerless assistant response を生成しない。
- Worker transcript / observation が正規 contract として扱われ、public `can_stream_events` / `can_read_bounded_transcript` capability が存在しない。
- RuntimeRegistry / Backend projection に raw backend handle / path / credential が漏れない。
- Focused tests が、backend 未接続 input rejection、backend 接続 Worker の input dispatch 境界、observation publish hook を確認する。
- `cargo test -p worker-runtime --features ws-server` が通る。
- `cargo test -p yoi-workspace-server` が通る。
- `cargo check -p yoi` が通る。
- `git diff --check` が通る。
- `nix build .#yoi --no-link` が通る。

View File

@ -0,0 +1,7 @@
<!-- event: create author: "yoi ticket" at: 2026-06-27T18:26:46Z -->
## 作成
LocalTicketBackend によって作成されました。
---

View File

@ -0,0 +1,21 @@
{
"version": 1,
"relations": [
{
"ticket_id": "00001KW55B33B",
"kind": "depends_on",
"target": "00001KW55B32Y",
"note": "execution backend boundary must exist before worker crate adapter can connect",
"author": "yoi ticket",
"at": "2026-06-27T18:29:46Z"
},
{
"ticket_id": "00001KW55B33B",
"kind": "related",
"target": "00001KVZKSTJT",
"note": "Execution events must flow through Runtime/Backend observation proxy",
"author": "yoi ticket",
"at": "2026-06-27T18:29:46Z"
}
]
}

View File

@ -0,0 +1,73 @@
---
title: 'embedded worker-runtimeをworker crate実行に接続する'
state: 'planning'
created_at: '2026-06-27T18:26:46Z'
updated_at: '2026-06-27T18:29:46Z'
assignee: null
---
## 背景
`worker-runtime` の embedded Runtime は Backend RuntimeRegistry / Worker Console から見える Worker を作れるが、実際の LLM agent 実行は既存 `worker` crate 側にある。現在はこの execution-plane が接続されていないため、embedded Worker は transcript / observation の箱としては見えるが、user input を実行できない。
この Ticket では、前段の execution backend 境界に対して、既存 `worker` crate を使う embedded execution adapter を実装する。Runtime が Worker を spawn したときに実 `worker::Worker` / `WorkerController` 相当を生成し、input を既存 Worker の run lifecycle に渡し、`protocol::Event` を Runtime observation bus に bridge する。
## 目的
- embedded Runtime Worker が既存 `worker` crate の実行 engine を使って動く。
- user input が fake response ではなく、実 Worker run / LLM execution に渡る。
- 既存 `protocol::Event` が Runtime observation stream に流れる。
- Runtime / Backend / Web Console が Worker 実行の正規経路を共有する。
## 要件
### Adapter placement / dependency boundary
- `worker-runtime``worker` crate の依存関係を確認し、循環依存を作らない場所に adapter を置く。
- `worker-runtime` の optional feature、別 adapter crate、または Backend 側 adapter のいずれかを選んで Ticket thread に理由を記録する。
- Adapter は `worker-runtime` の execution backend 境界に接続する。
- Runtime public API / Browser-facing API に `worker::Worker` handle、socket path、session path、secret、raw manifest path を露出しない。
### Profile / config / authority resolution
- Runtime Worker spawn request の Profile selector / config bundle ref から、既存 Worker 実行に必要な config を解決する。
- prompt resources、model/provider config、SecretRef、ToolRegistry、HostAuthority、memory/session/history scope の扱いを明示する。
- Backend internal Companion 用であっても、暗黙の broad workspace authority を付けない。
- config / secret / provider が不足している場合は typed diagnostic として spawn/input を拒否し、fake response を返さない。
### Input / run lifecycle
- Backend Worker input API からの user input を、既存 Worker の `Method::Run` 相当または同等の run API に渡す。
- Worker が busy の場合、二重 run を typed rejection / queue policy で扱う。v0 で queue しないなら明示する。
- run started / completed / errored / cancelled を Runtime Worker status と transcript projection に反映する。
- stop / cancel が実装できる場合は既存 Worker control に接続し、できない場合は typed unsupported とする。
### Protocol event bridge
- 既存 Worker が出す `protocol::Event` を Runtime observation bus へ bridge する。
- Snapshot / transcript reconstruction / text delta / text done / thinking / tool call / tool result / usage / status / error を、既存 protocol semantics のまま流す。
- Runtime が event variant subset や別 output model を作らない。
- Worker history / session persistence と Runtime transcript projection が矛盾しないようにする。
## Non-goals
- Workspace Companion 専用 UX の完成。
- Web Console の visual redesign。
- remote Runtime process の execution adapter 実装。
- Full multi-user auth / permission / redaction policy。
- Task scheduling / background queue。
## 受け入れ条件
- embedded Runtime に `worker` crate 実行 adapter が接続されている。
- embedded Worker への user input が実 Worker run に渡る。
- provider / config が不足している場合、fake response ではなく typed diagnostic になる。
- 実行時の `protocol::Event` が Runtime observation bus と Backend client-facing WS に流れる。
- transcript projection が実 Worker run の user / assistant / tool / error output と整合する。
- raw execution handle / path / credential / session path が Browser-facing API に漏れない。
- Focused tests が fake provider または deterministic provider で user input -> assistant output -> protocol events -> transcript projection を確認する。
- `cargo test -p worker-runtime --features ws-server` が通る。
- `cargo test -p yoi-workspace-server` が通る。
- `cargo check -p yoi` が通る。
- `git diff --check` が通る。
- `nix build .#yoi --no-link` が通る。

View File

@ -0,0 +1,7 @@
<!-- event: create author: "yoi ticket" at: 2026-06-27T18:26:46Z -->
## 作成
LocalTicketBackend によって作成されました。
---

View File

@ -0,0 +1,29 @@
{
"version": 1,
"relations": [
{
"ticket_id": "00001KW55B33H",
"kind": "depends_on",
"target": "00001KW55B33B",
"note": "Companion can be executable only after embedded Runtime uses worker crate execution",
"author": "yoi ticket",
"at": "2026-06-27T18:29:46Z"
},
{
"ticket_id": "00001KW55B33H",
"kind": "related",
"target": "00001KVZ9JGK0",
"note": "Replaces the providerless Companion MVP with real Worker execution",
"author": "yoi ticket",
"at": "2026-06-27T18:29:46Z"
},
{
"ticket_id": "00001KW55B33H",
"kind": "related",
"target": "00001KW2GCPYF",
"note": "Worker Console attach UX depends on Companion being a normal executable Worker",
"author": "yoi ticket",
"at": "2026-06-27T18:29:46Z"
}
]
}

View File

@ -0,0 +1,74 @@
---
title: 'Workspace Companionを実LLM実行Workerとして起動する'
state: 'planning'
created_at: '2026-06-27T18:26:47Z'
updated_at: '2026-06-27T18:29:46Z'
assignee: null
---
## 背景
Workspace Backend は embedded Runtime 上に `workspace_companion` Worker を自動起動しているが、現時点では実 LLM 実行 backend に接続されていない。そのため Web Console から見ると Companion Worker は存在するが、input-capable Worker として動作しない。過去の providerless / fake response は正規動作ではないため削除済みであり、再導入しない。
この Ticket では、embedded Runtime が既存 `worker` crate 実行に接続された後、Workspace Companion を実際の LLM execution を持つ Worker として起動する。Workspace top の Worker list から Companion Worker を開き、Worker Console で Send すると実 provider / configured model 由来の応答が返る状態を完成させる。
## 目的
- `workspace_companion` Worker が実 LLM 実行に接続されている。
- Web Console から Send すると fake ではない assistant response が返る。
- Companion 専用 chat API / providerless response に依存しない。
- Companion は通常 Worker として Worker list から attach できる。
## 要件
### Companion bootstrap
- Workspace Backend 起動時に、Companion 用 Profile / config bundle を解決して executable Worker を spawn する。
- Companion Worker は `runtime_id + worker_id` で Console attach できる。
- role / profile は `workspace_companion` / appropriate companion Profile として表示される。
- provider / model / secret / prompt / authority が不足している場合は、input-capable Worker として表示せず、typed diagnostic を返す。
- fake / providerless assistant response を生成しない。
### Worker Console behavior
- Workspace top の Worker list から Companion Worker Console を開ける。
- Console composer は実行可能な Companion Worker でのみ有効になる。
- Send は Backend Worker input API を通り、embedded Runtime execution backend 経由で実 Worker run に届く。
- assistant response は provider / Worker execution 由来の `protocol::Event` と transcript に基づいて表示する。
- thinking / tool / status / error が届く場合は既存 Web Console protocol rendering に乗る。
### API cleanup
- Companion 専用 `/api/companion/messages` が残る場合も、正規経路は Worker input API とする。
- `/api/companion/messages` は fake response を返さない。残すなら Worker input API への thin wrapper とし、挙動差を作らない。
- Companion status / transcript は必要な bootstrap/status API として残してよいが、Console の authority は `runtime_id + worker_id` とする。
### Validation / evidence
- Test では real external provider secret を要求しない。deterministic fake provider / test Worker execution backend を使い、fake UI response ではなく Worker execution path を通ったことを確認する。
- Manual smoke では設定済み provider がある環境で Web Console Send -> assistant response -> observation WS event を確認できる。
## Non-goals
- Companion 専用 sidebar entry / standalone Console route の復活。
- providerless canned response の復活。
- Full multi-user auth / permission / redaction policy。
- Advanced Companion UXglobal composer、drawer、quick action
- remote Runtime 上の Companion 実行。
## 受け入れ条件
- Workspace Backend が executable `workspace_companion` Worker を起動できる。
- provider/config 不足時は fake response ではなく typed diagnostic になり、input-capable Worker として誤表示しない。
- Worker list から Companion Worker Console を開ける。
- Console Send が実 Worker/LLM execution path を通り、assistant response が provider/test provider 由来で表示される。
- `protocol::Event` が Runtime observation bus / Backend WS / Web Console に流れる。
- `/api/companion/messages` が fake response を返さない。残す場合は Worker input API と同一実行経路を使う。
- Focused tests が Companion bootstrap、input dispatch、assistant output、observation event、transcript projection を確認する。
- `cd web/workspace && deno task test` が通る。
- `cd web/workspace && deno task check` が通る。
- `cd web/workspace && deno task build` が通る。
- `cargo test -p yoi-workspace-server` が通る。
- `cargo check -p yoi` が通る。
- `git diff --check` が通る。
- `nix build .#yoi --no-link` が通る。

View File

@ -0,0 +1,7 @@
<!-- event: create author: "yoi ticket" at: 2026-06-27T18:26:46Z -->
## 作成
LocalTicketBackend によって作成されました。
---