Skip to content

refactor(adapters): delete the port reads that only the slice's list and search used - #164

Merged
aRustyDev merged 1 commit into
mainfrom
refactor/delete-adapter-slice-work-item-methods
Nov 14, 2026
Merged

aRustyDev merged 1 commit into
mainfrom
refactor/delete-adapter-slice-work-item-methods

Conversation

@aRustyDev

Copy link
Copy Markdown
Owner

Summary

Step 5c-3b of moving off /api/_slice: delete the port reads that only the slice's list and search used. The owner's order for step 5c-3 is the core (#161, merged), then the adapters (this), then the create limiter, one PR each. #161 deleted the core functions that called the port's list_work_items and search_work_items, so nothing but tests calls them now.

What goes

  • list_work_items and search_work_items on the Database port, and their memory and Postgres implementations.
  • get_work_item and the Tx writes stay: create_issue, delete_issue and put_attachment use them. The Postgres adapter's like_pattern stays too, because the workspace search uses it.
  • 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).

How the tests that read through them change

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.
  • Postgres adapter tests: the 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

tests/history.rs checked that "the item as the list reads it carries the name". The page assertion just above it already compares the whole row with the updated one (after sets the name), and its subject, the list read, is gone. The commit message says so, as AGENTS rule 3 asks.

Two doctests in thrust-core

The two authorize doctests 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.

A correction to my own first attempt: I tagged the example 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; the tag is removed and the compiling control is what shows the reason.

Docs

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

Verification

  • The Postgres adapter tests against a container (cargo nextest run --ignore-default-filter -E 'binary(pg_adapter)', DOCKER_HOST set to OrbStack's socket): 70 of 70, no Docker errors.
  • cargo nextest run: 3866 of 3866 (4 skipped). cargo test --doc -p thrust-core: 3 of 3.
  • On native-memory: main 70 of 70, sweeper 3 of 3, csrfoff 6 of 6, engine 4 of 4. No contract test is added or removed.
  • cargo clippy --workspace --all-targets -- -D warnings and cargo fmt --all --check clean. Main has not moved since this branch was cut (c32e4bc), so nothing was merged.

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 its 4 tests.

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

Still to come in step 5c-3

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

…and search used

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
aRustyDev merged commit 1fe7963 into main Nov 14, 2026
35 checks passed
@aRustyDev
aRustyDev deleted the refactor/delete-adapter-slice-work-item-methods branch November 14, 2026 07:35
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