Repository navigation
fix(execution): 拒绝未知 trigger source 并补齐 origin 穷尽守卫与顺序用例 - #2557
Merged
Merged
Conversation
#2549 双审遗留的 4 条非阻断 P3 的 follow-up: - trigger-types.ts: 新增 TRIGGER_SOURCE_TYPES 运行时常量作为单一事实源, TriggerSourceType 由它派生;validateTriggerRequest 对 source.type 做枚举 校验,未知值在准入边缘返回 400 bad_request。此前非法字符串(如 email)会被 rememberTriggerTurn 登记,导致该轮 execution current 因 triggerSource 过不 了 CLI 侧枚举而整篇 403(fail-closed,但坏请求应在提交时被拒)。 - turn-origin.ts: TRIGGER_SOURCES 改为复用同一常量,消除第二份手写字面量; 加类型级穷尽断言,以后常量被改写成漏值的手写列表时 tsc 直接报错(加注释 说明不能加 readonly TriggerSourceType[] 注解,否则宽化会使断言失效)。 - current-execution.test.ts: 补两条顺序守卫用例,均用真实字段形状( worker-pool readonly-task 续跑继承 human caller;failed_turn_recovery source 且无恢复标记时必须 unknown 而非 im)。 - trigger-api.test.ts: 枚举校验用例,六个合法值全过、非法值 400。 - docs/current-execution.md: 修正「仅发送 sessionId」与 fields opt-in 的矛盾。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
October 29, 2026 21:24
#2557 复审 P2:validateTriggerRequest 收为闭合枚举后,docs-site 仍有 一处 curl 示例填 "custom"(照抄即 400)和三行「不做任何校验/不校验」 断言(zh/en 各一份)与新行为矛盾。 - api-core-only.md 官方示例 "custom" → "webhook"(zh/en) - api-task-trigger.md §3.1 备注改为「按枚举校验,非法值 400 bad_request」(zh/en) - 已知限制节删除 source.type 不校验条目,改为指向 §3.1(zh/en) §3.1 字段表本就列出六个值,改后备注与表格一致;其余示例原本均为 webhook。 Co-Authored-By: Claude Code <[email protected]>
deepcoldy
pushed a commit
to uestcwangci/botmux
that referenced
this pull request
Oct 30, 2026
…ity-recovery-2473-final 四次同步 master(0345cc5f1..eb43116,14 提交,含 deepcoldy#2514/deepcoldy#2534/deepcoldy#2535/deepcoldy#2541/ deepcoldy#2467/deepcoldy#2550/deepcoldy#2553/deepcoldy#2554/deepcoldy#2557/deepcoldy#2561/deepcoldy#2562 等)。与本 PR 仅 worker-pool.ts / worker.ts 文件交集,git 自动合并干净、无冲突标记;PR 关键接线(codexApp TurnFailureCode 四处、!turn.error 守卫、pool 恢复落账、worker 签名 final 失败字段、Pi boot 20s 预算)逐处 grep 仍在原位。合并树 build 过、 codex 集成/容量/engine/deployment/schedule 共 276 项 vitest 绿、 容量+Pi argv 46 项 bun 绿。 Co-Authored-By: Claude Code <[email protected]>
|
🚀 Released in v3.56.0 |
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.
背景
#2549(
execution current --json返回轮次来源 origin,已合入02e382d4d)双审遗留 4 条非阻断 P3,本 PR 一次性收口;复审另发现枚举收窄需同步公开文档站(P2),已一并修复。无产品形态变化。改了什么
src/services/trigger-types.ts新增运行时常量TRIGGER_SOURCE_TYPES,TriggerSourceType改为由它派生;validateTriggerRequest对source.type做枚举校验,非六值之一(含非字符串、空串、大小写不符)直接 400bad_request。此前非法值(如"email")会被rememberTriggerTurn原样登记,该轮再调execution current时 daemon 产出的triggerSource过不了 CLI 侧枚举,整篇返回 403——fail-closed 但坏请求本应在提交时被拒。src/core/turn-origin.ts的TRIGGER_SOURCES不再是第二份手写字面量,直接复用TRIGGER_SOURCE_TYPES;另加类型级断言_triggerSourcesExhaustive,将来若被改写成漏值的手写列表,tsc在该文件直接 TS2322。已实测:给常量加宽类型注解会使断言失效,注释里写明了这一点。test/current-execution.test.ts补两条用例,均用生产代码的真实字段形状:worker-pool.ts把冻结的 human caller 克隆到续跑 turnId 的activeInteractiveTurn)必须判recovery,不能被前面的 interactive 分支判成im;caller.source === 'failed_turn_recovery'且无恢复标记指向本轮时必须unknown,不得判im。docs/current-execution.md原写「仅发送 sessionId」与 feat(execution): execution current --json 返回轮次来源 origin #2549 后的fields:["origin"]opt-in 矛盾,改为一句说明新旧两边行为。POST /api/trigger的契约变化,docs-site/此前与新行为矛盾,共 4 处:api-core-only.md官方 curl 示例"source": {"type": "custom"}照抄现在会 400 → 改为"webhook"(zh/en);api-task-trigger.md§3.1 备注「不做任何校验,任意字符串都能通过」→ 改为「按枚举校验,非法值 400」(zh/en;同节字段表本就列着六个值,改后一致);source.type不校验」条目删除并指向 §3.1(zh/en)。"custom"示例或「不校验」残留;docs-site 其余示例原本就是webhook。test/trigger-api.test.ts补枚举校验用例:六个合法值全部通过,email/EMAIL/空串/形近词/数字/undefined 全部 400。影响面
validateTriggerRequest是 HTTP/api/trigger与 dashboard trigger API 的入口校验;收紧只影响畸形请求。已排查 src 全部 11 个内部TriggerRequest生产者(webhook/ui/vc_meeting/headless,全部在枚举内);custom从未被任何 src 生产者使用,只存在于文档示例。docs/current-execution.md同节区有相邻改动,谁后合 rebase 一次即可(本 PR 该文档只改一句)。验证
bun run build(含 tsc)通过;!caller.source→ failed_turn_recovery 用例双引擎红;TRIGGER_SOURCE_TYPES加email而 CLI 字面量不跟 → K4 一致性用例与枚举用例变红;把TRIGGER_SOURCES改成漏值手写 tuple → tsc TS2322 精确报在守卫行(加宽类型注解则不报错,故守卫不带注解);🤖 Generated with Claude Code