Skip to content

doc: adr broadcast offline - #662

Open
1-leo wants to merge 1 commit into
masterfrom
adr/broadcast-offline
Open

doc: adr broadcast offline#662
1-leo wants to merge 1 commit into
masterfrom
adr/broadcast-offline

Conversation

@1-leo

@1-leo 1-leo commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

ADR for offline broadcast refactor

Summary by CodeRabbit

  • Documentation
    • New Architecture Decision Record documenting the Offline Broadcast approach for NDK, including system design patterns, broadcast and eviction policies, operational requirements, error handling, and performance considerations.

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new Architecture Decision Record at doc/library-development/ADRs/broadcast-offline.md describing an "Offline Broadcast" design for NDK. The document defines a refactor into four concerns, two policy types (BroadcastPolicy, EvictionPolicy), acceptance/eviction/retry/reject-handling requirements, remote signer consequences, impact radius, and a monolithic alternative.

Changes

Offline Broadcast ADR

Layer / File(s) Summary
Offline Broadcast ADR document
doc/library-development/ADRs/broadcast-offline.md
New 134-line ADR defining the offline broadcast architecture: four refactored components, BroadcastPolicy/EvictionPolicy policy contracts, acceptance/eviction/retry/reject-handling requirements, remote signer consequences mitigated by caching unsigned events, impact radius, and a monolithic alternative.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐇 A document hops into the doc tree,
Describing how broadcasts should offline be.
Four components split, policies neat,
Unsigned events cached — no signer to meet.
The ADR lands with a thump and a cheer! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'doc: adr broadcast offline' directly describes the main change - adding an Architecture Decision Record for offline broadcast functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch adr/broadcast-offline

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
doc/library-development/ADRs/broadcast-offline.md (1)

41-55: ⚡ Quick win

Normalize the outline and fenced example.

Use h3s under the h2 sections here, and give the fenced example a language like text or convert it to a list. That will make the ADR easier to scan and keep markdownlint happy; the same heading jump repeats again in Impact Radius.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@doc/library-development/ADRs/broadcast-offline.md` around lines 41 - 55, The
ADR document has inconsistent heading hierarchy and a fenced code block without
a language identifier. Under the h2 section "Refactor the Broadcast use case
into several concerns," add h3 headings to organize the bullet points (such as
"Cache with state information," "Cache of deleted events," "Broadcast monitor,"
and "Broadcast function"). For the example showing the cache structure with
PriorityBroadcast and event details, either add a language identifier like
`text` to the fenced code block or convert it to a properly formatted markdown
list. Apply the same heading hierarchy improvements to the "Impact Radius"
section mentioned in the comment to ensure consistent structure throughout the
document and satisfy markdownlint requirements.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@doc/library-development/ADRs/broadcast-offline.md`:
- Around line 5-17: The ADR metadata in the status section contains conflicting
information: the status field shows "In progress" while the "Final decision made
by" field indicates the decision has been finalized, and the "Updated on" date
appears outdated. To resolve this inconsistency, either change the status from
"In progress" to "Accepted" and update the date to the current date (15-06-2025
or later as appropriate), or remove the "Final decision made by" field entirely
and keep the status as "In progress" to maintain the document as a draft. Choose
the approach based on whether this ADR's decision has actually been finalized or
is still under discussion.
- Around line 27-35: The Requirements section in the broadcast-offline ADR uses
incomplete placeholder language (like `todo`, `%`, `different modes`) instead of
concrete, implementable policy rules. Replace these vague entries with specific,
actionable requirements based on the actual behavior in relay_manager.dart
(particularly the reject handling logic in lines L469-L640). Specifically, add
`auth-required` to the list of retryable reject classes (since the relay_manager
already treats it as retryable rather than terminal), define explicit thresholds
and eviction policy rules instead of vague guidance, and enumerate the concrete
reject classes (such as retry, dismiss, paymentRequired, POW, blocked,
auth-required) with their respective handling behaviors to match the current
broadcast flow implementation.

