Skip to content
MSO CloudDocumentation

ADR 0025 — Proof-carrying numbers and quotes (PCNQ) for the audience insight narrative

On this page
  • Status: Accepted (2026-07-31) — operator directive, after Fable review (D1 Tier-1 Landed with tests; D2–D7 are the authorized V2 scope, ledger-tracked). Originally Phase 0; the merge gate for the V2 narrative work. Approved by Fable review 2026-07-30 after a 15-agent chaired debate (architecture doc §3.7, ruling F3). MVP ships Tier 1 only and needs nothing here; no Tier-2 PR may merge before this ADR is accepted.
  • Date: 2026-07-30
  • Context owner: Platform
  • Related: ADR 0005 (the one resolver + failover chain this ADR consumes unchanged), ADR 0010 (durable intent through the outbox), ADR 0021 (confirm-gate posture: nothing load-bearing until a human confirms), ADR 0022 (companion — the audience pillar + content_intel family), ADR 0023 (companion — the taxonomy catalog and its merge gate), ADR 0024 (companion — org-editable tabs + the audience widget family, which owns the typed insight widget config member). CLAUDE.md §32 §35 §38 §44 §49 §53 §61 §62 §63 §66. The programme's evidence bundle private/mso-content-intelligence/** is operator-local (gitignored); the quotations in this ADR are the durable record.

Implementation status (declared 2026-07-30)#

None of this ADR's FLOW is implemented, but D5's storage row has already LANDED with WP1 (uncommitted, same working tree): content_insight_publications (packages/schema/src/tables/content-intelligence.ts:972-1013) already carries status (CHECK: draft|pending_approval|published|retracted), authored_by (default 'ai'), fact_pack_hash, and approved_by/approved_at — exactly the boundary conditions D4/D5 name — with its migration, RLS policy and runtime-ACL grants. Still unimplemented: the approve mutation and publication FLOW, factRefs, the grounding gates, and maskFreeText (grep: 0 hits).

V2 delivery note (2026-07-31). D2–D7 landed in the Wave-2 pass. maskFreeText (packages/ui/src/mask.ts) shipped with them as the span-addressed free-text masker the evidence surface owed, wired into audience_mentions_evidence — masked BY DEFAULT in the RESOLVER, because a per-COLUMN mask: PiiKind cannot express per-ROW offsets, which also keeps the generic dataset revealPii flag (org-membership authority) from un-masking a corpus body. Reveal is an owner/admin capability audited under audience.evidence.reveal, offered on no public or share surface.

Share-wave note (2026-07-31). The D4 adoption report and the D7 issuer refusal + low-agreement badge landed with the client delivery surface: the audience DECK share (resource_type='audience_deck') rides the shipped resource_shares core — no new table, no second public route — and resolves org AND brand from the SHARE ROW inside runWithRlsContext, never from a cookie or session. Evidence text is masked by the same resolver path with no reveal affordance, the PDF export prints the share URL through the shipped generic page renderer (so the document and the page are one render, §49) and is audited as audience.share.export.

One correction to the debate record, stated first because everything below depends on it. The debate proposed PCNQ as a new mechanism. Half of it already ships. applyPcnGate(text, factTokens) (apps/worker/src/pcn.ts:53-82) is a Proof-Carrying-Numbers gate in production today: it drops the whole sentence carrying an ungrounded numeral, and it runs on every Market-Intelligence insight (apps/worker/src/processors/insight-generation.ts:135). No proposal and no critique surfaced it. §49 therefore binds this ADR: Tier-2's numeric grounding is an EXTENSION of applyPcnGate / factTokens, generalized to the audience fact pack — never a second implementation. What PCNQ genuinely invents is (a) quote grounding by character offsets against verbatim mention text, and (b) factRefs resolved at render time.

