Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(control-api): pin the oauth-19 migrations to their post-sync numbers
Diego Zacarias1970c175cfdc
diff --git a/control-api/package-lock.json b/control-api/package-lock.jsonindex 8093b6275..2495d5a15 100644--- a/control-api/package-lock.json+++ b/control-api/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-control-api",- "version": "0.1.676",+ "version": "0.1.677","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-control-api",- "version": "0.1.676",+ "version": "0.1.677","dependencies": {"@clerum/display-field": "file:../packages/display-field","@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",diff --git a/control-api/package.json b/control-api/package.jsonindex 027aa5a26..24feb396f 100644--- a/control-api/package.json+++ b/control-api/package.json@@ -1,6 +1,6 @@{"name": "clerum-control-api",- "version": "0.1.676",+ "version": "0.1.677","description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets","main": "dist/main.js","engines": {diff --git a/control-api/src/db.ts b/control-api/src/db.tsindex fa10744ea..52e3870ae 100644--- a/control-api/src/db.ts+++ b/control-api/src/db.ts@@ -6508,7 +6508,7 @@ async function applyDynamicClientsTable(db: DbClient): Promise<void> {}async function applyDynamicClientsRuntimeAccess(db: DbClient): Promise<void> {- // `dynamic_clients` was created (0117) after the base migration's+ // `dynamic_clients` was created (0119) after the base migration's// `GRANT ... ON ALL TABLES IN SCHEMA public`, which only reaches tables that// existed when it ran. Without this the runtime role has f/f/f/f on the table// and no USAGE/SELECT/UPDATE on its identity sequence, so dynamicClientStore's@@ -6541,7 +6541,7 @@ async function applyOAuthInstallIdentity(db: DbClient): Promise<void> {// Greenfield/additive: dynamic_clients ships only on this branch, so no// backfill is possible or needed (legacy rows keep both columns NULL and the// decision logic treats them as name-only). ADD COLUMN is covered by the table- // GRANTs from 0117/0118 (legacy_dml), so no new runtime-access grant is needed.+ // GRANTs from 0119/0120 (legacy_dml), so no new runtime-access grant is needed.// Idempotent: ADD COLUMN IF NOT EXISTS, and each CHECK is guarded on// pg_constraint (Postgres has no ADD CONSTRAINT IF NOT EXISTS).await db.query(`diff --git a/control-api/test/db.dynamicClientsTableMigration.test.ts b/control-api/test/db.dynamicClientsTableMigration.test.tsindex d7e9840de..07d0d3ef9 100644--- a/control-api/test/db.dynamicClientsTableMigration.test.ts+++ b/control-api/test/db.dynamicClientsTableMigration.test.ts@@ -9,7 +9,7 @@ const mockPoolCtor = vi.fn(function MockPool() {vi.mock('pg', () => ({ Pool: mockPoolCtor }))-describe('0117_dynamic_clients_table migration', () => {+describe('0119_dynamic_clients_table migration', () => {beforeEach(() => {vi.resetModules()vi.clearAllMocks()@@ -22,13 +22,13 @@ describe('0117_dynamic_clients_table migration', () => {const versions = CONTROL_API_MIGRATIONS.map(m => m.version)// Renumbered 0116->0117 during the dev sync: dev's 0116_mcp_secret_rollback_permits// now sits between 0115 and this migration, so this guards ordering, not adjacency.- expect(versions).toContain('0117_dynamic_clients_table')+ expect(versions).toContain('0119_dynamic_clients_table')expect(versions.indexOf('0115_llm_allowed_models_image_input')).toBeLessThan(- versions.indexOf('0117_dynamic_clients_table')+ versions.indexOf('0119_dynamic_clients_table'))// The runtime-access grant for the table must run after the table exists.- expect(versions.indexOf('0117_dynamic_clients_table')).toBeLessThan(- versions.indexOf('0118_dynamic_clients_runtime_access')+ expect(versions.indexOf('0119_dynamic_clients_table')).toBeLessThan(+ versions.indexOf('0120_dynamic_clients_runtime_access'))})diff --git a/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts b/control-api/test/db.oauthGrantsOwnerGeneralization.test.tsindex 10014c8fd..e40e3e861 100644--- a/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts+++ b/control-api/test/db.oauthGrantsOwnerGeneralization.test.ts@@ -35,16 +35,16 @@ describe('0101 oauth_grants owner generalization migration', () => {expect(versions.indexOf('0108_llm_provider_attempts_sdk_link_on_delete_set_null')).toBeLessThan(versions.indexOf('0116_mcp_secret_rollback_permits'))- // oauth-19 dynamic-clients pair, renumbered past dev's 0116 during the sync- // (0116->0117 table, 0117->0118 runtime-access). Same liveness+ordering+ // oauth-19 dynamic-clients pair, renumbered past dev's 0116-0118 over two+ // syncs (table 0116->0117->0119, runtime-access 0117->0118->0120). Same liveness+ordering// guard so a future re-number or drop fails here first.- expect(versions).toContain('0117_dynamic_clients_table')- expect(versions).toContain('0118_dynamic_clients_runtime_access')+ expect(versions).toContain('0119_dynamic_clients_table')+ expect(versions).toContain('0120_dynamic_clients_runtime_access')expect(versions.indexOf('0116_mcp_secret_rollback_permits')).toBeLessThan(- versions.indexOf('0117_dynamic_clients_table')+ versions.indexOf('0119_dynamic_clients_table'))- expect(versions.indexOf('0117_dynamic_clients_table')).toBeLessThan(- versions.indexOf('0118_dynamic_clients_runtime_access')+ expect(versions.indexOf('0119_dynamic_clients_table')).toBeLessThan(+ versions.indexOf('0120_dynamic_clients_runtime_access'))expect(versions.indexOf('0100_seed_minimax_allowed_model')).toBeLessThan(versions.indexOf('0106_oauth_grants_owner_generalization')diff --git a/control-api/test/db.oauthInstallIdentityMigration.test.ts b/control-api/test/db.oauthInstallIdentityMigration.test.tsindex 8a7700d36..384cf9a93 100644--- a/control-api/test/db.oauthInstallIdentityMigration.test.ts+++ b/control-api/test/db.oauthInstallIdentityMigration.test.ts@@ -9,7 +9,7 @@ const mockPoolCtor = vi.fn(function MockPool() {vi.mock('pg', () => ({ Pool: mockPoolCtor }))-describe('0119_oauth_install_identity migration', () => {+describe('0121_oauth_install_identity migration', () => {beforeEach(() => {vi.resetModules()vi.clearAllMocks()@@ -20,14 +20,14 @@ describe('0119_oauth_install_identity migration', () => {it('is registered after the dynamic-clients table and its runtime-access grant', async () => {const { CONTROL_API_MIGRATIONS } = await import('../src/db.js')const versions = CONTROL_API_MIGRATIONS.map(m => m.version)- expect(versions).toContain('0119_oauth_install_identity')- // The columns extend dynamic_clients, so the table (0117) and its runtime- // grant (0118) must already exist when 0119 runs.- expect(versions.indexOf('0117_dynamic_clients_table')).toBeLessThan(- versions.indexOf('0119_oauth_install_identity')+ expect(versions).toContain('0121_oauth_install_identity')+ // The columns extend dynamic_clients, so the table (0119) and its runtime+ // grant (0120) must already exist when 0121 runs.+ expect(versions.indexOf('0119_dynamic_clients_table')).toBeLessThan(+ versions.indexOf('0121_oauth_install_identity'))- expect(versions.indexOf('0118_dynamic_clients_runtime_access')).toBeLessThan(- versions.indexOf('0119_oauth_install_identity')+ expect(versions.indexOf('0120_dynamic_clients_runtime_access')).toBeLessThan(+ versions.indexOf('0121_oauth_install_identity'))})@@ -40,7 +40,7 @@ describe('0119_oauth_install_identity migration', () => {sql.includes('ALTER TABLE dynamic_clients ADD COLUMN IF NOT EXISTS install_id UUID') &&sql.includes('cr_uid'))- expect(ddl, 'the 0119 DDL was applied').toBeDefined()+ expect(ddl, 'the 0121 DDL was applied').toBeDefined()const sql = ddl as string// Additive + idempotent columns.@@ -67,15 +67,15 @@ describe('0119_oauth_install_identity migration', () => {const recordedVersions = clientQuery.mock.calls.filter(([q]) => String(q).includes('INSERT INTO schema_migrations')).map(([, params]) => (Array.isArray(params) ? params[0] : undefined))- expect(recordedVersions).toContain('0119_oauth_install_identity')+ expect(recordedVersions).toContain('0121_oauth_install_identity')})it('needs no new runtime-access grant — ADD COLUMN is covered by the table GRANTs', async () => {const { initDb } = await import('../src/db.js')await initDb()const sqls = clientQuery.mock.calls.map(([sql]) => String(sql))- // No GRANT is emitted for the 0119 columns: they inherit the 0117/0118- // table-level GRANTs. Any GRANT on dynamic_clients belongs to 0118, not here.+ // No GRANT is emitted for the 0121 columns: they inherit the 0119/0120+ // table-level GRANTs. Any GRANT on dynamic_clients belongs to 0120, not here.const grantsInInstallIdentity = sqls.filter(sql => sql.includes('install_id') && sql.includes('cr_uid') && sql.includes('GRANT'))diff --git a/control-api/test/db.runtimeAccessMigrations.test.ts b/control-api/test/db.runtimeAccessMigrations.test.tsindex c3662cc85..9a98556bf 100644--- a/control-api/test/db.runtimeAccessMigrations.test.ts+++ b/control-api/test/db.runtimeAccessMigrations.test.ts@@ -55,7 +55,7 @@ describe('runtime access migrations', () => {expect(recordedVersions).toContain('0070_member_registration_runtime_delete_revoke')})- it('0117 grants the control-api runtime S/I/U/D on dynamic_clients and USAGE/SELECT/UPDATE on its sequence', async () => {+ it('0120 grants the control-api runtime S/I/U/D on dynamic_clients and USAGE/SELECT/UPDATE on its sequence', async () => {const { initDb } = await import('../src/db.js')await initDb()@@ -76,6 +76,6 @@ describe('runtime access migrations', () => {const recordedVersions = clientQuery.mock.calls.filter(([sql]) => String(sql).includes('INSERT INTO schema_migrations')).map(([, params]) => (Array.isArray(params) ? params[0] : undefined))- expect(recordedVersions).toContain('0118_dynamic_clients_runtime_access')+ expect(recordedVersions).toContain('0120_dynamic_clients_runtime_access')})})diff --git a/control-api/test/oauth.dynamicClientStore.installIdentity.realPostgres.integration.test.ts b/control-api/test/oauth.dynamicClientStore.installIdentity.realPostgres.integration.test.tsindex 9da823f32..463e04f86 100644--- a/control-api/test/oauth.dynamicClientStore.installIdentity.realPostgres.integration.test.ts+++ b/control-api/test/oauth.dynamicClientStore.installIdentity.realPostgres.integration.test.ts@@ -579,13 +579,13 @@ describeRealPostgres('dynamicClientStore install identity (real Postgres)', () =).not.toBeNull()})- it('migration 0119 is idempotent — re-running the guarded DDL over an already-migrated DB does not error', async () => {+ it('migration 0121 is idempotent — re-running the guarded DDL over an already-migrated DB does not error', async () => {// Force applyPendingMigrations to re-run applyOAuthInstallIdentity against a DB// that ALREADY has the columns and CHECK constraints. This exercises the real// guards (ADD COLUMN IF NOT EXISTS + pg_constraint DO-blocks) end to end — a// mocked pg that never executes DDL cannot. A dropped guard would raise a// duplicate-object error here instead of resolving.- await db.query(`DELETE FROM schema_migrations WHERE version = '0119_oauth_install_identity'`)+ await db.query(`DELETE FROM schema_migrations WHERE version = '0121_oauth_install_identity'`)await expect(initDb({ connect: () => dbPool.connect() })).resolves.not.toThrow()// Still exactly one copy of each object — no duplicate column or constraint.diff --git a/control-api/test/oauth.mcpServerOAuthTeardown.realPostgres.integration.test.ts b/control-api/test/oauth.mcpServerOAuthTeardown.realPostgres.integration.test.tsindex 5f08d652a..71c701caa 100644--- a/control-api/test/oauth.mcpServerOAuthTeardown.realPostgres.integration.test.ts+++ b/control-api/test/oauth.mcpServerOAuthTeardown.realPostgres.integration.test.ts@@ -143,7 +143,7 @@ describeRealPostgres('teardownMcpServerOAuthState — fenced by cr_uid (real Posconst name = `srv-tp-legacy-${randomUUID().slice(0, 8)}`const install = randomUUID()await insertDynamicClientPending(db, KEY, { ...dcrCreds(name, 'legacy'), installId: install })- // Emulate a pre-0119 legacy row: null the identity columns the migration added+ // Emulate a pre-0121 legacy row: null the identity columns the migration added// (the encrypted creds still came from the real producer above).await db.query(`UPDATE dynamic_clients SET install_id = NULL, cr_uid = NULL