Skip to content
MSO CloudDocumentation

ADR 0022 — Pillar audience (Thảo luận khách hàng) + connector family content_intel

On this page
  • Status: Accepted (2026-07-31) — operator directive, after Fable review of the filled Implementation-status ledger (D1–D5 all Landed; cross-org gate + Tier-A set green on a fresh-migrated DB). Originally the Phase 0 merge gate of the MSO Audience Intelligence programme, approved by Fable review 2026-07-30 after a 15-agent chaired debate whose chair verified its findings against a live PostgreSQL 16.13, the repo, and the five real client files (private/mso-content-intelligence/mso-audience-intelligence-architecture.md §2). Awaiting operator acceptance. No schema PR may merge before acceptance — table work is ADR 0023's scope and ADR 0023 is its own merge gate.
  • Date: 2026-07-30
  • Context owner: Platform
  • Related: ADR 0008 (connector family = pillar map), ADR 0014 (D3 — vendor fixed-header maps, family market_intel), ADR 0017 (one mapping contract, two transports), ADR 0019 (D4 — pillar market landed through this same seam), ADR 0023 (taxonomy catalog — companion merge gate, drafted the same day), ADR 0024 + ADR 0025 (companions — tabs/widgets and the narrative gates). CLAUDE.md §32, §35, §47, §53, §57, §58, §62. The evidence bundle private/mso-content-intelligence/** is operator-local (gitignored); the quotations in this ADR are the durable record. Clients are named only by industry codename (Client A–E) in this repo; the real codename→identity map lives in private/mso-content-intelligence/CLIENT-CODENAMES.md (gitignored) — client vocabulary AND identity are operator data, not repo content (§44 / ADR 0023 D3).

Implementation status (declared 2026-07-30)#

This section is the ledger the implementing PRs fill, following ADR 0017's convention of auditing a decision at a time rather than declaring the ADR "shipped" wholesale. First filled 2026-07-30 (WP1 schema, WP2 stream, WP4 metric layer landed; WP3 promoters, WP5 reconciliation, WP6 surface in flight).

Decision Status Evidence that will count when it lands
D1 — pillar audience, not a plane Landed (2026-07-30) 'audience' in MetricPillar (packages/metrics/src/types.ts:52); the audience arm (pillar-resolvers/index.ts:168); PILLAR_PLUGIN.audience = 'content-intelligence' (shape.ts:191-197); first audience page ships gated — content-intelligence/taxonomy/page.tsx calls requirePlugin('content-intelligence') + requirePageMenuItem('content_taxonomy') (§47), plugin-page-guard.py green over 39 pages.
D2 — 1st-party, brand-scoped, inside verify:data Landed (2026-07-30) 14 content_*/agg_content_* tables with org_id + brand_id NOT NULL (migration 0129); RLS + inventory coverage (verify:rls 145 PASS on a fresh-migrated DB); Tier-A audience set #A1–#A11 + #A-GOLD + #A-ALIAS (102 assertions over the synthetic 10-kind fixture scripts/fixtures/audience-content-intel.ts, promoted through the REAL WP3 chain) green under pnpm run verify:data — 124 passed / 0 failed; R7 filter-sensitivity included. Chat (V3, 2026-07-31): AUDIENCE_CHAT_TOOLS (6 read-only tools over the §49 @yng/metrics/content-intel readers) composed into the ToolSet ONLY behind ctx.audienceEnabled (chat/tools.ts buildChatTools), prompt swapped by audiencePromptSection (AUDIENCE_TOOL_INTENT / AUDIENCE_DISABLED_GUARD), fail-closed assertion over the COMPOSED ToolSet in api/chat/route.ts, classifyChatMetric opens EXACTLY the audience pillar behind the same flag (market stays blocked under every gate), MCP import-time leak guard; §44 posture: counts + client-approved catalog labels only — no mention bodies, author names, links or PII spans. Guards: scripts/audit/chat-audience-isolation.py in audit:all + chat-audience-gating.test.ts (15 assertions).
D3 — the social pillar is not reused Landed (2026-07-30) pillar-resolvers/social.ts untouched by the audience commit (git show 9b58033f --stat — no social.ts entry); pillar-resolvers/audience.ts + packages/metrics/src/content-intel.ts read only content_* tables, enforced continuously by scripts/audit/audience-plane-isolation.py in audit:all.
D4 — trust grade declared Partial (2026-07-30) LANDED: required coverageBasis on the share-style return types in packages/metrics/src/content-intel.ts (33 tests green). OWED: the widget that cannot render without a base label (WP6 base bands) and the denominator ban check (WP6).
D5 — separation from ADR 0014 D3 Landed (2026-07-30) content_intel in connectorFamilySchema (packages/plugin-host/src/manifest.ts:64); zero diff in packages/connectors/socialheat + packages/connectors/socialtrend (9b58033f stat); audience-plane-isolation.py registered in audit:all (package.json), negative-control verified (planted crossing detected, clean tree green).

