Repository navigation
feat(mcp): add delete_event and reports_action over a report setter - #1222
Conversation
…r (incomplete) The storage half of slice 3: `ReportRepository::set_actionable` in the trait and its four other implementors (LMDB removes the three `reports_actionable_*` keys and rewrites through `report_write`; Postgres is one `UPDATE`), `ServiceStores.reports` at all ten construction sites, and the MCP harness opening its store with the settings it serves. The surface half: both tools with their constants, `TOOLS` rows at `Requires::Write`, `parses` functions, handlers, the `MCP_INSTRUCTIONS` sentence, and the descriptions, argument docs and payload literals the spec words verbatim. `ReportAction` implements `schemars::JsonSchema` by hand so the published schema states the closed set as `enum` rather than a `oneOf` of `const` variants. Incomplete: the new `write_tools` target, the parity cases, the daemon's stdio case, the remaining count sites, ADR 0017 / ADR 0014 D18 and the changeset are not in this commit. See the job's build.md.
The oracle: `tests/write_tools.rs` with the fourteen cases (four delete outcomes, the read-back, the count leaving V13, both refusals, and `hide`/`allow` moving the LMDB indexes behind the NIP-56 gate), four `set_actionable_*` cases in `parity_lmdb`, the `#[ignore]`d Postgres arm, and the daemon's `the_write_tools_report_the_unwired_store`. The sites that pin the tool count read seven, the two absent-name inversions move to `user_admin`, `--help` names all three writing tools, and both tool names now occur on exactly five lines of `server.rs` (the instructions sentence among them). The record: ADR 0017 with D1–D6, ADR 0014's audit table and its two sentences, and one empty changeset.
…rules Rework 1's findings, from `round-1/review-code.md`. The ordering case read a real LMDB store, whose `(event_id, report_id)` walk is ascending by construction, so removing the handler's sort left it green. The harness gains a report repository seam, and the case reads through a store that answers newest id first: with the sort removed the payload's ids descend and the case fails. The read-only case called with an id no report row carried, so its "moved nothing" assertion had no subject; it now names the seeded report event and asserts the row is still actionable. Flipping the fixture's grant to `write` reddens it. Two cases the gate measured green with throwaway copies now pin the behaviour: an `allow` leaves a target hidden while another actionable report still names it, and a report with one already-false row and one true row answers `changed: 1` with both rows listed.
`a_read_only_document_is_refused_both_writes` sent `hide` at a row already `actionable: true`, which the store skips, so a leaked report gate answered `changed: 0` and left the row true: the "moved nothing" assertion had no write to be the subject of. It now sends `allow`, and the state assertions come before the refusals, so the store's own read is what fails when either gate leaks — the delete's at the deleted row, the report's at the row's flag. The case's header says three fixtures carry the NIP-56 gate, which is the count now.
🦋 Changeset detectedLatest commit: 0a01867 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; both earlier delete issues are addressed.
|
…two new ones reach
…and the bundle reads five
An event an actionable report hides resolved through `get_event`'s gated read to `not_found`, so `reports_action hide` followed by `delete_event` deleted nothing: the pair this slice ships contradicted itself. `EventRepository` gains `find_stored(&EventId)` — LMDB one `get` on the events table, Postgres one `SELECT … WHERE event_id = $1` — whose doc says it bypasses the NIP-56 gate and that only the delete path may call it. All nine implementors carry it; the delegating double calls it fully qualified so the ungated read keeps exactly one call site in the workspace. `deleted()` now runs the 64-character criterion, reads through `find_stored`, and takes its outcome from the row as it stands after the call, so a row a concurrent delete already marked answers `already_deleted` rather than `not_deleteable`. R5's description gains the hidden-event exception, and a case pins a hidden event's delete plus the read tools still hiding it afterwards.
R5's sentence and `DeleteEventArgs.id`'s field doc now say a prefix shorter than 64 characters is refused rather than widened to whatever the store's range would match, which is the answer the handler already gives. The snapshot follows both: the tool's description and its id field's schema description are regenerated from the attributes.
…ive sentences The outcome's second condition was reached only at a zero count, where the pre-read and the read-back agree, so the amendment's subject was unobservable. `ZeroCountDeleter` is the store that disagrees with itself — the real soft delete, a count of zero — and the case reads it as `already_deleted`; the pre-read subject answers `not_deleteable` there. The rest is text: four gate fixtures in the module header, the case table catching up with the 17th and 18th cases and with the prefix refusal, the relay double's `UPDATE` sentence back on `delete_by_pubkey_and_ids`, and the two kind-62 citations moved to where the skips now are.
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
Slice 3 of #1183. Two write tools on the MCP door, and the store seams they need.
delete_eventSoft delete through
delete_by_pubkey_and_ids— the store's own single-row delete — with fouroutcomes (
deleted,already_deleted,not_deleteablefor kind 62,not_found) and the eventrow read back after the call. The outcome is decided by the row as it stands after the call,
so two concurrent deletes answer
already_deletedrather thannot_deleteable.The description states what the store actually does: the event leaves REQ and COUNT, keeps its
row, and
get_event/list_eventsstill return it withdeleted_atset — unless anactionable report hides it, in which case it stays hidden until the report is allowed.
reports_actionActs on a report's own kind-1984 event id through
find_by_event_id, settingReport.actionableforhideandallowacross every row that event wrote, and answerschanged— the rows whose value actually moved — with every row of the event sorted byidbythe 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 filterhonest;
allowcannot re-publish a target that another actionable report still names.The seams
ReportRepository::set_actionable, implemented by LMDB, Postgres, InMemory, Unavailable andNoop, reached through a new
ServiceStores.reportsfield (one field at ten constructionsites) rather than a third
AdminStatefield.EventRepository::find_stored(&EventId)— one ungated exact-id read, LMDB oneget, Postgresone
SELECT ... WHERE event_id = $1. The NIP-56 gate is a read's, and the delete path must seethe row a report hides: with the gated read, "hide the report, then delete the event" answered
not_foundand deleted nothing, which made the two tools incoherent with each other. Its docsays who may call it, and an acceptance leg counts
.find_stored(call sites — two, both thehandler'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_storedspells past it,as the parity cases themselves do, and the record says so.
Requires::Writeand audit through the existing path:mcp.delete_event/mcp.reports_actionwithdetail {"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 whatthey 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 newparity_lmdbcases plus two#[ignore]d Postgres ones that CI runs, an audit case and a real-binary case. Each load-bearingassertion 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).