ticket: scope config bundle sync implementation

This commit is contained in:
Keisuke Hirata 2026-07-08 06:05:47 +09:00
parent ebc3804ebd
commit fb25f1a33d
No known key found for this signature in database

View File

@ -1,8 +1,8 @@
--- ---
title: 'Design Backend-to-Runtime ConfigBundle synchronization strategy' title: 'Implement Backend-resolved ConfigBundle sync for Runtime worker creation'
state: 'planning' state: 'planning'
created_at: '2026-07-07T20:51:35Z' created_at: '2026-07-07T20:51:35Z'
updated_at: '2026-07-07T20:51:35Z' updated_at: '2026-07-07T21:08:00Z'
assignee: null assignee: null
--- ---
@ -10,112 +10,115 @@ assignee: null
Backend -> Runtime の ConfigBundle 境界は既に型と sync/check/store の外枠を持っているが、現状の bundle は profile selector 宣言が中心であり、Worker 作成時の実際の Profile discovery / manifest resolution は Runtime 側の `ProfileRuntimeWorkerFactory` が host filesystem から再実行している。 Backend -> Runtime の ConfigBundle 境界は既に型と sync/check/store の外枠を持っているが、現状の bundle は profile selector 宣言が中心であり、Worker 作成時の実際の Profile discovery / manifest resolution は Runtime 側の `ProfileRuntimeWorkerFactory` が host filesystem から再実行している。
これは長期設計と合わない。Workspace は Browser/product の論理単位であり、Runtime は Workspace filesystem を profile discovery source として読むべきではない。Backend が Workspace / project の有効 Profile と policy を解決し、Runtime には検証済み ConfigBundle として同期する。Runtime は同期済み bundle と WorkingDirectory / execution backend の入力だけで Worker を作れる必要がある。 これは正規経路ではない。Workspace は Browser/product の論理単位であり、Runtime は Workspace filesystem を profile/config discovery source として読まない。Backend が Workspace / project / builtin Profile を解決し、Runtime へ同期した ConfigBundle だけを Worker creation の config authority にする。
既存の closed Ticket `00001KVZQHPNY` は ConfigBundle sync の初期設計、`00001KW7726H9` は Runtime Worker creation の正規経路を扱った。本 Ticket はその follow-up として、selector-only bundle から resolved launch config bundle へ進める同期戦略を確定し、実装可能な slice に分ける。 既存の closed Ticket `00001KVZQHPNY` は ConfigBundle sync の初期設計、`00001KW7726H9` は Runtime Worker creation の正規経路を扱った。本 Ticket はその follow-up として、selector-only bundle を廃止し、Backend-resolved ConfigBundle で Worker を作る実装 slice にする。
## 目的 ## 実装目的
- Backend が Profile discovery / resolution の authority を持つことを明確にする - Backend が Profile discovery / resolution を行い、Runtime は通常 Worker creation 経路で Profile filesystem discovery を行わない
- Runtime が Worker creation 時に Workspace filesystem / profile base を読まない設計にする - ConfigBundle は profile selector allowlist ではなく、Worker 作成に必要な resolved launch config を持つ
- ConfigBundle に何を含め、何を含めないかを確定する。 - Backend は Worker launch 前に対象 Runtime の ConfigBundle availability を ensure/sync/check する。
- Backend が Runtime ごとに bundle availability を ensure/sync/check する戦略を定義する。 - Runtime は同期済み ConfigBundleRef、WorkingDirectory、initial input から Worker を作る。
- Worker creation は synced ConfigBundle identity と WorkingDirectory / execution backend の入力で成立するようにする - Browser-facing API には ConfigBundleRef、bundle digest、Runtime config store、raw path、Runtime endpoint を出さない
## 設計方針 ## 実装内容
### 1. ConfigBundle は selector allowlist ではなく resolved launch config を運ぶ ### 1. ConfigBundle payload を resolved launch config に拡張する
現状の `ConfigProfileDescriptor { selector, label }` だけでは Runtime が Worker manifest を作れない。ConfigBundle には少なくとも Backend-resolved Profile artifact または WorkerManifestConfig 相当の launch recipe を含める `ConfigBundle` に Backend-resolved profile payload を追加する。新しい payload は selector 宣言だけではなく、Runtime が Worker manifest/config を構築するための typed data を持つ
候補: 実装する payload:
- `ResolvedProfileBundle` / `ResolvedWorkerLaunchConfig` のような新型を bundle に入れる。 - profile selector。
- 既存 `WorkerManifestConfig` を直接入れる場合は、runtime-bound / authority-bearing field が混入しない validation を強化する。 - display label / role metadata。
- prompt/resource/workflow は inline bytes、embedded resource ref + digest、または explicit resource table のどれにするかを決める。 - `WorkerManifestConfig` 相当の resolved launch config。
- prompt / resource / workflow 参照を解決するための resource table。
- non-secret provider/model config refs。
- tool / hook / plugin declaration と policy declaration。
- language / memory / ticket / runtime policy のうち Worker manifest 作成に必要な non-secret config。
### 2. Runtime は bundle を検証・保存・参照するが discovery はしない payload に含めないもの:
Runtime の責務: - secret values。
- host absolute path。
- Runtime endpoint / token / socket path / session path。
- runtime-local mount actual path。
- Browser request 由来の raw cwd / raw filesystem scope。
- ConfigBundle digest / revision / provenance / workspace_id を検証する。 ConfigBundle digest は metadata だけではなく、この resolved payload を含む canonical content identity にする。
- `CreateWorkerRequest` の ConfigBundleRef が保存済み bundle と一致することを確認する。
- bundle 内の resolved launch config から Worker を作る。
- host-local secret / plugin / mount / network / shell policy は Runtime host policy と照合する。
- WorkingDirectory は Worker execution root/cwd として使うが、Profile discovery source にはしない。
Runtime がしてはいけないこと: ### 2. Backend に ConfigBundle builder を実装する
- Workspace filesystem を profile discovery のために読む。 Workspace Backend に、Browser launch の profile/role selector から ConfigBundle を構築する経路を追加する。
- Browser-facing request 由来の raw path / cwd / secret / endpoint を信頼する。
- selector だけを受け取り、Runtime-local FS から暗黙解決する。
### 3. Backend は bundle identity を content-addressed に扱う 実装すること:
Backend は launch 時に、対象 Runtime に必要な bundle があるかを確認し、なければ sync する。 - 既存の builtin / workspace / project Profile discovery を Backend 側で呼び出す。
- selector ambiguity / missing profile / invalid profile を Backend diagnostic にする。
- Profile を resolved launch config payload に変換する。
- ConfigBundle digest を計算する。
- Runtime ごとの bundle availability を確認し、missing / digest mismatch の場合は sync する。
- launch options は Browser に profile/role candidates だけ返し、ConfigBundle identity は返さない。
想定 flow: ### 3. Runtime の ConfigBundle store / sync / check を resolved payload 対応にする
```text Runtime 側の ConfigBundle store は resolved payload を保存・検証できるようにする。
Browser / Web Console
-> Backend: launch worker(profile/role, working_directory_id, initial input)
Backend 実装すること:
-> resolve Profile/config/prompt/resource/policy into ConfigBundle
-> compute digest / stable bundle id
-> Runtime: check bundle availability
-> Runtime: sync bundle if missing or digest mismatch
-> Runtime: create worker with ConfigBundleRef + WorkingDirectory/claim + initial input
```
### 4. Browser-facing API に ConfigBundle を出さない - `store_config_bundle` / check API が payload digest を検証する。
- unsupported declaration / unsupported host policy / missing secret ref を typed diagnostic にする。
- embedded Runtime direct call と remote Runtime REST path が同じ ConfigBundle contract を使う。
- retry / duplicate launch で同じ bundle content は同じ identity として扱える。
Browser は Profile selector / role / display information を選ぶだけにする。ConfigBundleRef、Runtime internal config store、bundle digest、secret refs の詳細、Runtime endpoint は Browser-facing payload に出さない。 ### 4. Worker creation を ConfigBundle payload から構築する
### 5. 互換 bridge は明示的に一時扱いにする Runtime Worker creation は、通常経路で Runtime-local filesystem から Profile discovery しない。
実装途中に builtin/default fallback や `profile_base_dir` が必要なら、runtime-local compatibility path として明示し、Browser WorkingDirectory launch の通常経路では使わない。 実装すること:
## 実装分割案 - `CreateWorkerRequest` は Backend が ensure した ConfigBundleRef を参照する。
- Runtime は ConfigBundleRef が保存済み bundle と一致することを検証する。
- Runtime は bundle payload から Worker manifest/config を構築する。
- WorkingDirectory は Worker execution root/cwd としてのみ使う。
- WorkingDirectory を Profile discovery source として使わない。
- ConfigBundle missing / digest mismatch / profile not in bundle / unsupported declaration は typed rejection にする。
1. Field audit / current boundary report ### 5. Browser WorkingDirectory launch を ConfigBundle 経由に接続する
- `ConfigBundle`、`CreateWorkerRequest`、`ProfileRuntimeWorkerFactory`、Backend launch API、remote Runtime sync API の現状を整理する。
- Runtime が FS profile discovery をしている箇所を列挙する。
2. Bundle payload model 既存 Browser WorkingDirectory launch は、Backend-resolved ConfigBundle を必ず経由して Worker を作る。
- ConfigBundle に resolved launch config を表す typed payload を追加する。
- digest 計算に payload を含める。
- secret values / raw host path / runtime endpoint / socket/session path を拒否する validation を追加する。
3. Backend bundle builder 実装すること:
- Backend が Profile selector / role から resolved bundle を作る経路を実装する。
- builtin role profiles と workspace/project profile discovery を Backend 側に寄せる。
- launch options は Browser に selector candidates だけ見せる。
4. Runtime create integration - Browser request は profile/role selector、working_directory_id、relative cwd / initial input など product-level fields だけを送る。
- Worker creation が ConfigBundle payload から Worker manifest/config を構築する - Backend は request を ConfigBundleRef + WorkingDirectory + initial input に落とし込む。
- Runtime-side profile filesystem discovery を Browser launch 経路から外す - Browser-facing response / error に ConfigBundleRef、bundle digest、Runtime store path、Runtime endpoint、raw path を含めない
- missing/mismatch/unsupported bundle は typed diagnostic にする - diagnostic は Browser に必要な sanitized message/code だけを返す
5. Remote/embedded sync behavior ### 6. compatibility fallback を通常経路から外す
- embedded Runtime direct call と remote Runtime REST client の sync/check behavior を揃える。
- retries は content identity で idempotent にする。
6. Cleanup / compatibility removal plan `config_bundle = None` や runtime-local profile discovery fallback が残る場合は、direct worker-runtime CLI / tests / builtin debugging の compatibility path として明示的に隔離する。
- selector-only bundle や runtime-local profile fallback が残る場合、その用途と削除条件を記録する。
実装すること:
- Browser / Workspace Backend launch では fallback を使わない。
- fallback を使う code path には diagnostic または test name で compatibility-only であることを残す。
- `profile_base_dir` / legacy `workspace_root` 呼称が残る場合、通常 launch 経路から参照されていないことを test で確認する。
## 受け入れ条件 ## 受け入れ条件
- ConfigBundle の payload strategy が Ticket thread または artifact に明文化されている。 - ConfigBundle に resolved launch config payload が実装されている。
- Backend が Profile/config を解決して ConfigBundle を作る責務を持つことが code/docs/tests 上で明確になっている。 - ConfigBundle digest が resolved payload を含む canonical content identity になっている。
- Runtime Worker creation は通常経路で Workspace filesystem / profile base から Profile discovery を行わない。
- ConfigBundle digest は resolved payload を含む content identity になっている。
- ConfigBundle validation が secret values、raw host paths、Runtime endpoint、socket/session paths、runtime-local mount actual paths を拒否する。 - ConfigBundle validation が secret values、raw host paths、Runtime endpoint、socket/session paths、runtime-local mount actual paths を拒否する。
- Browser-facing API に ConfigBundleRef / bundle digest / Runtime config store / raw path が露出しない。 - Backend が profile/role selector から ConfigBundle を構築し、対象 Runtime に ensure/sync/check できる。
- Runtime Worker creation は通常経路で Workspace filesystem / profile base / WorkingDirectory root から Profile discovery を行わない。
- Runtime Worker creation は保存済み ConfigBundleRef と bundle payload から Worker manifest/config を構築する。
- Existing Browser WorkingDirectory launch が ConfigBundle 経由で Worker を作れる。
- Browser-facing API に ConfigBundleRef / bundle digest / Runtime config store / raw path / Runtime endpoint が露出しない。
- Embedded Runtime と remote Runtime の bundle check/sync/create behavior が同じ contract を使う。 - Embedded Runtime と remote Runtime の bundle check/sync/create behavior が同じ contract を使う。
- Missing bundle、digest mismatch、unsupported declaration、unsupported host policy、missing secret ref は typed diagnostic になる。 - Missing bundle、digest mismatch、profile missing、unsupported declaration、unsupported host policy、missing secret ref は typed diagnostic になる。
- Existing WorkingDirectory launch が ConfigBundle 経由で Worker を作れる。 - Focused tests が Backend bundle build、Runtime bundle validation、Worker create without Runtime FS profile discovery、remote sync/check path、Browser payload redaction、WorkingDirectory launch success を確認する。
- Focused tests が Backend bundle build、Runtime bundle validation、create without Runtime FS profile discovery、remote sync/check path、Browser payload redactionを確認する。
- `cargo test -p worker-runtime --features ws-server,fs-store` が通る。 - `cargo test -p worker-runtime --features ws-server,fs-store` が通る。
- `cargo test -p yoi-workspace-server` が通る。 - `cargo test -p yoi-workspace-server` が通る。
- `cargo check -p yoi` が通る。 - `cargo check -p yoi` が通る。
@ -130,3 +133,4 @@ Browser は Profile selector / role / display information を選ぶだけにす
- Multi-tenant auth model の完成。 - Multi-tenant auth model の完成。
- Browser-facing ConfigBundle editor UI。 - Browser-facing ConfigBundle editor UI。
- Runtime が Workspace filesystem を profile/config discovery source として読む経路の延命。 - Runtime が Workspace filesystem を profile/config discovery source として読む経路の延命。
- WorkingDirectory materializer の新しい dirty snapshot / cache / remote clone policy。