Skip to content

refactor(core): delete the work-item use-cases that only the slice's routes called - #161

Merged
aRustyDev merged 1 commit into
mainfrom
refactor/delete-core-slice-work-item-use-cases
Nov 14, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
refactor/delete-core-slice-work-item-use-cases

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

Summary

Step 5c-3a of moving off /api/_slice: delete the core's slice work-item use-cases. The owner split step 5c-3 into three PRs, one each and in this order: the core (this), then the adapters, then the create limiter. Since #159 nothing in the routes calls these use-cases, and /api/v1 and the compat plane make, read and delete work items through create_issue, list_issues and delete_issue. Under the owner's decision of 2026-11-11 a slice route with a replacement goes, and so does the code behind it.

What goes

  • In thrust-core: create_work_item, delete_work_item, list_work_items and search_work_items; their constants SEARCH_LIMIT and SEARCH_QUERY_MAX; and the two permissions only they used, DeleteWorkItem and ReadDeleted, with their rows in the role table.
  • In thrust-contracts: CreateWorkItemRequest, the wire type of the deleted create route.
  • crates/thrust-core/tests/model.rs: see the next section.

validate_name, relay_after_commit and event stay: the issue use-cases use them.

A passing test file is deleted, on purpose

tests/model.rs (model_work_items_match_the_reference_model and its coverage control) is deleted. 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. The commit message says so, as AGENTS rule 3 asks.

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);
  • mutant_dup_sequence still fails 3 (the generated prop_work_items_are_numbered_and_placed_one_after_another and two issues_v1 tests).

What changes, and what does not

  • outbox.rs and attachments.rs 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. another_tenants_project_is_not_found probes WriteState where it probed ReadDeleted, so it keeps its three cases.

Docs

  • docs/src/flows/app.md: creating and deleting a work item are described 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.

Verification

Controls (both temporary and reverted):

  • put_attachment made to accept a soft-deleted item fails an_attachment_needs_a_live_work_item alone (9 of 10 attachment tests pass).
  • The fast-path guard of relay_after_commit inverted fails 5 of the 6 outbox tests, so the new vehicle is what those tests drive.

Not run locally: native-pg, worker-memory and worker-cf (they run in CI), and the passes outside main, sweeper and csrfoff.

Still to come in step 5c-3

The adapters (the port methods only the deleted functions used, with their memory and Postgres impls and the tests that call them), then the create limiter (RL_CREATE, THRUST_CREATE_RATE_LIMIT, THRUST_EXPECT_CREATE_LIMIT, Target::create_limit and the pages that describe them).

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

🤖 Generated with Claude Code

