Skip to content

feat(analytics): dataset semantic layer (ADR-0021) — schema, compiler, RLS, REST - #1643

Merged
os-zhuang merged 1 commit into
mainfrom
claude/dataset-semantic-layer
Jun 7, 2026
Merged

feat(analytics): dataset semantic layer (ADR-0021) — schema, compiler, RLS, REST#1643
os-zhuang merged 1 commit into
mainfrom
claude/dataset-semantic-layer

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

Implements the analytics dataset semantic layer (ADR-0021) end-to-end on the backend.

spec: new dataset metadata type (object + include relationships + dimensions/measures + derived measures) registered across the 7 surfaces; context-aware getReadScope/getAllowedRelationships on StrategyContext; IAnalyticsService.query/generateSql take an optional ExecutionContext.

service-analytics: dataset→Cube compiler (resolves include to TARGET TABLES, fixing lookup-field-name ≠ table-name, e.g. accountcrm_account); DatasetExecutor (filters, measure-scoped filters, derived measures, compareTo); NativeSQLStrategy D-C hardening (per-object tenant/RLS scope on base + joined tables; reject undeclared joins); fail-closed FilterCondition→SQL compiler; plugin wires context-bound read-scope + relationshipResolver.

rest: POST /api/v1/analytics/dataset/query (inline draft or saved name), threads ExecutionContext; D-C errors → 400.

cli: analytics is now an always-on built-in capability.

Verified live (app-crm, SqlDriver): cross-object revenue by account.industry → correct rows + correct LEFT JOIN "crm_account" "account"; D-C guard → 400; single-object path OK. Tests: service-analytics 85, rest analytics 6, spec dataset+contracts 240.

Pairs with objectui PR #1570 (Studio designer + preview); .objectui-sha pins that commit.

Follow-up (separate, security-reviewed): SecurityPlugin to expose getReadFilter so multi-org cross-object analytics auto-scopes in production.

🤖 Generated with Claude Code

…, RLS, REST
Implements the analytics `dataset` semantic layer end-to-end on the backend.
spec:
- New `dataset` metadata type (ui/dataset.zod.ts): object + include relationships
+ declared dimensions/measures + derived measures, with superRefine validation.
- Registered across the 7 surfaces (type-schemas, plugin enum + registry with
loadOrder 55, collection maps, engine metadataArrayKeys, stack).
- StrategyContext contract: context-aware `getReadScope` (returns FilterCondition)
+ `getAllowedRelationships`; `IAnalyticsService.query/generateSql` take an
optional ExecutionContext.
service-analytics:
- dataset → Cube compiler: resolves `include` relationships to TARGET TABLES via a
RelationshipResolver and emits cube.joins (fixes lookup-field-name ≠ table-name,
e.g. `account` → `crm_account`); D-C relationship allowlist.
- DatasetExecutor: filter combination, measure-scoped filters, derived-measure
evaluation (ratio/sum/difference/product), compareTo time-shift.
- NativeSQLStrategy D-C hardening: per-object tenant/RLS read scope injected on the
base AND every joined table; reject joins not backed by a declared relationship.
- read-scope-sql: fail-closed FilterCondition → alias-qualified parameterized SQL.
- Plugin: context-bound read-scope per request; auto-bridge to a `security` service's
getReadFilter; relationshipResolver from the data engine's object schema.
rest: POST /api/v1/analytics/dataset/query (inline draft or saved name), threads
ExecutionContext for tenant/RLS scoping; D-C errors → 400.
cli: `analytics` is now an always-on built-in capability so the dataset/analytics
endpoints exist even when an app declares no cubes.
Verified live (app-crm, SqlDriver): cross-object "revenue by account.industry"
returns correct rows with the right JOIN; D-C guard → 400; single-object path OK.
Tests: service-analytics 85, rest analytics 6, spec dataset+contracts 240.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercelBot commented Jun 7, 2026

Copy link
Copy Markdown

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

ProjectDeploymentActionsUpdated (UTC)
specBuildingBuildingPreview, CommentJun 7, 2026 9:45am

Request Review

@os-zhuang
os-zhuang merged commit ec626ba into mainJun 7, 2026
10 of 11 checks passed
@os-zhuang
os-zhuang deleted the claude/dataset-semantic-layer branch June 7, 2026 09:45
Sign up for freeto 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.

2 participants

@os-zhuang@hotlong