Skip to content

test: cover the no-clobber publish guarantee and state it in the readme - #26

Merged
pasichDev merged 1 commit into
mainfrom
test/publish-no-clobber
Nov 10, 2026
Merged

pasichDev merged 1 commit into
mainfrom
test/publish-no-clobber

Conversation

@pasichDev

Copy link
Copy Markdown
Owner

What and why

#12 asked whether migrations on Android API 24–29 should get a strict mode that refuses to publish when the kernel cannot guarantee no-replace. Decision: keep the current behaviour and no strict mode. On API 24–29, Sealite publications are serialized against each other, across threads and processes. Unrelated code that writes the same path without the lock can still race the check-and-rename. A strict mode would be new public API for a case few apps have. This PR pins the guarantee with tests and states it precisely.

  • PublishNoClobberTest (commonTest, every platform). It exercises publishWithoutReplacing directly:
    • an existing destination, its sidecars and the rejected source stay untouched;
    • an empty destination created by another writer is not replaced;
    • a publish to a free name moves the file, and a later publish to it is rejected;
    • eight competing publishers over 8 rounds give exactly one winner, and the losers keep their files;
    • four migrations onto a destination someone else wrote all fail, and nothing changes.
  • Android fallback: publishUnderLock goes from private to internal. PublishAndroidTest gains three device tests that force the API 24–29 path on any API level: an existing target with sidecars, eight threads with one winner, and a dangling symbolic link.
  • README: the migration section states the guarantee per platform: atomic no-replace on the JVM, Apple and Android 30+, and serialized against Sealite only on Android 24–29. It also says which exception the loser of a race throws.

The known race with a non-cooperating writer on API 24–29 is documented, not asserted.

How it was tested

  • PublishNoClobberTest (5) and EncryptPlaintextTest (12) on the JVM (macOS)
  • compileAndroidDeviceTest
  • Platforms tested: jvm (macOS)

Not verified: the three new Android device tests were only compiled here. This PR's Android jobs run them for the first time.

Checklist

  • Public API unchanged (publishUnderLock is internal)
  • No key material is logged, copied into a String or left unwiped
  • Docs and CHANGELOG-relevant behaviour described above
  • New source files carry the SPDX header

Closes #12

Competing publications to one destination have exactly one winner, an
existing destination and its sidecars are never touched, on every
platform. The Android fallback for API 24 to 29 is internal now so a
device test can force it on any API level. The readme states the
guarantee per platform.
@pasichDev
pasichDev enabled auto-merge (squash) November 10, 2026 12:45
@pasichDev
pasichDev merged commit f0df9b1 into main Nov 10, 2026
18 checks passed
@pasichDev
pasichDev deleted the test/publish-no-clobber branch November 10, 2026 13:09
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.

enhancement(android): evaluate strict no-clobber publish for migrations on API 24–29

1 participant