products

Planning draft — not approved as a finished article

Pensieve: Ideation and Implementation Plan

1. Executive summary

Pensieve explores how an AI assistant can connect user-visible product behavior—questions, answers, citations, feedback, and actions—with the technical execution behind it—retrieval, model generation, APIs, and distributed traces. Its strongest architectural idea is a shared correlation model across two distinct telemetry planes:

  1. Product analytics: durable, semantically named events used to understand user journeys and outcomes.
  2. Technical observability: OpenTelemetry traces, metrics, and logs used to diagnose latency, failures, and service behavior.

The source is a broad design notebook rather than an implementation-ready specification: it spans 175 numbered sections and roughly 8,200 lines, ranging from event identity and React instrumentation to MongoDB aggregation, ClickHouse, retention, and sharding. The first implementation should not build all of those systems. It should establish the user/problem model, an implementation-neutral event contract, and a small, testable telemetry slice. Storage, vendors, and scale-out architecture should be chosen only after requirements and workload evidence are available.

2. Product vision

Working vision: Give an AI application a trustworthy behavioral memory: the ability to explain what a user tried, what the system did, whether the answer helped, and where the experience or infrastructure failed—without capturing more personal data than necessary or slowing down the interaction.

User journey to explain: A visitor starts a session, asks a question in a chat, receives an answer grounded in retrieved sources, opens a citation, provides feedback, and optionally completes a downstream action. The system must correlate that journey to retrieval and generation work while keeping product facts distinct from sampled diagnostic telemetry.

Intended stakeholders

3. Problem framing and desired outcomes

Problems to solve

Jobs to be done

  1. Reconstruct a single AI interaction from session through answer and follow-up.
  2. Measure meaningful product outcomes without relying on arbitrary click counts.
  3. Diagnose technical failures and latency across service boundaries.
  4. Evolve event contracts without silently breaking deployed clients or reports.
  5. Audit which data is collected, retained, sampled, and exposed to each team.

4. Core design principles

  1. One correlation vocabulary, separate lifecycles. Share identifiers and trace context where appropriate; do not merge analytics storage and observability storage by default.
  2. Semantic events over blanket autocapture. Instrument domain actions such as question.submitted, response.completed, citation.clicked, and feedback.submitted; do not treat every render or component click as a product event.
  3. Product events are not trace samples. Define reliability and retention independently for each telemetry plane.
  4. Instrumentation is non-blocking. Telemetry failure must not prevent a question, answer, feedback action, or navigation from completing.
  5. Minimize data at the source. Do not collect raw message bodies, prompts, completions, credentials, or sensitive profile values by default.
  6. Contracts precede dashboards. Specify event names, versions, required fields, allowed properties, and metric definitions before broad rollout.
  7. Start small and measure. Add queues, specialized stores, sharding, and advanced processing only when reliability or workload evidence requires them.
  8. Make every metric traceable. A metric must have a documented definition, grain, source events, exclusions, and known limitations.

Proposed article spine

  1. Start with the end-to-end user journey and the questions each team needs to answer.
  2. Explain why product analytics and technical observability have separate delivery, sampling, and retention rules.
  3. Define the identity hierarchy, correlation contract, and versioned event envelope.
  4. Show where semantic events belong in the AI-chat, retrieval, and generation journey.
  5. Present the logical dual-plane architecture and a deliberately small first implementation.
  6. Define privacy controls, metric semantics, tests, and operational failure behavior before vendor comparisons.
  7. Close with measurable decision gates for queues, analytical stores, and other scale-up options.

5. Proposed conceptual architecture

flowchart LR
  UI["AI chat UI"] --> SDK["Typed product telemetry API"]
  SDK --> PRODUCT["Product event endpoint"]
  UI --> WEBOTEL["Browser observability"]
  API["Chat API"] --> OTel["Backend OpenTelemetry"]
  API --> RETRIEVAL["Retrieval"]
  API --> MODEL["Model generation"]
  PRODUCT --> LEDGER["Validated product-event sink"]
  WEBOTEL --> COLLECTOR["OTel collector / configured backend"]
  OTel --> COLLECTOR
  LEDGER --> FACTS["Purpose-built facts and metrics"]
  SDK -. "correlation context" .-> WEBOTEL
  API -. "trace and domain IDs" .-> PRODUCT

This is a logical design, not a vendor or deployment decision. The first technical slice should prove event contracts, correlation, privacy controls, and non-blocking behavior before choosing a durable queue, database, analytics vendor, or dashboard product.

Identity and correlation model to specify

