fix(hook): apply http-hook headers and harden hookAdd validation - #281
Merged
Conversation
- httpHandler now sends entry.headers (auth etc.) with the hook POST; non-2xx and network-error semantics unchanged - hooksapi hookAdd rejects blank command strings and non-positive timeouts (BadRequest, matching the existing empty-hooks guard) - refresh the F1 interrupt comment in goal/loop.ts for the cancel-path pause landed with the goal-turn-scope change - tests: wire-level httpHandler headers test (Bun.serve), hooksapi validation test, httpapi-exercise scenarios
This was referenced Aug 15, 2026
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.
Problem
Review 复盘 hooks/hooksapi 发现(前置 review verdict: BLOCKING):
headers字段被 schema 接受但httpHandler从未应用——配置 auth headers → 端点 401 → 非 2xx 被转为exitBlock→ PreToolUse 错误拒绝工具调用 / Stop hook 强制最多 5 轮额外模型轮。合法配置产生错误控制流。hookAdd接受空command(空 shell 静默 no-op)与非正timeout(立即 kill)。Fix
hook/settings.tshttpHandler:HttpClientRequest.setHeaders(entry.headers ?? {})(bodyJson 前);非 2xx → exitBlock 与网络错误静默放行语义不变handlers/session.tshookAdd 逐条校验:command 空/纯空白、timeout ≤ 0 →HttpApiError.BadRequest(与相邻 empty-hooks guard 同形)goal/loop.ts: F1 注释改写为准确描述 cancel 路径同步暂停(pauseForUserCancel, fix(goal): bound goal-driven turns and map ESC to goal pause #280)与 shouldPreempt 作为 DB 失败回退的新分工Evidence
bun typecheck(packages/opencode) 干净test/hook/http-handler.test.ts(真实 Bun.serve 断言 authorization/x-hook-test 到达 + 500 exitBlock 路径)test/server/session-hooks-api.test.ts(真实 HttpApi 面 400/200)--fail-on-missing)Review 处置说明
DAG 工作流 review 节点曾 REJECT,其两条 FAIL 经核实为误判:
pauseForUserCancel不存在是因为检查基线为 main(#280 尚未合入 main,本 PR 基于 dev);'unrelated changes' 为用户工作区固有文件,本 PR 仅提交 6 个修复相关文件。F1/F2/测试质量三项 review 均 PASS。