feat(post-audit): batch A+B quick-wins + audit-side residuals

Bundles the user-prioritised follow-ups from the post-audit punch-list.

Batch A — pipeline + EOI safety:
 - §1.1 timeline buildAuditDescription renders diff fields ("leadCategory → hot_lead").
 - §4.13 EOI rejection cascade: notification to assigned rep + audit row + rose banner.
 - §4.10b finish doc-detail: SigningProgress reuse, linked-entity names (server-resolved),
   per-event icons + tooltips + show-more in activity panel.
 - §7.2 stage guidance card replaces empty Payments slot pre-reservation.
 - §4.15 deal-pulse trigger audit (docs/deal-pulse-trigger-audit.md).

Batch B — UX consistency + docs:
 - §1.4 quick log-contact button on interest header.
 - §2.1 contact-log compose: Dialog → Sheet.
 - §7.1 docs/deal-pulse explainer page; /docs/ in PUBLIC_PATHS.
 - DocumentStatus now includes 'rejected' + 'declined' across constants, labels, tone maps.

Audit-side residuals:
 - M-NEW-1 /me/ports skips port-context requirement.
 - M-AU03 audit log CSV export endpoint + UI button.
 - M-IN03 dead receipt-scanner.ts deleted; live path already per-port.
 - M-P01 pg_trgm GIN indexes (migration 0071).
 - §10.1 webhook tests verified passing (was stale).

Deferred per user direction:
 - §11.3 email copy refactor (needs old-CRM reference).
 - M-EM03 IMAP bounce-to-interest linking.

Tests: 1374/1374. tsc + lint clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 14:22:11 +02:00
parent 4b5f85cb7d
commit 0f99f054b3
21 changed files with 1399 additions and 258 deletions

View File

@@ -0,0 +1,48 @@
-- M-P01: pg_trgm GIN indexes on the leading-wildcard ILIKE search
-- columns used by `buildListQuery` (src/lib/db/query-builder.ts:67).
--
-- Without these, every `ILIKE '%term%'` predicate sequential-scans
-- the entire table. The fix isn't to rewrite the SQL — Postgres will
-- transparently use a `gin_trgm_ops` index for ILIKE patterns once
-- one exists on the column.
--
-- The pg_trgm extension is a one-time install; CREATE EXTENSION IF NOT
-- EXISTS is idempotent. Each CREATE INDEX CONCURRENTLY runs outside
-- a transaction (the db-migrate runner detects CONCURRENTLY and
-- splits the statement out of the wrapping tx).
CREATE EXTENSION IF NOT EXISTS pg_trgm;
--> statement-breakpoint
-- ─── Clients ──────────────────────────────────────────────────────────────
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_clients_full_name_trgm
ON clients USING gin (full_name gin_trgm_ops);
--> statement-breakpoint
-- ─── Yachts ──────────────────────────────────────────────────────────────
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_yachts_name_trgm
ON yachts USING gin (name gin_trgm_ops);
--> statement-breakpoint
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_yachts_builder_trgm
ON yachts USING gin (builder gin_trgm_ops);
--> statement-breakpoint
-- ─── Companies ───────────────────────────────────────────────────────────
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_companies_name_trgm
ON companies USING gin (name gin_trgm_ops);
--> statement-breakpoint
-- ─── Berths ──────────────────────────────────────────────────────────────
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_berths_mooring_number_trgm
ON berths USING gin (mooring_number gin_trgm_ops);
--> statement-breakpoint
-- ─── Residential clients (parallel client surface) ───────────────────────
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_residential_clients_full_name_trgm
ON residential_clients USING gin (full_name gin_trgm_ops);
--> statement-breakpoint
-- ─── Tags (filter-bar autocomplete) ──────────────────────────────────────
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_tags_name_trgm
ON tags USING gin (name gin_trgm_ops);