Audit cleanup completion plan, all tiers shipped: Tier 1 (security + data integrity) - A.7 RTBF true wipe: redact email_messages body/subject/addresses for threads owned by deleted client; redact document_sends.recipient_email; collect file storage keys + delete blobs post-commit. - A.8 user_permission_overrides FK: documented inline why cascade is correct (not set-null as audit suggested) — overrides have no value without their user. - W2.14 PII redaction: camelCase normalization in audit.ts + error-events.service.ts isSensitiveKey; added city/postal/country/ birth fragments. firstName/lastName/dateOfBirth/postalCode etc. now caught in BOTH masker paths. 12 new test cases lock the coverage. Tier 2 (Documenso completion + refactor) - C.2: documentEvents.recipient_email column + partial unique index for per-recipient webhook dedup (migration 0075). handleDocumentSigned now sets recipient_email on insert. - Phase 2: completion_cc_emails distribution. handleDocumentCompleted reads documents.completionCcEmails, filters out signer-duplicates case-insensitively, fans signed PDF out to non-signer recipients. - C.4: extracted createPublicInterest() service from the 346-line api/public/interests route. Route becomes a thin shell (rate-limit, port resolution, audit log, email fan-out). The trio creation logic is now unit-testable without an HTTP fixture. - Phase 4: POST /api/v1/document-templates/[id]/detect-fields wired to document-field-detector.detectFields(). Sparkles "Auto-detect" button added to template-editor.tsx — maps DetectedField → marker with best-guess merge token (DATE / NAME / EMAIL); user retags. Tier 3 (reporting + recommender snapshot lockfiles) - W7.reports: extracted rollupStageRevenue / rollupStageCounts / computeTotalForecast / computeOccupancyRate / rollupBerthStatusCounts into src/lib/services/report-math.ts (pure functions). 16 new tests including an inline-snapshot lockfile on a representative 7-stage forecast. report-generators.ts now delegates. - W7.recommender: 18 new toMatchSnapshot tripwires on classifyTier boundaries + computeHeat at canonical input points. Tier 4 (rolling) - W6.attach: fixed outdated CLAUDE.md claim — threshold banner is informational and never depended on IMAP; bounce monitoring (the IMAP poller) is separate. - D.1 + D.2: documented deferral inline with full why-not-build-it reasoning so a future engineer sees the rationale. - G.1: representative formatDate sweep (audit-log-list, user-list, document-templates merge tokens, document-signing email). Rest of the ~100 sites stay rolling. Quality gates: 1420/1420 vitest (46 new tests above baseline of 1374), tsc clean, 0 lint errors. Plan: docs/superpowers/plans/2026-05-18-audit-cleanup-completion.md Migration: 0075_c2_document_events_recipient_email.sql (applied to dev DB). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
193 lines
3.8 KiB
Plaintext
193 lines
3.8 KiB
Plaintext
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
|
|
exports[`W7 snapshots — heat at canonical inputs > heat: cold (no history) 1`] = `
|
|
{
|
|
"eoiCount": 0,
|
|
"furthestStage": 0,
|
|
"interestCount": 0,
|
|
"recency": 0,
|
|
"total": 0,
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — heat at canonical inputs > heat: no fallthrough but many interests 1`] = `
|
|
{
|
|
"eoiCount": 15,
|
|
"furthestStage": 0,
|
|
"interestCount": 15,
|
|
"recency": 0,
|
|
"total": 30,
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — heat at canonical inputs > heat: old fallthrough at deposit stage (recency decayed) 1`] = `
|
|
{
|
|
"eoiCount": 15,
|
|
"furthestStage": 40,
|
|
"interestCount": 15,
|
|
"recency": 21.94,
|
|
"total": 91.94,
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — heat at canonical inputs > heat: recent fallthrough at deposit stage (deepest hurt) 1`] = `
|
|
{
|
|
"eoiCount": 15,
|
|
"furthestStage": 40,
|
|
"interestCount": 15,
|
|
"recency": 30,
|
|
"total": 100,
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — heat at canonical inputs > heat: recent fallthrough at enquiry stage 1`] = `
|
|
{
|
|
"eoiCount": 0,
|
|
"furthestStage": 0,
|
|
"interestCount": 3,
|
|
"recency": 30,
|
|
"total": 33,
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — heat at canonical inputs > heat: recent fallthrough at eoi stage 1`] = `
|
|
{
|
|
"eoiCount": 5,
|
|
"furthestStage": 20,
|
|
"interestCount": 6,
|
|
"recency": 30,
|
|
"total": 61,
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — heat at canonical inputs > heat: typical mid-funnel hot lead 1`] = `
|
|
{
|
|
"eoiCount": 10,
|
|
"furthestStage": 30,
|
|
"interestCount": 9,
|
|
"recency": 30,
|
|
"total": 79,
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=0, lost=0, stage=0) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 0,
|
|
"lostCount": 0,
|
|
"maxActiveStage": 0,
|
|
},
|
|
"out": "A",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=0, lost=1, stage=0) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 0,
|
|
"lostCount": 1,
|
|
"maxActiveStage": 0,
|
|
},
|
|
"out": "B",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=0, lost=5, stage=0) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 0,
|
|
"lostCount": 5,
|
|
"maxActiveStage": 0,
|
|
},
|
|
"out": "B",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=1, lost=0, stage=1) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 1,
|
|
"lostCount": 0,
|
|
"maxActiveStage": 1,
|
|
},
|
|
"out": "C",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=1, lost=0, stage=3) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 1,
|
|
"lostCount": 0,
|
|
"maxActiveStage": 3,
|
|
},
|
|
"out": "C",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=1, lost=0, stage=4) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 1,
|
|
"lostCount": 0,
|
|
"maxActiveStage": 4,
|
|
},
|
|
"out": "C",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=1, lost=0, stage=5) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 1,
|
|
"lostCount": 0,
|
|
"maxActiveStage": 5,
|
|
},
|
|
"out": "D",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=1, lost=0, stage=6) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 1,
|
|
"lostCount": 0,
|
|
"maxActiveStage": 6,
|
|
},
|
|
"out": "D",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=1, lost=5, stage=6) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 1,
|
|
"lostCount": 5,
|
|
"maxActiveStage": 6,
|
|
},
|
|
"out": "D",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=2, lost=0, stage=5) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 2,
|
|
"lostCount": 0,
|
|
"maxActiveStage": 5,
|
|
},
|
|
"out": "D",
|
|
}
|
|
`;
|
|
|
|
exports[`W7 snapshots — tier-ladder boundaries > tier(active=3, lost=2, stage=4) is stable 1`] = `
|
|
{
|
|
"in": {
|
|
"activeInterestCount": 3,
|
|
"lostCount": 2,
|
|
"maxActiveStage": 4,
|
|
},
|
|
"out": "C",
|
|
}
|
|
`;
|