Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix: stop advertising an output cap the Codex wire cannot enforce
Alfredo Lopeze65c7e19a07f
diff --git a/charts/clerum-crds/crds/workflowrecipe.yaml b/charts/clerum-crds/crds/workflowrecipe.yamlindex d5f1362b7..741b54c2f 100644--- a/charts/clerum-crds/crds/workflowrecipe.yaml+++ b/charts/clerum-crds/crds/workflowrecipe.yaml@@ -477,6 +477,14 @@ spec:maxOutputTokens:type: integerminimum: 1+ description: >-+ DEPRECATED — accepted for+ compatibility but no longer enforced.+ The Codex ChatGPT wire discards+ max_output_tokens, so no layer capped+ the response by token count.+ Scheduled for removal in a future+ version.clientNotifications:type: objectrequired: [allowedEventTypes]@@ -1711,6 +1719,12 @@ spec:maxOutputTokens:type: integerminimum: 1+ description: >-+ DEPRECATED — accepted for compatibility but no+ longer enforced. The Codex ChatGPT wire discards+ max_output_tokens, so no layer capped the response+ by token count. Scheduled for removal in a future+ version.maxRequestsPerRun:type: integerminimum: 1diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex d8dff2505..79765c78a 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.536",+ "version": "0.1.537","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.536",+ "version": "0.1.537","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 6cb79190f..53e51c3af 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.536",+ "version": "0.1.537","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/pluginWorkloadSdk.ts b/control-api/src/routes/admin/pluginWorkloadSdk.tsindex de166e0b4..833f20cf3 100644--- a/control-api/src/routes/admin/pluginWorkloadSdk.ts+++ b/control-api/src/routes/admin/pluginWorkloadSdk.ts@@ -147,15 +147,22 @@ function parseModelArray(value: unknown, field: string, res: Response): string[]// Issue #348: per-run quota keys are deprecated. They remain accepted on the// wire for compatibility and are validated with the same shape rules, but they// are stripped before persistence — only per-minute/platform limits are stored.+//+// J8: `maxOutputTokens` joins them. It was advertised as a policy ceiling but+// bound nothing: the Codex ChatGPT wire rejects `max_output_tokens`, so no+// layer ever capped the response by token count. The only real bound is the+// 300s wall clock, and the budget reservation is admission control that denies+// the NEXT call, after the overspend already happened. Persisting the key kept+// a promise the platform could not keep.const DEPRECATED_QUOTA_LIMIT_KEYS: ReadonlyArray<keyof PluginWorkloadSdkQuotaLimits> = ['maxRequestsPerRun','maxNotificationsPerRun',+ 'maxOutputTokens',]const ACTIVE_QUOTA_LIMIT_KEYS: ReadonlyArray<keyof PluginWorkloadSdkQuotaLimits> = ['maxInvocationsPerMinute','maxNotificationsPerMinute',- 'maxOutputTokens',]function parseQuotaLimits(value: unknown, res: Response): PluginWorkloadSdkQuotaLimits | null {diff --git a/control-api/src/routes/mcp-host/plugin-workload-sdk.routes.ts b/control-api/src/routes/mcp-host/plugin-workload-sdk.routes.tsindex 1f75d5bd2..d2cabdf47 100644--- a/control-api/src/routes/mcp-host/plugin-workload-sdk.routes.ts+++ b/control-api/src/routes/mcp-host/plugin-workload-sdk.routes.ts@@ -611,7 +611,6 @@ async function handlePromptBridgeAuthorization(attemptGeneration: result.value.attemptGeneration,policyRevision: result.value.policyRevision,policyHash: result.value.policyHash,- maxOutputTokens: result.value.maxOutputTokens,})}diff --git a/control-api/src/services/pluginWorkloadSdkAuthorizer.ts b/control-api/src/services/pluginWorkloadSdkAuthorizer.tsindex ff5151c7e..be07334b5 100644--- a/control-api/src/services/pluginWorkloadSdkAuthorizer.ts+++ b/control-api/src/services/pluginWorkloadSdkAuthorizer.ts@@ -128,7 +128,6 @@ export interface AuthorizedPromptBridge {attemptGeneration: numberpolicyRevision: numberpolicyHash: string- maxOutputTokens: number | null}type PromptTargetResolution =@@ -398,7 +397,6 @@ async function authorizePromptBridgeInner(attemptGeneration: recorded.invocation.attemptGeneration,policyRevision: grant.policyRevision,policyHash: resolvedPolicyHash,- maxOutputTokens: grant.quotaLimits.maxOutputTokens ?? null,},}}@@ -496,7 +494,6 @@ async function authorizePromptBridgeInner(attemptGeneration: recorded.invocation.attemptGeneration,policyRevision: grant.policyRevision,policyHash: resolvedPolicyHash,- maxOutputTokens: grant.quotaLimits.maxOutputTokens ?? null,},}}@@ -599,6 +596,20 @@ export async function reissuePromptBridgeCredentialTicket(return deny('target_not_allowed', 'target is not in the current promptBridge policy')}+ const reservationOnly =+ isLlmProviderId(target.provider) && PROVIDER_AUTH_MODE[target.provider] === 'oauth-broker'+ // RP-539-009: an oauth-broker target is redeemable only through the broker+ // binding the WRC installs for the grant's default target. Any other broker+ // target would be reserved here and then die in execution with no credential+ // to redeem, after the reservation already charged the attempt budget. Deny+ // before reserving, and fail closed when the grant has no default target.+ if (reservationOnly && target.targetRef !== grant.defaultTargetRef) {+ return deny(+ 'target_not_allowed',+ 'oauth-broker fallback is authorized only for the default target of this grant'+ )+ }+const providerAttempt = await reservePluginWorkloadSdkProviderAttempt({invocationId: invocation.id,recipeNamespace: params.claims.recipeNamespace,@@ -613,8 +624,6 @@ export async function reissuePromptBridgeCredentialTicket()}- const reservationOnly =- isLlmProviderId(target.provider) && PROVIDER_AUTH_MODE[target.provider] === 'oauth-broker'if (reservationOnly) {return {ok: true,diff --git a/control-api/src/services/pluginWorkloadSdkDb.ts b/control-api/src/services/pluginWorkloadSdkDb.tsindex 0fcf3fa38..bf8e6d311 100644--- a/control-api/src/services/pluginWorkloadSdkDb.ts+++ b/control-api/src/services/pluginWorkloadSdkDb.ts@@ -167,10 +167,13 @@ export function getPromptBridgeAttemptLeaseSeconds(): number {const IDEMPOTENCY_TTL_HOURS = 24export interface PluginWorkloadSdkQuotaLimits {+ /** Deprecated (issue #348) — accepted and validated on the wire, never persisted. */maxRequestsPerRun?: number+ /** Deprecated (issue #348) — accepted and validated on the wire, never persisted. */maxNotificationsPerRun?: numbermaxInvocationsPerMinute?: numbermaxNotificationsPerMinute?: number+ /** Deprecated (J8) — accepted and validated on the wire, never persisted. */maxOutputTokens?: number}diff --git a/control-api/src/services/pluginWorkloadSdkFinalization.ts b/control-api/src/services/pluginWorkloadSdkFinalization.tsindex 0423a021e..fbc5d281d 100644--- a/control-api/src/services/pluginWorkloadSdkFinalization.ts+++ b/control-api/src/services/pluginWorkloadSdkFinalization.ts@@ -421,6 +421,12 @@ export async function finalizePromptBridgeInTransaction(if (!providerAttempt) {throw new PromptBridgeFinalizationError('not_found', 'provider attempt not found', 404)}+ // N-19: shape before binding, matching `replayExistingOutcome`. A non-oauth+ // finalization that omits `target.credentialSlot` is a malformed request, and+ // both paths must classify it as 400 `invalid_request`. Running the binding+ // comparison first would report the same body as 403 `binding_mismatch` here+ // and 400 on replay, so the same defect got two different verdicts.+ assertPersistedAuthModeCredentialRules(String(providerAttempt.provider), input)if (String(providerAttempt.invocation_id) !== input.invocationId ||String(providerAttempt.recipe_namespace) !== input.recipeNamespace ||@@ -438,7 +444,6 @@ export async function finalizePromptBridgeInTransaction(403)}- assertPersistedAuthModeCredentialRules(String(providerAttempt.provider), input)const currentInvocationStatus = String(invocation.status)const currentReceiptStatus = String(receipt.status)@@ -608,8 +613,12 @@ export async function finalizePromptBridgeInTransaction(// RP-539-003: a successful failover finalizes only its winner, so the// attempts it displaced would never reach this endpoint. They are terminal// and immutable by the reservation fence, so they can be discovered and- // settled here without trusting the host to declare them. Index 1 has no- // predecessors, so the query is skipped rather than run over an empty range.+ // settled here without trusting the host to declare them.+ //+ // The index-1 skip is NOT a defensive optimization: `attempt_index < 1`+ // matches nothing by construction, because attempt_index starts at 1 and+ // UNIQUE (invocation_id, attempt_generation, attempt_index) forbids gaps.+ // The query is skipped because it is provably empty, not because it might be.if (input.providerAttemptIndex > 1) {await settlePriorProviderAttemptFloors(db, {invocationId: input.invocationId,diff --git a/control-api/test/routes.adminPluginWorkloadSdk.test.ts b/control-api/test/routes.adminPluginWorkloadSdk.test.tsindex f7188af8a..0a182f459 100644--- a/control-api/test/routes.adminPluginWorkloadSdk.test.ts+++ b/control-api/test/routes.adminPluginWorkloadSdk.test.ts@@ -531,10 +531,14 @@ describe('routes/admin/pluginWorkloadSdk — grants', () => {)})- it('accepts deprecated per-run keys, strips them, keeps active keys', async () => {+ it('accepts deprecated quota keys, strips them, keeps active keys', async () => {// Issue #348 (plan 2.6/2.7): deprecated per-run keys stay shape-validated// (malformed still 400s, pinned above) but are dropped on write, while the- // active per-minute/token keys persist untouched.+ // active per-minute keys persist untouched.+ //+ // J8: maxOutputTokens joins the stripped set. It was persisted and+ // advertised as a policy ceiling, but the Codex ChatGPT wire discards+ // max_output_tokens, so nothing ever capped the response by token count.vi.mocked(sdkDb.upsertGrant).mockResolvedValue({ id: 'g1' } as never)const res = await request(buildApp()).post('/admin/plugin-workload-sdk/grants')@@ -543,6 +547,7 @@ describe('routes/admin/pluginWorkloadSdk — grants', () => {quotaLimits: {maxRequestsPerRun: 5,maxNotificationsPerRun: 7,+ maxOutputTokens: 4096,maxInvocationsPerMinute: 30,},})@@ -556,6 +561,15 @@ describe('routes/admin/pluginWorkloadSdk — grants', () => {)})+ it('still shape-validates the deprecated maxOutputTokens on the wire (J8)', async () => {+ // Deprecating the key must not loosen the boundary: a malformed value is+ // still a 400, exactly as it was while the key was persisted.+ const res = await request(buildApp())+ .post('/admin/plugin-workload-sdk/grants')+ .send({ ...validGrantBody, quotaLimits: { maxOutputTokens: 0 } })+ expect(res.status).toBe(400)+ })+it('rejects promptBridge targets outside the provider allowlist', async () => {// Allowlist for provider `zai` enables only glm-4.7; the request asks for a// model that is not enabled → 400 model_not_allowed listing the offenders.diff --git a/control-api/test/routes.mcp-host.plugin-workload-sdk.test.ts b/control-api/test/routes.mcp-host.plugin-workload-sdk.test.tsindex 16a32f055..9f376b1b9 100644--- a/control-api/test/routes.mcp-host.plugin-workload-sdk.test.ts+++ b/control-api/test/routes.mcp-host.plugin-workload-sdk.test.ts@@ -162,7 +162,6 @@ beforeEach(() => {attemptGeneration: 1,policyRevision: 1,policyHash: 'policy-hash',- maxOutputTokens: null,},})vi.mocked(authorizer.reissuePromptBridgeCredentialTicket).mockResolvedValue({@@ -534,7 +533,6 @@ describe('POST /mcp-host/plugin-workload-sdk/prompt-bridge/v2', () => {],policyRevision: 1,policyHash: 'policy-hash',- maxOutputTokens: null,},})const res = await request(buildApp())diff --git a/control-api/test/services.pluginWorkloadSdkAuthorizer.test.ts b/control-api/test/services.pluginWorkloadSdkAuthorizer.test.tsindex a9ad1a214..0b314e973 100644--- a/control-api/test/services.pluginWorkloadSdkAuthorizer.test.ts+++ b/control-api/test/services.pluginWorkloadSdkAuthorizer.test.ts@@ -599,8 +599,12 @@ describe('authorizePromptBridge', () => {})expect(result).toMatchObject({ok: true,- value: { invocationId: 'inv-1', replay: false, maxOutputTokens: 2048 },+ value: { invocationId: 'inv-1', replay: false },})+ if (!result.ok) throw new Error('expected the authorization to succeed')+ // J8: a legacy grant may still carry maxOutputTokens, but the authorization+ // must not re-advertise it as a policy ceiling — nothing enforced it.+ expect(result.value).not.toHaveProperty('maxOutputTokens')expect(sdkDb.insertInvocation).toHaveBeenCalledOnce()// Issue #348: the per-run leg is inert — no period quota is consumed even// though the grant still carries a legacy maxRequestsPerRun value.@@ -883,6 +887,66 @@ describe('reissuePromptBridgeCredentialTicket', () => {expect(sdkDb.markPluginWorkloadSdkProviderAttemptStatus).not.toHaveBeenCalled()})+ it('denies an oauth-broker fallback that is not the default target (RP-539-009)', async () => {+ // The WRC installs the broker binding for the grant's default target only.+ // A non-default Codex fallback is authorizable but not executable: without+ // this guard it reserved an attempt, burned budget, and died in execution.+ const policy = grant({+ promptTargets: [+ {+ targetRef: 'primary-zai',+ provider: 'zai',+ model: 'glm-4.7',+ credentialSlot: 'zai-api-key',+ },+ {+ targetRef: 'codex-fallback',+ provider: 'codex-subscription',+ model: 'gpt-5.1',+ credentialSlot: '',+ },+ ],+ defaultTargetRef: 'primary-zai',+ })+ const policyHash = sdkDb.hashPromptTargetPolicy(policy)+ vi.mocked(sdkDb.findGrant).mockResolvedValue(policy)+ vi.mocked(sdkDb.getInvocationById).mockResolvedValue(+ invocation({+ promptAuthorization: {+ policyRevision: 1,+ policyHash,+ authorizedTargetRefs: ['primary-zai', 'codex-fallback'],+ },+ })+ )+ vi.mocked(sdkDb.getPluginWorkloadSdkAttemptReceipt).mockResolvedValue({+ invocationId: 'inv-1',+ recipeNamespace: NS,+ recipeName: RECIPE,+ attemptGeneration: 1,+ method: 'promptBridge',+ targetRefs: ['primary-zai', 'codex-fallback'],+ policyRevision: 1,+ policyHash,+ status: 'in_progress',+ startedAt: '2026-06-09T00:00:00.000Z',+ leaseExpiresAt: '2026-06-09T00:01:00.000Z',+ completedAt: null,+ })++ const result = await reissuePromptBridgeCredentialTicket({+ claims: claims(),+ invocationId: 'inv-1',+ targetRef: 'codex-fallback',+ attemptGeneration: 1,+ })++ expect(result).toMatchObject({ ok: false, error: 'target_not_allowed' })+ // The denial precedes the reservation, so no attempt index is consumed.+ expect(sdkDb.reservePluginWorkloadSdkProviderAttempt).not.toHaveBeenCalled()+ expect(sdkDb.registerPluginWorkloadSdkCredentialTicketJti).not.toHaveBeenCalled()+ })+it('fails closed when policy changes or the invocation is terminal', async () => {const policy = twoTargetGrant()authorizedSuffix.policyHash = sdkDb.hashPromptTargetPolicy(policy)diff --git a/control-api/test/services.pluginWorkloadSdkFinalization.test.ts b/control-api/test/services.pluginWorkloadSdkFinalization.test.tsindex bec9015d9..b506e9b99 100644--- a/control-api/test/services.pluginWorkloadSdkFinalization.test.ts+++ b/control-api/test/services.pluginWorkloadSdkFinalization.test.ts@@ -1172,8 +1172,41 @@ describe('Plugin Workload SDK promptBridge finalization', () => {) as never)).rejects.toMatchObject({- code: 'binding_mismatch',- httpStatus: 403,+ // N-19: the persisted `openai` attempt still governs, so the missing+ // credentialSlot is a malformed body (400), not a binding mismatch (403).+ // `replayExistingOutcome` already classified this exact body as 400; the+ // fresh path used to answer 403 only because the binding comparison ran+ // before the persisted-auth-mode assert.+ code: 'invalid_request',+ httpStatus: 400,+ })+ })++ it('classifies the same malformed body identically on the replay path (N-19)', async () => {+ await expect(+ finalizePromptBridgeInTransaction(+ {+ ...inputBase,+ target: {+ ...inputBase.target,+ provider: 'codex-subscription',+ credentialSlot: '',+ },+ status: 'complete',+ usage: {+ llmSecretName: '',+ callerRef: 'scanner',+ fallbackUsed: false,+ attemptCount: 1,+ inputTokens: 1,+ outputTokens: 1,+ },+ },+ dbWithRows([], spendRow({ outcome: 'exact', input_tokens: 1, output_tokens: 1 })) as never+ )+ ).rejects.toMatchObject({+ code: 'invalid_request',+ httpStatus: 400,})})diff --git a/control-ui/app/plugin-workload-sdk/page.tsx b/control-ui/app/plugin-workload-sdk/page.tsxindex 114e0b684..2b05120c1 100644--- a/control-ui/app/plugin-workload-sdk/page.tsx+++ b/control-ui/app/plugin-workload-sdk/page.tsx@@ -678,13 +678,14 @@ function GrantFormModal({setError('')// Edit mode: the upsert is a full-column overwrite, and the form does not expose// the quota fields. Round-trip every quota key from the original grant except the- // deprecated per-run keys (no longer enforced, issue #348) so editing does not- // silently wipe values configured outside this form.+ // deprecated ones (per-run: issue #348; maxOutputTokens: J8 — no longer enforced)+ // so editing does not silently wipe values configured outside this form.const quotaLimits: PluginWorkloadSdkGrantInput['quotaLimits'] = {}if (grant) {const {maxRequestsPerRun: _d1,maxNotificationsPerRun: _d2,+ maxOutputTokens: _d3,...keptQuotaLimits} = grant.quotaLimitsObject.assign(quotaLimits, keptQuotaLimits)diff --git a/control-ui/lib/api.ts b/control-ui/lib/api.tsindex 522130379..7b26a6c74 100644--- a/control-ui/lib/api.ts+++ b/control-ui/lib/api.ts@@ -3658,6 +3658,11 @@ export type PluginWorkloadSdkQuotaLimits = {maxNotificationsPerRun?: numbermaxInvocationsPerMinute?: numbermaxNotificationsPerMinute?: number+ /**+ * @deprecated No longer enforced (J8); the Codex ChatGPT wire discards+ * max_output_tokens, so no layer capped the response by token count. Still+ * returned on legacy grants; never sent by this UI.+ */maxOutputTokens?: number}@@ -3717,10 +3722,13 @@ export type PluginWorkloadSdkGrantInput = {allowedTargetRefs?: string[]allowedUserRefs?: string[]allowedCallers?: string[]- // Input type omits the deprecated per-run keys (issue #348): this UI never- // sends them and the server strips them on write. The response- // PluginWorkloadSdkQuotaLimits still carries them for legacy grants.- quotaLimits?: Omit<PluginWorkloadSdkQuotaLimits, 'maxRequestsPerRun' | 'maxNotificationsPerRun'>+ // Input type omits the deprecated keys (per-run: issue #348; maxOutputTokens:+ // J8): this UI never sends them and the server strips them on write. The+ // response PluginWorkloadSdkQuotaLimits still carries them for legacy grants.+ quotaLimits?: Omit<+ PluginWorkloadSdkQuotaLimits,+ 'maxRequestsPerRun' | 'maxNotificationsPerRun' | 'maxOutputTokens'+ >modelPolicies?: Record<string, PluginWorkloadSdkModelPolicy>promptTargets?: PluginWorkloadSdkPromptTarget[]defaultTargetRef?: stringdiff --git a/control-ui/package-lock.json b/control-ui/package-lock.jsonindex afb8dde75..bc520064e 100644--- a/control-ui/package-lock.json+++ b/control-ui/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-ui",- "version": "0.1.486",+ "version": "0.1.487","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-ui",- "version": "0.1.486",+ "version": "0.1.487","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/llm-providers": "file:../packages/llm-providers",diff --git a/control-ui/package.json b/control-ui/package.jsonindex 9434e6613..6b85b2738 100644--- a/control-ui/package.json+++ b/control-ui/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-ui",- "version": "0.1.486",+ "version": "0.1.487","private": true,"scripts": {"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",diff --git a/docs/crds/workflowrecipe.md b/docs/crds/workflowrecipe.mdindex 753bc1e64..1698a18a8 100644--- a/docs/crds/workflowrecipe.md+++ b/docs/crds/workflowrecipe.md@@ -1374,7 +1374,7 @@ Declaring this block forces an always-on `mcp-host`. Runtime enforcement is addi| Field | Type | Required | Description || -------------------------------------------- | -------- | --------- | --------------------------------------------------------------------------- || `promptBridge.allowedModels` | string[] | No | Max 32. |-| `promptBridge.maxOutputTokens` | integer | No | Min 1. |+| `promptBridge.maxOutputTokens` | integer | No | Min 1. **Deprecated:** accepted but ignored; the Codex ChatGPT wire discards `max_output_tokens`, so nothing capped the response by token count. Removal planned. || `promptBridge.maxRequestsPerRun` | integer | No | Min 1. **Deprecated:** accepted but ignored; platform per-minute rate limits apply. Removal planned. || `promptBridge.maxConcurrentInvocations` | integer | No | Min 1. Runtime default 5. || `promptBridge.maxInvocationsPerMinute` | integer | No | Min 1. Platform default 120 when unset (ENV `CONTROL_API_PLUGIN_SDK_PROMPTBRIDGE_PER_MIN`, issue #348). |diff --git a/docs/testing/optional-playwright-qa-recorder.md b/docs/testing/optional-playwright-qa-recorder.mdindex 6cbfbe647..8af773bf0 100644--- a/docs/testing/optional-playwright-qa-recorder.md+++ b/docs/testing/optional-playwright-qa-recorder.md@@ -99,6 +99,7 @@ prompt/notification journey:```bashE2E_PLUGIN_SDK_WRITE_CONFIRM=1 \+E2E_PLUGIN_SDK_EXPECT_PROVIDER=codex-subscription \CONTROL_UI_BASE_URL=http://127.0.0.1:<random-control-ui-port> \CONTROL_API_BASE_URL=http://127.0.0.1:<random-control-api-port> \EXTERNAL_REST_API_BASE_URL=http://127.0.0.1:<random-external-rest-port> \@@ -107,6 +108,15 @@ KUBECONTEXT=<branch-profile-context> \make test-e2e-plugin-workload-sdk-desktop```+`E2E_PLUGIN_SDK_EXPECT_PROVIDER` is **mandatory and has no default**. It+declares which provider the run is meant to exercise, and the precondition+asserts the live recipe declares exactly that one. Without it the spec used to+accept `openai`, `claude` or `codex-subscription` and skip its Codex assertions+when the recipe was not Codex — so a run against the OpenAI recipe that+`seed-e2e-data.sh` provisions by default went green while proving nothing about+Codex. Declare the provider you intend to evidence; a mismatch now fails the+precondition instead of quietly narrowing the run.+The target sets the opt-in flag only for this spec, requires non-defaultbranch-owned URLs, and compares them with the exact `ports.env` generated forthe selected branch profile. It runs the actual Electron/WebContentsView@@ -114,6 +124,32 @@ journey and fails before building if the profile map is missing or belongs to adifferent context. It does not start Minikube or create grants; thoseprerequisites must already be provided by the T2/T3 profile lane.+### No-grant guard lane++`plugin-workload-sdk-no-grant-guard.spec.ts` is the regression test for the+symptom of issue #533: a Codex recipe whose execution binding is missing must+report `awaiting_policy`, never `validated`. It lives in its own spec and its+own Make target because it is mutually exclusive with the happy path — that one+requires the recipe to reach `validated`, this one requires it not to.++```bash+E2E_PLUGIN_SDK_WRITE_CONFIRM=1 \+E2E_PLUGIN_SDK_NO_GRANT_RECIPE_NAME=<codex-recipe-without-binding> \+E2E_PLUGIN_SDK_NO_GRANT_APP_TITLE=<its-app-title> \+CONTROL_UI_BASE_URL=http://127.0.0.1:<random-control-ui-port> \+CONTROL_API_BASE_URL=http://127.0.0.1:<random-control-api-port> \+EXTERNAL_REST_API_BASE_URL=http://127.0.0.1:<random-external-rest-port> \+RPC_PROXY_BASE_URL=http://127.0.0.1:<random-rpc-port> \+KUBECONTEXT=<branch-profile-context> \+make test-e2e-plugin-workload-sdk-desktop-no-grant+```++Both `E2E_PLUGIN_SDK_NO_GRANT_*` variables are **mandatory**: the spec has no+default recipe and fails loudly when either is missing, and it refuses to run+against the happy path's recipe even if pointed at it. **Provisioning a Codex+recipe with no execution binding is operator work** — the lane will not create+one, and a lane that cannot find its fixture fails rather than skipping.+## Repository isolationThe recorder adds new commands; it does not alter any existing command:diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex b7eb7f138..792528ec0 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.311",+ "version": "0.1.312","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.311",+ "version": "0.1.312","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex c9c428555..857b26e11 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.311",+ "version": "0.1.312","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/pluginWorkloadSdk/metrics.test.ts b/mcp-host/src/pluginWorkloadSdk/metrics.test.tsindex c12e1c0ae..559db16df 100644--- a/mcp-host/src/pluginWorkloadSdk/metrics.test.ts+++ b/mcp-host/src/pluginWorkloadSdk/metrics.test.ts@@ -39,7 +39,6 @@ function makeHandler(recipeName: string, complete?: ReturnType<typeof vi.fn>) {attemptGeneration: 1,policyRevision: 1,policyHash: 'a'.repeat(64),- maxOutputTokens: null,}),reportProviderAttemptStatus: vi.fn().mockResolvedValue(undefined),reportInvocationStatus: vi.fn().mockResolvedValue(undefined),diff --git a/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.test.ts b/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.test.tsindex 9ec3361f7..0ef46fa6f 100644--- a/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.test.ts+++ b/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.test.ts@@ -34,7 +34,6 @@ function authorizedBody(invocationId: string) {attemptGeneration: 1,policyRevision: 2,policyHash: 'a'.repeat(64),- maxOutputTokens: null,}}diff --git a/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.ts b/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.tsindex efeff34e2..86d3147d3 100644--- a/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.ts+++ b/mcp-host/src/pluginWorkloadSdk/promptBridge/controlApiClient.ts@@ -51,7 +51,6 @@ export interface AuthorizePromptBridgeResponse {attemptGeneration: numberpolicyRevision: numberpolicyHash: string- maxOutputTokens: number | null}export interface PluginWorkloadSdkCapabilities {@@ -186,8 +185,7 @@ function isAuthorizePromptBridgeResponse(v: unknown): v is AuthorizePromptBridgeNumber.isInteger(r.policyRevision) &&(r.policyRevision as number) >= 1 &&typeof r.policyHash === 'string' &&- /^[a-f0-9]{64}$/.test(r.policyHash) &&- (r.maxOutputTokens === null || typeof r.maxOutputTokens === 'number')+ /^[a-f0-9]{64}$/.test(r.policyHash))}diff --git a/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.test.ts b/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.test.tsindex f965bd516..0c50bc889 100644--- a/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.test.ts+++ b/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.test.ts@@ -45,7 +45,6 @@ function authorization(overrides: Record<string, unknown> = {}) {attemptGeneration: 1,policyRevision: 7,policyHash: 'a'.repeat(64),- maxOutputTokens: 2048,...overrides,}}@@ -183,7 +182,6 @@ describe('PromptBridgeHandler', () => {expect(complete).toHaveBeenCalledWith(expect.objectContaining({invocationId: 'inv-1',- maxTokens: 2048,targets: [{ target: primary }, { target: fallback }],}))@@ -208,6 +206,18 @@ describe('PromptBridgeHandler', () => {)})+ it('forwards the workload maxTokens verbatim and applies no grant cap (J8)', async () => {+ const { handler, complete } = makeDeps()+ await handler.handle({ ...validBody, maxTokens: 9000 }, 'api')+ expect(complete).toHaveBeenCalledWith(expect.objectContaining({ maxTokens: 9000 }))+ })++ it('sends no maxTokens when the workload asks for none (J8)', async () => {+ const { handler, complete } = makeDeps()+ await handler.handle(validBody, 'api')+ expect(complete.mock.calls[0]?.[0]).toMatchObject({ maxTokens: undefined })+ })+it('preserves metering when the logical terminal acknowledgement is unavailable', async () => {const report = vi.fn().mockRejectedValue(new Error('control-api unavailable'))const onUsage = vi.fn()diff --git a/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.ts b/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.tsindex dc333f53f..7e8108dc6 100644--- a/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.ts+++ b/mcp-host/src/pluginWorkloadSdk/promptBridge/handler.ts@@ -429,7 +429,12 @@ export class PromptBridgeHandler {acknowledgementMode: this.deps.finalizePromptBridge? 'atomic_terminal_finalization': 'per_attempt',- maxTokens: clampMaxTokens(request.maxTokens, authorized.maxOutputTokens),+ // J8: the workload's own maxTokens is the only value on this seam. The+ // grant no longer advertises an output cap, because nothing enforced it:+ // Codex ChatGPT `/codex/responses` rejects max_output_tokens and the+ // proxy omits it, so the clamp bounded only the hashed request shape+ // while the real call ran uncapped.+ maxTokens: request.maxTokens,temperature: request.temperature ?? authorized.modelPolicy?.temperature,timeoutMs: this.deps.promptTimeoutMs,recipeNamespace: this.deps.recipeNamespace,@@ -649,18 +654,3 @@ function unexpectedAuthorizationResponse(): PluginWorkloadError {false)}--/**- * Grant-advertised output cap for providers that honor max_tokens on the wire.- * Codex ChatGPT `/codex/responses` rejects max_output_tokens; the proxy omits- * it. This clamp still bounds the host request used for authorize hashing. It- * is not ChatGPT enforcement.- */-function clampMaxTokens(- requested: number | undefined,- grantCap: number | null-): number | undefined {- if (grantCap === null) return requested- if (requested === undefined) return grantCap- return Math.min(requested, grantCap)-}diff --git a/mcp-host/src/pluginWorkloadSdk/promptBridge/runtime-http.test.ts b/mcp-host/src/pluginWorkloadSdk/promptBridge/runtime-http.test.tsindex 0a0592cc2..a212a45cd 100644--- a/mcp-host/src/pluginWorkloadSdk/promptBridge/runtime-http.test.ts+++ b/mcp-host/src/pluginWorkloadSdk/promptBridge/runtime-http.test.ts@@ -149,7 +149,6 @@ function makeHarness(scenario: Scenario): RuntimeHarness {attemptGeneration: 1,policyRevision: 9,policyHash: POLICY_HASH,- maxOutputTokens: 256,}})const controlApiClient = {diff --git a/mcp-host/src/pluginWorkloadSdk/securityInvariants.test.ts b/mcp-host/src/pluginWorkloadSdk/securityInvariants.test.tsindex 4a9c7d8eb..e3b563a70 100644--- a/mcp-host/src/pluginWorkloadSdk/securityInvariants.test.ts+++ b/mcp-host/src/pluginWorkloadSdk/securityInvariants.test.ts@@ -56,7 +56,6 @@ describe('Plugin Workload SDK — §6.2 response-shape security invariants', ()attemptGeneration: 1,policyRevision: 1,policyHash: 'a'.repeat(64),- maxOutputTokens: null,}),reportProviderAttemptStatus: vi.fn().mockResolvedValue(undefined),reportInvocationStatus: vi.fn().mockResolvedValue(undefined),diff --git a/workflow-recipes/package-lock.json b/workflow-recipes/package-lock.jsonindex ec9ef2bdd..0d2273a9f 100644--- a/workflow-recipes/package-lock.json+++ b/workflow-recipes/package-lock.json@@ -1,12 +1,12 @@{"name": "workload-recipes-controller",- "version": "0.1.328",+ "version": "0.1.329","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "workload-recipes-controller",- "version": "0.1.328",+ "version": "0.1.329","license": "SEE LICENSE IN LICENSE","dependencies": {"@aws-sdk/client-s3": "^3.1009.0",diff --git a/workflow-recipes/package.json b/workflow-recipes/package.jsonindex a7a77cf17..83f779fea 100644--- a/workflow-recipes/package.json+++ b/workflow-recipes/package.json@@ -1,6 +1,6 @@{"name": "workload-recipes-controller",- "version": "0.1.328",+ "version": "0.1.329","description": "Workload Recipes Controller (WRC) - WorkloadRecipe lifecycle management and MCP server interface","main": "dist/main.js","engines": {diff --git a/workflow-recipes/src/types.ts b/workflow-recipes/src/types.tsindex 15293e51e..66dd006ce 100644--- a/workflow-recipes/src/types.ts+++ b/workflow-recipes/src/types.ts@@ -507,6 +507,7 @@ export interface OAuthClientDef {export interface PluginWorkloadSdkSpec {promptBridge?: {allowedModels?: string[]+ /** @deprecated Accepted for compatibility; no longer enforced (J8). The Codex ChatGPT wire discards max_output_tokens, so no layer capped the response by token count. */maxOutputTokens?: number/** @deprecated Accepted for compatibility; no longer enforced (issue #348). Platform per-minute rate limits apply. */maxRequestsPerRun?: number@@ -548,6 +549,7 @@ export interface PluginWorkloadSdkSpec {export interface PluginWorkloadSdkSnippetConfig {promptBridge?: {allowedModels?: string[]+ /** @deprecated Accepted for compatibility; no longer enforced (J8). The Codex ChatGPT wire discards max_output_tokens, so no layer capped the response by token count. */maxOutputTokens?: number}clientNotifications?: {