Decision Status Evidence that will count when it lands
D1 — two tiers; the line is a number Partial (2026-07-30) LANDED (Tier 1): packages/metrics/src/content-narrative.ts — compiled deterministic Vietnamese templates keyed by archetype × structural role, no LLM/Date/DB, formatters from @yng/charts, 15 tests incl. every abstain mode; rendered server-side in the audience widget renderer from the SAME reader result as the adjacent chart (no second fetch); zero generateText in the audience path. OWED: the Tier-2 flow (V2, §61 chain + enqueueDurableJob).
D2 — the ordered publish gate Landed (2026-07-31) apps/worker/src/audience-grounding.ts — applyAudienceGroundingGate delegates the numeric half to applyPcnGate and verifies quotes by stored offsets + clause alignment (no diacritic folding; [CTX] excluded by pool construction); ordered after the §63 guard in processors/audience-insight.ts; scripts/audit/ai-quote-grounding.py registered in audit:all (negative-controlled); 10 behavioural tests incl. polarity flip, truncated quote, [CTX], folded near-match
D3 — typed WSNA output + factRefs Landed (2026-07-31) WsnaOutputSchema (named Zod, processors/audience-insight.ts) is the generation boundary; the typed body is stored as canonical JSON in body_vi behind the wsna.v1 marker (packages/metrics/src/audience-fact-pack.ts, no DDL); resolveWsnaBody resolves every {{f:<id>}} against the CURRENT pack at render time in the narrative_block renderer, with tests proving a moved pack AND an unresolvable ref both render the re-review state instead of a number
D4 — edit-and-lock Landed (2026-07-31) contentInsights.editAndLock writes authored_by='human' and keeps fact_pack_hash; the generator's upsert setWhere refuses any row that is not draft+ai, so human prose is never overwritten; human bodies skip the gates but keep live factRefs and re-flag on a moved hash (resolveWsnaBody, tested); contentInsights.reflagStale is the approver's explicit take-back. ADOPTION REPORT (2026-07-31): contentInsights.adoption counts (dataset, authored_by) in SQL — never over the capped queue list — and renders as one line on the Taxonomy Studio (G20 — the queue page is gone; adoption is a property of the delivered corpus, so it sits on the corpus screen); an empty dataset has NO share, not a 0% one (§32). CONFIRMED OVERRIDE (G20): regenerate takes confirmOverwrite (defaulted FALSE) and the pure regenerateOverwriteGate refuses a hand-edited or once-approved row without it (regenerate_would_discard_manual_edit / …_approved), naming the loss in the audit row
D5 — publication approval Landed (2026-07-31) apps/web/src/server/routers/content-insights.ts — requestApproval/approve/retract/editAndLock, each requireOwnerOrOrgAdmin → REAL-row publicationTransitionGate → stamp + writeAuditLog (audience.insight.*); content-insight-key.ts holds the pure gate (6 tests); ACTION_KEYWORDS carries approve/submit/reflag/edit/retract; UI (G20, 2026-08-12) = the WIDGET itself — dashboards/[slug]/_components/audience-narrative-actions.tsx renders the status badge, submit/approve/retract, "Sửa nội dung" (works on a PUBLISHED row: an edit un-approves) and "Tạo lại" with its confirm dialog, reading one block through contentInsights.blockState; the standalone "Duyệt nhận định" page and its content_insights nav id are DELETED (an insight belongs to the widget it explains), stale org grants stripped by migration 0161. REGULATED REFUSAL (2026-07-31): evaluateDeckShareIssue refuses an external deck share for a regulated_vertical dataset whose deck carries evidence-bearing widgets, naming them
D6 — cost + cache policy Landed (2026-07-31) PER-WIDGET PROMPT (G20, 2026-08-12): promptOverride on the narrative widget's config (plain text, ≤2000, no {{ }}) is APPENDED to the archetype prompt and read SERVER-side from the widget row (resolveWidgetPromptOverride — a client never posts prompt text); deliberately NOT in the cache key, so a wording change takes effect on the next "Tạo lại" and the config panel says so; the weekly refresher stays archetype-only (no widget identity per dataset). audienceInsightCacheKey (sha256 over datasetId · taxonomyVersion · archetype · scopeHash · factPackHash, content-insight-key.ts, 6 tests incl. all five axes); audienceInsightBudgetRemaining returns the OrgLimit union from the nullable per-org column organizations.audience_ai_budget_tokens (0163) — NULL = unlimited and NOT metered; a cap that IS set is metered on ai_usage_log per ICT month (packages/ai/src/server.ts) and hard-stops to Tier-1; generation is a MUTATION through enqueueDurableJob — a page view never regenerates. DEVIATION CLOSED (2026-08-12): the constant DEFAULT_AUDIENCE_AI_BUDGET_TOKENS = 500_000 is GONE — it refused an unconfigured org and its refusal reached a client deck; the cap is now a per-org row set by super admin, and refusals carry codes (audience_ai_budget_exhausted) whose copy lives in @yng/i18n and renders only in the operator action strip
D7 — label-quality artifact (F3) Landed (2026-07-31) STORAGE + RECEIPT: contentLabelQualityLineKey + CONTENT_LABEL_QUALITY_THRESHOLD_BP (packages/schema/src/tables/content-intelligence.ts), written by contentInsights.recordLabelQuality as provenance_class='attested' lines with a named attested_by, per dimension in basis points; recorded from the Taxonomy Studio's label-quality panel (G20 — moved off the retired queue page, and it now names the corpus explicitly instead of relying on the single-active fallback). ISSUER REFUSAL + BADGE (2026-07-31): apps/web/src/server/share/audience-deck-gate.ts is the ONE pure policy module — evaluateDeckShareIssue refuses a mint whose receipt carries no label_quality block (checked before the regulated branch) and lowAgreementDimensions badges every dimension under its kind's bar; both re-checked on EVERY anonymous read (audience-deck-share.ts), 23 tests incl. the cross-brand / cross-org leak evidence. BADGE RE-HOMED (2026-08-18, operator ruling — see the D7 amendment): it no longer renders on /share/<slug>; it renders in-app on the deck behind edit_dashboard (dashboards/[slug]/_components/deck-label-quality-banner.tsx ← contentInsights.labelQuality, same capability re-checked server-side). The refusal, the thresholds, the receipt lines and payload.lowAgreement are unchanged; guard: deck-label-quality-audience.test.tsx

