Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
feat(control-api): attest oauth-broker spend against live targets
Jose Gabriel Ramirez Encinasb656b5793fa1
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex a223c56f9..7accde0c0 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.550",+ "version": "0.1.551","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.550",+ "version": "0.1.551","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/image-policy": "file:../packages/image-policy",diff --git a/control-api/package.json b/control-api/package.jsonindex 05ea1f10b..b3b94222e 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.550",+ "version": "0.1.551","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/routes/admin/hostSpecValidation.ts b/control-api/src/routes/admin/hostSpecValidation.tsindex 0d0562b4b..3079b07d6 100644--- a/control-api/src/routes/admin/hostSpecValidation.ts+++ b/control-api/src/routes/admin/hostSpecValidation.ts@@ -130,10 +130,28 @@ function validateCodexBrokerAdmission(}}- const hasBroker = targets.some(- target =>- isLlmProviderId(target.provider) && PROVIDER_AUTH_MODE[target.provider] === 'oauth-broker'- )+ const brokerIds = [+ ...new Set(+ targets+ .map(target => target.provider)+ .filter(+ (provider): provider is string =>+ isLlmProviderId(provider) && PROVIDER_AUTH_MODE[provider] === 'oauth-broker'+ )+ ),+ ]+ if (brokerIds.length > 1) {+ return {+ errors: [+ {+ field: 'spec.model.provider',+ message:+ 'a Host may declare at most one oauth-broker provider across model, fallbacks, and allowedModels',+ },+ ],+ }+ }+ const hasBroker = brokerIds.length > 0const hasStatic = targets.some(target =>isLlmProviderId(target.provider) &&diff --git a/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.tsindex 3695ea73e..12fc85f06 100644--- a/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts+++ b/control-api/src/routes/mcp-host/llmProviderAttempts.routes.ts@@ -4,14 +4,16 @@ import { asyncHandler } from '../../http/asyncHandler.js'import type { K8sGateway } from '../../k8s.js'import { requireMcpHostJwt } from '../../middleware/mcpHostJwtAuth.js'import { rootLogger } from '../../observability/logger.js'-import {- CODEX_CONNECTION_REF_ANNOTATION,- readHostCodexConnectionRef,-} from '../../services/codexSubscriptionConnection.js'+import { readHostCodexConnectionRef } from '../../services/codexSubscriptionConnection.js'import {LlmProviderAttemptAuthorizeError,authorizeLlmProviderAttempt,} from '../../services/llmProviderAttemptAuthorizer.js'+import {+ collectHostOauthBrokerProviders,+ collectRecipeOauthBrokerProviders,+ readSubscriptionConnectionRef,+} from '../../services/subscriptionGrantIdentity.js'import { llmProviderAttemptAuthorizeRateLimits } from '../workflows/shared/rateLimit.js'const log = rootLogger.child({ module: 'mcp-host-llm-provider-attempts' })@@ -42,15 +44,23 @@ function sendAuthorizeError(res: Response, err: unknown): void {throw err}-export async function resolveHostAssignedConnectionKey(+export type LiveBrokerAssignment = {+ liveBrokerProviders: string[]+ liveConnectionRef: string+}++function throwAttestError(result: { ok: false; code: string; message: string }): never {+ throw new LlmProviderAttemptAuthorizeError(+ result.code as 'host_binding_mismatch' | 'unassigned_connection',+ result.message+ )+}++export async function resolveHostAssignedAssignment(gateway: Pick<K8sGateway, 'getResource'>,hostRef: string-): Promise<string> {+): Promise<LiveBrokerAssignment> {if (hostRef.includes('/')) {- // Workflow callers attest as `namespace/recipeName`. The grant identity is- // the `clerum.io/codex-connection-ref` annotation on that WorkflowRecipe- // (WRC stamps the parent's chosen key onto DB-run children). Missing or- // empty annotations resolve to the fail-closed `unassigned` sentinel.const [recipeNamespace, recipeName, ...rest] = hostRef.split('/')if (!recipeNamespace || !recipeName || rest.length > 0) {throw new LlmProviderAttemptAuthorizeError(@@ -64,9 +74,19 @@ export async function resolveHostAssignedConnectionKey(recipeName,recipeNamespace)) as { metadata?: { annotations?: Record<string, string> }; spec?: Record<string, unknown> }- return readHostCodexConnectionRef(- recipe?.metadata?.annotations?.[CODEX_CONNECTION_REF_ANNOTATION]- )+ const spec = recipe?.spec && typeof recipe.spec === 'object' ? recipe.spec : {}+ const liveBrokerProviders = collectRecipeOauthBrokerProviders(spec)+ const annotationProvider =+ liveBrokerProviders[0] ??+ (typeof (spec.agent as { provider?: string } | undefined)?.provider === 'string'+ ? String((spec.agent as { provider: string }).provider)+ : 'codex-subscription')+ const read = readSubscriptionConnectionRef({+ provider: annotationProvider,+ annotations: recipe?.metadata?.annotations,+ })+ if (!read.ok) throwAttestError(read)+ return { liveBrokerProviders, liveConnectionRef: read.connectionKey }} catch (err) {if (err instanceof LlmProviderAttemptAuthorizeError) throw errthrow new LlmProviderAttemptAuthorizeError(@@ -77,10 +97,20 @@ export async function resolveHostAssignedConnectionKey(}try {const host = (await gateway.getResource('hosts', hostRef, config.hostsNamespace)) as {- spec?: { model?: { connectionRef?: string } }+ spec?: Record<string, unknown>+ }+ const spec = host?.spec && typeof host.spec === 'object' ? host.spec : {}+ const model = spec.model+ const connectionRef =+ model && typeof model === 'object' && !Array.isArray(model)+ ? (model as { connectionRef?: string }).connectionRef+ : undefined+ return {+ liveBrokerProviders: collectHostOauthBrokerProviders(spec),+ liveConnectionRef: readHostCodexConnectionRef(connectionRef),}- return readHostCodexConnectionRef(host?.spec?.model?.connectionRef)- } catch {+ } catch (err) {+ if (err instanceof LlmProviderAttemptAuthorizeError) throw errthrow new LlmProviderAttemptAuthorizeError('host_binding_mismatch','Host assignment could not be attested'@@ -88,6 +118,14 @@ export async function resolveHostAssignedConnectionKey(}}+export async function resolveHostAssignedConnectionKey(+ gateway: Pick<K8sGateway, 'getResource'>,+ hostRef: string+): Promise<string> {+ const assignment = await resolveHostAssignedAssignment(gateway, hostRef)+ return assignment.liveConnectionRef+}+export function createMcpHostLlmProviderAttemptRoutes(gateway: K8sGateway): Router {const router = Router()router.post(@@ -103,6 +141,7 @@ export function createMcpHostLlmProviderAttemptRoutes(gateway: K8sGateway): Routtry {const result = await authorizeLlmProviderAttempt(claims, req.body, {resolveConnectionKey: hostRef => resolveHostAssignedConnectionKey(gateway, hostRef),+ resolveAssignment: hostRef => resolveHostAssignedAssignment(gateway, hostRef),})res.status(200).json(result)} catch (err) {diff --git a/control-api/src/services/llmProviderAttemptAuthorizer.ts b/control-api/src/services/llmProviderAttemptAuthorizer.tsindex 5837107f4..e1bd8909c 100644--- a/control-api/src/services/llmProviderAttemptAuthorizer.ts+++ b/control-api/src/services/llmProviderAttemptAuthorizer.ts@@ -16,7 +16,6 @@ import {CODEX_UNASSIGNED_CONNECTION_KEY,getSafeCodexSubscriptionConnection,isCodexUnassignedConnectionKey,- readHostCodexConnectionRef,} from './codexSubscriptionConnection.js'import {getMaxLlmProviderAttemptGeneration,@@ -29,6 +28,7 @@ import {pluginWorkloadSdkSpendOutcomeExists,promoteReservedOauthBrokerProviderAttempt,} from './pluginWorkloadSdkDb.js'+import { attestRequestedBrokerProvider } from './subscriptionGrantIdentity.js'const log = rootLogger.child({ module: 'llm-provider-attempt-authorizer' })const CODEX_EXECUTE_SCOPE = 'llm:codex:execute'@@ -91,6 +91,16 @@ export type LlmProviderAttemptAuthorizerDeps = {getConnection: typeof getSafeCodexSubscriptionConnectiongetModelState: typeof getCodexCatalogModelStateresolveConnectionKey: (hostRef: string) => Promise<string>+ /**+ * Live oauth-broker targets on the Host/recipe. When omitted, authorize+ * treats the requested provider as the only live target so existing unit+ * tests that mock only the connection key keep working. Production routes+ * must pass the K8s-attested assignment.+ */+ resolveAssignment?: (hostRef: string) => Promise<{+ liveBrokerProviders: string[]+ liveConnectionRef: string+ }>evaluateBudget: typeof evaluateBudgetCheckgetActiveReservation: typeof getActiveReservationgetMaxGeneration: typeof getMaxLlmProviderAttemptGeneration@@ -254,9 +264,21 @@ export async function authorizeLlmProviderAttempt()}- const connectionKey = readHostCodexConnectionRef(- await resolvedDeps.resolveConnectionKey(caller.hostRef)- )+ const assignment = resolvedDeps.resolveAssignment+ ? await resolvedDeps.resolveAssignment(caller.hostRef)+ : {+ liveBrokerProviders: [request.provider],+ liveConnectionRef: await resolvedDeps.resolveConnectionKey(caller.hostRef),+ }+ const attested = attestRequestedBrokerProvider({+ requestedProvider: request.provider,+ liveBrokerProviders: assignment.liveBrokerProviders,+ liveConnectionRef: assignment.liveConnectionRef,+ })+ if (!attested.ok) {+ throw new LlmProviderAttemptAuthorizeError(attested.code, attested.message)+ }+ const connectionKey = attested.connectionKeyif (isCodexUnassignedConnectionKey(connectionKey)) {throw new LlmProviderAttemptAuthorizeError('unassigned_connection',diff --git a/control-api/src/services/subscriptionGrantIdentity.ts b/control-api/src/services/subscriptionGrantIdentity.tsnew file mode 100644index 000000000..d31131024--- /dev/null+++ b/control-api/src/services/subscriptionGrantIdentity.ts@@ -0,0 +1,143 @@+import { PROVIDER_AUTH_MODE, isLlmProviderId } from '@clerum/llm-providers'+import { isPlainObject } from '../utils/isPlainObject.js'+import {+ CODEX_CONNECTION_REF_ANNOTATION,+ CODEX_UNASSIGNED_CONNECTION_KEY,+ isCodexUnassignedConnectionKey,+ readHostCodexConnectionRef,+} from './codexSubscriptionConnection.js'++export const SUBSCRIPTION_CONNECTION_REF_ANNOTATION =+ 'clerum.io/subscription-connection-ref' as const++export type SubscriptionGrantAttestErrorCode = 'host_binding_mismatch' | 'unassigned_connection'++export type SubscriptionGrantAttestResult =+ | { ok: true; provider: string; connectionKey: string }+ | { ok: false; code: SubscriptionGrantAttestErrorCode; message: string }++function isOauthBroker(provider: string): boolean {+ return isLlmProviderId(provider) && PROVIDER_AUTH_MODE[provider] === 'oauth-broker'+}++export function collectHostOauthBrokerProviders(spec: Record<string, unknown>): string[] {+ const providers: string[] = []+ const push = (value: unknown) => {+ if (typeof value !== 'string') return+ const provider = value.trim()+ if (provider && isOauthBroker(provider) && !providers.includes(provider)) {+ providers.push(provider)+ }+ }+ if (isPlainObject(spec.model)) push(spec.model.provider)+ if (Array.isArray(spec.allowedModels)) {+ for (const entry of spec.allowedModels) {+ if (isPlainObject(entry)) push(entry.provider)+ }+ }+ if (isPlainObject(spec.llmPolicy) && Array.isArray(spec.llmPolicy.fallbacks)) {+ for (const entry of spec.llmPolicy.fallbacks) {+ if (isPlainObject(entry)) push(entry.provider)+ }+ }+ return providers+}++export function collectRecipeOauthBrokerProviders(spec: Record<string, unknown>): string[] {+ const providers: string[] = []+ const push = (value: unknown) => {+ if (typeof value !== 'string') return+ const provider = value.trim()+ if (provider && isOauthBroker(provider) && !providers.includes(provider)) {+ providers.push(provider)+ }+ }+ if (isPlainObject(spec.agent)) push(spec.agent.provider)+ if (Array.isArray(spec.steps)) {+ for (const step of spec.steps) {+ if (isPlainObject(step) && isPlainObject(step.agent)) push(step.agent.provider)+ }+ }+ if (Array.isArray(spec.promptTargets)) {+ for (const target of spec.promptTargets) {+ if (isPlainObject(target)) push(target.provider)+ }+ }+ return providers+}++/**+ * Codex alias is read only when the attested provider is codex-subscription.+ * Grok (and any other broker) reads only the canonical annotation.+ * Disagree (both set, unequal) fails closed. Non-empty Codex alias on a+ * non-Codex provider fails closed.+ */+export function readSubscriptionConnectionRef(input: {+ provider: string+ annotations?: Record<string, string> | null+}):+ | { ok: true; connectionKey: string }+ | { ok: false; code: 'host_binding_mismatch'; message: string } {+ const annotations = input.annotations ?? {}+ const canonical =+ typeof annotations[SUBSCRIPTION_CONNECTION_REF_ANNOTATION] === 'string'+ ? annotations[SUBSCRIPTION_CONNECTION_REF_ANNOTATION].trim()+ : ''+ const alias =+ typeof annotations[CODEX_CONNECTION_REF_ANNOTATION] === 'string'+ ? annotations[CODEX_CONNECTION_REF_ANNOTATION].trim()+ : ''++ if (input.provider === 'codex-subscription') {+ if (canonical && alias && canonical !== alias) {+ return {+ ok: false,+ code: 'host_binding_mismatch',+ message: 'subscription connection annotations disagree',+ }+ }+ return { ok: true, connectionKey: readHostCodexConnectionRef(canonical || alias) }+ }++ if (alias) {+ return {+ ok: false,+ code: 'host_binding_mismatch',+ message: 'Codex connection annotation is not valid for this oauth-broker provider',+ }+ }+ return { ok: true, connectionKey: readHostCodexConnectionRef(canonical) }+}++export function attestRequestedBrokerProvider(input: {+ requestedProvider: string+ liveBrokerProviders: string[]+ liveConnectionRef: string+}): SubscriptionGrantAttestResult {+ if (!isOauthBroker(input.requestedProvider)) {+ return {+ ok: false,+ code: 'host_binding_mismatch',+ message: 'requested provider is not an oauth-broker target',+ }+ }+ if (!input.liveBrokerProviders.includes(input.requestedProvider)) {+ return {+ ok: false,+ code: 'host_binding_mismatch',+ message: 'requested oauth-broker provider is not a live target on this resource',+ }+ }+ const connectionKey = readHostCodexConnectionRef(input.liveConnectionRef)+ if (+ isCodexUnassignedConnectionKey(connectionKey) ||+ connectionKey === CODEX_UNASSIGNED_CONNECTION_KEY+ ) {+ return {+ ok: false,+ code: 'unassigned_connection',+ message: 'Host has no coding-plan subscription assigned',+ }+ }+ return { ok: true, provider: input.requestedProvider, connectionKey }+}diff --git a/control-api/test/hostSpecValidation.codexSubscription.test.ts b/control-api/test/hostSpecValidation.codexSubscription.test.tsindex 2170607c0..69d190824 100644--- a/control-api/test/hostSpecValidation.codexSubscription.test.ts+++ b/control-api/test/hostSpecValidation.codexSubscription.test.ts@@ -33,6 +33,22 @@ describe('codex-subscription Host admission', () => {expect(res).toBeNull()})+ it('allows a static primary plus Codex fallback when secretRef is set', async () => {+ process.env.CONTROL_API_CODEX_SUBSCRIPTION_ENABLED = 'true'+ const isModelAllowed = vi.fn().mockResolvedValue(true)+ const res = await validateHostSpec(+ {+ model: { provider: 'openai', name: 'gpt-5.1' },+ secretRef: 'llm-keys',+ llmPolicy: {+ fallbacks: [{ provider: 'codex-subscription', model: 'gpt-5.3-codex' }],+ },+ },+ { isModelAllowed }+ )+ expect(res).toBeNull()+ })+it('requires secretRef when a Codex Host also has a static fallback', async () => {process.env.CONTROL_API_CODEX_SUBSCRIPTION_ENABLED = 'true'const isModelAllowed = vi.fn().mockResolvedValue(true)diff --git a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts b/control-api/test/routes.mcp-host.llmProviderAttempts.test.tsindex a95a4d53e..ba74f5f6f 100644--- a/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts+++ b/control-api/test/routes.mcp-host.llmProviderAttempts.test.ts@@ -3,6 +3,7 @@ import express from 'express'import request from 'supertest'import {createMcpHostLlmProviderAttemptRoutes,+ resolveHostAssignedAssignment,resolveHostAssignedConnectionKey,} from '../src/routes/mcp-host/llmProviderAttempts.routes.js'import { LlmProviderAttemptAuthorizeError } from '../src/services/llmProviderAttemptAuthorizer.js'@@ -145,6 +146,39 @@ describe('POST /api/v1/mcp-host/llm/provider-attempts/authorize', () => {})describe('resolveHostAssignedConnectionKey', () => {+ it('reads connectionRef from a static primary with a Codex fallback', async () => {+ const gateway = {+ getResource: vi.fn().mockResolvedValue({+ spec: {+ model: { provider: 'openai', name: 'gpt-5.1', connectionRef: 'team-plus' },+ secretRef: 'llm',+ llmPolicy: { fallbacks: [{ provider: 'codex-subscription', name: 'gpt-5.3-codex' }] },+ },+ }),+ }+ await expect(resolveHostAssignedAssignment(gateway, 'agent-a')).resolves.toEqual({+ liveBrokerProviders: ['codex-subscription'],+ liveConnectionRef: 'team-plus',+ })+ })++ it('fails closed when recipe subscription annotations disagree', async () => {+ const gateway = {+ getResource: vi.fn().mockResolvedValue({+ metadata: {+ annotations: {+ 'clerum.io/codex-connection-ref': 'team-plus',+ 'clerum.io/subscription-connection-ref': 'other-key',+ },+ },+ spec: { agent: { provider: 'codex-subscription' } },+ }),+ }+ await expect(+ resolveHostAssignedConnectionKey(gateway, 'sandbox-recipes/codex-recipe')+ ).rejects.toMatchObject({ code: 'host_binding_mismatch' })+ })+it('reads the Host connectionRef and treats a missing field as unassigned', async () => {const gateway = {getResource: vi.fn().mockResolvedValue({diff --git a/control-api/test/services.llmProviderAttemptAuthorizer.test.ts b/control-api/test/services.llmProviderAttemptAuthorizer.test.tsindex 6e55f2094..598cfb2f3 100644--- a/control-api/test/services.llmProviderAttemptAuthorizer.test.ts+++ b/control-api/test/services.llmProviderAttemptAuthorizer.test.ts@@ -474,6 +474,31 @@ describe('authorizeLlmProviderAttempt', () => {).rejects.toMatchObject({ code: 'invalid_request' })})+ it('allows Codex spend when the live Host primary is static and Codex is a fallback', async () => {+ const result = await authorizeLlmProviderAttempt(claims(), body(), {+ ...current,+ resolveAssignment: async () => ({+ liveBrokerProviders: ['codex-subscription'],+ liveConnectionRef: 'team-plus',+ }),+ })+ expect(result.executionTicket).toBe('ticket.jwt')+ expect(current.getConnection).toHaveBeenCalledWith(expect.anything(), 'team-plus')+ })++ it('denies a Codex body when the live Host has no oauth-broker target', async () => {+ await expect(+ authorizeLlmProviderAttempt(claims(), body(), {+ ...current,+ resolveAssignment: async () => ({+ liveBrokerProviders: [],+ liveConnectionRef: 'team-plus',+ }),+ })+ ).rejects.toMatchObject({ code: 'host_binding_mismatch' })+ expect(current.getConnection).not.toHaveBeenCalled()+ })+it('rejects an unassigned Host connectionRef as unassigned_connection', async () => {await expect(authorizeLlmProviderAttempt(claims(), body(), {diff --git a/control-api/test/subscriptionGrantIdentity.test.ts b/control-api/test/subscriptionGrantIdentity.test.tsnew file mode 100644index 000000000..4f3b50f2d--- /dev/null+++ b/control-api/test/subscriptionGrantIdentity.test.ts@@ -0,0 +1,110 @@+import { describe, expect, it } from 'vitest'+import { CODEX_CONNECTION_REF_ANNOTATION } from '../src/services/codexSubscriptionConnection.js'+import {+ SUBSCRIPTION_CONNECTION_REF_ANNOTATION,+ attestRequestedBrokerProvider,+ collectHostOauthBrokerProviders,+ collectRecipeOauthBrokerProviders,+ readSubscriptionConnectionRef,+} from '../src/services/subscriptionGrantIdentity.js'++describe('collectHostOauthBrokerProviders', () => {+ it('includes Codex fallbacks when the primary is static', () => {+ expect(+ collectHostOauthBrokerProviders({+ model: { provider: 'openai', name: 'gpt-5.1' },+ secretRef: 'llm',+ llmPolicy: { fallbacks: [{ provider: 'codex-subscription', name: 'gpt-5.3-codex' }] },+ allowedModels: [{ provider: 'codex-subscription', name: 'gpt-5.3-codex' }],+ })+ ).toEqual(['codex-subscription'])+ })++ it('returns empty when every target is static', () => {+ expect(+ collectHostOauthBrokerProviders({+ model: { provider: 'openai', name: 'gpt-5.1' },+ })+ ).toEqual([])+ })+})++describe('attestRequestedBrokerProvider', () => {+ it('allows a static primary plus Codex fallback to spend Codex', () => {+ const result = attestRequestedBrokerProvider({+ requestedProvider: 'codex-subscription',+ liveBrokerProviders: collectHostOauthBrokerProviders({+ model: { provider: 'openai' },+ llmPolicy: { fallbacks: [{ provider: 'codex-subscription' }] },+ }),+ liveConnectionRef: 'team-plus',+ })+ expect(result).toEqual({+ ok: true,+ provider: 'codex-subscription',+ connectionKey: 'team-plus',+ })+ })++ it('denies a Codex body on a static-only Host', () => {+ const result = attestRequestedBrokerProvider({+ requestedProvider: 'codex-subscription',+ liveBrokerProviders: collectHostOauthBrokerProviders({+ model: { provider: 'openai' },+ }),+ liveConnectionRef: 'team-plus',+ })+ expect(result.ok).toBe(false)+ if (!result.ok) expect(result.code).toBe('host_binding_mismatch')+ })++ it('returns unassigned when connectionRef is empty', () => {+ const result = attestRequestedBrokerProvider({+ requestedProvider: 'codex-subscription',+ liveBrokerProviders: ['codex-subscription'],+ liveConnectionRef: '',+ })+ expect(result.ok).toBe(false)+ if (!result.ok) expect(result.code).toBe('unassigned_connection')+ })+})++describe('readSubscriptionConnectionRef', () => {+ it('reads the Codex alias when only that key is set', () => {+ const result = readSubscriptionConnectionRef({+ provider: 'codex-subscription',+ annotations: { [CODEX_CONNECTION_REF_ANNOTATION]: 'team-plus' },+ })+ expect(result).toEqual({ ok: true, connectionKey: 'team-plus' })+ })++ it('fails closed when Codex annotations disagree', () => {+ const result = readSubscriptionConnectionRef({+ provider: 'codex-subscription',+ annotations: {+ [CODEX_CONNECTION_REF_ANNOTATION]: 'team-plus',+ [SUBSCRIPTION_CONNECTION_REF_ANNOTATION]: 'other-key',+ },+ })+ expect(result.ok).toBe(false)+ })++ it('fails closed when a non-Codex broker still has the Codex alias', () => {+ const result = readSubscriptionConnectionRef({+ provider: 'openai',+ annotations: { [CODEX_CONNECTION_REF_ANNOTATION]: 'team-plus' },+ })+ expect(result.ok).toBe(false)+ })+})++describe('collectRecipeOauthBrokerProviders', () => {+ it('includes Codex promptTargets when the recipe agent is static', () => {+ expect(+ collectRecipeOauthBrokerProviders({+ agent: { provider: 'openai' },+ promptTargets: [{ provider: 'codex-subscription' }],+ })+ ).toEqual(['codex-subscription'])+ })+})