Skip to content

feat(admin): add bounded NIP-66 probe history and timeline - #814

Open
Ferryx349 wants to merge 2 commits into
mainfrom
feat/admin-network-health-history
Open

Ferryx349 wants to merge 2 commits into
mainfrom
feat/admin-network-health-history

Conversation

@Ferryx349

Copy link
Copy Markdown
Collaborator

Description

  • Persist bounded NIP-66 probe run history and expose GET /admin/network-health/history?limit=
  • Add nip66.historyRetentionRuns (default 168) and optional historyRetentionHours
  • Admin dashboard timeline for recent probe runs

Related Issue

Closes - #800

Motivation and Context

How Has This Been Tested?

  • pnpm run test:unit
  • Enable NIP-66, wait for probe runs, confirm history API and dashboard timeline

Screenshots (if appropriate):

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

@changeset-bot

changeset-bot Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 70e63c8

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

This PR includes changesets to release 1 package
Name Type
nostream Minor

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

@greptile-apps

greptile-apps Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 3/5

[Medium impact] Adds probe history storage and admin API endpoint.

Fix the stale default dashboard view and overlapping history deletion before merging.

Findings

  1. P1 Latest probes stop appearing ▶
  2. P1 Cleanup deletes retained runs ▶

Summary

Adds bounded NIP-66 probe history, an authenticated history API, and a dashboard timeline.

  • Admins can request bounded history for NIP-66 probe runs.
  • The Network Health panel lets admins select earlier probe runs.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Worker[Probe worker] --> Latest[Latest snapshot]
  Worker --> History[Redis probe history]
  Worker --> Public[Public NIP-66 events]
  History --> Cleanup[Count and age cleanup]
  API[Authenticated history request] --> Cleanup
  Cleanup --> Timeline[Dashboard timeline]
  Latest --> Panel[Dashboard probe panel]
  Timeline --> Panel
Loading

Reviews (2) · Last reviewed commit: "fix(admin): address Greptile review on p..." · Reviewed by Greptile

Comment thread resources/default-settings.yaml
Comment thread src/utils/relay-probe-history.ts Outdated
Comment thread src/app/relay-monitor-worker.ts
Comment thread resources/admin/assets/dashboard.js Outdated
Comment thread src/utils/relay-probe-history.ts Outdated
@coveralls

coveralls commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Status

Coverage is 73.314% — feat/admin-network-health-history into main. No base build found for main.

Register nip66.historyRetentionHours in defaults, trim history on read,
use rank-based Redis cleanup, isolate history failures from NIP-66 publish,
and preserve timeline selection during dashboard polling.
Comment on lines +674 to +680
if (selectedNetworkHealthRunAt && networkHealthHistoryRuns.length > 0) {
const selected = networkHealthHistoryRuns.find((run) => run?.runAt === selectedNetworkHealthRunAt)
if (selected) {
displaySnapshot = selected
}
} else if (snapshot?.runAt) {
selectedNetworkHealthRunAt = snapshot.runAt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Latest probes stop appearing

refreshNetworkHealth now treats the first automatically selected snapshot as a user-selected historical run. After the next probe finishes, polling still displays that first run while it remains in networkHealthHistoryRuns, even if the operator never clicked the timeline. An old healthy result can hide a newer failure.

Keep following the latest snapshot by default, and preserve a historical run only after an explicit click.

Knowledge Base Used: Admin dashboard and controls

Comment on lines +44 to +47
const size = await this.cache.getSortedSetSize(RELAY_PROBE_HISTORY_KEY)

if (size > maxRuns) {
await this.cache.removeRangeByRankFromSortedSet(RELAY_PROBE_HISTORY_KEY, 0, size - maxRuns - 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Cleanup deletes retained runs

trim reads the history size and deletes by rank in separate Redis calls. Since history requests now also call trim, two requests can read the same size and both remove the same number of oldest runs. The second deletion removes runs the first call kept. For example, after lowering maxRuns from 168 to 1, two overlapping reads can delete all history.

Make the count-and-delete step atomic, or use a rank range that keeps the newest maxRuns entries without first reading the size.

This branch has not been deployed

No deployments
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.

2 participants