ticket: refine worker runtime core plan

This commit is contained in:
Keisuke Hirata 2026-06-26 01:18:21 +09:00
parent befbabe13a
commit 5dceaf9a72
No known key found for this signature in database
8 changed files with 246 additions and 16 deletions

View File

@ -1,8 +1,8 @@
--- ---
title: 'worker-runtime core crateと組み込みRuntime APIを作る' title: 'worker-runtime core crateと組み込みRuntime APIを作る'
state: 'planning' state: 'ready'
created_at: '2026-06-25T12:17:05Z' created_at: '2026-06-25T12:17:05Z'
updated_at: '2026-06-25T14:48:23Z' updated_at: '2026-06-25T16:18:21Z'
assignee: null assignee: null
--- ---
@ -43,18 +43,69 @@ Yoi は旧 `Pod` 相当の実行単位を今後 `Worker` として扱い、`Runt
- Backend などの Rust process に `Runtime` を直接組み込める。 - Backend などの Rust process に `Runtime` を直接組み込める。
- v0 は memory store でよい。 - v0 は memory store でよい。
- API は少なくとも以下を表現する。 - Runtime API は transport API ではなく、`worker-runtime/lib.rs` が公開する Rust API として定義する。
- runtime summary / status。 - API surface は以下の責務に分ける。
- worker list / detail。
- create worker。 #### Runtime management API
- send input。
- stop / cancel worker。 Runtime 自体の管理・観測を扱う。Worker 1体の操作とは分ける。
- `runtime_summary` / `runtime_status`
- Runtime capabilities。
- Runtime diagnostics。
- Runtime-local store/allocation status。
- Runtime が保持している Worker 数や busy summary。
- v0 では Runtime config mutation は不要。config bundle sync も別 Ticket とする。
#### Worker catalog / lifecycle API
Runtime 内に存在する Worker の作成・一覧・停止を扱う。これは旧 `Pod` の process lifecycle をそのまま露出するのではなく、Runtime-scoped Worker lifecycle として定義する。
- `list_workers(query)`
- `get_worker(worker_id)`
- `create_worker(CreateWorkerRequest)`
- `stop_worker(worker_id)`
- `cancel_worker(worker_id)` or active run cancel。
- Unknown worker / duplicate worker / busy worker / unsupported capability を typed error にする。
`CreateWorkerRequest` は Web/Dashboard intent を直接受けない。Backend resolver 後、Runtime が解決可能な profile-oriented request とする。
- `display_name` / optional caller-provided worker id。
- `WorkerIntent`
- `ProfileSelector`
- optional `ConfigBundleRef`
- requested capabilities。
- optional workspace / mount references。
Profile/config bundle sync は別 Ticket とし、この Ticket では `config_bundle` は optional placeholder として型に含める程度でよい。`config_bundle` が無い場合、Runtime-local builtin/default Profile resources の範囲で toolsなし Worker を作れるようにする。
#### Worker interaction API
Worker へ入力を送り、run を開始する経路を扱う。これは既存 `worker` crate が持つ single Worker の入力処理を Runtime 経由で呼べるようにする層であり、Worker 内部 API を無制限に継承しない。
- `send_input(worker_id, WorkerInput)`
- v0 input は user message を最小単位とする。
- v0 は per-worker single-flight / busy reject でよい。
- acceptance result は accepted / rejected / busy / not found / failed を区別する。
- Runtime は `pod_name` / socket path / session path を input authority にしない。
#### Worker observation / projection API
Worker の状態と UI 用 projection を扱う。raw provider trace / raw full session log は Runtime public authority にしない。
- worker status / active run summary。
- bounded transcript projection。 - bounded transcript projection。
- event subscription または event cursor。 - event cursor or subscription abstraction
- usage / overview projection placeholder。 - usage / overview projection placeholder。
- v0 は tools なし Worker / mock or minimal engine を許容する。 - diagnostics / last error。
- v0 は single-flight / busy reject でよい。 - v0 は in-memory event log / transcript projection でよい。
- raw provider trace / raw full session log を Runtime public authority にしない。
#### Existing Worker APIとの関係
- `worker` crate は当面 single Worker host として残る。
- Runtime core は `worker` crate の全 public API を再公開しない。
- Runtime が公開するのは複数 Worker 管理に必要な catalog / lifecycle / interaction / projection API のみ。
- Worker 固有の socket protocol / attach details / session file details は Runtime API に漏らさない。
### Store / allocation core ### Store / allocation core
@ -80,13 +131,20 @@ Yoi は旧 `Pod` 相当の実行単位を今後 `Worker` として扱い、`Runt
- Existing `pod-store` / `pod-registry` crate の即時削除。 - Existing `pod-store` / `pod-registry` crate の即時削除。
- Existing Worker process/socket/session model の削除。 - Existing Worker process/socket/session model の削除。
- Full remote Runtime protocol。 - Full remote Runtime protocol。
- Profile/config bundle sync implementation。
- Plugin package / grant / prompt resource synchronization。
## 受け入れ条件 ## 受け入れ条件
- `crates/worker-runtime` が追加されている。 - `crates/worker-runtime` が追加されている。
- `worker-runtime` core は HTTP / WS / FS store dependency なしで library として使える。 - `worker-runtime` core は HTTP / WS / FS store dependency なしで library として使える。
- `Runtime` concrete struct と Runtime/Worker domain types が公開されている。 - `Runtime` concrete struct と Runtime/Worker domain types が公開されている。
- Memory-backed embedded Runtime が worker list/detail/create/send input/stop/transcript projection の最小 API を持つ。 - Runtime management API、Worker catalog/lifecycle API、Worker interaction API、Worker observation/projection API が型として分離されている。
- Memory-backed embedded Runtime が runtime summary/status、worker list/detail/create、send input、stop/cancel、bounded transcript projection、event cursor/subscription placeholder を持つ。
- Worker create request は Web/Dashboard intent ではなく、`WorkerIntent`、Profile selector、optional `ConfigBundleRef`、requested capabilities を表現できる。
- `ConfigBundleRef` が無い場合、Runtime-local builtin/default resources で toolsなし Worker を作れる。
- `worker` crate の socket / attach / session file details が Runtime public API に再公開されていない。
- Profile/config bundle sync は実装されていないが、後続 Ticket が接続できる型境界がある。
- `runtime_id + worker_id` が authority であり、`pod_name` / socket path / session path を authority にしない。 - `runtime_id + worker_id` が authority であり、`pod_name` / socket path / session path を authority にしない。
- Store / allocation abstraction が Runtime internal responsibility として定義されている。 - Store / allocation abstraction が Runtime internal responsibility として定義されている。
- `worker-store` / `worker-registry` standalone crate は作られていない。 - `worker-store` / `worker-registry` standalone crate は作られていない。

