Repository navigation
feat: give each device a stable identity - #648
Merged
Merged
Conversation
Ketch devices had no identity: the apps keyed them by host and port, and
nothing told a device's own server apart from another one. Each device
now generates a random UUID on its first start and keeps it in
device.json beside its task database (owner-only, written to a temp file
and moved into place). The desktop app, ketch server and
ketch mcp --standalone share the config directory and so one id; each
reads it under the downloads lock. Android keeps it in filesDir, left out
of backups and device transfers, and iOS sets isExcludedFromBackup, so a
restored phone gets an id of its own. It never goes in config.toml.
- config: DeviceStore (missing or unreadable files are replaced, unknown
fields kept), defaultDevicePath(), RemoteConfig.instanceId
- api/core: KetchStatus.instanceId (null from older servers) and
Ketch(instanceId = ...); RemoteKetch passes it through /api/status
- apps: InstanceFactory.instanceId, RemoteConfig.instanceId learned on
connect and saved, and the Add device form refuses a device reporting
this device's id ("<address> is this device")
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
# Conflicts: # AGENTS.md # app/android/src/main/kotlin/com/linroid/ketch/app/android/KetchService.kt # app/desktop/src/main/kotlin/com/linroid/ketch/app/desktop/main.kt # app/shared/src/commonTest/kotlin/com/linroid/ketch/app/FakeInstanceFactory.kt # app/shared/src/iosMain/kotlin/com/linroid/ketch/app/MainViewController.kt # cli/src/main/kotlin/com/linroid/ketch/cli/Main.kt # library/core/src/commonMain/kotlin/com/linroid/ketch/core/Ketch.kt
Contributor
Test Results 2 234 files + 1 2 262 suites +1 58m 7s ⏱️ + 2m 38s Results for commit 5b512ce. ± Comparison against base commit 3d1cf0f. This pull request removes 4 and adds 26 tests. Note that renamed tests count towards both. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #422: a device directory on a public server needs to tell devices apart, hide the device itself and recognize devices already added, and Ketch devices had no identity (the apps key them by host and port). This builds only that identity, as designed in multi-instance-downloads §7.1 (task transfer's F7). Pairings, the mDNS
bootvalue and device hues by id are out of scope.What changes
device.json:DeviceStore(config) generates a random UUID on first start and keeps it indevice.jsonbeside the task database, created owner-only (rw-------) as a temp file moved into place, likeSingleInstance's files. A missing or unreadable file (bad JSON, no or invalid id) is replaced; unknown fields, such as later pairings, are kept. It never goes inconfig.toml.defaultDevicePath()), so the desktop app,ketch serverandketch mcp --standalonereport one id. Each reads it under the downloads lock. Android keeps it infilesDir, excluded inbackup_rules.xmlanddata_extraction_rules.xml. iOS keeps it in Application Support withisExcludedFromBackup. So a restored phone gets an id of its own.KetchStatus.instanceId: String? = null(additive; ABI dump updated) andKetch(instanceId = ...).RemoteKetchpasses it through/api/status, and older servers decode asnull.InstanceFactory.instanceId, also set when another process runs the downloads.RemoteConfig.instanceIdis learned on connect inInstanceManager.learnStatus, asosis, and saved.DeviceConnectorrefuses a device whose probed status reports this device's id (ConnectOutcome.ThisDevice→ConnectProblem.ThisDevice), with the new string translated into every app language./configlisting.UI
The Add device form, after typing this device's own shared server by its LAN address. This is a new state: before, the app added its own server as a second device.
Tests
DeviceStoreTest: the id is created once with owner-only permissions and reused; a missing folder is created; empty, malformed or invalid-id files are replaced; a later version's fields are kept; an id that can't be saved is still returned.RemoteConfigTest(old configs decode with no id, ids round-trip),ServerRoutesTest.status_reportsTheEnginesInstanceId,RemoteKetchTest.status_serverOlderThanIdentities_reportsNoInstanceId.DeviceConnectorTestandConnectFormTest: self-add refused, other ids saved, apps without an id unaffected.InstanceManagerKeepAliveTest: the id is learned and saved, and kept when a device reports none.:config:jvmTest,:library:core:jvmTest,:library:server:test,:library:remote:jvmTest --tests '*RemoteKetchTest*',:app:shared:jvmTest,:library:api:checkKotlinAbi,compileTestKotlinIosSimulatorArm64for config, api, core, remote and app:shared,:app:android:compileDirectDebugKotlin,:cli:compileKotlin,:app:desktop:compileKotlin.