Skip to content

fix(sync): ask a store only for keys it can hold - #1664

Open
A-EDev wants to merge 1 commit into
mainfrom
fix/sync2-chain-epoch0
Open

A-EDev wants to merge 1 commit into
mainfrom
fix/sync2-chain-epoch0

Conversation

@A-EDev

@A-EDev A-EDev commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Every sync asked the server (and LAN peers) for the history chain box of epoch 0, which never exists, so each sync logged one 404 on the server. A device that joined after a rotation also asked for its own wrap at every older epoch, which never exists either.

keyNames() in sync2/store/Store.kt now lists only the keys a store can hold along the roster chain:

  • a chain box for every epoch after genesis;
  • this device's wrap for the epochs since it joined (an epoch whose to names it, or the epoch in force when an add added it).

GroupStore.download and LanPeer.pull both use it. No user-visible change, so no nightly note.

Related issue

None.

Change type

  • Bug fix
  • Feature
  • Refactor or maintenance
  • Build, packaging, or CI
  • Documentation

Validation

  • New test HeldStoreTest.a_download_asks_only_for_keys_the_store_holds: rotates once, adds C at epoch 1, then downloads as B and as C and asserts no key request misses. Failed before the fix (AssertionError at HeldStoreTest.kt:123, with app/src/main stashed), passes after.
  • ./gradlew --offline -Dorg.gradle.jvmargs="..." :app:testGithubDebugUnitTest --tests 'io.github.aedev.flow.sync2.*': 227 tests, 0 failures.
  • ./gradlew --offline ... ktlintCheck: exit 0.
  • ./gradlew :app:assembleGithubDebug: not run separately (the test task compiled the github debug sources).
  • I manually tested the affected behavior on an Android device or emulator: not yet; part of the Phase 7 device test round.

Test device and Android version: none yet.

Risk and compatibility

Fewer requests only. A key the device still needs is in the list by the spec's rules (spec/protocol.md: wraps go to to of each epoch, an add wraps the current epoch, every later epoch writes a chain box).

  • The change does not introduce secrets, private data, or unexpected telemetry.
  • New user-facing text uses Android string resources.
  • Dependency and lockfile changes are intentional and limited to this PR.
  • Room schema changes include the required version bump and migration, or this PR does not change the Room schema.
  • Breaking changes and upgrade steps are clearly documented.

Copilot AI balanced review requested due to automatic review settings November 2, 2026 22:36

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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