Skip to content

feat(analytics): ADR-0037 P3 — draft data preview (seed-overlay dataset queries)#1726

Merged
os-zhuang merged 1 commit into
mainfrom
feat/adr-0037-p3-draft-data-preview
Jun 11, 2026
Merged

feat(analytics): ADR-0037 P3 — draft data preview (seed-overlay dataset queries)#1726
os-zhuang merged 1 commit into
mainfrom
feat/adr-0037-p3-draft-data-preview

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Implements ADR-0037 Phase 3 (option B-min) — the only genuinely new mechanism of the Live Canvas: draft data preview.

What

queryDataset(dataset, selection, context, { previewDrafts }): when the flag is set and the dataset's base object has a pending seed draft, the selection is evaluated over the seed's resolved rows in memory — a query-evaluating proxy feeds the unchanged DatasetExecutor, so measure-scoped filters, compareTo and derived measures all behave identically to the engine path.

  • preview-evaluator.tsAnalyticsQuery over rows: Mongo-style where subset ($eq/$ne/$gt/$gte/$lt/$lte/$in/$nin/$contains/$and/$or/$not), timeDimensions dateRange filtering + granularity bucketing (day/week/month/quarter/year), count/countDistinct/sum/avg/min/max, order/limit/offset.
  • draftRowsResolver config hook; the analytics plugin wires it to the kernel protocol with state:'draft' reads only — a published seed's rows are already in the real table and must not overlay. No pending seed → clean fall-through to live data (published objects keep charting real data inside a preview; numbers are continuous across Publish because publish materializes the same seed).
  • REST /analytics/dataset/query: body.previewDrafts / ?preview=draft thread through to both the saved-dataset lookup (draft-overlaid definitions) and execution.
  • spec: additive optional options param on IAnalyticsService.queryDataset.

Security

Reads only, same ExecutionContext principal as any other read; the flag changes the source, never the principal (ADR-0037 §Phase 3). Physical tables untouched.

Tests

9 new cases: seed-overlay aggregation (group/sum/count), month bucketing, fall-through proof (no pending seed → engine path), flag ignored without resolver, evaluator units (filters, dateRange, order/limit, zero-row count, helpers). Suites green: service-analytics 118/118, rest 100/100.

Follow-up (objectui, next PR)

DatasetWidget/list reads pass the flag under PreviewModeContext so the canvas iframe actually sends it; /data/:object list-read overlay per ADR remains open.

🤖 Generated with Claude Code

…et queries)

queryDataset gains options.previewDrafts: when set AND the dataset's base
object has a PENDING seed draft, the selection is evaluated over the seed's
rows in memory — a query-evaluating proxy feeds the unchanged DatasetExecutor,
so measure filters / compareTo / derived measures behave identically. The Live
Canvas charts real numbers from drafted sample data BEFORE publish, and since
publish materializes the same seed, the numbers are continuous across the gate.

- preview-evaluator.ts: AnalyticsQuery over rows — Mongo-style where subset,
  timeDimension dateRange + granularity bucketing (day/week/month/quarter/
  year), count/countDistinct/sum/avg/min/max, order/limit/offset.
- AnalyticsServiceConfig.draftRowsResolver — injected hook; analytics plugin
  wires it to the kernel protocol (state:'draft' seed reads ONLY: a published
  seed's rows are already in the table and must not overlay). No pending seed
  → falls through to live data, so published objects keep charting real data
  inside a preview.
- REST /analytics/dataset/query: body.previewDrafts / ?preview=draft thread
  through to the lookup (draft-overlaid dataset definitions) and execution.
- spec: IAnalyticsService.queryDataset optional options param (additive).

Reads only; same ExecutionContext principal; never touches physical tables.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jun 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jun 11, 2026 12:29pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant