mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 12:37:55 +01:00
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 <noreply@anthropic.com>
This commit is contained in:
1 parent
ab0116963b
commit
d1954bbbe9
1 file changed
+5
-3
@@ -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 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user