Files
archived-orca/cloud/packages/relay-contract/src/control-continuity.ts
T
Jinwoo Hong 3eec77c11a chore(cloud): add the relay fence broker, ops console, Terraform root, scripts, and 24 cloud-* workflows (#18413)
Phase 6 of the relay split: the relay's deploy/operate surface moves under cloud/ with 24 cloud-* workflows gated on ORCA_CLOUD_OPERATIONS_ENABLED, the Cloud SQL rollout lease action, the relay Terraform root (dual-accept identities for both repositories), scripts, docs, CODEOWNERS, and a terraform validate job in Cloud Verify.
2026-09-03 06:55:14 -04:00

44 lines
1.2 KiB
TypeScript

export const CONTROL_GENERATION_STATE = {
ACTIVE: 'active',
ORPHANED: 'orphaned',
DRAIN_ONLY: 'drain-only',
FENCED: 'fenced',
CLOSED: 'closed'
} as const
export const CONTROL_CONTINUITY_LIMITS = {
orphanGraceMs: 30 * 1000,
authRefreshMinBeforeExpiryMs: 60 * 1000,
authRefreshMaxBeforeExpiryMs: 120 * 1000,
expiredAuthExistingSpliceGraceMs: 60 * 1000
} as const
export function controlLossDisposition(input: {
matchingResumeSecret: boolean
competingGeneration: boolean
}): 'rebind' | 'fence-old' | 'orphan-grace' {
if (input.matchingResumeSecret) return 'rebind'
if (input.competingGeneration) return 'fence-old'
return 'orphan-grace'
}
export function mayStartNewRelayWork(state: string, authExpired: boolean): boolean {
return state === CONTROL_GENERATION_STATE.ACTIVE && !authExpired
}
export interface RelayAuthIdentity {
sub: string
prof: string
org?: string
relayHostId: string
}
export function preservesRelayAuthIdentity(previous: RelayAuthIdentity, refreshed: RelayAuthIdentity): boolean {
return (
previous.sub === refreshed.sub &&
previous.prof === refreshed.prof &&
previous.org === refreshed.org &&
previous.relayHostId === refreshed.relayHostId
)
}