Relay Manager implementation plan

Current direction

Relay-advertised NIP-11 information (approved)

Display compact Relay info disclosures in Relays and Extra fetch sources only. Show name/description, linked software/version, advertised NIPs, supplied limits, retention/authentication/payment requirements, fetched time and per-relay Refresh. Keep advertised metadata separate from actual query outcomes and storage evidence.

Approved presentation follow-up: place Relay info on its own full-width row below the relay controls, with a short readable summary and nested Full NIP-11 JSON.

Presentation verification: targeted ESLint passed. An isolated renderer check confirmed a full-width seventh grid child below the six relay control cells, separate settings/source disclosures, concise name/version, nested pretty JSON without truncating an unknown field exceeding 8,000 characters, refresh actions and the shared WebNode schema. Authenticated visual review remains pending.

Verification: targeted ESLint and plugin TypeScript checks passed; registration generation completed. In-memory/mock-HTTP checks covered idempotent schema setup, normalized endpoints/Accept headers, cache/coalescing/force refresh, cached failures and last-success preservation, response caps, non-object JSON rejection, five-request batching and extra sources. Structured refresh command checks confirmed configured URL scoping and rejection without fetching unrelated URLs. Renderer checks passed the shared WebNode schema for settings/source disclosures, account/view-preserving refresh actions, safe software links, missing/stale labels and successful-fetch timestamps. No production database or live relays were modified during validation. Backend restart is user-initiated outside the active chat.

Relay-scoped history rechecks (approved)

Verification: targeted ESLint passed, changed-module TypeScript diagnostics were zero and registration generation completed. An in-memory/mock-transport check exercised the structured backup command, URL normalization, fresh relay-only bounds, other-source checkpoint isolation, invalid scope/source rejection, global history and unchanged saved-range Refetch/Resume settings. A separate in-memory UI/sync check covered full destination scope across 50-row outcome pages, single/multi-relay shortcuts, account/relay action arguments, busy/removed-source disabling, multi-relay count aggregation, clean/retry/stop guidance and the shared WebNode schema. No live relay or production data was used. Backend restart is user-initiated outside chat.

Widget-wide tree controls (approved)

Implementation belongs to the generic Web renderer; no Relay Manager-specific client branches or changes to the plugin's tree layout are required.

Verification: targeted ESLint passed and TypeScript reported no diagnostics in the four changed shared renderer modules. An in-memory state check covered hidden descendants, independent sibling/nested trees, saved refresh state, manual reopening, tree-local controls and isolation. Repo-wide lint was attempted and is blocked by unrelated unused variables in plugins/nr/db/evaluation-queue.ts (NostrEvent) and plugins/translate/service.ts (settings). Authenticated browser review remains pending. The renderer change is frontend-only and requires no backend restart.

Archive selection and JSONL export (approved)

Export-button fix verification: targeted ESLint passed. An isolated in-memory adapter invocation using the button's structured payload confirmed full and selected JSONL exports, unchanged CLI fallback, and required-pubkey validation. The plugin now consumes structured arguments/options rather than discarding them. Authenticated browser download review remains pending; backend restart is user-initiated outside chat.

Verification: targeted ESLint passed, changed-module TypeScript diagnostics were zero, and registration generation completed. An in-memory check covered scope/child overrides, unloaded pages, parent tri-state, account boundaries, overlap deduplication, full-history export, empty selection rejection, and original signed JSONL values including embedded newlines/Unicode. It checked the filename, menu/button wiring, view-state preservation and shared WebNode/download schemas. A mocked DOM/Blob check confirmed download click, content, anchor removal and object-URL cleanup; command errors are not downloaded as files. Authenticated browser download review remains pending. No production data was changed by export validation.

Publish-only Sync follow-up (approved)

Sync publishes original events and records acknowledgements; the user runs Recheck history afterward to update Coverage. This supersedes automatic per-event read-back and the 200-copy manual stopping point in the earlier milestones.

Verification: targeted ESLint passed, plugin TypeScript diagnostics were zero, and registration generation completed. An isolated 201-copy transport check proved automatic chunk continuation, no read-back requests, one attempt per pass, separate rejection/uncertain outcomes, explicit retries without resending accepted copies, Stop/Resume, and preservation of older Accepted/Verified records. It also checked that acknowledgements yield Awaiting recheck rather than stored presence, recent Fetch leaves older copies pending, and Recheck history updates Coverage. Updated compact progress/awaiting-recheck output passed the generic WebNode schema. Live relay/authenticated UI review remains pending; existing queued runs can Resume after the backend is restarted outside the active chat.

Approved clean reset

The user requested a complete Relay Manager reset, including account/relay settings, and removal of the old backup implementation. This supersedes the legacy-preservation and legacy-resume requirements below; historical completion records remain historical.

Completed: reset plugins/relays/db.sqlite in place in an immediate SQLite transaction after confirming no running operations. Removed the one configured account, 1,055 events, the partial old backup, relay checks and all metadata/evidence. All 12 current tables were verified empty; obsolete tables are absent. SQLite integrity/foreign-key checks passed and WAL was checkpointed successfully.

Verification: targeted ESLint passed, plugin TypeScript diagnostics were zero, and bun run plugin:generate completed. An isolated fresh-database check confirmed repeat initialization, current paging/NIP-77 evidence and positive supersession, shared work exclusion/cancellation, and legacy-free command metadata/UI schema. The backend needs a user-initiated restart outside the active chat before re-adding accounts.

The approved Fetch / Coverage / Sync design is the source of truth for the implementation. It supersedes the earlier 500-event split-window strategy, one-hour presence expiry, global Coverage table, and proposed mandatory per-ID existence-check stage. The active milestones describe current delivery; the historical sections preserve the earlier implementation record.

Runtime status

Implemented: account/relay settings, metadata/socket checks, NIP-65 publication, signature-verified archive, preferred NIP-77/fallback paging, incremental checkpoints, query/range history, non-expiring comparison, range Coverage, explicit eligible publish-only missing-copy Sync, subsequent history rechecking, outcome paging, and cancellation. Legacy code is removed under the approved clean reset above. Individual event browsing adds lazy month pages, read-only JSON inspection, hierarchical selection and full/selected JSONL export. Pending: live relay/authenticated browser review and the deferred scope below.

Implementation milestones

1. Evidence, query history, and migration

Exit: repeat-safe initialization creates only the current schema; an event can have independent observations in multiple ranges/runs; partial and newer unrelated scopes do not overwrite older evidence; projection can be rebuilt from recorded provenance.

Progress: evidence.ts provides normalized ranges, query/evidence records, comparison projection, and delivery snapshots. The clean reset removed old presence migration and the legacy runner. Targeted lint/TypeScript checks passed. Current in-memory checks confirmed repeat-safe fresh initialization, scoped historical absence, positive supersession, and non-expiring evidence. Query details distinguish attempt start from actual wire-send time, including unsent/cancelled attempts.

2. Ordinary paging and incremental fetching

Exit: repeated runs avoid unnecessary full backfills; interrupted snapshots resume without jumping forward; timestamp overlap does not duplicate archive bodies; rechecking can discover newly imported old events; short-page completion records its relay-limit assumptions rather than claiming universal completeness.

Verification: stub transport confirmed ordinary paging fallback, ten-second recent intervals, disconnect recovery, unchanged Resume limits, same-second stall without false completion, and a later completed history run superseding old partial work. NIP-11 max_limit guides the saved effective limit; no hostname-specific fallback.

3. NIP-77 reconciliation

Selected: existing nostr-tools 2.24.1 root nip77 export, with raw WebSocket handling to preserve NEG-ERR reasons and bound negotiation. No new dependency.

Exit: differences in both directions are correctly attributed; common bodies are not redownloaded unnecessarily; same-timestamp IDs reconcile; unsupported relays still fetch; partial/error scopes never generate unsupported missing conclusions.

Verification: stub relay responses exercised common, remote-only, and local-only IDs, unsupported fallback, same-timestamp reconciliation, policy-excluded bodies, and cancellation. Limits are 60 kB binary outgoing payloads (hex-encoded on wire), 128 kB incoming JSON frames, 100 rounds, 250,000 local/difference IDs, and a 15-second negotiation timeout. A bounded failed scope falls back independently; no partial fragment is considered a full inventory.

4. Range Coverage and automatic comparison

Exit: the same UI works for both transports; scope history remains inspectable; partial scopes are not displayed as complete empty ranges; multiple overlapping observations do not inflate the unique archive total.

Verification: populated generic WebNode output passed the shared schema; range menus, query attempts, Found/Fetched distinction, checked times, scope forms and distinct delivery outcomes were inspected. Authenticated visual review is pending.

5. Eligible missing-copy Sync and verification (initial iteration)

The automatic verification and manual 200-copy budget below record the initial implementation. They are superseded by the approved publish-only follow-up above.

