Skip to content

feat(api-v1): describe the Projects operations as an OpenAPI document and diff it against the pinned schema - #179

Merged
aRustyDev merged 6 commits into
mainfrom
feat/api-v1-openapi-projects
Nov 15, 2026
Merged

aRustyDev merged 6 commits into
mainfrom
feat/api-v1-openapi-projects

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

Part of #58; this PR does not close it.

#58's last unmet criterion is "oasdiff reports no breaking change for the 32 operations, and the generated schema is committed" (G-25 item 6, ADR-0032 line 70). This is the first of four per-resource pull requests (Projects, States, Labels, Work Items). It builds the whole pipeline for the 8 Projects operations; each of the other three adds its bodies as types and its operations to tools/oracle-v1/schema/described.operations, and the last makes the list the 32 operations of the scope m1.

What changes

  1. The project bodies are types. ProjectDto, ProjectLiteDto and the list envelope Page<T> (src/dto/, pagination.rs) replace the json! builders, and the routes serialize them. The wire is unchanged (below). States, labels and work items still build json! and call Plan::envelope, which now delegates to Plan::page.
  2. The openapi feature of thrust-api-v1 derives utoipa's ToSchema on those types, puts #[utoipa::path] on the eight handlers, and cargo run -p thrust-api-v1 --features openapi --example openapi prints the document. Off in every other build: cargo tree -i utoipa finds nothing in the Worker's wasm32 graph or the server's. What a Rust type cannot say (the pin's bounds, network as 0 or 2, the 433 timezones) is a schema function in openapi.rs; the timezone list is thrust_core::known_timezones(), the list the route validates against, now exported.
  3. Request bodies are described, not derived. A request is read by hand (DRF's coercions and its messages, fields.rs), so ProjectCreateRequest and PatchedProjectUpdateRequest are hand-written descriptions. On the request side the diff compares the pin with a hand copy until a later series makes each parser return a typed struct (it needs its own go-ahead; G-25 item 6 says so).
  4. scripts/check-openapi.sh (a step of deps, so gate's required contexts do not change) builds the document, compares it with the committed copy (tools/oracle-v1/schema/openapi.thrust.json), checks it has exactly the operations of described.operations, cuts the pin to them and diffs with oasdiff. Every finding must be an entry of diff-accepted.json, and every entry must still be found, per entry and operation: an entry that stops being true is stale and fails, as in the oracle gate's register.
  5. Two tests (tests/openapi.rs) tie the document to the code: every operation it describes is a route of the router, and the keys of a real body, and its nulls, are what its schema says. CI also runs clippy and these tests with the feature on, which nothing else turns on.

Something worth knowing about oasdiff

The pin is OpenAPI 3.0.3 and utoipa 6 writes 3.1 only. oasdiff v1.33.0 does not read nullable: true and type: [T, "null"] as one thing: the pin against its own oasdiff upgrade is 384 false breaking changes. So both sides go through oasdiff upgrade first; canonical against canonical is "No changes detected". The pinned digest is an index with linux/amd64 and arm64.

What the diff found

37 findings for the 8 operations (17 errors, 20 warnings), all accepted by 9 entries:

Entry Difference Record
SD-001 cover_image_url can be null (a project with no cover) EX-006; the corpus shows it 18 times
SD-002, SD-003 member_role and sort_order can be null (a caller who is in no such project) EX-006's defect, read from the pin's source (views/project.py:128-133, :173-181; serializers/project.py:221-222), because the recorded corpus has no such caller
SD-004, SD-005 form and multipart bodies are a 415 D-030 (5), confirmed 2026-11-07
SD-006 to SD-009 network is the enum 0 or 2 here; the pin writes it as allOf: [NetworkEnum] with Django's 0 to 32767 form, not a deviation

One thing for you: EX-006 names cover_image_url and avatar_url as examples, and SD-002 and SD-003 name two more fields as the same defect. Their reasons are written out in the register; say so if you read it differently.

Before the fidelity fixes the first generation had 957 findings (866 were the timezone enum alone). What was left was the schema saying less than the route guarantees (formats, bounds, a request body that is optional), and that is fixed in the types, not accepted.

Checked

  • The wire did not change: the crate's 545 tests pass (as before); the workspace's hermetic run is 3922 passed (4 skipped: the oracle_ tests the profile excludes); scripts/contract.sh native-memory main is 70 of 70; scripts/oracle-v1.sh native-memory controls ends in VERDICT: PASS three times (gate: 162 cases, 12 failures all accepted, 0 unaccepted, 0 stale; corpus: 108 exchanges compared, 13 accepted, 0 unaccepted, 0 stale; controls C0 to C4 and the comparison's eight). The run rewrote one committed result file, with a different random port only, which I restored.
  • rustfmt, clippy --workspace --all-targets -D warnings, clippy with the feature, clippy of the Worker on wasm32: clean. check-deps.sh, cargo deny check, and the other scripts of the deps job (topology, Plane 500, acceptance list, placement, render-wrangler.sh --self-test, the workflow lint): clean. The check runs under /bin/dash.
  • Controls, each shown failing (files copied first and restored, compared byte for byte): a key dropped from the document, a type changed, a request key made required, and the register with an entry that no longer matches (all in the check itself); on the real code, dropping maxLength from a body field (4 unaccepted findings), a typo in a documented path (the route test names the operation), and a sort_order that is no longer skipped (the body test names it). The helper's 21 cases include one I wrote wrong and corrected (an expectation of two stale entries where one is right), not the code.

Not run here

native-pg, worker-memory and worker-cf (CI runs them). Docker is needed by the new step; ubuntu-24.04 runners have it (not exercised on a runner yet: the first CI run is the test).

Left

States, Labels and Work Items (three more pull requests, each shorter than this one), and the request-side series.

🤖 Generated with Claude Code

aRustyDev and others added 3 commits November 14, 2026 23:50
…, written from the types the routes answer with

The project routes built their bodies with `json!`, so nothing could say what they send. They now build `ProjectDto`, `ProjectLiteDto` and the list envelope `Page<T>` and serialize those (`src/dto/`, `pagination.rs`). The wire is unchanged: the oracle's gate and corpus comparison give the numbers they had (162 cases, 12 failures, all accepted; 108 exchanges, 13 accepted, none unaccepted or stale; every control fails as it must), the contract suite's main pass is 70 of 70 on native-memory, and the crate's 545 tests pass as before. The other three resources still build `json!` bodies and call `Plan::envelope`, which now delegates to `Plan::page`; each moves in its own pull request.

With the `openapi` feature the types derive utoipa's `ToSchema`, the eight handlers carry `#[utoipa::path]` (operationIds, tags and the `X-API-Key` scheme as in the pin), and `cargo run -p thrust-api-v1 --features openapi --example openapi` prints the document. The feature is off in every other build: `cargo tree -i utoipa` finds nothing in the Worker's wasm32 graph or the server's, and `check-deps.sh` and `cargo deny` are clean. What a Rust type cannot say (the pin's bounds, `network` as 0 or 2, the 433 timezones) is a schema function in `openapi.rs`, used by the bodies and the request descriptions alike; the timezone list is `thrust_core::known_timezones()`, the list the route validates a body against, now exported.

A request body is read by hand (DRF's coercions and messages, `fields.rs`), so the two request types are descriptions, written by hand, and say so. A parser that returns a typed struct is a later step.

Two tests in `tests/openapi.rs` tie the document to the code, and each was shown failing on the real code: every operation the document describes is a route of the router (a typo in `list_projects_lite`'s path fails it, and a path the router lacks is shown to be the URLconf's 404), and the keys of a real body, and its nulls, are what its schema says (a `sort_order` that is no longer skipped fails it). `#![recursion_limit]` goes: it was there for the 43-key `json!`.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
`scripts/check-openapi.sh` builds the document, compares it with the committed copy (`tools/oracle-v1/schema/openapi.thrust.json`), checks it has exactly the operations of `described.operations`, cuts the pin to them, and diffs the two with `oasdiff` (the digest `schema_diff.sh` names; the image has linux/amd64 and arm64). Every finding must be an entry of `diff-accepted.json` and every entry must still be found, per entry and operation, as the oracle gate's register does. The pin is OpenAPI 3.0.3 and utoipa 6 writes 3.1 only; oasdiff v1.33.0 does not read `nullable: true` and `type: [T, "null"]` as one thing (the pin against its own `oasdiff upgrade` is 384 false breaking changes), so both sides go through `oasdiff upgrade` first.

For the 8 Projects operations: 37 findings (17 errors, 20 warnings), all accepted by 9 entries, none unaccepted, stale or ambiguous. SD-001 to SD-003 are EX-006's nulls (`cover_image_url`, which the corpus shows 18 times, and `member_role` and `sort_order`, which the pin's source produces for a caller who is in no such project: `views/project.py:128-133`, `:173-181`; the corpus has no such caller), SD-004 and SD-005 are D-030 (5), the 415 on form and multipart bodies, and SD-006 to SD-009 are `network`'s enum written without the pin's `allOf` and Django's 0 to 32767, a difference of form.

The controls run with the check, each of which must be refused: a key dropped from the document, a type changed, a request key made required, and the register with an entry that no longer matches. On the real code, dropping `maxLength` from a body field made the check report 4 unaccepted findings. The helper (`openapi_diff.py`, standard library only) has 21 cases of its own, one of which was written wrong and corrected here (the expectation, not the code).

CI: the check and its self-test are a step of `deps` (no new required context), clippy with the feature a step of `lint`, and the feature's tests a step of `hermetic` (the default profile, so the full run's JUnit report is not replaced). The docs that called the schema diff planned or not done say what is covered: G-25 and its item (6), by-change, the defect matrix (X14), standards, CI/CD and the oracle README.

Not run here: `native-pg`, `worker-memory` and `worker-cf` (CI runs them).

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ease bot) into the OpenAPI Projects branch

#179 conflicted with main, so GitHub started no `pull_request` run for it. Two conflicts, both where main and this branch each added to the same list:

- `.github/workflows/ci.yml`, the end of the `deps` job: main's "Release workflow guard" step and this branch's "OpenAPI schema diff (oasdiff)" step. Both stay, the release guard first.
- `docs/src/contributing/standards.md`, the "Decided, and built only in part" paragraph: main's rewrite says the deploy bundle is attested and ADR-0110 is built; this branch says the oracle schema check exists and covers the Projects operations only. The paragraph keeps both, and no longer lists "oracle schema check" among what is absent.

`Cargo.lock`, `docs/src/architecture/cicd.md` and `docs/src/testing/status.md` merged without a conflict; `cargo metadata --locked` resolves the lockfile, and the prose that mentions the schema check (cicd.md, by-change.md, defect-matrix.md, status.md G-25) agrees with itself.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@socket-security

socket-security Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​utoipa@​6.0.010010093100100

View full report

aRustyDev and others added 3 commits November 15, 2026 02:15
…) into the OpenAPI Projects branch

#183 merged while #179 was waiting for its first run, and conflicted with it a second time. One conflict, `.github/workflows/ci.yml`, the end of the `deps` job: #183 renamed the release step to "Release configuration and workflow guards" and rewrote its `env` and `run` (`SECRET_JOBS: release release-pr`, `check-release-plz.py`, the `release-plz.yml` lint), directly above this branch's "OpenAPI schema diff (oasdiff)" step. Main's step is taken whole and the OpenAPI step stays after it, unchanged.

`Cargo.toml`, `Cargo.lock` and `docs/src/architecture/cicd.md` merged without a conflict. `cargo metadata --locked` resolves the lockfile with `utoipa` and #183's changes together, the merged `ci.yml` parses with both steps in `deps`, and `scripts/check-openapi.sh` gives the same 37 findings, 0 unaccepted, with its four controls refused.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
… into the OpenAPI Projects branch

#179 conflicted with main a third time, once the three small PRs it was opened with had merged. One conflict, `docs/src/testing/status.md`, and it is one hunk because G-25 and G-26 are adjacent rows: this branch changed G-25 only (the schema diff), #180 changed G-26 only (`THRUST_RL_CREATE_ID`). Checked by hash against the merge base (G-25 4337a2f968e5 on main and the base, 55eb907971f4 here; G-26 bb75219068af on the base and here, 104945eb6fb9 on main), so the resolution is this branch's G-25 row and main's G-26 row, and each now has exactly those hashes.

`.github/workflows/ci.yml` merged without a conflict: `deps` has the count guard's self-test, the release step and the OpenAPI step; `hermetic` has the count check and the OpenAPI tests; `lint` has the OpenAPI clippy. #182's D-19 row and #181's sentence in G-33 are in `status.md`, no conflict marker is left anywhere in the tree, and `cargo metadata --locked` resolves.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 2258d6b into main Nov 15, 2026
68 of 70 checks passed
@aRustyDev
aRustyDev deleted the feat/api-v1-openapi-projects branch November 15, 2026 21:20
This was referenced Nov 15, 2026
aRustyDev added a commit that referenced this pull request Nov 16, 2026
… written from the type the routes answer with (#188)

The second of the per-resource steps of #58's schema diff (Projects was #179). The five state operations are in the document and in `described.operations`, so `scripts/check-openapi.sh` now diffs 13 of the pin's 32 against `oasdiff`.

`StateDto` is the 18 keys of the pin's `StateSerializer`, and `state_body` builds it and serializes it (`into_object`, as the project bodies do); the list answers `Page<Value>` from `Plan::page`. The five handlers carry `#[utoipa::path]` with the pin's operation ids, summaries and response descriptions (create answers 200, as the pin does). A `StatesQuery` has no `order_by` (the pin's list has none, and `ListQuery` does), `state_group` takes its enum from `StateGroup::ALL` so the six names are written once, and `StateRequest` and `PatchedStateRequest` describe what the hand parser takes, as the project request types do.

The wire is unchanged: the crate's tests 560 of 560 (11 new: 3 in `openapi.rs`, and the 415 matrix of 4 cases in each of `states.rs` and `projects.rs`), the oracle gate and corpus comparison with the same numbers as G-25 (162 cases, 12 failures all accepted; 108 exchanges of which 14 are States, 13 accepted, 0 unaccepted; the corpus comparison's 9 controls and C1 to C4), the contract `main` pass 70 of 70, and clippy clean for the crate with and without the feature, for the workspace and for the Worker on wasm32 (`utoipa` is not in its graph).

The first generation had 45 findings, 8 of them new and unaccepted, of two kinds:

- The form and multipart bodies of `create_state` and `update_state` (SD-010, SD-011). Thrust answers 415 to both, as it does on a project, but D-030 (5) is the projects' and the owner confirmed it for projects only. It is D-031 (5) now, **proposed and not confirmed**, in DEVIATIONS.md and in the register entries, so that the check does not pass over it.
- The pattern of `slug` (SD-012). The pin's schema gives it `^[-a-zA-Z0-9_]+$` and the pin does not keep to it: `State.save()` stores `slugify(name)` in a field that is `blank=True`, and a name of CJK or emoji alone has the empty slug on the pin and here (D-031 (2), owner confirmed). The document claims no pattern, because the route can send an empty slug, which `a_name_with_no_letter_has_an_empty_slug_which_the_document_does_not_forbid` shows; claiming the pattern fails it.

Controls, each shown on the real code: a pattern on `slug` fails the empty-slug test; `external_id` skipped when `null` fails the new schema test and four of the States tests; `json_body` made to read forms fails exactly the two urlencoded cases of the new 415 test and none of the Projects or States tests that existed. That last result is a gap in what U1 stood on: nothing pinned D-030 (5) for projects either, so `a_form_or_a_multipart_body_is_a_415` is added to both `projects.rs` and `states.rs`.

45 findings (25 errors, 20 warnings), 0 unaccepted, 0 stale, 0 ambiguous, and the check's four controls still refuse. Not run here: `native-pg`, `worker-memory` and `worker-cf`, which CI runs.

Refs: #58

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
aRustyDev added a commit that referenced this pull request Nov 16, 2026
… written from the type the routes answer with (#193)

The third of the per-resource steps of #58's schema diff (Projects was #179, States #188). The five label operations are in the document and in `described.operations`, so `scripts/check-openapi.sh` now diffs 18 of the pin's 32 against `oasdiff`.

`LabelDto` is the 15 keys of the pin's `LabelSerializer`, and `label_body` builds it and serializes it (`into_object`, as the project and state bodies do). A work item read with `expand=labels` takes its labels from the same function, so the expansion is the same type. The list answers `Page<Value>` from `Plan::page`. The five handlers carry `#[utoipa::path]` with the pin's operation ids (the detail read is `get_labels` there), response descriptions (create answers 201) and no summaries, because the pin has none. The list's query is `ListQuery`: the pin lists `expand` and `order_by` for it and the route ignores both, as the pin's view does (D-032 (2)), so a request that sends them is answered as one that does not. `LabelCreateUpdateRequest` and `PatchedLabelCreateUpdateRequest` describe what the hand parser takes, as the project and state request types do.

The wire is unchanged: the crate's tests 566 of 566 with the feature and 557 of 557 without it (6 new: 2 in `openapi.rs`, and the 415 matrix of 4 cases in `labels.rs`), the oracle gate and corpus comparison with the same numbers as G-25 (162 cases, 12 failures all accepted; 108 exchanges of which 11 are Labels, 13 accepted, 0 unaccepted; the corpus comparison's controls and C0 to C4), the contract `main` pass 70 of 70, and clippy clean for the crate with and without the feature, for the workspace and for the Worker on wasm32 (`utoipa` is not in its graph, and `cargo tree -i utoipa` finds it under `thrust-api-v1` with the feature, which is the control).

The first generation had 49 findings, 4 of them new and unaccepted, all of one kind: the form and multipart bodies of `create_label` and `update_label` (SD-013, SD-014). Thrust answers 415 to both, as it does on a project and a state, but D-030 (5) is the projects' and the owner confirmed it for projects only. It is D-032 (6) now, **proposed and not confirmed**, in DEVIATIONS.md and in the register entries, so that the check does not pass over it. The schema of a label needed no other fix: nothing else in the 15 keys, the two request bodies or the list's parameters differed from the pin by more than the register already accepts.

Controls, each shown on the real code: widening `LabelDto.name`'s `maxLength` from 255 to 300 turns 49 findings into 53, 4 of them unaccepted, one on each operation that answers with a label; skipping `parent` when it is `null` fails 8 tests, the new `a_labels_body_is_its_schema` among them and the work item's `expand=labels` test too; `json_body` made to read urlencoded forms fails exactly the six urlencoded cases of the three 415 tests (Labels, Projects, States) and none of the others. Nothing pinned a 415 for a form on a label before, which is the same gap as on the projects and the states; `a_form_or_a_multipart_body_is_a_415` is in `labels.rs` now.

49 findings (29 errors, 20 warnings), 0 unaccepted, 0 stale, 0 ambiguous, and the check's four controls still refuse. Not run here: `native-pg`, `worker-memory` and `worker-cf`, which CI runs.

Refs: #58

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
aRustyDev added a commit that referenced this pull request Nov 16, 2026
…ent, which now has all 32 of the pin's operations (#203)

The fourth and last of the per-resource steps of #58's schema diff (Projects #179, States #188, Labels #193). The 14 work item operations (seven under `issues/` and the same seven under `work-items/`) are in the document and in `described.operations`, so `scripts/check-openapi.sh` now diffs the 32 operations of the scope `m1` against `oasdiff`.

`IssueDto` is the 29 keys of the pin's `IssueSerializer`, and `work_item_body` builds it and serializes it. Where a body can say two things the type says both: a `state`, an assignee or a label is its id or, with `expand`, the object (`StateRef`, `UserRef`, `LabelRef`, over `StateBriefDto`, `UserBriefDto` and the `LabelDto` of the label routes), so the expansions that were `json!` are typed too. The list answers `Listing<T>`, a page or, when both halves of an integration key are named, the one work item; the search answers `IssueSearchDto`; the five names of a priority are `PriorityEnum`, written once for the body and the two request descriptions. The seven handlers carry `#[utoipa::path]` with the pin's operation ids, summaries and response descriptions (create answers 201). The routes register both families on the same handlers, so the document derives the `work-items/` family from the `issues/` one (`WorkItemsTwice`: the path, and the operation id followed by `_2`), and a test holds the two to be one set of operations. `Plan::envelope`, which stood for the lists that were not types yet, is gone.

Two things in the document changed for every resource. An optional request body was written `oneOf [T, null]`, which claims a `null` body that the routes refuse (400); `OptionalBodies` writes it as the object, as the pin does, which also lets `oasdiff` see inside it (it reports a body wrapped in a `oneOf` and stops there). And `priority` is `allOf` of the enum by reference, as the pin writes it: a bare reference left 52 findings that would each have needed an entry, and entries for an enum would hide a value that is added.

The wire is unchanged: the crate's tests 588 of 588 with the feature and 573 of 573 without it (22 new: 6 in `openapi.rs`, 16 in `work_items.rs`), the oracle gate and corpus comparison with the same numbers as G-25 (162 cases, 12 failures all accepted; 108 exchanges of which 36 are Work Items, 13 accepted, 0 unaccepted; the corpus comparison's controls and C0 to C4), the contract `main` pass 70 of 70, and clippy clean for the crate with and without the feature, for the workspace and for the Worker on wasm32 (`utoipa` is not in its graph).

