Skip to content

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

TypeScript

test(hcc): pin the trailing convergence coalescing invariant

Alfredo Lopez25a27401e848
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index 42bc4c09b..4b38710f3 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.184",
+ "version": "0.1.185",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.184",
+ "version": "0.1.185",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@clerum/image-policy": "file:../packages/image-policy",
diff --git a/host-context-controller/package.json b/host-context-controller/package.json
index 2a031ef82..5bb9fbdac 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.184",
+ "version": "0.1.185",
"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/k8sClient.test.ts b/host-context-controller/src/k8sClient.test.ts
index ff77474cc..b5e418844 100644
--- a/host-context-controller/src/k8sClient.test.ts
+++ b/host-context-controller/src/k8sClient.test.ts
@@ -460,6 +460,35 @@ describe('McpServerWatcher startup', () => {
}
})
+ it('coalesces sustained convergence churn into a single trailing pass', async () => {
+ // Sustained churn must not turn the trailing loop into one apiserver pass
+ // per request. `trailingRequested` is a boolean latch, so an unbounded
+ // burst arriving during one in-flight pass may cost at most one more pass.
+ const watcher = new McpServerWatcher()
+ const inFlight = deferred()
+ let coreRuns = 0
+ ;(watcher as any).runInitialNetworkPolicyConvergenceCore = async () => {
+ coreRuns += 1
+ if (coreRuns === 1) await inFlight.promise
+ }
+
+ try {
+ const first = (watcher as any).runInitialNetworkPolicyConvergence() as Promise<void>
+ await flushMicrotasks()
+ for (let burst = 0; burst < 50; burst += 1) {
+ void (watcher as any).runInitialNetworkPolicyConvergence()
+ }
+ inFlight.resolve(undefined)
+ await first
+ await flushMicrotasks()
+
+ expect(coreRuns).toBeLessThanOrEqual(2)
+ } finally {
+ inFlight.resolve(undefined)
+ await watcher.stop()
+ }
+ })
+
it('retains Context uid and generation from the authoritative initial snapshot', async () => {
mocks.listNamespacedCustomObject.mockImplementation(async ({ plural }: { plural: string }) => {
if (plural === 'contexts') {