…routes called

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]>
@aRustyDev
aRustyDev merged commit c32e4bc into main Nov 14, 2026
66 of 68 checks passed
@aRustyDev
aRustyDev deleted the refactor/delete-core-slice-work-item-use-cases branch November 14, 2026 06:50
aRustyDev added a commit that referenced this pull request Nov 14, 2026
…and search used (#164)

Step 5c-3b of moving off /api/_slice (the owner's order for 5c-3 is the core, then the adapters, then the create limiter, one PR each). #161 deleted the core functions that called the port's `list_work_items` and `search_work_items`; nothing but tests calls them now. `get_work_item` and the `Tx` writes stay, because `create_issue`, `delete_issue` and `put_attachment` use them; the Postgres adapter's `like_pattern` stays too, because the workspace search uses it.

Deleted: the two methods on the `Database` port and their memory and Postgres implementations. `mutant_search_case_sensitive` was planted in both searches of the memory adapter; it is in the workspace search now (the one /api/v1 and the engine pass go through), and the engine pass still kills it: 2 of its 4 tests fail.

The tests that read through the two methods read what is left, and each replacement keeps what the read was for:
- memory adapter: the reset test checks each seeded row is gone in any state (`get_work_item` with `WithDeleted`, stronger than the old live list); a refused creation leaves one live item (the `total` of a page); the not-there update test checks both rows of the project, the only two, by id with `WithDeleted`.
- Postgres adapter: tests of a rollback, an abandoned transaction, a soft delete and a refused update read the table with SQL (`every_item_name`, `live_item_count`). That is the table's state and not the adapter's reading of it, so a row that a failed write leaked cannot hide behind the adapter's own filter.
- Postgres model: `Op::List` becomes `Op::Table`, the project's live rows or every row read with SQL and compared with the model's. It is kept because it is the model's only way to see an extra row (`Op::Get` picks from rows the model knows). The step classes go from 214 to 213: `ListedWrongWorkspace` went with the method, since a SQL read has no scope check to probe (`GotWrongWorkspace` keeps the tenant probe of `get_work_item`).
- statement-counting model: `Step::List` becomes `Step::Get`; each is one statement.

One assertion is removed and not replaced, under AGENTS rule 3: tests/history.rs checked that "the item as the list reads it carries the name", and the page assertion just above it already compares the whole row with the updated one (`after` sets the name). Its subject, the list read, is gone.

Two doctests in thrust-core's `authorize` called the port's `list_work_items`. They use `get_work_item` now, with the same arguments in the failing example and in its compiling control. Before, the failing example called a two-argument method with three, so it failed on arity and not on the proof it exists to guard. I first tagged it `compile_fail,E0308` and said rustdoc enforces the code; a control (the example given the wrong kind of error) still passed, so on stable it does not, and the tag is removed. What shows the reason is the control: the same call with the proof in the first place compiles.

G-24 in status.md still said nine requests and the slice's list; it says eight (step 5c-1 missed it). G-26 records this step; mutation.md says where the search mutant is.

Checked: the Postgres adapter tests against a container 70 of 70 (DOCKER_HOST set; no Docker errors); `cargo nextest run` 3866 of 3866 (4 skipped); core doctests 3 of 3; native-memory main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6, engine 4 of 4; clippy and rustfmt clean on the workspace.

Controls, all temporary and reverted:
- `ROLLBACK` changed to `COMMIT` in `PgTx::rollback`: the Postgres model fails, at its end-of-case outbox depth check and not at the table op; the rollback test and the counting model do not see it.
- the table op's expectation inverted: the model fails at step 1 with "the project's rows in the table", so the new observation runs and compares.
- `mutant_search_case_sensitive`: the engine pass fails 2 of 4.

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
…nd its settings (#166)

* refactor(rate-limits): delete the slice's create limit, its binding and its settings

Step 5c-3c of moving off /api/_slice, the last piece of step 5c-3 (the owner's order was the core, then the adapters, then this, one PR each). The per-user create limit was applied by the slice's `create_work_item`, which #161 deleted. Nothing reads it now, and /api/v1 has its own per-key allowance.

Deleted:
- `CoreConfig.create_rate_limit` and `THRUST_CREATE_RATE_LIMIT`, in the native server and the Worker.
- `CoreConfig.rate_window_secs` and `THRUST_RATE_WINDOW_SECS`, and the Worker's startup check of that window. Only the create limit's use-case read them (checked: no other reader in the workspace); /api/v1's window is the period in `THRUST_V1_RATE_LIMIT` and sign-in's is a constant of the core's config.
- The `RL_CREATE` binding and its `[[ratelimits]]` block in wrangler.toml, wrangler.stage2.toml and wrangler.pg.stage.toml, and the Worker's `env.rate_limiter("RL_CREATE")`.
- In thrust-adapters-cloudflare, `KeyClass::Create` and `CfRateLimiter.create`. A key that starts with `create:` is a key of no class now: an error, never a free pass. The tests list it, as three refused keys.
- `Target::create_limit` (no caller) and `THRUST_EXPECT_CREATE_LIMIT`; `THRUST_WORKER_CREATE_LIMIT` and the create handling in scripts/worker-dev.sh; `RATE_LIMIT` in scripts/contract.sh; the create refusal in scripts/stage2-contract.sh.

One option is retargeted, not deleted: `scripts/spike-0002-pg.sh deploy --create-limit N` is `--v1-limit N` and rewrites the `RL_V1` limit (marker `__V1_LIMIT__` on that line, default 60). The engine pass goes through /api/v1, so RL_V1 is the binding it needs raised on a deployed Worker; `--create-limit` raised one that the pass no longer touched. The infra, contract-suite and defect-matrix pages and G-26 say so.

Operations: the Worker built from this commit and this commit's config are a pair. The code no longer asks for `RL_CREATE` and the config no longer declares it, so the previous Worker with this config would fail to start (it asks for a binding that is not there). Deploy them together.

The two assertions that changed in thrust-adapters-cloudflare/tests/rate_limiter.rs are the class list (two classes, not three) and the setting name the period tests pass to `check_binding_period`, which was `THRUST_RATE_WINDOW_SECS` and is the name the Worker still passes (`the period of THRUST_V1_RATE_LIMIT`).

Checked: native-memory main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6, engine 4 of 4; worker-memory main 70 of 70; worker-cf main 70 of 70 and bindings 5 of 5, from a config with RL_SIGNIN and RL_V1 only; `cargo nextest run` 3860 of 3860 (6 fewer than before: the class tests have 2 classes where they had 3, and the 3 refused keys are added); doctests; clippy and rustfmt; `sh -n` of the four changed scripts under dash (an Ubuntu container). One test, thrust-api-v1's `parity_slugify_of_drawn_names_is_the_pins`, was reported "leaky" once in the full parallel run and passed clean in three solo runs; it is in a crate this change does not touch.

Controls, temporary and reverted:
- `create` mapped to a class again in `KeyClass::of`: the 3 refused-key cases fail, 127 others pass.
- a Worker that asks for a binding its config lacks never comes up (wrangler: "Binding ... is undefined", exit 4), so the worker-cf cell catches a binding mismatch and its pass without RL_CREATE is evidence.
- stage2-contract.sh refuses `THRUST_EXPECT_V1_LIMIT=1000000` (exit 2) and passes the guard at the default.
- the spike script's `sed` on the staging template changes only the RL_V1 line (a dry run; nothing is deployed from here).
- the dash check of the scripts fails a deliberately broken script.

Not run: native-pg (CI runs it) and any deploy.

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

* refactor(deploy): drop the RL_CREATE binding from the deploy configuration

The deploy pipeline (#165) declared the binding that this PR's earlier commit deletes from the Worker and the other configs: the template crates/thrust-worker/wrangler.deploy.toml had an `RL_CREATE` block with a `__RL_CREATE_ID__` marker, scripts/render-wrangler.sh filled it from `THRUST_RL_CREATE_ID`, and deploy.yml and the deploy-worker action passed that variable through. Left alone it fails CI: `test-deploy-template.sh` requires the template and wrangler.toml to bind the same things (`deploy_parity.py`), and the template would still have a binding wrangler.toml no longer has. My first push did not have #165 in it; the failure was found when main moved, by searching its tree for the names this PR deletes.

Changed:
- wrangler.deploy.toml: the `RL_CREATE` block and its marker go; the comment says the environment has two namespace ids, not three, and that there was a third.
- render-wrangler.sh: the marker, the variable, the id list in the header and the self-test fixtures go, and the rule that the ids differ is about two ids now (its message says "the two"; the self-test's fragment "must differ from one another" still matches). The cases for `THRUST_RL_CREATE_ID` unset and empty and for the two equalities that involved it go with it (four cases). Two cases are added, as the control for the removal: a template that still has the retired `__RL_CREATE_ID__` marker is refused ("which this script does not know"), with or without `THRUST_RL_CREATE_ID` still in the environment, so a stale template cannot be rendered into a config that declares a binding the Worker does not use.
- The deploy-worker action loses its `rl-create-id` input and its `THRUST_RL_CREATE_ID` env; deploy.yml loses the variable from its list of an environment's variables, from the dry run's environment and from both `rl-create-id:` inputs; test-deploy-worker.sh drops it from its good environment.
- G-26 records this.

Checked, under dash in an Ubuntu 24.04 container (CI's shell) on this tree and, as a baseline, on origin/main, with python3, jq and nc installed: every test of the `ci-scripts` job and both deploy guards (the renderer's `--self-test` and the workflow lint of deploy.yml and the action) pass on both. The renderer's self-test is 43 ok on this tree and 45 on main: four cases removed, two added. `scripts/check-placement.sh` passes. clippy and rustfmt are clean on the merged tree.

Control: main's template against this wrangler.toml fails the parity check (exit 1: the template has `RL_CREATE`, wrangler.toml does not); the fixed template agrees.

The `THRUST_RL_CREATE_ID` variable of the GitHub environments is unused now. It is harmless and deleting it is the owner's. A deploy of this commit renders a config with two rate-limit bindings and a Worker that asks for those two.

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

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 15, 2026
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