Skip to content

refactor(platform-wallet): share the sync loop lifecycle across coordinators - #6163

Merged
llbartekll merged 12 commits into
v5.2-devfrom
refactor/platform-wallet-sync-loop
Nov 26, 2026
Merged

llbartekll merged 12 commits into
v5.2-devfrom
refactor/platform-wallet-sync-loop

Conversation

@llbartekll

@llbartekll llbartekll commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #6162, which pinned the current behaviour with tests; those tests pass here with their assertions unchanged.

Issue being fixed or feature implemented

The five periodic sync coordinators in packages/rs-platform-wallet/src/manager/ (identity, DashPay, DPNS, platform-address, shielded) each carried their own copy of the same lifecycle: the loop thread, the is_syncing slot, the admission preamble and the quiesce* family. The copies were identical statement for statement apart from the worker key, the stack size, a log label and the pass call, and the drift had already cost a fix that had to touch all five files (#5663).

What was done?

One commit per coordinator, each behaviour-preserving.

  • New manager/sync_loop.rs with SyncLoop, embedded by composition in each coordinator:
    • SyncLoop::admit is the admission preamble: reopen a drained latch, claim the slot, check the gate. It returns Admitted(PassPermit), Busy or Closed.
    • start_sync_loop is the loop, in the same order as before: cancel check, pass, sample the latch, sleep the interval or the latched retry interval.
    • drain / drain_sealed wrap the existing drain_pass.
  • QuiesceGate, drain_pass and SyncSlotGuard are unchanged and stay in manager/mod.rs.
  • What stays in each coordinator: the pass body, its result type, its completion event (or the lack of one), and every public and pub(crate) method, now delegating.
  • Kept exactly, per coordinator:
    • DashPay and DPNS: the 8 MB loop stack.
    • Platform-address: sync_wallet maps Busy and Closed to the two refusal messages it had.
    • Shielded: the pass token is taken before admission; stop() cancels and rotates the token before it cancels the loop; sync_wallet reads the coordinator before admission; the loop passes force = false.
    • All: the completion event is sent before the slot is released (the permit is declared where the slot guard was).
  • No futures are boxed, so sync_now / sync_wallet stay Send + 'static for the FFI.

Not touched: rs-platform-wallet-ffi, swift-sdk, kotlin-sdk, rs-unified-sdk-jni.

One observable difference: the "sync loop started behind a wedged pass" debug line keeps its text, but is now emitted from manager::sync_loop rather than from each coordinator's module, so its tracing target changes.

Production line count is roughly flat (each coordinator loses 46 to 67 lines; sync_loop.rs adds 291 including docs). What goes away is the five-way duplication of the logic.

How Has This Been Tested?

The tests from #6162 pass with their assertions unchanged. One exception to "unedited": identity tests that arrived later with the v5.2-dev merge (#6283) set the private fields directly, so in identity_sync.rs they now go through the test hooks (is_syncing.store(true) → assert!(wedge_sync_slot_for_test()), is_syncing.store(false) → release_sync_slot_for_test(), quiescing.seal() → seal_sync_admission_for_test()). What they assert is the same. sync_loop.rs adds 8 unit tests of its own.

After each of the five commits:

  • RUST_MIN_STACK=4194304 cargo test -p platform-wallet --features shielded manager:: — all passed (300 on the current base)
  • cargo check -p platform-wallet --all-targets (without shielded)
  • cargo clippy -p platform-wallet --features shielded --tests -- -D warnings
  • cargo check -p platform-wallet-ffi --features shielded (proves the futures are still Send)

At the tip, merged with the current v5.2-dev: cargo test -p platform-wallet --features shielded — 2835 lib tests passed, 0 failed.

Not verified: the 8 MB loop stack for DashPay and DPNS has no cheap test; the value is passed through unchanged, but a device run of DashPay/DPNS sync is the real check. Swift and Kotlin builds were not run (their sources are untouched).

Breaking Changes

None.

Checklist:

  • I have performed a self-review of my own code
  • My Rust, FFI, WASM, Swift or Kotlin changes follow the coding conventions
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed
  • If I added or changed GroveDB structure, I described it in the area's structure.rs, regenerated grovedb-structure.json, and checked the structure viewer link posted on this pull request
  • If I added or changed a system contract's document schemas, I checked the contract viewer link posted on this pull request

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

PR Hygiene · 0663d29

  • Bots — thepastaclaw ✓
  • Self-review — posted; again after any push
  • Build green
  • Approvals — you own every area touched; none needed

When every merge requirement is met, the PR Hygiene check passes. Reviewer limits do not block merging; other required GitHub checks and protections still apply.

llbartekll and others added 6 commits November 23, 2026 15:46
Characterization tests for the five periodic sync coordinators
(identity, DashPay, DPNS, platform-address, shielded), ahead of
sharing their loop, admission and drain code. No production change.

- All five coordinators get the same test hooks
  (`wedge_sync_slot_for_test`, `release_sync_slot_for_test`,
  `sync_admission_closed`); the existing tests go through them instead
  of the private `is_syncing` / `quiescing` fields, so they survive the
  fields moving.
- DPNS had no tests; it now has the full lifecycle set.
- Every coordinator now pins: interval clamp, quiesce waiting on the
  slot, the timeout latch, refusal behind a busy slot (which stays with
  its owner) and behind a shut gate, held / overlapping / sealed drains,
  start behind a latch, the drained latch reopening, stop then quick
  start, the first pass running at start, and a second start being a
  no-op.
- Completion events: fired once per pass and before the slot is
  released (platform-address, DPNS, shielded).
- `sync_wallet`: platform-address keeps two distinct refusal messages;
  shielded reports `None`, reads the coordinator before admission, and
  a pass cancelled before it produced anything is neither stamped nor
  reported.
- The manager shutdown test also starts and joins DPNS and shielded.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The five periodic sync coordinators each carried their own copy of the
loop thread, the `is_syncing` slot, the admission preamble and the
`quiesce*` family. `SyncLoop` (new `manager/sync_loop.rs`) holds that
state and those steps once; a coordinator embeds one and keeps its own
pass body, result type and completion event.

- `SyncLoop::admit` is the preamble: reopen a drained latch, claim the
  slot, check the gate. It tells a busy slot from a shut gate.
- `start_sync_loop` is the loop, unchanged in order: cancel check, pass,
  sample the latch, sleep the interval or the latched retry interval.
- `QuiesceGate`, `drain_pass` and `SyncSlotGuard` stay where they are.

DPNS is the first coordinator on it. No behaviour change: same public
API, same 8 MB loop stack, same log line, completion event still sent
before the slot is released. Its tests pass unedited.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
`DashPaySyncManager` embeds `SyncLoop` instead of its own copy of the
loop thread, the `is_syncing` slot, the admission preamble and the
drain family. No behaviour change: same public API, same 8 MB loop
stack, same log line, and still no completion event. Its tests pass
unedited.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
`IdentitySyncManager` embeds `SyncLoop` instead of its own copy of the
loop thread, the `is_syncing` slot, the admission preamble and the
drain family. `SyncLoop` is not generic; the coordinator stays generic
over its persister. No behaviour change: same public API, same default
loop stack, same log line, `sync_now` still returns `()` and fires no
completion event. Its tests pass unedited.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…dress)

