Repository navigation
test(subagents): bound manager status waits - #204
Merged
agnitum2009 merged 1 commit intoAug 26, 2026
Merged
Conversation
## 变更文件 - tests/extensions/subagents/manager.test.ts Closes openpi-dev#177
agnitum2009
approved these changes
Aug 26, 2026
agnitum2009
left a comment
Collaborator
There was a problem hiding this comment.
审批结论:Approve
对照 #177 逐条核验,并在本地做了对抗性测试复现。
与 issue 的对齐
- 轮询清零(
while(...)grep 零残留),全部换为view.subscribeTo(id)事件订阅——超出"轮询加 deadline"的要求; - 每个等待点独立 5s deadline(实测正常最慢 ~1.1s,余量合理,支持 per-call 覆盖);
- timeout 错误含 agent id、等待目标、最后观测状态(含实体消失时的
missing兜底); - 含超时自测,且额外断言了超时后的退订清理路径;
consumed=false语义保留:helper 只被动观察 view、不经manager.waitFor消费 settle,未消费再投递行为链未破坏。
实现细节核验(对源码)
- check-then-subscribe 竞态闭环:先
read()快速路径 → 订阅后补跑一次observe()兜住窗口 → 同步触发的极端情况由if (finished) unsubscribe()收口;成功/超时两路均unsubscribe + clearTimeout; - 订阅语义核实过 manager 源码:所有状态迁移点
notify(id)均带 id 派发,id 级监听器表存在且自清理。
对抗性实测
- #177 复现:stub
HANG:路径(RunStarted 后无终止事件)+ 关闭首响应看门狗,pre-fix 无界 while 轮询 2s 内自旋 200+ 次仍卡死,仅外部守卫可救 —— bug 为真; - 同状态下 PR helper:500ms 有界失败,诊断信息完整;
- 六路攻击(订阅内同步完成、超时后迟到通知、实体中途蒸发、高频状态穿越、subscribe 抛异常、卡死实体超时路径):全部通过——不复活已 reject 的 promise、不泄漏监听器、真实原因不被吞成误导性 timeout;
- 原套件实跑 17/17 通过。
唯一理论缺口是快速路径与 subscribe 之间若未来引入 await 可能漏历史事件——当前同步执行下不可达,建议后续加注释说明即可,不阻塞。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
关联 #177。
Subagent manager 测试中的无界状态轮询可能在生命周期回归时永久挂住 CI。
改动
manager.waitFor()时的consumed=false语义。验证
manager.test.ts通过,17/17。Closes #177