feat: complete audit coverage — comment, webhook, system-role, dispo, scenario

- comment.ts: create (body preview), resolve, delete
- webhook.ts: create, update, delete, test (result in summary)
- system-role-config.ts: update with before/after
- dispo.ts: commitImportBatch (IMPORT with counts), cancelImportBatch
- scenario.ts: applyScenario (CREATE with allocation count)

Audit coverage now: 29/36 routers (81%). Remaining 7 are read-only
(dashboard, staffing, chargeability-report, computation-graph,
report, insights.detectAnomalies, notification read/dismiss).

Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
2026-03-22 22:46:34 +01:00
parent 66878f18f4
commit 7a7430851c
5 changed files with 157 additions and 8 deletions
+14 -1
View File
@@ -2,6 +2,7 @@ import { calculateAllocation, countWorkingDays } from "@planarchy/engine/allocat
import { z } from "zod";
import { TRPCError } from "@trpc/server";
import { createTRPCRouter, controllerProcedure, protectedProcedure } from "../trpc.js";
import { createAuditEntry } from "../lib/audit.js";
const DEFAULT_AVAILABILITY = {
monday: 8,
@@ -485,7 +486,7 @@ export const scenarioRouter = createTRPCRouter({
const project = await ctx.db.project.findUnique({
where: { id: projectId },
select: { id: true },
select: { id: true, name: true },
});
if (!project) {
throw new TRPCError({ code: "NOT_FOUND", message: "Project not found" });
@@ -548,6 +549,18 @@ export const scenarioRouter = createTRPCRouter({
created.push(newAssignment.id);
}
void createAuditEntry({
db: ctx.db,
entityType: "ScenarioApplication",
entityId: projectId,
entityName: project.name,
action: "CREATE",
userId: ctx.dbUser?.id,
summary: `Applied scenario to project "${project.name}" (${created.length} allocations created/modified)`,
metadata: { appliedCount: created.length, assignmentIds: created },
source: "ui",
});
return { appliedCount: created.length };
}),
});