`PlatformAddressSyncManager` embeds `SyncLoop` instead of its own copy
of the loop thread, the `is_syncing` slot, the admission preamble and
the drain family. `sync_wallet` maps a busy slot and a shut gate to the
two refusal messages it had. No behaviour change: same public API, same
default loop stack, same log line, completion event still sent before
the slot is released. Its tests pass unedited.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
`ShieldedSyncManager` embeds `SyncLoop` instead of its own copy of the
loop thread, the `is_syncing` slot, the admission preamble and the
drain family. The pass-cancellation token stays the coordinator's own,
and its ordering is kept as it was:

- `sync_now` and `sync_wallet` take the pass token before admission;
- `stop()` cancels and rotates the token before it cancels the loop;
- `sync_wallet` reads the coordinator before admission, so it returns
  without touching the slot or the gate when none is configured.

No behaviour change: same public API, the loop still passes
`force = false`, same log line, a pass cancelled before it produced
anything is still neither stamped nor reported, and the completion
event is still sent before the slot is released. Its tests pass
unedited.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@thepastaclaw

thepastaclaw commented Nov 23, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Final review complete — no blockers (commit 0663d29)

llbartekll and others added 3 commits November 24, 2026 10:48
…istic

Review follow-up on the lifecycle characterization tests.