Context#

The Content Intelligence team's delivered product today is a file. Five client cases were reverse-engineered file by file — Client A (banking campaign), Client B (healthcare), Client C (FMCG), Client D (pharma customer journey), Client E (sponsorship weekly tracking) — and every one is the same shape: a vendor social-listening export preprocessed in Python, an agent skill that enriches it, and a multi-tab static HTML deck with a client-side password (private/mso-content-intelligence/mso-audience-intelligence-architecture.md §1). The client signs off on the numbers in that deck. This is a paid deliverable, not an estimate feed — which is the single fact that decides everything below.

The data is more uniform than the decks suggest. One row is one mention, with a fixed envelope (content, context, source_name, created_date, link, sentiment, platform, mention_type, id) plus per-client taxonomy columns — stages, intents, barriers, topics, open-vocabulary entity lists, eligibility flags, confidence ladders, evidence quotes, hierarchy roll-ups (architecture doc §1). What varies between clients is vocabulary, not structure. That is the shape ADR 0017 D1 already sanctions: one new stream registered once, customer variability absorbed by mapping templates, client #6 adding zero fields and zero code.

Phase 0 therefore decides one thing only: where this data lives in the platform's plane and pillar model. The wrong answer is expensive in a way that is invisible at review time — filing it on the 3rd-party plane silently exempts a signed-off number from the DATA gate (§53/§57) and locks the dataset out of the Data Assistant (§58); reusing the social pillar inherits an org-scoped, monthly-grained, self-row-only contract that the CI product contradicts on every axis. Both costs are argued from verified code below, not from preference.

Fact Evidence
The non-eCom pillar switch is exhaustive with no default branch — a missing arm narrows pillar to never, so a new pillar is a compile-time obligation, not a silent gap apps/web/src/server/pillar-resolvers/index.ts:141-165 (four arms: marketing, crm, social, market)
MetricPillar is a five-member enum — pillars (5) already outnumber data planes (3) packages/metrics/src/types.ts:44 — z.enum(['ecom','marketing','social','crm','market'])
Every pillar is gated fail-closed on one plugin id before any resolver runs pillar-resolvers/shape.ts:184-193 (PILLAR_PLUGIN) consumed at index.ts:134-139
Pillar market was added through exactly this seam by ADR 0019 D4 docs/adr/0019-universal-report-surface.md:42; the plane boundary is restated in packages/metrics/src/types.ts:38-43
The social resolver is org-scoped: zero brandId/brand_id occurrences in the whole 159-line file grep -n "brandId|brand_id" apps/web/src/server/pillar-resolvers/social.ts → no match
Its social-listening read path is monthly-grained — a sub-month window reads the containing month social.ts:24-32 (monthOf(dayLabel) → ${dayLabel.slice(0,7)}-01), applied at :44 and :85; the limitation is stated in the header comment social.ts:25-28
It renders only the org's own row, and abstains otherwise social.ts:34-36 (selfRow → brandTotals.find(r => r.isSelf)), :51-58, :61-70, :92-93
Its third slug is a daily topic-trend read with no brand dimension social.ts:115-127 (computeSocialTrendDailyTop over win.fromDate/win.toDate)
The pillar reads rollups only — never mention-grain rows readers import socialListening{BrandDaily,PlatformDaily,TopItems} (packages/metrics/src/social-listening-read.ts:5-7) and socialTrend{Posts,Rankings} (social-trend-read.ts:3); grep social_mentions social.ts → no match
A mention-grain table does exist — org-scoped, vendor-sourced, feeding the §46 rollup packages/schema/src/tables/social-market-intel.ts:146-157 (socialMentions, orgId() with no brand column, source default 'socialheat')
Market chat tools are gated twice: build-time inclusion plus a post-composition assertion that throws apps/web/src/server/chat/tools.ts:1486-1493 (if (ctx.marketEnabled)), apps/web/src/app/api/chat/route.ts:294-305 (fails closed on the ACTUAL ToolSet)
§57 — the market_intel_* ESTIMATE plane "stays out of verify:data by design" CLAUDE.md:138
§58 — market tools reach chat ONLY via MARKET_CHAT_TOOLS gated on ctx.marketEnabled; /api/chat asserts zero market keys when disabled CLAUDE.md:139
The connector family enum has three members and a docstring saying new families slot in without plumbing packages/plugin-host/src/manifest.ts:46-54 (connectorFamilySchema)
ADR 0014's SocialHeat/SocialTrend connectors are family market_intel, thirdPartyData: true docs/adr/0014-sheet-stream-connectors-social-crm.md:44-49
ADR 0014's own status line marks D3 superseded-as-history by ADR 0017; the fixed maps remain correct and in use for genuine fixed vendor exports docs/adr/0014-sheet-stream-connectors-social-crm.md:3; D3 text at :59-64
A vendor export arrives pre-filtered: Client E's workbook's own meta sheet declares default_filters={'is_relevant':1,'original_lang':'Tiếng Việt','week':'2026-W12'} Chair verification against the client file, recorded at private/mso-content-intelligence/debate/judge-decisions.md:28. Not independently re-verified by this ADR's author — the workbook is a client artifact outside the repo.

