Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(codex): prepare workflow and subscription journey fixtures
Alfredo Lopezf5f207576c85
diff --git a/deploy/images.json b/deploy/images.jsonindex f1693847f..f11e801b9 100644--- a/deploy/images.json+++ b/deploy/images.json@@ -320,6 +320,15 @@"published": false,"deployed_to_minikube": false},+ {+ "name": "codex-approved-tools-workflow-e2e",+ "path": "tests/e2e/fixtures/codex-subscription/approved-tools-workflow",+ "local_name": "workflow-custom-sdk-e2e",+ "local_tag": "approved-tools-test",+ "rooted": true,+ "published": false,+ "deployed_to_minikube": false+ },{"name": "workflow-custom-sdk-e2e","path": "tests/e2e/fixtures/custom-workflow-coordinator",diff --git a/scripts/e2e/codex-approved-tools-pf-owner.sh b/scripts/e2e/codex-approved-tools-pf-owner.shindex 27a92140b..d697ed426 100755--- a/scripts/e2e/codex-approved-tools-pf-owner.sh+++ b/scripts/e2e/codex-approved-tools-pf-owner.sh@@ -31,7 +31,7 @@ local_port="$6" remote_port="$7""$context" == "${CONTROL_API_REAL_PG_CONTEXT:-}" && "$worktree" == "$WORKTREE" ]] || failcase "$namespace" incontrol-plane) [[ "$service" == codex-llm-proxy && "$remote_port" == 9090 ]] || fail ;;- mcp-server) [[ "$service" =~ ^approved-tools-[a-f0-9]{12}-mcp-(83|150|250)$ && "$remote_port" == 8080 ]] || fail ;;+ mcp-server) [[ "$service" =~ ^approved-tools-[a-f0-9]{12}-mcp-(83|150|250|workflow)$ && "$remote_port" == 8080 ]] || fail ;;*) fail ;;esac[[ "$local_port" =~ ^[0-9]{4,5}$ ]] || fail@@ -40,7 +40,7 @@ esacpid_directory="$(cd -- "${T2_PROFILE_ROOT}/${profile}/pids" && pwd -P)" || fail[[ "${record%/*}" == "$pid_directory" ]] || failfilename="${record##*/}"-[[ "$filename" =~ ^approved-tools-[a-f0-9]{12}-(codex-llm-proxy|approved-tools-[a-f0-9]{12}-mcp-(83|150|250))\.pid$ ]] || fail+[[ "$filename" =~ ^approved-tools-[a-f0-9]{12}-(codex-llm-proxy|approved-tools-[a-f0-9]{12}-mcp-(83|150|250|workflow))\.pid$ ]] || fail[[ "$filename" == *"-${service}.pid" ]] || fail# shellcheck source=scripts/minikube/port-forward-owner.shdiff --git a/scripts/e2e/desktop-login-seed.sh b/scripts/e2e/desktop-login-seed.shnew file mode 100644index 000000000..68d7b6dcc--- /dev/null+++ b/scripts/e2e/desktop-login-seed.sh@@ -0,0 +1,73 @@+#!/usr/bin/env bash+# Shared existing development-only Desktop login seed. No new database privileges.+# Caller supplies CONTEXT, KC, CONTROL_API_NS, ADMIN_USERNAME, and die().+is_branch_scoped_minikube_context() {+ case "$CONTEXT" in+ clerum-codex-*|clerum-cursor-*|clerum-detached-*)+ return 0+ ;;+ *)+ printf '%s' "$CONTEXT" | grep -Eq '^clerum-[a-z0-9][a-z0-9-]*-[0-9a-f]{8}$'+ ;;+ esac+}++is_minikube_context() {+ case "$CONTEXT" in+ clerum-test)+ return 0+ ;;+ *)+ is_branch_scoped_minikube_context+ ;;+ esac+}++is_password_seed_allowed_context() {+ case "$CONTEXT" in+ clerum-test|gke_your-gcp-project_us-central1-a_example-dev)+ return 0+ ;;+ *)+ is_branch_scoped_minikube_context+ ;;+ esac+}++seed_desktop_login_for_user() {+ local email="$1"+ local user_id="$2"+ local credential="$3"+ local updated secret_column secret_time_column++ if [ -z "$user_id" ]; then+ die "Cannot seed desktop login for $email: missing user id"+ fi+ if [ "${#credential}" -lt 8 ] || [ "${#credential}" -gt 256 ]; then+ die "Desktop login credential must be between 8 and 256 characters"+ fi++ secret_column="$(printf '%s%s' 'pass' 'word_hash')"+ secret_time_column="$(printf '%s%s' 'pass' 'word_set_at')"+ updated="$(printf '%s\n' \+ "UPDATE users AS u" \+ " SET ${secret_column} = a.${secret_column}," \+ " ${secret_time_column} = NOW()," \+ " updated_at = NOW()" \+ " FROM control_admin_users AS a" \+ " WHERE u.id = :'user_id'" \+ " AND u.email = :'email'" \+ " AND a.username = :'admin_username'" \+ " RETURNING u.id;" \+ | $KC -n "$CONTROL_API_NS" exec -i deploy/control-postgres -- \+ psql -v ON_ERROR_STOP=1 -U postgres -d profiles \+ -v "user_id=$user_id" \+ -v "email=$email" \+ -v "admin_username=$ADMIN_USERNAME" \+ -t -A)"++ if ! printf '%s' "$updated" | grep -q "$user_id"; then+ die "No user row updated while seeding desktop login for $email"+ fi+}+diff --git a/scripts/e2e/desktop-login-seed.test.mjs b/scripts/e2e/desktop-login-seed.test.mjsnew file mode 100644index 000000000..5eaa2683e--- /dev/null+++ b/scripts/e2e/desktop-login-seed.test.mjs@@ -0,0 +1,76 @@+import assert from 'node:assert/strict'+import { spawnSync } from 'node:child_process'+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'+import test from 'node:test'+import { fileURLToPath } from 'node:url'++const helper = fileURLToPath(new URL('./desktop-login-seed.sh', import.meta.url))++test('shared seed preserves context allowlist and original copy-in-DB behavior without a cluster', () => {+ const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-seed-contract-'))+ const sqlFile = path.join(directory, 'captured.sql')+ const argsFile = path.join(directory, 'captured.args')+ const harness = path.join(directory, 'harness.sh')+ const fakeKubectl = path.join(directory, 'kubectl')+ try {+ fs.writeFileSync(+ fakeKubectl,+ '#!/usr/bin/env bash\nprintf "%s\\n" "$@" > "$CAPTURE_ARGS"\ncat > "$CAPTURE_SQL"\nprintf "%s\\n" "$FIXTURE_USER_ID"\n',+ { mode: 0o700 }+ )+ fs.writeFileSync(+ harness,+ '#!/usr/bin/env bash\nset -euo pipefail\nsource "$1"\nCONTEXT="$2"\nis_password_seed_allowed_context || exit 88\nKC="kubectl --context=${CONTEXT}"\nCONTROL_API_NS=control-plane\nADMIN_USERNAME=fixture-admin\ndie() { exit 89; }\nseed_desktop_login_for_user [email protected] "$FIXTURE_USER_ID" fixture-password\n',+ { mode: 0o700 }+ )+ const env = {+ PATH: `${directory}:/usr/bin:/bin`,+ CAPTURE_ARGS: argsFile,+ CAPTURE_SQL: sqlFile,+ FIXTURE_USER_ID: '00000000-0000-4000-8000-000000000001',+ }+ for (const context of [+ 'clerum-test',+ 'clerum-codex-fixture',+ 'clerum-fix-fixture-1234abcd',+ 'gke_your-gcp-project_us-central1-a_example-dev',+ ]) {+ const result = spawnSync('bash', [harness, helper, context], {+ env,+ timeout: 5000,+ encoding: 'utf8',+ })+ assert.equal(result.status, 0, result.stderr)+ assert.equal(result.stdout, '')+ const args = fs.readFileSync(argsFile, 'utf8').trim().split('\n')+ assert.deepEqual(args.slice(0, 8), [+ `--context=${context}`,+ '-n',+ 'control-plane',+ 'exec',+ '-i',+ 'deploy/control-postgres',+ '--',+ 'psql',+ ])+ assert.ok(args.includes('user_id=00000000-0000-4000-8000-000000000001'))+ assert.ok(args.includes('[email protected]'))+ const sql = fs.readFileSync(sqlFile, 'utf8')+ assert.ok(sql.includes('SET password_hash = a.password_hash'))+ assert.ok(sql.includes("WHERE u.id = :'user_id'"))+ assert.ok(sql.includes("AND u.email = :'email'"))+ assert.ok(sql.includes("AND a.username = :'admin_username'"))+ assert.equal(sql.includes('fixture-password'), false)+ }+ fs.unlinkSync(sqlFile)+ for (const context of ['gke_project_eu_clerum', 'production', 'clerum-dev', 'other']) {+ const result = spawnSync('bash', [harness, helper, context], { env, timeout: 5000 })+ assert.equal(result.status, 88)+ assert.equal(fs.existsSync(sqlFile), false)+ }+ } finally {+ fs.rmSync(directory, { recursive: true, force: true })+ }+})diff --git a/scripts/e2e/prepare-codex-approved-tools.mjs b/scripts/e2e/prepare-codex-approved-tools.mjsindex 1ae699e32..928602b10 100644--- a/scripts/e2e/prepare-codex-approved-tools.mjs+++ b/scripts/e2e/prepare-codex-approved-tools.mjs@@ -9,6 +9,8 @@ const repo = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')const sizes = [83, 150, 250]const fixtureImage = 'clerum/codex-approved-tools-mcp-e2e:test'const proxyImage = 'clerum/codex-approved-tools-proxy-e2e:test'+const workflowImage = 'clerum/workflow-custom-sdk-e2e:approved-tools-test'+const workflowFeatureCheck = `process.stdout.write(JSON.stringify(process.env.WRC_ENABLE_CUSTOM_COORDINATOR_IMAGE === 'true' && process.env.WRC_REQUIRE_COORDINATOR_IMAGE_DIGEST === 'false' && (process.env.WRC_ALLOWED_COORDINATOR_IMAGE_PREFIXES || '').split(',').some(prefix => prefix.trim() && '${workflowImage}'.startsWith(prefix.trim()))))`const proxyFlags = ['CODEX_APPROVED_TOOLS_TEST_ONLY','CODEX_APPROVED_TOOLS_MINIKUBE_PROFILE',@@ -23,20 +25,129 @@ export function makeScenarios(run, ports, probePort) {[...ports, probePort].some(p => !Number.isInteger(p) || p < 1024 || p > 65535))throw new Error('Invalid fixture ports')- return sizes.map((catalogSize, index) => ({+ return sizes.map((catalogSize, index) =>+ scenarioMetadata(run, String(catalogSize), catalogSize, ports[index], probePort)+ )+}++function scenarioMetadata(run, label, catalogSize, port, probePort) {+ return {catalogSize,- runId: `${run}-${catalogSize}`,- agentName: `${run}-agent-${catalogSize}`,- agentDisplayName: `Codex tools ${catalogSize} ${run}`,- contextName: `${run}-context-${catalogSize}`,- connectorName: `${run}-mcp-${catalogSize}`,- subscriptionName: `Codex fixture ${catalogSize} ${run}`,- connectionKey: `${run}-grant-${catalogSize}`,+ runId: `${run}-${label}`,+ agentName: `${run}-agent-${label}`,+ agentDisplayName: `Codex tools ${label} ${run}`,+ contextName: `${run}-context-${label}`,+ connectorName: `${run}-mcp-${label}`,+ subscriptionName: `Codex fixture ${label} ${run}`,+ connectionKey: `${run}-grant-${label}`,modelName: 'gpt-5.3-codex',modelLabel: 'Codex isolated tool test',- fixtureUrl: `http://127.0.0.1:${ports[index]}`,+ fixtureUrl: `http://127.0.0.1:${port}`,upstreamEvidenceUrl: `http://127.0.0.1:${probePort}`,- }))+ }+}++export function makeWorkflowScenario(run, port, probePort) {+ if (+ !/^approved-tools-[a-f0-9]{12}$/.test(run) ||+ port === probePort ||+ [port, probePort].some(p => !Number.isInteger(p) || p < 1024 || p > 65535)+ )+ throw new Error('Invalid workflow fixture identity or ports')+ return {+ ...scenarioMetadata(run, 'workflow', 83, port, probePort),+ workflowName: `${run}-recipe`,+ workflowNamespace: 'sandbox-recipes',+ }+}++export function makeWorkflowResources(scenario) {+ const labels = {+ 'evenfire.ai/e2e-suite': 'codex-approved-tools',+ 'evenfire.ai/e2e-run': scenario.runId,+ }+ // Output scope is the parent recipe for both its runtime and triggered child+ // runs. The component selector excludes every other pod in that lineage.+ const coordinator = {+ matchLabels: {+ 'clerum.io/workflow-output-scope': scenario.workflowName,+ 'clerum.io/component': 'workflow-coordinator',+ },+ }+ const backend = { matchLabels: { 'clerum.io/mcpserver': scenario.connectorName } }+ const namespace = name => ({ matchLabels: { 'kubernetes.io/metadata.name': name } })+ return [+ {+ apiVersion: 'clerum.io/v1alpha1',+ kind: 'WorkflowRecipe',+ metadata: {+ name: scenario.workflowName,+ namespace: scenario.workflowNamespace,+ labels,+ annotations: { 'clerum.io/codex-connection-ref': scenario.connectionKey },+ },+ spec: {+ coordinatorImage: workflowImage,+ // WRC requires a broker agent for declared MCP dependencies. The fixture+ // coordinator never requests a model; the binding remains explicit.+ agent: { provider: 'codex-subscription', model: scenario.modelName },+ // Actual MCP dependency makes WRC defer the parent until a triggered run;+ // a bare id-only custom step would otherwise start eagerly.+ steps: [{ id: 'receipt', mcpServers: ['receipt'] }],+ mcpServers: [+ {+ id: 'receipt',+ endpoint: `http://${scenario.connectorName}.mcp-server.svc.cluster.local:8080/mcp`,+ },+ ],+ output: { destination: 'pvc', format: 'json' },+ triggers: { onDemand: { requiresApproval: true, allowedActors: ['user'] } },+ },+ },+ {+ apiVersion: 'networking.k8s.io/v1',+ kind: 'NetworkPolicy',+ metadata: {+ name: `${scenario.workflowName}-receipt-egress`,+ namespace: scenario.workflowNamespace,+ labels,+ },+ spec: {+ podSelector: coordinator,+ policyTypes: ['Egress'],+ egress: [+ {+ to: [{ namespaceSelector: namespace('mcp-server'), podSelector: backend }],+ ports: [{ protocol: 'TCP', port: 8080 }],+ },+ ],+ },+ },+ {+ apiVersion: 'networking.k8s.io/v1',+ kind: 'NetworkPolicy',+ metadata: {+ name: `${scenario.workflowName}-receipt-ingress`,+ namespace: 'mcp-server',+ labels,+ },+ spec: {+ podSelector: backend,+ policyTypes: ['Ingress'],+ ingress: [+ {+ from: [+ {+ namespaceSelector: namespace(scenario.workflowNamespace),+ podSelector: coordinator,+ },+ ],+ ports: [{ protocol: 'TCP', port: 8080 }],+ },+ ],+ },+ },+ ]}export function makeResources(scenarios) {@@ -61,6 +172,19 @@ export function makeResources(scenarios) {contextRef: s.contextName,model: { provider: 'codex-subscription', name: s.modelName, connectionRef: 'unassigned' },channels: [],+ ...(s.workflowName+ ? {+ workflowControl: {+ scopes: [+ 'workflow:list',+ 'workflow:read',+ 'workflow:trigger',+ 'workflow:approval:resolve',+ 'workflow:approval:decide',+ ],+ },+ }+ : {}),},},{@@ -212,7 +336,7 @@ export function validateOwnerArgs(args, recording, profile, pidDirectory) {context !== profile ||worktree !== repo ||!['control-plane', 'mcp-server'].includes(namespace) ||- !/^(codex-llm-proxy|approved-tools-[a-f0-9]{12}-mcp-(83|150|250))$/.test(service)+ !/^(codex-llm-proxy|approved-tools-[a-f0-9]{12}-mcp-(83|150|250|workflow))$/.test(service))throw new Error('Invalid owner binding')if (@@ -224,7 +348,7 @@ export function validateOwnerArgs(args, recording, profile, pidDirectory) {throw new Error('Invalid owner port')if (path.dirname(record) !== pidDirectory ||- !/^approved-tools-[a-f0-9]{12}-(codex-llm-proxy|approved-tools-[a-f0-9]{12}-mcp-(83|150|250))\.pid$/.test(+ !/^approved-tools-[a-f0-9]{12}-(codex-llm-proxy|approved-tools-[a-f0-9]{12}-mcp-(83|150|250|workflow))\.pid$/.test(path.basename(record)))@@ -262,7 +386,7 @@ export function validateKubectlArgs(args, profile) {(verb === 'wait' && resource === '--for=create')) &&((namespace === 'control-plane' && operation[4] === 'deployment/codex-llm-proxy') ||(namespace === 'mcp-server' &&- /^deployment\/approved-tools-[a-f0-9]{12}-mcp-(83|150|250)$/.test(operation[4])))+ /^deployment\/approved-tools-[a-f0-9]{12}-mcp-(83|150|250|workflow)$/.test(operation[4]))))return argsif (@@ -326,6 +450,8 @@ export function validateKubectlArgs(args, profile) {operation[5] === 'node' &&operation[6] === '-e') {+ if (resource === 'deployment/workflow-recipes' && operation[7] === workflowFeatureCheck)+ return argsconst keys =resource === 'deployment/control-api'? ['CONTROL_API_CODEX_SUBSCRIPTION_ENABLED', 'CODEX_LLM_PROXY_EXECUTION_ENABLED']@@ -635,8 +761,15 @@ async function main() {'TEST_ADMIN_PASSWORD','TEST_USER_EMAIL','TEST_USER_PASSWORD',+ 'APPROVED_TOOLS_UNAUTHORIZED_EMAIL',+ 'APPROVED_TOOLS_UNAUTHORIZED_PASSWORD',])required(name)+ if (+ required('TEST_USER_EMAIL').trim().toLowerCase() ===+ required('APPROVED_TOOLS_UNAUTHORIZED_EMAIL').trim().toLowerCase()+ )+ throw new Error('Unauthorized login fixture must be a distinct fresh identity')// The supported Minikube overlays enable these already. Refuse a stale or// differently configured runtime; fixture setup must not weaken feature gates.for (const [deploymentName, keys] of [@@ -666,14 +799,31 @@ async function main() {)if (hostFlags.data?.MCP_HOST_CODEX_SUBSCRIPTION_ENABLED !== 'true')throw new Error('Host Codex feature gate is not enabled by the Minikube overlay')+ if (+ kubectl([+ '-n',+ 'control-plane',+ 'exec',+ 'deployment/workflow-recipes',+ '--',+ 'node',+ '-e',+ workflowFeatureCheck,+ ]).trim() !== 'true'+ )+ throw new Error(+ 'Workflow fixture image is not permitted by the running Minikube coordinator policy'+ )const run = 'approved-tools-' + randomBytes(6).toString('hex')const ports = []- while (ports.length < 4) {+ while (ports.length < 5) {const port = await freePort()if (!ports.includes(port)) ports.push(port)}- const scenarios = makeScenarios(run, ports.slice(0, 3), ports[3])- const resources = makeResources(scenarios)+ const scenarios = makeScenarios(run, ports.slice(0, 3), ports[4])+ const workflowScenario = makeWorkflowScenario(run, ports[3], ports[4])+ const allScenarios = [...scenarios, workflowScenario]+ const resources = [...makeResources(allScenarios), ...makeWorkflowResources(workflowScenario)]const proposed = { apiVersion: 'v1', kind: 'List', items: resources }const validated = JSON.parse(kubectl(['create', '--dry-run=server', '-f', '-', '-o', 'json'], {@@ -705,6 +855,7 @@ async function main() {head,run,scenarios,+ workflowScenario,forwards: [],resources: resources.map(r => ({kind: r.kind,@@ -809,12 +960,12 @@ async function main() {await startForward('control-plane','codex-llm-proxy',- ports[3],+ ports[4],9090,`${scenarios[0].upstreamEvidenceUrl}/approved-tools/evidence`,value => Array.isArray(value.requests))- for (const [index, scenario] of scenarios.entries()) {+ for (const [index, scenario] of allScenarios.entries()) {kubectl(['-n',@@ -852,12 +1003,15 @@ async function main() {const seedInput = {mode: 'deterministic',profile,- scenarios,+ scenarios: allScenarios,+ workflowScenario,userDisplayName: run,adminUsername: required('TEST_ADMIN_USERNAME'),adminPassword: required('TEST_ADMIN_PASSWORD'),userEmail: required('TEST_USER_EMAIL'),userPassword: required('TEST_USER_PASSWORD'),+ unauthorizedEmail: required('APPROVED_TOOLS_UNAUTHORIZED_EMAIL'),+ unauthorizedPassword: required('APPROVED_TOOLS_UNAUTHORIZED_PASSWORD'),}kubectl([@@ -879,10 +1033,16 @@ async function main() {JSON.stringify(scenarios, null, 2) + '\n',{ flag: 'wx', mode: 0o600 })+ fs.writeFileSync(+ path.join(evidence, 'workflow-scenario.json'),+ JSON.stringify(workflowScenario, null, 2) + '\n',+ { flag: 'wx', mode: 0o600 }+ )state.ready = truesave()if (action === 'run') {process.env.APPROVED_TOOLS_SCENARIOS = JSON.stringify(scenarios)+ process.env.APPROVED_TOOLS_WORKFLOW_SCENARIO = JSON.stringify(workflowScenario)command('runner', [], {timeout: 25 * 60_000,inherit: true,@@ -890,7 +1050,7 @@ async function main() {await restore()}process.stdout.write(- `${JSON.stringify({ fixture: 'ready', mode: 'deterministic', scenariosFile: path.join(evidence, 'scenarios.json'), restored: state.restored })}\n`+ `${JSON.stringify({ fixture: 'ready', mode: 'deterministic', scenariosFile: path.join(evidence, 'scenarios.json'), workflowScenarioFile: path.join(evidence, 'workflow-scenario.json'), restored: state.restored })}\n`)} catch (error) {try {diff --git a/scripts/e2e/prepare-codex-approved-tools.test.mjs b/scripts/e2e/prepare-codex-approved-tools.test.mjsindex ba950feca..87d83c8db 100644--- a/scripts/e2e/prepare-codex-approved-tools.test.mjs+++ b/scripts/e2e/prepare-codex-approved-tools.test.mjs@@ -6,6 +6,7 @@ import path from 'node:path'import test from 'node:test'import {IMAGES,+ localRef,minikubeVerifyRefs,publishedImages,pullInGhcrMode,@@ -14,6 +15,8 @@ import {assertResourceRoundTrip,makeResources,makeScenarios,+ makeWorkflowResources,+ makeWorkflowScenario,openOwnedFile,readOwnedDescriptor,readOwnedFile,@@ -26,8 +29,13 @@ import {const scenarios = makeScenarios('approved-tools-a1b2c3d4e5f6', [43101, 43102, 43103], 43104)test('explicit tools fixtures never enter default publish, acquisition or verification sets', () => {- for (const name of ['codex-approved-tools-mcp-e2e', 'codex-approved-tools-proxy-e2e']) {- assert.ok(IMAGES.some(image => image.name === name))+ for (const name of [+ 'codex-approved-tools-mcp-e2e',+ 'codex-approved-tools-proxy-e2e',+ 'codex-approved-tools-workflow-e2e',+ ]) {+ const image = IMAGES.find(image => image.name === name)+ assert.ok(image)assert.equal(publishedImages().some(image => image.name === name),false@@ -41,14 +49,72 @@ test('explicit tools fixtures never enter default publish, acquisition or verifi{ mode: 'ghcr', tag: 'test' },{ mode: 'ghcr', tag: 'test', includeE2eFixtures: true },]) {- assert.equal(- minikubeVerifyRefs(options).some(ref => ref.includes(name)),- false- )+ assert.equal(minikubeVerifyRefs(options).includes(localRef(image)), false)}}})+test('fourth workflow scenario has separate backend, explicit grant and two retained approval gates', () => {+ const workflow = makeWorkflowScenario('approved-tools-a1b2c3d4e5f6', 43105, 43104)+ for (const field of [+ 'runId',+ 'agentName',+ 'contextName',+ 'connectorName',+ 'connectionKey',+ 'fixtureUrl',+ ])+ assert.ok(scenarios.every(s => s[field] !== workflow[field]))+ assert.equal(workflow.catalogSize, 83)+ const host = makeResources([workflow]).find(r => r.kind === 'Host')+ assert.equal(host.spec.model.connectionRef, 'unassigned')+ assert.equal(host.spec.approval, undefined)+ assert.ok(host.spec.workflowControl.scopes.includes('workflow:trigger'))+ const [recipe, egress, ingress] = makeWorkflowResources(workflow)+ assert.deepEqual(recipe.spec.steps, [{ id: 'receipt', mcpServers: ['receipt'] }])+ assert.deepEqual(recipe.spec.triggers.onDemand, {+ requiresApproval: true,+ allowedActors: ['user'],+ })+ assert.deepEqual(recipe.spec.agent, { provider: 'codex-subscription', model: workflow.modelName })+ assert.equal(+ recipe.metadata.annotations['clerum.io/codex-connection-ref'],+ workflow.connectionKey+ )+ assert.equal(recipe.spec.coordinatorImage, 'clerum/workflow-custom-sdk-e2e:approved-tools-test')+ assert.deepEqual(recipe.spec.output, { destination: 'pvc', format: 'json' })+ assert.deepEqual(recipe.spec.mcpServers, [+ {+ id: 'receipt',+ endpoint: `http://${workflow.connectorName}.mcp-server.svc.cluster.local:8080/mcp`,+ },+ ])+ assert.deepEqual(egress.spec.podSelector, {+ matchLabels: {+ 'clerum.io/workflow-output-scope': workflow.workflowName,+ 'clerum.io/component': 'workflow-coordinator',+ },+ })+ assert.equal(egress.spec.egress.length, 1)+ assert.deepEqual(egress.spec.egress[0].to, [+ {+ namespaceSelector: { matchLabels: { 'kubernetes.io/metadata.name': 'mcp-server' } },+ podSelector: { matchLabels: { 'clerum.io/mcpserver': workflow.connectorName } },+ },+ ])+ assert.deepEqual(egress.spec.egress[0].ports, [{ protocol: 'TCP', port: 8080 }])+ assert.deepEqual(ingress.spec.podSelector, egress.spec.egress[0].to[0].podSelector)+ assert.deepEqual(ingress.spec.ingress[0].from, [+ {+ namespaceSelector: {+ matchLabels: { 'kubernetes.io/metadata.name': workflow.workflowNamespace },+ },+ podSelector: egress.spec.podSelector,+ },+ ])+ assert.deepEqual(ingress.spec.ingress[0].ports, [{ protocol: 'TCP', port: 8080 }])+})+test('all three isolated catalogs start without connector grants or subscription bindings', () => {assert.deepEqual(scenarios.map(s => s.catalogSize),@@ -266,6 +332,25 @@ test('fixed ownership CLI rejects invalid operations and bindings without touchitry {// The canonical library's valid missing-record cleanup is a harmless no-op.assert.equal(run('cleanup').status, 0)+ const workflowService = 'approved-tools-a1b2c3d4e5f6-mcp-workflow'+ const workflowRecord = path.join(+ canonicalPidDirectory,+ `approved-tools-a1b2c3d4e5f6-${workflowService}.pid`+ )+ const workflowArgs = [+ workflowRecord,+ profile,+ profile,+ worktree,+ 'mcp-server',+ workflowService,+ '43105',+ '8080',+ ]+ assert.equal(run('cleanup', workflowArgs).status, 0)+ const invalidWorkflow = [...workflowArgs]+ invalidWorkflow[5] += '-other'+ assert.equal(run('cleanup', invalidWorkflow).status, 2)for (const operation of ['unknown', 'cleanup;echo', '--help', 'pf_owner_cleanup_record'])assert.equal(run(operation).status, 2)for (const [index, value] of [diff --git a/scripts/e2e/run-codex-approved-tools.mjs b/scripts/e2e/run-codex-approved-tools.mjsindex 49f822633..5177d90ce 100644--- a/scripts/e2e/run-codex-approved-tools.mjs+++ b/scripts/e2e/run-codex-approved-tools.mjs@@ -160,6 +160,7 @@ function main() {`tests/e2e/playwright/desktop/${specFile}`,'tests/e2e/playwright/helpers/approved-tools-scenarios.ts','tests/e2e/playwright/helpers/approved-tools-workflow.ts',+ 'tests/e2e/playwright/helpers/approved-tools-subscription.ts',],{ cwd: repo, env, stdio: 'inherit', timeout: 30_000 })diff --git a/scripts/e2e/seed-e2e-data.sh b/scripts/e2e/seed-e2e-data.shindex 7a0b8f764..6c9110a46 100755--- a/scripts/e2e/seed-e2e-data.sh+++ b/scripts/e2e/seed-e2e-data.sh@@ -192,75 +192,8 @@ if [ -z "$PLUGIN_SDK_DEMO_CREDENTIAL_SLOT" ]; thenesacfi-is_branch_scoped_minikube_context() {- case "$CONTEXT" in- clerum-codex-*|clerum-cursor-*|clerum-detached-*)- return 0- ;;- *)- printf '%s' "$CONTEXT" | grep -Eq '^clerum-[a-z0-9][a-z0-9-]*-[0-9a-f]{8}$'- ;;- esac-}--is_minikube_context() {- case "$CONTEXT" in- clerum-test)- return 0- ;;- *)- is_branch_scoped_minikube_context- ;;- esac-}--is_password_seed_allowed_context() {- case "$CONTEXT" in- clerum-test|gke_your-gcp-project_us-central1-a_example-dev)- return 0- ;;- *)- is_branch_scoped_minikube_context- ;;- esac-}--seed_desktop_login_for_user() {- local email="$1"- local user_id="$2"- local credential="$3"- local updated secret_column secret_time_column-- if [ -z "$user_id" ]; then- die "Cannot seed desktop login for $email: missing user id"- fi- if [ "${#credential}" -lt 8 ] || [ "${#credential}" -gt 256 ]; then- die "Desktop login credential must be between 8 and 256 characters"- fi-- secret_column="$(printf '%s%s' 'pass' 'word_hash')"- secret_time_column="$(printf '%s%s' 'pass' 'word_set_at')"- updated="$(printf '%s\n' \- "UPDATE users AS u" \- " SET ${secret_column} = a.${secret_column}," \- " ${secret_time_column} = NOW()," \- " updated_at = NOW()" \- " FROM control_admin_users AS a" \- " WHERE u.id = :'user_id'" \- " AND u.email = :'email'" \- " AND a.username = :'admin_username'" \- " RETURNING u.id;" \- | $KC -n "$CONTROL_API_NS" exec -i deploy/control-postgres -- \- psql -v ON_ERROR_STOP=1 -U postgres -d profiles \- -v "user_id=$user_id" \- -v "email=$email" \- -v "admin_username=$ADMIN_USERNAME" \- -t -A)"-- if ! printf '%s' "$updated" | grep -q "$user_id"; then- die "No user row updated while seeding desktop login for $email"- fi-}+# shellcheck source=scripts/e2e/desktop-login-seed.sh+source "${SCRIPT_DIR}/desktop-login-seed.sh"seed_desktop_login_if_enabled() {local enabled="$SEED_DESKTOP_LOGIN"diff --git a/scripts/minikube/build-images.sh b/scripts/minikube/build-images.shindex 371ceb038..74a828e11 100755--- a/scripts/minikube/build-images.sh+++ b/scripts/minikube/build-images.sh@@ -361,6 +361,10 @@ if [ "$ONLY_SVC" = codex-approved-tools-proxy-e2e ]; thenALL_IMAGES+=("clerum/codex-approved-tools-proxy-e2e:test")KNOWN_BUILD_NAMES+=(codex-approved-tools-proxy-e2e)fi+if [ "$ONLY_SVC" = codex-approved-tools-workflow-e2e ]; then+ ALL_IMAGES+=("clerum/workflow-custom-sdk-e2e:approved-tools-test")+ KNOWN_BUILD_NAMES+=(codex-approved-tools-workflow-e2e)+fiif [ "$MINIKUBE_BUILD_DESKTOP_IMAGE" = "true" ]; thenALL_IMAGES+=("clerum/mcp-host-desktop:test")@@ -955,6 +959,9 @@ build_image() {# the same profile lease. The test image never replaces that tag.docker_args+=(--build-arg CODEX_PROXY_IMAGE=clerum/codex-llm-proxy:test)fi+ if [ "$name" = codex-approved-tools-workflow-e2e ]; then+ docker_args+=(--build-arg WORKFLOW_CUSTOM_SDK_IMAGE=clerum/workflow-custom-sdk-e2e:test)+ filocal build_cmd=(docker build "${docker_args[@]}" "$dir")local build_status=0docker_cli_run_public "build-${name}" "$MINIKUBE_DOCKER_BUILD_TIMEOUT_SECONDS" \@@ -1164,6 +1171,11 @@ if [ "$ONLY_SVC" = codex-approved-tools-proxy-e2e ]; thenclerum/codex-approved-tools-proxy-e2e:test \"${PROJECT_DIR}/tests/e2e/fixtures/codex-subscription/approved-tools-proxy/Dockerfile"fi+if [ "$ONLY_SVC" = codex-approved-tools-workflow-e2e ]; then+ build_image codex-approved-tools-workflow-e2e "${PROJECT_DIR}" \+ clerum/workflow-custom-sdk-e2e:approved-tools-test \+ "${PROJECT_DIR}/tests/e2e/fixtures/codex-subscription/approved-tools-workflow/Dockerfile"+fibuild_image "webhook-gateway" \"${PROJECT_DIR}/webhook-gateway" \diff --git a/scripts/tests/test-codex-subscription-t0.sh b/scripts/tests/test-codex-subscription-t0.shindex db74e5b9b..2f2c2fae1 100755--- a/scripts/tests/test-codex-subscription-t0.sh+++ b/scripts/tests/test-codex-subscription-t0.sh@@ -199,7 +199,8 @@ run_group "codex-catalog-projection" "packages/codex-catalog-projection" "index.run_node_group "approved-tools-fixtures-and-runner" \"tests/e2e/fixtures/codex-subscription/approved-tools/server.test.mjs" \"scripts/e2e/prepare-codex-approved-tools.test.mjs" \- "scripts/e2e/run-codex-approved-tools.test.mjs"+ "scripts/e2e/run-codex-approved-tools.test.mjs" \+ "tests/e2e/fixtures/codex-subscription/approved-tools-workflow/index.test.mjs"run_group "control-api" "control-api" \@@ -239,6 +240,7 @@ run_group "codex-llm-proxy" "codex-llm-proxy" \run_group "mcp-host" "mcp-host" \"src/capabilities/toolCatalogTools.test.ts" \+ "src/core/orchestration/__tests__/approvedToolsLifecycle.integration.test.ts" \"src/core/orchestration/__tests__/toolUseLoop.spillover.test.ts" \"src/mcp/__tests__/managerDelimiterDispatch.test.ts" \"src/logger.test.ts" \diff --git a/scripts/tests/test-images-manifest.sh b/scripts/tests/test-images-manifest.shindex 9caef90eb..f007fc01f 100755--- a/scripts/tests/test-images-manifest.sh+++ b/scripts/tests/test-images-manifest.sh@@ -212,7 +212,7 @@ assert_unpublished_images_are_exactly_the_known_fixtures() {# otherwise was missing its Accept header). doc-generator-mcp used to be the# third; it has no manifest row at all now (see# assert_doc_generator_mcp_has_been_removed_from_the_image_system).- local want="codex-approved-tools-mcp-e2e,codex-approved-tools-proxy-e2e,workflow-custom-sdk-e2e,workflow-plugin-sdk-e2e"+ local want="codex-approved-tools-mcp-e2e,codex-approved-tools-proxy-e2e,codex-approved-tools-workflow-e2e,workflow-custom-sdk-e2e,workflow-plugin-sdk-e2e"if [ "$got" = "$want" ]; thenpass "the unpublished set is exactly the known fixtures"elsediff --git a/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.ts b/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.tsindex 830efe8ed..8d1ebab6d 100644--- a/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.ts+++ b/tests/e2e/playwright/desktop/codex-subscription-approved-tools.spec.ts@@ -17,6 +17,7 @@ import {required,scenarios,} from '../helpers/approved-tools-scenarios'+import { prepareSubscriptionVisible } from '../helpers/approved-tools-subscription'import { workflowJourney } from '../helpers/approved-tools-workflow'import { launchDesktopApp } from '../helpers/launch-desktop'import { loginControlUiVisible } from '../helpers/visible-login'@@ -147,6 +148,7 @@ for (const scenario of cases) {expect((await readEvidence(scenario)).calls).toEqual([])await page.goto('/')await loginControlUiVisible(page)+ scenario.connectionKey = await prepareSubscriptionVisible(page, scenario)await new ControlUiShell(page).openAgents()await new AgentListPage(page).openNamed(scenario.agentName)await expect(page.getByText(`Agent: ${scenario.agentName}`, { exact: true })).toBeVisible()diff --git a/tests/e2e/playwright/helpers/approved-tools-scenarios.ts b/tests/e2e/playwright/helpers/approved-tools-scenarios.tsindex 86b3a5cdb..ba603b28f 100644--- a/tests/e2e/playwright/helpers/approved-tools-scenarios.ts+++ b/tests/e2e/playwright/helpers/approved-tools-scenarios.ts@@ -90,6 +90,11 @@ export function scenarios(): Scenario[] {if (new Set(rows.map(row => row[key])).size !== 3)throw new Error(`Scenarios must isolate ${key}`)}+ if (+ process.env.APPROVED_TOOLS_UPSTREAM_MODE === 'deterministic' &&+ new Set(rows.map(row => row.subscriptionName)).size !== 3+ )+ throw new Error('Deterministic UI-created subscriptions require unique names')return rows.sort((a, b) => a.catalogSize - b.catalogSize)}export async function readEvidence(scenario: Scenario): Promise<Evidence> {diff --git a/tests/e2e/playwright/helpers/approved-tools-subscription.ts b/tests/e2e/playwright/helpers/approved-tools-subscription.tsnew file mode 100644index 000000000..59a42e6ef--- /dev/null+++ b/tests/e2e/playwright/helpers/approved-tools-subscription.ts@@ -0,0 +1,78 @@+/**+ * Only the external OAuth verification page is simulated. Grant creation,+ * encrypted device state, polling, catalog publication and assignment all use+ * real Control API routes. The isolated OAuth provider has preapproved consent.+ * Real-account mode uses the explicitly prepared existing grant unchanged.+ */+import { type Page, type Route, expect } from '@playwright/test'+import { ControlUiShell, SecretsLlmSubscriptionsPage } from '../pages/codex-subscription'+import { type Scenario, required } from './approved-tools-scenarios'++const verificationUrl = 'https://auth.openai.com/codex/device'++export async function prepareSubscriptionVisible(page: Page, scenario: Scenario): Promise<string> {+ if (required('APPROVED_TOOLS_UPSTREAM_MODE') === 'real') {+ if (!scenario.connectionKey || scenario.connectionKey === 'unassigned')+ throw new Error('Real mode requires an existing approved subscription grant')+ return scenario.connectionKey+ }+ await new ControlUiShell(page).openSecretsLlmSubscriptions()+ const subscriptions = new SecretsLlmSubscriptionsPage(page)+ const connectionKey = await subscriptions.createGrant(scenario.subscriptionName)+ expect(connectionKey).not.toBe('unassigned')+ const context = page.context()+ const externalConsent = async (route: Route) => {+ expect(route.request().url()).toBe(verificationUrl)+ await route.fulfill({+ status: 200,+ contentType: 'text/html',+ body: '<!doctype html><title>Isolated OAuth consent</title><h1>Isolated OAuth consent</h1><p>Consent belongs to the synthetic account provisioned for this local test.</p>',+ })+ }+ // Exact external URL only; no Control UI/API route or browser session is mocked.+ await context.route(verificationUrl, externalConsent)+ let popup: Page | undefined+ try {+ const popupOpened = context.waitForEvent('page')+ const started = page.waitForResponse(+ response =>+ new URL(response.url()).pathname ===+ `/api/v1/admin/llm/providers/codex-subscription/connections/${connectionKey}/device/start` &&+ response.request().method() === 'POST'+ )+ const connected = page.waitForResponse(+ async response => {+ if (+ new URL(response.url()).pathname !==+ `/api/v1/admin/llm/providers/codex-subscription/connections/${connectionKey}/device/poll` ||+ response.request().method() !== 'GET' ||+ !response.ok()+ )+ return false+ return (await response.json()).status === 'connected'+ },+ { timeout: 120_000 }+ )+ await page+ .getByRole('dialog')+ .getByRole('button', { name: 'Sign in with ChatGPT', exact: true })+ .click()+ popup = await popupOpened+ await expect(popup).toHaveURL(verificationUrl)+ await expect(+ popup.getByRole('heading', { name: 'Isolated OAuth consent', exact: true })+ ).toBeVisible()+ expect((await started).ok()).toBe(true)+ const result = await (await connected).json()+ expect(result.connection).toMatchObject({ connectionKey, catalogStatus: 'ready' })+ await expect(page.getByTestId('codex-device-code')).toHaveCount(0)+ await expect(page.getByLabel(scenario.modelName, { exact: true })).toBeVisible()+ await expect(page.getByLabel(scenario.modelName, { exact: true })).toBeChecked()+ await subscriptions.closeConnectModal()+ await expect(subscriptions.grantRow(scenario.subscriptionName)).toBeVisible()+ return connectionKey+ } finally {+ if (popup && !popup.isClosed()) await popup.close()+ await context.unroute(verificationUrl, externalConsent)+ }+}diff --git a/tests/e2e/playwright/helpers/approved-tools-workflow.ts b/tests/e2e/playwright/helpers/approved-tools-workflow.tsindex 0076776e1..884c550e0 100644--- a/tests/e2e/playwright/helpers/approved-tools-workflow.ts+++ b/tests/e2e/playwright/helpers/approved-tools-workflow.ts@@ -14,6 +14,7 @@ import {required,scenarios,} from './approved-tools-scenarios'+import { prepareSubscriptionVisible } from './approved-tools-subscription'import { launchDesktopApp } from './launch-desktop'import { loginControlUiVisible } from './visible-login'@@ -56,7 +57,9 @@ function workflowScenario(): WorkflowScenario {row =>row.agentName === value.agentName ||row.runId === value.runId ||- row.fixtureUrl === value.fixtureUrl+ row.fixtureUrl === value.fixtureUrl ||+ (required('APPROVED_TOOLS_UPSTREAM_MODE') === 'deterministic' &&+ row.subscriptionName === value.subscriptionName)))throw new Error('Workflow fixture must be isolated from receipt scenarios')@@ -70,6 +73,7 @@ export async function workflowJourney(page: Page, testInfo: TestInfo) {await test.step('Select the isolated workflow agent and bind its subscription visibly', async () => {await page.goto('/')await loginControlUiVisible(page)+ scenario.connectionKey = await prepareSubscriptionVisible(page, scenario)await new ControlUiShell(page).openAgents()await new AgentListPage(page).openNamed(scenario.agentName)const model = new AgentModelPage(page)diff --git a/tests/e2e/playwright/package-lock.json b/tests/e2e/playwright/package-lock.jsonindex 41a19ce63..872047f7f 100644--- a/tests/e2e/playwright/package-lock.json+++ b/tests/e2e/playwright/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-playwright-tests",- "version": "0.1.43",+ "version": "0.1.44","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-playwright-tests",- "version": "0.1.43",+ "version": "0.1.44","devDependencies": {"@playwright/test": "^1.50.0","@types/node": "^22.0.0",diff --git a/tests/e2e/playwright/package.json b/tests/e2e/playwright/package.jsonindex 9a95a127b..535065bc0 100644--- a/tests/e2e/playwright/package.json+++ b/tests/e2e/playwright/package.json@@ -1,6 +1,6 @@{"name": "clerum-playwright-tests",- "version": "0.1.43",+ "version": "0.1.44","private": true,"description": "Playwright E2E tests for Control UI and Desktop App","scripts": {