The source proposes identifiers including visitor_id, session_id, tab_id, chat_id, turn_id, request_id, response_id, and trace_id. The implementation plan should define:

No identity scheme is considered approved until privacy, consent, retention, and account requirements are reviewed.

Initial event envelope

Design a versioned, typed envelope before selecting the transport:

Field groupCandidate fieldsContract questions
Eventevent_id, event_name, event_version, occurred_atNaming, schema evolution, idempotency
Contextapplication_version, environment, localeAllowlist and cardinality
Journey IDsvisitor/session/chat/turn/request/response IDsOwnership, lifetime, privacy
Tracetrace_id, optional span contextPropagation and sampling semantics
Propertiesevent-specific, allowlisted valuesValidation, size caps, redaction
Deliveryreceived_at, schema outcomeServer-generated receipt and diagnostics

Event timestamps should distinguish client occurrence time from server receipt time. Server-derived fields should not be trusted from the browser. Raw conversation text and unbounded arbitrary property maps are excluded by default.

6. MVP scope and explicit exclusions

MVP proof

Not in the first implementation

7. First-pass event taxonomy

The final catalog must be reviewed against actual Pensieve UI/API behavior. The following is a discovery set, not a promise that every event will ship.

Journey stageCandidate eventsRequired interpretation
Sessionsession.started, session.endedDefine session boundary and inactivity rules
Chatchat.created, question.submittedDo not include message text by default
Answerresponse.started, response.completed, response.failed, response.cancelledClarify streaming and cancellation semantics
Retrievalretrieval.completed, retrieval.failedPrefer backend spans for technical detail
Citationscitation.impression, citation.clickedDefine impression visibility and eligible denominator
Feedbackfeedback.submitted, feedback.updatedLink feedback to a response; avoid inferred sentiment
Actionsform_link.clicked, action.completedSeparate click intent from verified completion
Reliabilitydelivery/schema diagnosticsKeep product events and diagnostic logs distinct

Events should be emitted from domain actions or approved wrappers, not inferred from component render frequency. Avoid duplicate semantic events when both client and server observe the same action; designate an authoritative producer for each event.

8. Initial metric catalog

Before implementation, agree on definitions and distinguish product metrics from system-health measures.

MetricCandidate definitionImportant guardrail
Question-to-answer completionEligible turns with a completed response / eligible submitted turnsDefine cancellation, errors, and retries
Positive feedback ratePositively rated responses / rated responsesDo not use all responses as denominator
Citation click-throughEligible citation clicks / citation impressionsDefine impression visibility and deduplication
Time to first tokenTime from accepted request to first generated tokenUse trace/span timing, not client wall-clock alone
End-to-end answer latencyAccepted request to terminal response stateSegment by model/retrieval only with safe dimensions
Telemetry delivery rateAccepted product events / valid events attemptedExclude retries consistently; monitor dropped events
Cost per completed answerAttributed model cost / completed responsesState attribution and missing-cost treatment
Return usageReturning eligible visitors / eligible cohortRequires reviewed identity, consent, and retention policy

The source’s proposed Weekly Successful Answer Users (WSAU) north star must remain a hypothesis until validated against product goals and user outcomes. Avoid labeling a metric “successful answer” unless its measurable proxy and limitations are explicit.

9. Incremental implementation roadmap

PhaseDeliverableExit evidence
P0 — Source and product discoveryGlossary, current-system map, stakeholder questions, source inventoryEvery major claim labeled as requirement, hypothesis, example, or option
P1 — Decisions and privacyDecisions on identity, consent, data classes, event retention, sink, and ownershipReviewed decision record; no unresolved privacy blocker
P2 — Event contractVersioned schema, event catalog, producer ownership, compatibility policyPositive/negative schema tests; unknown fields and sensitive fields rejected
P3 — Frontend sliceTyped telemetry facade and semantic events for one chat journeyUnit/component tests; chat works during endpoint failure; bounded batching
P4 — Backend correlationTrace propagation across chat API, retrieval, and generationIntegration test links turn/request IDs to trace; no high-cardinality metric labels
P5 — Ingestion and persistenceValidated endpoint and approved durable sink; idempotent writes and failure policyLoad/error tests; duplicates bounded; invalid payloads visible and actionable
P6 — Facts and metricsOne or two derived facts and a small metric outputReproducible fixtures; lineage and grain documented
P7 — Production readinessPrivacy/security review, performance budget, retention/deletion, rollout planApproved release checklist, dashboards for telemetry health, rollback tested
V1+ — Scale evolutionQueue, specialized analytical store, richer cohorts/funnels, experimentsEvidence-based trigger and ADR for each added operational component

