Repository navigation
feat(mcp): add user_admin, user_get, the invoice reads and reports_list - #1224
Conversation
user_admin carries admit, revoke, vanish and unvanish as one closed action enum, and user_get reads the same row and its balance under a document that grants nothing: the scope is a property of the TOOLS row, so one tool would have made a balance read cost a write document or an admission reachable with a read-only one.
The read path is find_by_pubkey plus get_balance_by_pubkey and never is_vanished, which hydrates a live kind-62 and stores a row. invoices_list is the store's pending walk, paged by offset and limit; invoices_get takes the opaque id verbatim and answers a miss as {invoice: null}. reports_list is the review queue over find_actionable, newest first, with no offset. Both list tools share the door's one page bound.
The audit vocabulary gains five mcp.* names, each carrying {tool} and nothing else; the four absent-name sites move to maintenance_run; the count sites read twelve.
ADR 0018 records D1-D7 with a cost each: the two rows the scope forces, the read path that never hydrates, the row-not-a-count payload, the queue and the price of a full listing, pending-only invoices with a miss as a result, one page bound, and the absent-name move with the five audit names. ADR 0014's D18 table gains the five names and its two sentences say twelve. CONFIGURATION.md's two tool lists and nostreamd --help name the twelve tools and the eight/four split. The changeset is empty: Rust only, no published package moves.
R14 asks MAX_ROWS_PER_PAGE's doc for one sentence; the first copy was spliced into the paragraph's previous line and said the same thing twice. Doc prose is what fmt and clippy cannot see, so the round-1 gate's read found it.
The --mcp-stdio sentence was rewritten for this slice and still named eleven of the twelve tools; relay_status was missing at base too, which is not a reason to carry the omission through a rewrite.
The user payload called get_balance_by_pubkey after find_by_pubkey, which loads and decodes the same row a second time on the read path — and on a read reachable with a scopeless document. The row carries its balance, so the payload derives it: user is null versus Some(row) is what distinguishes no row from no funds, and one read keeps one snapshot in one answer. D2 states that, and D6's cost names the cause that actually shifts the offset walk: a pending row leaving the index when its status moves off Pending, not an insertion after the cursor. The four action names were spelled twice — as_str and the schema literal — and only two of the four payloads were pinned. The enum now comes from as_str over one ALL table, and the vanish case asserts each payload's action against the members the schema publishes.
The one-read invariant had no case: a store that answers get_balance_by_pubkey cannot say whether the call happened. A forwarding UserRepository refuses it instead, seeded through a users factory beside the event and report ones, and user_get on an absent pubkey answers {user: null, balance: 0} only if nothing calls the removed read — with the second read restored the case fails. D2 gains the edge the pair was not outcome-identical on: a NULL balance coalesces to 0 in the row read and would have failed the removed try_get.
The approver found this sentence was the one false claim in the merged artifact: it named a second read the branch had removed in its own rework.
🦋 Changeset detectedLatest commit: e31c919 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
[High impact] The PR appears safe to merge; the previous finding is fixed and no new actionable issue was found.
|
Its rows carry an integer id and a separate hex event_id, and reports_action takes the latter. Copying the id the list shows is a refusal, which is what the old sentence invited.
Slice 4 of #1183. Five tools over the store seams already in the tree — no new trait method, no new store field (
git diff a8cef4a5 -- crates/nostream-storageis empty).user_adminanduser_get— two rows, because scope is a row propertyuser_admincarries the four decisions an operator makes about one pubkey —admit,revoke,vanish,unvanish— as one closed action enum, and answers the row as it stands after the call.user_getreads the same row and its balance. They are separate tools because scope is a property of theTOOLSrow: one tool would have made a balance read cost awritedocument or an admission reachable with a read-only one. A case pins the split by running the four reads under an empty document and asserting the write is refused once.The read path is one
find_by_pubkeywith the balance taken from the row it answers, and neveris_vanished— that method hydrates a live kind-62 and stores a row, anduser_getis reachable with a document that grants nothing. A case refuses the balance read through a delegating repository, so the one-read invariant is pinned rather than described.The reads
invoices_listis the store's pending walk, oldest first, paged byoffsetandlimit;invoices_gettakes the invoice's own opaque id verbatim and answers a miss as{"invoice": null}, matchingget_event.reports_listis the actionable review queue overfind_actionable(limit)— the description says so, and the general listing is out of scope with its price in ADR 0018, so a later slice takes it deliberately.Record
ADR 0018 with D1–D7 and a cost each; ADR 0014's D18 table and its two sentences; the twelve count sites; the four absent-name sites move from
user_admintomaintenance_run;CONFIGURATION.mdand--helpname all twelve tools; changeset added.Verification
cargo fmt --all --check, both clippy passes,cargo test --workspace --all-features(1 801 passed / 0 failed / 9 ignored) and a release build, all exit 0. The oracle iscrates/nostream-mcp/tests/store_families.rs— 18 cases, each made to fail once by a specific edit, with the reds in the job record. The gate ran eight named inversions before writing a finding; all eight reddened.Known and stated: the Postgres arms run only in CI;
offsetis unbounded on a read grant (filed as #1223).Implements #1183 (slice 4 of 5).