Skip to content

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

TypeScript

test(hcc): prove the draining revert requires a stateless fresh read

Alfredo Lopeze073d00b4693
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 77a4bf322..9f3a313df 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.372",
+ "version": "0.1.373",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.372",
+ "version": "0.1.373",
"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 ff71f8766..6cd3117b3 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.372",
+ "version": "0.1.373",
"description": "Host Context Controller - provides McpServer CRDs to mcp-host via REST API",
"main": "dist/main.js",
"engines": {
diff --git a/host-context-controller/test/hostReconciler.heartbeat.test.ts b/host-context-controller/test/hostReconciler.heartbeat.test.ts
index e3c9ff2c1..a71694304 100644
--- a/host-context-controller/test/hostReconciler.heartbeat.test.ts
+++ b/host-context-controller/test/hostReconciler.heartbeat.test.ts
@@ -1556,6 +1556,37 @@ describe('HostReconciler.markHostActiveFromHeartbeat', () => {
expect(writes[0].lifecycle).toEqual({ state: 'active', wakeHandledGeneration: 4 })
expect(host.status?.lifecycle?.state).toBe('active')
})
+
+ it.each([
+ { channels: 1, expectedWrites: 0, finalState: 'draining' },
+ { channels: 0, expectedWrites: 1, finalState: 'active' },
+ ] as const)(
+ 'reverts a same-revision draining Host only while its fresh read is stateless (channels=$channels)',
+ async ({ channels, expectedWrites, finalState }) => {
+ // Channel ingress makes a Host effectively not stateless, so the lifecycle
+ // it would revert is not the one the stateless executor owns.
+ const { reconciler, customApi } = createReconciler()
+ reconciler.setCountCommunicationChannels(() => channels)
+ const host = {
+ ...makeStatelessHost({
+ status: { lifecycle: { state: 'draining', wakeHandledGeneration: 3 } },
+ }),
+ generation: 5,
+ }
+ const fresh = freshHostRead({ state: 'draining', wakeHandledGeneration: 3 })
+ customApi.getNamespacedCustomObject.mockResolvedValue({
+ ...fresh,
+ metadata: { ...fresh.metadata, generation: 5, resourceVersion: 'rv-draining' },
+ })
+
+ await reconciler.markHostActiveFromHeartbeat(host)
+
+ // Liveness witness: the decision was taken on exactly one fresh read.
+ expect(customApi.getNamespacedCustomObject).toHaveBeenCalledOnce()
+ expect(customApi.patchNamespacedCustomObjectStatus).toHaveBeenCalledTimes(expectedWrites)
+ expect(host.status?.lifecycle?.state).toBe(finalState)
+ }
+ )
})
describe('HostReconciler heartbeat cores — fresh-read guard (cross-instance staleness)', () => {
// The Host watch callback builds a brand-new HostCRD per ADDED/MODIFIED