View File

@ -282,4 +282,55 @@ Current order:
The core ticket must not absorb FS persistence, REST server, event stream server, or Backend remote client integration. Those are separate implementation tickets. The core ticket must not absorb FS persistence, REST server, event stream server, or Backend remote client integration. Those are separate implementation tickets.
---
<!-- event: decision author: hare at: 2026-06-25T15:51:07Z -->
## Decision
Decision update: Profile/config bundle synchronization is a separate implementation ticket.
The worker-runtime core ticket should only define the create-worker boundary:
- create request accepts a Profile selector.
- create request has an optional ConfigBundleRef placeholder.
- if no bundle is supplied, Runtime may resolve against its local builtin/default resources for v0 testing.
Full bundle sync is tracked by 00001KVZQHPNY and should cover digest/versioned bundle storage, Runtime-side profile resolution, Backend sync orchestration, and host-local secret/mount/plugin policy enforcement.
---
<!-- event: decision author: hare at: 2026-06-25T16:14:53Z -->
## Decision
Decision update: the worker-runtime core API must not be described as a vague list of capabilities.
The API surface is split into:
- Runtime management API: runtime summary/status/capabilities/diagnostics/store-allocation status.
- Worker catalog/lifecycle API: list/detail/create/stop/cancel workers inside one Runtime.
- Worker interaction API: send user input and start a run, with single-flight/busy semantics.
- Worker observation/projection API: status, bounded transcript, event cursor/subscription placeholder, usage/overview diagnostics.
The Runtime API should wrap the single-worker host functionality exposed by the renamed `worker` crate, but must not re-export all Worker internals. Socket protocol, attach details, session file layout, and legacy process details stay out of the Runtime public API.
---
<!-- event: intake_summary author: hare at: 2026-06-25T16:18:21Z -->
## Intake summary
Marked ready by `yoi ticket state`.
---
<!-- event: state_changed author: "yoi ticket" at: 2026-06-25T16:18:21Z from: planning to: ready reason: cli_state field: state -->
## State changed
Marked ready by `yoi ticket state`.
--- ---

