Skip to content

feat(api): typed response structs, batch 9 — metrics, insights (#1199) - #1211

Merged
athvin merged 2 commits into
mainfrom
issue/1199-typed-metrics-insights
Nov 24, 2026
Merged

athvin merged 2 commits into
mainfrom
issue/1199-typed-metrics-insights

Conversation

@athvin

@athvin athvin commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Closes #1199

Part of #864 (batch 9 of 10: metrics+insights).

🚧 Claimed by an agent session — 2026-11-24T17:09:41Z, session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on Mac.
The claim is this open draft PR: closing it releases the ticket.

Post-merge is part of this pull request. The ledger below records whether
the follow-up work actually happened. /land-pr closes it.

What

Batch 9 of #864 converts the dashboard metrics, data quality, record quality, the insight series and per-source insights to typed structs. 5 more operations now publish a $ref success schema (74 → 79 of 119). One classifier change in er-api-spec: Json::<Name>(value) now reads as the same unresolved scalar that Json(value) does.

Why

OpenAPI is the customer integration contract (#857), and these are the numbers an integrator monitors.

Proof

  • make check: 1,157 passed, 0 failed.
  • er-server --tests against Postgres: 391 passed.
  • Frontend tsc --noEmit is clean against the regenerated schema.d.ts.
  • envelopes.json is unchanged.
  • Classifier mutation: deleting the new condition fails envelopes::tests::the_classifier_reads_each_form.

Risk & rollback

Bodies are value-equal to the old ones. /quality keeps its two bodies, now published as a oneOf. Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on Mac · 2026-11-24T17:38:58Z

Specific to this change

Context — plan, discoveries, measurements, files

Plan

  • read::Metrics, DataQuality/Completeness, Quality (an untagged QualityReport | QualityUnconfigured), InsightPoint, SourceInsight. Envelopes: InsightSeries, SourceInsights (run_id: null with no sources before any retained run).
  • Value-equality test in read.rs::typed_detail_tests.

Discoveries

  • These handlers return a reader's result directly (Json(m)), and the GET classifier rejected Json::<Name>(m) with "no Json(...) found". A turbofish over a variable is exactly as unresolved as Json(m), so it now classifies Scalar too. The ledger is unchanged, because the old form was already Scalar.

Measurements

Files

rust/crates/er-api-spec/src/envelopes.rs, rust/crates/er-server/src/{read.rs,lib.rs,openapi.rs}, frontend/src/lib/api/{openapi.json,openapi.public.json,schema.d.ts}

…ty (#1199)

The dashboard metrics, data quality, record quality, the insight series
and per-source insights now return typed structs: read::Metrics,
DataQuality/Completeness, Quality (an untagged oneOf of QualityReport
and QualityUnconfigured, the two bodies the endpoint has always had),
InsightPoint, SourceInsight, and the InsightSeries/SourceInsights
envelopes. 5 more operations publish a $ref success schema (74 -> 79).

er-api-spec: the envelope classifier now reads Json::<Name>(value) as
the same unresolved scalar Json(value) is (pinned, and mutation-checked
by deleting the condition). Without it a GET handler had to construct
its response at the Json call to be typed at all, which these readers
cannot do.

Value equality against the previous json! builds is pinned in read.rs
typed_detail_tests; envelopes.json is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The marketing preview was removed because this PR is closed or merged.

@athvin
athvin merged commit d3fb012 into main Nov 24, 2026
46 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 24, 2026 17:28 — with GitHub Actions Inactive

This branch was previously deployed

1 inactive deployment
marketing-preview — f23516a9 Deployed Nov 24, 2026 by athvin via remove closed PR previews #30
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.

#864 batch 9: typed responses for metrics+insights

2 participants