Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
fix(mcp-host): reject a non-positive or non-integer sweep limit
Alfredo Lopez38011f341539
diff --git a/mcp-host/package-lock.json b/mcp-host/package-lock.jsonindex 159bd355e..1c6bcbd3e 100644--- a/mcp-host/package-lock.json+++ b/mcp-host/package-lock.json@@ -1,12 +1,12 @@{"name": "clerum-mcp-host",- "version": "0.1.588",+ "version": "0.1.589","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "clerum-mcp-host",- "version": "0.1.588",+ "version": "0.1.589","license": "SEE LICENSE IN LICENSE","dependencies": {"@anthropic-ai/sdk": "^0.32.0",diff --git a/mcp-host/package.json b/mcp-host/package.jsonindex d4dd49eef..147554aeb 100644--- a/mcp-host/package.json+++ b/mcp-host/package.json@@ -1,6 +1,6 @@{"name": "clerum-mcp-host",- "version": "0.1.588",+ "version": "0.1.589","description": "MCP Host - reads Host CRD and provides LLM access via OpenAI/Claude","main": "dist/main.js","engines": {diff --git a/mcp-host/src/core/sessionSearch/__tests__/sessionSearch.test.ts b/mcp-host/src/core/sessionSearch/__tests__/sessionSearch.test.tsindex f30821606..5bcc575e7 100644--- a/mcp-host/src/core/sessionSearch/__tests__/sessionSearch.test.ts+++ b/mcp-host/src/core/sessionSearch/__tests__/sessionSearch.test.ts@@ -466,6 +466,31 @@ describe('SessionSearchService — retention sweep', () => {.all()expect(kept).toHaveLength(1)})++ it('#14 rejects a sweep limit that is not a positive integer', async () => {+ const cutoffEpoch = Date.now() / 1000 - 90 * 86400+ for (const id of ['old-a', 'old-b']) {+ seedSession(h.db, {+ id,+ userId: 'u1',+ endReason: 'cancelled',+ endedAt: Date.now() / 1000 - 100 * 86400,+ })+ }+ for (const limit of [0, -1, 1.5]) {+ await expect(+ h.persistQueue.enqueueSync({ kind: 'sweep_closed_sessions', cutoffEpoch, limit })+ ).rejects.toThrow('sweep_closed_sessions: limit must be a positive integer')+ }+ const count = () =>+ (h.db.prepare('SELECT COUNT(*) AS n FROM sessions').get() as { n: number }).n+ expect(count()).toBe(2)+ // Liveness witness: a valid limit deletes exactly that many rows.+ await expect(+ h.persistQueue.enqueueSync({ kind: 'sweep_closed_sessions', cutoffEpoch, limit: 1 })+ ).resolves.toEqual({ deleted_messages: 0, deleted_sessions: 1 })+ expect(count()).toBe(1)+ })})describe('Schema invariants', () => {diff --git a/mcp-host/src/db/worker/dispatcher.ts b/mcp-host/src/db/worker/dispatcher.tsindex 047bc3445..d870380bb 100644--- a/mcp-host/src/db/worker/dispatcher.ts+++ b/mcp-host/src/db/worker/dispatcher.ts@@ -887,6 +887,11 @@ export async function dispatch(op: WorkerOp, deps: DispatcherDeps): Promise<unkn}case 'sweep_closed_sessions':+ // SQLite reads LIMIT 0 as "delete nothing" and a negative LIMIT as "no+ // limit"; either would break the bounded-batch contract silently.+ if (!Number.isSafeInteger(op.limit) || op.limit <= 0) {+ throw new Error('sweep_closed_sessions: limit must be a positive integer')+ }return withBusyRetry(() => {const tx = db.transaction(() => {const params = { cutoff: op.cutoffEpoch, limit: op.limit }