Milestone M3 task 3 (DESKTOP_PHASE_PLAN §5). Three pieces:
1. DesktopKeyProvider — the JVM FieldKeyProvider. The plan's keyring
condition is FAILed honestly: no keyring library is in the catalog
and the candidates are unverified on this stack, so the sanctioned
fallback applies: the 32-byte field key lives in `field.key` inside
the library dir, written via temp+atomic-move with 0600 POSIX perms
(File.setReadable/setWritable fallback for non-POSIX fs). It speaks
the phone's recovery format natively through EncryptedKeyCodec
(importRecoveryKey / exportRecoveryKey — INCKEY1, PBKDF2-200k,
AES-GCM, wrong passphrase throws before anything is written).
Key retention on disable: the sweep decrypts first, then flags
clear, but the key file stays (Android's deleteKey-on-disable is
Keystore-scoped; keeping it lets users re-enable and re-export).
Stated, not silent.
2. DesktopContainer now mirrors AppContainer fully: settings -> cipher
auto-install from snapshot (isEncryptionActive AND key on disk)
BEFORE the repository -> NoteCryptoService -> EncryptionVerifier ->
checkNow at startup. shutdown() cancels appScope.
3. UI: SecurityActions menu (theme cycle + encrypt/decrypt toggle +
recovery-key import/export, incl. Android's overwrite-warning gate)
reusing the backup menu's pickFile/PassphraseDialog (now internal,
parameterized title/extensions). theme_mode drives Material3 via
colorScheme (M3 MaterialTheme has no darkTheme param). dynamic_color
/ use_biometric / block_screenshots are NOT shown — no JVM
equivalent, hide-don't-fake. Window geometry persists to its own
incido_window.preferences_pb (desktop-only state; position left to
KWin).
Verification (scripted legs in Main.kt, --crypto-self-test / --crypto-reopen):
leg A: probe note -> key+cipher+sweep -> verifier trial-decrypt
PASS (verified=1 failed=0) -> transparent repo read -> WRONG KEY
REJECTED via AEAD tag -> INCKEY1 envelope 84 bytes, wrong-pw
rejected, key byte-match -> LEG-A PASS.
leg B (separate process = real relaunch): settings survived, cipher
auto-installed, sweep all-ok, decrypt sweep reverses it -> PASS.
:desktopApp:run --self-test regression green; assembleDebug green.
ls confirms field.key is -rw------- (0600).
One environmental note: a leg-A run earlier in the session wedged in
XWayland window teardown (never reached exitApplication); the rerun
auto-exited cleanly — same one-off as the M3.2 startup wedge.
Milestone M3 task 1 (DESKTOP_PHASE_PLAN §5): move UserSettings +
SettingsRepository into a plain kotlin("jvm") module so the desktop
build reads/writes the SAME preferences keys and .preferences_pb format
the phone uses. Package name org.incido.compose.data.settings kept, so
the Android diff is file moves + one constructor change.
Seam: SettingsRepository now takes an injected DataStore<Preferences>.
Android supplies the preferencesDataStore(name = "incido_settings")
Context-extension store (new AndroidSettingsStore.kt, moved verbatim);
desktop builds it with PreferenceDataStoreFactory.create(
corruptionHandler = ReplaceFileCorruptionHandler, produceFile) — the
Phase-0 API delta (no Context extension on the multiplatform core
artifact). snapshot() keeps runBlocking for startup-only use.
DesktopContainer grows settingsRepository first, mirroring AppContainer
construction order ahead of M3's cipher install. dynamic_color /
use_biometric / block_screenshots keys ride along but have no desktop
UI — hidden, not faked (M3 exit rule).
Verified: ./gradlew assembleDebug (green; :app needed :core:settings on
its classpath — MainActivity reads userSettingsFlow, same pattern as
:core:domain) + ./gradlew :desktopApp:run --args="--data-dir
/tmp/incido-desktop-smoke --self-test --exit-after 6" (RENDER/SELFTEST
sequence intact) + ./gradlew :core:data-jvm:smoke (green).
Phase 1 milestone M1b: a Compose Multiplatform window driven by the same
NoteRepositoryImpl the Android app uses, over its own ObjectBox library.
DesktopContainer mirrors AppContainer's construction order (store,
CipherHolder, repository). Owns its library at
$XDG_DATA_HOME/incido — a separate library per machine,
since ObjectBox is single-writer; the backup file (M2)
is the only bridge to the phone. --data-dir opens
another library, e.g. one pulled off a phone.
Main.kt two panes, save-as-you-type with a 400ms debounce,
favourite toggle. Material 3 defaults on purpose: the
app's theme and screens arrive with the M4 composeApp
conversion, which deletes this stand-in.
Verified headlessly (--self-test drives the same repository calls the "+"
button and the star make, --exit-after auto-closes), against a library
previously written by :core:data-jvm:smoke — i.e. a different module's
generated MyObjectBox, same schema:
RENDER notes=0 selected=null first frame (collectAsState initial value)
RENDER notes=1 selected=1 ObjectBox flow delivered
SELFTEST wrote note id=2 write path through the UI's own calls
RENDER notes=2 selected=2 and it came back through the flow
reopen -> RENDER notes=2 persisted
Gotcha recorded in the findings doc: the first composition always sees the
empty initial value of collectAsState, so anything asserting on note counts
must watch the flow rather than the first frame.
Still synthetic: theme + screens. Not wired yet: settings, encryption (M3),
backup bridge (M2), packaging (M5). assembleDebug verified green.