Skip to content

refactor(contract): rebuild the slice model on /api/v1 work items - #155

Merged
aRustyDev merged 2 commits into
mainfrom
refactor/slice-model-on-v1
Nov 14, 2026
Merged

aRustyDev merged 2 commits into
mainfrom
refactor/slice-model-on-v1

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

Summary

Step 5c-1 of moving off /api/_slice: the slice model, its access matrix and the round-trip budget stop calling the slice's four work-item routes (create, list, search, delete), so the next PR can delete them. The owner chose to rebuild the model on /api/v1 rather than keep the routes for it or drop its coverage. Under the owner's decision of 2026-11-11 a slice route with a replacement goes, and the ones without stay under /api/_slice.

What the model checks now

What no Plane route replaces: attachments (ADR-0080), the activity feed and what the queue consumer does with an event (injected, redelivered, swept; a Checkpoint reads the feed). Its work items are a vehicle: made by a project's admin or member and deleted by its admin through /api/v1 with their API keys. MAX_OPS is asserted to stay below a key's v1 allowance.

What the model and matrix no longer check

  • Names, external keys, sequence ids, the role table and the list: these are tests/v1_model/'s, written from Plane's rules, so repeating them against the slice's rules would test a second, different contract.
  • Eight step classes went with them (37 became 29). The access matrix keeps the four routes with no Plane counterpart (the activity feed and attachment put, get, delete): 252 combinations, not 504.
  • The round-trip budget loses the slice's list: eight requests, six asked by an admin.
  • scope=with_deleted, the slice's admin-only list scope, has no counterpart on /api/v1 and loses its test with the route. This is the one real loss of coverage; G-26 records it.

The saved regression seed

mod.proptest-regressions held one seed (cc e3a9b674..., attachment steps around slice deletes). It cannot replay against the new strategy: the Op it names is gone. Its attachment steps are now the pinned sequence pinned() in tests/model/mod.rs, a pinned regression (AGENTS rule 9a) that both passes run first; the regressions file says so. No failing test is deleted or weakened.

Docs

  • G-26 in docs/src/testing/status.md: a "Moved (step 5c-1 ...)" paragraph, and the "Still on the slice" and "Not done" clauses brought up to date.
  • docs/src/testing/techniques/contract-suite.md, model-based.md and docs/src/flows/app.md: the model's description, the matrix size and the budget's eight requests.

Verification

