You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a8cef4a
Browse filesBrowse the repository at this point in the historyBrowse files
feat(mcp): add delete_event and reports_action over a report setter (#1222)
Slice 3 of #1183. Two write tools on the MCP door, and the store seams
they need.
### `delete_event`
Soft delete through `delete_by_pubkey_and_ids` — the store's own
single-row delete — with four
outcomes (`deleted`, `already_deleted`, `not_deleteable` for kind 62,
`not_found`) and the event
row read back after the call. The outcome is decided by the row **as it
stands after** the call,
so two concurrent deletes answer `already_deleted` rather than
`not_deleteable`.
The description states what the store actually does: the event leaves
REQ and COUNT, keeps its
row, and `get_event` / `list_events` still return it with `deleted_at`
set — **unless an
actionable report hides it**, in which case it stays hidden until the
report is allowed.
### `reports_action`
Acts on a report's **own kind-1984 event id** through
`find_by_event_id`, setting
`Report.actionable` for `hide` and `allow` across every row that event
wrote, and answers
`changed` — the rows whose value actually moved — with every row of the
event sorted by `id` by
the handler, not by either backend's order. The LMDB arm removes the
three denormalised
`reports_actionable_*` index entries in the same write, which is what
keeps the NIP-56 filter
honest; `allow` cannot re-publish a target that another actionable
report still names.
### The seams
- `ReportRepository::set_actionable`, implemented by LMDB, Postgres,
InMemory, Unavailable and
Noop, reached through a new `ServiceStores.reports` field (one field at
ten construction
sites) rather than a third `AdminState` field.
- `EventRepository::find_stored(&EventId)` — one ungated exact-id read,
LMDB one `get`, Postgres
one `SELECT ... WHERE event_id = $1`. The NIP-56 gate is a read's, and
the delete path must see
the row a report hides: with the gated read, "hide the report, then
delete the event" answered
`not_found` and deleted nothing, which made the two tools incoherent
with each other. Its doc
says who may call it, and an acceptance leg counts `.find_stored(` call
sites — two, both the
handler's — so a third caller in the method-call form fails the
criterion. The leg is a
deterrent rather than a proof: a fully qualified
`EventRepository::find_stored` spells past it,
as the parity cases themselves do, and the record says so.
- Both tools sit at `Requires::Write` and audit through the existing
path: `mcp.delete_event` /
`mcp.reports_action` with `detail {"tool": ...}` and nothing else.
### Record
ADR 0017 with D1–D6, each with its cost; ADR 0014's scope column, D7's
bundle and D18's table
brought current; `CONFIGURATION.md`'s write-scope table now names all
three write tools and what
they reach; the eleven count sites; the two absent-name inversions moved
to `user_admin`;
changeset added.
### Verification
`cargo fmt --all --check`, both clippy passes, `cargo test --workspace
--all-features`
(**1 781 passed / 0 failed / 9 ignored**) and a release build, all exit
0. The oracle is
`crates/nostream-mcp/tests/write_tools.rs` (18 cases), five new
`parity_lmdb` cases plus two
`#[ignore]`d Postgres ones that CI runs, an audit case and a real-binary
case. Each load-bearing
assertion was made to fail once: the four delete outcomes, the
hidden-event delete, the post-call
read-back, the write gate on both tools, the ordering sort through a
reversed repository seam,
each of the three index removals, the cross-report rule and the
mixed-row count. The reds are in
the job record.
Known and stated rather than fixed here: the raced double-delete (two
deletes of one row in
flight) has no deterministic case — the branch is correct by the
post-read, and no test claims a
proof it cannot make; the Postgres setter arm runs only in CI, where a
database exists.
Out of scope, deliberately: the hidden-content mirror's 30 s refresh
(per-query reads are already
gated, so the only consequence is a bounded disclosure the description
names), and `reports_list`,
which no slice owns.
Implements #1183 (slice 3 of 5).
Copy file name to clipboardExpand all lines: CONFIGURATION.md
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,7 +75,8 @@ The following environment variables can be set:
75
75
## The admin MCP mode (`--mcp-stdio`)
76
76
77
77
`nostreamd --mcp-stdio` serves the admin MCP server (`settings_get`, `settings_set`,
78
-
`list_events`, `get_event`) on stdin/stdout and exits when stdin closes. It binds no socket,
78
+
`list_events`, `get_event`, `delete_event`, `reports_action`) on stdin/stdout and exits when stdin
79
+
closes. It binds no socket,
79
80
opens no store of its own, and writes its log lines to **stderr** so nothing but JSON-RPC crosses
80
81
stdout.
81
82
@@ -96,7 +97,7 @@ The document is JSON, and `scopes` is optional:
96
97
| Document | What it may call |
97
98
|---|---|
98
99
|`{}` or `{ "scopes": [] }`| The read tools: `settings_get`, `list_events`, `get_event`. |
99
-
|`{ "scopes": ["write"] }`| The read tools and `settings_set`. |
100
+
|`{ "scopes": ["write"] }`| The read tools, and the three that change something: `settings_set`, `delete_event` (soft-deletes **any author's** stored event by id — there is no per-author restriction, the holder of the token is the operator) and `reports_action` (sets the relay-wide NIP-56 filter for the target an actionable report names). |
100
101
101
102
`write` is the only accepted scope, and an unknown name — a typo, or a document from another tool
102
103
— refuses to start rather than being narrowed silently. A call the document's scopes deny is
0 commit comments