fix(15): WR-02 refresh evidence snapshot even when content_hash unchanged

This commit is contained in:
lorentz 2026-07-15 08:08:20 -04:00
parent c875081275
commit 7c63c5f76d

View file

@ -188,7 +188,19 @@ export async function detectPhishingTicket(
);
if (existing.rowCount && existing.rowCount > 0 && existing.rows[0].content_hash === contentHash) {
return { flagged: true, skippedUnchanged: true };
// Content unchanged (D-04): skip full reprocessing (title/description/
// matched_patterns/content_hash rewriting would be a no-op anyway).
// But the evidence snapshot (notes, time entries, attachments) can
// still drift after the first detection — an analyst can add a note,
// log time, or attach a file without touching title/description. Refresh
// the evidence snapshot on every call regardless of the content-hash
// gate so later phases never read a stale snapshot.
const refreshedEvidence = await gatherTicketEvidence(ticket);
await postgresClient.query(
`UPDATE reports SET evidence = $1::jsonb, updated_at = NOW() WHERE ticket_id = $2`,
[JSON.stringify(refreshedEvidence), ticket.id]
);
return { flagged: true, reportId: existing.rows[0].id, skippedUnchanged: true };
}
const evidence = await gatherTicketEvidence(ticket);