Skip to content

test(contract): move the engine pass onto /api/v1 with API keys - #125

Merged
aRustyDev merged 3 commits into
mainfrom
refactor/contract-engine-model-on-v1
Nov 11, 2026
Merged

aRustyDev merged 3 commits into
mainfrom
refactor/contract-engine-model-on-v1

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

What

Stage 2a of moving the contract suite off the slice's /api/_slice routes (G-26 in docs/src/testing/status.md is the ledger; the shape is the owner's choice of 2026-11-11: staged, work-item tests onto /api/v1 with API keys). Stage 1 was #122. This moves the engine pass: the four engine_ tests of engine.rs.

Part of #58 (not closing it).

Stage 2b (the model test and the access matrices) is not here. The model is a spec of the slice's behaviour, with attachments, the activity feeds, with_deleted and bearer actors in it, so it cannot move whole; carving a /api/v1 model out of it is a design of its own, and I will propose it separately.

What changed

  • engine.rs: the four tests go through /api/v1 with the fixture's API key. The pass needs the target started with a very high /api/v1 limit (the 10,000 creates of 50 writers are far over Plane's 60 requests a minute per key), so scripts/contract.sh exports THRUST_V1_RATE_LIMIT=1000000/minute for the engine pass, as it already does for oracle.
  • lib.rs of the suite: v1_list_all (a whole list by cursor, a thousand to a page), v1_search and v1_search_hits.
  • thrust-adapters-memory: mutant_search_case_sensitive is in search_workspace_work_items too (see below).
  • Docs: G-26, the contract-suite page and the mutation page.

What the tests say now (the pin's answers)

  • The 10k test: no duplicate sequence number, contiguous from 1, none reused after the deletes, as before. Each writer deletes the work items it made (the pin lets a member delete only those). The whole list is read back by cursor and compared with the numbers made and not deleted. The sort_order check is dropped: the pin reads the greatest one of a state before it inserts, so two creates at once can share a place.
  • The search tests compare with the pin's workspace search (/workspaces/{slug}/issues/search/): a work item matches when its name has the query in it (any case), or its project identifier does, or the query says its number as a whole number; the first 100, newest first. A description is not searched, and a control says so. A stranger and a member of no project are answered with nothing, not refused (the old route said 404 and 403); a blank or missing text is no search. The two deliberately wrong matchers (case-sensitive, prefix-only) must still differ from the oracle on the corpus.
  • The bulk seed's numbering is checked through /api/v1. Its own sort_order and plain description are not shown there and are not held to a rule.

A finding: the mutant was on the wrong search

scripts/mutants.sh runs this pass against mutant_search_case_sensitive and requires it to fail. That mutant was only in the slice's per-project search_work_items; /api/v1 searches through search_workspace_work_items. Measured on this branch before the fix: the engine pass passed 4 of 4 against the mutant (exit 0), which the script would have reported as SURVIVED. The mutant is in both searches now (its own commit), and the two search tests fail against it.

Evidence (2026-11-11, local)

  • scripts/contract.sh <target> engine: 4 passed, 4 expected, on native-memory, native-pg, worker-memory and worker-cf (183 s on worker-cf). On Postgres the pin's search, with ILIKE and escaping, agrees with the oracle on all 400 generated queries.
  • Controls (the engine pass's two mutants, by hand): duplicate-sequence-number fails 2 of 4 (the 10k test and the bulk seed); case-sensitive-search fails the 2 search tests (and passed 4 of 4 before the second commit).
  • cargo nextest run -p thrust-adapters-memory: 529 passed. cargo fmt --all --check and cargo clippy -p thrust-contract-tests -p thrust-adapters-memory --all-targets -- -D warnings: clean.
  • Not run locally: the whole scripts/mutants.sh (the mutants job runs it) and the main pass on the four targets (not touched here; the memory adapter's change is inside a cfg that the default build does not take).
  • The engine pass is opt-in and not in contract-all.sh, so CI runs it only through mutants.

Not done (G-26)

Stage 2b (the model test and the matrices), and then what stays on the slice until the routes that replace it exist: sign-out and sign-out-everywhere, the session info, OIDC, API-key management, the activity feeds, attachments, and the tests that use a slice work item as their vehicle (the outbox, redelivery, sweeper and panic tests, the create limit, the cookie and CSRF tests, the bench).

🤖 Generated with Claude Code

aRustyDev and others added 3 commits November 11, 2026 18:32
…rkspace search too

`mutant_search_case_sensitive` (a `contains` that does not fold case, which
`scripts/mutants.sh` runs the engine pass against and requires to fail) was only
in `search_work_items`, the slice's per-project search. `/api/v1`'s search is
another function, `search_workspace_work_items`, so an engine pass that goes
through `/api/v1` would not see the mutant at all.

It is in both now, through the same `fold` closure. Without it, the engine pass
moved onto `/api/v1` passed 4 of 4 against the mutant (measured: exit 0), which
`scripts/mutants.sh` would have reported as SURVIVED; with it, the two search
tests fail.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
The four `engine_` tests (`engine.rs`, `scripts/contract.sh <target> engine`) went
through the slice's routes with a Bearer session. They go through `/api/v1` with
the fixture's API key now, and the pass starts the target with
`THRUST_V1_RATE_LIMIT=1000000/minute` as well, because the 10,000 creates of 50
writers are far more than Plane's 60 requests a minute per key.

- The 50-writer test checks the numbers as before (no duplicate, contiguous from
  1, none reused after the deletes). Each writer deletes the work items it made,
  because the pin lets a member delete only those, and the whole list is read
  back by cursor (a thousand to a page) and compared with the numbers made and
  not deleted. The `sort_order` check is dropped: the pin reads the greatest one
  of a state before it inserts, so two creates at once can share a place.
- The search tests go through the pin's workspace search
  (`/workspaces/{slug}/issues/search/`). The oracle is the pin's: a work item
  matches when its name has the query in it (any case), or its project's
  identifier does, or the query says its number as a whole number; the first 100
  newest first; a description is not searched (the test says so with a
  control). The two deliberately wrong matchers (case-sensitive, prefix-only)
  still have to differ from it on the corpus. A stranger to the workspace and a
  member of no project are answered with nothing, not refused; a blank or
  missing text is no search.
- The bulk seed's numbering is checked through `/api/v1`; its own `sort_order`
  and plain description are not shown there and are not held to the pin's rule.

Measured (2026-11-11): the engine pass, 4 of 4, on native-memory, native-pg,
worker-memory and worker-cf (183 s on worker-cf for the 10,000 creates).
Controls: the `duplicate-sequence-number` mutant fails 2 of the 4 (the 10k test
and the bulk seed), and the `case-sensitive-search` mutant fails the 2 search
tests (with the mutant also on the workspace search, the previous commit).

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
G-26 lists stage 2a as moved, and says that the case-sensitive-search mutant
was found surviving the moved pass and is now in the workspace search too. The
contract-suite and mutation pages say which surface the engine pass uses, the
pin's workspace search it compares with, and where the mutant sits.

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