View File

@ -24,6 +24,14 @@
"note": "Backend event proxy/observation needs the Runtime event stream API.", "note": "Backend event proxy/observation needs the Runtime event stream API.",
"author": "yoi ticket", "author": "yoi ticket",
"at": "2026-06-25T14:47:43Z" "at": "2026-06-25T14:47:43Z"
},
{
"ticket_id": "00001KVZKSV6C",
"kind": "related",
"target": "00001KVZQHPNY",
"note": "Backend RuntimeRegistry integration will eventually coordinate config bundle sync for remote runtimes, but v0 can use builtin/default fallback.",
"author": "yoi ticket",
"at": "2026-06-25T15:51:07Z"
} }
] ]
} }

View File

@ -2,7 +2,7 @@
title: 'Backend RuntimeRegistryをworker-runtimeへ接続する' title: 'Backend RuntimeRegistryをworker-runtimeへ接続する'
state: 'planning' state: 'planning'
created_at: '2026-06-25T14:44:03Z' created_at: '2026-06-25T14:44:03Z'
updated_at: '2026-06-25T14:47:43Z' updated_at: '2026-06-25T15:51:07Z'
assignee: null assignee: null
--- ---

View File

@ -0,0 +1,13 @@
{
"version": 1,
"relations": [
{
"ticket_id": "00001KVZQHPNY",
"kind": "depends_on",
"target": "00001KVZBCQH4",
"note": "Config bundle sync builds on the worker-runtime core CreateWorkerRequest/Profile boundary.",
"author": "yoi ticket",
"at": "2026-06-25T15:51:07Z"
}
]
}

View File

