Repository navigation
feat(api): typed response structs, batch 1 — jobs/tasks (#1191) - #1190
Merged
Merged
Conversation
10 tasks
A success Json(...) naming a registered type now becomes a component
reference in the generated document. Json(Name { .. }), Json(NameWire::from(..))
and Json::<Vec<NameWire>>(..) are supported; a handler mixing typed and untyped
success bodies fails generation. Response envelopes that are not entities
register on a separate ResponseDoc, so the entity-registration guards keep
their meaning.
Batch 1 of #864 converts get/create/cancel_job and jobs_global to JobWire,
list_jobs to JobList, list_job_tasks to TaskList, and resume_job and
clear_job_task to ResumeAccepted and ClearAccepted. envelopes.json is
unchanged. serde_json has no preserve_order, so a json! object sorted its keys:
the converted Job bodies keep every value but now emit keys in declaration
order. response_shape_tests pins value equality for each shape, and byte
equality where the fields were already sorted.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The typed TaskList (#864) emits each row's keys in declaration order, where the json! it replaced sorted them. The test's purpose is to pin every field and value with token_hash removed, which the parsed value does without depending on key order. Co-Authored-By: Claude Opus 5.5 <[email protected]>
athvin
marked this pull request as ready for review
November 24, 2026 00:13
Contributor
|
The marketing preview was removed because this PR is closed or merged. |
athvin
temporarily deployed
to
marketing-preview
November 24, 2026 00:20 — with
GitHub Actions
Inactive
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1191
Part of #864 (batch 1 of 10: jobs/tasks).
What
Why
Proof
Risk & rollback
Post-merge ledger
Closed by: agent · session
Claude Code:d1e3b2dc-3174-4091-9c30-c08fc4820306onMac· 2026-11-24T00:30:06Zmainis green with this change on it — the merge SHA, and the runthat proves it. A later head SHA with this commit as an ancestor counts;
a cancelled run with zero jobs does not: merge
c56164ec; rust45296313996, frontend45296313912, infra45296314118, devcontainer45296313926all success.imagesbuilt, or correctly never ran because nothing that goes intoan image changed:
images45296314033success.deployconverged — proved by a line the running process emitted, notby the image digest and not by the workflow conclusion: deploy
45296755794namesDEPLOY_SHA c56164ec. devci/web-api-blueand prodapp/web-api-greenrun theer-apiimage ECR-taggedc56164ec, and theirer-serveremitted"er-server listening"at 00:24:32Z (dev) and 00:24:19Z (prod).deploy,drift,kind's nightly leg) is green, or knowingly red for a reason that is notthis change: deploy, infra and devcontainer green on the merge SHA.
Donethrough the automation rather than byhand, and the issue closed: #864 batch 1: typed responses for jobs/tasks #1191 CLOSED by this PR; parent Typed response structs across er-server handlers, by resource family (10 batches) #864 stays open for batches 2–10 (#864 batch 2: typed responses for orgs+datasets #1192–#864 batch 10: typed responses for steward actions+assertions #1200).
(a skill, a reference, memory) — or nothing new was learned: the typed-response forms and the key-order finding are in the PR Context and on Typed response structs across er-server handlers, by resource family (10 batches) #864 (comment); the api-contract skill still says responses are envelope-level, and that is corrected by #864 batch 10: typed responses for steward actions+assertions #1200's final batch at the latest, when the claim stops being true for most operations.
Specific to this change
Context — plan, discoveries, measurements, files
Plan
Batch 1 of #864 (jobs/tasks). Today a typed
Json(LocalStruct {…})classifies to the same keys-only envelope asjson!, so converting handlers alone would add no schema. This batch builds the mechanism first, then converts.er-api-spec: resolve each successJson(…)to a component when its type is registered. The forms areJson(Registered { … }),Json(XWire::from(…))→X, andJson::<Vec<XWire>>(…)→ array ofX. A handler mixing typed and untyped success responses fails generation.classify_envelopetreats the wire spellings asBare, soenvelopes.jsondoes not change.openapi.rs: emit$ref(oranyOfof refs) for typed responses and register the new response structs inApiDoc.get_job,create_job,cancel_job→JobWire;list_jobs→JobList { jobs };jobs_global→Vec<JobWire>;list_job_tasks→TaskList { tasks };resume_job→ResumeAccepted;clear_job_task→ClearAccepted.json!bytes equal the typed bytes);envelopes.jsonbyte-identical; regeneratedopenapi.json,openapi.public.jsonandschema.d.ts;make checkandmake check-e2e.Discoveries
The ticket's counts still hold on
b809525f: 149Json(json!sites and 27Query<HashMapiner-server/src.JobandJobWirehave identical fields in the same order (the job entity has no internal columns), soJobWire::from(&job)serializes to the same bytes asjson!(job). #864 closes only after all ten batches, so it was split into sub-issues #1191–#1200 and each batch PR closes one.Byte identity does not hold for record bodies, and cannot. The workspace's
serde_jsonhas nopreserve_order, so everyjson!object,json!(job)included, emitted its keys sorted. A struct serializes in declaration order. So the convertedJobandTaskInstancebodies carry every value unchanged, but their keys now arrive in the entity's declaration order. JSON object order carries no meaning and every consumer parses these bodies. Verification is therefore value equality per shape (response_shape_tests), plus byte equality forResumeAcceptedandClearAccepted, whose fields are declared in sorted order.JobList::from(iter)is not a form either reader resolves (the derivation saw it as untyped, and the ledger would have readscalar), solist_jobsbuildsJobList { jobs }as a literal.Measurements
make check: exit 0, 1,138 tests passed, 0 failed.ER_TEST_PG_DSN=… cargo test -p er-server --test main: 142 passed, 0 failed, 2 ignored (real Postgres, every job/task endpoint test included).response_envelopespasses, soenvelopes.jsonis byte-identical. Mutation: disabling thewire_valuerule fails it (GET /v1/jobs [jobs_global]: no Json(...) … found).pg_task_instancespinned the task list's bytes; it now pins the parsed value, for the key-order reason above. That is the only test changed.Files