Phase 1 M2 task 3 (tools/DESKTOP_PHASE_PLAN.md §4). Logic lives in
BackupBridge so both platforms get it through the one bridge:
- BackupBridge.import gains skipExisting (default true) and returns
ImportSummary(imported, skipped). A note is skipped when the library
already holds the key (createdAt, updatedAt, sha256(content)) — the
triple the export preserves verbatim, trustworthy only since the M2
import-timestamp fix. Keys are snapshotted BEFORE importing, so two
genuinely identical notes inside one file still both import into a
fresh library; only a second import of the same file is a no-op.
Snapshotted keys include trashed notes. skipExisting=false restores
the old additive behaviour (the documented override).
- Android: BackupManager.import passes the flag and returns the summary
(signature-identical call for SettingsViewModel); its snackbar now
reports the skip count. Screen layouts untouched — exit criterion
"Android backup screens unchanged" holds.
- Desktop: the import confirm dialog swaps its "duplicates persist"
warning for a working "Skip notes that are already here" checkbox
(default ON); scripted path prints the re-import outcome.
- Format unchanged: formatVersion stays 1 (streaming/dedupe-at-format
level stays a Phase-2 formatVersion=2 idea).
Verification passed: :core:data-jvm:backupSmoke (new step — re-import
skipped=27, override added 27, store=54; RESULT M2 round-trip PASS on
the real export) + :desktopApp:run --args="--data-dir /tmp/incido-m2t3
--backup-import <export> --backup-export … --exit-after 8" (imported=27
skipped=0 → exported=27 → reimport imported=0 skipped=27, clean exit) +
assembleDebug + :core:data-jvm:smoke + :desktopApp:run --self-test —
all green; output recorded in DESKTOP_FEASIBILITY.md.
Known limitation (by design): attachments are not in the key.
Phase 1 M2 verification probe, driven by a real phone export (27 notes,
1 attachment, 14 orphan tags; the file is user data and stays out of the
repo):
- :core:data-jvm:backupSmoke --args="<export.incido.json> [libDir]" —
preview, import into a fresh JVM library, re-export + field-by-field
compare, encrypted envelope export (wrong passphrase rejected),
encrypted import into a 2nd library with attachment-byte equality.
The probe caught a PRE-EXISTING Android bug the phone also has: upsert /
saveNoteWithHashtags stamped createdAt+updatedAt to now on every insert,
so backup import rewrote every note's history — and would defeat the
(createdAt, updatedAt, sha256(content)) dedupe key M2 task 3 depends on.
Justified behavior change (invariant 1: not silent): non-zero caller
timestamps are now honoured, 0 still means now. The Android editor
passes its own stamps (verified at both Note(...) sites), so only the
import path changes. addAttachment gains createdAt: Long = 0L;
importSnapshot passes the phone value through.
Verification passed: :core:data-jvm:backupSmoke (RESULT: M2 round-trip
PASS on the real export) + assembleDebug + :core:data-jvm:smoke (after a
forced codegen regen: "ID model file unchanged") + :desktopApp:run
--self-test + :spike:data-jvm:run — all green; output recorded in
DESKTOP_FEASIBILITY.md.
Known pre-existing gap left open (documented): importSnapshot never
recreates orphaned hashtag rows.
Phase 1 milestone M1a (Development Plan §6, desktop track): make the whole
data layer usable from a non-Android build, without touching what the
Android app compiles.
:core:data splits its sources:
src/main/kotlin platform-neutral — entities, repository, field
crypto, NoteCryptoService. Compiled by BOTH
:core:data and :core:data-jvm. Must not import
android.*
src/androidMain/kotlin Android-only seam implementations.
Two seams were required, both identified by the Phase-0 spike:
ObjectBoxStore Context on Android, a directory on desktop. Same
FQN in sibling modules that are never on one
classpath — which is also what keeps
objectbox-android and objectbox-java (they ship
the same io.objectbox.* classes) apart.
ImageOrientationNormalizer EXIF rotation needs a bitmap decoder; the
implementation moved verbatim out of
NoteRepositoryImpl, which is now platform-free.
The parameter is required, not defaulted, so a
platform that forgets it fails the build.
New :core:data-jvm compiles those shared sources against objectbox-java /
objectbox-linux with its own codegen. `:core:data-jvm:smoke` runs the real
NoteRepositoryImpl (save + hashtags + attachment round-trip + close/reopen)
on the JVM: PASS, with the generator reporting "ID model file unchanged" —
one schema, two generated runtimes.
Also: .gitignore excluded **/objectbox-models/, so the schema contract was
never committed and a fresh clone regenerated UIDs. default.json is now
tracked; the rest of that directory stays ignored. This matters more now
that two modules generate from it.
Verified: :core:data-jvm:smoke PASS, assembleDebug green.