RAIA™ Specification

Universal Inbox — Core of RAIA (Real estate Artificial Intelligence Agent) Operations, Labels SSOT, Audience & Chip Palette (ADR-273/280/285/286)

The Universal Inbox is the front desk of the whole company. Every message that arrives — email, portal alert, e-sign completion — is turned into a plain, safe note by a simple recipe (never by a guessing robot), sorted by a points system into "definitely ours", "probably ours", or "not sure", and only then does a human (or an approved robot draft) answer it. Gmail keeps the fancy original letter forever; the inbox keeps the working note and the buttons that get work done.

← Back to Developer Hub TEXTBOOK SPECIFICATION
In Plain English

The Universal Inbox is the front desk of the whole company. Every message that arrives — email, portal alert, e-sign completion — is turned into a plain, safe note by a simple recipe (never by a guessing robot), sorted by a points system into "definitely ours", "probably ours", or "not sure", and only then does a human (or an approved robot draft) answer it. Gmail keeps the fancy original letter forever; the inbox keeps the working note and the buttons that get work done.

The ops work surface where every inbound message is ingested, deterministically distilled, mechanically triaged, confidence-banded, and turned into linked actions/jobs — with AI restricted to sandbox reply composition and HITL catching everything uncertain.

ADR-273 ADR-280 ADR-285 ADR-286 / V309 Accepted — doctrine locked Deterministic-First Risk Tier: HIGH 2026-08-01
0
LLM calls in the body-storage path — distill is a pure deterministic function
3 + 1
Confidence bands — high / medium / low ("Not sure" HITL) + shadow reject
100%
Reject precision required on the golden set before any auto-reject is enabled
1
Stored copy per message — multi-mailbox is tags, never duplicates

Section A Why the Inbox Is the Core of Operations

Every working day at an estate agency starts the same way: a pile of messages. A tenant reporting a leak, a landlord asking about rent, a portal sending a new enquiry, an e-sign service saying a contract was signed. In most agencies that pile lives inside an email program, and the work — creating a maintenance job, chasing a deposit, updating a tenancy record — happens somewhere else, by hand, when somebody remembers.

The Universal Inbox deletes that gap. It is not an email client; it is the ops work surface where messages become work. A message arrives, is reduced to a safe plain-text note with a few trusted clickable links, is scored by a mechanical points system, and lands in front of the right person already linked to the tenant, the property, and the open actions it touches. One click creates the job. Nothing is re-typed. Nothing is lost in someone's personal mailbox.

Three locked doctrine points make this safe (ADR-273):

  • The body is a deterministic extract, never an AI rewrite. The same email always produces the same note — so it can be tested, diffed, and audited. No robot paraphrases what the customer "really meant".
  • No HTML email is ever stored or rendered. The full-fidelity original — formatting, images, attachments — stays in Gmail, one deep link away on every message. This removes the entire XSS/tracking/phishing attack surface instead of trying to tame it.
  • AI only drafts replies in a sandbox, and only when needed. A human approves every draft before it sends. AI never decides what a message says; it only helps answer it.

The Pipeline Shape

The mission of the pipeline, in one line: Ingest → deterministic distill → mechanical triage (90%+) → confidence bands → AI sandbox reply only when needed → HITL "Not sure" → create/link actions and jobs.

  1. 1
    Ingest — Gmail filters first

    Server-side Gmail labels (RAIA/INBOX, RAIA/NOTIFY) decide what is even allowed in. Junk never crosses the door. RAIA (Real estate Artificial Intelligence Agent) reads labels; it never writes them.

  2. 2
    Distill — one pure function

    MIME walk → prefer plain text → normalize whitespace/quotes → unwrap tracking redirects. Byte-stable output for a given source message, versioned by distill_version.

  3. 3
    Triage — mechanical rules handle 90%+

    Sender resolution, portal detection, junk rules: the deterministic ruleset routes almost every message with zero AI. The full ruleset lives in § 3.30 Universal Inbox Triage Rules — this page defines the doctrine they run on, not the rules themselves.

  4. 4
    Confidence — three bands plus a shadow reject

    A mechanical score (0–100, no LLM) routes high/medium to the normal queue, low to the "Not sure" HITL queue, and would-be rejects to "Not sure" too until the golden set proves 100% reject precision.

  5. 5
    Reply — AI sandbox only when needed

    Most messages need an action, not an essay. When a written reply is warranted, AI composes a draft that a human approves before send. The draft never replaces the message.

  6. 6
    Act — create and link actions/jobs/tasks

    Every created entity stores the originating conversation_id/message_id back-reference. The inbox is the entry point into the EstateAigents OS loop, not a dead end.