- The four "quiesce blocks until the in-flight pass drains" tests held
  the slot from a background task for a fixed 200 ms and waited for it
  with an unbounded loop, so a loaded runner could miss the window and
  hang. The test now holds the slot itself, polls `quiesce()` once to
  see it pending with admission shut, releases the slot and awaits the
  drain under a timeout.
- The shielded cancelled-pass test polls the pass by hand, so a pass
  that read the coordinator before claiming the slot fails an assertion
  instead of waiting on the lock the test holds.
- Shielded gets the sealed-drain-that-times-out test its four siblings
  already had.
- The shielded stamp test is renamed to what it can prove: both sides
  read the wall clock, so it cannot tell whose stamp was kept.
- The identity retry comment named a 15 s default; it is 60 s.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…efactor/platform-wallet-sync-loop

# Conflicts:
#	packages/rs-platform-wallet/src/manager/identity_sync.rs
Base automatically changed from test/platform-wallet-sync-coordinator-lifecycle to v5.2-dev November 25, 2026 10:58
@github-actions github-actions Bot added this to the v5.2.0 milestone Nov 25, 2026
…-wallet-sync-loop

# Conflicts:
#	packages/rs-platform-wallet/src/manager/dpns_sync.rs
@llbartekll
llbartekll marked this pull request as ready for review November 25, 2026 11:15
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added the waiting-bots Waiting for the review bots to report on this head label Nov 25, 2026

@thepastaclaw thepastaclaw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Final validation — Phase 1 + Phase 2

Changes requested: 1 blocker

  • A cancelled worker can repopulate platform-address data after Clear succeeds — packages/rs-platform-wallet/src/manager/sync_loop.rs:263-268 (new)
    Impact: A wallet user who clears platform-address data just as a background tick starts can have cached balances and the sync watermark written back without restarting sync.

The PR extracts scheduling, pass admission, and draining into a shared SyncLoop for all five wallet coordinators, leaving each coordinator’s pass body and completion handling in place. Linux wallet tests and Swift and Kotlin SDK checks passed; Rust workspace tests were skipped, and PastaClaw review and PR Hygiene were pending.