On native-memory, after merging main (#151 raised EXPECT_MAIN from 68 to 70; this PR adds and removes no test): main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6; cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --all --check clean.

Controls:

  • The build mutants ignore-tenant, duplicate-sequence-number, no-activity-dedupe and ignore-revoked are still killed in the main pass. The rebuilt model is among the killers of ignore-tenant and no-activity-dedupe; duplicate-sequence-number is now killed by v1_model and the work-item tests, not by this model.
  • A temporary, uncommitted change to put_attachment that let a put land on a soft-deleted item failed this model alone (67 of 68) at AttachmentOnDeletedItem, shrunk to create, delete, put. It is reverted.
  • model_strategy_reaches_every_step_class passes with all 29 classes.

Not run locally: native-pg, worker-memory and worker-cf (they run in CI), the budget test against Postgres, and the whole of scripts/mutants.sh (only the four mutants above).

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

🤖 Generated with Claude Code

aRustyDev and others added 2 commits November 14, 2026 00:24
The slice model, its access matrix and the round-trip budget no longer call the slice's four work-item routes (create, list, search, delete), so the next step can delete them. The owner chose to rebuild the model on /api/v1 rather than keep the routes for it or drop its coverage.

What the model still checks is what no Plane route replaces: attachments (ADR-0080), the activity feed and what the queue consumer does with an event (injected, redelivered, swept, the checkpoint read of the feed). Its work items are a vehicle: made by the project's admin and member and deleted by the project's admin through /api/v1 with their API keys. A run stays under a key's v1 allowance (MAX_OPS is asserted below it).

What the model and matrix no longer check, and why that is not a loss of coverage except the last item:
- names, external keys, sequence ids, the role table and the list are v1_model's, written from Plane's rules, so repeating them against the slice's rules would test a second, different contract;
- 8 step classes went with them (37 became 29), and the access matrix is 252 combinations, not 504: only the activity feed and the three attachment routes have no Plane counterpart;
- the round-trip budget loses the slice's list (eight requests, six by an admin);
- `scope=with_deleted`, the slice's admin-only list scope, has no counterpart on /api/v1 and loses its test with the route. Recorded in G-26.

The one saved counterexample in mod.proptest-regressions (cc e3a9b674..., attachment steps around slice deletes) cannot replay against the new strategy: the Op it names is gone. Its attachment steps are now the pinned sequence `pinned()` in tests/model/mod.rs, a pinned regression that both passes run first (AGENTS rule 9a); the regressions file says so. The seed is replaced because it cannot be replayed at all; no failing test is deleted or weakened, and the pinned sequence passes in the runs below.

Checked on native-memory: main 68 of 68, sweeper 3 of 3, csrfoff 6 of 6, clippy clean on the workspace; no test was added or removed. Controls: ignore-tenant, duplicate-sequence-number, no-activity-dedupe and ignore-revoked are still killed in the main pass (the slice model is among the killers of ignore-tenant and no-activity-dedupe; duplicate-sequence-number is now killed by v1_model and the work-item tests, not by this model). A temporary change to put_attachment that let a put land on a soft-deleted item failed this model alone (67 of 68), shrunk to create, delete, put, and was reverted. The other three targets run in CI.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Main gained #151 (change password, two contract tests: EXPECT_MAIN 68 became 70 and EXPECT_BINDINGS 4 became 5), #152, #153 and #154. The merge was clean, with no conflicts; the only files both sides touched are docs (docs/src/testing/status.md and docs/src/flows/app.md, merged automatically, different lines). This branch adds and removes no contract test, so main's 70 is the count.

Checked on native-memory after the merge: main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6, clippy clean on the workspace.

Refs: #58
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@aRustyDev
aRustyDev merged commit 9b8ebe7 into main Nov 14, 2026
35 checks passed
@aRustyDev
aRustyDev deleted the refactor/slice-model-on-v1 branch November 14, 2026 05:52
aRustyDev added a commit that referenced this pull request Nov 14, 2026
…delete routes (#159)

Step 5c-2 of moving off /api/_slice. Work items are made, listed, searched and deleted through /api/v1 and Plane's compat routes, and since #155 no test calls the slice's four routes for that except the walk that shows the routes left the reserved prefix. Under the owner's decision of 2026-11-11 a slice route with a replacement goes.

Deleted: POST and GET .../work-items, GET .../work-items/search and DELETE .../work-items/{id}; their four handlers and the two query types in thrust-api; the contract suite's helpers for them (create, create_ok, list, search, search_path). wi_path stays: it is the base of the activity and attachment routes, which no Plane route replaces. The four leave slice_routes(), the table that the_slice_routes_are_gone_from_the_reserved_v1_prefix walks (nine tenant routes became five).

One assertion went with its route and is not replaced: the last check of that test, "the retired-prefix calls had no effect", read the slice's list and expected the one item that the live prefix's create had made, so it cannot exist without those routes. The walk keeps its guard: every retired call is asserted a routing 404 (a 404 with no error code, so no handler ran; a handler answers with an error body or a 2xx), so a retired route that is still mounted fails on its own line whatever state it would have changed. The test's POST arm, which only the deleted create used, goes too.

What stays, and why: the core's create_work_item, delete_work_item, list_work_items and search_work_items, their port methods and the create limiter. Nothing in the routes calls them now, but the core's own model, outbox and attachment tests and the adapters' tests do, so removing them reworks those tests: that is step 5c-3 and more than dead code. G-26 and the flows page say so.

Docs: flows/app.md loses the three route rows (search was never in the table), notes where work items are served now, marks the "Creating a work item" section as the core use case that only tests call, corrects the errors table (no slice route raises the create limit's 429 any more; the 409 example is the operator's create of an account whose email is taken, which still can) and the route counts of the walking test (five tenant routes and seven identity routes, were "eight" and "ten"). G-26 records the deletion and updates its "Not done" clause.

No test is added or removed. Checked on native-memory: main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6, clippy clean on the workspace and rustfmt clean. Control: with GET /work-items put back in the table, the walking test fails (69 of 70) at "not mounted (404)", so the table is held. The other three targets run in CI.

Refs: #58

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
aRustyDev added a commit that referenced this pull request Nov 14, 2026
…routes called (#161)

Step 5c-3a of moving off /api/_slice. The owner split step 5c-3 into three PRs, one each: the core (this), then the adapters, then the create limiter. Since #159 nothing in the routes calls the core's slice work-item use-cases, and `/api/v1` and the compat plane make, read and delete work items through `create_issue`, `list_issues` and `delete_issue`.

Deleted in thrust-core: `create_work_item`, `delete_work_item`, `list_work_items`, `search_work_items`, their constants `SEARCH_LIMIT` and `SEARCH_QUERY_MAX`, and the two permissions only they used (`DeleteWorkItem`, `ReadDeleted`, with their rows in the role table). Deleted in thrust-contracts: `CreateWorkItemRequest`, the wire type of the deleted create route. `validate_name`, `relay_after_commit` and `event` stay: the issue use-cases use them.

One passing test file is deleted, on purpose and under AGENTS rule 3: tests/model.rs (`model_work_items_match_the_reference_model` and its coverage control). Its subject was the deleted functions (validation first, who may list, who may list the deleted rows), so unlike the slice model of #155 it has no vehicle to keep. What it wrote down for work items is `tests/v1_model/` over HTTP and the core's tests of the v1 use-cases. That the deletion loses no kill was measured, not assumed: with `cargo nextest run -p thrust-core --no-fail-fast`, the planted `mutant_ignore_tenant` still fails 40 core tests (`another_tenants_project_is_not_found` and `the_slug_decides_which_workspace_a_project_is_looked_up_in` among them) and `mutant_dup_sequence` fails 3 (the generated `prop_work_items_are_numbered_and_placed_one_after_another` and two `issues_v1` tests).

Changed, not deleted: the outbox and attachment tests keep their subjects (the relay, ADR-0080) and make their work items with `v1_issue_writer`, `create_issue` and `delete_issue`, as `/api/v1` does; their assertions are unchanged except that an id is read from `item.item.id`. `authorize_follows_the_role_table` loses the two removed permissions' rows, and `another_tenants_project_is_not_found` probes `WriteState` where it probed `ReadDeleted`, so it keeps its three cases.

Docs: flows/app.md describes creating and deleting a work item as `create_issue` and `delete_issue` do (the request layer is Plane's; the old section described the deleted function and its limiter); contributing/patterns.md cites those instead; model-based.md, evidence-and-controls.md, defect-matrix.md, mutation.md and G-11 and G-26 in status.md stop naming the deleted model and say where its properties live.

Checked: `cargo nextest run -p thrust-core` 1569 of 1569; native-memory main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6 (no contract test is added or removed); clippy and rustfmt clean on the workspace. Controls: a temporary change that let `put_attachment` accept a soft-deleted item failed `an_attachment_needs_a_live_work_item` alone (9 of 10 attachment tests pass); inverting the fast-path guard in `relay_after_commit` failed 5 of 6 outbox tests. Both reverted. The other three targets run in CI.

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