Skip to content

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

TypeScript

fix(hcc): distinguish abandoned convergence and strengthen regression tests

Alfredo Lopez42385869a611
diff --git a/control-ui/e2e/qa-recorder-shared-fs-folders.spec.ts b/control-ui/e2e/qa-recorder-shared-fs-folders.spec.ts
index f9236aca6..14374f7cd 100644
--- a/control-ui/e2e/qa-recorder-shared-fs-folders.spec.ts
+++ b/control-ui/e2e/qa-recorder-shared-fs-folders.spec.ts
@@ -59,7 +59,7 @@ test.describe('optional QA recorder: Control UI SharedFileSystem folders', () =>
})
).toBeVisible()
await expect(page.getByRole('region', { name: 'Storage request' })).toBeVisible()
- await page.getByLabel('Name', { exact: true }).fill(name)
+ await page.getByLabel('Name *', { exact: true }).fill(name)
await page.getByLabel('Shared filesystem size', { exact: true }).fill('5')
await page.getByLabel('Shared filesystem size unit').selectOption('Gi')
await page.getByRole('button', { name: 'Continue', exact: true }).click()
@@ -70,7 +70,7 @@ test.describe('optional QA recorder: Control UI SharedFileSystem folders', () =>
await expect(page.getByLabel('Keep storage after deletion')).not.toBeChecked()
await page.getByRole('button', { name: 'Back', exact: true }).click()
await expect(page.getByRole('region', { name: 'Storage request' })).toBeVisible()
- await expect(page.getByLabel('Name', { exact: true })).toHaveValue(name)
+ await expect(page.getByLabel('Name *', { exact: true })).toHaveValue(name)
await expect(page.getByLabel('Shared filesystem size', { exact: true })).toHaveValue('5')
await expect(page.getByLabel('Shared filesystem size unit')).toHaveValue('Gi')
await page.getByRole('button', { name: 'Continue', exact: true }).click()
diff --git a/control-ui/package-lock.json b/control-ui/package-lock.json
index 6a1b59c5a..afbd8e7c6 100644
--- a/control-ui/package-lock.json
+++ b/control-ui/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-control-ui",
- "version": "0.1.566",
+ "version": "0.1.567",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-control-ui",
- "version": "0.1.566",
+ "version": "0.1.567",
"dependencies": {
"@clerum/display-field": "file:../packages/display-field",
"@clerum/frontend-components": "file:../packages/frontend-components",
diff --git a/control-ui/package.json b/control-ui/package.json
index cc76bae98..849a44c86 100644
--- a/control-ui/package.json
+++ b/control-ui/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-control-ui",
- "version": "0.1.566",
+ "version": "0.1.567",
"private": true,
"scripts": {
"dev": "NEXT_IGNORE_INCORRECT_LOCKFILE=1 next dev",
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index dba82bee6..ac64d6908 100644
--- a/host-context-controller/package-lock.json
+++ b/host-context-controller/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.307",
+ "version": "0.1.308",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.307",
+ "version": "0.1.308",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@clerum/codex-catalog-projection": "file:../packages/codex-catalog-projection",
diff --git a/host-context-controller/package.json b/host-context-controller/package.json
index 7360143fa..e2d883c8e 100644
--- a/host-context-controller/package.json
+++ b/host-context-controller/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-host-context-controller",
- "version": "0.1.307",
+ "version": "0.1.308",
"description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API",
"main": "dist/main.js",
"engines": {
diff --git a/host-context-controller/src/ensureResource.test.ts b/host-context-controller/src/ensureResource.test.ts
index 5a6694267..f43309655 100644
--- a/host-context-controller/src/ensureResource.test.ts
+++ b/host-context-controller/src/ensureResource.test.ts
@@ -7,6 +7,30 @@ const resource = (rv = '1') => ({
})
describe('ensureResource', () => {
+ it('does not count a resource that disappears during presence-path convergence', async () => {
+ const read = vi.fn().mockResolvedValueOnce(resource()).mockRejectedValueOnce({ code: 404 })
+ const create = vi.fn()
+ const replace = vi.fn().mockRejectedValue({ code: 409 })
+ const onSkipped = vi.fn()
+ await ensureResource({
+ read,
+ create,
+ onSkipped,
+ converge: readOnce =>
+ replaceWithConflictRetry({
+ description: 'policy',
+ logPrefix: '[Test]',
+ body: resource(),
+ read: readOnce,
+ replace,
+ }),
+ })
+ expect(read).toHaveBeenCalledTimes(2)
+ expect(replace).toHaveBeenCalledTimes(1)
+ expect(create).not.toHaveBeenCalled()
+ expect(onSkipped).not.toHaveBeenCalled()
+ })
+
it.each([{ code: 404 }, { response: { statusCode: 404 } }])(
'creates only after an actual absence read (%j)',
async absent => {
diff --git a/host-context-controller/src/llmHookReconciler.test.ts b/host-context-controller/src/llmHookReconciler.test.ts
index f5e7c570a..9a55f1462 100644
--- a/host-context-controller/src/llmHookReconciler.test.ts
+++ b/host-context-controller/src/llmHookReconciler.test.ts
@@ -439,18 +439,42 @@ describe('LlmHookReconciler', () => {
// ─── Concurrency (§10) ─────────────────────────────────────────────
it('serializes concurrent reconciles of two CRs sharing a pod key', async () => {
- // First materialization is absent; subsequent reads still use the live-state fixture.
- appsApi.readNamespacedDeployment.mockRejectedValueOnce({ code: 404 })
+ // The server may expose the first create before its response settles. Force
+ // the second pass onto a real PUT, and observe both mutation paths.
+ const readExisting = appsApi.readNamespacedDeployment.getMockImplementation()!
+ expect(readExisting).toBeDefined()
+ appsApi.readNamespacedDeployment
+ .mockImplementation(async request => {
+ const observed = await readExisting(request)
+ return { ...observed, spec: { ...observed.spec, replicas: 0 } }
+ })
+ .mockRejectedValueOnce({ code: 404 })
coreApi.readNamespacedService.mockRejectedValueOnce({ code: 404 })
+ let releaseFirst!: () => void
+ const firstBlocked = new Promise<void>(resolve => {
+ releaseFirst = resolve
+ })
+ let markFirstStarted!: () => void
+ const firstStarted = new Promise<void>(resolve => {
+ markFirstStarted = resolve
+ })
let inFlight = 0
let maxInFlight = 0
- appsApi.createNamespacedDeployment.mockImplementation(async () => {
+ const mutate = async (hold: boolean) => {
inFlight++
maxInFlight = Math.max(maxInFlight, inFlight)
- await new Promise(r => setTimeout(r, 5))
- inFlight--
- return {}
- })
+ try {
+ if (hold) {
+ markFirstStarted()
+ await firstBlocked
+ }
+ return {}
+ } finally {
+ inFlight--
+ }
+ }
+ appsApi.createNamespacedDeployment.mockImplementation(() => mutate(true))
+ appsApi.replaceNamespacedDeployment.mockImplementation(() => mutate(false))
const a = makeHook({
name: 'a',
spec: {
@@ -469,7 +493,21 @@ describe('LlmHookReconciler', () => {
})
hooks.set('a', a)
hooks.set('b', b)
- await Promise.all([reconciler.reconcile(a), reconciler.reconcile(b)])
+ const pending = Promise.all([reconciler.reconcile(a), reconciler.reconcile(b)])
+ try {
+ await firstStarted
+ // Flush runnable work while the first mutation is deliberately held;
+ // the second reconcile must still be waiting behind the same pod key.
+ await new Promise<void>(resolve => setImmediate(resolve))
+ expect(appsApi.readNamespacedDeployment).toHaveBeenCalledTimes(1)
+ expect(appsApi.createNamespacedDeployment).toHaveBeenCalledTimes(1)
+ expect(appsApi.replaceNamespacedDeployment).not.toHaveBeenCalled()
+ } finally {
+ releaseFirst()
+ await pending
+ }
+ expect(appsApi.createNamespacedDeployment).toHaveBeenCalledTimes(1)
+ expect(appsApi.replaceNamespacedDeployment).toHaveBeenCalledTimes(1)
expect(maxInFlight).toBe(1)
})
diff --git a/host-context-controller/src/utils.ts b/host-context-controller/src/utils.ts
index 068096412..3a58b7ce6 100644
--- a/host-context-controller/src/utils.ts
+++ b/host-context-controller/src/utils.ts
@@ -66,7 +66,19 @@ export async function ensureResource<T extends { metadata?: { name?: string } }>
}
return value
}
- const readFresh = async (): Promise<T> => validate(await read())
+ // The existing retry may deliberately return void after a missing read.
+ // Retain that policy while distinguishing it from completed preservation.
+ let latestReadSucceeded = true
+ const readFresh = async (): Promise<T> => {
+ try {
+ const value = validate(await read())
+ latestReadSucceeded = true
+ return value
+ } catch (error) {
+ latestReadSucceeded = false
+ throw error
+ }
+ }
let existing = opts.existing
if (existing === undefined) {
try {
@@ -91,7 +103,9 @@ export async function ensureResource<T extends { metadata?: { name?: string } }>
return readFresh()
}
const result = await converge(readOnce, existing)
- if (result !== false && (!mutationAllowed || mutationAllowed())) onSkipped()
+ if (result !== false && latestReadSucceeded && (!mutationAllowed || mutationAllowed())) {
+ onSkipped()
+ }
return
}