test(m2): backupSmoke — round-trip a real Android export through :core:backup, + import-timestamp fix
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.
This commit is contained in:
1 parent
7cc4eda90d
commit
8facbe718b
6 files changed
+278
-3
No files matched your search
@@ -295,3 +295,41 @@ Housekeeping found on the way: `:core:data-jvm:smoke` does not clear
|
||||
second consecutive run fails with "expected 1 note, got 2". Run it against
|
||||
a deleted directory (worth fixing in a later milestone).
|
||||
|
||||
**M2 — real-data round-trip probe + import-timestamp fix: DONE.** New
|
||||
`./gradlew :core:data-jvm:backupSmoke --args="<export.incido.json> [libDir]"`
|
||||
feeds a **real** phone export (27 notes, 1 attachment, 14 orphan tags,
|
||||
TASK_LIST+TEXT, colors, 1 favourite — file kept out of the repo, it's user
|
||||
data) through the bridge on the JVM: preview → import into a fresh library
|
||||
→ re-export and compare every field the format claims to preserve →
|
||||
encrypted envelope export (wrong passphrase → `null` preview) → import of
|
||||
the envelope into a second library with attachment-byte equality.
|
||||
|
||||
The probe immediately caught a **pre-existing Android bug**: `upsert` /
|
||||
`saveNoteWithHashtags` overwrote `createdAt` AND `updatedAt` with "now"
|
||||
for every insert, so even the phone's own import re-stamped the whole
|
||||
library — silently breaking the `(createdAt, updatedAt, sha256(content))`
|
||||
dedupe key M2 task 3 is built on. Fixed in the shared repository: a
|
||||
caller-supplied non-zero timestamp is honoured, `0` still means "now"
|
||||
(the Android editor already stamps both fields itself, verified at its two
|
||||
`Note(…)` sites — so only the import path changes). Same for
|
||||
`addAttachment`, which now takes `createdAt: Long = 0L` and
|
||||
`importSnapshot` passes the phone's value through.
|
||||
|
||||
```
|
||||
preview (plain, no passphrase) PASS — notes=27 attachments=1 app=0.4.0.0
|
||||
import into fresh JVM library PASS — imported 27 notes, all readable back through the flow
|
||||
re-export plain == original PASS — all 27 notes + 1 attachments identical
|
||||
(content/times/fav/color/type/trash/draft/tags/bytes)
|
||||
encrypted export + wrong-pw reject PASS — envelope=366739B, wrong passphrase → null
|
||||
import encrypted into 2nd library PASS — attachment 260121B byte-identical to the phone's
|
||||
RESULT: M2 round-trip PASS
|
||||
```
|
||||
|
||||
Still open from the probe: `importSnapshot` never recreates *orphaned*
|
||||
hashtag rows (the export carries them, the import ignores them) —
|
||||
pre-existing on Android, noted for task 3. After the fix, full suite green:
|
||||
`assembleDebug`, `:core:data-jvm:smoke`, desktop `--self-test`,
|
||||
`:spike:data-jvm:run` — and the ObjectBox generator kept printing
|
||||
`ID model file unchanged`.
|
||||
|
||||
|
||||
Reference in new issue
Block a user