Skip to content

feat(agent): 结构化依赖等待、循环检测与可恢复唤醒 #50

Description

@Qiyuanqiii

Parent: #36

问题概述 / Summary

当前 child 生命周期与 waitgraph 已有基础,但尚缺完整的“任务 A 等待任务 B”结构化合同、持久唤醒和业务层死锁处理。需要防止父等子、子反等父,或 Tool/RAG/Agent 相互等待造成无限 Running。

当前基线 / Current baseline

  • Run/child、lease、timeout、cancel fan-out、waitgraph 包与部分生命周期事件已存在。
  • 不能依赖字符串状态、轮询日志或模型自行判断来解除等待。
  • 等待关系必须由 Go 控制平面持久化和裁决。

范围 / Scope

  • 定义 versioned dependency/wait edge:source、target、reason、deadline、generation。
  • 写入前检测自环、祖先环、跨 Mission 非法边和最大深度。
  • 持久化 wait/satisfied/failed/cancelled/expired 状态与唯一唤醒收据。
  • 进程重启后恢复未决依赖,不重复唤醒或重复消费结果。
  • 父取消向下扇出;child 失败按声明策略传播。
  • 检测无进展、循环轮询和 Tool/RAG 反向依赖,返回稳定 deadlock/livelock 错误。
  • Activity 以简明折叠项展示依赖与解除原因。

非目标 / Non-goals

  • 不在本 Issue 让模型创建任意 child。
  • 不实现分布式跨机器调度。
  • 不用 goroutine/thread lock 代替业务依赖图。

涉及目录 / Affected directories

  • internal/waitgraph/
  • internal/coordinator/
  • internal/application/
  • internal/domain/
  • internal/store/
  • internal/events/
  • internal/runactivity/
  • internal/httpapi/
  • web/src/

依赖 / Dependencies

  • 模型驱动 child 调度 Issue 依赖本 Issue 的等待合同。

验收条件 / Acceptance criteria

  • 自环、两节点环、多节点环和跨层反向依赖在写入前被拒绝。
  • 正常完成、失败、取消、超时和父取消均只唤醒一次。
  • 进程在写 edge、目标完成和提交唤醒之间崩溃时可幂等恢复。
  • 无进展 deadline 与重复相同状态触发稳定 deadlock/livelock 诊断。
  • 并发创建/完成依赖不丢事件、不双重消费。
  • Activity 不泄露 raw child output,只显示可验证状态摘要。
  • SQLite migration、并发、恢复和 race-sensitive 测试通过。

安全边界 / Security boundaries

模型只能提出依赖意图;Go 验证图、预算、Scope 与 owner。外部 Tool/RAG 结果不能反向调用等待中的同一 Agent。

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-runtimeAgent orchestration, memory, and extensionsenhancementNew feature or requestgoPull requests that update go codehelp wantedExtra attention is neededsecuritySecurity boundary or high-risk capability高难度

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions