Conversation
…recovery, settlement races, and hot paths - worker.ts: replace empty exception handlers with file logging, worker.fatal RPC notification, and safe exit; main process listens for worker fatal/error/close - rpc.ts: propagate RPC handler failures to caller instead of unhandledRejection + hung promise - llm.ts (V2 runner): close awaitToolFibers race where awaitEmpty could swallow the last tool fiber failure - processor.ts (V1): guard cleanup against overwriting settled tool results; claim toolcalls synchronously - prompt.ts: parallelize independent request-build I/O with concurrency unbounded - recovery.ts: narrow session status checker to NotFoundError; propagate unexpected errors instead of inventing node failures - loop.ts: move orchestrator_unresponsive dag.fail under evalLock; log wake redelivery store failures instead of swallowing - stream.transport.ts: cap buffered events at 1000, add prompt-turn idle escape threshold, bound recoverQuestion polling to 120s - convert-to-openai-responses-input.ts: batch reasoning provider-option parsing out of the per-part loop - handler.ts (zen): cumulative-weight provider pick replaces O(sum-of-weights) array expansion - plugin/index.ts: observe plugin event hook rejections via forkDetach + logError - dag.ts: structural guard in parseWorkflowConfig for nodes/id/depends_on invariants - acp/service.ts: drop failed contextLimit lookups from cache so they retry - event-reducer.ts: batch per-delta store updates into one reactive notification - instance-state.ts: document why the ScopedCache is deliberately unbounded
fix(core,opencode): resolve audit CRITICAL/HIGH defects across crash recovery, settlement races, and hot paths
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.
内容
将
dev上的审查缺陷修复批次晋升到main。本批次为单个 PR(#154),修复一次全代码库审查报告的 3 个 CRITICAL + 12 个 HIGH 级缺陷。修复清单
CRITICAL
uncaughtException/unhandledRejection为空函数,静默丢弃所有未捕获异常,进程在损坏状态下继续运行(表现为 TUI 黑屏/挂死且零日志)。改为:uncaughtException 落盘日志 +worker.fatalRPC 通知主进程 + 安全退出;unhandledRejection 仅落盘(游离 rejection 不等于进程损坏)。同时加固 RPC 层(handler 抛错回传给调用方,不再变成 unhandledRejection + 永久 pending promise),主进程三路兜底监听 worker fatal/error/close。raceFirst(join, awaitEmpty)在最后一个工具 fiber 失败时可能被awaitEmpty的成功赢得竞争而吞掉失败(Effect 源码证实:observer 先backing.delete再完成 deferred,同 tick 竞争)。修复为awaitEmpty胜出后复查 deferred,有失败则改走 join。prompt.ts的Effect.all漏传 concurrency 选项,6 个独立 I/O 被串行化(每 turn 约 100–600ms);copilot responses 转换的 reasoning 解析从循环内串行 await 提升为批量Promise.all。HIGH(12 项)
崩溃恢复:recovery.ts 精确捕获 NotFoundError 不再编造 nodeFailed、loop.ts wake 重投递失败记录日志、dag.ts 配置解析结构守卫。
资源边界:stream.transport buffered 上限 1000、recoverQuestion 120s 截止、ACP contextLimit 失败不再永久缓存、plugin 事件 hook rejection 可观测。
并发正确性:loop.ts
dag.fail移入 evalLock 消除误杀窗口、processor.ts cleanup 状态守卫防覆盖已结算工具结果、stream.transport prompt 回合空闲逃生阈值。性能:zen 网关加权选择去掉 O(Σweight) 数组展开、event-reducer 每 delta 双通知合并为 batch。
其中 5 项修正了审查报告的论断(H1 的 DB 错误实为 defect、H3 的直接置 live 会引入抢跑竞态、H7 无限容量是有意设计、H9 严格 Schema 会拒绝旧行、H11 rope string 下 O(n²) 不成立)。完整论证见 #154。
门禁验证
dev上全量 CI 已通过(run 30638047212):首轮 Unit Tests 曾因
v2 pty HttpApi > serves location-wrapped PTY routes失败(轮询 20s 后 PTY 状态仍为 running)。已论证为环境 flaky 而非本批改动引起:PTY 退出状态由proc.onExit同步回调直写session.info(packages/core/src/pty.ts,未改动),不经任何被修改的路径;pty handler 仅依赖InstanceState.context(本批只加注释)与registerDisposer(未改动);本地该文件 4/4 通过;重跑该 job 全绿。补充审查