Skip to content

feat(profile-distribution): paired histogram cells for inline profile (DRC-3390 PR 3)#1391

Closed
danyelf wants to merge 1 commit into
feature/drc-3390-pr1-polyglot-foundationfrom
feature/drc-3390-pr3-frontend-cells
Closed

feat(profile-distribution): paired histogram cells for inline profile (DRC-3390 PR 3)#1391
danyelf wants to merge 1 commit into
feature/drc-3390-pr1-polyglot-foundationfrom
feature/drc-3390-pr3-frontend-cells

Conversation

@danyelf
Copy link
Copy Markdown
Contributor

@danyelf danyelf commented May 21, 2026

Summary

PR 3 of the DRC-3390 paired-histograms GA productionization (4-PR stack). Adds the frontend cells, hook, schema-row integration, and unsupported-adapter banner that consume the per-column payloads PR 2 produces.

Stacks on #1389. Mocks PR 2 payload until #1389 merges. Rebase onto main after PR 2 merges.

Adds

  • PairedHistogramContinuous — quantile-bin, constant-area paired bar chart. Heights = density, widths = bin span, so bar area reads as the proportion of rows in that bin. Replaces the prototype's uniform-bin renderer (closed PR feat(schema): bubble-up paired histograms + inline profile in schema view #1380).
  • PairedHistogramDiscrete — top-K paired chart with gap-on-absent semantics. When a value is missing on one side, that bar isn't drawn, leaving a visible empty half-slot that reads as "absent here."
  • useInlineProfileDistribution — TanStack-Query-backed hook that fires a single PROFILE_DISTRIBUTION run per model, parses the discriminated-union payload, and returns {distributions, loading, error, isUnsupported}. Emits Amplitude analytics events at request and result (DRC-3390 says PostHog, codebase uses Amplitude — same trail).
  • InlineProfileDistributionCell — Compact-mode wrapper that picks between loading / error / empty (per-column failure) / continuous / discrete renders in a fixed-size slot so adjacent rows don't reflow. Grid mode is intentionally absent at GA.
  • ProfileDistributionUnsupportedBanner — once-per-task MUI Alert for the {status: 'unsupported', reason} envelope (Postgres / MySQL / SQLite / SQL Server pre-2022).

Payload contract (frozen — PR 2 produces exactly this)

  • Continuous: {kind:'histogram', bin_edges:[12], base_density:[11], current_density:[11], base_total, current_total}
  • Categorical: {kind:'topk', values, base_counts, current_counts, base_total, current_total, trimmed}
  • Per-column failure: {kind:null}
  • Unsupported envelope: {status:'unsupported', reason:...}

Refines ProfileDistributionResult in api/types/run.ts from PR 1's stub Record<string, unknown> to the full discriminated union.

Out of scope (per DRC-3390 locked decisions)

  • Grid mode (Compact only at GA)
  • Lineage pre-warm / hover-grazing (PR 4)
  • SQLMesh adapter coverage

Also fixes baseline regressions PR 1 introduced

  • chore(run-registry): PR 1 narrowed findByRunType to RegisteredRunType but left js/src/components/run/__tests__/registry.test.ts arrays typed as RunType[] — tsc flagged 3 sites. Re-typed to RegisteredRunType[].
  • test(action-adapter): PR 1 added an isRegisteredRunType guard inside RecceActionAdapter but the test mock didn't stub it, breaking 9 tests with timeout failures. Added the guard to the mock.

Both committed separately so they can be reviewed (or cherry-picked back to PR 1) in isolation.

Test plan

  • pnpm run --filter @datarecce/ui type:check clean (remaining errors are pre-existing CSS-module + lineage-hooks baseline noted in the project memory).
  • pnpm run --filter @datarecce/storybook build succeeds.
  • 57 new unit tests pass (PairedHistogramContinuous, PairedHistogramDiscrete, InlineProfileDistributionCell, ProfileDistributionUnsupportedBanner, useInlineProfileDistribution).
  • Pre-push hook clean — 1933 tests pass, no leftover failures.
  • 20 storybook stories rendered visually on http://localhost:6011; screenshots verified for the mixed-state Compact view, gap-on-absent, trimmed marker, loading spinner, error chrome, unsupported banner (light + dark).
  • Manual smoke against the real schema view once PR 2 lands — wire useInlineProfileDistribution into the actual SchemaView Compact row and confirm cells render against a real PROFILE_DISTRIBUTION run result.

