Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(teammates): a held account boundary is not proof the owner changed
Dash8ea7a890235b
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.tsindex 2198e8ed9e..cf8ba54041 100644--- a/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts+++ b/apps/desktop/src/main/maker-ipc/__tests__/taskActionAuthorization.test.ts@@ -439,7 +439,16 @@ describe('Owner-delegated scheduled task actions', () => {// teammate-authority.md「延迟投递只认真实撤权」(2026-10-30): live turn facts still// expire the admission, but only real revocation stops a queued message. Before,// any of these rollovers between turns dropped every supplement still queued.- it.each(['permission', 'plan', 'instance', 'account', 'input'] as const)('invalidates admission after %s changes; delayed delivery stops only on account change', async changed => {+ // A held app-session boundary alone proves nothing (a same-owner Ghost projection repair holds+ // it too): the captured database client is the owner identity (review on #7969).+ it.each([+ ['permission', 'delivered'],+ ['plan', 'delivered'],+ ['instance', 'delivered'],+ ['input', 'delivered'],+ ['boundary', 'retryable'],+ ['owner', 'revoked'],+ ] as const)('invalidates admission after %s changes; delayed delivery is %s', async (changed, outcome) => {const h = scheduledFixture();const queued = input();const guard = await withToolCallAuthority(h.authorize, scheduledSend(), async () => {@@ -452,12 +461,13 @@ describe('Owner-delegated scheduled task actions', () => {if (changed === 'permission') h.runtime.stablePermissionModeState.generation++;if (changed === 'plan') h.runtime.stablePlanModeState.generation++;if (changed === 'instance') h.getSession.mockReturnValue({ ...h.runtime });- if (changed === 'account') hostFacts.boundaryPending.mockReturnValue(true);+ if (changed === 'boundary') hostFacts.boundaryPending.mockReturnValue(true);+ if (changed === 'owner') hostFacts.getDb.mockReturnValue({});if (changed === 'input') h.activeInput.boundary = 'replacement-runtime';expect(() => guard()).toThrow('AUTHORIZATION_EXPIRED');- const delivery = expect(taskActionInputGuard('target', queued)!());- if (changed === 'account') await delivery.rejects.toThrow('AUTHORIZATION_EXPIRED');- else await delivery.resolves.toBeUndefined();+ const rejection = await taskActionInputGuard('target', queued)!().then(() => null, (error: unknown) => ({ error }));+ if (outcome === 'delivered') expect(rejection).toBeNull();+ else expect(rejection && isTaskActionRevoked(rejection.error)).toBe(outcome === 'revoked');});// Review on #7969: /clear moves the coordinator's boundary before cleared_at is persisted,diff --git a/apps/desktop/src/main/maker-ipc/taskActionHost.ts b/apps/desktop/src/main/maker-ipc/taskActionHost.tsindex 8e28ed7202..dadded5dcf 100644--- a/apps/desktop/src/main/maker-ipc/taskActionHost.ts+++ b/apps/desktop/src/main/maker-ipc/taskActionHost.ts@@ -312,10 +312,17 @@ export function createDesktopTaskActionAuthorizer(deps: {// or archived, delegation run or team changed, group grant. The sender's live// Session incarnation, input generation and permission/Plan generation gate// executing this call (assertCurrent), never an already queued message.+ // The captured database client is the owner identity. A held app-session boundary alone+ // proves nothing: a same-owner Ghost projection repair holds it too. While it is pending+ // a delivery check cannot be answered, which is a failed check (kept for retry), not a+ // revocation; once the client is replaced the next check proves the owner changed.+ const assertSameOwner = (revokedAs: string) => {+ if (db !== tryGetDbClient()) throw new Error(revokedAs);+ if (isAppSessionBoundaryPending()) throw new Error('HOST_NOT_READY');+ };const assertDeliveryCurrent = async () => {await group?.refresh();- if (isAppSessionBoundaryPending() || db !== tryGetDbClient())- throw new Error('TASK_ACTION_AUTHORIZATION_EXPIRED');+ assertSameOwner('TASK_ACTION_AUTHORIZATION_EXPIRED');const [fresh] = await db.drizzle.select({status: sessions.status,@@ -351,8 +358,7 @@ export function createDesktopTaskActionAuthorizer(deps: {throw new Error('TASK_ACTION_AUTHORIZATION_EXPIRED');}group?.assertCurrent();- if (db !== tryGetDbClient() || isAppSessionBoundaryPending())- throw new Error('OWNER_SCOPE_CHANGED');+ assertSameOwner('OWNER_SCOPE_CHANGED');};const assertCurrentSync = () => {runtime?.assertInputCurrent();diff --git a/docs/product-rules/teammate-authority.md b/docs/product-rules/teammate-authority.mdindex 75c8827340..285a93d588 100644--- a/docs/product-rules/teammate-authority.md+++ b/docs/product-rules/teammate-authority.md@@ -48,11 +48,12 @@- 同意到执行仍校验账号、实例、输入、权限与 Plan 代次;变更使这次放行失效。- **延迟投递只认真实撤权**(2026-10-30 用户裁决:能力优先):已准入的消息因目标忙而排队后,发起轮结束、发起方 Session 重建、换新输入,或发起方的权限档、计划模式变化,都不撤销这条消息;- 它由接收任务按自己的权限执行,主人可以在接收任务的队列里编辑或撤回。只有切换账号、发起任务被- 清空或删除、伙伴被暂停或归档、委派执行代次或 Orca 团队变化、群授权失效时才不再投递;这类消息在- 落库前移出队列,不在接收任务里留下失败回复。清空以协调器的内存边界和数据库 `cleared_at` 中较新者- 为准(`/clear` 先改内存、后写库,写库可能失败);重启后晚加载的旧边界不算新的清空。校验本身失败- (群授权传输中断、数据库未就绪等)不算撤权,不销毁消息,保留为可重试的队首。任务动作守卫只在消息+ 它由接收任务按自己的权限执行,主人可以在接收任务的队列里编辑或撤回。只有数据库客户端被替换+ (切换账号)、发起任务被清空或删除、伙伴被暂停或归档、委派执行代次或 Orca 团队变化、群授权失效时+ 才不再投递;这类消息在落库前移出队列,不在接收任务里留下失败回复。清空以协调器的内存边界和数据库+ `cleared_at` 中较新者为准(`/clear` 先改内存、后写库,写库可能失败);重启后晚加载的旧边界不算新的+ 清空。「判不了」不算撤权:账号边界持有中但数据库客户端没换(同账号 Ghost 投影修复也会持有它)、+ 群授权传输中断、数据库未就绪等校验失败,都不销毁消息,保留为可重试的队首。任务动作守卫只在消息落库之前判定(派发前预检,以及紧贴落库的那次复核):确认撤权则不落库、不留痕地移出队列;落库之后不再由它截断,照常派发——此时拒绝只会留下用户行和失败回复,而排队的任务消息无法重试(重试会换新的clientId,守卫绑定的是原 clientId)。实现见