Context#

The Content Intelligence deliverable is prose as much as it is charts: the delivered decks carry a written narrative the client reads first, and the CI team's writing is the differentiator the platform is trying to keep rather than replace. The naive port is an LLM writing the whole tab. Two verified findings kill that shape.

First, an all-LLM narrative desyncs from its own charts the moment a client touches a filter — the block renders — while the chart beside it moves, a visible downgrade against the static deck being replaced. Second, the corpus narrative is not analysis at all where it carries numbers: it is string interpolation over the same aggregation the chart uses. A deterministic template reproduces it exactly, at zero cost, and cannot desync by construction.

That is why the dividing line in D1 is a number rather than a tab, a widget or a tier of client. Everything numeric is compiled; the LLM is confined to the interpretation a template cannot write.

The rest of this ADR is about what has to be true before that interpretation reaches a client's eyes. The platform already has the machinery, and it is stronger than the debate assumed.

Fact Evidence
A Proof-Carrying-Numbers gate already ships. It "DROPS THE WHOLE SENTENCE that carries an ungrounded numeral rather than blanking just the digits in place", because blanking left unreadable fragments apps/worker/src/pcn.ts:1-26 (docstring), applyPcnGate at :53-82
It is not a parser and cannot introduce a wrong value — "it removes untrustworthy sentences, never rewrites a number" apps/worker/src/pcn.ts:16-18
It is wired into the real generation loop, before the truncation check and before anything is cached apps/worker/src/processors/insight-generation.ts:134-135 ("PCN gate — blank any numeral not grounded in a supplied fact token"), inside runBoundedInsightGeneration (:95)
Its factTokens are built server-side as "the closed vocabulary the worker enforces" and travel on the durable job payload under a Proof-Carrying-Numbers comment apps/web/src/server/routers/market-intel.ts:1945 (docstring) + :1948-1958 (builder), :5018 (surfaceFactTokens), :5021-5038 (the enqueueDurableJob call and the comment)
§61 — resolveAiCandidates is "the SINGLE source for turning per-org ai_connections rows into an ordered list of ready-to-run AiConfig candidates", and is pure by design packages/ai/src/resolve.ts:4-25
resolveOrgAi does NOT live in resolve.ts — it is the DB-reading entry in server.ts that loads the rows and delegates to the pure resolver packages/ai/src/server.ts:117-132
The failover convenience entry names the whole chain in its own docstring: resolveAiCandidates(...) → createFailoverLanguageModel(candidates) → streamChat/generateText packages/ai/src/failover.ts:256-266
§63 — truncation detection is a shared pure guard, and salvage returns null so "the caller should publish nothing (the surface shows its empty/retry state) rather than a stub" packages/ai/src/truncation.ts:38-46 (looksTruncatedText), :74-81 (trimToCompleteText)
The guard is a retry-then-salvage-then-publish-nothing loop on the REAL call site, not advice apps/worker/src/processors/insight-generation.ts:140-157
The §63 audit exists because half-sentences reached production — "…chưa có dữ liệu giá nội bộ để so sánh trực", "…ghi nhận sự bứt phá vượt trội từ **@sen" scripts/audit/ai-truncation-guard.py:1-19
§66a — enqueueDurableJob "intentionally refuses to open its own transaction" and throws unless the caller's RLS scope matches the job's org packages/schema/src/job-outbox.ts:11-27
The shipped precedent commits cache invalidation and regeneration intent atomically, by design apps/web/src/server/routers/market-intel.ts:5011-5013 ("The cache invalidation and regeneration intent commit atomically, so a worker can never observe the stale cache after this request wins")
An insight cache key is already a sha256 over declared parts including locale, model, promptRevision and the demo-mask flag apps/web/src/server/routers/market-intel-insight-key.ts:84-106; storage packages/schema/src/tables/ai.ts:72-91 (ai_insight_cache, cache_key + expires_at)
§44 — masking is "DISPLAY ONLY … Data is stored verbatim as the source returns it"; the shipped helpers are field-shaped (maskEmail, maskPhone, maskName) packages/ui/src/mask.ts:1-4, :11, :23
maskFreeText does not exist — the free-text primitive the evidence surface needs is a V2 build, paired with WP1's content_pii_spans grep maskFreeText → 0 hits; handoff WP1 table list (content_sources, content_pii_spans — "spans: offsets + kind + detector + confidence")
The publication-approval shape already exists in three parts: RBAC, a server-side re-check on the REAL row, then stamp + audit apps/web/src/server/routers/offtake.ts:1135-1139 (requireOwnerOrOrgAdmin), :1140-1150 (row fetch + decisionApprovalGate; "button hiding is not enforcement"), :1240-1241 (approvedBy/approvedAt), :1246-1249 (writeAuditLog, action: 'mso.decision.approve')
§38/§62 — the slop audit exists because operators repeatedly flagged filler copy; "A dashboard label is a LABEL, not a sentence that re-describes the chart it sits on" scripts/audit/no-ai-slop-copy.py:1-13
audit:all is the ONE registry, and it already chains the three AI/outbox audits this ADR builds on package.json:40 — ai-resolver-single-source.py, ai-truncation-guard.py, durable-job-outbox.py
The insight widget config is the only .passthrough() member of the widget union apps/web/src/server/widget-config.ts:240-245
PCNQ's flow artifacts do not exist; the STORAGE row does (WP1, uncommitted) grep: factRefs, maskFreeText → 0 hits; content_insight_publications + fact_pack_hash landed in packages/schema/src/tables/content-intelligence.ts:972-1013 with WP1