103 findings (83 errors, 20 warnings), 0 unaccepted, 0 stale, 0 ambiguous, by 22 entries (SD-015 to SD-022 are new). The first generation had 108 unaccepted; what was left after the two changes above, 54, is of five kinds:

- The form and multipart bodies of the four operations that read a body (SD-015, SD-016). Thrust answers 415 to both, as on the other three resources, but D-030 (5) is the projects' and the owner confirmed it for projects only. It is D-033 (11) now, **proposed and not confirmed**.
- The pin's schema against the pin's own answers, each with its evidence and none of them a departure of Thrust's: the search (the schema describes one hit as the whole answer and a `sequence_id` that is a string; the recorded answer is `{"issues": [...]}` with a whole number: SD-017), the `state` (the schema says a uuid and the pin answers the object under `expand`, as the corpus's `list-expand-assignees-labels-state` records: SD-018, SD-019), and the list (a page, or the one work item for an integration key, which the schema does not describe: SD-020).
- The range of `sequence_id`: an i64 here and an int32 there (SD-021, SD-022).

Controls, each shown on the real code: a sixth priority in `PriorityEnum` turns 103 findings into 111, 8 unaccepted, and fails the test that ties the enum to the route; a `avatar_url` skipped when `null` fails 3 tests, the new `a_work_items_body_is_its_schema` and two that existed; the `OptionalBodies` modifier left out fails its test; the `_2` of the second family made `_3` fails the families test and the check (the document is not what the code writes); and `json_body` made to read urlencoded forms fails exactly the 10 urlencoded cases of the four `a_form_or_a_multipart_body_is_a_415` tests (2 each for Projects, States and Labels, 4 for Work Items). Nothing pinned a 415 for a form on a work item before.

Not run here: `native-pg`, `worker-memory` and `worker-cf`, which CI runs.

Refs: #58

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.

1 participant