refactor(runtime): P7 收敛 before_completion_decision 到 AcceptanceService 单一裁决 (#495)#546
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…ing, max-turn signal, and decider projection
Role: 高级架构级 Code Reviewer & 技术布道师Context你现在需要 Review 一份关于核心运行时(Runtime)状态机重构的 GitHub PR。该系统采用了 Clean Architecture 的设计思想,包含 Gateway、TUI 和 Runtime 等层级。 Tasks请你仔细阅读提供的 PR 描述和代码 Diff,并严格按照以下结构输出你的 Review 意见: 第一部分:通俗易懂的逻辑白话翻译 (Plain English Summary)不要使用过多的内部黑话。请使用生动、易懂的比喻(例如:把 第二部分:深度风险分析 (Deep Risk Analysis)请切换到资深架构师的视角,针对以下三个核心维度,分析代码中可能存在的风险、漏洞或边界遗漏,并给出排查建议: 1. 契约与架构边界风险 (Architecture & Contracts)
2. 核心业务逻辑风险 (Core Logic & Gates)
3. 异常处理与兜底风险 (Error Handling & Fallbacks)
Format Constraints
|
结论先行我这轮 Review 看到 3 个值得优先处理的风险点:
第一部分:逻辑白话翻译这个 PR 做的事,可以把它理解成把“模型准备交卷”之前的最后流程,从“几个保安各自判断、口头传话”改成“一道固定顺序的总安检”。 以前的风险在于:completion、verification、final decider、hooks 这些信号虽然都在参与“到底能不能收尾”,但决策链比较分散,谁先说了算、信息怎么传,有不少隐式约定。现在作者把它们收敛到
所以重构后的数据流更像: 这个改动解决的核心痛点,是把“最终收尾到底是谁拍板”从散点逻辑收回到一个地方,后面 TUI、Gateway、运行态快照都只需要认这一份结构化结论,而不是自己猜 metadata、猜 stop reason、猜 error_class。 第二部分:深度风险分析1. 契约与架构边界风险
2. 核心业务逻辑风险
3. 异常处理与兜底风险
补充我本轮没有做代码修改,只做了读码和定向验证。补跑通过的定向测试为: |
|
这些问题都不是P0问题,我想可以延后,都不是什么吹毛求疵的问题,只是为了后续兜底和兼容,我想我会在p6引入的时候顺手修了 |
|
GuardSignal 仅观测不参与裁决 这些是有意为之,收敛本Pr范围 |
关联 Issue
实现语义(与代码一致)
本 PR 将 final acceptance 收敛到
before_completion_decision专用编排阶段:先收集 user/repo hook signals,再由 runtime 内部
AcceptanceService执行 completion gate + verification gate + decider 聚合,最终输出唯一AcceptanceDecision。变更摘要
before_completion_decision编排收敛AcceptanceDecision走强类型 runtime 内部路径,不通过通用HookResultmetadata 承载。beforeAcceptFinalLegacy标注为 Deprecated(rollback/对照用,主链不调用)。mapDeciderDecisionToAcceptance标注为 Deprecated(仅 legacy 回滚对照/测试使用)。accepted仅在completion_passed && verification_passed时成立。AcceptanceService对关键 stop reason 做稳定 error_class 补齐,避免 TUI/Gateway 落入空/unknown 推断歧义。verification_config_missing / execution_denied / execution_error / required_todo_failed / no_progress_after_final_intercept / verification_failed相关分支。测试
新增/增强
internal/runtime/acceptance_service_test.go:incomplete + no_progress_after_final_intercept并验证:
go test ./internal/runtime -run "Test(BeforeCompletionDecisionAcceptanceHooksOnOffParity|AcceptanceDecisionRequiresCompletionAndVerification|BeforeCompletionDecisionUserRepoCannotDirectlyTerminal|ChatAnswerAcceptancePassesWithoutHeavyVerification|NoProgressThresholdProducesIncomplete|VerificationFailureProducesStopReasonAndErrorClass|NormalizeAcceptanceErrorClassCoverage)" -count=1go test ./internal/runtime/decider ./internal/runtime/acceptance ./internal/runtime/verify ./internal/runtime/hooks -count=1非本 PR 范围