refactor(hub): role 改为数据条目,不再是写死的闭集枚举

ADR-0017 说 role-based routing 是 product/admin config,不是 spec invariant。
之前 RunRole = "draft"|"review"|"triage" 闭集违反这条——role 钉死在代码里,
教师/admin 无法自定义。改为:
- RoleEntry(id+label+defaultModel)是数据,registry 持有 role 集合
- roleId 退化为 string,新 role 是配置改动不是代码改动
- runner 不再带 role 字段(model 已由 caller resolve 好传入,role 透传无意义)
- 未知 role 优雅降级到首个启用 model,不抛
tsc --noEmit rc=0;role-as-data + ADR-0003 不变式 smoke 通过。
This commit is contained in:
2026-07-06 22:41:39 +08:00
parent 3bca137b48
commit a08c33205b
3 changed files with 46 additions and 25 deletions
-2
View File
@@ -11,7 +11,6 @@
*/
import type { AgentProvider, ChatResponse, Message, ToolCallPart } from "./provider.js";
import type { ToolContext, ToolRegistry } from "./tools.js";
import type { RunRole } from "./models.js";
/** What the runner needs about the project to seed and bound a run. */
export interface ProjectContext {
@@ -26,7 +25,6 @@ export interface RunRequest {
readonly prompt: string;
/** Resolved model id (already chosen by the caller per ADR-0017). */
readonly model: string;
readonly role: RunRole;
readonly project: ProjectContext;
readonly systemPrompt?: string;
/** Iteration cap before the run is returned as `length`. Default 25. */