@ -0,0 +1,93 @@
---
title: 'RuntimeへProfile/config bundleを同期する'
state: 'planning'
created_at: '2026-06-25T15:49:30Z'
updated_at: '2026-06-25T15:51:07Z'
assignee: null
---
## 背景
Runtime は Worker を動かす環境であり、Worker creation 時には Profile / prompt resources / tool policy / plugin declarations / host-local policy を使って最終的な WorkerSpec を作る必要がある。Backend が Profile を完全解決して巨大な WorkerSpec を毎回 Runtime に渡す設計にすると、remote Runtime / Plugin / secret / mount / host-specific policy と相性が悪い。
一方で、Runtime に `profile = "builtin:companion"` の selector だけを送っても、remote Runtime が同じ Profile / prompt / plugin resource を持っている保証はない。したがって、Backend は workspace/project で有効な Profile/config bundle を Runtime に同期し、Worker creation では profile selector + bundle digest + intent を送る形にしたい。
この Ticket は `worker-runtime` core の後続として、Runtime への Profile/config bundle sync と Runtime-side profile resolution を実装する。初期 `worker-runtime` core では `config_bundle = None` による builtin/default fallback で動作確認できるため、この同期機能は別実装粒度とする。
## 要件
### Config bundle model
- Runtime に同期可能な Profile/config bundle model を定義する。
- Bundle は digest / revision / workspace id / created_at / source metadata を持つ。
- Bundle は少なくとも以下を表現できる。
- Profile definitions。
- prompt resources。
- workflow definitions or references。
- tool declarations / tool policy。
- plugin descriptors / package refs / digests。
- non-secret model/provider config refs。
- language settings。
- workspace/project metadata。
- grants / policy declarations。
- Secret values、runtime-local mount actual path、local cache path、raw socket/session path は bundle に含めない。
- Secret は secret ref / grant / policy として表現し、値は Runtime host-local secret store が解決する。
### Runtime sync API
- Runtime は config bundle を受け取り、digest で保存・照合できる。
- Embedded Runtime では direct lib API で bundle sync できる。
- Networked Runtime では REST API で bundle sync できる shape を定義する。
- 例: `PUT /v1/config-bundles/{digest}`
- 例: `GET /v1/config-bundles/{digest}` or status endpoint。
- Runtime は create worker 時に指定された bundle digest を持っているか検証する。
- Bundle digest mismatch / missing bundle / invalid profile selector / unsupported declaration を typed error にする。
### Worker creation integration
- `CreateWorkerRequest` は profile selector + config bundle ref を受ける。
- Runtime は bundle 内の Profile を最終解決する。
- Runtime は host-local policy / capability / secret / mount / plugin grant enforcement を適用して `ResolvedWorkerSpec` を作る。
- Backend は Profile を完全解決した巨大 WorkerSpec を送らず、intent / profile selector / bundle ref / required capabilities を送る。
- Runtime-local builtin/default fallback は残してよいが、remote Runtime / plugin use では bundle が必要になる policy を設定できる。
### Backend responsibility
- Backend は workspace/project の有効 config bundle を作成・選択し、対象 Runtime に同期する。
- Backend はどの Runtime にどの bundle を同期してよいかを policy / workspace visibility で判断する。
- Backend は Browser に Runtime credential / direct endpoint / raw bundle storage path を渡さない。
- Backend RuntimeRegistry は Runtime の bundle availability / digest status を確認できる。
### Plugin / host policy boundary
- Plugin package bytes を bundle に含めるか package ref + digest にするかは実装時に決める。
- Runtime は plugin descriptor / digest / grants を検証してから tool/service/ingress surface を登録する。
- Runtime host が保護したい secret / mount / network egress / shell/git availability は host-local policy として最終判断する。
- Bundle sync は Plugin execution を直接許可するものではなく、Runtime-side grant enforcement が必要である。
## Non-goals
- `worker-runtime` core crate の作成。
- FS store feature の実装。
- REST command server の実装そのもの。ただし API shape は定義してよい。
- Full Plugin package manager / registry / signature policy。
- Secret value synchronization。
- Workspace mount actual path synchronization without host policy。
- Backend internal Companion Web Console completion。
## 受け入れ条件
- Config bundle domain type が定義され、digest / revision / provenance を持つ。
- Runtime は bundle を保存・一覧/確認・digest 検証できる。
- `CreateWorkerRequest` が profile selector + config bundle ref を扱える。
- Runtime は bundle 内 Profile を解決し、host-local policy を適用する境界を持つ。
- Missing bundle / digest mismatch / invalid profile / unsupported declaration が typed error になる。
- Bundle は secret values / raw socket path / raw session path / runtime-local mount actual path を含まない。
- Backend は Runtime へ bundle sync し、Runtime の bundle availability を確認できる。
- Remote Runtime 用 REST sync API shape または実 endpoint がある。
- Builtin/default fallback と synced bundle mode の責務が docs/tests で区別されている。
- `cargo test -p worker-runtime` が通る。
- `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-25T15:49:30Z -->
## 作成
LocalTicketBackend によって作成されました。
---