🔴 1 blocking | 🟡 3 suggestion(s)

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); reviewer 7: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 8: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 9: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 10: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The refactor centralizes concurrency-sensitive lifecycle logic across five wallet sync coordinators, but the diff does not change a critical surface.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Second Phase-2 pass: on this first full review every Phase-2 reviewer also ran a second, independent time, and the verifier weighed both sets
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/manager/sync_loop.rs`:
- [BLOCKING] packages/rs-platform-wallet/src/manager/sync_loop.rs:263-268: A cancelled worker can repopulate platform-address data after Clear succeeds
  Impact: A wallet user who clears platform-address data just as a background tick starts can have cached balances and the sync watermark written back without restarting sync.
  Clear can return success and report sync stopped, yet the cancelled worker can still write a new balance snapshot and watermark. If the worker is descheduled after `cancel.is_cancelled()` but before it claims the sync slot, `reset_platform_address_sync_state` can close admission, cancel the worker, observe an idle slot, reset the wallets, and reopen admission when its guard drops (`manager/mod.rs:1246–1275`). The registry’s clearing latch only prevents new worker registrations. When the old worker resumes, `background_pass()` enters through the reopened gate without checking its token again, and a successful scan calls `persister.store` (`wallet/platform_addresses/sync.rs:172–193`). The base had the same gap in the loop this PR moves into `SyncLoop`. Check the worker’s own token after acquiring the pass permit and before doing wallet work, leaving manual admission independent. Add a test that pauses a tick before admission, completes an unsealed drain, and verifies that the cancelled tick cannot enter the pass body.
- [SUGGESTION] packages/rs-platform-wallet/src/manager/sync_loop.rs:268-281: A restarted loop can sleep a full interval when the old pass drains just after a refused tick
  Impact: After restarting sync following a timed-out stop, a wallet user can wait a full configured polling interval for an update even though the old pass has finished.
  The loop can miss its one-second recovery retry even though the slot is now free. If the background tick is refused because the old pass still holds the slot, and that pass releases it before the post-pass probe, `reopen_if_drained()` clears the latch and returns `true`. The loop then chooses the normal interval even though the tick did no work. The original loops had the same ordering. Preserve whether the tick was refused during latch recovery and schedule a short retry even if the latch clears before the delay is chosen. Test that specific ordering by releasing the old pass between the refusal and the probe.
- [SUGGESTION] packages/rs-platform-wallet/src/manager/sync_loop.rs:445-455: The retry-cadence test can pass without the worker ever retrying
  Impact: On a busy CI runner, maintainers can get a green test even if the loop always sleeps for the configured one-hour interval.
  The test does not establish that the worker selected the short delay while the slot was wedged. `is_running()` reports registration, and zero successful passes after 100 ms means either admission was refused or the worker has not run yet. In the latter case, releasing the wedge lets the worker’s first immediate pass satisfy the test. Even observing a refusal is not enough: releasing the slot before the subsequent latch probe can make the unchanged loop select the full interval and fail the test. Keep the slot wedged until the worker signals that it has selected a delay, assert that the delay is `LATCHED_RETRY_INTERVAL`, then release the slot and verify that an admitted pass follows.
- [SUGGESTION] packages/rs-platform-wallet/src/manager/sync_loop.rs:47-48: Discarding the admission result silently releases the sync slot
  Impact: If a future coordinator discards `admit()` and proceeds with the pass, reset or shutdown can miss its writes and callbacks.
  A drain can report completion while an unguarded pass is still working. A bare `self.sync.admit();` drops the successful permit at the end of the statement, clearing `is_syncing` without a diagnostic. All current callers retain their permit; this is a safeguard for the new shared API, not a current failure or a layer-ownership violation. Mark `Admission` as `#[must_use]` so an accidentally discarded result is diagnosed.

@github-actions

Copy link
Copy Markdown
Contributor

Your move: thepastaclaw requested changes on this head; dismiss the review or push a fix; thepastaclaw left review threads unresolved; resolve them.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 25, 2026
A bare `self.sync.admit();` would drop an admitted permit at the end of
the statement and release the `is_syncing` slot while the pass went on.
Every caller holds its permit; the attribute makes a future slip a
compiler warning.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@github-actions github-actions Bot added waiting-bots Waiting for the review bots to report on this head and removed waiting-self-review Waiting for the author to post /self-reviewed labels Nov 25, 2026
…-wallet-sync-loop

Conflicts in manager/identity_sync.rs: the base reworked the identity
coordinator's pass entry and drain (try_sync_pass / SyncAttempt,
sync_now_after_in_flight, the persistence barrier in the quiesce
family, the gate check before a store). Kept all of it, on SyncLoop:

- try_sync_pass maps SyncLoop::admit's Busy / Closed to SyncAttempt.
- quiesce_held_within drains through SyncLoop::drain, then waits out
  the persistence barrier and latches admission on its timeout.
- quiesce_sealed_within goes through quiesce_held_within again, so the
  sealed drain keeps the barrier.
- SyncLoop gains admission_closed (no longer test-only),
  latch_admission_closed and seal_admission for those callers.

