Skip to content

fix(nip56): start the hidden-content cache on every worker - #1241

Merged
cameri merged 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/hidden-content-cache-start-always
Nov 29, 2026
Merged

cameri merged 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/hidden-content-cache-start-always

Conversation

@Priyanshubhartistm

@Priyanshubhartistm Priyanshubhartistm commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Description

workerFactory started the NIP-56 hidden-content cache only when nip56.enabled was true at boot:

if (settings.nip56?.enabled) {
  startHiddenContentCache(reportRepository, createSettings)...
}

The cache already reads the settings on every tick and queries the database only while hideActionableReports is on, so it was built to pick up a later change. The boot condition defeated that: a worker that booted with reporting off never started the timer.

  • the cache now starts on every worker, whatever nip56.enabled says at boot;
  • nothing changes in hidden-content-cache.ts: each tick still checks hideActionableReports first, so a relay that does not use reporting reads the settings object every 30 seconds and never queries the database;
  • the comment in worker-factory.ts says why the start is unconditional.

Related Issue

Partly addresses #1022 (F-032). The other findings in that issue are handled separately.

Motivation and Context

WebSocketAdapter.onSendEvent hides an event from live subscribers when nip56.enabled and hideActionableReports are on and isHidden(event) is true. isHidden reads the worker's in-memory cache. On a worker that booted without reporting, an operator who turns reporting and hiding on later (settings reload or backup restore) activates the check, but the cache stays empty. A reported pubkey or event is still sent to open subscriptions until the next restart. REQ and COUNT are not affected, because they exclude reported targets in SQL.

How Has This Been Tested?

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.

Summary by CodeRabbit

  • Bug Fixes
    • Changes to the hide-actionable-reports setting now take effect after the app has started, without requiring a restart.
    • Hidden-content handling now stays in sync with the current setting across workers. When the setting is off, hidden-content checks remain inactive; when it’s on, they run periodically.

Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
@changeset-bot

changeset-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 3ac2880

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

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

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

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The worker now starts the hidden-content cache regardless of NIP-56 settings at boot. The cache checks settings on each tick and queries the database only when hideActionableReports is enabled.

Changes: Hidden-content cache polling

Layer / File(s) Summary
Settings-gated cache polling
src/factories/worker-factory.ts, test/unit/factories/worker-factory.spec.ts, .changeset/hidden-content-cache-start-always.md
workerFactory starts the cache unconditionally and passes createSettings for fresh settings checks. The test verifies there is no database read at boot when NIP-56 is unset, then verifies a read after hideActionableReports is enabled. The changeset records the behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

Possibly related PRs

  • cameri/nostream#1157: This PR changes how cached settings reload after settings files change. That reload path affects which values the cache reads on each tick.
Merge Risk: Minimal · up to 3ac28

The hidden-content cache now starts on every worker, so enabling reporting and hiding later takes effect without a restart. Relays that do not use reporting only read settings on each tick and do not query the database. Merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the NIP-56 hidden-content cache now starts on every worker. The raw summary and objectives both describe this change to workerFactory and its tests, so the title match…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: the NIP-56 hidden-content cache now starts on every worker. The raw summary and objectives both describe this change to workerFactory and its tests, so the title matches the changeset. It uses the conventional fix(nip56) prefix and is specific.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks the settings each round,
The cache wakes up when workers are found.
No report flag at boot? That’s fine,
It checks again along the line.
When enabled, database reads begin,
Then carrots await with a satisfied grin.

Recent review info

Automatic approval policy

Commit: 3ac28808e46f.

Setting Effective value Source
Automatic approvals Enabled Global configuration
Merge risk Minimal Global configuration
Security risk Not set Global configuration

Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c6a15fee-7748-4742-af45-798435a9b89b
Commits

Reviewing files that changed from the base of the PR and between 549a97d and 3ac2880.

Files selected for processing: 3

  • .changeset/hidden-content-cache-start-always.md
  • src/factories/worker-factory.ts
  • test/unit/factories/worker-factory.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Starts the hidden-content cache on every client-facing worker, even when reporting is off at boot.

  • Every worker starts the hidden-content cache for live hiding.

No actionable issues found. Tests were inspected but not run.

Reviews (1) · Last reviewed commit: "fix(nip56): start the hidden-content cac..." · Reviewed by Greptile

@coveralls

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 45671844487

Coverage decreased (-0.002%) to 80.248%

Details

  • Coverage decreased (-0.002%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (1 of 2 lines covered, 50.0%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/factories/worker-factory.ts 2 1 50.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15101
Covered Lines: 12625
Line Coverage: 83.6%
Relevant Branches: 8395
Covered Branches: 6230
Branch Coverage: 74.21%
Branches in Coverage %: Yes
Coverage Strength: 639.03 hits per line

💛 - Coveralls

@cameri
cameri merged commit ccf6690 into cameri:main Nov 29, 2026
20 of 22 checks passed
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.

3 participants