Skip to content

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

TypeScript

test(control-api): require the Grok catalog refresh to fill display_name (#739)

Alfredo Lopez8f53a6555595
diff --git a/control-api/package-lock.json b/control-api/package-lock.json
index 7c2a1ed14..46b5a4117 100644
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-api",
- "version": "0.1.612",
+ "version": "0.1.613",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.612",
+ "version": "0.1.613",
"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 7480cba97..65faa571e 100644
--- a/control-api/package.json
+++ b/control-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-api",
- "version": "0.1.612",
+ "version": "0.1.613",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --git a/control-api/test/services.grokSubscriptionConnection.realPostgres.integration.test.ts b/control-api/test/services.grokSubscriptionConnection.realPostgres.integration.test.ts
index 5aefaaca1..23770ebd0 100644
--- a/control-api/test/services.grokSubscriptionConnection.realPostgres.integration.test.ts
+++ b/control-api/test/services.grokSubscriptionConnection.realPostgres.integration.test.ts
@@ -594,4 +594,59 @@ describeRealPostgres('Grok subscription connection on real PostgreSQL', () => {
expect(silent.refreshed).toBe(1)
expect(await windows()).toEqual({ connection: [500_000], union: [500_000] })
})
+
+ it('T-R5-2-grok fills a NULL display_name on an existing row and keeps it when the catalog omits it', async () => {
+ const key = 'team-grok-display-name'
+ const model = 'grok-display-name-r52'
+ const created = await insertInitialGrokSubscriptionConnection(
+ pool,
+ KEY,
+ { refreshToken: 'refresh-name', accessToken: 'access', accountFingerprint: 'fp-name' },
+ key
+ )
+ const sync = (models: GrokDiscoveredModel[]) =>
+ syncGrokSubscriptionCatalog(
+ pool,
+ { listModels: async () => ({ outcome: 'ready', models }) },
+ 'access',
+ { connectionKey: key },
+ { withTransaction: poolTransaction }
+ )
+ const names = async () => {
+ const connection = await pool.query<{ display_name: string | null }>(
+ `SELECT display_name FROM grok_catalog_models
+ WHERE connection_id = $1 AND model = $2`,
+ [created.id, model]
+ )
+ const union = await pool.query<{ display_name: string | null }>(
+ `SELECT display_name FROM llm_allowed_models
+ WHERE provider = 'grok-subscription' AND model = $1`,
+ [model]
+ )
+ return {
+ connection: connection.rows.map(row => row.display_name),
+ union: union.rows.map(row => row.display_name),
+ }
+ }
+
+ // Discovered before the catalog supplied a name.
+ expect((await sync([{ model }])).added).toBe(1)
+ expect(await names()).toEqual({ connection: [null], union: [null] })
+
+ // The catalog now supplies the name; the existing rows take the refresh path.
+ const supplied = await sync([{ model, displayName: 'Grok Display R52' }])
+ expect(supplied.refreshed).toBe(1)
+ expect(await names()).toEqual({
+ connection: ['Grok Display R52'],
+ union: ['Grok Display R52'],
+ })
+
+ // A later catalog without a name keeps the stored one.
+ const silent = await sync([{ model }])
+ expect(silent.refreshed).toBe(1)
+ expect(await names()).toEqual({
+ connection: ['Grok Display R52'],
+ union: ['Grok Display R52'],
+ })
+ })
})