Commit Graph
6 Commits
Author SHA1 Message Date
Incido Developer 0dc5935d1d feat(phase-1/m4.4e): real JVM EXIF orientation normalizer
The §6.3 EXIF row deferred implementation to "M4+ when the JVM
attachment intake lands" — it landed in M4.4c, so the last NoOp
placeholder is gone. JvmImageOrientationNormalizer keeps the Android
contract exactly: orientation 6/3/8 -> bake 90/180/270 into pixels,
re-encode JPEG @ 0.92, return input UNCHANGED for normal/absent/mirror
tags or any decode/rotate failure.

Tooling differs, contract doesn't: com.drewnoakes:metadata-extractor
2.19.0 (first Central pull this phase — recorded) for the tag read,
BufferedImage + AffineTransform for the rotate, ImageIO JPEG writer at
explicit 0.92 for the encode. DesktopContainer now wires it into
NoteRepositoryImpl (was ImageOrientationNormalizer.NoOp).

New probe: :core:data-jvm:orientationSmoke hand-builds an
EXIF-Orientation-90 JPEG (APP1 splice — metadata-extractor is
read-only) and asserts: no-EXIF passthrough, EXIF-90 rewrite, pixels
rotated (4x2 -> 2x4), output stability, garbage passthrough.

Verified: :core:data-jvm:orientationSmoke (RESULT: M4.4e PASS, 5/5)
+ ./gradlew assembleDebug :desktopApp:build SUCCESSFUL
+ :desktopApp:run --self-test (SELFTEST id=1 -> RENDER notes=1
selected=1); objectbox-models clean.
2026-10-06 19:04:09 +13:00
Incido Developer 29288b0370 test(m2): make :core:data-jvm:smoke idempotent — wipe its probe library in doFirst
The probe asserts exact note counts; running it twice in a row against the surviving build/data-jvm-smoke directory failed on count assertions (found while verifying m2.5). The task now cleans the directory like backupSmoke does.
2026-10-05 19:48:54 +13:00
Incido Developer 9cb7fdbf58 perf(phase-1/m2.5): export memory measured on synthesized worst-case libraries
Phase 1 M2 task 5 (tools/DESKTOP_PHASE_PLAN.md §4): measure & record,
no redesign. New :core:data-jvm:backupMemory probe (2g heap) samples
heap-used at 1 ms during BackupBridge.exportPlain — the phone's own
export path — across four fresh libraries:

  24 MB data (3 att)  → peak 230 MB   |  2 MB text x2000 notes → 140 MB
  80 MB data (10 att) → peak 777 MB   | 320 MB data (40 att)  → OOM at -Xmx2g

Attachments drive memory (~9–10x allocation pressure: store load →
base64 String → UTF-8 bytes → JsonElement tree); note count alone is
trivial. The plan's 250 MB gate trips at ~25–30 MB of attachments, and
the phone (no largeHeap) shares the ceiling — a pre-existing Android
limitation, unchanged by the bridge extraction. The real library
exports at 366 KB ≈ 1000x headroom. Bonus: a ~1.6 GB library dies in
objectbox-java's DbFullException before the bridge ever sees it.

Verdict: record, don't redesign. Streaming formatVersion=2 stays parked
for Phase 2, required only if attachment libraries approach ~25 MB.
2026-10-05 19:48:02 +13:00
Incido Developer 031d8570b4 feat(phase-1/m2.3): import dedupe — importing the same file twice adds nothing
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.
2026-10-05 19:33:07 +13:00
Incido Developer 8facbe718b 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.
2026-10-05 19:03:31 +13:00
Incido Developer 9fe4763aa7 feat(phase-1/m1a): platform-neutral data layer + :core:data-jvm
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.
2026-10-05 18:20:59 +13:00