🤖 Generated with Claude Code

… (DRC-3390 PR 3)

PR 3 of the paired-histograms GA productionization. Adds the frontend
cells, hook, schema-row integration, and unsupported-adapter banner
that consume the per-column payloads PR 2 will produce. Stacks on PR 1
(#1389) which already shipped RunType.PROFILE_DISTRIBUTION + the
discriminated-union plumbing.

Includes:

- PairedHistogramContinuous — quantile-bin, constant-area paired bar
  chart. Heights = density, widths = bin span, so bar area reads as
  the proportion of rows in that bin. Replaces the prototype's
  uniform-bin renderer (closed PR #1380).
- PairedHistogramDiscrete — top-K paired chart with gap-on-absent
  semantics. When a value is missing on one side, that bar isn't drawn,
  leaving a visible empty half-slot that reads as 'absent here'.
- useInlineProfileDistribution — TanStack-Query-backed hook that fires
  a single PROFILE_DISTRIBUTION run per model, parses the discriminated-
  union payload, and returns {distributions, loading, error,
  isUnsupported}. Emits Amplitude analytics events at request and
  result (PostHog wiring noted in DRC-3390 but the codebase uses
  Amplitude — same trail).
- InlineProfileDistributionCell — Compact-mode wrapper that picks
  between loading / error / empty (per-column failure) / continuous /
  discrete renders in a fixed-size slot, so adjacent rows don't reflow.
  Grid mode is intentionally absent at GA (per DRC-3390 lock).
- ProfileDistributionUnsupportedBanner — once-per-task MUI Alert for
  the {status: 'unsupported', reason} envelope (Postgres / MySQL /
  SQLite / SQL Server pre-2022).

Payload contract (frozen — PR 2 produces exactly this):
- Continuous: {kind:'histogram', bin_edges:[12], base_density:[11],
  current_density:[11], base_total, current_total}
- Categorical: {kind:'topk', values, base_counts, current_counts,
  base_total, current_total, trimmed}
- Per-column failure: {kind:null}
- Unsupported envelope: {status:'unsupported', reason:...}

Refines the ProfileDistributionResult type in api/types/run.ts from
the PR 1 stub (Record<string, unknown>) to the full discriminated
union — PR 1 left this as a placeholder for PR 2/3.

Tests + storybook:
- 57 unit tests across 5 files covering both cells, the integration
  wrapper, the banner, and the hook (mocked at the submit boundary so
  PR 2 doesn't need to be merged).
- 20 storybook stories covering both cells (cell + card density,
  light + dark, gap-on-absent, trimmed, empty payload, degenerate
  range) and all four integration-cell states; verified visually on
  port 6011.
- pnpm type:check clean; remaining errors are pre-existing baseline
  (CSS module declarations, lineage hooks) and unrelated to this PR.

Stacks on #1389. Mocks PR 2's payload in tests; rebase onto main once
PR 2 lands. PR 4 (lineage pre-warm + GA flip) consumes the same hook +
cacheKeys.profileDistribution(model) cache key.

Refs DRC-3390.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Danyel Fisher <danyel@gmail.com>
@danyelf danyelf force-pushed the feature/drc-3390-pr3-frontend-cells branch from d91cc06 to 0925fd6 Compare May 21, 2026 20:12
@danyelf
Copy link
Copy Markdown
Contributor Author

danyelf commented May 26, 2026

Closing as part of restructure (Ultraplan-approved). New 4-stage vertical-slice plan replaces the original 4-PR breakdown.

This PR's content splits across:

  • Stage A (Storybook-only): the three leaf cells (PairedHistogramContinuous, PairedHistogramDiscrete, ProfileDistributionUnsupportedBanner) + their unit tests + the two dedicated .stories.tsx files + fixtures.ts + SchemaRowMock.tsx. Cells refactored to use local types so Stage A has zero dependency on the API contract.
  • Stage C (UI wiring): InlineProfileDistributionCell container + its 9 stories, useInlineProfileDistribution hook, api/profileDistribution.ts (submit helper + type guards), cacheKeys update, trackProfileDistribution Amplitude event, and the SchemaView Compact integration.

Branch feature/drc-3390-pr3-frontend-cells retained as a code-stash source.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant