Skip to content

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

TypeScript

feat(control-api): add replace_inviter to control admin invitations

Jose Gabriel Ramirez Encinasbbddeb86b85f
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index efe682948..5866a0ac6 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.637",
+ "version": "0.1.638",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.637",
+ "version": "0.1.638",
"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.json
index 52a7ddeb8..2783e9829 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.637",
+ "version": "0.1.638",
"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.ts
index bdcdb8227..b33150a69 100644
--- a/control-api/src/db.ts
+++ b/control-api/src/db.ts
@@ -3129,6 +3129,17 @@ async function applyMcpSecretRollbackPermitSchema(db: DbClient): Promise<void> {
`)
}
+// A control-admin invitation that, when accepted, hands the inviter's access to
+// the invitee and retires the inviter (completeControlAdminInvitation). Additive
+// and defaulted false, so N-1 pods that never read the column keep today's
+// behavior.
+async function applyControlAdminInvitationReplaceInviterSchema(db: DbClient): Promise<void> {
+ await db.query(`
+ ALTER TABLE control_admin_invitations
+ ADD COLUMN IF NOT EXISTS replace_inviter BOOLEAN NOT NULL DEFAULT false;
+ `)
+}
+
// Exported (read-only) so the migration-order invariant test can assert the
// array is monotonic by version-string. Applied strictly in array order and
// tracked by full version-string in `schema_migrations`, so a non-monotonic
@@ -6208,6 +6219,10 @@ export const CONTROL_API_MIGRATIONS: DbMigration[] = [
legacyVersions: ['0101_mcp_secret_rollback_permits', '0109_mcp_secret_rollback_permits'],
apply: applyMcpSecretRollbackPermitSchema,
},
+ {
+ version: '0117_control_admin_invitation_replace_inviter',
+ apply: applyControlAdminInvitationReplaceInviterSchema,
+ },
]
async function consolidateWorkflowAllowedUsersToTriggers(db: DbClient): Promise<void> {
diff --git a/control-api/test/db.controlAdminInvitationReplaceInviterMigration.test.ts b/control-api/test/db.controlAdminInvitationReplaceInviterMigration.test.ts
new file mode 100644
index 000000000..d3ecd6ac7
--- /dev/null
+++ b/control-api/test/db.controlAdminInvitationReplaceInviterMigration.test.ts
@@ -0,0 +1,25 @@
+import { describe, expect, it, vi } from 'vitest'
+
+vi.mock('pg', () => ({
+ Pool: vi.fn(function MockPool() {
+ return { connect: vi.fn(), query: vi.fn() }
+ }),
+}))
+
+describe('0117_control_admin_invitation_replace_inviter migration', () => {
+ it('runs after the invitation opened-status migration and adds a non-null false-default flag', async () => {
+ const { CONTROL_API_MIGRATIONS } = await import('../src/db.js')
+ const versions = CONTROL_API_MIGRATIONS.map(migration => migration.version)
+ const openedStatus = versions.indexOf('0041_control_admin_invitation_opened_status')
+ const replaceInviter = versions.indexOf('0117_control_admin_invitation_replace_inviter')
+ expect(openedStatus).toBeGreaterThanOrEqual(0)
+ expect(replaceInviter).toBeGreaterThan(openedStatus)
+
+ const migration = CONTROL_API_MIGRATIONS[replaceInviter]
+ const query = vi.fn().mockResolvedValue({ rows: [], rowCount: 0 })
+ await migration!.apply({ query })
+ const sql = String(query.mock.calls[0]?.[0])
+ expect(sql).toContain('ALTER TABLE control_admin_invitations')
+ expect(sql).toContain('ADD COLUMN IF NOT EXISTS replace_inviter BOOLEAN NOT NULL DEFAULT false')
+ })
+})