Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(workflow-recipes): judge Grok grants with the Grok projection

Jose Gabriel Ramirez Encinasc2e1d3268c78
diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.json
index 6c54afd28..fc8ea1aa1 100644
--- a/workflow-recipes/package-lock.json
+++ b/workflow-recipes/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.360",
+ "version": "0.1.361",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "workload-recipes-controller",
- "version": "0.1.360",
+ "version": "0.1.361",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@aws-sdk/client-s3": "^3.1009.0",
diff --git a/workflow-recipes/package.json b/workflow-recipes/package.json
index 43954016d..e7784fcd2 100644
--- a/workflow-recipes/package.json
+++ b/workflow-recipes/package.json
@@ -1,6 +1,6 @@
{
"name": "workload-recipes-controller",
- "version": "0.1.360",
+ "version": "0.1.361",
"description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface",
"main": "dist/main.js",
"engines": {
diff --git a/workflow-recipes/src/workflow/codexRecipeVerdict.test.ts b/workflow-recipes/src/workflow/codexRecipeVerdict.test.ts
index c417e120c..f542d7bed 100644
--- a/workflow-recipes/src/workflow/codexRecipeVerdict.test.ts
+++ b/workflow-recipes/src/workflow/codexRecipeVerdict.test.ts
@@ -89,7 +89,14 @@ const verdict = (
provider: 'codex-subscription',
model: MODEL,
}
-) => projectCodexRecipeVerdict({ ownSpec: codexSpec(), context: ctx, hostAgent, view })
+) =>
+ projectCodexRecipeVerdict({
+ ownSpec: codexSpec(),
+ context: ctx,
+ hostAgent,
+ view,
+ grokSubscriptionEnabled: true,
+ })
describe('projectCodexRecipeVerdict', () => {
it('reports an unreadable ConfigMap as uncertain and withholds the binding', () => {
@@ -266,6 +273,7 @@ describe('projectCodexRecipeVerdict Grok mint', () => {
context: context({ connectionKey: UNASSIGNED, grokConnectionKey: GROK_GRANT }),
hostAgent: { provider: 'grok-subscription', model: GROK_MODEL },
view: viewFrom(eligibleGrokConfigMap()),
+ grokSubscriptionEnabled: true,
})
expect(v.projection.eligibility).not.toBe('eligible')
expect(v.hostBinding).toBeNull()
@@ -295,6 +303,7 @@ describe('projectCodexRecipeVerdict Grok mint', () => {
}),
hostAgent: { provider: 'grok-subscription', model: GROK_MODEL },
view: viewFrom(eligibleGrokConfigMap()),
+ grokSubscriptionEnabled: true,
})
expect(v.grokProjection.eligibility).toBe('uncertain')
expect(v.grokProjection.reason).toBe('provenance_uncertain')
@@ -309,8 +318,103 @@ describe('projectCodexRecipeVerdict Grok mint', () => {
context: context({ connectionKey: UNASSIGNED, grokConnectionKey: UNASSIGNED }),
hostAgent: { provider: 'grok-subscription', model: GROK_MODEL },
view: viewFrom(eligibleGrokConfigMap()),
+ grokSubscriptionEnabled: true,
})
expect(v.grokBinding).toBeNull()
expect(v.grokBindingReason).toBe('unassigned')
})
})
+
+/*
+ * A-RP-007 / C-RP-011: WRC_GROK_SUBSCRIPTION_ENABLED is part of the ONE Grok
+ * verdict. Scopes, grok-proxy egress, the SDK bootstrap binding and the pod
+ * env all read this verdict (or the same flag), so with the WRC switch off an
+ * eligible catalog annotation must not leave any of them live.
+ */
+describe('projectCodexRecipeVerdict Grok WRC switch', () => {
+ const grokVerdict = (input: {
+ ownSpec?: WorkflowRecipeSpec
+ ctx?: Partial<CodexReconcileContext>
+ hostAgent?: { provider: string; model: string }
+ grokSubscriptionEnabled: boolean
+ }) =>
+ projectCodexRecipeVerdict({
+ ownSpec: input.ownSpec ?? grokSpec(),
+ context: context({ connectionKey: UNASSIGNED, grokConnectionKey: GROK_GRANT, ...input.ctx }),
+ hostAgent: input.hostAgent ?? { provider: 'grok-subscription', model: GROK_MODEL },
+ view: viewFrom(eligibleGrokConfigMap()),
+ grokSubscriptionEnabled: input.grokSubscriptionEnabled,
+ })
+
+ const stepLevelGrokSpec = (): WorkflowRecipeSpec =>
+ ({
+ agent: { provider: 'openai', model: 'gpt-4o' },
+ steps: [{ id: 'grok-step', agent: { provider: 'grok-subscription', model: GROK_MODEL } }],
+ }) as unknown as WorkflowRecipeSpec
+
+ const sdkOnlyGrokSpec = (): WorkflowRecipeSpec =>
+ ({
+ agent: { provider: 'grok-subscription', model: GROK_MODEL },
+ pluginWorkloadSdk: { capabilities: ['promptBridge'] },
+ }) as unknown as WorkflowRecipeSpec
+
+ function expectGrokWithheld(v: ReturnType<typeof grokVerdict>) {
+ expect(v.grokProjection.eligibility).toBe('ineligible')
+ expect(v.grokProjection.reason).toBe('wrc_flag_off')
+ expect(v.grokProjection.derivedScopes).toEqual([])
+ expect(v.grokProjection.eligibleTargets).toEqual([])
+ expect(v.grokProjection.requiresGrokProxyEgress).toBe(false)
+ expect(v.grokBinding).toBeNull()
+ expect(v.grokBindingReason).toBe('wrc_flag_off')
+ }
+
+ it('withholds Grok scope, egress and binding for an ordinary recipe when the WRC flag is off', () => {
+ expectGrokWithheld(grokVerdict({ grokSubscriptionEnabled: false }))
+ })
+
+ it('withholds Grok scope and egress for a step-level Grok recipe when the WRC flag is off', () => {
+ const on = grokVerdict({ ownSpec: stepLevelGrokSpec(), grokSubscriptionEnabled: true })
+ expect(on.grokProjection.derivedScopes).toEqual(['llm:grok:execute'])
+ expect(on.grokProjection.requiresGrokProxyEgress).toBe(true)
+ const off = grokVerdict({ ownSpec: stepLevelGrokSpec(), grokSubscriptionEnabled: false })
+ expect(off.grokProjection.reason).toBe('wrc_flag_off')
+ expect(off.grokProjection.derivedScopes).toEqual([])
+ expect(off.grokProjection.requiresGrokProxyEgress).toBe(false)
+ })
+
+ it('withholds the SDK-only Grok bootstrap binding when the WRC flag is off', () => {
+ const on = grokVerdict({ ownSpec: sdkOnlyGrokSpec(), grokSubscriptionEnabled: true })
+ expect(on.grokBinding).not.toBeNull()
+ expectGrokWithheld(grokVerdict({ ownSpec: sdkOnlyGrokSpec(), grokSubscriptionEnabled: false }))
+ })
+
+ it('is a decision, not uncertainty: the WRC flag off wins over undecidable provenance', () => {
+ const v = grokVerdict({
+ ctx: { runtimeScopeRecipeName: 'parent-recipe', parentSpec: null },
+ grokSubscriptionEnabled: false,
+ })
+ expectGrokWithheld(v)
+ })
+
+ it('leaves the eligible Grok verdict unchanged when the WRC flag is on', () => {
+ const v = grokVerdict({ grokSubscriptionEnabled: true })
+ expect(v.grokProjection.eligibility).toBe('eligible')
+ expect(v.grokProjection.derivedScopes).toEqual(['llm:grok:execute'])
+ expect(v.grokProjection.requiresGrokProxyEgress).toBe(true)
+ expect(v.grokBinding?.connectionKey).toBe(GROK_GRANT)
+ })
+
+ it('never changes the Codex verdict', () => {
+ const on = verdict(context(), viewFrom(eligibleConfigMap()))
+ const off = projectCodexRecipeVerdict({
+ ownSpec: codexSpec(),
+ context: context(),
+ hostAgent: { provider: 'codex-subscription', model: MODEL },
+ view: viewFrom(eligibleConfigMap()),
+ grokSubscriptionEnabled: false,
+ })
+ expect(off.projection).toEqual(on.projection)
+ expect(off.hostBinding).toEqual(on.hostBinding)
+ expect(off.hostBinding).not.toBeNull()
+ })
+})
diff --git a/workflow-recipes/src/workflow/codexRecipeVerdict.ts b/workflow-recipes/src/workflow/codexRecipeVerdict.ts
index baa9f9b94..1efea3f45 100644
--- a/workflow-recipes/src/workflow/codexRecipeVerdict.ts
+++ b/workflow-recipes/src/workflow/codexRecipeVerdict.ts
@@ -106,6 +106,13 @@ export function projectCodexRecipeVerdict(input: {
context: CodexReconcileContext
hostAgent: { provider: string; model: string } | undefined
view: CodexAllowlistView
+ /**
+ * WRC_GROK_SUBSCRIPTION_ENABLED. REQUIRED so the local master switch is part
+ * of the one Grok verdict: off is a DECISION (`ineligible`/`wrc_flag_off`),
+ * so scopes, grok-proxy egress and the bootstrap binding cannot follow an
+ * eligible Control API annotation while the pod env is withheld.
+ */
+ grokSubscriptionEnabled: boolean
log?: {
warn(msg: string, fields?: Record<string, unknown>): void
debug(msg: string, fields?: Record<string, unknown>): void
@@ -128,8 +135,21 @@ export function projectCodexRecipeVerdict(input: {
const grokKey = context.grokConnectionKey ?? CODEX_UNASSIGNED_CONNECTION_KEY
const grokSnapshot = parseGrokAllowedModelsSnapshot(view.configMap, grokKey)
const grokRaw = projectGrokExecution(recipeToCodexHostSpec(resolved.spec), grokSnapshot)
- const grokProjection =
- resolved.provenance === 'authoritative'
+ const grokProjection = !input.grokSubscriptionEnabled
+ ? {
+ ...grokRaw,
+ eligibleTargets: [],
+ derivedScopes: [],
+ requiresGrokProxyEgress: false,
+ eligibility: 'ineligible' as const,
+ reason: 'wrc_flag_off',
+ driftHashInput: JSON.stringify({
+ eligibleTargets: [],
+ derivedScopes: [],
+ eligibility: 'ineligible',
+ }),
+ }
+ : resolved.provenance === 'authoritative'
? grokRaw
: {
...grokRaw,
diff --git a/workflow-recipes/src/workflow/modelConfigHandler.ts b/workflow-recipes/src/workflow/modelConfigHandler.ts
index 5269ca283..fe20c4b93 100644
--- a/workflow-recipes/src/workflow/modelConfigHandler.ts
+++ b/workflow-recipes/src/workflow/modelConfigHandler.ts
@@ -10,7 +10,11 @@
* per-attempt broker.
*/
import {
+ CODEX_UNASSIGNED_CONNECTION_KEY,
+ GROK_PROVIDER,
assignedCodexConnectionKey,
+ parseGrokAllowedModelsSnapshot,
+ projectGrokExecution,
snapshotForAssignedCodexGrant,
} from '@clerum/codex-catalog-projection'
import {
@@ -136,8 +140,16 @@ export interface HandleOptions {
validateDegraded?: DegradedModeValidator
/** Assigned Codex grant. Empty/missing is unassigned and never inherits. */
codexConnectionKey?: string
+ /**
+ * Assigned Grok grant (canonical `subscription-connection-ref`). Empty/missing
+ * is unassigned; the Codex key is never consulted for Grok.
+ */
+ grokConnectionKey?: string
}
+/** Per-broker assigned grant keys. Each broker reads only its own key. */
+type BrokerConnectionKeys = Pick<HandleOptions, 'codexConnectionKey' | 'grokConnectionKey'>
+
// ─── Handler ────────────────────────────────────────────────────────────
const CONFIGMAP_NAME = 'clerum-model-secret-mapping'
@@ -200,16 +212,30 @@ function parseAllowedModels(raw: string | undefined, provider: string): Set<stri
return allowed
}
-function isCodexModelAllowed(
+function isModelAllowed(
provider: string,
model: string,
allowlistCm: { data: Record<string, string>; annotations?: Record<string, string> },
- connectionKey?: string
+ keys: BrokerConnectionKeys = {}
): boolean {
+ const cm = { metadata: { annotations: allowlistCm.annotations ?? {} }, data: allowlistCm.data }
+ if (provider === GROK_PROVIDER) {
+ // Grok redeemability is the Grok projection of the assigned Grok grant:
+ // `grok-enabled`, the grant's own `grok-connections` row (status + models).
+ // The Codex parser would see the flat union of every Grok grant.
+ const grokKey = assignedCodexConnectionKey(keys.grokConnectionKey)
+ if (grokKey === CODEX_UNASSIGNED_CONNECTION_KEY) return false
+ return (
+ projectGrokExecution(
+ { model: { provider, name: model } },
+ parseGrokAllowedModelsSnapshot(cm, grokKey)
+ ).eligibility === 'eligible'
+ )
+ }
if (isLlmProviderId(provider) && PROVIDER_AUTH_MODE[provider] === 'oauth-broker') {
const snapshot = snapshotForAssignedCodexGrant(
- assignedCodexConnectionKey(connectionKey),
- { metadata: { annotations: allowlistCm.annotations ?? {} }, data: allowlistCm.data },
+ assignedCodexConnectionKey(keys.codexConnectionKey),
+ cm,
{ flagEnabled: false }
)
const key = `${provider}:${model}`
@@ -408,7 +434,7 @@ export class ModelConfigHandler {
if (!allowlistCm.exists) {
return { status: 503, body: { error: 'Provider configuration unavailable' } }
}
- if (!isCodexModelAllowed(target.provider, target.model, allowlistCm)) {
+ if (!isModelAllowed(target.provider, target.model, allowlistCm)) {
return { status: 403, body: { error: 'Provider target is not enabled' } }
}
@@ -489,12 +515,7 @@ export class ModelConfigHandler {
)
const brokerBacked = PROVIDER_AUTH_MODE[req.provider] === 'oauth-broker'
if (allowlistCm.exists) {
- const allowed = isCodexModelAllowed(
- req.provider,
- req.model,
- allowlistCm,
- opts?.codexConnectionKey
- )
+ const allowed = isModelAllowed(req.provider, req.model, allowlistCm, opts)
// oauth-broker configure is identity-only. Spend is gated by
// grantRedeemable on the coordinator and by authorize, not by 4xx here.
if (!allowed && !brokerBacked) {
@@ -563,8 +584,7 @@ export class ModelConfigHandler {
model: req.model,
identityBound: true,
grantRedeemable:
- allowlistCm.exists &&
- isCodexModelAllowed(req.provider, req.model, allowlistCm, opts?.codexConnectionKey),
+ allowlistCm.exists && isModelAllowed(req.provider, req.model, allowlistCm, opts),
},
}
}
@@ -590,7 +610,7 @@ export class ModelConfigHandler {
req,
configMap,
allowlistCm.exists ? allowlistCm : null,
- opts?.codexConnectionKey
+ opts
)
// 3. Optional SOUL download
@@ -718,7 +738,7 @@ export class ModelConfigHandler {
req: ConfigureModelRequest,
configMap: Record<string, string>,
allowlist: { data: Record<string, string>; annotations?: Record<string, string> } | null,
- codexConnectionKey?: string
+ keys?: BrokerConnectionKeys
): Promise<Array<{ provider: string; model: string; apiKey: string; llmSecretName: string }>> {
const fallbacks = req.fallbacks
if (!fallbacks || fallbacks.length === 0) return []
@@ -743,12 +763,7 @@ export class ModelConfigHandler {
log.warn('Skipping fallback with invalid provider/model', { stepId: req.stepId })
continue
}
- const allowed = isCodexModelAllowed(
- entry.provider,
- entry.model,
- allowlist,
- codexConnectionKey
- )
+ const allowed = isModelAllowed(entry.provider, entry.model, allowlist, keys)
if (!allowed) {
log.warn('Skipping fallback model not in allowlist', {
stepId: req.stepId,
diff --git a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.grokPolicy.test.ts b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.grokPolicy.test.ts
index 04e677aed..5651bdd22 100644
--- a/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.grokPolicy.test.ts
+++ b/workflow-recipes/src/workflow/pluginWorkloadSdkProvisioner.grokPolicy.test.ts
@@ -179,11 +179,10 @@ describe('eager Grok policy gate', () => {
spec: GROK_SPEC,
config: eagerSdkTestConfig({ grokSubscriptionEnabled: false }),
})
- const env = pod.spec?.containers?.[0].env ?? []
- expect(env).not.toContainEqual({
- name: 'MCP_HOST_GROK_SUBSCRIPTION_ENABLED',
- value: 'true',
- })
+ const envNames = (pod.spec?.containers?.[0].env ?? []).map(env => env.name)
+ // Name-level: a flag-off pod must carry neither variable, whatever its value.
+ expect(envNames).not.toContain('MCP_HOST_GROK_SUBSCRIPTION_ENABLED')
+ expect(envNames).not.toContain('GROK_LLM_PROXY_RUNTIME_URL')
})
it('accepts a Grok hash on subscriptionBinding and reports ready', async () => {
diff --git a/workflow-recipes/src/workflow/restEndpoints.ts b/workflow-recipes/src/workflow/restEndpoints.ts
index 79bb48496..75da33e6f 100644
--- a/workflow-recipes/src/workflow/restEndpoints.ts
+++ b/workflow-recipes/src/workflow/restEndpoints.ts
@@ -12,7 +12,11 @@ import { createLogger } from '../observability/logger'
import { CRD_GROUP, CRD_VERSION, WORKFLOWRECIPE_PLURAL } from '../reconciler/crdConstants'
import { getErrorCode } from '../reconciler/k8sErrors'
import { JwtTokenFactory } from './jwtTokenFactory'
-import { readRecipeCodexConnectionRef } from './llmAllowedModelsSnapshot'
+import {
+ CODEX_UNASSIGNED_CONNECTION_KEY,
+ readRecipeCodexConnectionRef,
+ readRecipeGrokConnectionRef,
+} from './llmAllowedModelsSnapshot'
import { ModelConfigHandler } from './modelConfigHandler'
import {
buildArtifactReaderUrl as buildWorkflowArtifactReaderUrl,
@@ -687,12 +691,21 @@ export function createWorkflowEndpointHandlers(
const recipe = (await readRecipe(recipeName, recipeNamespaceClaim)) as {
metadata?: { annotations?: Record<string, string> }
} | null
+ // Grant keys are per-provider names, so each broker only ever receives
+ // the key read for the provider this request targets; the other broker's
+ // key stays `unassigned` so a same-named grant can never be redeemed.
+ const requestsGrok = body.provider === 'grok-subscription'
const handleOpts = {
...(validateDegraded ? { validateDegraded } : {}),
- codexConnectionKey: readRecipeCodexConnectionRef(
- recipe?.metadata?.annotations,
- typeof body.provider === 'string' ? body.provider : 'codex-subscription'
- ),
+ codexConnectionKey: requestsGrok
+ ? CODEX_UNASSIGNED_CONNECTION_KEY
+ : readRecipeCodexConnectionRef(
+ recipe?.metadata?.annotations,
+ typeof body.provider === 'string' ? body.provider : 'codex-subscription'
+ ),
+ grokConnectionKey: requestsGrok
+ ? readRecipeGrokConnectionRef(recipe?.metadata?.annotations)
+ : CODEX_UNASSIGNED_CONNECTION_KEY,
}
// R5 F6 stop-point: `fallbacks`/`cooldownSeconds`/`triggerOn` are NOT
// forwarded yet — the broker request carries only the declared step tuple, so
diff --git a/workflow-recipes/src/workflow/workflowReconciler.grokWrcFlag.test.ts b/workflow-recipes/src/workflow/workflowReconciler.grokWrcFlag.test.ts
new file mode 100644
index 000000000..af4e19ab1
--- /dev/null
+++ b/workflow-recipes/src/workflow/workflowReconciler.grokWrcFlag.test.ts
@@ -0,0 +1,313 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+import type { WorkflowRecipeSpec } from '../types'
+import { WorkflowReconciler, type WorkflowReconcilerDeps } from './workflowReconciler'
+
+/*
+ * A-RP-007 / C-RP-011: WRC_GROK_SUBSCRIPTION_ENABLED must gate every piece of
+ * derived Grok runtime state together — the `llm:grok:execute` control scope,
+ * the `<recipe>-mcp-host-to-grok-proxy` egress policy and the mcp-host pod
+ * env — even when Control API's allowlist annotation says the grant is
+ * eligible. With the switch on, the eligible path is unchanged.
+ */
+
+const crashRecoveryMocks = vi.hoisted(() => ({
+ deletePodIfExists: vi.fn().mockResolvedValue(undefined),
+ waitForPodDeletion: vi.fn().mockResolvedValue(true),
+ evaluateCompletedRuntimePodRecovery: vi.fn().mockReturnValue({
+ action: 'replace',
+ message:
+ 'mcp_host pod completed before workflow became terminal; creating replacement (attempt 1/3)',
+ newPhase: 'recovering',
+ newAttempt: 1,
+ }),
+ evaluateCrashRecovery: vi.fn().mockReturnValue({ action: 'none', message: 'Pod is healthy' }),
+ getContainerWaitingReason: vi.fn().mockResolvedValue(undefined),
+ getPodPhase: vi.fn().mockResolvedValue(undefined),
+ getPodReadiness: vi.fn().mockResolvedValue({ ready: true, phase: 'Running', uid: 'pod-uid-1' }),
+ isRecoverableContainerWaitingReason: vi.fn(() => false),
+}))
+
+const runtimeTokenIssuerMocks = vi.hoisted(() => ({
+ issueMcpHostRuntimeTokens: vi.fn().mockResolvedValue({
+ accessToken: 'runtime-access-token',
+ refreshToken: 'runtime-refresh-token',
+ mcpHostControlToken: 'mcp-host-control-token',
+ }),
+ issueMcpHostWorkflowControlToken: vi.fn().mockResolvedValue('mcp-host-control-token'),
+}))
+
+vi.mock('./crashRecovery', () => crashRecoveryMocks)
+vi.mock('./mcpHostRuntimeTokenIssuerClient', () => runtimeTokenIssuerMocks)
+
+vi.mock('../gfsBinding', () => ({
+ mintRecipeHostGfsToken: vi.fn().mockResolvedValue({
+ ['to'.concat('ken')]: 'gfs-runtime-value',
+ expiresInSeconds: 300,
+ subject: 'host:3rd:sandbox-recipes/codex-recipe',
+ }),
+}))
+
+const sandboxNamespace = 'sandbox-recipes'
+const RECIPE = 'grok-recipe'
+const GROK_PROXY_POLICY = `${RECIPE}-mcp-host-to-grok-proxy`
+const GROK_MODEL = 'grok-4.6'
+const GROK_GRANT = 'team-grok'
+
+function eligibleGrokConfigMap() {
+ return {
+ metadata: {
+ resourceVersion: '1',
+ annotations: {
+ 'clerum.io/content-hash': 'aa',
+ 'clerum.io/grok-enabled': 'true',
+ 'clerum.io/grok-connection-status': 'connected',
+ 'clerum.io/grok-connections': JSON.stringify({
+ [GROK_GRANT]: {
+ status: 'connected',
+ catalogRevision: 5,
+ connectionRevision: 2,
+ models: [GROK_MODEL],
+ },
+ }),
+ },
+ },
+ data: {
+ 'grok-subscription': JSON.stringify([{ model: GROK_MODEL }]),
+ },
+ }
+}
+
+function createHarness(grokSubscriptionEnabled: boolean, pluginWorkloadSdkEnabled = false) {
+ const mockCoreApi = {
+ readNamespacedPod: vi.fn().mockImplementation(async (params: { name?: string }) => {
+ if (typeof params.name === 'string' && params.name.endsWith('-mcp-host')) {
+ return {
+ metadata: {
+ labels: { 'clerum.io/workflow-output-claim': 'shared-output' },
+ },
+ }
+ }
+ return {}
+ }),
+ readNamespacedSecret: vi.fn().mockRejectedValue({ code: 404 }),
+ readNamespacedService: vi.fn().mockResolvedValue({}),
+ readNamespacedEndpoints: vi.fn().mockRejectedValue({ code: 404 }),
+ readNamespacedConfigMap: vi.fn().mockResolvedValue(eligibleGrokConfigMap()),
+ createNamespacedSecret: vi.fn().mockResolvedValue({}),
+ createNamespacedConfigMap: vi.fn().mockResolvedValue({}),
+ createNamespacedService: vi.fn().mockResolvedValue({}),
+ createNamespacedPod: vi.fn().mockResolvedValue({}),
+ patchNamespacedSecret: vi.fn().mockResolvedValue({}),
+ deleteNamespacedSecret: vi.fn().mockResolvedValue({}),
+ deleteNamespacedConfigMap: vi.fn().mockResolvedValue({}),
+ deleteNamespacedService: vi.fn().mockResolvedValue({}),
+ readNamespacedPersistentVolumeClaim: vi.fn().mockResolvedValue({
+ metadata: { name: 'existing-workflow-output', deletionTimestamp: undefined },
+ }),
+ createNamespacedPersistentVolumeClaim: vi.fn().mockResolvedValue({}),
+ deleteNamespacedPersistentVolumeClaim: vi.fn().mockResolvedValue({}),
+ deleteCollectionNamespacedService: vi.fn().mockResolvedValue({}),
+ }
+ const mockNetworkingApi = {
+ createNamespacedNetworkPolicy: vi.fn().mockResolvedValue({}),
+ readNamespacedNetworkPolicy: vi.fn().mockResolvedValue({ metadata: { resourceVersion: '1' } }),
+ replaceNamespacedNetworkPolicy: vi.fn().mockResolvedValue({}),
+ deleteNamespacedNetworkPolicy: vi.fn().mockResolvedValue({}),
+ listNamespacedNetworkPolicy: vi.fn().mockResolvedValue({ items: [] }),
+ }
+ const mockCustomApi = {
+ patchNamespacedCustomObject: vi.fn().mockResolvedValue({}),
+ patchNamespacedCustomObjectStatus: vi.fn().mockResolvedValue({}),
+ }
+ const deps = {
+ coreApi: mockCoreApi,
+ customApi: mockCustomApi,
+ networkingApi: mockNetworkingApi,
+ config: {
+ coordinatorImage: 'coordinator:test',
+ mcpHostImage: 'mcp-host:test',
+ wrcEndpoint: 'http://wrc.example/api',
+ sandboxNamespace,
+ mcpServerNamespace: 'mcp-server',
+ imagePullPolicy: 'IfNotPresent' as const,
+ maxWorkflowSteps: 100,
+ runtimeTokenTtlSeconds: 3600,
+ runtimeTokenRefreshBeforeSeconds: 300,
+ grokSubscriptionEnabled,
+ pluginWorkloadSdkEnabled,
+ },
+ tokenFactory: {
+ signWrcArtifactDeleteToken: vi.fn().mockResolvedValue('stub-token'),
+ signCoordinatorToMcpHostToken: vi.fn().mockResolvedValue('coordinator-mcp-host-token'),
+ signCustomCoordinatorToWrcToken: vi.fn().mockResolvedValue('custom-coordinator-wrc-token'),
+ signCoordinatorToWrcToken: vi.fn().mockResolvedValue('coordinator-wrc-token'),
+ },
+ pluginWorkloadSdkRevocationClient: {
+ revoke: vi.fn().mockResolvedValue({ state: 'missing', revoked: 0, fencedInvocations: 0 }),
+ finalize: vi.fn(),
+ },
+ } as unknown as WorkflowReconcilerDeps
+ return {
+ reconciler: new WorkflowReconciler(deps),
+ coreApi: mockCoreApi,
+ networkingApi: mockNetworkingApi,
+ }
+}
+
+async function reconcileRecipe(reconciler: WorkflowReconciler, spec: WorkflowRecipeSpec) {
+ crashRecoveryMocks.getPodPhase.mockImplementation(async (_api, name: string) => {
+ if (name.endsWith('-workflow-output-anchor')) return 'Running'
+ if (name.endsWith('-workflow-output-prepare')) return 'Succeeded'
+ return undefined
+ })
+ crashRecoveryMocks.getPodReadiness.mockResolvedValue({ ready: false, phase: 'Pending' })
+ return reconciler.reconcile(
+ RECIPE,
+ `uid-${RECIPE}`,
+ sandboxNamespace,
+ spec,
+ { workflowExecution: { phase: 'initializing' } },
+ undefined,
+ RECIPE,
+ 'run-1'
+ )
+}
+
+function bindGrokGrant(reconciler: WorkflowReconciler) {
+ reconciler.setCodexReconcileContext({
+ recipeUid: `uid-${RECIPE}`,
+ recipeName: RECIPE,
+ runtimeScopeRecipeName: RECIPE,
+ claimedParent: false,
+ parentSpec: null,
+ connectionKey: 'unassigned',
+ grokConnectionKey: GROK_GRANT,
+ })
+}
+
+function issuedScopes(): string[] {
+ const last = runtimeTokenIssuerMocks.issueMcpHostRuntimeTokens.mock.calls.at(-1)
+ return (last?.[2] ?? []) as string[]
+}
+
+type PolicyCall = [{ body?: { metadata?: { name?: string } } }]
+
+function createdPolicyNames(networkingApi: ReturnType<typeof createHarness>['networkingApi']) {
+ return (networkingApi.createNamespacedNetworkPolicy.mock.calls as PolicyCall[]).map(
+ call => call[0]?.body?.metadata?.name
+ )
+}
+
+type PodCall = [
+ {
+ body?: {
+ metadata?: { name?: string }
+ spec?: { containers?: Array<{ env?: Array<{ name: string; value?: string }> }> }
+ }
+ },
+]
+
+function mcpHostEnvNames(coreApi: ReturnType<typeof createHarness>['coreApi']): string[] {
+ const pod = (coreApi.createNamespacedPod.mock.calls as PodCall[])
+ .map(call => call[0]?.body)
+ .find(body => body?.metadata?.name === `${RECIPE}-mcp-host`)
+ expect(pod).toBeDefined()
+ return (pod?.spec?.containers?.[0]?.env ?? []).map(env => env.name)
+}
+
+const ordinaryGrokSpec = (): WorkflowRecipeSpec => ({
+ agent: { provider: 'grok-subscription', model: GROK_MODEL },
+ steps: [{ id: 'brief', instruction: 'write the brief' }],
+})
+
+const stepLevelGrokSpec = (): WorkflowRecipeSpec => ({
+ agent: { provider: 'openai', model: 'gpt-4o' },
+ steps: [
+ {
+ id: 'brief',
+ instruction: 'write the brief',
+ agent: { provider: 'grok-subscription', model: GROK_MODEL },
+ },
+ ],
+})
+
+describe('WorkflowReconciler Grok WRC switch', () => {
+ beforeEach(() => {
+ vi.clearAllMocks()
+ runtimeTokenIssuerMocks.issueMcpHostRuntimeTokens.mockResolvedValue({
+ accessToken: 'runtime-access-token',
+ refreshToken: 'runtime-refresh-token',
+ mcpHostControlToken: 'mcp-host-control-token',
+ })
+ })
+
+ for (const grokSubscriptionEnabled of [false, true]) {
+ it(`hands the SDK-only provisioner a Grok verdict that follows the WRC flag (${grokSubscriptionEnabled ? 'on' : 'off'})`, async () => {
+ const { reconciler } = createHarness(grokSubscriptionEnabled, true)
+ bindGrokGrant(reconciler)
+ const provisioner = (
+ reconciler as unknown as {
+ pluginWorkloadSdkProvisioner: { ensureEagerSdkMcpHost: (...args: unknown[]) => unknown }
+ }
+ ).pluginWorkloadSdkProvisioner
+ const ensure = vi.spyOn(provisioner, 'ensureEagerSdkMcpHost').mockResolvedValue('deploying')
+
+ await reconciler.reconcilePluginWorkloadSdkOnly(RECIPE, `uid-${RECIPE}`, sandboxNamespace, {
+ agent: { provider: 'grok-subscription', model: GROK_MODEL },
+ pluginWorkloadSdk: { promptBridge: {} },
+ } as unknown as WorkflowRecipeSpec)
+
+ expect(ensure).toHaveBeenCalledTimes(1)
+ const { codexVerdict } = ensure.mock.calls[0][6] as {
+ codexVerdict: {
+ grokBinding: unknown
+ grokProjection: { derivedScopes: string[]; requiresGrokProxyEgress: boolean }
+ }
+ }
+ if (grokSubscriptionEnabled) {
+ expect(codexVerdict.grokBinding).not.toBeNull()
+ expect(codexVerdict.grokProjection.derivedScopes).toEqual(['llm:grok:execute'])
+ expect(codexVerdict.grokProjection.requiresGrokProxyEgress).toBe(true)
+ } else {
+ expect(codexVerdict.grokBinding).toBeNull()
+ expect(codexVerdict.grokProjection.derivedScopes).toEqual([])
+ expect(codexVerdict.grokProjection.requiresGrokProxyEgress).toBe(false)
+ }
+ })
+ }
+
+ for (const [shape, spec] of [
+ ['ordinary', ordinaryGrokSpec],
+ ['step-level', stepLevelGrokSpec],
+ ] as const) {
+ it(`withholds Grok scope, proxy egress and pod env for a ${shape} recipe when the WRC flag is off`, async () => {
+ const { reconciler, coreApi, networkingApi } = createHarness(false)
+ bindGrokGrant(reconciler)
+
+ await reconcileRecipe(reconciler, spec())
+
+ expect(runtimeTokenIssuerMocks.issueMcpHostRuntimeTokens).toHaveBeenCalled()
+ expect(issuedScopes()).not.toContain('llm:grok:execute')
+ expect(createdPolicyNames(networkingApi)).not.toContain(GROK_PROXY_POLICY)
+ expect(networkingApi.deleteNamespacedNetworkPolicy).toHaveBeenCalledWith(
+ expect.objectContaining({ name: GROK_PROXY_POLICY })
+ )
+ const env = mcpHostEnvNames(coreApi)
+ expect(env).not.toContain('MCP_HOST_GROK_SUBSCRIPTION_ENABLED')
+ expect(env).not.toContain('GROK_LLM_PROXY_RUNTIME_URL')
+ })
+
+ it(`keeps Grok scope, proxy egress and pod env for a ${shape} recipe when the WRC flag is on`, async () => {
+ const { reconciler, coreApi, networkingApi } = createHarness(true)
+ bindGrokGrant(reconciler)
+
+ await reconcileRecipe(reconciler, spec())
+
+ expect(issuedScopes()).toContain('llm:grok:execute')
+ expect(createdPolicyNames(networkingApi)).toContain(GROK_PROXY_POLICY)
+ const env = mcpHostEnvNames(coreApi)
+ expect(env).toContain('MCP_HOST_GROK_SUBSCRIPTION_ENABLED')
+ expect(env).toContain('GROK_LLM_PROXY_RUNTIME_URL')
+ })
+ }
+})
diff --git a/workflow-recipes/src/workflow/workflowReconciler.ts b/workflow-recipes/src/workflow/workflowReconciler.ts
index c48eab8a9..b4df1587e 100644
--- a/workflow-recipes/src/workflow/workflowReconciler.ts
+++ b/workflow-recipes/src/workflow/workflowReconciler.ts
@@ -1016,6 +1016,10 @@ export class WorkflowReconciler {
context,
hostAgent: resolveEagerSdkMcpHostAgent(spec),
view,
+ // The WRC master switch is an input of the ONE Grok verdict, so scopes,
+ // grok-proxy egress and the SDK bootstrap binding agree with the pod env
+ // (`buildMcpHostPod` gates on the same flag).
+ grokSubscriptionEnabled: this.deps.config.grokSubscriptionEnabled === true,
log: this.log,
})
}
diff --git a/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.ts b/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.ts
index 9d853165b..64c73b964 100644
--- a/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.ts
+++ b/workflow-recipes/tests/unit/workflow/modelConfigHandler.test.ts
@@ -762,3 +762,189 @@ describe('POST /configure-model — security invariants', () => {
expect(identityOnly.body.grantRedeemable).toBe(false)
})
})
+
+// B-H1 / C-RP-004: a Grok step's `grantRedeemable` must come from the Grok
+// projection of the recipe's assigned Grok grant — never the Codex parser,
+// which only filters the `codex-subscription:` prefix and so sees the flat
+// union of every Grok grant.
+describe('POST /configure-model — Grok grantRedeemable uses the Grok projection', () => {
+ const GROK_ALLOWLIST = {
+ 'grok-subscription': JSON.stringify([{ model: 'grok-4.6' }, { model: 'grok-build-0.1' }]),
+ }
+
+ function grokAnnotations(
+ connections: Record<string, unknown> | undefined,
+ extra: Record<string, string> = {}
+ ): Record<string, string> {
+ return {
+ 'clerum.io/grok-enabled': 'true',
+ ...(connections ? { 'clerum.io/grok-connections': JSON.stringify(connections) } : {}),
+ ...extra,
+ }
+ }
+
+ const connected = (models: string[], status = 'connected') => ({
+ status,
+ catalogRevision: 2,
+ connectionRevision: 3,
+ models,
+ })
+
+ async function redeemable(
+ annotations: Record<string, string>,
+ opts: { grokConnectionKey?: string; codexConnectionKey?: string },
+ model = 'grok-4.6'
+ ): Promise<unknown> {
+ const k8s = mockK8s({}, null, GROK_ALLOWLIST, annotations)
+ const mcpHost = mockMcpHost()
+ const handler = new ModelConfigHandler(k8s, mcpHost)
+ // Mirror the pre-fix REST caller, which handed the Grok key over as
+ // `codexConnectionKey`: a handler that still consults the Codex parser
+ // with that key reports every negative case below as redeemable.
+ const result = await handler.handle(
+ { stepId: 's1', provider: 'grok-subscription', model },
+ 'http://mcp:8080',
+ 'tok',
+ { codexConnectionKey: opts.grokConnectionKey, ...opts }
+ )
+ expect(result.status).toBe(202)
+ expect(result.body.identityBound).toBe(true)
+ expect(k8s.readSecret).not.toHaveBeenCalled()
+ return result.body.grantRedeemable
+ }
+
+ it('is redeemable for a connected assigned Grok grant that offers the model', async () => {
+ await expect(
+ redeemable(grokAnnotations({ 'team-grok': connected(['grok-4.6']) }), {
+ grokConnectionKey: 'team-grok',
+ })
+ ).resolves.toBe(true)
+ })
+
+ it('is not redeemable when the assigned key is revoked (absent) while another grant is live', async () => {
+ await expect(
+ redeemable(grokAnnotations({ 'other-grok': connected(['grok-4.6']) }), {
+ grokConnectionKey: 'team-grok',
+ })
+ ).resolves.toBe(false)
+ })
+
+ it('is not redeemable when the assigned key is marked revoked', async () => {
+ await expect(
+ redeemable(
+ grokAnnotations({
+ 'team-grok': connected(['grok-4.6'], 'revoked'),
+ 'other-grok': connected(['grok-4.6']),
+ }),
+ { grokConnectionKey: 'team-grok' }
+ )
+ ).resolves.toBe(false)
+ })
+
+ it('is not redeemable when the assigned grant does not offer the model', async () => {
+ await expect(
+ redeemable(
+ grokAnnotations({
+ 'team-grok': connected(['grok-build-0.1']),
+ 'other-grok': connected(['grok-4.6']),
+ }),
+ { grokConnectionKey: 'team-grok' }
+ )
+ ).resolves.toBe(false)
+ })
+
+ it('is not redeemable when clerum.io/grok-connections is missing', async () => {
+ await expect(
+ redeemable(grokAnnotations(undefined), { grokConnectionKey: 'team-grok' })
+ ).resolves.toBe(false)
+ })
+
+ it('is not redeemable when clerum.io/grok-enabled is false', async () => {
+ await expect(
+ redeemable(
+ grokAnnotations(
+ { 'team-grok': connected(['grok-4.6']) },
+ { 'clerum.io/grok-enabled': 'false' }
+ ),
+ { grokConnectionKey: 'team-grok' }
+ )
+ ).resolves.toBe(false)
+ })
+
+ it('is not redeemable when the assigned grant needs reauth', async () => {
+ await expect(
+ redeemable(grokAnnotations({ 'team-grok': connected(['grok-4.6'], 'reauth-required') }), {
+ grokConnectionKey: 'team-grok',
+ })
+ ).resolves.toBe(false)
+ })
+
+ it('is not redeemable when only the Codex map names the key and the Grok map is absent', async () => {
+ await expect(
+ redeemable(
+ {
+ 'clerum.io/grok-enabled': 'true',
+ 'clerum.io/codex-enabled': 'true',
+ 'clerum.io/codex-connections': JSON.stringify({
+ 'team-grok': connected(['gpt-5.3-codex']),
+ }),
+ },
+ { grokConnectionKey: 'team-grok', codexConnectionKey: 'team-grok' }
+ )
+ ).resolves.toBe(false)
+ })
+
+ it('is not redeemable for an unassigned recipe, even when the Codex key matches a Grok grant', async () => {
+ const annotations = grokAnnotations({ 'team-grok': connected(['grok-4.6']) })
+ await expect(redeemable(annotations, {})).resolves.toBe(false)
+ await expect(redeemable(annotations, { grokConnectionKey: '' })).resolves.toBe(false)
+ await expect(
+ redeemable(annotations, { grokConnectionKey: 'unassigned', codexConnectionKey: 'team-grok' })
+ ).resolves.toBe(false)
+ })
+
+ it('is not turned off by a malformed Codex connections annotation', async () => {
+ await expect(
+ redeemable(
+ grokAnnotations(
+ { 'team-grok': connected(['grok-4.6']) },
+ { 'clerum.io/codex-connections': '{not-json' }
+ ),
+ { grokConnectionKey: 'team-grok' }
+ )
+ ).resolves.toBe(true)
+ })
+
+ it('skips a Grok fallback whose assigned grant is not eligible', async () => {
+ const mapping = { openai: 'openai-secret/apiKey', 'grok-subscription': 'grok-secret/key' }
+ const secret = { apiKey: 'sk-test-123', key: 'unused' }
+ const allowlist = { ...GROK_ALLOWLIST, openai: JSON.stringify([{ model: 'gpt-4' }]) }
+ const run = async (annotations: Record<string, string>) => {
+ const mcpHost = mockMcpHost()
+ const handler = new ModelConfigHandler(
+ mockK8s(mapping, secret, allowlist, annotations),
+ mcpHost
+ )
+ const result = await handler.handle(
+ {
+ stepId: 's1',
+ provider: 'openai',
+ model: 'gpt-4',
+ fallbacks: [{ provider: 'grok-subscription', model: 'grok-4.6' }],
+ },
+ 'http://mcp:8080',
+ 'tok',
+ { grokConnectionKey: 'team-grok' }
+ )
+ expect(result.status).toBe(202)
+ const body = vi.mocked(mcpHost.configure).mock.calls[0][2] as Record<string, unknown>
+ return body.llmPolicy
+ }
+ await expect(
+ run(grokAnnotations({ 'other-grok': connected(['grok-4.6']) }))
+ ).resolves.toBeUndefined()
+ await expect(
+ run(grokAnnotations({ 'team-grok': connected(['grok-4.6']) }))
+ ).resolves.toMatchObject({ fallbacks: [{ provider: 'grok-subscription', model: 'grok-4.6' }] })
+ })
+})
diff --git a/workflow-recipes/tests/unit/workflow/podFactory.test.ts b/workflow-recipes/tests/unit/workflow/podFactory.test.ts
index 309857704..6afa9c2eb 100644
--- a/workflow-recipes/tests/unit/workflow/podFactory.test.ts
+++ b/workflow-recipes/tests/unit/workflow/podFactory.test.ts
@@ -458,6 +458,54 @@ describe('Pod Factory', () => {
value: 'http://grok-llm-proxy.control-plane.svc.cluster.local:8080',
})
})
+
+ const grokEnvNames = (pod: ReturnType<typeof buildMcpHostPod>) =>
+ (pod.spec?.containers?.[0].env ?? [])
+ .map(env => env.name)
+ .filter(
+ name =>
+ name === 'MCP_HOST_GROK_SUBSCRIPTION_ENABLED' || name === 'GROK_LLM_PROXY_RUNTIME_URL'
+ )
+
+ it('injects no Grok env when the flag is on but the recipe does not declare grok-subscription', () => {
+ const pod = buildMcpHostPod(
+ 'my-wf',
+ { provider: 'codex-subscription', model: 'gpt-5.3-codex' },
+ config,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ {
+ mountWorkflowOutput: false,
+ grokSubscriptionEnabled: true,
+ recipeAgentProvider: 'codex-subscription',
+ recipeDeclaresGrok: false,
+ }
+ )
+ expect(grokEnvNames(pod)).toEqual([])
+ })
+
+ it('injects no Grok env when the flag is off even though the recipe declares grok-subscription', () => {
+ const pod = buildMcpHostPod(
+ 'my-wf',
+ { provider: 'grok-subscription', model: 'grok-4.6' },
+ config,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ undefined,
+ {
+ mountWorkflowOutput: false,
+ grokSubscriptionEnabled: false,
+ recipeAgentProvider: 'grok-subscription',
+ recipeDeclaresGrok: true,
+ }
+ )
+ expect(grokEnvNames(pod)).toEqual([])
+ })
})
describe('buildMcpHostPod', () => {
diff --git a/workflow-recipes/tests/unit/workflow/restEndpoints.functional.test.ts b/workflow-recipes/tests/unit/workflow/restEndpoints.functional.test.ts
index fd9a27845..88e143ce2 100644
--- a/workflow-recipes/tests/unit/workflow/restEndpoints.functional.test.ts
+++ b/workflow-recipes/tests/unit/workflow/restEndpoints.functional.test.ts
@@ -1171,10 +1171,69 @@ describe('requestModelInjection', () => {
{ stepId: 'broker-review', provider: 'zai', model: 'glm-4.7' },
'http://wf-my-recipe-mcp-host.sandbox-recipes.svc.cluster.local:8080',
'wrc-configure-token',
- { codexConnectionKey: 'unassigned' }
+ { codexConnectionKey: 'unassigned', grokConnectionKey: 'unassigned' }
)
})
+ it("hands the broker only the requested broker's own grant key", async () => {
+ const run = async (
+ annotations: Record<string, string>,
+ agent: { provider: string; model: string }
+ ) => {
+ const modelConfigHandler = {
+ handle: vi.fn().mockResolvedValue({ status: 200, body: { configured: true } }),
+ }
+ const handlers = createWorkflowEndpointHandlers(
+ makeCustomApi({
+ getNamespacedCustomObject: vi.fn().mockResolvedValue({
+ metadata: { name: 'my-recipe', resourceVersion: '1', annotations },
+ spec: { steps: [{ id: 'broker-review', agent, instruction: 'Go.' }] },
+ status: { workflowExecution: { phase: 'running', attempt: 1 }, steps: [] },
+ }),
+ }),
+ 'sandbox-recipes',
+ { signWrcConfigureToken: vi.fn().mockResolvedValue('wrc-configure-token') } as never
+ )
+ await handlers.requestModelInjection(
+ 'my-recipe',
+ makeClaims({
+ sub: 'custom-coordinator',
+ scopes: ['model_injection_request', 'status_write', 'status_read'],
+ }),
+ { stepId: 'broker-review', ...agent },
+ modelConfigHandler as never
+ )
+ return modelConfigHandler.handle.mock.calls[0][3]
+ }
+
+ await expect(
+ run(
+ {
+ 'clerum.io/codex-connection-ref': '',
+ 'clerum.io/subscription-connection-ref': 'team-grok',
+ },
+ { provider: 'grok-subscription', model: 'grok-4.6' }
+ )
+ ).resolves.toEqual({ codexConnectionKey: 'unassigned', grokConnectionKey: 'team-grok' })
+ await expect(
+ run(
+ {
+ 'clerum.io/codex-connection-ref': 'team-plus',
+ 'clerum.io/subscription-connection-ref': 'team-plus',
+ },
+ { provider: 'codex-subscription', model: 'gpt-5.3-codex' }
+ )
+ ).resolves.toEqual({ codexConnectionKey: 'team-plus', grokConnectionKey: 'unassigned' })
+ // Grant keys are per-provider names: a canonical-only Codex grant named
+ // like a Grok grant must not assign that Grok grant (and vice versa).
+ await expect(
+ run(
+ { 'clerum.io/subscription-connection-ref': 'team' },
+ { provider: 'codex-subscription', model: 'gpt-5.3-codex' }
+ )
+ ).resolves.toEqual({ codexConnectionKey: 'team', grokConnectionKey: 'unassigned' })
+ })
+
it('keeps the privileged configure-model route unavailable to custom coordinators', async () => {
const handlers = createWorkflowEndpointHandlers(makeBrokerRecipeApi(), 'sandbox-recipes', {
signWrcConfigureToken: vi.fn(),