Skip to content

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

TypeScript

chore: sync latest dev without dropping regression coverage

Alfredo Lopez48aa06d6eb6b
diff --cc control-api/package-lock.json
index 4e19aa7aa,fe6e679b9..901ef8fa0
--- a/control-api/package-lock.json
+++ b/control-api/package-lock.json
@@@ -1,12 -1,12 +1,12 @@@
{
"name": "clerum-control-api",
- "version": "0.1.700",
- "version": "0.1.699",
++ "version": "0.1.701",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-api",
- "version": "0.1.700",
- "version": "0.1.699",
++ "version": "0.1.701",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/grok-provider-attempt-contract": "file:../packages/grok-provider-attempt-contract",
diff --cc control-api/package.json
index 2d2de50fa,be18ec391..43026ba2d
--- a/control-api/package.json
+++ b/control-api/package.json
@@@ -1,6 -1,6 +1,6 @@@
{
"name": "clerum-control-api",
- "version": "0.1.700",
- "version": "0.1.699",
++ "version": "0.1.701",
"description": "Internal Clerum control plane REST API + UI for managing CRDs and secrets",
"main": "dist/main.js",
"engines": {
diff --cc control-api/test/services.adminAuthDelete.realPostgres.integration.test.ts
index 666e4b364,601ff4df6..899fde065
--- a/control-api/test/services.adminAuthDelete.realPostgres.integration.test.ts
+++ b/control-api/test/services.adminAuthDelete.realPostgres.integration.test.ts
@@@ -3,8 -3,8 +3,9 @@@ import { randomBytes, randomUUID } fro
import { Pool } from 'pg'
import { initDb, pool } from '../src/db.js'
import { deleteControlAdmin } from '../src/services/adminAuthService.js'
+import { endPoolAndWaitForClients } from './helpers/realPostgresTeardown.js'
import './realPostgres.requirement.ts'
+ import { waitForDatabaseConnectionsToClose } from './realPostgresCleanup.ts'
const adminUrl = process.env.CONTROL_API_REAL_PG_ADMIN_URL
const describeRealPostgres = adminUrl ? describe : describe.skip
@@@ -75,15 -75,14 +76,14 @@@ describeRealPostgres('deleteControlAdmi
afterAll(async () => {
querySpy?.mockRestore()
connectSpy?.mockRestore()
- await endPoolAndWaitForClients(testPool)
if (!adminPool) return
- await adminPool.query(
- `SELECT pg_terminate_backend(pid) FROM pg_stat_activity
- WHERE datname = $1 AND pid <> pg_backend_pid()`,
- [database]
- )
- await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
- await adminPool.end()
+ try {
- await testPool?.end()
++ await endPoolAndWaitForClients(testPool)
+ await waitForDatabaseConnectionsToClose(adminPool, database)
+ await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
+ } finally {
+ await adminPool.end()
+ }
})
// Regression for the plain DELETE /admin/control-admins/:id path (replaceInviter
diff --cc control-api/test/services.controlAdminReplaceInviter.realPostgres.integration.test.ts
index 17210d380,59ca26618..a0caa7fe5
--- a/control-api/test/services.controlAdminReplaceInviter.realPostgres.integration.test.ts
+++ b/control-api/test/services.controlAdminReplaceInviter.realPostgres.integration.test.ts
@@@ -23,8 -23,8 +23,9 @@@ import
createSilentInvitationForTeams,
} from '../src/services/directory/membership.js'
import { retireDesktopUser } from '../src/services/directory/users.js'
+import { endPoolAndWaitForClients } from './helpers/realPostgresTeardown.js'
import './realPostgres.requirement.ts'
+ import { waitForDatabaseConnectionsToClose } from './realPostgresCleanup.ts'
const adminUrl = process.env.CONTROL_API_REAL_PG_ADMIN_URL
const describeRealPostgres = adminUrl ? describe : describe.skip
@@@ -182,15 -182,14 +183,14 @@@ describeRealPostgres('control admin rep
afterAll(async () => {
querySpy?.mockRestore()
connectSpy?.mockRestore()
- await endPoolAndWaitForClients(testPool)
if (!adminPool) return
- await adminPool.query(
- `SELECT pg_terminate_backend(pid) FROM pg_stat_activity
- WHERE datname = $1 AND pid <> pg_backend_pid()`,
- [database]
- )
- await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
- await adminPool.end()
+ try {
- await testPool?.end()
++ await endPoolAndWaitForClients(testPool)
+ await waitForDatabaseConnectionsToClose(adminPool, database)
+ await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
+ } finally {
+ await adminPool.end()
+ }
})
it('stores replaceInviter and exposes it with the inviter on every invitation read', async () => {
diff --cc control-api/test/services.directory.userRetirement.realPostgres.integration.test.ts
index 9d6d3b350,245b4d5d1..40dd8a8bf
--- a/control-api/test/services.directory.userRetirement.realPostgres.integration.test.ts
+++ b/control-api/test/services.directory.userRetirement.realPostgres.integration.test.ts
@@@ -4,7 -4,7 +4,8 @@@ import { Pool } from 'pg
import { initDb, pool } from '../src/db.js'
import { retireDesktopUser } from '../src/services/directory/users.js'
import { gfsDesktopOperatorLinkService } from '../src/services/gfsDesktopOperatorLinkService.js'
+import { endPoolAndWaitForClients } from './helpers/realPostgresTeardown.js'
+ import { waitForDatabaseConnectionsToClose } from './realPostgresCleanup.ts'
const adminUrl = process.env.CONTROL_API_REAL_PG_ADMIN_URL
const describeRealPostgres = adminUrl ? describe : describe.skip
@@@ -57,15 -57,14 +58,14 @@@ describeRealPostgres('retireDesktopUse
afterAll(async () => {
corePoolConnectSpy?.mockRestore()
- await endPoolAndWaitForClients(testPool)
if (!adminPool) return
- await adminPool.query(
- `SELECT pg_terminate_backend(pid) FROM pg_stat_activity
- WHERE datname = $1 AND pid <> pg_backend_pid()`,
- [database]
- )
- await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
- await adminPool.end()
+ try {
- await testPool?.end()
++ await endPoolAndWaitForClients(testPool)
+ await waitForDatabaseConnectionsToClose(adminPool, database)
+ await adminPool.query(`DROP DATABASE IF EXISTS ${quoteIdent(database)}`)
+ } finally {
+ await adminPool.end()
+ }
})
it('persists the legacy deleted outcome and returns it on an identical replay', async () => {
diff --cc desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.test.tsx
index 077ad6951,c817cbd01..4023a07f5
--- a/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.test.tsx
+++ b/desktop-app/ui/src/hooks/domain/__tests__/useAgentChatController.test.tsx
@@@ -60,35 -76,6 +60,39 @@@ function deferred<T>()
return { promise, resolve, reject }
}
+// A send writes the user turn to the real ChatStore (disk I/O) before it wires
+// the progress subscription. On a loaded CI runner that write can take longer
+// than the 1000 ms waitFor default (#958), so the wiring waits get this bound.
+const WIRING_TIMEOUT_MS = 10_000
+// Captured at module load, before any test installs fake timers.
+const realSetTimeout = globalThis.setTimeout
+
+async function waitForProgressHandler(taskId: string) {
+ await waitFor(() => expect(clerum.hasProgressHandler(taskId)).toBe(true), {
+ timeout: WIRING_TIMEOUT_MS,
+ })
+}
+
+/**
+ * Fake-timer variant. `vi.waitFor` advances the fake clock by its interval on
+ * every check, which would move it toward the watchdog and connection timeouts
+ * the test advances to explicitly. This polls in real time and only runs the
+ * timers that are already due, so the fake clock does not move.
+ */
+async function waitForProgressHandlerUnderFakeTimers(taskId: string) {
+ const intervalMs = 50
+ for (let waitedMs = 0; waitedMs < WIRING_TIMEOUT_MS; waitedMs += intervalMs) {
+ await vi.advanceTimersByTimeAsync(0)
+ if (clerum.hasProgressHandler(taskId)) return
+ await new Promise(resolve => realSetTimeout(resolve, intervalMs))
+ }
+ expect(clerum.hasProgressHandler(taskId)).toBe(true)
+}
+
++function waitForWithFakeTimers<T>(assertion: () => T | Promise<T>) {
++ return vi.waitFor(assertion, { timeout: WIRING_TIMEOUT_MS })
++}
++
describe('useAgentChatController — characterization (D.0)', () => {
describe('switchToChat', () => {
// ⚠️ Rewritten for D.4 (plan §5.3): the pre-D.4 `isRemote` dual-path was