Decision#

D1 — Two tiers, and the dividing line is a NUMBER

TIER 1 (MVP, no LLM anywhere). Every sentence containing a number is a compiled deterministic Vietnamese template, keyed by dashboard archetype and dimension role — never per client (ADR 0023 D3: shared semantics compile, tenant vocabulary is data). It is rendered server-side in the same pass, from the same helper result object as the adjacent chart. Three properties follow structurally rather than by discipline: it is filter-reactive because it reads the filtered result; it cannot desync from its chart because there is only one aggregation (§49); it costs nothing.

This is not a downgrade of the deliverable. The corpus narrative, where it carries numbers, IS string interpolation over the same aggregation — so the template reproduces the delivered prose rather than approximating it.

TIER 2 (V2, LLM). The model authors interpretation only: SO WHAT / NOW WHAT / AVOID, a verdict, and glossary drafts. It never authors a number. Its plumbing is the shipped chain, unchanged and un-forked:

  • resolveOrgAi (packages/ai/src/server.ts:117-132) → createFailoverLanguageModel (packages/ai/src/failover.ts:256-266) → generateText — §61a/b, with resolveAiCandidates (resolve.ts:4-25) as the pure resolver underneath. No audience code constructs a provider client.
  • Enqueued through enqueueDurableJob in the same transaction as the state that caused it (§66a, job-outbox.ts:11-27) — web never publishes BullMQ directly.
  • Never inside runWithRlsContext (§66b): a model round-trip is long external I/O, and the generation runs in the worker.
  • The provider and model are never surfaced to a CI client or an analyst (§61c). They render only on /admin/ai and /settings/ai.

