diff --git a/.changeset/mcp-maintenance.md b/.changeset/mcp-maintenance.md new file mode 100644 index 000000000..13fc9b875 --- /dev/null +++ b/.changeset/mcp-maintenance.md @@ -0,0 +1,20 @@ +--- +--- + +feat(mcp): the maintenance tools, the counts the pass drops, and the run record + +The admin MCP server gains `maintenance_run`, which runs the maintenance pass's retention purge +in the answering process through the same `MaintenanceService` the worker's `MaintenanceTasks` +arm delegates to, and `maintenance_last_run`, which reads the last run this process recorded. + +`MaintenanceService::clear_old_events` now answers `EventPurgeCounts` instead of `()`, the +`MaintenanceTasks` trait's future carries them, and `PassOutcome` gains +`counts: Option` — `None` on a failed or timed-out purge, never zeros. Every +implementor and test double moves with it; `crates/nostream-storage` is untouched. + +The run record lives in `AdminState`'s process memory (`MaintenanceRun`: `ranAt`, `deleted`, +`expired`, `retained`), so "never ran" is `null` and "ran, nothing to purge" is three zeros. ADR +0019 records the six decisions, including why the door runs the purge step rather than the whole +pass and why the record is not a sixth key in the published status document. + +Rust only: no version bump. diff --git a/CONFIGURATION.md b/CONFIGURATION.md index 2a756446f..4d555d713 100644 --- a/CONFIGURATION.md +++ b/CONFIGURATION.md @@ -76,7 +76,8 @@ The following environment variables can be set: `nostreamd --mcp-stdio` serves the admin MCP server (`settings_get`, `settings_set`, `list_events`, `get_event`, `relay_status`, `delete_event`, `reports_action`, `reports_list`, -`user_admin`, `user_get`, `invoices_list` and `invoices_get`) on stdin/stdout and exits when stdin +`user_admin`, `user_get`, `invoices_list`, `invoices_get`, `maintenance_run` and +`maintenance_last_run`) on stdin/stdout and exits when stdin closes. It binds no socket, opens no store of its own, and writes its log lines to **stderr** so nothing but JSON-RPC crosses stdout. @@ -97,8 +98,8 @@ The document is JSON, and `scopes` is optional: | Document | What it may call | |---|---| -| `{}` or `{ "scopes": [] }` | The read tools: `settings_get`, `list_events`, `get_event`, `relay_status`, `user_get`, `invoices_list`, `invoices_get` and `reports_list`. | -| `{ "scopes": ["write"] }` | The read tools, and the four 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), `reports_action` (sets the relay-wide NIP-56 filter for the target an actionable report names) and `user_admin` (admits, revokes, vanishes and unvanishes one pubkey). | +| `{}` or `{ "scopes": [] }` | The read tools: `settings_get`, `list_events`, `get_event`, `relay_status`, `user_get`, `invoices_list`, `invoices_get`, `reports_list` and `maintenance_last_run`. | +| `{ "scopes": ["write"] }` | The read tools, and the five 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), `reports_action` (sets the relay-wide NIP-56 filter for the target an actionable report names), `user_admin` (admits, revokes, vanishes and unvanishes one pubkey) and `maintenance_run` (runs the retention purge in the calling process and records it). | `write` is the only accepted scope, and an unknown name — a typo, or a document from another tool — refuses to start rather than being narrowed silently. A call the document's scopes deny is diff --git a/crates/nostream-admin/src/lib.rs b/crates/nostream-admin/src/lib.rs index ff9c73252..f4ad293b3 100644 --- a/crates/nostream-admin/src/lib.rs +++ b/crates/nostream-admin/src/lib.rs @@ -49,7 +49,7 @@ pub mod utils; pub use error::AdminError; pub use routes::{ADMIN_ROUTES, AdminRoute, PREFIX_MIDDLEWARE, mount}; -pub use state::{AdminState, AdminStateConfig, GrafanaSettings}; +pub use state::{AdminState, AdminStateConfig, GrafanaSettings, MaintenanceRun}; /// The CSP nonce the page's `