Wire up remaining TODO stubs: P3 test notifications, P2 drift notification trigger

- P3: test notification endpoint now instantiates real Slack/Email/Webhook notifiers
- P2: drift processor triggers notification service when drift_score > 0 (non-fatal on failure)
This commit is contained in:
2026-03-01 04:14:26 +00:00
parent b10e88e14d
commit e1b22e5309
2 changed files with 45 additions and 5 deletions

View File

@@ -56,8 +56,21 @@ export async function registerProcessorRoutes(app: FastifyInstance) {
);
});
// TODO: Trigger notification if drift_score > threshold
// TODO: Trigger remediation workflow if auto-remediate enabled
// Trigger notification if drift score exceeds threshold
if (report.drift_score > 0) {
try {
const { DriftNotificationService } = await import('../notifications/service.js');
const notifService = new DriftNotificationService(pool);
await notifService.notifyDrift(tenantId, {
stackName: report.stack_name,
driftScore: report.drift_score,
totalResources: report.total_resources,
driftedResources: report.drifted_resources?.length ?? 0,
});
} catch (err) {
app.log.warn({ tenantId, error: (err as Error).message }, 'Notification dispatch failed (non-fatal)');
}
}
return reply.status(201).send({ status: 'accepted' });
});