Why the split is a decision and not a phasing accident. An all-LLM narrative renders — the moment a client touches a filter — a visible downgrade against the static decks this product replaces — and a numeric token guard applied to whole-narrative prose false-rejects legitimate years, week labels and ordinals. Tier 1 has neither failure mode because it never generates.

D2 — The publish gate, in this order

A Tier-2 block is published only after passing, in sequence:

  1. §63 truncation guard. finishReason === 'length' or looksTruncatedText (truncation.ts:38-46) → retry with a larger maxOutputTokens → on the last attempt trimToCompleteText (:74-81) or publish nothing. The shape is already written (insight-generation.ts:140-157); the audience path reuses it rather than restating it.
  2. NUMERIC grounding against the server fact pack — an EXTENSION of the shipped PCN mechanism, not a second one. applyPcnGate(text, factTokens) (pcn.ts:53-82) already enforces exactly this contract for market insights: the prompt supplies a closed vocabulary of pre-formatted tokens, and any numeral not bound to one costs its whole sentence. The audience work generalizes the token builder to the audience fact pack and calls the same gate. §49 binds: one implementation. A parallel verifyAudienceNumbers() is forbidden, and a reviewer should reject one on that ground without re-opening the design.
  3. QUOTE grounding by stored CHARACTER OFFSETS against VERBATIM mention text. A quote is admissible only as a (mention_id, start, end) triple that re-extracts, character for character, from the stored body. Three specifics, each traced to a verified failure:
    • Diacritic folding is FATAL in Vietnamese. The debate's quote oracle was a whitespace/diacritic-folded content_norm; hoa, hóa and hòa are different words. Offsets are taken against the verbatim text, never against a folded normal form. (Folding survives only where ADR 0023 puts it — as a last-resort ALIAS match tier that is never a stored display value.)
    • Offsets close the polarity hole. Quoting "hiệu quả" out of "không hiệu quả" passes every substring check and inverts the claim. An offset span cannot start mid-clause and still re-extract as the model wrote it.
    • [CTX] parent-post text is EXCLUDED from the quote pool. It is somebody else's words; attributing it to the mention's author is a misattribution the client would catch.
  4. Slop / hedge / vendor-name gates (§38/§62). The existing rules apply verbatim to generated prose: no filler, no subtitle restating a title, no vendor name in user copy, no internal jargon. no-ai-slop-copy.py:1-13 is the standing enforcement for authored copy; generated copy is checked at publish time against the same token sets.
  5. Plane guard. An audience narrative may not contain 3rd-party market-intel data (ADR 0022 D2/D5, §57/§58). The fact pack is assembled from content_* reads only; a market fact in an audience pack is a build error, not a review note.

Failing any gate means the block is NOT published. Tier 1 still renders, so the tab never goes blank — which is what makes "publish nothing" an acceptable outcome here rather than a regression.

Enforcement: scripts/audit/ai-quote-grounding.py registered in audit:all (package.json:40 — the ONE registry, never inlined into a hook or workflow), plus behavioural tests for the polarity and [CTX] cases, which no static audit can prove, plus the Tier-A quote/number grounding assertion in scripts/audit/data-reconciliation.ts over synthetic is_sample fixtures (§53; architecture doc §3.5).

D3 — Typed WSNA output, and factRefs resolved at RENDER time