Section B Working a Message (Ops Workflow)

Staff open the inbox to a queue of plain-text message bubbles, WhatsApp-style. Each bubble shows the distilled body, the linked person and property in the right panel, a handful of clickable trusted links (e-sign, payments, portals, our own app), and a View in Gmail link for the full original.

What You Can Do in the Inbox
  • Read the distilled plain-text body — safe by construction
  • Click allowlisted action links (https only)
  • Approve, edit, or discard the AI sandbox draft reply
  • Create an action/job/task from the message — one click
  • Open the full original in Gmail (deep link on every message)
What the Inbox Never Does
  • Render HTML email, images, or remote content in the body
  • Show an AI summary as the message (secondary panel only, labelled)
  • Auto-send any reply — every draft is human-approved
  • Auto-reject a message (shadow-only until golden-set gate passes)
  • Duplicate a message across mailboxes — mailboxes are tags

The "Not Sure" HITL Queue

Low-confidence messages are not a failure mode — they are the designed pressure-release valve. The "Not sure" queue asks a human one of a small set of mechanical questions:

  • Confirm person — is this really the tenant/landlord we resolved to?
  • Confirm asset — which property does this message concern?
  • Confirm inbox membership — does this belong in the ops queue at all, or is it junk/marketing?

Verdicts are recorded deterministically and feed the rules, never a hidden model: two junk verdicts on the same sender add it to the org blocklist (scoring input I7); recurring misroutes go into the weekly rules-tuning review. No implicit ML, no automatic weight mutation.

!
Shadow reject is the default posture

Until the golden-set suite proves 100% reject precision (zero false rejects on real, human-labelled messages) in CI, every would-be reject is parked in "Not sure" with reason shadow-reject. Nothing is silently dropped from the staff work queue.

The Gmail Escape Hatch

Gmail remains the full-fidelity archive: all MIME parts, headers, attachments, and threading, exactly as received. Every message row carries a gmail_url — computed at render time from the Gmail thread ID, never stored — that opens the exact original in Gmail web. Staff use it for anything the distill intentionally drops: layout, branding, images, signatures, quoted history in full fidelity, and attachments (which surface as document links per ADR-155, never inline).

Section C Deterministic Distill — Contract

The stored content is produced by a pure function of the Gmail message. Normative algorithm order (appendix spec: docs/planning/universal-inbox-distill-confidence-spec.md):

distillBody(gmailMessage: GmailMessageRaw, distillVersion: int) -> DistillResult

DistillResult = {
  content: string          # plain text, UTF-8, \n line endings
  extracted_urls: UrlHit[] # every URL found, with allowlist verdict
  warnings: string[]       # e.g. "html-only source", "truncated"
}

UrlHit = { url: string, allowlisted: bool, scheme: string }
#StepRule
1MIME walkDepth-first, first text/plain wins; html-only → deterministic tag-strip + warning
2DecodeQuoted-printable / base64 per part headers; charset → UTF-8 (replace on errors)
3Line endings\r\n, \r → \n
4Tracking unwrapDeterministic decoders only; unknown wrappers left as-is; no heuristic guessing
5Whitespace3+ blank lines → 1; trailing spaces stripped
6Quoted historyPreserved in content; machine-readable marker computed so UI can collapse
7URL extractionRegex over final text; classify against allowlist; text itself unchanged
  • Pure: same input + same distill_version → byte-identical output. No clock, no randomness, no network, no LLM.
  • Total: never throws on malformed MIME; falls back to Gmail snippet with a warning.
  • Bounded: 20,000-char cap; truncation appends \n… [truncated — view in Gmail] plus a warning.
  • Versioned: any change to steps 1–7 increments distill_version and ships with a re-distill backfill script.

