fix(housekeeping): complete people workflow fidelity

This commit is contained in:
Simo committed 2026-08-29 14:39:38 +02:00
1 parent 25b76437ff
commit 91c9efcbb4
29 files changed
+1365 -290

No files matched your search

+37 -5
View File
@@ -84,6 +84,13 @@ registerHousekeepingCommand({
ipAddress: commandContext.ipAddress,
},
commandContext.correlationId,
input.value === "partial"
? {
status: "partial",
external: "failed",
audit: "persisted",
}
: undefined,
);
},
});
@@ -136,6 +143,28 @@ describe("executeHousekeepingCommand", () => {
expect(sealRegistryMock).not.toHaveBeenCalled();
});
it("preserves one returned partial completion and its correlation through the real action dispatcher", async () => {
const result = await executeHousekeepingCommand({
commandId: "system.server-action.serializable",
input: { value: "partial" },
});
expect(result).toMatchObject({
ok: true,
data: { value: "partial" },
completion: {
status: "partial",
external: "failed",
audit: "persisted",
},
});
expect(auditEntries).toHaveLength(1);
expect(auditEntries[0]).toMatchObject({
outcome: "partial",
correlationId: result.correlationId,
});
expect(() => JSON.stringify(result)).not.toThrow();
});
it("strictly rejects spoofed server-owned metadata before execution", async () => {
const result = await executeHousekeepingCommand({
commandId: "system.server-action.serializable",
@@ -185,7 +214,7 @@ describe("executeHousekeepingCommand", () => {
expect(commandExecutions).toEqual([]);
});
it("maps completed-operation audit failures to a typed partial result", async () => {
it("returns one truthful partial completion when outcome audit persistence fails", async () => {
auditWriteMock.mockImplementation(async (entry: AuditEntry) => {
if (entry.outcome === "success") {
throw new Error("success audit unavailable");
@@ -200,13 +229,16 @@ describe("executeHousekeepingCommand", () => {
expect(commandExecutions).toEqual(["changed"]);
expect(result).toMatchObject({
ok: false,
error: {
code: "INTERNAL",
messageKey: "errors.housekeeping.partial",
ok: true,
data: { value: "changed" },
completion: {
status: "partial",
external: "not-required",
audit: "persisted",
},
});
expect(auditEntries.map((entry) => entry.outcome)).toEqual(["partial"]);
expect(auditEntries[0]?.correlationId).toBe(result.correlationId);
expect(() => JSON.stringify(result)).not.toThrow();
});
});