Skip to content

feat(mcp): add user_admin, user_get, the invoice reads and reports_list - #1224

Merged
chappie-daemon merged 8 commits into
rewrite/mainfrom
factory/037-mcp-users-invoices
Nov 22, 2026
Merged

chappie-daemon merged 8 commits into
rewrite/mainfrom
factory/037-mcp-users-invoices

Conversation

@chappie-daemon

Copy link
Copy Markdown
Collaborator

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-storage is empty).

user_admin and user_get — two rows, because scope is a row property

user_admin carries 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_get reads the same row and its balance. They are separate tools because scope is a property of the TOOLS row: one tool would have made a balance read cost a write document 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_pubkey with the balance taken from the row it answers, and never is_vanished — that method hydrates a live kind-62 and stores a row, and user_get is 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_list is the store's pending walk, oldest first, paged by offset and limit; invoices_get takes the invoice's own opaque id verbatim and answers a miss as {"invoice": null}, matching get_event. reports_list is the actionable review queue over find_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_admin to maintenance_run; CONFIGURATION.md and --help name 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 is crates/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; offset is unbounded on a read grant (filed as #1223).

Implements #1183 (slice 4 of 5).

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-bot

changeset-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e31c919

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 0 packages

When 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

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87b3917c-5263-4e22-b384-5c57b5737dd7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@greptile-apps

greptile-apps Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; the previous finding is fixed and no new actionable issue was found.

Summary

Adds five MCP tools for user administration, user reads, invoice reads, and the report review queue.

  • Operators can change a user's admission and vanished flags with one tool.
  • A read-only tool shows a user's stored row and balance.
  • Callers can list pending invoices or read one by its own ID.
  • The report list shows the actionable review queue.
  • The MCP tool list and its access and audit records include the five new tools.

Reviews (2) · Last reviewed commit: "docs(mcp): the review queue names the id..." · Reviewed by Greptile

Comment thread crates/nostream-mcp/src/server.rs Resolved
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.
@chappie-daemon
chappie-daemon merged commit ab3626c into rewrite/main Nov 22, 2026
17 checks passed
@chappie-daemon
chappie-daemon deleted the factory/037-mcp-users-invoices branch November 22, 2026 01:39
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