feat: finalize transport v2 migration (Phase C)#637
Conversation
- Remove global Config.mostroVersion; message version now derived from the transport (toJson defaults to 1, wrapNip44 passes 2) - Extract testable buildOrdersFilter() from the subscription manager with unit tests (v1 kind 1059 / v2 kind 14 authors-pinned) - About screen shows the node's protocol_version with an explanatory dialog (l10n en/es/it/de/fr) - Docs: mark the v1 -> v2 migration complete (status, §4.2, §4.3, Phase C/D) - Tidy: import order in subscription_manager; drop duplicate publishEvent stub in mostro_service_test
|
Warning Review limit reached
Next review available in: 21 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughRemoves the global ChangesVersion derivation and transport-aware filtering
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
lib/data/models/mostro_message.dart (1)
30-34: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winDon't describe the default JSON as transport-derived for logging/storage.
wrapNip44()correctly overrides this to2, butlib/services/mostro_service.dartstill logsorder.toJson()with no version override. That means a v2 send goes out on the wire asversion: 2while the logged payload still showsversion: 1. Either thread the resolved version into those non-wire call sites or narrow this comment so it only describes the actual send paths.✏️ Possible wording tweak
- // The message version is derived from the wire transport: 1 for gift wrap - // (the default here, used by storage/logging and the v1 send path) and 2 - // for NIP-44 direct (passed explicitly by `wrapNip44`). See §4.2 of - // docs/architecture/TRANSPORT_V2_MIGRATION.md. + // Bare JSON serialization defaults to protocol v1. + // Transport-specific send paths override this where needed: + // `wrap()` keeps v1, while `wrapNip44()` passes `version: 2`. + // See §4.2 of docs/architecture/TRANSPORT_V2_MIGRATION.md.🤖 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 `@lib/data/models/mostro_message.dart` around lines 30 - 34, The default version value in MostroMessage is being described too broadly as transport-derived, but non-wire call sites like MostroService still use order.toJson() without overriding it and will log storage payloads with version 1. Narrow the comment in MostroMessage.toJson() so it only describes the actual send paths, or thread the resolved version through the logging/storage serialization path in MostroMessage and MostroService so the logged payload matches the wire version.
🤖 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 `@docs/architecture/TRANSPORT_V2_MIGRATION.md`:
- Around line 21-26: The phase introduction still describes the migration as
future work, which conflicts with the updated completed-state wording. Update
the introductory text in TRANSPORT_V2_MIGRATION.md near the phases section so it
no longer says the phases are for “subsequent branches” or that the document
“does not execute them,” and make it consistent with the completed status
already stated; use the surrounding phase overview text and headings as the
anchor for the edit.
In `@lib/features/settings/about_screen.dart`:
- Around line 338-343: The protocol version row in about_screen’s info card is
rendering nullable data directly via AboutScreen/_buildInfoRowWithDialog, so
legacy nodes can show the literal string "null". Update the value passed for
instance.protocolVersion to use a null fallback consistent with the other
optional fields in this card, such as S.of(context)!.notAvailableShort, so
nullable protocolVersion is displayed as a friendly unavailable label instead of
null.
---
Nitpick comments:
In `@lib/data/models/mostro_message.dart`:
- Around line 30-34: The default version value in MostroMessage is being
described too broadly as transport-derived, but non-wire call sites like
MostroService still use order.toJson() without overriding it and will log
storage payloads with version 1. Narrow the comment in MostroMessage.toJson() so
it only describes the actual send paths, or thread the resolved version through
the logging/storage serialization path in MostroMessage and MostroService so the
logged payload matches the wire version.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e755971a-d417-4a7e-a9a3-66cc73ecf3eb
📒 Files selected for processing (12)
docs/architecture/TRANSPORT_V2_MIGRATION.mdlib/core/config.dartlib/data/models/mostro_message.dartlib/features/settings/about_screen.dartlib/features/subscriptions/subscription_manager.dartlib/l10n/intl_de.arblib/l10n/intl_en.arblib/l10n/intl_es.arblib/l10n/intl_fr.arblib/l10n/intl_it.arbtest/features/subscriptions/orders_filter_test.darttest/services/mostro_service_test.dart
💤 Files with no reviewable changes (1)
- lib/core/config.dart
There was a problem hiding this comment.
Code Review Summary
Verdict: Approve
I rechecked the current head of PR #637 and the transport-v2 wiring looks internally consistent.
What I verified
MostroMessage.wrapForTransport()is now the single entry point for outbound transport selection.wrapNip44()stampsversion: 2, while the legacy path still defaults toversion: 1.SubscriptionManager.buildOrdersFilter()correctly splits receive-side filters:- v1 → kind
1059withp = tradeKeys - v2 → kind
14withauthors = [mostroPubkey]andp = tradeKeys
- v1 → kind
- The node's
protocol_versionis surfaced throughMostroInstance.protocolVersionand is used consistently on both send and receive paths. - The About screen change is safe because it reads
MostroInstance.protocolVersionfrom the model, not the nullable Nostr extension getter. - The docs now match the implementation and the migration is clearly marked complete.
Test coverage
- The new
buildOrdersFilter()tests cover both transport branches. - The existing service tests still exercise message signing / verification behavior on the send path.
Notes
- I did not find a blocking correctness issue in the current head.
- The only thing I'd keep watching is that the transport switch relies on the node info event arriving and the subscription manager re-subscribing when it does; the current implementation already accounts for that, so this is a watchpoint rather than a blocker.
Overall: clean implementation, sensible decomposition, and the migration is wired coherently end-to-end.
There was a problem hiding this comment.
I reviewed the current head and I do not see a blocking issue.
What I checked:
- Removing the global
Config.mostroVersionis the right cleanup. The message version is now derived from the wire transport at the serialization/wrap boundary, which avoids drift between v1 gift-wrap and v2 NIP-44 paths. MostroMessage.toJson()defaulting toversion: 1is consistent with the remaining v1/storage/logging callers, whilewrapNip44explicitly forcesversion: 2for protocol-v2 traffic.- Extracting
buildOrdersFilter()is a good move and the v2 filter keeps the importantauthors: [mostroPubkey]pin, so kind-14 Mostro replies stay disambiguated from peer chat. - The About screen surfacing
protocol_versionis aligned with the migration model and helps explain transport selection without changing behavior. - The docs update matches the code state for this branch.
I could not run Flutter tests in this sandbox because flutter is not installed here, but the PR check run on the current head is green and I do not see a correctness blocker in the changes themselves.
Approved on the current revision.
There was a problem hiding this comment.
Strict review: full diff inspected against the surrounding code, all call sites of toJson/serialize/sign/wrap* grepped across lib/ and test/, PR-relevant test suites executed locally (all green), plus multi-pass analysis (correctness, silent failures, test coverage, docs/comment accuracy, Flutter idioms).
Correctness — no findings
Config.mostroVersionremoval is clean: zero dangling references; every outbound send (mostro_service.dart,restore_manager.dart×3,dispute_repository.dart) routes throughwrapForTransport, so there is no v1/v2 version-drift risk.sign/serialize(v1) andwrapNip44(v2) build tuple element 0, the trade signature and the identity-proof payload from the same serialized JSON — they cannot drift apart.- The
versionfield written to Sembast (mostro_storage.dart) is write-only metadata (fromJson/deserializednever read it), so the?? 1default is behavior-preserving for storage/logging. buildOrdersFilterextraction is a pure refactor; calling a@visibleForTestingtop-level function from the same library is valid and lint-clean._appliedOrdersTransporttracking preserved.instance.protocolVersionin the About screen is the non-nullableMostroInstance.protocolVersion(defaults to 1), so no "null" can render.- ARB: both new keys present and consistent in all 5 locales (en/es/it/de/fr), flat structure, metadata convention matches sibling
mostroDaemonVersion. Docs (§4.2, §4.3, Phase C/D, "Migration complete") verified accurate against the code and the five referenced test files.
Summary by CodeRabbit
New Features
Bug Fixes
Tests