Tier-2 output is a named Zod object, never free markdown:

  • what — a reference to a rendered widget, not a re-description of it. The number lives in the widget; the block points at it.
  • soWhat — the interpretation.
  • nowWhat — the action.
  • avoid — the counter-indication.

Free-form markdown is rejected at the boundary. This replaces the .passthrough() insight widget config (apps/web/src/server/widget-config.ts:240-245 — the only passthrough member of the union); the typed union member itself is ADR 0024's to land (§21: widget config is a typed discriminated union, never z.record).

Every number inside prose is a factRef token, resolved against the CURRENT helper result at render time. Numbers therefore cannot go stale — not when a filter moves, not when data is re-ingested, and not inside human-locked prose (D4). A literal digit in a Tier-2 body is a defect, caught by the same gate that grounds numerics (D2 step 2).

D4 — Edit-and-lock, shipped WITH Tier 2

(Phasing note, stated because two mandate sources disagree: the judge record and architecture §3.7 label edit-and-lock "MVP"; architecture §7 and the handoff place it in V2. V2 is the operative phasing — MVP generates no Tier-2 body to lock.)

An analyst may replace any Tier-2 body. Locked prose is stored authored_by='human' and is EXEMPT from numeric and quote grounding — a human author is accountable for their own claims, and running a machine gate over them would delete sentences an analyst deliberately wrote. Two things still bind:

  • its factRefs stay live, so its numbers keep moving under filters (D3);
  • it is re-flagged for review when factPackHash moves — the data underneath a locked opinion changed, so the opinion is stale until a human says otherwise. This is a flag, not an auto-regeneration: the platform never overwrites human prose.

