Skip to content

feat(agent): 模型驱动的有界 child 任务调度 - #67

Merged
Qiyuanqiii merged 4 commits into
mainfrom
codex/issue-51-bounded-child-scheduling
Aug 15, 2026
Merged

Qiyuanqiii merged 4 commits into
mainfrom
codex/issue-51-bounded-child-scheduling

Conversation

@Qiyuanqiii

Copy link
Copy Markdown
Member

背景

issue #51(父任务 #36):已有核心委派(≤2 child、operator 审批链)与批量只读 fan-out(1/2/4/6 档位、operator 建计划执行),但缺少模型在明确协议内提出 child 任务、由 Go 验证并安全调度的完整产品路径。

本次改动

  • child_task_proposal.v1 协议(internal/domain/child_task.go):每任务 title/goal/skills/input_refs/dependency_ordinals/surface_hint/turn_limit/token_limit/timeout_millis/expected_artifacts;严格解码(未知字段拒绝)、目标去重、依赖自环与环写入前拒绝、空 hint 归一为 auto。
  • Go 裁决执行面:含写/审批技能(非 model.chat/list_workspace/read_file)的任务强制 core 面(≤2);纯只读任务按数量解析 fan-out 档位 1/2/4/6;混合 hint、只读面上声明依赖、三 core 任务均写入前拒绝。模型只能 hint;操作者审阅可把 fan-out 档位压到显式上限(1/2/4/6),模型无法自行提高。readonly 权限天花板由现有 fan-out capability 指纹(仅 list/read,无 Shell/写/网络/再委派)保证。
  • schema v102:child_task_proposals(spec/surface/fanout_tier/dedup_fingerprint 唯一/状态/审阅)+ child_task_assignments(每任务面/档位/预算/准入身份)+ 提案与审阅两张幂等操作表。同操作键回放、同语义 fingerprint 跨键去重。
  • 原子预算复核:写入事务内校验 run 运行中、root 存在、core 面 child 总数 ≤2、总 turn/token 不超过 effectiveRootBudget(沿用 v21 预留机制,留一个 root turn)。
  • 审阅与准入:approve/deny 幂等;core 面准入复用既有 AdmitSpecialist,并在准入后把 dependency_ordinals 绑定到 schema v101 的 agent_dependency_edges(唯一唤醒收据保证重放不重复绑定);readonly 面记录绑定意图,不可变 fan-out 计划创建与执行保持 operator 既有流程。
  • 模型入口:新工具 child_task_propose(agent_proposal 类、自动审批、必须 fenced root Supervisor 调用),只记录提案(admission_authorized=false),不创建 Agent;接入 toolgateway/应用执行器/CLI 与 Supervisor 网关。
  • 可观测性:agent.child_task_proposed/reviewed/admitted 事件;Run Activity 折叠展示 surface/档位/任务数(绝不展示 goal/输入引用/期望产物)。

测试覆盖

  • domain:协议严格解码、依赖环拒绝、surface 解析(core≤2、readonly 档位、三 core 拒绝、混合 hint 拒绝)。
  • store:记录/回放/跨键去重、审阅 approve(档位上限)幂等、core 准入(两 child + 依赖边绑定到 v101 账本)、环拒绝。
  • toolgateway:定义集与 payload 规范化用例更新(7 个普通工具 / 8 个 plan-phase)。
  • 全量 go test -timeout 30m ./...(含 analyzer opt-in)无 FAIL;go build/go vet 通过。
  • 迁移链:v102 逆迁移 helper;README schema 时间线审计(102 行)通过。

验证结果

  • go build ./...、go vet ./... 通过。
  • 全量 Go 套件(含 analyzer opt-in 跳过宿主限制)全部通过。
  • Web:typecheck/vitest/build 通过;openapi/schema 重新生成无漂移。

安全边界与非目标

  • 不允许 child 再创建无界 child(只读技能集封闭,core 面 ≤2、depth=1);不让 readonly fan-out 修改文件、执行命令或联网。
  • 模型只能提出意图:Go 验证图、预算、Scope、owner 与去重;并发档位只提高吞吐,不提高权限。
  • 不做跨机器/云端调度;fan-out 计划创建/执行的 operator 流程与预算预留保持不变。
  • UI 通过 Run Activity 看到提案状态/面/档位/任务数;child 树与取消复用既有 agent 图投影与逐 child 取消控制。

Closes #51

- child_task_proposal.v1 协议:title/goal/skills/input_refs/dependency_ordinals/surface_hint/预算/期望产物,严格解码、依赖自环与环写入前拒绝、目标去重
- Go 裁决执行面:含写技能强制 core(≤2),纯只读按任务数解析 fan-out 档位 1/2/4/6,混合 hint 与只读依赖拒绝;操作者审阅可压档位上限,模型无法自行提高
- schema v102:proposal/assignments/双幂等操作表;同键回放、同语义 fingerprint 跨键去重;写入前原子复核 run/root/core 容量/effectiveRootBudget
- 审阅 approve/deny 幂等;core 准入复用 AdmitSpecialist 并把依赖序绑定到 v101 agent_dependency_edges;readonly 记录绑定意图,fan-out 计划执行保持 operator 流程
- 新工具 child_task_propose(agent_proposal 类、fenced root、只记录提案不创建 Agent)接入 toolgateway/应用执行器/CLI 与 Supervisor 网关
- agent.child_task_proposed/reviewed/admitted 事件与 Run Activity 折叠展示
- prepareSupervisorToolCalls 白名单放行 child_task_propose(此前工具已广告进定义集但模型调用会被拒绝)
- NormalizeSupervisorToolPayload 补上 child_task_proposal.v1 分支(此前回落到 structured memory 归一化报 unsupported)
- 新增 Deliver 阶段白名单回归测试
- 提案/审阅事务以 runs 行 touch 串行化并发变更(防预算超卖竞态)
- 提案 dedup_fingerprint 唯一冲突恢复为幂等回放而非裸约束错误
- 审阅 UPDATE 校验影响行数,并发审阅返回稳定 CONFLICT;child_task_review_operations 增加 UNIQUE(proposal_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(agent): 模型驱动的有界 child 调度与总预算复核

1 participant