Decision#

D1 — A new PILLAR audience, not a fourth data plane

Content Intelligence joins the platform as pillar audience on the existing 1st-party plane: one member added to MetricPillar (packages/metrics/src/types.ts:44), one arm added to the exhaustive resolvePlaneCore switch (pillar-resolvers/index.ts:155-165), one entry added to PILLAR_PLUGIN (shape.ts:188-193) binding it to plugin id content-intelligence, and requirePlugin('content-intelligence') on every page (§47 — nav hiding is not enforcement).

The user-facing label is "Thảo luận khách hàng". The slug audience is a code identifier and is never rendered (§62 — no internal jargon, no vendor names in user copy).

The "fourth data plane" framing is explicitly dropped. The switch already carries four non-eCom pillars while the platform has three planes, so pillars already outnumber planes (types.ts:44 vs §57's three-plane rule) — adding a pillar is a routine, compile-time-checked extension, exactly how ADR 0019 D4 landed market (0019-universal-report-surface.md:42). It does not weaken §57's plane-mixing prohibition, because it does not create a plane to mix: audience data is 1st-party client data, governed by the same rules as the other 1st-party pillars. Inventing a plane would have inflated the very vocabulary §57 depends on being small.

The seam also makes the extension safe rather than trusting review: a new pillar that forgets its resolver arm fails to compile (index.ts:141-142 — TS narrows to never in the absent default branch), and one that forgets its plugin gate fails at the PILLAR_PLUGIN lookup, not at runtime on a customer's URL.

D2 — 1st-party, brand-scoped, INSIDE verify:data; chat-eligible only behind a future AUDIENCE_CHAT_TOOLS gate

Three properties, each with its enforcement:

  • Brand-scoped from row one. Every new fact table carries org_id and brand_id NOT NULL (root invariant 1: tenancy is org → brand; fact tables carry both), with an RLS policy and inventory coverage. This holds even while the programme provisions CI clients as dedicated orgs, so lifting that restriction later is configuration, not a migration.
  • Inside verify:data. Every metric-bearing audience surface owes a reconciliation assertion in scripts/audit/data-reconciliation.ts (§53). This is the load-bearing consequence of the deliverable being paid for: §57 keeps the estimate plane out of verify:data by design (CLAUDE.md:138) — correct for third-party estimates, and disqualifying for a number a client signs off on. Filing this feature under market_intel would not merely mis-label it; it would exempt the deliverable's numbers from the DATA gate.
  • Chat-eligible, but closed until V3. When audience data reaches the Data Assistant it does so through a dedicated AUDIENCE_CHAT_TOOLS list mirroring the shipped two-layer market pattern verbatim: build-time inclusion conditioned on the org's plugin state (chat/tools.ts:1486-1493) plus a fail-closed post-composition assertion over the ACTUAL ToolSet handed to the model (api/chat/route.ts:294-305), guarded by a chat-audience-isolation.py audit registered in audit:all when it ships (mirroring chat-market-isolation.py). Until then, zero audience tools exist — an absence, not a disabled flag.

The second cost of the market_intel alternative is the mirror of the first: §58 blocks third-party market data from chat whenever Market Intelligence is off (CLAUDE.md:139). A CI client has no reason to enable Market Intelligence, so filing the dataset there would lock the product out of the Data Assistant — the feature that sells it — for exactly the tenants who bought it.

D3 — The existing social pillar is NOT reused

Reusing social looks free and is not. The shipped resolver's contract, read from the file:

  • Org-scoped. brandId/brand_id appear nowhere in its 159 lines — no query predicate can be brand-partitioned without changing the readers underneath it.
  • Monthly-grained on the social-listening path: monthOf() (social.ts:30-32) collapses the window's start day to the first of its month and both social_buzz_volume (:44) and social_sov (:85) read that month. A sub-month window reads the containing month — stated as a documented limitation in the file's own header (social.ts:25-28).
  • Self-row only. selfRow() (social.ts:34-36) keeps the row where isSelf, series and platform breakdowns filter to that brand (:61-70), and anything else abstains with emptyCore() (:51-58, :92-93).
  • Rollup-only reads. Its two readers touch social_listening_{brand,platform}_daily, social_listening_top_items (social-listening-read.ts:5-7) and social_trend_{posts,rankings} (social-trend-read.ts:3). The mention-grain table social_mentions exists (tables/social-market-intel.ts:152-157) and this pillar never reads it — that table is org-scoped, source defaults to 'socialheat', and it feeds the §46 rollup rather than a reader. Its third slug social_trend_buzz (social.ts:115-127) is daily but carries no brand dimension at all.

Audience Intelligence needs the opposite on every one of those axes: brand-scoped, ICT-day-grained (§34/§41), mention-level facts carrying per-client taxonomy. Retrofitting social would change the org-scoped monthly contract under tenants already reading it — a numbers change disguised as a refactor, which is the §55a failure mode. A new resolver behind the same seam costs one switch arm and leaves the shipped contract untouched.

D4 — Trust grade declared: within-file counts are EXACT, coverage is UNKNOWABLE

A vendor social-listening export is a crawl sample, and Client E's workbook says so itself: its first sheet is a meta sheet declaring default_filters including is_relevant:1, a language and a week (chair verification, debate/judge-decisions.md:28) — the file arrives three filters deep. Exactness against the delivered file is defensible and is what a client disputes; completeness is not ours to claim. Three binding consequences:

  • Every share-style metric carries a required coverageBasis: 'declared_universe' | 'unknown' discriminator — not an optional field, so a widget cannot render a share without saying what it is a share of.
  • Whole-market denominators are FORBIDDEN on this pillar (§32/§35 applied): no denominator that implies a market total, no fabricated multiplier. Missing basis renders — plus the base, never a number.
  • A share-of-voice-style metric takes an explicit universe dimension key and always renders its base label. The base is part of the number, not a caption.

The programme's own review flagged that all three candidate architectures drifted the same way here ("verbatim, not an estimate" / "counts are exact"), which is why the grade is written into an ADR rather than a code comment: this is a claim the product makes to a client.

D5 — Separation rule versus ADR 0014 D3 — so nobody "unifies" them later

The vendor fixed-header path stays exactly where it is. socialheat and socialtrend remain their own connector types on family market_intel with thirdPartyData: true (0014-…-social-crm.md:44-49); this ADR touches neither package.

audience datasets arrive only through org-authored ADR 0017 mapping templates, under a new connector family content_intel added to connectorFamilySchema (packages/plugin-host/src/manifest.ts:54, whose docstring already anticipates that "new families slot in without plumbing").

The two paths must never merge, because they differ on every governing axis:

Axis ADR 0014 D3 fixed maps content_intel (this ADR)
Source format fixed vendor product export per-client authored contract
Plane 3rd-party estimate 1st-party deliverable
Tenancy org-scoped brand-scoped
§53 DATA gate outside verify:data (§57) inside verify:data

Stated honestly: ADR 0014's own status line already marks D3 superseded-as-history by ADR 0017 (0014-…-social-crm.md:3) — per-org column mapping for a sheet binding exists now, and the fixed maps remain correct, tested code for genuine fixed vendor exports. That supersession is about mapping mechanics. This separation rule binds the plane and family assignment, which ADR 0017 never changed and this ADR does not relax: a content_intel template may not be pointed at a market_intel stream, and a market_intel connector may not emit an audience stream.

D6 — The name audience

Chosen over two rejected candidates, both for reasons that are rules rather than taste: voc is untranslatable jargon and would surface as an acronym no Vietnamese user can read (§62a), and content collides with §48's TikTok content analytics (shop_videos/shop_lives per-day attribution) — two unrelated "content" domains in one codebase is a naming defect waiting to be mis-grepped. The user-facing label carries the meaning ("Thảo luận khách hàng"); the slug only has to be unambiguous in code.

Non-goals

  • No tables, columns, or schema here. The taxonomy catalog, the mention fact table and the bridge sit behind ADR 0023's merge gate — their DDL is owned by the programme handoff's WP1, and ADR 0023 fixes only the boundary WP1 must respect, including its cross-org read test. No schema PR merges against this ADR alone.
  • No change to the social pillar or its readers, and no change to the ADR 0014 socialheat/socialtrend connectors. A diff touching either is out of scope by construction (D3, D5).
  • No chat exposure before V3. AUDIENCE_CHAT_TOOLS is named here so the pattern is fixed in advance; it is not built. (Shipped 2026-07-31 — see the D2 ledger row.)
  • No Cube binding until brand_id lands in the generated Cube schema — a brand-scoped pillar cannot bind to org-wide generated cubes without returning the wrong number (0019-universal-report-surface.md:101, recorded there as known debt).
  • No pillar-wide metric slugs, widget kinds, or dashboard surfaces decided here; those follow the shipped registries (ADR 0019 D6) in later ADRs.

Consequences#

  • A new client is configuration, not code for the positioning layer: the pillar, the plugin gate and the family exist once, and client #6 arrives as templates plus vocabulary. That is the whole reason to prefer a pillar over per-client anything.
  • A fifth pillar obligates every exhaustive consumer. resolvePlaneCore is the one that fails loudly (index.ts:141-165); any other switch over MetricPillar that is not exhaustive will simply not handle audience and will do so quietly. The implementing PR owes a sweep of MetricPillar consumers, not just the resolver.
  • coverageBasis is permanent API surface. Every share-style return type, every widget config that renders one, and every dataset row carries it. It will feel like ceremony on the first widget; it is the only thing standing between a crawl sample and a whole-market claim (D4). Accepted deliberately.
  • Being inside verify:data is a recurring cost, not a one-off. Every new audience surface owes an assertion (§53), and unlike the estimate plane there is no §57 exemption to fall back on. That cost is the point.
  • Chat stays closed until V3, and that is a product limitation — an operator asking the Data Assistant about audience data before V3 gets nothing, by design. Stated rather than hidden: the alternative (an ungated tool) would ship the exact leak §58 exists to prevent. (V3 shipped 2026-07-31: the same absence now holds for any org whose content-intelligence plugin is off — it is a disabled flag rather than a missing feature, enforced at four layers: build-time tool composition, prompt swap, the post-composition ToolSet assertion, and classifyChatMetric.)
  • Two ingest paths for social-listening-shaped data coexist, deliberately (D5). The risk is a future reader "unifying" them; the mitigation is this ADR plus audience-plane-isolation.py registered in audit:all when the family lands.

Alternatives considered#

  • File it under market_intel (the existing 3rd-party plane). Rejected on consequences, not taxonomy. §57 keeps that plane out of verify:data by design (CLAUDE.md:138), so a signed-off client number would carry no DATA gate; §58 blocks it from chat whenever Market Intelligence is off (CLAUDE.md:139), so the dataset would be invisible to the Data Assistant for every CI tenant. The superficial fit (the raw file comes from a listening vendor) is outweighed by what the plane means: estimate, not deliverable.
  • Reuse the social pillar. Rejected on the verified contract: org-scoped (zero brandId in social.ts), monthly-grained (monthOf, social.ts:30-32), self-row-only (selfRow, :34-36), and rollup-only (never reads social_mentions). CI needs brand-scoped, ICT-day, mention-level facts — the opposite on every axis — so "reuse" means rewriting the resolver and its readers under tenants who currently depend on them.
  • Declare a fourth data plane. Rejected: pillars already outnumber planes 5 to 3 (types.ts:44 vs §57), so the extension the code is built for is a pillar, not a plane. Plane inflation would weaken §57 — a rule whose force comes from there being few, clearly-different planes that must never mix.
  • Name it voc or content. Rejected: voc is untranslatable jargon (§62a) and content collides with §48 TikTok content analytics (D6).
  • Compiled per-client modules instead of a shared pillar. Rejected as a dead end for the programme (architecture doc §5 F1): it re-inserts an engineer into every onboarding, which is the cost this feature exists to remove. Documented as a fallback if ADR 0023 is rejected — never as a target.