Adoption metric: the share of narrative blocks left generated versus human-locked, per client (operator default #8 in architecture doc §6: ≥60% generated at 90 days per client, reviewed at client #2).

Rationale, stated because it is a product decision and not a convenience. A system that can only regenerate-or-reject gets bypassed: analysts paste prose into a text widget, or keep shipping static HTML — and the CI team's prose IS the differentiator. The honest failure mode is named too: the team locks everything and the platform becomes a more expensive status quo. The response is measurement plus the data-moved re-review trigger, not a cap on locking.

D5 — Publication approval for client-facing prose

Client-facing prose requires a row in content_insight_publications (columns owned by WP1 — this ADR fixes the FLOW, not the DDL) moving through draft → pending_approval → published | retracted.

The approve mutation reuses the shipped three-part gate shape verbatim, from the offtake precedent:

  • RBAC first — requireOwnerOrOrgAdmin({ userId, orgId, isSuperAdmin }) (apps/web/src/server/routers/offtake.ts:1135-1139), or its audience-scoped equivalent.
  • A server-side re-check on the REAL row — fetch the row inside the org scope, then evaluate the gate against its actual status, exactly as decisionApprovalGate({ status, mode }) does (:1140-1150), under the comment that states the rule: "button hiding is not enforcement". A block that failed D2 cannot be approved by calling the mutation directly.
  • Stamp + audit — approvedBy/approvedAt written in the same update (:1240-1241) and writeAuditLog with an audience.insight.* action (:1246-1249, the precedent uses mso.decision.approve). New verbs update ACTION_KEYWORDS in apps/web/src/app/admin/orgs/[slug]/logs/page.tsx:287 — anti-pattern #10, or the log's filter silently classifies them other.

Regulated verticals require human approval before any external share. A regulated_vertical dataset (the Client D / pharma-class case) cannot be shared externally from a draft or auto-published block (operator default #4 in architecture doc §6, alongside evidence_access='masked' by default and 'none' for healthcare/pharma external shares until counsel signs).

D6 — Cost and cache policy

  • One narrative per tab. Not per widget, not per chart.
  • Fact pack ≤8k tokens. The pack is assembled deterministically and truncated by rule, not by the model.
  • Per-org monthly token budget, OPT-IN. organizations.audience_ai_budget_tokens is nullable and NULL means unlimited and unmetered (0163, OrgLimit); a cap exists only when a super admin sets one in the Admin CP. Reaching a cap that WAS set is a hard stop that degrades Tier-2 to absent — Tier-1 keeps rendering, so exhaustion is invisible to the client rather than a blank tab. SUPERSEDES the original 500k/month code default (operator default #7): an org nobody had configured crossed it mid-delivery and the refusal printed "Đã dùng hết hạn mức…" on a client deck. A refusal must trace to a number an operator typed, and an operational refusal never renders in a deck body — it is a response to the operator's own click (insightWidget.refusal*).
  • Cache key: scopeHash | taxonomyVersion | blueprintVersion | factPackHash | dataWatermark. The precedent is insightCacheKey (market-intel-insight-key.ts:84-106), a sha256 over declared parts already including locale, model, promptRevision and the demo-mask flag; the audience key adds the taxonomy, blueprint and watermark axes because a vocabulary bump or a re-ingest changes what the prose means, not just what it says. Storage follows ai_insight_cache (packages/schema/src/tables/ai.ts:72-91).
  • Refresh triggers are ingest, publish, manual and nightly — NEVER a page view. A page view that regenerates is an unbounded bill and a non-deterministic deliverable. Invalidation and the regeneration intent commit atomically in one transaction, as the shipped path already does (market-intel.ts:5011-5013 + :5021).

D7 — Label-quality artifact required for external shares from V2 (Fable ruling F3)

Classification of mentions happens off-platform until V3. From V2, no external share link is issued for a dataset version unless its receipt carries a label_quality block:

  • a stratified re-label stability sample — ≥200 mentions or 10% of the dataset, whichever is smaller — re-classified with the client's frozen prompt;
  • per-dimension agreement reported, not a single headline number;
  • provenance attested (ours, not the client's) — never labelled as external verification.

Below-threshold agreement does not block delivery. Defaults are 85% single-select / 75% multi-select; below them the receipt must show the number, and every affected dimension renders a "độ tin cậy phân loại thấp" badge. Hiding a weak agreement score is the failure this rule exists to prevent; refusing delivery over it is not.

Amendment — WHO the badge is for (operator ruling 2026-08-18). The badge shipped at the top of /share/<slug>, the delivered artefact. It is removed from that surface and from that surface only: "trong deck (bản gốc client) không có thì vứt". The reading is INTERNAL — our own re-label stability sample, scored against our own bar — and on the client's page it read as the agency disowning the report it had just handed over, next to a client artefact that carries nothing like it. Nothing about the measurement moves: the receipt still stores it, evaluateDeckShareIssue still refuses to mint a link for a dataset with no label_quality block, and lowAgreementDimensions remains the one place the bar is applied. Only the READER moves — in-app, on the deck itself, behind the edit_dashboard capability (deck-label-quality-banner.tsx + contentInsights.labelQuality, which re-checks that capability server-side). The rule this amendment keeps intact is the one D7 states: the number is never hidden from the people who can act on it; it was only ever addressed to the wrong audience.

The receipt must say, in words, that it proves COUNTING and not LABELLING — until V3 brings classification in-platform with provenance and abstention. This is design, not copy polish: the whole "prove this number" framing is a claim the product makes to a paying client, and it is only true of the counting half.

Non-goals

  • No LLM anywhere in MVP. MVP is Tier 1 only. A generateText call on the audience path before this ADR is accepted is out of scope by construction.
  • No in-platform classification (V3). This ADR governs narrative, not labelling; D7 exists precisely because classification is somebody else's until V3.
  • No free-form LLM markdown into any widget. Typed WSNA or nothing (D3).
  • No second numeric-grounding implementation beside applyPcnGate (§49). Generalize the builder and the gate; never fork them.
  • No Vietnamese NER claim. PII spans are dictionary + regex (content_pii_spans, WP1), and the recall limit is stated to the operator rather than implied. maskFreeText is a V2 primitive to build in @yng/ui/mask beside the shipped field-shaped helpers (packages/ui/src/mask.ts:1-4); verbatim text is never mutated (§44).
  • No schema DDL here. content_insight_publications' columns, keys and indexes are WP1's. Where this ADR names a field (authored_by, approved_by/approved_at, status, factPackHash), it is a boundary condition WP1 must satisfy, not an optional suggestion.
  • No Tier-2 chat exposure. Audience data reaches the Data Assistant only through ADR 0022 D2's future AUDIENCE_CHAT_TOOLS gate in V3.

Consequences#

  • The narrative survives a filter change, which the decks it replaces do not. That is the whole return on Tier 1 being compiled: a client dragging a date picker sees prose that moves with the chart, from one aggregation (§49).
  • applyPcnGate becomes a shared, cross-app dependency. It lives in apps/worker/src/pcn.ts today and is imported by one processor. Generalizing it to a second consumer means it should move to a package with its tests, and its "lenient by design" binding rule (pcn.ts:22-25 — a numeral binds if it is a substring of any token) must be re-read against audience fact tokens before it is trusted there. Stated as an obligation, not a footnote: leniency tuned for VND and percentages is not automatically right for mention counts and share ratios.
  • Quote grounding needs the offsets to exist at ingest. Verbatim bodies must be stored unmutated (§44) and spans recorded against them; any later normalization of stored text invalidates every published quote. This couples the narrative layer to WP1's storage guarantee permanently.
  • Two exemptions now exist in one system — human-locked prose skips grounding (D4), and Tier 1 never enters the gate at all (D1). Both are deliberate, and both mean "the gate passed" is not the same sentence as "a machine verified this text". The receipt has to say which.
  • factRefs are permanent API surface. Every Tier-2 body, every locked human body and every render path carries them. It will feel like ceremony on the first block; it is the only thing that makes a number inside frozen prose safe.
  • A per-org token budget is an operational duty, not a setting. Somebody must notice when a client's tabs quietly stop carrying interpretation. The hard stop is designed to be invisible to the CLIENT and must therefore be loud to the OPERATOR.
  • D7 adds a per-delivery cost and a per-delivery honesty obligation. A few dollars of re-label sampling per dataset version, plus a receipt that publicly reports a number the team may not like. Accepted: the alternative is a "prove this number" receipt that overstates what it proves.

Alternatives considered#

  • One tier: the LLM writes the whole narrative. Rejected on a reproduced regression — the block renders an em dash the moment a client touches the date picker, while its chart updates. Against a static deck that always showed prose, that reads as the platform being worse. A whole-narrative numeric token guard also false-rejects valid prose containing years, week labels and ordinals.
  • A second, audience-specific numeric grounding implementation. Rejected under §49 and on the evidence: applyPcnGate already does exactly this in production (pcn.ts:53-82, insight-generation.ts:135). The debate corpus never surfaced it, and a design that invents a parallel gate would have shipped two definitions of "a grounded number" — the failure mode §49 exists to prevent.
  • Substring quote verification (a verified_substring precondition). Rejected: it is polarity-blind. "hiệu quả" is a substring of "không hiệu quả", so the check passes while the quote inverts the claim.
  • A diacritic-folded quote oracle (content_norm). Rejected as fatal in Vietnamese, where diacritics are semantic — hoa / hóa / hòa are different words, so a folded oracle certifies quotes the source never contained. Folding survives only as ADR 0023's last-resort alias match tier, never as a display value and never as a quote oracle.
  • Allow [CTX] parent-post text in the quote pool. Rejected: it attributes another person's words to the mention's author. Cheap to include, indefensible in front of the client whose brand the misattributed sentence is about.
  • Regenerate-or-reject only, with no edit-and-lock lane. Rejected on adoption: analysts bypass it by pasting prose into a text widget or by continuing to ship static HTML, and the platform loses the differentiator it was built to keep. Locking is the sanctioned path precisely so it is visible and measurable (D4's adoption metric) instead of happening off-platform.
  • Auto-regenerate a locked block when factPackHash moves. Rejected: it overwrites human authorship silently. The block is flagged for review; a human decides.
  • TTL-only caching with refresh on page view. Rejected twice over: cost is unbounded and a deliverable becomes non-deterministic between two viewers. The declared five-axis key plus ingest/publish/manual/nightly refresh makes regeneration an event, not a side effect of reading.
  • Ship Tier-2 without the label-quality artifact and disclose the limitation in prose. Rejected by Fable ruling F3: a prose disclaimer next to a receipt headed "prove this number" is read as boilerplate. The artifact makes the claim's boundary a number on the receipt, and the low-agreement badge puts it on the affected chart rather than in a footnote.