Repository navigation
Description
This was generated by AI during triage.
Problem
The Console's OpenAPI description (/api/v1/openapi.json, thirdshift console openapi) describes each 200 response with a schema written by hand in src/console/openapi.rs (about 500 lines of json!). Those schemas are a second copy of the Serialize types the handlers actually return, and nothing checks that the two agree:
- Some schemas duplicate a real type field by field. For example, the
View::Whoamiarm restatesWhoamiinsrc/console/identity.rs. If a field is added to or renamed in the struct, the published description goes stale silently. - Many views fall back to
{"type": "object"},array(record)or{"type": "string"}(Evals, RecordDifficulty, Rechecks, RenameExperiment and others). A client author learns nothing about their shape, which is the reason Spec: the Console API, /api/v1 behind scoped tokens #1753's user story 39 asked for a description at all. openapi_equals_cli_and_describes_operations_without_local_secretsintests/console/api.rschecks that the description matches the CLI, lists the routes, and has a schema object per operation. It never checks a response against that schema.
#1753 suggested generating the description "for example with utoipa". The implementation kept the route table as the source of operations (ADR 0026) but hand-wrote the response schemas.
Proposal
Derive each API response schema from the Rust type the handler serializes, and test real responses against the published description.
- Derive a JSON Schema for each
/api/v1response type:schemars::JsonSchema, orutoipa::ToSchema(OpenAPI-native, as Spec: the Console API, /api/v1 behind scoped tokens #1753 suggested). Pick one in the PR and say why. Replace the hand-written per-View schemas inoperation()with the derived ones, keeping the route table as the source of paths, scopes and CLI twins. - Responses that are genuinely free-form text (help, version, process output) can stay
{"type": "string"}. - Add a test that validates each API endpoint's actual JSON response (from the existing Console test fixtures) against the schema the description publishes for it, so a type change that isn't reflected fails CI.
Context
The TypeScript prototype (#1839, docs/research/typescript-vs-rust.md, "Console velocity and type sharing") showed one contract shared by CLI, server, browser and tests through Zod. That report noted Rust could get partway there with schemars. This issue takes the server-side part of that. Generating TypeScript declarations (ts-rs) is out of scope: the Console's browser assets are plain JavaScript, so nothing would consume them.
Acceptance
- No per-View response schema in
src/console/openapi.rsrestates a struct by hand. Shapes come from derives on the returned types. - Views that currently publish
{"type": "object"}for a structured response publish the real shape. - A test fails when an endpoint's response does not validate against its published schema.
thirdshift console openapiand/api/v1/openapi.jsonstay equal, and secrets stay out of the description.
Activity
JacobStephens2 commentedon Nov 11, 2026
Investigation summary
Investigated existing issue #1865 against main at dbdd894. The reported duplication and incomplete response descriptions are confirmed. Recommend shaping this as a Spec with Tickets before implementation because it spans 65 published operations across 60 paths, including recursive Command responses, Fleet passthrough and deeply nested Experiment responses.
Evidence:
Validation: cargo test --locked --test console openapi -- --nocapture passed both tests. Isolated HTTP and CLI OpenAPI documents were equal. scripts/affected-tests main reported no changed files and no affected tests.
Implementation constraints: preserve ADR 0026's route-table ownership of operations, scopes and CLI twins; derive serialization-facing shapes, including omitted fields and variants; retain genuine text responses and genuinely dynamic values; keep credentials and local records out of schema generation. Library selection remains delegated to implementation as requested. No current response/schema incompatibility was established; the confirmed problem is incomplete contracts and missing comprehensive validation.
Questionnaire
For the Day shift: #1865's incomplete response schemas are confirmed, including a seven-field /api/v1/look response documented only as an object. Completing the acceptance criteria spans 65 operations and response types across several domains.
A. Establish derived-schema generation, reference handling and reusable response validation through Whoami end to end. Select schemars or utoipa with a documented rationale; cover identity variants, serialization omissions, CLI/HTTP equality, secret exclusion and rejection of an incompatible response.
B. Migrate Command and observation responses: status aliases, Fleet, inspection, metrics, spans, logs, Stop and Dismissal. Describe known local structure while preserving deliberate passthrough metadata and recursive output. Add response validation alongside existing fixtures. Blocked by A.
C. Migrate Eval and Experiment reads and actions using their actual serialized types, including Difficulty, rechecks, pairwise views and nested results. Validate populated and relevant optional/variant responses. Blocked by A.
D. Migrate remaining operations, including configuration, look/themes, resources, start results/options, process and utility responses, and the OpenAPI document response itself. Preserve genuine text and dynamic values; add fixture validation. Blocked by A.
E. Complete a coverage inventory checked against every published path/method, close fixture gaps, remove remaining hand-written structured response shapes, and run the required repository checks. Blocked by B, C and D.
Keep each migration Ticket responsible for its own validation so it is independently reviewable. TypeScript declarations remain out of scope. This questionnaire proposes publication only; no Spec or Tickets were created during investigation.