From d1954bbbe91ec562707f3504ae61013591b41900 Mon Sep 17 00:00:00 2001 From: Dotta Date: Sat, 7 Nov 2026 13:26:50 -0600 Subject: [PATCH] test: give the budget-authority unit a DB that accepts work hints Configuration preparation on current master publishes passive work hints through db.execute, so the empty object mock from #17857 throws before the budget assertions run. Co-Authored-By: Claude Opus 5.5 --- server/src/__tests__/agent-budget-configuration.test.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/server/src/__tests__/agent-budget-configuration.test.ts b/server/src/__tests__/agent-budget-configuration.test.ts index c21e34fa904..c5c8544b889 100644 --- a/server/src/__tests__/agent-budget-configuration.test.ts +++ b/server/src/__tests__/agent-budget-configuration.test.ts @@ -3,17 +3,19 @@ import type { Db } from "@paperclipai/db"; import type { AgentConfigurationRecord } from "../lib/agent-records.js"; import { prepareAgentConfiguration } from "../services/agent-configuration.js"; +// Configuration preparation now publishes passive work hints; this unit only checks budget authority. +const hintDb = () => ({ execute: async () => [] }) as unknown as Db; const existing = { id: "agent", companyId: "company", status: "idle", budgetMonthlyCents: 500 } as AgentConfigurationRecord; describe("budget authority in configuration preparation", () => { it("rejects agent-originated budget changes before persistence or policy audit", async () => { - const db = {} as Db; + const db = hintDb(); await expect(prepareAgentConfiguration(db, existing, { budgetMonthlyCents: 5000 }, { recordRevision: { createdByAgentId: "ceo" } })).rejects.toMatchObject({ status: 403 }); await expect(prepareAgentConfiguration(db, existing, { budgetMonthlyCents: 0 }, { recordRevision: { createdByAgentId: "ceo" } })).rejects.toMatchObject({ status: 403 }); }); it("removes an unchanged legacy budget from agent rollback so it cannot rewrite policy or invent a board actor", async () => { - expect(await prepareAgentConfiguration({} as Db, existing, { budgetMonthlyCents: 500 }, { recordRevision: { createdByAgentId: "ceo", source: "rollback" } })).toEqual({}); + expect(await prepareAgentConfiguration(hintDb(), existing, { budgetMonthlyCents: 500 }, { recordRevision: { createdByAgentId: "ceo", source: "rollback" } })).toEqual({}); }); it("preserves the actual board-authorized amount for the existing policy writer", async () => { - expect(await prepareAgentConfiguration({} as Db, existing, { budgetMonthlyCents: 5000 }, { recordRevision: { createdByUserId: "operator-user" } })).toEqual({ budgetMonthlyCents: 5000 }); + expect(await prepareAgentConfiguration(hintDb(), existing, { budgetMonthlyCents: 5000 }, { recordRevision: { createdByUserId: "operator-user" } })).toEqual({ budgetMonthlyCents: 5000 }); }); });