Repository navigation
fix(platform): 回合内重取凭据写盘前复查当前策略,堵住切换中的在途窗口 - #2807
Merged
Merged
Conversation
#2786 引入的回合内重取,在发起前检查一次「该工具是否仍由平台提供凭 据」,但写盘前的 CAS 只复查材料是否仍是本次拒绝、以及凭据 epoch,没 有复查策略。平台请求耗时一整个预算(最长 8 秒),这段时间里操作者在 Dashboard 把 bot 切成 credentialSource: local、或把该工具移出治理, 重取回来的平台凭据仍会落到该轮的身份材料里,与该人的本地凭据并存。 更关键的是它不能靠「发起时多传一份 config」修好:Dashboard 改配置是 整体替换(bot-registry.ts 的 bots.set(appId, { config: cfg, … })), 新对象与发起时的引用无关,快照只能挡住发起前就已切走的策略——那本来 就被现有闸挡住了——在途窗口依旧开着。 所以策略改为通过读取函数现取:IPC 路由传入 () => getBot(ds.larkAppId).config.triggerUserAuth,重取在 await 平台 返回后、写盘前的同一个同步段里调用它复查。复查谓词与入口完全一致: triggerUserAuthApplies(policy, tool) && credentialSourceOf(policy) !== 'local'。读取函数抛错(bot 已删除)按「不再治理」处理,删除条目 且不写盘,不放行。auto 不算切换(它仍然从平台取凭据),照常写入。 不变的部分:同人同 app,无越权面;单模型、adopt、跨 bot 委托路径不 经过回合内重取;平台返回「不可达」时行为与前一轮一致。 证据(合入前用真实组件 + 假时钟跑出,均为「发起 → 平台挂住 → 改策略 → 放行」序列): - 切成 local:修复前 grant 落盘(publishedGrant=true),修复后不落盘。 - 关掉治理:修复前同样落盘,修复后不落盘。 - 在途改成 auto:修复前后都落盘(期望行为,不当拦)。 - 用尽后文案、auto 不复查本地 HOME 等其余 P3 不受本次改动影响。
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 4, 2026 21:36
|
🚀 Released in v3.57.1 |
DylanQiao
added a commit
to DylanQiao/botmux
that referenced
this pull request
Nov 10, 2026
回合开始时平台答复 not_authorized(含 consent_missing),本回合发布的拒绝原先对整个回合是终局:用户在平台授权、按拒绝文案「完成后直接让我重试」重试,同一回合内仍然 exit 77;中途回复又会被 Codex steer 进运行中的回合,新回合不会开始,只能等回合结束再发一条消息。 沿用 deepcoldy#2786 / deepcoldy#2807 的回合内重取机制,把 not_authorized 也登记为可重取: - 独立节奏:从拒绝本身起算,至少间隔 30 秒,每回合每工具最多 20 次(unavailable 的节奏不变); - 平台仍答 not_authorized 时保留拒绝、稍后再问;答复在「未授权 / 未同意」之间变化时重发对应文案并继续可重取; - 拿到 granted 才写入(同一 CAS、策略复查、撤销即停);not_teammate / forbidden 仍是本回合终局;单文件模型不变。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
改了什么
#2786 引入的「回合内重取凭据」(
retryTransientTurnIdentity)在发起前检查一次「该工具是否仍由平台提供凭据」,但写盘前的 CAS 只复查两件事:材料是否仍是本次发布的拒绝、凭据 epoch 是否变了。它没有复查策略。平台请求耗时一整个 grant 预算(最长 8s)。这段时间里操作者在 Dashboard 把 bot 切成
credentialSource: local、或把该工具移出triggerUserAuth.tools,重取回来的平台凭据仍会写进该轮的身份材料,与那个人的本地凭据并存。为什么不能靠「发起时多传一份 config」修掉
Dashboard 改配置是整体替换:
cfg是新对象,与发起 attempt 时捕获的引用毫无关系。所以传快照只能挡住「发起前就已切走」的策略——那本来就被现有闸挡住了,在途窗口依旧开着。必须使用读取函数现取。改法
retryTransientTurnIdentity增加可选currentPolicy: () => TriggerUserAuthConfig | undefined,并把它一路传到写盘前:triggerUserAuthApplies(policy, tool) && credentialSourceOf(policy) !== 'local'。CURRENT_EXECUTION_IDENTITY_ROUTE)传() => getBot(ds.larkAppId).config.triggerUserAuth。auto不算切换:它仍然从平台取凭据,照常写入(拦它才是反向 bug)。policyStillWants,两处不再是两份谓词。影响面
senderOpenId,同 app 同人;这里只决定「要不要写」,不改变写给谁。botConfig仍保留,作为没有 registry 读取函数时的回退(测试与未来只有单个 config 的调用方),生产路径由 IPC 路由提供读取函数。timeoutMs边界、turnId去重注释)不在本 PR,仍在 fix(platform): 取凭据无响应时换新连接重试,回合内瞬时拒绝可重新获取 #2786 的 follow-up 评论里。证据(真实组件 + 假时钟,均为「发起 → 平台挂住 → 改策略 → 放行」)
localtriggerUserAuth关掉auto修复前用
console.log探针实测的原始输出(RACEX / OFFX / AUTOX,见 #2786 复审记录)已整理进上面的表格。测试
新增 6 条(
turn-cli-identity-transient-retry.test.ts)+ 1 条 IPC 路由层(ipc-current-execution-route.test.ts,验证读取函数确实被调用而不是快照)。IPC 那条用getBot每次返回新对象来模拟 Dashboard 的整体替换,正是快照修不了的那条缝。变异复验(置换式,4 枪全咬红):
truepolicyStillWants()整体置换为恒真验证