The base's new identity tests wrote the private is_syncing / quiescing
fields; they now use the test hooks (wedge / release / seal), with no
other change.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Waiting for bot review — thepastaclaw not yet. Wait for the missing reviews, or a writer can post /skip-bots to proceed without them; blocking findings still need addressing.
Full checklist in the description.

@thepastaclaw thepastaclaw left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Re-review — Final validation — Phase 1 + Phase 2

Updated after discussion: 1 finding(s) of this review were settled in the inline threads.

  • ✅ Withdrawn: 🟡 Identity shutdown now duplicates the shared admission-sealing sequence

New on this head: This head marks sync admission as #[must_use] and merges v5.2-dev, preserving identity sync’s persistence barrier and shielded sync’s handling of incomplete scans. The Rust wallet tests and the Swift and Kotlin SDK builds and tests passed; PR Hygiene and PastaClaw review were pending, with no failed code checks.

🟡 3 2 suggestion(s)

Approved: nothing here blocks the merge. The non-blocking findings are optional: fix them forward, in this PR or a follow-up, without waiting for another review round.

Still open from earlier rounds (1)

  • 🟡 Suggestion: The retry-cadence test can pass without the worker ever retrying — packages/rs-platform-wallet/src/manager/sync_loop.rs:460-474 (thread)

⏸️ Awaiting tracking link (1): A restarted loop can sleep a full interval when the old pass drains just after a refused tick (thread). Link an issue on its thread, or ask there and PastaClaw files it.

Review provenance

