Repository navigation
fix(xpi): 跨身份确定性拒收无法改道时直接告知未执行,不再空耗重试 - #3061
Merged
Merged
Conversation
现象:开启实验性的跨身份打断隔离(XPI)后,会话正在跑定时任务唤起的一轮时,另一个 机器人发来的普通消息被 worker 以 cross_principal_requires_owner_confirmation 在准入前拒收, daemon 只打一行「lacked a safe reroute envelope/owner」,消息被原样重投一次、再被同样拒收, 最后才发出失败提示。日志也分不出改道前提里缺的是哪一项。 根因:daemon 的 onOrdinaryImInputRejected 在凑不齐改道前提(改道信封 / 发起主体 / 当前轮主体, 或当前轮 caller、controller 与发起方是同一主体)时返回 false,worker-pool 把这次确定性拒收 交给为 XPI 开关 TTL 偏斜这种瞬时分歧设计的 retryOrFailOrdinaryImDelivery。当前轮还在跑时, 重投会撞上同一道 worker 闸门,结果不会变。 修法:确定性分支与开关偏斜分支分开。新增纯函数 crossPrincipalRerouteGaps 列出缺项,daemon 日志写明 gaps=…,并返回 'not_executed';worker-pool 收到后不再重投,直接以 worker.input_rejected_before_admission 终态失败,告诉发信方这条消息没有被执行、可以重新发送。 XPI 开关关闭(TTL 偏斜)时仍返回 false,维持原有重试。 验证: - bunx vitest run --project unit test/session-lifecycle-start.test.ts test/cross-principal-interruption-store.test.ts test/cross-principal-interruption-gate.test.ts --maxWorkers=2:3 个文件 392 个用例通过 - 变异验证:src 全部还原时新增的 4 个用例失败;只还原 worker-pool 时投递用例失败(拒收后 无任何提示);只还原 daemon 时源码护栏用例失败 - bunx vitest run --project unit test/final-output-handoff.test.ts test/worker-ordinary-im-init-concurrency.integration.test.ts test/worker-collaborative-oncall.integration.test.ts test/test-hygiene.test.ts --maxWorkers=2:通过 (worker-ordinary-im-init-concurrency 有一个用例在与 build 并行时超时,单独重跑 9/9 通过) - bunx tsc --noEmit -p tsconfig.json:通过 - bun run build:通过
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 12:35
This was referenced Nov 7, 2026
|
🚀 Released in v3.59.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.
现象
开启跨身份打断隔离(
BOTMUX_XPI_ENABLED=true/crossPrincipalInterruption,默认关闭)时,会话正在跑定时任务唤起的一轮,另一个机器人发来的普通消息被 worker 以cross_principal_requires_owner_confirmation在准入前拒收。daemon 只打一行deterministic principal rejection lacked a safe reroute envelope/owner,然后把消息原样重投一次,再被同样拒收,最后才发出失败提示。日志里也看不出改道前提缺的是哪一项。根因
src/daemon.ts的onOrdinaryImInputRejected在凑不齐改道前提时返回false。改道前提包括:有改道信封、有发起主体、有当前轮主体,且当前轮的 caller / controller 都不是发起方。src/core/worker-pool.ts的rejectOrdinaryImDelivery把false交给retryOrFailOrdinaryImDelivery,这条重试路径是为 XPI 开关 TTL 偏斜这种瞬时分歧设计的。确定性拒收在当前轮还在跑时重投,会撞上同一道 worker 闸门,结果不会变。修法
src/core/cross-principal-interruption-store.ts新增纯函数crossPrincipalRerouteGaps,列出缺失的前提:envelope/proposer/active/active_caller_is_proposer/active_controller_is_proposer。空数组表示可以暂存。gaps=…,并返回'not_executed'。'not_executed'后不再重投,直接用已有文案worker.input_rejected_before_admission终态失败,告诉发信方这条消息没有被执行、可以重新发送。false,维持原有重试。影响面
已知限制
accepteddispatch ledger 条目,这是既有问题,本 PR 不处理。修改前重投耗尽后也会发同一条「未执行」提示,这一点没有变化。验证
bunx vitest run --project unit test/session-lifecycle-start.test.ts test/cross-principal-interruption-store.test.ts test/cross-principal-interruption-gate.test.ts --maxWorkers=2:3 个文件 392 个用例通过。test/session-lifecycle-start.test.ts:定时任务轮(不带 caller)期间对端机器人的消息被拒收,daemon 返回'not_executed'。断言只发出一次、重复拒收帧不再回调 daemon、立即发出一条「没有被执行」提示(带 turnId 和拒收原因),且不是「无法确认」文案。test/cross-principal-interruption-store.test.ts:crossPrincipalRerouteGaps的无缺项、各单项缺失和全部缺失。test/cross-principal-interruption-gate.test.ts:在既有的 daemon 源码护栏里断言开关闸之后、暂存之前的确定性分支返回'not_executed',不再return false。false→ 重投一次后以「未执行」失败)保持通过,只更新了注释。src/core/worker-pool.ts→ 投递用例变红(拒收后没有任何提示)。src/daemon.ts→ 源码护栏用例变红。bunx vitest run --project unit test/final-output-handoff.test.ts test/worker-ordinary-im-init-concurrency.integration.test.ts test/worker-collaborative-oncall.integration.test.ts test/test-hygiene.test.ts --maxWorkers=2:通过。worker-ordinary-im-init-concurrency有一个用例在与 build 并行时超时,单独重跑 9/9 通过。bunx tsc --noEmit -p tsconfig.json:通过。bun run build:通过。Fixes #1449