---

Nitpick comments:
In `@doc/library-development/ADRs/broadcast-offline.md`:
- Around line 41-55: The ADR document has inconsistent heading hierarchy and a
fenced code block without a language identifier. Under the h2 section "Refactor
the Broadcast use case into several concerns," add h3 headings to organize the
bullet points (such as "Cache with state information," "Cache of deleted
events," "Broadcast monitor," and "Broadcast function"). For the example showing
the cache structure with PriorityBroadcast and event details, either add a
language identifier like `text` to the fenced code block or convert it to a
properly formatted markdown list. Apply the same heading hierarchy improvements
to the "Impact Radius" section mentioned in the comment to ensure consistent
structure throughout the document and satisfy markdownlint requirements.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4d117ce5-70e6-4719-8197-ac336a928566

📥 Commits

Reviewing files that changed from the base of the PR and between b0cc63c and 5660ff1.

📒 Files selected for processing (1)
  • doc/library-development/ADRs/broadcast-offline.md

Comment on lines +5 to +17
## status

In progress

Updated on 15-06-2025

## contributors

- Main contributor(s): fmar

- Reviewer(s): fmar, leo, nogringo

- Final decision made by: fmar, leo, nogringo

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the ADR metadata consistent.

In progress conflicts with Final decision made by, and the Updated on 15-06-2025 stamp looks stale for this PR. Please either keep this as a draft and remove the final-decision field, or mark it accepted with the correct date.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@doc/library-development/ADRs/broadcast-offline.md` around lines 5 - 17, The
ADR metadata in the status section contains conflicting information: the status
field shows "In progress" while the "Final decision made by" field indicates the
decision has been finalized, and the "Updated on" date appears outdated. To
resolve this inconsistency, either change the status from "In progress" to
"Accepted" and update the date to the current date (15-06-2025 or later as
appropriate), or remove the "Final decision made by" field entirely and keep the
status as "In progress" to maintain the document as a draft. Choose the approach
based on whether this ADR's decision has actually been finalized or is still
under discussion.

Comment on lines +27 to +35
#### Requirements:
- relay specific
- gossip
- Consider done %
- different modes,
specific: relay broadcast must succeed
- eviction policy (keep in cache, delete old ones)
- Streamlined reject handling (retry, dismiss, paymentRequired, POW, blocked, etc.)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Tighten the acceptance criteria and preserve auth-required retry behavior.

This section still reads like notes (todo, %, different modes) instead of implementable policy rules, and it omits auth-required, which packages/ndk/lib/domain_layer/usecases/relay_manager.dart#L469-L640 already treats as retryable rather than terminal. Please spell out the concrete thresholds and reject classes so the refactor matches the current broadcast flow.

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 27-27: Heading levels should only increment by one level at a time
Expected: h3; Actual: h4

(MD001, heading-increment)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@doc/library-development/ADRs/broadcast-offline.md` around lines 27 - 35, The
Requirements section in the broadcast-offline ADR uses incomplete placeholder
language (like `todo`, `%`, `different modes`) instead of concrete,
implementable policy rules. Replace these vague entries with specific,
actionable requirements based on the actual behavior in relay_manager.dart
(particularly the reject handling logic in lines L469-L640). Specifically, add
`auth-required` to the list of retryable reject classes (since the relay_manager
already treats it as retryable rather than terminal), define explicit thresholds
and eviction policy rules instead of vague guidance, and enumerate the concrete
reject classes (such as retry, dismiss, paymentRequired, POW, blocked,
auth-required) with their respective handling behaviors to match the current
broadcast flow implementation.

@frnandu

frnandu commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

This will pretty quickly be out of date, and I don't want to still need to update such docs along the way, so I would propose to not keep such doc that will be anyhow out-of-date once everything is in place, unless you want to come back to this and update it to the final implementation details @1-leo

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