Exit: extra/read-only sources receive no sync uploads; one event missing on two destinations counts as two deliveries; acknowledgement alone is not verification; rejection and inconclusive read-back are separate; archive-only historical versions are not accidentally replayed as current events.

Verification: in-memory signed-event checks covered deletion, expiry and no revival of superseded versions. Stub transport confirmed write-only uploads, per-destination copy counts, positive read-back superseding old absence, and separate Rejected, Unverified/accepted, and Verified outcomes. A 201-copy queue check confirmed the 200-copy invocation budget, pending-first Resume, fair retries, and no resend of Verified copies. Accepted/Unverified Resume retries read-back; new explicit Sync can resend still-missing copies. Outcomes page in groups of 50 without event bodies.

6. Integration review and documentation

Final local verification: targeted ESLint passed; the relay plugin had zero TypeScript diagnostics; bun run plugin:generate completed. In-memory and stub transport checks described above passed. A signed-body check also confirmed integer timestamp/kind validation and invalidation of cached signature validation when the stored body changes. No test files or test-suite commands were added/run. Real relay and authenticated browser review are the remaining integration check.

No new test files or test-suite runs are included unless requested by the user.

Event browsing follow-up (approved)

Verification: targeted ESLint passed and plugin TypeScript diagnostics were zero. An in-memory check confirmed lazy initial output, disjoint 50-row pages and page clamping, range membership, eligible missing-copy filtering, cross-account JSON lookup rejection, body-less IDs, preserved page state, exact row menus, non-clickable rows, original JSON modal content, and explicit kind/count labels. Web output passed the shared schema; bun run plugin:generate completed. Authenticated visual/clipboard review remains pending.

Selection and JSONL export are implemented in the follow-up above; import remains deferred.

Deferred scope

Historical implementation record

First timeline iteration

Verification: targeted ESLint passed; TypeScript reported zero diagnostics in the plugin; a one-off in-memory check validated empty/preview/populated WebNode schemas, npub account creation, normalized relay updates/removal, invalid URL rejection, account deletion, and preview non-persistence. No browser or live relay checks were run.

Subsequent iterations

Account selection convenience

Verification: targeted ESLint passed; changed-file TypeScript checks reported zero diagnostics; a one-off schema check confirmed the dynamic public-key picker and independent manual npub form in list. Authenticated browser review remains pending.

Compact layout iteration

Verification: targeted ESLint and changed-file TypeScript checks passed; registration generation completed. A one-off in-memory schema/layout check verified empty/populated list output, six element cells per header/body row, inline account submit controls, and removal of the preview command option and render paths. Visual review in authenticated AppWeaver remains pending.

Account actions and automatic refresh

Verification: targeted ESLint passed; plugin TypeScript diagnostics were zero. A one-off in-memory check with stubbed network responses validated concurrent refresh coalescing, five-minute cache reuse, URL-change invalidation, profile and connection observations, preservation of local settings, polling stop on completion, DM list without networking, and visible control placement. Live relay and browser review remain pending.

Account label and alignment cleanup

Verification: targeted ESLint passed; static inspection confirmed the identity label removal and centered flex alignment for account add/selector forms.

Agreed fetch / coverage / sync structure

Verification: targeted ESLint passed and plugin TypeScript diagnostics were zero. A one-off in-memory SQLite check validated additive/repeated migration, existing account/archive retention, write-only scopes, per-relay duplicated-copy counting, stale/future/unknown classification, monotonic observation writes, independent source/relay edits, and the ordered WebNode section/tree schema. No live relay or authenticated browser checks were run.

The initial UI and presence-query foundations were arranged here. The archive and NIP-65 publication actions were implemented in the following section. Their next fetching/coverage changes are tracked in the active milestones above.

Enable publication and backup actions

Verification: targeted ESLint passed, changed-module TypeScript diagnostics were zero, and command registration generation completed. A one-off in-memory check using actual signed events and stubbed relay transport verified invalid-signature/ wrong-author/private-kind filtering, archive deduplication, observed presence, partial backup resume, concurrent-run rejection, interrupted-run recovery, selected-account signer restrictions, signed-list/config validation, per-relay publication outcomes, stale snapshot protection, and enabled widget actions. Live relay and authenticated browser review remain pending.

Initial event-engine backlog (superseded by active milestones)

The historical sections above describe the earlier iterations. Current Fetch, Coverage and Sync status is recorded in the active milestones; individual event selection/export are recorded in their follow-ups; JSONL import remains deferred. No dock widget registration. Runtime restart must be done by the user outside the active chat.