Skip to content

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

TypeScript

test(mcp-host): prove an open reservation counts toward the protected cap

Alfredo Lopez2642b7605754
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.json
index 5027e4889..9b58097a3 100644
--- a/mcp-host/package-lock.json
+++ b/mcp-host/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.542",
+ "version": "0.1.543",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-mcp-host",
- "version": "0.1.542",
+ "version": "0.1.543",
"license": "SEE LICENSE IN LICENSE",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.0",
diff --git a/mcp-host/package.json b/mcp-host/package.json
index b1de58c92..c8cebcaa8 100644
--- a/mcp-host/package.json
+++ b/mcp-host/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-mcp-host",
- "version": "0.1.542",
+ "version": "0.1.543",
"description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude",
"main": "dist/main.js",
"engines": {
diff --git a/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts b/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts
index 38d2ba840..890746f92 100644
--- a/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts
+++ b/mcp-host/src/internalTools/gfsDownloadStoreProtected.test.ts
@@ -140,7 +140,7 @@ describe('GFS download store: a caller protects at most half the budget (R3-F1)'
})
})
- it('an active reservation counts, pinned or not', async () => {
+ it('the new reservation itself counts, pinned or not', async () => {
const store = await openStore()
await copies(store, rootA, A, 0, 8, 'task-a')
const before = await protectedRefusals()
@@ -155,6 +155,30 @@ describe('GFS download store: a caller protects at most half the budget (R3-F1)'
await store.fail(admitted.transfer.id, A)
})
+ it("a caller's open reservation counts when it pins a reused copy", async () => {
+ const store = await openStore()
+ // 5 unpinned, then 30 pinned, then an open 10-byte reservation without
+ // owner: 40 protected. One caller holds one reservation at a time by
+ // default, so reuse is where an existing reservation meets a new pin.
+ await completedCopy(store, rootA, A, 1, 5)
+ await completedCopy(store, rootA, A, 0, 30, { owner: 'task-a' })
+ const open = await startTransfer(store, rootA, A, 2, 10)
+ const before = await protectedRefusals()
+
+ // 30 + 10 + 5 = 45: refused while the reservation is open.
+ await expect(
+ store.reusableReceipt(A, sourceFor(1), 5, { retentionOwnerId: 'task-b' })
+ ).rejects.toMatchObject({ code: 'host_quota_exceeded' })
+ expect(await protectedRefusals()).toBe(before + 1)
+
+ // Once it settles, 30 + 5 = 35 is admitted.
+ await store.fail(open.transfer.id, A)
+ await expect(
+ store.reusableReceipt(A, sourceFor(1), 5, { retentionOwnerId: 'task-b' })
+ ).resolves.toMatchObject({ sizeBytes: 5 })
+ expect(await protectedRefusals()).toBe(before + 1)
+ })
+
it('unpinned copies are not protected: one caller still fills the whole budget', async () => {
const store = await openStore()
await copies(store, rootA, A, 0, 16)
diff --git a/scripts/ci/pinned-vitest-cases/mcp-host.json b/scripts/ci/pinned-vitest-cases/mcp-host.json
index 982115953..eb1c8b4f8 100644
--- a/scripts/ci/pinned-vitest-cases/mcp-host.json
+++ b/scripts/ci/pinned-vitest-cases/mcp-host.json
@@ -913,7 +913,11 @@
},
{
"suite": "gfsDownloadStoreProtected.test.ts",
- "fullName": "GFS download store: a caller protects at most half the budget (R3-F1) an active reservation counts, pinned or not"
+ "fullName": "GFS download store: a caller protects at most half the budget (R3-F1) the new reservation itself counts, pinned or not"
+ },
+ {
+ "suite": "gfsDownloadStoreProtected.test.ts",
+ "fullName": "GFS download store: a caller protects at most half the budget (R3-F1) a caller's open reservation counts when it pins a reused copy"
},
{
"suite": "gfsDownloadStoreProtected.test.ts",