Rendering Contract (WhatsApp-Style)

  • Body renders as plain text, whitespace-pre-line, no dangerouslySetInnerHTML.
  • Linkify at render: only allowlisted == true URLs become <a target="_blank" rel="noopener noreferrer">. Everything else is plain text.
  • Allowlist v0 (admin-editable config, org-scoped, audited): *.docusign.net, *.hellosign.com, *.dropbox.com/sign, *.gocardless.com, *.stripe.com, *.rightmove.co.uk, *.zoopla.co.uk, *.estateaigents.com. https: only.
  • Every bubble carries "View in Gmail" using the computed gmail_url.
  • AI summaries, if present, render in the right panel only — never in the bubble.

Confidence Score — Inputs, Weights, Bands

Every ingested message gets a deterministic score (no LLM): score = clamp(sum(inputs), 0, 100). The mechanical triage rules (ADR-267/269) handle 90%+ of routing upstream; this score governs the residual confidence bands. Full triage ruleset: § 3.30 Universal Inbox Triage Rules.

#InputSignalPoints
I1Sender resolved via tbl_persons_channels.channel_value to a person_id in this orgexact match+40
I2Resolved person has live link: tbl_tenancies_persons (tenant) or asset ownership (landlord)role known+20
I3Gmail label = RAIA/INBOXpre-filtered human-relevant+20
I4Gmail label = RAIA/NOTIFYautomated but expected+5
I5Asset disambiguation: asset_id set, or exactly one address token matchunambiguous property+15
I6Sender domain matches org's own domaininternal+10
I7Sender on org blocklist (≥2 HITL junk verdicts)known-bad−50
I8No RAIA/* label at allunfiltered−20
I9List-Unsubscribe header AND no person resolutionprobable marketing−15
I10Person links to multiple assets, no subject/body matchdisambiguation failed−10
BandScoreRoute
High≥ 70Universal Inbox, normal queue
Medium40–69Universal Inbox, normal queue (low-confidence context flag in UI)
Low10–39"Not sure" HITL queue
Reject< 10Gmail only — shadow-only until golden-set gate passes (D9)
!
Golden-set gate before any live reject (D9)

The versioned corpus (tests/inbox/golden/) of anonymized real messages with human verdicts (inbox, not_sure, reject) runs in CI on every rules/weights change. Promotion criterion: reject precision = 100%. Weights and bands are config, not code — a config change that fails the golden set does not deploy. Same gate philosophy as ADR-177 transform gates.

Data Contract — Field List

FieldStatusPurpose
external_message_idExistingGmail message ID; dedup key across mailboxes (D7)
external_thread_idNewGmail thread ID; one logical thread across mailboxes
gmail_urlNewDeep link — computed at render: https://mail.google.com/mail/u/0/#all/<thread_id>; zero storage
inbound_mailboxes[]NewMailbox tag array — tags, never copies (D7)
contentExistingDeterministic distilled extract only; HTML never stored
content_htmlRejectedADR-272 D2 superseded — no HTML storage anywhere in the pipeline; V272 migration must not run
confidence_scoreNewSMALLINT 0–100, mechanical score (D8)
confidence_bandNewhigh / medium / low / reject
gmail_labelsNewLabel snapshot at ingest for audit + rules debugging
distill_versionNewVersion of the distill function; enables unambiguous re-distill migrations
!
No silent schema (D10 + standing rule)

Every field marked New requires a DDL migration dispatched to Programmer only after Eugin's explicit approval. No new actions/jobs/tasks linkage schema may be invented without flagging Eugin — interface points use existing tables (tbl_conversations, tbl_actions); any gap is raised as a question, not silently migrated.

Phased Build (Programmer Dispatch Order)

PhaseScopeGate
0 — GuardConfirm V272 content_html not applied to live; hold all ADR-272 HTML-render work—
1 — Distill coredistillBody() + unit tests, WhatsApp-style render + allowlist linkify, computed gmail_url, golden-set harness scaffoldNo schema change; determinism tests byte-stable
2 — Identity + confidenceMigration (6 new fields), mechanical scorer I1–I10, three-band routing, mailbox tag dedupEugin-approved migration; band-boundary unit tests (9/10, 39/40, 69/70)
3 — Gmail contract + HITLFilter/label runbook finalized, "Not sure" queue UI, verdict feedback into rules tuning, shadow-reject routing verifiedGolden-set 100% reject precision before live reject (D9)
4 — Actions loopMessage → action/job/task creation wired to tbl_actions, back-references stored, Outstanding Actions surfacingAPI curl verification on staging (standing rule); O3-DB dependency

Dispatch mechanics follow standing Programmer rules: parallel fix/<slug> branches, PA merges, no PRs, kanban_complete with SHA + API curl proof.

Non-negotiables Checklist

RuleCheck
No LLM in the body-storage pathD3 — deterministic distill only
No HTML stored or rendered in inbox bodiesD5 — content_html rejected; ADR-272 D2/D3/D6 superseded
Gmail deep link on every messageD2 — computed at render, always correct
Mailboxes as tags, never copiesD7 — dedup on external_message_id
Reject rules gated on golden-set 100% precisionD9 — shadow-reject until proven
No new schema without flagging EuginD10 + Data Contract table
Gmail label writes forbiddenD6 — RAIA (Real estate Artificial Intelligence Agent) reads labels; ops maintains filters in Gmail
KISSOne distill function, one scorer, three bands
Source of Truth

The canonical doctrine record is 03_technology/architecture/decisions/ADR-273-universal-inbox-distill-doctrine.md; the implementable mechanical spec is 03_technology/architecture/briefs/universal-inbox-distill-confidence-spec.md; the live Gmail filter HITL pack is 03_technology/architecture/briefs/HITL-gmail-filters-enquiries-2026-07-26.md. The labels + audience model canonical records are ADR-280, ADR-285, ADR-286 (as amended) with migrations V307/V309 — see Section D. This page is the human-readable companion; where they differ, the ADR wins. The triage ruleset itself lives at § 3.30 Universal Inbox Triage Rules — linked, not duplicated.


Section D Labels, Audience & Chip Palette — Content SSOT, System Audience Flag, and Chip Colour SSOT

Cutover applied to production 2026-08-01. This section is the canonical human-readable reference for the live label + audience model, the Universal Inbox vs Chat product boundary, and the chip colour single source of truth. It replaces the retired 16-value conversation_type content mix. Sources: ADR-280 (mechanical labels), ADR-285 (labels SSOT + phased retirement), ADR-286 as amended (repurpose not drop), V307 (CHECK hardening), V309 (internal|external).

ELI5 — Two Chips, One Audience Flag, Two Different Inboxes

Every conversation in the Universal Inbox now shows two independent chips and carries one audience flag:

  • Channel chip — how the message arrived (Email, WhatsApp, Telegram, Phone). This is the transport. It never tells you what the message is about.
  • Category chip(s) — what the message is about (Enquiries, Maintenance, Accounts, IT, Compliance, Legal, HR, Marketing, Junk). A conversation can have several category chips. These come only from tbl_conversation_labels.
  • Audience flag — who the conversation is for: internal (staff / contractor product thread for that org) or external (tenant, landlord, supplier, portal, prospect — everyone else). This is tbl_conversations.conversation_type, repurposed 2026-07-31.

The old behaviour — one field trying to be both "what it is about" and "who it is for" — is gone. Content lives in labels; audience lives in conversation_type; transport lives in channel. Three axes, three homes, no overlap.

One product consequence: the Universal Inbox (left-nav Inbox) shows external threads only. Staff conversations (Telegram, aigent DMs, internal product threads) live in the separate left-nav Chat surface. The audience flag is what keeps them apart — but the UI never shows "Internal" or "External" as a pill. It is a system filter, not a user badge.

The Three-Axis Model (Eugin Lock 2026-07-31)

AxisColumn / TableValuesWho cares
Audiencetbl_conversations.conversation_typeinternal | externalProduct visibility — staff threads vs customer threads
Routingtbl_conversations.thread_kindcustomer | staff_bot | systemCode path — telegram webhook, staff DM, AI session exclusion
Contenttbl_conversation_labelsEnquiries, Maintenance, Accounts, Compliance, Legal, HR, IT, Marketing, JunkHuman triage + sidebar counts + stats
Transporttbl_conversations.channelemail, phone, whatsapp, aigent_telegram, …Channel chip in the UI
!
Product locks — read before touching labels
  • Content chips SSOT = tbl_conversation_labels only. No other table or column stores "what this conversation is about."
  • conversation_type = audience only. It is not a content category. Never write enquiry, maintenance, general, agent_aigent into it — V309 dropped those values.
  • Enquiries = sales + lettings only. It is not a catch-all for "anything at the enquiries@ mailbox." Portal tech alerts → IT; newsletters / Gumtree / saved-search digests → Junk.
  • Invalid multi-label: Enquiries+IT, Enquiries+Compliance. When Enquiries fires, all other candidate labels are dropped by the engine.
  • Channel chip ≠ category chip. "Email" is transport; "Enquiries" is content. They are rendered as separate chips.
  • inbound_address = RECEIVED AT telemetry (right panel). It is not a label and not a mailbox verdict — the mailbox prior is only a weak input signal to the label engine, never its output.
  • Mechanical-first labels; AI residual only. ADR-280 DA1 Option A: no heuristic band. Rules miss → AI fallback or HITL. Manual labels (assigned_by='manual') are never overwritten.
  • Org RLS is separate from internal/external. organisation_id scoping is unchanged; the audience flag does not replace RLS.

Universal Inbox vs Chat — The Audience Boundary

The Universal Inbox and the left-nav Chat surface are two different products serving two different audiences. They are separated by the conversation_type audience flag, not by user-facing filters or pills.

Universal InboxChat (left-nav)
Audienceexternal — customer threads onlyinternal — staff / contractor product threads
ChannelsEmail, WhatsApp, Phone, Web Chat, Social, AI Agents (A2A)Telegram, aigent DMs, internal system threads
API filterGET /api/inbox/conversations → .neq('conversation_type', 'internal')GET /api/webhooks/telegram / /api/ai/chat/sessions → .eq('conversation_type', 'internal')
User seesCustomer queue, triage labels, confidence bands, action creationStaff DM list, AI session history, internal notes
ADRADR-273 (distill doctrine), ADR-280/285/286 (labels + audience)ADR-286 V309 (staff-thread cutover to conversation_type='internal')
Never show Internal/External as user pills

The conversation_type value is a system audience flag, not a user-facing category. It must never appear as a chip, pill, or filter option in the Universal Inbox UI. The separation between Inbox and Chat is architectural — enforced at the API layer — not a visual badge the user toggles. If you need to explain why a conversation is missing from the Inbox, the answer is "it is an internal staff thread; look in Chat" — not "click the Internal pill."

conversation_type — System Audience Flag (internal | external)

tbl_conversations.conversation_type is a database-level audience discriminator. It is written at ingest time by the channel-specific webhook or cron route, and it is consumed by API queries to decide which product surface (Inbox vs Chat) serves the conversation. It is not editable by users, not displayed in the UI, and not a label.

ValueMeaningWritten byRead by
externalCustomer-facing thread — tenant, landlord, supplier, portal, prospect/api/cron/gmail-sync, /api/webhooks/voice/*, /api/webhooks/timelines, /api/channels/conversations, /api/conversations/webchat/ingest, /api/ai/chat/sessionsGET /api/inbox/conversations (excludes internal), asset view, AI session list
internalStaff / contractor product thread — Telegram DM, aigent session, internal note/api/webhooks/telegram (staff DM path)/api/webhooks/telegram (staff routing), /api/ai/chat/sessions (excludes internal)
i
Documented as internal|external in DB; UI silent

The schema comment on conversation_type (V309) reads: "Audience flag: internal = staff/contractor product thread; external = customer thread. Not a content category. Content lives in tbl_conversation_labels." The UI never surfaces this value. There is no "Internal" or "External" chip, no filter dropdown, and no settings toggle. The value exists purely so the backend can route the conversation to the correct product surface.

Chip Colour Single Source of Truth (chip-tokens.ts)

All chip colours in the Universal Inbox are defined in portal/src/lib/ui/chip-tokens.ts. No component may hardcode a chip colour. The palette is designed to be theme-stable (fixed hex values that do not flip with light/dark mode) and semantically unambiguous (channel and category chips never share the same hue).

Chip TypeColour RuleExampleWhy
Channel chipNeutral slate — fixed #f1f5f9 bg, #334155 text, #cbd5e1 borderEmail, WhatsApp, Phone, TelegramReads as "how this arrived" metadata; visually subordinate to category chips
Category chipDistinct fixed hues per label — see palette belowEnquiries (indigo), Maintenance (amber), Accounts (emerald)Reads as "what this is about" signal; scannable across the list

Category Chip Palette (Fixed Hex Values)

LabelHexTailwind ReferenceUsage
Enquiries#4f46e5indigo-600Sales + lettings portal leads, genuine customer intent
Maintenance#d97706amber-600Repairs, boiler, leak, urgent property issues
Accounts#059669emerald-600Invoices, rent, payments, financial
Compliance#7c3aedviolet-600Regulatory, licensing, safety certificates
Legal#6366f1indigo-500Contracts, disputes, solicitor correspondence
HR#db2777pink-600Staff scheduling, payroll, internal HR
IT#0891b2cyan-600Portal tech alerts, system errors, listing sync
Marketing#e11d48rose-600Newsletters, campaigns, bulk senders
Junk#334155slate-700Spam, bulk mail, low-priority
Unknown / fallback#64748bslate-500Any label not in the palette above
!
Theme-stable by design

Chip colours do not change with light/dark mode. A user learns "Enquiries = indigo" once and recognises it in any theme. The 12% opacity tint background (1f suffix) and 25% opacity border (40 suffix) provide subtle visual weight without relying on theme variables. All combos target ≥ 4.5:1 contrast on white. Do not add theme-dependent chip colours — if a new label needs a colour, add it to chip-tokens.ts as a fixed hex value.

Data Flow — Email Ingest → Label Engine → tbl_conversation_labels

  1. 1
    Gmail-sync ingest

    Message arrives via /api/cron/gmail-sync. Distill produces plain text. conversation_type is set to 'external' (customer email thread) — V309 default.

  2. 2
    Label engine evaluates

    evaluateLabel(envelope, rules) in src/lib/email/label-engine.ts runs Layer 1 (jurisdiction) then Layer 2 (universal) rules from tbl_triage_rules. First match wins. Enquiries exclusivity drops other candidates.

  3. 3
    Label row written

    Verdict upserts into tbl_conversation_labels with assigned_by='rule' (confidence 1.0, zero tokens) or assigned_by='ai' (residue). No match → hitl_needed, no row written, conversation routes to "Not sure" queue.

  4. 4
    UI renders chips + counts

    List rows show category chips from tbl_conversation_labels. Sidebar counts call GET /api/inbox/label/bulk?org_id=…. Channel chip comes from channel. Audience flag filters staff vs customer views at the API layer — never shown as a pill.

UNIVERSAL INBOX — LABELS + AUDIENCE MODEL (V307/V309) Email Ingest Label Engine rules → AI → HITL tbl_conversation_labels Content SSOT (multi-pill) conversation_type internal | external Staff Telegram UI Chips + Counts category + channel chips Audience Filter API layer only — no pill Inbox Chat Content category → tbl_conversation_labels only  ·  Audience → conversation_type (internal|external)  ·  Transport → channel V307 hardened CHECKs (rule + Junk) · V309 repurposed conversation_type · Enquiries = sales+lettings only · Chip colours = chip-tokens.ts SSOT

Figure: Three-axis model — content, audience, and transport are stored separately. The audience flag routes to Inbox (external) or Chat (internal) at the API layer; it is never rendered as a user pill.

Enquiries Scope Lock — Sales + Lettings Only

ADR-286 D1/D2 locks the Enquiries label to genuine sales/lettings intent. The mailbox prior (enquiries@, lettings@) is demoted from verdict to weak signal — it no longer independently applies the label.

ScenarioLabelWhy
dominant listing aggregator / incumbent property portal / alternative listings channel / SpareRoom / OpenRent enquiry, viewing, application, offerEnquiriesGenuine sales/lettings intent
Portal tech alert — "photos not uploading", "system error", "listing alert"ITPortal system notification, not a customer enquiry
Gumtree ad, newsletter, saved-search digest arriving at enquiries@JunkNegative rule priority 4 catches bulk/marketing
Enquiries + any back-office label (IT, Compliance, Legal, HR, Marketing)InvalidEngine drops all other candidates when Enquiries wins

Re-running the Label Backfill (Staff API)

The one-shot backfill route populates labels for historical email conversations that have none. It uses the same mechanical engine as live ingest — no Gmail re-download, no AI spend on the mechanical slice.

POST /api/admin/inbox/label-backfill
Content-Type: application/json
Authorization: *** session>

{
  "org_id": "optional — omit for all orgs",
  "limit": 500
}

→ Response: { processed: N, labelled: N, skipped_hitl: N, skipped_already: N }
  • Max 500 conversations per call; rate-limited to prevent runaway writes.
  • Skips conversations that already have at least one label.
  • Never overwrites assigned_by='manual' rows (M1 immutability).
  • hitl_needed verdicts are silently skipped — no row written.
  • Gate: T1 golden-set CI gate (170-row fixture) must pass before production backfill writes.

Migration Timeline — V307 + V309

MigrationDateChangeADR
V2862026-07-30tbl_conversation_labels created (zero rows initially)ADR-280
V3072026-07-31CHECK hardening: assigned_by gains 'rule'; label CHECK gains 'Junk'; covering index (label, conversation_id)ADR-285
V308a2026-07-31thread_kind column added (routing axis)ADR-286
V3092026-08-01conversation_type repurposed: old 16 values → internal | external; COMMENT ON COLUMN; partial indexADR-286 (amended)
Source of Truth — ADRs & Briefs
  • ADR-273 — Universal Inbox distill doctrine (parent)
  • ADR-267 — Jurisdiction-aware triage rules (rules engine shape)
  • ADR-280 — Mechanical content labels + org email migration (DA1–DA4 delta)
  • ADR-285 — Conversation label SSOT phased retirement (amended: repurpose not drop)
  • ADR-286 — Enquiries scope lock + thread_kind (amended: V309 repurpose)
  • Briefs: architect-mechanical-labels-org-email-migration-2026-07-30.md, architect-inbox-label-ssot-schema-2026-07-31.md, architect-conversation-type-internal-external-2026-07-31.md, architect-mechanical-labels-DA1-DA4-delta-2026-07-31.md
  • Migrations: V307__conversation_labels_ssot_hardening.sql, V309__conversation_type_internal_external.sql
  • Code: portal/src/lib/email/label-engine.ts, portal/src/app/api/cron/gmail-sync/route.ts, portal/src/app/api/inbox/label/bulk/route.ts, portal/src/app/api/admin/inbox/label-backfill/route.ts, portal/src/lib/ui/chip-tokens.ts

References

  • Ng — workflow/topology framing for the confidence fan-out (chain → bands); conceptual footnote only, not deployable
  • Kopadze — deterministic gates over probabilistic display paths
  • wandermist — golden-set evaluation methodology for gated automation
  • leopardracer — HITL queue patterns for uncertain classification
INBOX OPS ARCHITECTURE Layer 1 Channels Email · SMS · WhatsApp Ingestion queue tbl_inbox_messages Layer 2 Classification ML + rule engine Priority scoring Urgency detection Layer 3 Dispatch Role-based routing Action handlers Reply · Archive · Flag Multi-channel ingestion → classification → route → action