fix(housekeeping): isolate executable command schemas
This commit is contained in:
1 parent
00618fb2a3
commit
7895188b56
5 files changed
+431
-67
No files matched your search
@@ -385,7 +385,7 @@ describe("dispatchHousekeepingCommand", () => {
|
||||
]);
|
||||
expect(audit.entries[1]?.correlationId).toBe(result.correlationId);
|
||||
});
|
||||
it("runs sensitive validation and rate preflight before intent and execution", async () => {
|
||||
it("runs sensitive capability and rate preflight before intent and execution", async () => {
|
||||
const events: string[] = [];
|
||||
const audit = auditRecorder(events);
|
||||
const tracedContext = {
|
||||
@@ -399,9 +399,7 @@ describe("dispatchHousekeepingCommand", () => {
|
||||
baseCommand("system.dispatch.preflight-order", {
|
||||
risk: "sensitive",
|
||||
requiresReason: true,
|
||||
input: z.object({ enabled: z.boolean() }).superRefine(() => {
|
||||
events.push("input");
|
||||
}),
|
||||
input: z.object({ enabled: z.boolean() }),
|
||||
execute: async (context) => {
|
||||
events.push("execute");
|
||||
return ok(null, context.correlationId);
|
||||
@@ -427,7 +425,6 @@ describe("dispatchHousekeepingCommand", () => {
|
||||
|
||||
expect(events).toEqual([
|
||||
"capability",
|
||||
"input",
|
||||
"rate",
|
||||
"audit:intent",
|
||||
"execute",
|
||||
@@ -566,15 +563,19 @@ describe("dispatchHousekeepingCommand", () => {
|
||||
const audit = auditRecorder();
|
||||
register(
|
||||
baseCommand("system.dispatch.schema-exception", {
|
||||
input: z.preprocess(() => {
|
||||
throw new Error("schema secret exposed");
|
||||
}, z.object({})),
|
||||
input: z.object({ value: z.string() }),
|
||||
execute: async (context) => ok(null, context.correlationId),
|
||||
}),
|
||||
);
|
||||
const throwingInput = Object.defineProperty({}, "value", {
|
||||
enumerable: true,
|
||||
get: () => {
|
||||
throw new Error("schema secret exposed");
|
||||
},
|
||||
});
|
||||
|
||||
const result = await dispatchHousekeepingCommand(
|
||||
{ commandId: "system.dispatch.schema-exception", input: {} },
|
||||
{ commandId: "system.dispatch.schema-exception", input: throwingInput },
|
||||
dependencies({ audit: audit.writer }),
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user