3.29 Universal Inbox Triage Architecture
Workflow maps and gap analysis for the Universal Inbox: the verified live email triage path, the seven-layer deterministic filter model, the three "Paperclips" disambiguation, and the target rules-first architecture that ADR-265 must ratify.
Workflow maps and gap analysis for the Universal Inbox: the verified live email triage path, the seven-layer deterministic filter model, the three "Paperclips" disambiguation, and the target rules-first architecture that ADR-265 must ratify.
One Inbox, Scripts First, AI Last, Humans Gate the Door
Every inbound message — email, phone call, SMS, WhatsApp, social, web form — should land in one Universal Inbox. Cheap, deterministic scripts (not AI) then sort each message: bin the junk, work out who sent it and which property it concerns, classify what it is about, and hand it to the right specialist sub-agent. An AI model is only consulted as a fallback classifier when the rules cannot decide, and every outbound reply is gated by a human until an agent earns autonomy. Today that vision is partially real: the live email path is already fully deterministic through triage, but only email flows through it, all rules are hardcoded, and every action — whatever its category — is handed to a single enquiries agent. This page maps exactly what exists, what is missing, and what ADR-265 must decide.
Think of the Universal Inbox as a sorting office. Letters arrive from many doors (email, WhatsApp, phone, portals). A set of fixed, printed rules — not a person, not an AI — decides where each letter goes: junk in the bin, a dominant listing aggregator enquiry to the lettings desk, a boiler complaint from a known tenant to maintenance, an invoice to accounts. Only when the printed rules cannot decide do we ask a cheap AI to have a look, and if even that is unsure, a human sorts it by hand. Replies drafted by any AI wait in an approval tray until a human presses send. This document is the honest map of that sorting office: which conveyor belts are actually running (verified with file and line references), which are drawn on the blueprint but never built, and which two belts were accidentally built twice.
Universal Inbox Triage — Why, How, What
Evidence-Linked (ADR-262 / ADR-095 / ADR-090)
Why: ADR-262 (2026-07-16) mandates that "Paperclip triages all inbound messages; AI answers immediately where it can; where it can't, it creates a trackable Action and routes it to a human." ADR-095 (2026-04-09) mandated one inbox per agency and a deterministic noise/domain classifier, derived from 123,824 historical Intercom conversations. Doctrine throughout is deterministic first: LLM classification is expensive, slow, and rate-limited at webhook concurrency, while sender-domain and keyword rules are effectively free.
How: a single InboundPipeline normalises each message, resolves the sender against tbl_persons_channels, matches the property, classifies the issue with regex cascades, and writes an Action row to tbl_actions. A dispatcher hands AI-owned actions to an executor, which invokes a specialist agent. All drafted replies queue in tbl_message_approvals (SHADOW mode, ADR-091 gating).
What (verified 2026-07-20): only the Gmail path runs this pipeline end-to-end. Every triage rule is a hardcoded TypeScript constant, there is no tbl_triage_rules table in the database (confirmed via information_schema), the dispatcher routes every category to a single enquiries agent, and a second, dormant, LLM-led pipeline sits unused in 08_channels/. All file references below are relative to the portal root 03_technology/11_frontend/portal/ unless stated otherwise.
Chapter 1: Current State Map — The Live Email Path (Verified)
This is the only channel that traverses the full triage pipeline today. Every step below is deterministic — DB lookups and regex — except the single marked LLM call at the very end (reply drafting). The pipeline call from gmail-sync is non-blocking: failures are only console.warn'd (gmail-sync/route.ts:348–367).
Gmail API (poll every 5 min — vercel.json cron)
│
▼
gmail-sync cron src/app/api/cron/gmail-sync/route.ts
│
├─ JUNK GATE src/lib/email-blacklist.ts (applied :117–127,
│ ~30 blocked domains · 6 blocked emails · BEFORE any DB write)
│ 17 subject substrings · noreply local-part regex (:86)
│ /^(no-?reply|do-?not-?reply|donotreply|notifications?|
│ mailer-daemon|postmaster)$/
│
├─ own-mail skip (:129–138)
├─ person lookup (:145) → find/create conversation by threadId (:152–158)
├─ PORTAL LEAD PARSE src/lib/gmail.ts:103–218 PORTAL_PATTERNS
│ rightmove | zoopla | onthemarket | spareroom | openrent
│ → extract applicant name/email/phone → shadow contact (:284–314)
├─ ADDRESS MATCH src/lib/address-match.ts (called :324, :376)
│ postcode 0.70 · +building_number 0.90 · +unit 0.85
│ PR-ref exact match · auto-link ≥0.85 (ADR-261)
│
▼
InboundPipeline (4 steps) src/lib/bridge/inbound-pipeline.ts
─ 100% deterministic, zero LLM calls ─ (imported gmail-sync :42, called :352)
│
├─ 1. WHO (:41–56) exact lookup tbl_persons_channels
│ channel_type='email' AND channel_value=lower(sender)
├─ 2. PROPERTY (:61–75) matchAddress(subject+body), threshold 0.85
├─ 3. ISSUE (:80–151) pure regex keyword cascade, first match wins:
│ emergency /\b(gas leak|carbon monoxide|fire|flood|emergency|
│ no heat|no water|lockout)\b/i → urgent + human
│ legal /\b(evict|section 8|section 21|court|solicitor|
│ legal|sue|tribunal|ombudsman)\b/i → escalate
│ complaint (list) → human
│ maintenance /\b(repair|broken|fix|leak|heating|boiler|
│ damp|mould|maintenance)\b/i
│ rent /\b(rent|payment|arrears|...)\b/i
│ enquiry /\b(viewing|available|rent|let|property|
│ apartment|flat|bedroom)\b/i
│ default general / low
│ NOTE: "rent" appears in BOTH rent and enquiry branches — order decides
└─ 4. EXISTING-ACTION (:156–170) findOpenActionForFollowUp
newest open tbl_actions row for person/asset
(no time window, no category match)
│
▼ decision logic (:216–279)
tbl_actions
requiresHuman → createActionForHuman (actions-logger.ts:111–161,
sha256 daily idempotency key)
else → insert ai_owned=true, status='pending', stage=null
(:252–265 — omits person_id; executor recovers it
via source_conversation, executor.ts:36–43)
│
▼
Dispatcher src/lib/bridge/actions-dispatcher.ts
polls WHERE ai_owned AND status='pending' AND stage IS NULL (:78–85)
batches 50 → stage='dispatched'
trigger: POST /api/bridge/dispatch (CRON_SECRET) —
NOT in vercel.json crons (external trigger unverified)
│
▼
Executor src/lib/bridge/executor.ts
HARDCODED → runPropertyEnquiriesAgent (:51) for EVERY category
(API transport stubbed "not implemented" :60–64)
│
▼
PropertyEnquiriesAgent src/lib/agents/property-enquiries-agent.ts
★★ THE ONLY LLM CALL IN THE LIVE EMAIL PATH ★★
claude-sonnet-4-6 drafts the reply — and even here, rule-based
tracks return modelUsed:'rule-based' (:153, :172)
│
▼
tbl_message_approvals — SHADOW mode (ADR-091)
draft stored as internal note; human reviews; nothing auto-sends
Two live channels bypass this pipeline entirely: WhatsApp (src/app/api/webhooks/timelines/route.ts — its own flow: phone match on tbl_persons_channels :157–162, keyword escalation via ESCALATION_KEYWORDS in whatsapp-agent.ts:55–77, then a Claude reply) and voice (src/app/api/webhooks/voice/triage/route.ts — known callers get SMS MFA deterministically; unknown callers are classified by Gemini 2.5-flash :170–198, with spam rejected via TwiML :200–216). Neither writes a CanonicalMessage nor calls InboundPipeline.
Chapter 2: The Seven-Layer Deterministic Filter Model
This is the codified triage design: seven ordered layers, each a pure function of the message plus the database — no model calls. A message falls through the layers until one claims it. For each layer the table records what is built and live today (with file:line evidence) against what is missing to complete the design.
| Layer | Purpose | EXISTS today (evidence) | MISSING |
|---|---|---|---|
| L0 Junk / noise | Discard machine noise before any DB write: blocked domains, noreply senders, portal system messages, out-of-office. | src/lib/email-blacklist.ts — ~30 domain suffixes, 6 emails, 17 subject substrings, noreply regex (:86); applied at gmail-sync:117–127 before persistence. Voice spam rejected at voice/triage:200–216 (LLM-based). |
ADR-095 §noise mandated the blocklist live in a config table or env var ("updated without a deploy") — never built; everything is hardcoded TS. ADR-095's broader noreply set (newsletter@, updates@, mailer@) and the BigQuery-topic DISCARD class ("Auto-Reply & Out of Office") are unimplemented. |
| L1 Channel normalisation | Every channel converts to one canonical message shape so all downstream layers are shared. | Only in the dormant Omnichannel stack: 08_channels/normalizers/canonical_message.ts (+ deterministic classifyPii/classifyDataPurpose) with full adapters for Twilio (08_channels/adapters/twilio_adapter.ts), email webhook, and Telegram behind /api/channels/ingress/*. |
Live channels are all bespoke: Gmail builds its own InboundMessage; WhatsApp (webhooks/timelines) and voice write tables directly with no canonical shape. No Meta (Facebook/Instagram) adapter exists anywhere. SMS, social, and web forms: nothing. |
| L2 Identity | Exact match on tbl_persons_channels; unknown senders become a shadow contact or a first_touch brief. |
Email: exact lowercase match (inbound-pipeline.ts:41–56). Phone: timelines:157–162, channel_type IN (whatsapp, phone, sms). Shadow contacts created for portal leads only (gmail-sync:284–314, source: portal). Unknown senders get a first_touch=true PUBLIC-only brief (contact-brief.ts). |
Unknown direct senders stay person_id=null forever — no person row is ever created. The WhatsApp phone lookup is exact-string E.164 with no normalisation and no organisation scoping (missing .eq('organisation_id')). No cross-channel identity merge. |
| L3 Source classification | Sender domain decides the route: portal relays (dominant listing aggregator/incumbent property portal/alternative listings channel/OpenRent/SpareRoom) go straight to the enquiry route; marketing to the Marketing agent; bills to Accounts; system errors to IT Help. | Detection only: PORTAL_PATTERNS (gmail.ts:103–218) extracts applicant details from the 5 portal relay formats; inbox/conversations/route.ts:145–175 applies display-only labels. ADR-095 §2 specified portals as BUSINESS/vendor class (spec only). |
No routing decision is derived from the source. A dominant listing aggregator relay traverses the same generic keyword cascade as any other email — grep of src/lib/bridge/ finds zero portal-domain matches. No marketing, bills/accounts, or system-error routes exist at all. |
| L4 Role resolution | Resolve the sender to Landlord / Tenant / Supplier / New via contact_role, the tenancy join, and supplier accounts — and let the role steer the route. |
The data exists: tbl_persons.contact_role read at contact-brief.ts:71; active tenancy via tbl_tenancies_persons ⋈ tbl_tenancies (stage IN active/notice/renewal, :93–110); tbl_supplier_accounts table present in the DB. |
Nothing in the inbound path sets or routes on role. No code joins tbl_supplier_accounts in triage (the only supplier awareness is the voice LLM label supplier_contractor, prompt-only, :220–227). No "known tenant + boiler keyword → maintenance" rule anywhere. |
| L5 Continuation | Thread matching and open-action follow-up: a reply in an existing conversation must not spawn a duplicate action. | Email threads: find-or-create by channel_ref=threadId (gmail-sync:152–158) — solid. Action level: findOpenActionForFollowUp (actions-logger.ts:166–187). Daily sha256 idempotency key on human actions (:116–120). |
Follow-up match has no category and no time-window constraint — any open action for a person swallows new, unrelated topics. No cross-channel continuation: WhatsApp keys on chat_id, email on threadId, never merged by person. |
| L6 Category → executor dispatch | Map each action category (enquiries / maintenance / tenancy / accounts / marketing / onboarding) to its specialist executor agent. | Categories are assigned by the ISSUE cascade and stored on tbl_actions; the dispatcher/executor plumbing works (actions-dispatcher.ts:78–85, batch 50, stage transitions). |
The map does not exist. The dispatcher selects on ai_owned/status/stage only; executor.ts:51 hardcodes runPropertyEnquiriesAgent for every category — a maintenance or rent_arrears action is answered by the enquiries agent. No agent registry; ADR-090/093's specialist swarm is NOT STARTED per AGENTS.md. |
Verified negative: an information_schema query against the production database (project suazhpquxpzuhbtritxj) confirms no tbl_triage_rules, no blocklist, noise, filter, or routing tables exist. Every rule in every layer above is a hardcoded TypeScript constant, and PORTAL_PATTERNS is duplicated in two files (gmail.ts and inbox/conversations/route.ts).
Chapter 3: The Three "Paperclips" — the Root Documentation Failure
The word "Paperclip" refers to three different artefacts across the repository, and no ADR disambiguates them. This is why the docs hub, the ADRs, and the shipped code appear to describe different systems: they do.
1. The Concept (ADR-090)
"Paperclip" the orchestrator architecture (2026-04-09): an orchestrator plus 7 domain specialists, ORIENT/DECIDE/RECORD loop, stateless with DB-as-state. Its own code-structure section places the orchestrator inside portal code at src/lib/agents/paperclip-orchestrator.ts — yet its cron sizing is tuned to "VPS capacity (KVM4)". Ambiguous on runtime from day one. ADR-262 (2026-07-16) mandates "Paperclip triages all inbound messages" with zero words on where it runs (verified by grep).
2. The VPS Container (2026-04-05)
A Docker container on the Hostinger VPS (ghcr.io/hostinger/hvps-paperclip, Tailscale-only UI on :3100, local Ollama Qwen/Gemma), deployed 2026-04-05 per 03_technology/07_agent-framework/paperclip-setup.md. Deployed four days before ADR-090 was written. Its fate was never addressed by any subsequent ADR; it sits on the VPS doing nothing in the live triage path.
3. The OSS Product (2026-07-17)
The paperclipai/paperclip open-source product, documented live at paperclip.estateaigents.com (Docker-only, commit eaee610f). ADR-139 (2026-04-22) explicitly deferred adopting this framework until re-evaluation on 2026-08-22 — yet it was installed anyway. It is a third, distinct artefact sharing the same name.
Meanwhile the triage that actually runs (the bridge merged 2026-07-19, commit 47f2fdc7) executes as TypeScript inside the Next.js portal on Vercel — the path of least resistance under ADR-139 Phase 1 ("no new orchestration framework before launch; build domain agent logic as TypeScript API routes on Vercel"). The public docs hub page 3.17 Paperclip Orchestrator still tells developers triage is a No-LLM VPS daemon. No ADR ever formally decided where the triage brain runs; ADR-265 must resolve this (Chapter 6).
Chapter 4: Gap List and Target Architecture
The consolidated gap list from the verified inventory, followed by the ratification-candidate target design. Nothing built so far is wasted: the pipeline, dispatcher, and approvals tables all persist; only the hardcoded rules and the in-portal LLM agent are eventually retired.
- DB-backed rules table. ADR-095 mandated a non-deploy-updatable blocklist; today every rule is a TS constant. Target:
tbl_triage_rules(schema below) evaluated in order by a Vercel evaluator — "dominant listing aggregator changed their format" becomes a row insert, not a deploy. - Portal fast-path. Portal relays are already detected (
parsePortalLead) but still flow through the generic keyword cascade. Target: sender-domain rule →communications/rental_enquiryroute with structured portal parse — zero LLM tokens. - Role-based routing. Resolve
contact_role+ tenancy join +tbl_supplier_accountsin the WHO step and let role steer category ("known tenant + boiler keyword → maintenance"). - Category → executor dispatch map. Replace the
executor.ts:51hardcode with an agent registry keyed on action category (enquiries / maintenance / tenancy / accounts / marketing / onboarding). - Channel adapters per channel. One pipeline, thin adapters normalising to a canonical
InboundMessage; migrate WhatsApp and voice onto it; add SMS, Meta, and web forms in the locked build order (email → WhatsApp → Twilio → Meta/forms). Cut over from Intercom per-channel, never per-conversation. - Follow-up quality. Add category and time-window constraints to
findOpenActionForFollowUpso one open action stops swallowing unrelated topics. - Unknown-sender contacts. Extend shadow-contact creation beyond portal leads so direct unknown senders stop living as
person_id=nullconversations. - Phone normalisation + org scoping. Normalise E.164 and add
organisation_idscoping to the WhatsApp person lookup. - Dispatch trigger.
/api/bridge/dispatchis absent fromvercel.jsoncrons — put the trigger on record.
Proposed tbl_triage_rules schema (from the target-architecture proposal):
tbl_triage_rules
rule_id, priority (int, eval order), channel ('email' | '*'),
match jsonb — {sender_domain?, to_address?, subject_regex?,
body_regex?, keywords?[]} (ANDed)
output — {category, sub_type?, extract: 'portal_lead' | null}
confidence numeric, active bool, hit_count, last_hit_at
Flow: ordered evaluation; first match with confidence ≥ 0.90 routes
directly (0 tokens). No match → cheap classifier (Haiku/DeepSeek,
structured output). Classifier < 0.70 → "Unknown — triage" human queue.
hit_count + a weekly report of LLM-fallback volume by sender domain
surfaces candidate new rules — the LLM is the safety net AND the
rule-mining signal.
Target component diagram — deterministic triage on Vercel, specialists in Paperclip behind a durable queue (Vercel never calls Paperclip synchronously; it enqueues tbl_actions rows and Paperclip pulls, so a container outage queues work durably rather than dropping it):
Gmail cron Timelines.ai Twilio (SMS/voice+STT) Meta Web forms
│ │ │ │ │
▼ ▼ ▼ ▼ ▼
┌────────────── Channel Adapters (Vercel) ─────────────────────┐
│ normalise → junk filter → person/asset resolve │
└───────────────────────────┬──────────────────────────────────┘
▼
┌─────────── InboundPipeline (Vercel TS) ──────────────────────┐
│ 1. tbl_triage_rules (ordered; ≥0.90 → route, 0 tokens) │
│ 2. cheap LLM classifier (only on no-match) │
│ 3. <0.70 → human triage queue ("Unknown" badge) │
└───────────────────────────┬──────────────────────────────────┘
▼
tbl_actions ◄── DURABLE QUEUE (Supabase) ──► audit
│ (Paperclip pulls; survives outage)
▼
┌─────────── Paperclip (VPS) — specialist agents ──────────────┐
│ Enquiries (Sonnet) Maintenance Tenancy Onboarding │
│ Accounts Marketing (+ RentAgent/DepositAgent ringfenced) │
│ per-agent budget · instruction folders · tbl_agent_logs │
└───────────────────────────┬──────────────────────────────────┘
▼
tbl_message_approvals (SHADOW → GATED → AUTO, ADR-091)
→ human review → send
Migration sequence: (1) keep and verify the gmail-sync → InboundPipeline wiring against the 328-email backtest corpus; (2) extract the hardcoded 4-step rules into tbl_triage_rules, seeding portal domains and keyword sets; (3) repair the Paperclip agent roster (delete the errored agent, register the ratified roster with instruction folders and per-agent budgets); (4) flip PAPERCLIP_TRANSPORT=api for PropertyEnquiriesAgent only, run SHADOW in parallel, diff drafts against the 264 human-reply backtest, and retire property-enquiries-agent.ts at parity (dispatcher/executor stay as queue plumbing, with the local transport kept as a degraded-mode fallback); (5) fan out channels in the locked order, each gated SHADOW→GATED per ADR-090/091.
Repository Code
The live triage implementation sits in the portal bridge; the dormant omnichannel stack sits in 08_channels:
Chapter 5: Token Economy — Today vs Deterministic-First Target
The design principle is that classification should be free and only generation should cost tokens — and even generation is gated. The live email path already honours this; the target extends it to every channel and every rule.
| Step | Today | After (rules-first target) |
|---|---|---|
| Junk filtering (email) | 0 tokens — hardcoded blocklist, pre-DB-write | 0 tokens — DB-backed blocklist, no deploy to update |
| Email triage (WHO/PROPERTY/ISSUE/FOLLOW-UP) | 0 tokens — pure DB lookups + regex (inbound-pipeline.ts) |
0 tokens — tbl_triage_rules ordered evaluation, ≥0.90 routes directly |
| Portal enquiries (dominant listing aggregator/incumbent property portal/OTM/OpenRent/SpareRoom) | 0 tokens to triage, but then routed like any email into the generic cascade and answered by a Sonnet-4.6 agent | 0 tokens end-to-end for triage: sender-domain fast-path + structured portal parse (leads are structured data; no model needed to classify) |
| Ambiguous messages (no rule match) | Default to general/low silently — no fallback classifier, misroutes possible |
Cheap classifier (Haiku/DeepSeek-class) only on rule miss; <0.70 confidence → human queue at 0 tokens |
| Voice — unknown caller | LLM per call — Gemini 2.5-flash classifies every unknown caller (voice/triage:170–198) |
Rules first on caller metadata/transcript; LLM only on rule miss |
| WhatsApp replies | Claude reply per inbound message after keyword escalation check (own bespoke flow) | Shared pipeline: deterministic triage first; drafting only when a reply is actually owed |
| Reply drafting | claude-sonnet-4-6 in property-enquiries-agent.ts — the only LLM call in the live email path (rule-based tracks return modelUsed:'rule-based' :153, :172) |
Unchanged in principle: generation is the one legitimate token spend, gated by tbl_message_approvals; per-agent budgets in Paperclip |
| Dormant omnichannel (if it had shipped) | Would burn an LLM call per message — ConciergeAgent classifies every inbound with Haiku/Gemini-flash (08_channels/triage/concierge_agent.ts:193–243) |
Its hard/soft/auto rules engine (:177–183, default = human ticket) is the best rules-engine skeleton in the repo — salvage the rules, drop the always-on classifier |
Chapter 6: Open Contradictions — the ADR-265 Agenda
Three unresolved contradictions block a coherent triage architecture. Per STATE.md the next ADR number is 265; it must decide all three (and formally disambiguate the three Paperclips of Chapter 3).
1. Canonical address: enquiries@ vs accounts@
ADR-095 (2026-04-09) decided to retire maintenance@ and enquiries@rentlondonflat.com and keep accounts@ as the sole canonical address (it is the Intercom-forwarded address). The current operating model, however, routes portal mail to enquiries@ — meaning either ADR-095's migration never executed, or the mental model and the ADR have diverged. ADR-265 must pick one address and put the migration (or the reversal) on record.
2. Two rival InboundPipeline implementations
The bridge pipeline (src/lib/bridge/inbound-pipeline.ts) is live and 100% deterministic. The Omnichannel pipeline (08_channels/pipelines/inbound_pipeline.ts, with routes at /api/channels/ingress/{email,twilio,telegram} via the @channels/* tsconfig alias) is dormant, LLM-led (ConciergeAgent), but carries the better channel adapters, PII classification, and rules-engine skeleton. ADR-265 must declare one canonical pipeline and a salvage plan for the other — the recommended split is: keep the bridge as the spine, absorb the 08_channels adapters and the ConciergeAgent hard/soft/auto rule set, discard its always-on classifier.
3. Runtime: Vercel 60-second ceiling vs VPS daemon
Shipped triage runs on Vercel serverless (ADR-139 Phase 1) with its known 60-second execution ceiling — a constraint TRIAGE-INFRASTRUCTURE-HANDOVER.md (2026-05-22, Task 2) already flagged as a reason to containerise. The docs hub still describes triage as a VPS daemon. No ADR has ever formally located the triage brain. The recommended resolution: deterministic triage stays on Vercel (it is I/O glue, fast, and scales with webhook fan-out), while long-running specialist agents live in Paperclip on the VPS behind the durable tbl_actions queue — so the 60s ceiling never applies to agent work and the VPS is never a synchronous single point of failure.
Chapter 7: Pitfalls and Sharp Edges (Live Code, Verified)
1. Silent pipeline failures (Severity: Critical)
The problem: gmail-sync calls InboundPipeline.process() non-blocking; failures are only console.warn'd (gmail-sync/route.ts:348–367). A broken pipeline means messages land in the inbox with no action created and no alert.
Mitigation: add a failure counter/alert on pipeline errors before promoting past SHADOW.
2. Dispatch trigger not on record (Severity: Critical)
The problem: POST /api/bridge/dispatch is CRON_SECRET-gated but absent from vercel.json crons (which lists only outbound/dispatch, gmail-sync, property-link-backfill). If nothing external calls it, AI-owned actions queue forever at stage=null.
Mitigation: verify the actual trigger and register it in vercel.json (or the ADR-265 runtime decision).
3. Keyword collision: "rent" (Severity: Caution)
The problem: "rent" appears in both the rent/arrears branch and the enquiries branch of the ISSUE cascade (inbound-pipeline.ts:80–151); evaluation order silently decides the category. "How much is the rent?" from an applicant can classify as arrears.
Mitigation: role resolution (Layer 4) disambiguates — known tenant → arrears; unknown/applicant → enquiry. Encode as rule priority in tbl_triage_rules.
4. Greedy follow-up matching (Severity: Caution)
The problem: findOpenActionForFollowUp (actions-logger.ts:166–187) matches the newest open action for a person/asset with no category or time-window filter — any open action swallows new, unrelated messages from the same person.
Mitigation: constrain by category and a rolling window before promoting past SHADOW.
5. Unscoped, unnormalised phone lookup (Severity: Caution)
The problem: the WhatsApp person lookup (webhooks/timelines/route.ts:157–162) is an exact string match on E.164 with no formatting normalisation and no organisation_id scoping — a formatting variant creates a miss; a multi-org future creates cross-tenant leakage risk.
Mitigation: normalise E.164 on write and read; add org scoping now, while single-org.
6. Docs drift is the meta-pitfall (Severity: Caution)
The problem: the docs hub, the ADRs, and the shipped code describe three different triage systems (VPS No-LLM daemon vs LLM-confidence bridge vs what actually runs). This page is evidence-linked precisely so it can be falsified: every claim carries a file:line reference dated 2026-07-20.
Mitigation: when the bridge or rules change, update this page in the same PR (docs-mirror contract).
Chapter 8: Verification Checklist
Verify the live path
- –Confirm
gmail-syncimports and callsInboundPipeline(route.ts:42,:352) and thatvercel.jsonstill schedules it every 5 minutes. - –Confirm zero LLM imports in
src/lib/bridge/inbound-pipeline.ts— triage must stay deterministic. - –Check drafts accumulate in
tbl_message_approvalsand nothing auto-sends (SHADOW).
Verify the gaps stay closed
- –Query
information_schema.tablesfortbl_triage_rules— once created, seed portal domains and rerun the 328-email backtest. - –Grep
executor.tsfor the category dispatch map — therunPropertyEnquiriesAgenthardcode at :51 must be gone before any non-enquiry agent is promoted. - –Confirm ADR-265 exists and decides: canonical address, canonical pipeline, triage runtime, and the Paperclip disambiguation.