Phases P0–P2 should be completed before implementation-specific provider or storage choices are locked. P3 and P4 can proceed in parallel only after the event and trace correlation contracts are frozen. A central integrator should own shared schema, SDK interfaces, and ingestion contracts.

10. Decisions required before implementation

DecisionOptions to evaluateBlocking work
Application contextExisting Pensieve stack and services; greenfield prototypeAll integration work
IdentitySession-only anonymous; pseudonymous visitor; authenticated user linkageUser-level analytics and retention
Consent and legal basisProduct/privacy requirements by deployment and jurisdictionBrowser identity and analytics collection
Data policyExplicit property allowlist, redaction, deletion workflowEvent schema and persistence
Delivery guaranteeBest-effort client plus server authority; durable queue; retry/idempotency modelIngestion and reliability claims
Product event sinkExisting approved analytics platform; managed event API; self-hosted storageP3/P5 implementation
Observability backendExisting OTel-compatible platform; local development collectorTrace export and operations
Retention and accessPer-event-class retention, analyst access, deletion obligationsStorage design and release
First business outcomeAnswer utility, citation use, form completion, another user outcomeMetric prioritization
Scale triggerEvent volume, query latency, availability, or cost thresholdQueue/database/ClickHouse evolution

Do not resolve these from examples in the source document. Record material choices as ADRs after current product, regulatory, and operational context is known.

11. Quality, privacy, and reliability gates

12. Editorial and research plan for the source document

Source-to-article map

Source sectionsMain materialTreatment
1–18Product problem, analytics vs observability, identities, event envelope, taxonomy, architectureCore narrative; reconcile contracts before publication
19–37Browser/backend packages, UI instrumentation, event storage, queues, OpenTelemetry, privacy, samplingKeep implementation patterns that survive stack discovery; move provider-specific setup to examples
38–63Funnel and quality metrics, retention, cost, metric lineage, instrumentation health, tests, anti-patterns, initial roadmapCondense into a metric catalog and quality gates
64–86Tool selection, SDK abstraction, schema validation, vendor comparisons, autocapture, component instrumentationKeep decision criteria; date-stamp and verify vendor claims
87–115Collection choices, analytics pyramid, facts, schedules, MongoDB/ClickHouse alternatives and evolutionReframe as staged options with explicit scale triggers
116–175MongoDB behavioral data model, event/fact collections, processing, watermarks, operations, retention, shardingTreat as an optional implementation appendix, not the default architecture

Before publishing an article derived from Pensieve.md:

  1. Preserve the original file unchanged as source material while the plan is reviewed.
  2. Reorganize the narrative into problem, event/identity contracts, dual-plane architecture, implementation slices, metrics, privacy, testing, and scale-up decisions.
  3. Collapse repeated material and move detailed schema examples, metric definitions, and storage alternatives into focused appendices or linked entries if they remain useful.
  4. Replace recommendations that assume MongoDB, ClickHouse, analytics, or a specific queue with decision criteria unless current Pensieve requirements justify a choice.
  5. Verify time-sensitive claims and APIs against current official vendor documentation; cite claims and record verification dates.
  6. Normalize the repeated misspelling “Pencieve” to “Pensieve” in any edited publication copy, without silently rewriting the source file.
  7. Label examples, hypotheses, and decisions distinctly; avoid presenting illustrative IDs, user journeys, dates, retention windows, or thresholds as production facts.
  8. Keep the resulting VICHARA entry in draft status until factual review, privacy review, and publication approval are complete.

Proposed VICHARA metadata (not yet committed as a content entry)

id: ent_pensieve_ai_telemetry_001
slug: pensieve-ai-telemetry
kind: architecture
publication: draft
status: exploring
lenses: [conceptualization, hypothesis, analysis, research, architecture]
domains: [ai, software-engineering, data-engineering]

The ID, slug, taxonomy values, and metadata must be validated against the implemented content schema before creating a publishable entry. Do not add personal, client, or otherwise sensitive product details without authorization.

13. Definition of ready and done

Ready to implement

Done for the first production slice

14. Immediate next steps

  1. Confirm this scope and keep the first delivery to contracts plus one journey.
  2. Inventory Pensieve’s actual frontend, backend, retrieval, model, identity, hosting, and observability systems.
  3. Resolve the blocking questions in section 10 with product, engineering, privacy, and operations owners.
  4. Create the first ADRs and an event-catalog/schema proposal.
  5. Prototype the end-to-end event and trace correlation with synthetic, non-sensitive test data before collecting production telemetry.
🗃️ Source: products/pensieve/ideation-and-implementation-planView source ↗