Skip to content

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

TypeScript

test(hcc): pin fleet withdrawal through the Context authority fence

Alfredo Lopezb8b6260a5fca
diff --git a/host-context-controller/package-lock.json b/host-context-controller/package-lock.json
index eacc27b90..efe01cbef 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.267",
+ "version": "0.1.268",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-host-context-controller",
- "version": "0.1.267",
+ "version": "0.1.268",
"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 80eff8d53..f3ec65077 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.267",
+ "version": "0.1.268",
"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/hostReconciler.test.ts b/host-context-controller/src/hostReconciler.test.ts
index 6590681b1..e08462f3b 100644
--- a/host-context-controller/src/hostReconciler.test.ts
+++ b/host-context-controller/src/hostReconciler.test.ts
@@ -33,6 +33,17 @@ function deferred<T = void>(): {
return { promise, resolve, reject }
}
+async function readLabeledCounter(name: string, labels: Record<string, string>): Promise<number> {
+ const metric = registry.getSingleMetric(name)
+ if (!metric) throw new Error(`${name} is not registered`)
+ const snapshot = await metric.get()
+ return (
+ snapshot.values.find(entry =>
+ Object.entries(labels).every(([key, value]) => entry.labels[key] === value)
+ )?.value ?? 0
+ )
+}
+
vi.mock('./config', () => ({
config: {
hostNamespace: 'mcp-host',
@@ -1095,7 +1106,7 @@ describe('HostReconciler Host inventory mutation authority', () => {
expect(reconcileCore).not.toHaveBeenCalled()
})
- it('rejects a queued fleet worker after Context authority retires and recovers', async () => {
+ it('withdraws a queued fleet worker after Context authority retires and recovers', async () => {
const reconciler = makeBasicReconciler()
const hostA = makeHost({ name: 'context-authority-a' })
const hostB = makeHost({ name: 'context-authority-b' })
@@ -1131,17 +1142,26 @@ describe('HostReconciler Host inventory mutation authority', () => {
// transition and admit Host B with stale derived mounts. A pure watch
// reconnect with identical content would NOT advance the revision and is
// correctly admitted — that is the point of the content-identity fence.
+ // After #490 the fence still retires Host B; the fleet aggregator withdraws
+ // HostInventoryAuthorityUnavailableError instead of failing the pass.
mutationAuthority.current = {
known: true,
hostRevision: 7,
contextRevision: 13,
}
+ const before = await readLabeledCounter('clerum_hcc_host_fleet_benign_supersessions_total', {
+ error: 'HostInventoryAuthorityUnavailableError',
+ })
releaseBlocker.resolve(undefined)
await occupied
-
- await expect(fleet).rejects.toBeInstanceOf(HostFleetReconcileError)
+ await expect(fleet).resolves.toBeUndefined()
expect(reconcileCore).toHaveBeenCalledTimes(1)
expect(reconcileCore).not.toHaveBeenCalledWith(hostB, expect.any(Function))
+ expect(
+ await readLabeledCounter('clerum_hcc_host_fleet_benign_supersessions_total', {
+ error: 'HostInventoryAuthorityUnavailableError',
+ })
+ ).toBe(before + 1)
})
it('retires a Host reconcile when its Context is superseded within the same watch', async () => {
diff --git a/host-context-controller/test/hostReconciler.test.ts b/host-context-controller/test/hostReconciler.test.ts
index e411639f7..c76fea9d1 100644
--- a/host-context-controller/test/hostReconciler.test.ts
+++ b/host-context-controller/test/hostReconciler.test.ts
@@ -1987,25 +1987,42 @@ describe('collectHostReconcileFailures benign supersession (#490)', () => {
return error
}
- it('resolves reconcileHosts when every fleet error is a name-equivalent benign supersession', async () => {
+ it.each([
+ 'HostInventoryAuthorityUnavailableError',
+ 'HostMutationIdentityChangedError',
+ 'HostMutationSpecRevisionChangedError',
+ 'HostMutationDependencyChangedError',
+ ] as const)(
+ 'resolves reconcileHosts when every fleet error is name-equivalent %s',
+ async errorName => {
+ const { reconciler } = createReconciler()
+ const withdrawn = nameEquivalent(
+ errorName,
+ `Host "${errorName}" superseded before Host "alpha-host" reconcile admission`
+ )
+ vi.spyOn(reconciler, 'reconcile').mockRejectedValue(withdrawn)
+ const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
+ const before = await readFleetBenignSupersessions(errorName)
+
+ await expect(reconciler.reconcileHosts([makeHost()])).resolves.toBeUndefined()
+
+ expect(await readFleetBenignSupersessions(errorName)).toBe(before + 1)
+ expect(
+ errorSpy.mock.calls.some(call => String(call[0]).includes('Fleet reconcile failed'))
+ ).toBe(false)
+ errorSpy.mockRestore()
+ }
+ )
+
+ it('still rejects a lookalike error name that is not in the benign set', async () => {
const { reconciler } = createReconciler()
- const withdrawn = nameEquivalent(
- 'HostMutationSpecRevisionChangedError',
- 'Host spec generation changed before Host "alpha-host" reconcile admission'
+ vi.spyOn(reconciler, 'reconcile').mockRejectedValue(
+ nameEquivalent('HostMutationSpecRevisionChanged', 'almost the withdrawn name')
)
- vi.spyOn(reconciler, 'reconcile').mockRejectedValue(withdrawn)
- const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
- const before = await readFleetBenignSupersessions('HostMutationSpecRevisionChangedError')
- await expect(reconciler.reconcileHosts([makeHost()])).resolves.toBeUndefined()
-
- expect(await readFleetBenignSupersessions('HostMutationSpecRevisionChangedError')).toBe(
- before + 1
+ await expect(reconciler.reconcileHosts([makeHost()])).rejects.toBeInstanceOf(
+ HostFleetReconcileError
)
- expect(
- errorSpy.mock.calls.some(call => String(call[0]).includes('Fleet reconcile failed'))
- ).toBe(false)
- errorSpy.mockRestore()
})
it('still rejects HostFleetReconcileError for a non-benign fleet error', async () => {