Skip to content

Typed response structs across er-server handlers, by resource family (10 batches) #864

Done
11 of 11 issues completed

Description

@athvin

API product implementation work · roadmap #1008 · use parent dependency order; not a separate product rank.

Part of #857. Stack rank 7 of 13. Depends on: T6 (hard blocker — the classifier must read typed structs first).

Color

The big one, chosen eyes-open: er-server/src/lib.rs has 126 handlers, 139 Json(json!(…)) sites and zero Serialize derives — the entire response layer is untyped, which is why the document can only describe envelopes. Behaviour-preserving by construction (same field names, same order → same bytes), converted in ten resource-family batches, one PR each, so a regression is bisectable and each batch's regenerated artifacts are reviewable.

Batches: jobs/tasks · orgs+datasets · reviews+merges · golden records+lineage · config versions · webhooks+schedules+keys · tags · runs+entity events · metrics+insights · steward actions+assertions.

Reuse, don't invent: for lake-backed endpoints the typed row struct already exists — a declared statement with a typed returns: column list generates <Name>Row. Those are the response types; read.rs's Vec<serde_json::Value> is type information lost upstream of the handler, not inherently absent.

Scope (per batch)

Response structs with Serialize + ToSchema, registered in ApiDoc; handlers converted; regenerate openapi.json, openapi.public.json, schema.d.ts; envelopes.json must not change (the typed spelling classifies identically after T6).

Out of scope

Changing any response's field set or envelope (that would be a breaking change the gate exists to catch). Query params (T8).

Testing (per batch)

  • Byte-diff a captured response per converted endpoint against a real server before/after (needs ER_TEST_PG_DSN / the make check-e2e environment). The mock-backed tiers cannot catch an envelope change — that is exactly the W0.5b failure the ledger was built after.
  • envelopes.json clean diff; make check.

Definition of done

Epic DoD per batch PR. Ticket closes when all ten batches are landed and every 200 response in the internal document carries a real schema or an explicitly recorded envelope shape. PM checkpoint at batch 3: split into per-batch sub-issues if a single ticket is unwieldy.

  • jobs/tasks
  • orgs+datasets
  • reviews+merges
  • golden records+lineage
  • config versions
  • webhooks+schedules+keys
  • tags
  • runs+entity events
  • metrics+insights
  • steward actions+assertions

Prioritize full shapes for the external configure/ingest/jobs/results workflow before #1013 launch acceptance; remaining resource families may follow.

Sub-issues

Sub-issues

11 of 11 Issues completed
Loading 11 sub-issues

Activity

  1. added
    rust
    mvp
    on Nov 8, 2026
  2. self-assigned this
    on Nov 23, 2026
  3. athvin commented on Nov 23, 2026

    @athvin
    OwnerAuthor

    Claimed — working in #1190 (draft), batch 1 (jobs/tasks) first. Closing that PR releases the claim.

  4. athvin commented on Nov 24, 2026

    @athvin
    OwnerAuthor

    Batch 1 (jobs/tasks) landed in #1190, deployed to dev and prod. Two findings that change how the remaining batches (#1192–#1200) are done:

    1. The mechanism exists now. A success Json(…) naming a registered type becomes a $ref in the generated document. The supported forms are Json(Name { … }), Json(NameWire::from(…)) and Json::<Vec<NameWire>>(…). Response envelopes that aren't entities (JobList, …) register on ResponseDoc in openapi.rs, not ApiDoc, so the entity-registration guards are unaffected. A handler that types some success bodies and not others fails generation. Name::from(iter) is not a readable form: build the struct literally.
    2. "Same bytes" can't hold for record bodies. serde_json here has no preserve_order, so every json! object emits its keys sorted, while a struct emits declaration order. Values are unchanged; key order changes. Each batch therefore proves value equality per shape (see response_shape_tests in lib.rs), plus byte equality where the fields can be declared in sorted order. Any test that pinned raw response bytes needs to compare parsed values instead (pg_task_instances was the one in batch 1).
  5. athvin commented on Nov 24, 2026

    @athvin
    OwnerAuthor

    Progress (2026-11-24): batches 1–10 have all landed: #1190 #1201 #1202 #1205 #1207 #1208 #1209 #1210 #1211 #1212.

    The internal document now has:

    • 80 operations with a $ref success schema
    • 21 with an envelope-level shape (pages, observed keys)
    • 1 Arrow stream
    • 17 still publishing an unconstrained {}

    The done-criterion ("every 200 response carries a real schema or an explicitly recorded envelope shape") is not met until those 17 are typed. They are filed as #1213, with the customer-workflow ones first: resolve, models/*, profile, match-preview. This ticket stays open for it.

    Found along the way:

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

Metadata

Metadata

Assignees

Labels

mvprust

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions