Repository navigation
Description
What should be improved?
Tale has two Knowledge directories — Customers and Vendors — that are structurally near-identical contact records dressed in mismatched vocabulary. Neither carries real commercial semantics; both are functionally per-org address books. Consolidate them into a single Contacts entity.
This also fixes a correspondent-model defect: a conversation can only attach to a customerId, so every email correspondent (vendor, partner, colleague, anyone) is force-materialized as a "customer." The word is baked into the schema, not the result of any classification.
Current behavior
Customers (services/platform/convex/customers/schema.ts)
- Fields are 100% identity / contact / provenance / governance:
name, email, externalId, status, source, locale, address, metadata+ soft-delete plumbing. No revenue, deals, orders, billing, owner, or pipeline — and no commercial tables (deals/orders/invoices/subscriptions) exist anywhere in the schema. - The only CRM-flavoured field,
status(active|churned|potential), is written and displayed but never consumed — no branch, metric, automation, or view acts on its value.statusChangedAtis declared but never written for customers. Theassess-customer-statusworkflow only writes it and no cron runs that workflow. - Records are auto-materialized:
workflow_engine/action_defs/conversation/helpers/find_or_create_customer_from_email.tsmints astatus:'potential'customer for any inbound/outbound email address. There is no intentional "this is a customer" flow. - Filed under the Knowledge nav, not Sales/CRM (
app/features/knowledge/components/knowledge-navigation.tsx:51-54, route_knowledge/customers).
Vendors (services/platform/convex/vendors/schema.ts)
- Same base fields as customers, plus
phone,tags[],notes; minus thestatusenum. Same governance, RLS shape, list/table/import/edit/delete UI, parallel agent tools and workflow action — the tables were clearly copied from one another. - Nothing points at a vendor: no conversation or support_case FK, no email resolution, no domain events, not in global search. Created only via manual import / REST / agent / workflow.
The incoherence: the product already models a Customer/Vendor split, but the conversation layer ignores it — conversations/schema.ts:9 has only customerId: v.optional(v.id('customers')) (there is no vendorId anywhere), so a vendor's email is stored as a "customer."
Proposed change
Collapse Customers + Vendors into one Contacts entity — one contacts table, one feature dir, one nav item, one set of Convex functions / agent tools / workflow action / REST routes — and repoint conversations.customerId → contacts so any contact can be a correspondent. That last part is the actual fix for "every correspondent is a customer."
The only things that made "customers" different (the status enum, the conversation/case FKs, events, global search) are features that were only wired to that one table, not anything intrinsic to being a customer. So a flat Contacts model is clean — those features simply apply to all contacts.
Open decisions (needs discussion) — product calls, not mechanical:
- Flat vs discriminator. Recommended: flat
contactswith an optionaltype/tag only if we still want to filter "customers" vs "vendors". A hardtype:'customer'|'vendor'discriminator is only warranted if we deliberately keep FK/behaviour asymmetries; the audit suggests we don't need them. - Fate of
status.active|churned|potentialis customer-lifecycle vocabulary that doesn't fit generic contacts and is never consumed today. Recommended: drop it (or replace with a neutral optional label). - Vendor-only fields (
phone,tags,notes) become standard optional contact fields. - Search + events are customer-only today — decide whether all contacts become searchable / event-emitting (recommended: yes, uniform).
Blast radius (code pointers) — mirrored customer/vendor pairs at every layer:
- Schema + migration:
customers/schema.ts,vendors/schema.ts,schema.ts:154,299; repointconversations/schema.ts:9,37andsupport_cases/schema.tsFKs. Ships a versioned, reversible migration (migrations:checkgate) that createscontacts, backfills both tables, and rewrites FKs. - Convex fns:
convex/customers/*(~28 files, incl.find_or_create_customer.ts,get_customer_by_email.ts,search_customers.ts) +convex/vendors/*(~12) → oneconvex/contacts/*. - Conversation consumers:
create_conversation*.ts,list_conversations_paginated.ts:111,118,transform_conversation.ts:42,48-49,80,160-168,198,reply_to_conversation.ts:85,find_or_create_customer_from_email.ts,conversation_action.ts:160. - Events:
workflows/triggers/event_types.ts:64-79(customer.*→contact.*; vendors emit none today). - REST:
http.ts:1179-1214(customers, 8 routes) +:1220-1250(vendors, 6) → one/api/v1/contactsset. - Agent tools:
agent_tools/customers/*,agent_tools/vendors/*;tool_names.ts:19,43,47-48;tool_registry.ts:13-14,48-49,73,97,101-102. - Workflow engine:
action_defs/customer/customer_action.ts,action_defs/vendor/vendor_action.ts;action_registry.ts:6,19,44,48. - Governance / retention:
governance/internal_mutations_retention.ts(customer + vendor deletes),builtin-configs/governance/retention.json,retention-policy.json,lib/shared/schemas/retention.ts:22,schemas/governance.ts:324. - RLS / permissions:
lib/rls/helpers/access_control.ts,rls_rules.ts:224-248,auth.ts(per-role),lib/permissions/ability.ts:22,90. - Search:
lib/search/strategies/customers.ts,lib/search/index.ts:12(vendors not indexed today). - Frontend:
app/features/customers/*(~23 files) +app/features/vendors/*(~16) → oneapp/features/contacts/*; routes_knowledge/customers.tsx+vendors.tsx→contacts.tsx; navknowledge-navigation.tsx:13-59,use-navigation-items.ts:112-122. - i18n:
messages/en.jsoncustomer + vendor blocks (e.g.:1935,1992,2034,2080-2139,2166-2167,4049,4079-4081,7621-7670) and the parallelde.json/fr.jsonblocks (native voice, not literal — seewrite-translations).
Acceptance criteria
- A single
contactstable replacescustomersandvendors, with a versioned, reversible migration that backfills existing rows and passesmigrations:check. -
conversations(andsupport_cases) reference a contact; a correspondent from any source is no longer labelled "customer" in schema or copy. - Open decisions 1–4 resolved and reflected in the schema (discriminator/tag,
statusfate, vendor fields, search/events). - One Contacts feature (list / view / edit / import / delete), one nav item under Knowledge, one route.
- Convex fns, agent tools, workflow action, REST routes, events, RLS/permissions, retention consolidated to
contacts; no danglingcustomers/vendorssymbols. - All user-visible "Customer"/"Vendor" strings reframed to "Contact" across
en,de,fr(native voice, not word-for-word). -
bun run checkgreen; conversation correspondent display verified end-to-end.
Related (closed) — all symptoms of the parallel-but-divergent customer/vendor duplication this consolidates: #2060 (customer/vendor name-parity), #1993 (dup website/customer/vendor add), #1978 ("Unknown Customer" i18n), #1996 (conversation search misses customer name).
Grounded in a full read of the customers/ and vendors/ domains (schema, Convex functions, agent tools, workflow actions, REST, governance, i18n); the file:line anchors above are from that audit. Deduped against open and closed issues — no open duplicate.
Activity
feat(platform): add contacts table and backfill migrations (#2618)
feat(platform): add contacts table and backfill migrations (#2618 exp…
feat(platform)!: merge customers & vendors into contacts (#2618)
feat(platform)!: merge customers & vendors into contacts (#2618)
feat(platform)!: merge customers & vendors into contacts (#2618)
feat(platform)!: merge customers & vendors into contacts (#2618)
feat(platform)!: merge customers & vendors into contacts (#2618)
feat(platform): merge customers & vendors into contacts (#2618 switch) (
feat(platform): absorb the contacts merge into the migration framework
yannickmonney commentedon Jul 11, 2026
Verification (2026-07-12): the merge's code-level ACs are met on
main+ PR #2674. Evidence:convex/customersandconvex/vendorsare gone; one flatconvex/contacts/schema.ts(no type discriminator, nostatusenum — matching all four open decisions: flat model, status dropped, vendor fields standard, uniformcontact.*events + search strategy); REST is/api/v1/contactsonly; agent tools, workflow actions, RLS reference only contacts;migrations:checkgreen.Two loose ends, neither a functional bug: (1)
conversations/support_casesschemas still carry the transitionalcustomerIdfield documented as expand-contract leftover — the contract phase (dropping it) hasn't landed; (2)settings.logs.audit.actionLabels.customer/vendorlocale keys are deliberately kept for historical audit rows (the orphaned trash-tab keys were removed in PR #2674).Recommend closing this epic once #2674 merges, or keeping it open only to track the
customerIdcontract phase.fix(platform): restore transitional customerId schema fields