Source: reviewer 1: muse-spark-1.3-contributor (agent: phase1-reviewer, role: general); reviewer 2: muse-spark-1.3-contributor (agent: phase1-reviewer, role: rust-quality); reviewer 3: gpt-6.2-sol (agent: phase2-reviewer, role: general); reviewer 4: gpt-6.2-sol (agent: phase2-reviewer, role: architecture-layering); reviewer 5: gpt-6.2-sol (agent: phase2-reviewer, role: rust-quality); reviewer 6: gpt-6.2-sol (agent: phase2-reviewer, role: security-auditor); final verifier: gpt-6.2-sol (agent: sol-verifier, role: final-verifier)

  • Triage: normal by gpt-6.2-sol (effort low) — The refactor centralizes concurrent admission, cancellation, and draining across five wallet coordinators, making behavior preservation nontrivial without changing any of the listed critical surfaces.
  • Phase 1 reviewers: muse-spark-1.3-contributor — general (completed, effort xhigh); agent phase1-reviewer, muse-spark-1.3-contributor — rust-quality (completed, effort xhigh); agent phase1-reviewer
  • Phase 1 model: muse-spark-1.3-contributor — not quota-gated; passed over gemini-3.8-flash-high (lane failed), glm-5.3-flash (not used above high effort; tier asks max)
  • Fresh verifier: gpt-6.2-sol — final-verifier; agent sol-verifier
  • Phase 2 reviewers: gpt-6.2-sol — general (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — architecture-layering (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — rust-quality (completed, effort high); agent phase2-reviewer, gpt-6.2-sol — security-auditor (completed, effort high); agent phase2-reviewer
🤖 Prompt for all review comments with AI agents
These findings are from an automated code review (PastaClaw). How to work through them:
- Verify each finding against the code; fix only what is real, as narrowly as the finding.
- If a finding is wrong, decline it on its thread in one or two sentences; the bot answers once and stops.
- To defer one, link a tracking issue on its thread (or reply asking the bot to file one).
- Suggestions don't block the merge, but most are worth fixing in this PR; judge each on its merits.
- Keep the PR's scope; don't grow it to satisfy hardening suggestions.
- Carried items were raised in an earlier round: read the thread first, and don't re-fix what you already fixed, declined or deferred there. Disputed and deferred items are already handled and are not listed.

In `packages/rs-platform-wallet/src/manager/identity_sync.rs`:
- [SUGGESTION → WITHDRAWN in discussion; do not fix] packages/rs-platform-wallet/src/manager/identity_sync.rs:586-594: Identity shutdown now duplicates the shared admission-sealing sequence
  Impact: A future change to drain finalization made only in `SyncLoop::drain_sealed` will reach the other four coordinators but miss identity sync.
  The merge preserves shutdown behavior today but leaves the seal-before-release ordering in two places. Identity shutdown previously delegated to `SyncLoop::drain_sealed`; it now calls `quiesce_held_within` to include the new persistence wait, then checks the result, seals admission, and drops the guard itself. Keep the persistence wait in identity sync, but pass its drain result to a shared `SyncLoop` finalizer that seals admission before releasing the guard.

In `packages/rs-platform-wallet/src/manager/sync_loop.rs`:
- [SUGGESTION] packages/rs-platform-wallet/src/manager/sync_loop.rs:460-474: The retry-cadence test can pass without the worker ever retrying
  (carried; thread: https://github.com/dashpay/platform/pull/6163#discussion_r4694650973)
- [SUGGESTION] packages/rs-platform-wallet/src/manager/sync_loop.rs:268-281: A restarted loop can sleep a full interval when the old pass drains just after a refused tick
  (awaiting a tracking link: link an issue on its thread, or ask there and PastaClaw files it; no code change needed; thread: https://github.com/dashpay/platform/pull/6163#discussion_r4694650964)

@github-actions

Copy link
Copy Markdown
Contributor

Bots are done — your move: post /self-reviewed.
Full checklist in the description.

@github-actions github-actions Bot added waiting-self-review Waiting for the author to post /self-reviewed and removed waiting-bots Waiting for the review bots to report on this head labels Nov 25, 2026
@llbartekll

Copy link
Copy Markdown
Contributor Author

/self-reviewed

@github-actions

Copy link
Copy Markdown
Contributor

Policy satisfied — this can merge.
Full checklist in the description.

@github-actions github-actions Bot removed the waiting-self-review Waiting for the author to post /self-reviewed label Nov 26, 2026
@romchornyi

Copy link
Copy Markdown
Contributor

Reviewed the diff against the old per-coordinator code: admission order, permit lifetime across the completion event, shielded's token/stop ordering, the DashPay/DPNS 8 MB stack and platform-address's two refusal messages all carry over unchanged. No blockers from my side.

# Where Finding Suggestion
1 PR description / identity_sync.rs tests The description says the coordinators' test modules are byte-identical, but identity_sync.rs tests changed: is_syncing.store(true) → assert!(wedge_sync_slot_for_test()), quiescing.seal() → seal_sync_admission_for_test() (probably tests that came in with the v5.2-dev merge). The change itself is fine. Update the description so the "tests unedited" claim matches the diff.
2 sync_loop.rs ~460, should_poll_briskly_behind_a_latched_gate_and_resume_when_it_drains If the loop thread hasn't started within the 100 ms sleep, passes == 0 holds trivially. The first pass then succeeds after the release without any brisk retry, so the test passes even if the loop always slept the full interval. No production hook needed: count attempts in the test's CountingCoordinator::background_pass (admitted or not), and wait for attempts >= 1 before release_slot_for_test().
3 thread on sync_loop.rs:296 Still marked "Needs a tracking issue"; #6290 is linked only on the :283 thread. Reply with #6290 on the :296 thread as well.
4 (nit) start_sync_loop(this, stack_size, label) Stack size and label are per-coordinator constants passed as arguments. Consider const LABEL / const STACK_SIZE on SyncCoordinator, so the call becomes start_sync_loop(self).
5 (nit) SyncLoop::unix_now It doesn't use any loop state. Could be a free function in the module.

@romchornyi romchornyi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving; the table in my comment above lists non-blocking follow-ups.

@llbartekll
llbartekll merged commit 5d1046e into v5.2-dev Nov 26, 2026
36 of 37 checks passed
@llbartekll
llbartekll deleted the refactor/platform-wallet-sync-loop branch November 26, 2026 10:31
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