Skip to content

feat(api): typed response structs, batch 3 — reviews+merges (#1193) - #1202

Merged
athvin merged 4 commits into
mainfrom
issue/1193-typed-reviews-merges
Nov 24, 2026
Merged

athvin merged 4 commits into
mainfrom
issue/1193-typed-reviews-merges

Conversation

@athvin

@athvin athvin commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Closes #1193

Part of #864 (batch 3 of 10: reviews+merges).

🚧 Claimed by an agent session — 2026-11-24T00:56:11Z, 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 3 of #864: the reviews, merges and labels handlers return typed structs. They are registered on ResponseDoc, so 14 more operations publish a $ref success schema (15 → 29 of 119). The lake read layer is typed first (ReviewItem, UncertainPair, MergePlan).

Why

OpenAPI is the customer integration contract (#857). An envelope-level {} schema is no contract.

Proof

make check: 1,148 passed, 0 failed. The first run hit a pre-existing macOS temp-path race in er-cli, filed as #1203. er-server --tests against Postgres: 382 passed. Frontend tsc --noEmit is clean against the regenerated schema.d.ts. envelopes.json is unchanged.

Risk & rollback

Bodies are value-equal to the json! builds they replace, but key order changes (serde_json sorts json! keys; a struct keeps declaration order). Rollback: git revert <merge-sha>.

Post-merge ledger

Closed by: agent · session Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306 on Mac · 2026-11-24T15:13:15Z

Specific to this change

Context — plan, discoveries, measurements, files

Plan

Batch 3 of #864. Handlers: reviews_list, review_detail, review_merge_group, resolve_review, bulk_resolve_reviews, merge_group, merge_plans, unmerge_entity, create_label, labels_list, labeling_next.

  • Type the lake read layer for reviews first. read::reviews_list, review_get and merge_plans return Vec<Value>/Option<Value> built from generated rows (er_entities::review::read::{PageRow, ByIdRow}, which already derive Serialize + ToSchema), and with_confidence inserts a computed confidence key only when match_probability is non-null.
  • Item structs with flatten — replaced, see Discoveries. Item structs: ReviewItem { #[serde(flatten)] row: PageRow, #[serde(skip_serializing_if = "Option::is_none")] confidence: Option<String> } (and the ByIdRow twin). Flatten is allowed here because struct_fields only parses the immediate envelope struct, not its items. Open question to probe first: how utoipa 5 renders a flattened generated row. Every entity module names its rows PageRow/ByIdRow, so a $ref by bare name would collide; it may need #[schema(inline)] or a renamed registration.
  • Envelopes: ReviewPage { items, snapshot, next_cursor, unscored_hidden }, MergeGroupPage { items, total, snapshot }, MergePlans { items }, LabelList { labels }, then the POST bodies.
  • Proof as in feat(api): typed response structs, batch 1 — jobs/tasks (#1191) #1190/feat(api): typed response structs, batch 2 — orgs+datasets (#1192) #1201: value equality per shape, envelopes.json unchanged, Postgres suite, make check.

Discoveries

  • No flatten. Each item is spelled out with an exhaustive From destructure of the generated row. A new statement column then fails to compile instead of silently leaving the wire, and no colliding PageRow/ByIdRow name needs registering.
  • The envelope classifier refuses serde attributes on a response struct. So the optional apply_job (json! plus resp["apply_job"] = …) is two structs, StagedBatch and StagedBatchApplied, one per observable form, and the schema is an anyOf.
  • Neither classifier reads Json::<Name>(variable) on a write handler. The write path's get_ident rejects a turbofish path, and classify_envelope has no turbofish-record form. The handlers therefore construct at the call site, and the api-contract skill now says so.
  • Beyond the 11 batch handlers, the shared helpers type three more operations: staged_response, the staged-batch shape in mass_update, and create_assertion, whose apply_now body would otherwise have mixed typed and untyped bodies. The ticket's batch boundary is not the helper boundary.
  • ReviewItem.resolved_at and UncertainPair.scored_at are documented as plain strings, not date-time. ser_duckdb_timestamp emits naive lake text, not RFC 3339.

Measurements

  • Operations with a $ref success schema: 15 → 29. Counted with jq over frontend/src/lib/api/openapi.json before and after.
  • New tests: response_shape_tests (2) and read.rs::typed_item_tests (5).

Files

rust/crates/er-server/src/{read.rs,lib.rs,openapi.rs}, frontend/src/lib/api/{openapi.json,openapi.public.json,schema.d.ts}, .claude/skills/api-contract/SKILL.md

bmoore813 and others added 2 commits November 23, 2026 16:56
…1193)

The review queue, review detail and merge group, merge plans, the
labelling queue and labels, and every staged-correction response now
return Serialize + ToSchema structs, so 14 more operations publish a
$ref success schema (15 -> 29).

The lake read layer is typed first: ReviewItem, UncertainPair and
MergePlan replace the rows_to_values + with_confidence hop. They are
spelled out rather than flattened from the generated PageRow/ByIdRow,
whose names repeat across entity modules, and each From destructures
its row exhaustively, so a new column fails to compile instead of
leaving the wire. The optional apply_job key becomes two structs
(StagedBatch/StagedBatchApplied), because the envelope classifier
refuses serde attributes.

Value equality against the old json!/Value builds is pinned in
response_shape_tests and read.rs typed_item_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.

…ce (#1193)

The /docs page renders openapi.public.json's component schemas, and this
branch adds 18. The page grows, so the mobile sticky header lands at a
different offset inside the stitched element screenshot of #overview.
Regenerated in mcr.microsoft.com/playwright:v1.63.0-jammy for this spec
only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@athvin
athvin merged commit 3d7b8c3 into main Nov 24, 2026
42 checks passed
@athvin
athvin temporarily deployed to marketing-preview November 24, 2026 02:35 — with GitHub Actions Inactive
This was referenced Nov 24, 2026

This branch was previously deployed

1 inactive deployment
marketing-preview — 6ba93024 Deployed Nov 24, 2026 by athvin via remove closed PR previews #24
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 3: typed responses for reviews+merges

2 participants