Skip to content

Commit 1338950

Browse files
fix(copilot): align principal lifetime with orchestration
1 parent f890c89 commit 1338950

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

apps/sim/lib/copilot/auth/application-delegation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import type { DelegatedPrincipal } from '@sim/auth/principal'
2+
import { ORCHESTRATION_TIMEOUT_MS } from '@/lib/copilot/constants'
23

3-
export const COPILOT_APPLICATION_DELEGATION_TTL_MS = 5 * 60 * 1000
4+
/** Keeps delegated authority valid for the full bounded Copilot orchestration lifetime. */
5+
export const COPILOT_APPLICATION_DELEGATION_TTL_MS = ORCHESTRATION_TIMEOUT_MS
46

57
export interface CopilotExecutionContext {
68
userId?: string

apps/sim/lib/copilot/auth/file-delegation.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
messageForCopilotFileError,
99
resolveCopilotFilePrincipal,
1010
} from '@/lib/copilot/auth/file-delegation'
11+
import { ORCHESTRATION_TIMEOUT_MS } from '@/lib/copilot/constants'
1112
import { OrchestrationError } from '@/lib/core/orchestration/types'
1213

1314
const trustedContext = {
@@ -20,7 +21,7 @@ const trustedContext = {
2021
}
2122

2223
describe('Copilot file delegation', () => {
23-
it('creates a short-lived principal scoped to the trusted workspace and file', () => {
24+
it('creates an orchestration-bounded principal scoped to the trusted workspace and file', () => {
2425
const principal = resolveCopilotFilePrincipal(trustedContext, 'file-1')
2526

2627
expect(principal).toMatchObject({
@@ -36,7 +37,9 @@ describe('Copilot file delegation', () => {
3637
executionId: 'execution-1',
3738
},
3839
})
39-
expect(principal.expiresAt.getTime()).toBeGreaterThan(principal.issuedAt.getTime())
40+
expect(principal.expiresAt.getTime() - principal.issuedAt.getTime()).toBe(
41+
ORCHESTRATION_TIMEOUT_MS
42+
)
4043
})
4144

4245
it('creates a workspace-scoped principal for file creation', () => {

0 commit comments

Comments
 (0)