Repository navigation
feat: add hosted diagnostics uploads - #221
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
📝 WalkthroughWalkthroughDiagnostics now support hosted and self-hosted destinations. The change adds hosted upload, privacy filtering, durable evidence cleanup, identity-transition guards, destination-aware UI, and atomic account-session replacement. ChangesHosted diagnostics
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant DiagnosticsViewModel
participant DiagnosticsCoordinator
participant DefaultDiagnosticsUploader
participant PendingReportStore
participant HostedDiagnosticsApi
DiagnosticsViewModel->>DiagnosticsCoordinator: request upload
DiagnosticsCoordinator->>DefaultDiagnosticsUploader: upload report
DefaultDiagnosticsUploader->>PendingReportStore: load or persist sanitized envelope
DefaultDiagnosticsUploader->>HostedDiagnosticsApi: create and upload hosted report
HostedDiagnosticsApi-->>DefaultDiagnosticsUploader: receipt or processing state
DefaultDiagnosticsUploader->>PendingReportStore: record report state
DefaultDiagnosticsUploader-->>DiagnosticsCoordinator: upload decision
DiagnosticsCoordinator-->>DiagnosticsViewModel: processing or completion result
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 65b8c40faf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: dd13bb92ca
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6a6b240a6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 9
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/pairing/PairingAuthPort.kt (1)
52-72: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winRoll back a newly created registry entry when a second server was already registered.
addOrUpdatecan create a new entry. IfpreviousServerId != nullandreplaceAccountSessionfails before it activates the target, the active server is unchanged, so neither recovery branch runs. The new entry stays in the registry as an orphan with no credentials.Do not call
remove(serverId)unconditionally:addOrUpdatemay have updated an existing entry, andremovepurges that server's credential namespace. Record whether the entry existed before the call.🛠️ Proposed rollback fix
val previousServerId = serverRegistry.activeServerId.value + val existedBefore = serverRegistry.entries.value.any { + it.url == serverRegistry.entries.value.firstOrNull { entry -> entry.id == it.id }?.url && + it.id == AndroidServerRegistry.idFor(AndroidServerRegistry.normalizeUrl(serverUrl)) + } val serverId = serverRegistry.addOrUpdate(serverUrl, fetchedName = serverName) try { // Same-server approval is still an A -> B account boundary. // The token manager activates the registry and replaces the // complete profile/token identity inside one destructive gate. tokenManager.replaceAccountSession( serverId = serverId, accessToken = accessToken, refreshToken = refreshToken, expiresIn = expiresIn, ) } catch (error: Throwable) { if (previousServerId != null && serverRegistry.activeServerId.value != previousServerId) { serverRegistry.switchTo(previousServerId) tokenManager.switchActiveServer(previousServerId) - } else if (previousServerId == null) { + } + if (!existedBefore) { serverRegistry.remove(serverId) } throw error }Compute
existedBeforewith a simple id lookup beforeaddOrUpdateifidFor/normalizeUrlaccess is inconvenient here.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@android-shared/src/androidMain/kotlin/org/siloserver/silo/common/pairing/PairingAuthPort.kt` around lines 52 - 72, In the pairing flow around serverRegistry.addOrUpdate and tokenManager.replaceAccountSession, record whether the target server entry existed before addOrUpdate using the available server lookup. On failure, when a prior active server exists and the target entry was newly created, remove the new entry; otherwise restore the previous active server as appropriate. Do not remove entries that existed before, since that would purge their credentials.
🔇 Additional comments (114)
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/di/AndroidModule.kt (1)
189-189: LGTM!androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.kt (1)
1146-1146: LGTM!androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsPrompt.kt (1)
20-23: LGTM!Also applies to: 41-64, 69-77
androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsReportScreen.kt (2)
44-44: LGTM!Also applies to: 58-60, 72-72, 83-83, 101-111, 138-151, 210-210, 234-238, 250-251
162-173: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
⚠️ Unverified finding
Sandbox verification was unavailable.Keep hosted processing in an explicit in-flight state.
When
DiagnosticsUploadDecision.HostedProcessingreturns, this branch clearsuploadingand stores only a notice. The report remains pending while WorkManager polls, soSendbecomes available again. If the worker removes the report afterready,sentShortIdis still null and the screen shows"This report is no longer on this device."instead of the reference confirmation.Store the returned reference, disable
Sendwhile the report is processing, and renderDiagnosticsSentConfirmationonly after the finalUploaded/readytransition. Verify thatDiagnosticsViewModel.uploaddoes not rely on a later callback that this composable cannot retain.The hosted diagnostics design requires the reference to remain visible during
processingand local evidence to remain untilready.docs/README.md (1)
16-19: LGTM!Also applies to: 36-37
docs/superpowers/plans/2026-08-12-android-hosted-diagnostics.md (1)
1-33: LGTM!docs/superpowers/specs/2026-08-12-android-hosted-diagnostics-design.md (1)
1-68: LGTM!androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsSettingsScreen.kt (1)
49-49: LGTM!Also applies to: 68-83, 102-135, 248-280, 313-318
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.kt (1)
1245-1245: LGTM!androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvLoginViewModel.kt (1)
93-97: LGTM!Also applies to: 174-178
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsPromptScreen.kt (1)
44-44: LGTM!Also applies to: 87-87, 120-135
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsReportScreen.kt (1)
24-24: LGTM!Also applies to: 38-60, 72-82, 98-133, 167-168
androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsSettingsScreen.kt (1)
50-50: LGTM!Also applies to: 77-107, 128-159, 186-186, 238-255, 288-333
androidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsStateTest.kt (1)
44-59: LGTM!android-shared/src/androidMain/kotlin/org/siloserver/silo/common/pairing/CompanionPairingCoordinator.kt (1)
126-126: LGTM!Also applies to: 143-154
shared/src/androidMain/kotlin/org/siloserver/silo/network/AndroidServerRegistry.kt (2)
125-133: LGTM!
199-224: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.Confirm the dispatcher for the synchronous preference commit.
commitEditordefaults toSharedPreferences.Editor::commit, which performs blocking disk I/O.commitAccountReplacementandcommitAccountSignOutrun it while holdingmutex, and these paths are reached from sign-in, pairing, and sign-out actions. On encrypted preferences the write also pays key-derivation cost. If any caller runs onDispatchers.Main, this blocks the frame.Move the commit into
withContext(Dispatchers.IO), or confirm every caller is already off the main dispatcher.Also applies to: 242-243
shared/src/androidMain/kotlin/org/siloserver/silo/network/EncryptedTokenManagerImpl.kt (1)
579-589: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that every refresh caller stamps a generation before this silently drops rotated tokens.
This early return discards a successful refresh result. If the server rotates refresh tokens, the client keeps the consumed refresh token and the session cannot recover without a full re-login. The doc block at lines 513-526 names the interceptor refresh fallback and remote-playback identity as scopes that carry neither an epoch nor a stamp.
AuthInterceptorImpl.ktis part of this change but is not supplied here.Confirm that
AuthInterceptorImpland the remote-playback path now build stamped scopes. If a caller cannot stamp, surface the drop instead of returning silently, so the caller can invalidate the session rather than keep a dead refresh token.shared/src/commonMain/kotlin/org/siloserver/silo/network/IdentityTransitionBarrier.kt (2)
17-17: LGTM!Also applies to: 26-37, 124-125
46-56: 🩺 Stability & Availability | 🔴 Critical | 🏗️ Heavy lift
⚠️ Unverified finding
Sandbox verification was unavailable.One non-reentrant mutex now guards both identity mutation and guarded reads.
withCurrentGenerationandchangingsharemutationMutex, andkotlinx.coroutines.Mutexis not reentrant. Two hazards follow:
- Deadlock. Gates installed through
installGaterun inline insidechanging, while the lock is held. If a gate reads or writes a scoped credential,EncryptedTokenManagerImpl.withScopeGenerationcallswithCurrentGenerationand blocks forever. The diagnostics privacy gate in this stack is the likely caller.- Unbounded hold. A guarded block that awaits network I/O blocks every sign-in, sign-out, account replacement, and server removal for its full duration.
IdentityTransitionBarrierTest(lines 101-117) andRegistryPairingAuthPortTest(lines 101-121) both hold the lock across an external signal, which is exactly the hosted-upload fence shape.Confirm that no installed gate touches scoped credentials. Document the reentrancy constraint on
installGate, and state an upper bound for guarded blocks or apply a timeout at the call site.Also applies to: 90-95
shared/src/commonMain/kotlin/org/siloserver/silo/network/TokenManager.kt (1)
56-69: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.The default implementation is not an identity boundary, and nothing enforces the override.
saveTokensopens aSIGN_INtransition only when no credentials exist. For an account swap over existing credentials the default body emits noACCOUNT_REPLACEtransition, so the privacy gates never run and the previous account's diagnostics survive the swap. The KDoc states the override requirement, but any implementation that misses it silently degrades the privacy guarantee.Also, if a caller passes both
serverIdandserverUrl, lines 65-66 perform two separate switches with two transitions.Consider making the boundary explicit rather than optional, for example by throwing
NotImplementedErrorin the default body for implementations that persist credentials, or by keeping the default but asserting a single target argument.shared/src/commonMain/kotlin/org/siloserver/silo/network/TokenManagerImpl.kt (1)
124-138: LGTM!Also applies to: 233-236, 259-261
shared/src/commonTest/kotlin/org/siloserver/silo/network/IdentityTransitionBarrierTest.kt (1)
3-13: LGTM!Also applies to: 70-91, 93-124
shared/src/commonTest/kotlin/org/siloserver/silo/repository/AuthRepositoryAccountReplacementTest.kt (1)
28-75: LGTM!Also applies to: 87-128
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/pairing/RegistryPairingAuthPortTest.kt (1)
5-20: LGTM!Also applies to: 85-128, 130-165, 167-202, 204-241, 243-272, 274-313
shared/src/commonMain/kotlin/org/siloserver/silo/network/AuthInterceptorImpl.kt (1)
283-287: LGTM!Also applies to: 412-423
shared/src/commonMain/kotlin/org/siloserver/silo/network/AuthScopeSnapshot.kt (1)
38-38: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify no positional constructor call breaks from the inserted parameter.
isIdentityGenerationStampedis inserted beforecredentialEpoch. Any caller that passescredentialEpochpositionally now binds the wrong argument type or silently shifts meaning. Confirm every construction site uses named arguments.shared/src/commonMain/kotlin/org/siloserver/silo/network/DiagnosticsRequestScope.kt (1)
6-29: LGTM!Also applies to: 53-61, 70-75
shared/src/commonMain/kotlin/org/siloserver/silo/network/api/DiagnosticsApi.kt (2)
36-47: 🩺 Stability & Availability
⚠️ Unverified finding
Sandbox verification was unavailable.Confirm every non-test
DiagnosticsApiimplementation overrides the authorization overload.The default body drops
authorizationand calls the three-argumentupload. That path readsTokenManagerthroughSiloAuthPlugin. The KDoc states the Android token manager uses the same identity barrier the uploader holds, so a non-overriding implementation on a real transport can block instead of failing fast. Verify that only fakes rely on the default.
62-91: LGTM!shared/src/commonMain/kotlin/org/siloserver/silo/network/api/HostedDiagnosticsApi.kt (2)
59-76: LGTM!
231-241: 🩺 Stability & AvailabilityDo not flag these headers as engine-incompatible. Ktor 3.1.2 permits
Content-Length; OkHttp may replace it with theByteArraybody length, which matches this value.Content-Typeis also accepted, althoughcontentType(...)is the idiomatic API.> Likely an incorrect or invalid review comment.shared/src/commonMain/kotlin/org/siloserver/silo/repository/AuthRepository.kt (3)
31-45: LGTM!
132-141: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that the invitation server becomes active, and that
refreshActiveServerNametargets it.
addOrUpdateregisters the server but this path no longer callsswitchTo/switchActiveServer. The KDoc states the app adopts the server after a successful claim. IfreplaceAccountSessiondoes not switch the active server, the user keeps the previous active server while the new credentials sit in another scope, andrefreshActiveServerNamethen refreshes the wrong entry.
160-166: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that removing
ServerRegistry.signOutstill clears registry-side session state.
logoutnow calls onlytokenManager.signOutCurrentServer(). The registry previously cleared its own per-server state, for exampleprofileId. Confirm thatsignOutCurrentServerperforms that registry cleanup, otherwise a stale profile id survives sign-out.shared/src/androidUnitTest/kotlin/org/siloserver/silo/network/EncryptedTokenManagerScopeGenerationTest.kt (1)
21-40: LGTM!Also applies to: 155-213, 314-318, 331-331, 350-351, 369-385
shared/src/commonTest/kotlin/org/siloserver/silo/network/api/DiagnosticsApiTest.kt (2)
214-235: LGTM!Also applies to: 249-312
237-248: 📐 Maintainability & Code QualityConfirm the pinned kotlinx.coroutines version.
limitedParallelismis stable from version 1.9.0 onward. Add an opt-in if this project uses an earlier version.shared/src/commonTest/kotlin/org/siloserver/silo/network/api/HostedDiagnosticsApiTest.kt (1)
37-144: LGTM!Also applies to: 152-341
README.md (1)
39-39: LGTM!Also applies to: 102-104
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/BreadcrumbJournal.kt (1)
39-41: LGTM!Also applies to: 144-146, 167-167, 220-224
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/CrashCapture.kt (2)
248-257: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that the marker reader tolerates markers without
destination_kind.The writer now always emits
destination_kindinsidebinding. A marker written by the previous app version has no such field. After an app upgrade, the next-launch assembly reads that older marker. If the deserialized binding type declaresdestinationKindwithout a default, parsing of the retained marker fails and the crash evidence is dropped.
62-86: LGTM!Also applies to: 374-393, 400-438
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsArchiveEncoder.kt (4)
31-44: LGTM!
46-91: LGTM!
93-124: LGTM!
8-29: LGTM!android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilder.kt (8)
52-99: LGTM!
101-125: LGTM!
251-256: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.Make hosted crash-identifier stripping recursive.
stripHostedCrashIdentifiersIffilters keys only at the root object. Its siblingsstripHostedDeviceIdentifiers(Lines 276-284) andstripHostedForbiddenIdentifiers(Lines 286-298) recurse into nested objects and arrays. Ifcrash/summary.jsonnestsprocess,process_name, orprocess_hashinside any child object, those keys reach the hosted collector.
HOSTED_CRASH_IDENTIFIER_KEYSvalues are not present inHOSTED_FORBIDDEN_IDENTIFIER_KEYSorNETWORK_ASSIGNMENT_KEYS, so no other filter removes them by key.🔒️ Proposed fix
- private fun JsonElement.stripHostedCrashIdentifiersIf(strip: Boolean): JsonElement = - if (strip && this is JsonObject) { - JsonObject(filterKeys { key -> key.normalizedPrivacyKey() !in HOSTED_CRASH_IDENTIFIER_KEYS }) - } else { - this - } + private fun JsonElement.stripHostedCrashIdentifiersIf(strip: Boolean): JsonElement = + if (strip) stripHostedCrashIdentifiers() else this + + private fun JsonElement.stripHostedCrashIdentifiers(): JsonElement = when (this) { + is JsonObject -> JsonObject( + entries + .filterNot { (key, _) -> key.normalizedPrivacyKey() in HOSTED_CRASH_IDENTIFIER_KEYS } + .associate { (key, value) -> key to value.stripHostedCrashIdentifiers() }, + ) + is JsonArray -> JsonArray(map { value -> value.stripHostedCrashIdentifiers() }) + is JsonPrimitive -> this + }
150-206: LGTM!
208-231: LGTM!
386-395: 🔒 Security & Privacy
⚠️ Unverified finding
Sandbox verification was unavailable.Confirm that canonical UUIDs must pass through unchanged.
Line 387 returns the original value when it already matches
CANONICAL_UUID.capture_session_idand the log-lineruntoken are the two callers, and both normally hold canonical UUIDs. For those values the hashing branch never runs, sohostedAnonymousUuidonly lowercases the local identifier.If the intent is shape normalization for already-opaque per-capture identifiers, the code is correct. If the intent is to prevent the hosted collector from receiving the same identifier that local state holds, the early return defeats it.
State the intended policy in a comment, or hash unconditionally.
400-478: 🚀 Performance & Scalability
⚠️ Unverified finding
Sandbox verification was unavailable.Confirm that hosted sanitization never runs on the main thread.
sanitizeHostedTextapplies about 25 regex passes plus NFKC normalization to every string.sanitizeHostedStringscalls it for each JSON string value, andredactJsonLinescalls it for each log line.logs.jsonlis bounded at 256 KB, so a hosted bundle can execute tens of thousands of regex passes during onebuildcall.
hasUnsafeHostedResiduethen repeats a second pass of about 12 patterns over the result.Confirm that
buildandreframeHostedexecute on a background dispatcher. If a caller invokes them from a UI or WorkManager main-thread context, this blocks.
300-384: LGTM!Also applies to: 480-604, 606-732, 734-891, 893-912, 914-1207
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsFileDurability.kt (1)
8-37: LGTM!android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsIdentityResolver.kt (3)
86-88: 🔒 Security & Privacy
⚠️ Unverified finding
Sandbox verification was unavailable.
copy()does not re-apply thesourceProfileIddefault.
sourceProfileIddefaults to theprofileIdparameter. Kotlin applies that default only at construction.DiagnosticsCaptureContext.copy(profileId = newProfile)keeps the previoussourceProfileId.
sourceProfileIdgates privacy decisions, so a stale value after a profile transition binds the context to the wrong source profile.
100-107: 🔒 Security & Privacy
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that a hosted resolver overrides
resolveForCaptureandresolveForUpload.Both new methods delegate to
resolve, andDefaultDiagnosticsIdentityResolverdoes not override either one. As written, capture-time and upload-time attestation are identical to the existing resolution path.The PR objectives state that hosted diagnostics verify the live collector identity before a new capture and re-attest the source-server account before a first upload. Those checks must live in an overriding implementation. Confirm that such an override exists and that call sites use the specific methods rather than
resolve.
173-173: LGTM!Also applies to: 187-187
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRedactor.kt (1)
59-74: LGTM!Also applies to: 120-131, 170-176
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRunLedger.kt (2)
111-125: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that only one process writes the run ledger.
temporaryFile()returns a fixed path,run-ledger.json.tmp. Themutexserializes writers inside one process only. If a second process writes the ledger, both can open the same temporary file, and the atomic rename then publishes interleaved bytes.Confirm that
DiagnosticsRunLedgeris constructed in a single process. If the app declares a remote-process component that touches diagnostics, use a per-writer unique temporary name.
25-25: LGTM!Also applies to: 34-36, 64-64, 91-93
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStore.kt (8)
391-393: 🩺 Stability & Availability
⚠️ Unverified finding
Sandbox verification was unavailable.
checkNotNull(allEvidencePurger)can throw on the upgrade path.
allEvidencePurgeris an optional constructor parameter (Line 82). This branch runs once per device during the legacy-index upgrade, when a server is removed and no index entry exists. If any construction site omits the purger,purgeLocalServerthrowsIllegalStateExceptionat exactly that moment, and the migration flag on Line 401 is never set. The next server removal repeats the failure.Confirm every production construction site supplies
allEvidencePurger. If the parameter must stay optional, make the legacy branch fail soft and leave the migration flag unset.
111-164: LGTM!
231-240: 🔒 Security & Privacy
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that callers compare the hosted binding owner before overwriting it.
cacheHostedBindingOwneroverwrites any existing owner for the samelocalServerIdwithout comparison.hostedBindingOwneronly reads the value. The account-ownership fence therefore depends entirely on the caller reading first and rejecting a mismatch.Confirm the caller performs that comparison and refuses hosted upload when the stored owner differs. If the store is meant to own the invariant, reject a conflicting owner here instead.
216-229: LGTM!
259-271: LGTM!Also applies to: 288-314
321-360: LGTM!
378-404: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
⚠️ Unverified finding
Sandbox verification was unavailable.Removing an unindexed server can erase another server's retained reports.
The legacy branch triggers whenever
byLocalServerIdhas no entry forlocalServerId,fallbackBindingis null, andBINDING_INDEX_MIGRATION_COMPLETE_KEYis false. It then purges all diagnostics evidence and everydiagnostics.binding.*key for every server.That condition does not identify an upgraded device. It also matches a device that simply never indexed this server:
- The index entry exists only after
cacheContextruns with a non-blanklocalServerId(Lines 264-270). A server that never produced a diagnostics context has no entry.storeBindingIndexremovesBINDING_INDEX_KEYentirely when the map becomes empty (Lines 435-436), so an emptied entry is indistinguishable from a never-created one.Sequence that loses data: the user adds server A and server B, collects diagnostics only on B, then removes A.
purgeLocalServer("A")finds no entry for A, sees the migration flag unset, and deletes B's retained account reports.Scope the legacy cleanup to devices that actually predate the index. Seed
BINDING_INDEX_MIGRATION_COMPLETE_KEYtotrueon first run of a build that always writes the index, and require positive evidence of legacy state before the wipe.
362-377: LGTM!Also applies to: 405-415, 432-451, 471-477, 492-498
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRuntime.kt (2)
21-21: LGTM!
48-56: LGTM!android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPresentationModels.kt (1)
25-25: 🗄️ Data Integrity & Integration
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that every
DiagnosticsReportSummaryconstruction setsdestinationKindexplicitly.
DiagnosticsReportSummary.destinationKinddefaults toSELF_HOSTED, whileDiagnosticsUiState.destinationKinddefaults toHOSTED. The default on the summary is a silent fallback. If any mapping site omits the argument for a hosted report, the report screen shows self-hosted retention and destination text for a hosted upload.Consider removing the default on
DiagnosticsReportSummary.destinationKindso the compiler enforces the value at each construction site.Also applies to: 61-63
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPrivacyBarrier.kt (1)
13-18: 🩺 Stability & Availability
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that no code path acquires this barrier twice.
kotlinx.coroutines.sync.Mutexis not reentrant.DiagnosticsPrivacyBarrieris a Koinsingle, soDefaultDiagnosticsCoordinatorandDefaultDiagnosticsUploadershare one instance. If the coordinator holds a lease withwithRevocationorwithTransportand then callsuploader.upload(...), the uploader'sprivacyBarrier.withTransport { ... }suspends forever and the diagnostics actor deadlocks.The uploader code in this PR never nests leases within itself. The coordinator source is not included here, so the combined path needs confirmation.
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsModule.kt (2)
38-38: LGTM!Also applies to: 289-298
66-115: 🩺 Stability & Availability
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that resolving
HostedDiagnosticsCapabilitiesStorecannot create a Koin cycle.The factory at Line 68 calls
get<DiagnosticsSettingsStore>()eagerly inside the definition body.DiagnosticsSettingsStoreat Line 257 depends on both purgers, which depend onDiagnosticsCaptureController. If any of those transitively resolveHostedDiagnosticsCapabilitiesStore,HostedDiagnosticsCapabilitiesRepository, orDiagnosticsSettingsStoreagain, Koin throws a definition-cycle error at first resolution rather than at module load.The definitions shown here do not close the loop. The capture controller, log buffer, file logger, and breadcrumb journal sources are not included in this prompt.
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploader.kt (3)
125-142: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.The hosted status-poll path returns before the retry-deadline gate.
Lines 125-137 poll a hosted report whenever
hostedRemoteShortId != null. The retry-deadline check is at Line 138, after thatreturn. So a hosted report in PROCESSING never honours the deadline thatmapHostedErrorandpollHostedStatuspersist. Every scheduled attempt issues a fresh status request, and a collector that answers429withRetry-Aftergets ignored.There is a second inconsistency.
mapHostedErrorwrites the deadline per report withsetRetryAfterDeadlineForReport(report.id, report.binding.binding, ...)at Line 797, but Line 138 reads it per binding withretryAfterDeadline(report.binding.binding). If the store keys those two values differently, the deadline is never observed for either destination.Move the deadline gate above the poll branch.
🐛 Proposed fix
val report = reports.load(reportId) ?: return DiagnosticsUploadDecision.KeptInvalid + val retryDeadline = reports.retryAfterDeadline(report.binding.binding) + if (retryDeadline != null && retryDeadline > nowMs()) return DiagnosticsUploadDecision.KeptRetryable if ( report.binding.destinationKind == DiagnosticsDestinationKind.HOSTED && report.state.hostedRemoteShortId != null ) { return try { pollHostedStatus(report, operationGeneration) } catch (cancelled: CancellationException) { throw cancelled } catch (_: Throwable) { markRetryable(report.id, "status_unavailable") DiagnosticsUploadDecision.KeptRetryable } } - val retryDeadline = reports.retryAfterDeadline(report.binding.binding) - if (retryDeadline != null && retryDeadline > nowMs()) return DiagnosticsUploadDecision.KeptRetryable
381-386: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.The self-hosted success path deletes evidence before recording the receipt.
Line 381 calls
reports.delete(report.id). Line 382 then records the sent entry insiderunCatching. IfsentRecorder.recordfails, the report is already gone and the sent-history row is lost with no retry path.The hosted path solves this with one atomic store call,
reports.recordHostedReadyAndDelete(report.id, report.binding)at Line 628. Consider an equivalent atomic API for self-hosted, or record the receipt before the delete.
1038-1057: LGTM!Also applies to: 1059-1075
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/ExitInfoCollector.kt (3)
539-543: 🔒 Security & Privacy
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that
DiagnosticsRunLedgerpersistsdestinationKinddurably.The hosted redactions at Lines 539-543 and Lines 557-561 both branch on
binding.destinationKind. That value reaches the manifest only throughDiagnosticsRunRecord.destinationKindat Line 589.
ExitInfoCollectorruns after a process restart. If the ledger record does not persistdestinationKind, the rebuilt binding defaults toSELF_HOSTED, both hosted branches are skipped, and a hosted crash report shipsprofileIdandplaybackSessionIdsto the hosted collector.Also applies to: 557-561, 589-589
296-305: LGTM!Also applies to: 336-358
204-207: 📐 Maintainability & Code QualityKeep the current link probe.
Files.isSymbolicLink(Path)requires Android API 26, while this project supports API 24.> Likely an incorrect or invalid review comment.android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/BreadcrumbJournalTest.kt (1)
16-16: LGTM!Also applies to: 29-29, 60-68, 81-97
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/CrashCaptureTest.kt (1)
88-118: LGTM!Also applies to: 185-192, 213-289, 291-401, 476-496
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilderTest.kt (2)
63-63: 📐 Maintainability & Code Quality
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that the self-hosted gzip OS byte is stable across the toolchain.
Line 63 asserts byte 9 of the self-hosted gzip stream equals
0xff. Byte 9 is the gzip OS field.java.util.zip.GZIPOutputStreamwrites a fixed header whose OS byte is0, so0xffmust come from a different encoder path inDiagnosticsArchiveEncoder.If the value comes from a platform default rather than an explicit write, a JDK or Android toolchain bump can change it and break this assertion. The hosted assertion at Line 79 is safe because the collector-canonical origin is written explicitly.
68-82: LGTM!Also applies to: 140-192, 194-272, 274-309, 311-425, 427-508, 510-627, 661-738, 740-795, 813-845, 910-912
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsCoordinatorTest.kt (3)
1041-1044: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.This comparison depends on the order that
hostedDeletionIntents()returns.Line 1042 sorts the expected ids and compares against
fixture.reports.hostedDeletionIntents()without sorting the actual value. The test passes only if the store happens to return ascending ids.Line 1003 in the same file compares the same accessor with
.toSet(). Use one approach. If the store does not document an order, compare sets.💚 Proposed fix
assertEquals( - listOf(pending.id, processing.id, ready.id).sorted(), - fixture.reports.hostedDeletionIntents(), + setOf(pending.id, processing.id, ready.id), + fixture.reports.hostedDeletionIntents().toSet(), )
1674-1683: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.The fixture does not wire
allEvidencePurger, so no test covers that purge path.
DiagnosticsModuleconstructsDiagnosticsSettingsStorewith bothbindingPurgerandallEvidencePurger. This fixture passes onlybindingPurger, which meansallEvidencePurgerhas a default.DiagnosticsAllEvidencePurgerdeletes every report, clears the run ledger, and purges all crash markers. No test in this file observes it.Add a recording
allEvidencePurgerto the fixture and one test that asserts it runs, including the failure-then-retry path that the binding purger already covers at Lines 417-453.
72-72: LGTM!Also applies to: 76-297, 300-574, 577-834, 891-1012, 1015-1039, 1053-1196, 1199-1359, 1362-1557, 1594-1602, 1644-1673, 1692-1740, 1746-1903, 1912-1915
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsCoordinator.kt (3)
919-919: 🩺 Stability & Availability
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that
GuardedValueis declared only once.The reviewed snippet shows the same declaration twice at this position. Two top-level declarations with the same name in one file do not compile.
155-167: 🩺 Stability & Availability
⚠️ Unverified finding
Sandbox verification was unavailable.Confirm that
targetServerIdis always present forSERVER_REMOVEandACCOUNT_REPLACE.
requireNotNullruns inside the synchronous identity gate and insideprivacyBarrier.withRevocation. If a producer emits either transition withouttargetServerId, this throws inside the identity mutation path and can abort the transition. Verify that every producer setstargetServerIdfor these kinds.
64-70: LGTM!Also applies to: 125-154, 242-294, 382-473, 650-674, 697-800, 818-828
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/PendingReportStore.kt (1)
16-22: LGTM!Also applies to: 45-47, 68-98, 100-133, 212-293, 354-495, 511-627, 660-675, 760-819, 878-902
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnostics.kt (2)
110-126: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.Move the blocking
commit()calls off the caller's dispatcher.
saveandcleararesuspendfunctions, butSharedPreferences.Editor.commit()writes to disk synchronously on the calling thread. If any caller runs onDispatchers.Main, this blocks the UI thread. Wrap both bodies inwithContext(Dispatchers.IO). The same applies toload, because the firstgetStringcall can trigger the initial disk load.♻️ Proposed refactor
- override suspend fun save(credentials: HostedDiagnosticsCredentials) { + override suspend fun save(credentials: HostedDiagnosticsCredentials) = withContext(Dispatchers.IO) { check( encryptedPreferences.edit() .putString(INSTALLATION_ID_KEY, credentials.installationId) .putString(INSTALLATION_TOKEN_KEY, credentials.installationToken) .commit(), ) { "unable to persist hosted diagnostics credentials" } }Apply the same change to
clearandload, and add thekotlinx.coroutines.Dispatchersandkotlinx.coroutines.withContextimports.Run the following script to check the calling context:
23-32: LGTM!Also applies to: 44-82, 171-193, 195-218, 220-320, 322-352, 402-439
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStoreTest.kt (1)
12-18: LGTM!Also applies to: 81-87, 101-109, 131-165, 167-193, 195-247, 249-261, 275-278
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsTestFileOperations.kt (1)
1-14: LGTM!android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploaderTest.kt (1)
3-6: LGTM!Also applies to: 27-62, 139-198, 326-326, 382-840, 842-937, 961-996, 1020-1035, 1054-1243, 1266-1287
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/ExitInfoCollectorTest.kt (1)
3-6: LGTM!Also applies to: 17-17, 144-224, 226-299, 301-314, 316-327, 329-358, 398-418
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsTest.kt (1)
28-45: LGTM!Also applies to: 47-82, 86-102, 116-131, 133-178
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/PendingReportStoreTest.kt (1)
4-5: LGTM!Also applies to: 114-173, 207-277, 279-365, 367-461, 463-586, 588-670, 727-810, 812-836, 876-880
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsFileLogger.kt (2)
130-144: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
⚠️ Unverified finding
Sandbox verification was unavailable.
reconcileStoredEvidencecan delete a capture directory thatstarthas just created.
startcreatesgeneration-$generationat line 62 and launches the writer at line 71, but it publishesactiveonly at line 81.reconcileStoredEvidenceis public and readsactive.get().FileDiagnosticsCaptureController.reconcileStoredEvidence()exposes it to the coordinator, so it can run on another coroutine. If it runs inside that window,activeDirectoryisnull, so line 142 deletes the wholeroottogether with the new generation directory. The writer then fails and the capture loses its evidence.Serialize reconciliation against capture start. One option is a dedicated lock that both
startandreconcileStoredEvidencehold. Another option is to publish a "starting" marker inactivebeforemkdirs.Run the following script to list the callers that can invoke reconciliation concurrently with
start:
37-39: LGTM!Also applies to: 118-123, 147-153
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsManualCapture.kt (1)
157-172: LGTM!Also applies to: 193-193, 210-214
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsViewModel.kt (1)
27-30: LGTM!Also applies to: 65-65, 87-87
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploadWorker.kt (1)
21-22: 🩺 Stability & Availability
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that
coordinator.start()is idempotent across worker executions.The worker calls
coordinator.start()on every execution, and WorkManager can execute this worker many times throughResult.retry(). Ifstartinstalls log sinks, registers observers, or launches collectors, repeated calls can duplicate that state.Run the following script to inspect the coordinator lifecycle:
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsFileLoggerTest.kt (2)
106-120: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
⚠️ Unverified finding
Sandbox verification was unavailable.The purge test may assert on cleanup that the constructor already performed.
The constructor runs
reconcileStoredEvidence()at DiagnosticsFileLogger line 51. That call deletesroot/raw.jsonlbeforepurgeStoredEvidence()runs, so theassertFalse(root.exists())assertion does not prove that purge removed the raw bytes. The test name states that it does.Write
raw.jsonlafter the logger construction, then callpurgeStoredEvidence(). The assertions then cover the purge path.♻️ Proposed reordering
val noBackup = temporaryFolder.newFolder("purge-fsync") val root = noBackup.resolve("client-diagnostics/logs") - assertTrue(root.mkdirs()) - root.resolve("raw.jsonl").writeText("private") val logger = DiagnosticsFileLogger( noBackupFilesDir = noBackup, writerDispatcher = StandardTestDispatcher(testScheduler), directorySync = { error("injected fsync failure") }, ) + assertTrue(root.mkdirs()) + root.resolve("raw.jsonl").writeText("private") assertFailsWith<IllegalStateException> { logger.purgeStoredEvidence() } assertFalse(root.exists())Run the following script to confirm the deletion and sync order inside the strict helper:
24-24: LGTM!Also applies to: 50-50, 73-73, 93-93, 122-139, 141-172, 174-197
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPlaybackSessionTrackerTest.kt (1)
61-69: LGTM!android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPrivacyIntegrationTest.kt (2)
144-147: 🎯 Functional Correctness
⚠️ Unverified finding
Sandbox verification was unavailable.Verify that
DiagnosticsPlaybackSessionTrackerexposesrecord.Line 146 calls
record(...)on the tracker insideapply.DiagnosticsPlaybackSessionTrackerTestrecords only throughtracker.recording().record(...). If the tracker exposes norecordmember, this file fails to compile.Run the following script to confirm the tracker API and the
DiagnosticsCaptureContextparameters used at lines 132-143:
39-44: LGTM!Also applies to: 78-120, 202-261, 272-288, 290-358, 363-387, 397-397, 408-413, 425-425, 444-444, 465-476, 507-507, 530-542, 556-558
android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRedactorTest.kt (1)
67-82: LGTM!android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRunLedgerTest.kt (1)
9-9: LGTM!Also applies to: 22-27, 39-43, 57-58, 73-77, 87-107, 109-138
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 019d1372-3c06-42b5-835d-9ac3b41287b9
📒 Files selected for processing (73)
README.mdandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/BreadcrumbJournal.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/CrashCapture.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsArchiveEncoder.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilder.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsCoordinator.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsFileDurability.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsFileLogger.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsIdentityResolver.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsManualCapture.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsModule.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPresentationModels.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPrivacyBarrier.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRedactor.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRunLedger.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRuntime.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStore.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploadWorker.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploader.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsViewModel.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/ExitInfoCollector.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnostics.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/PendingReportStore.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/pairing/CompanionPairingCoordinator.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/pairing/PairingAuthPort.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/BreadcrumbJournalTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/CrashCaptureTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilderTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsCoordinatorTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsFileLoggerTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPlaybackSessionTrackerTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsPrivacyIntegrationTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRedactorTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsRunLedgerTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStoreTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsTestFileOperations.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploaderTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/ExitInfoCollectorTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/PendingReportStoreTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/pairing/RegistryPairingAuthPortTest.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/di/AndroidModule.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/downloads/AppWorkerFactory.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/navigation/AppNavigation.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsPrompt.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsReportScreen.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsSettingsScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/navigation/TvAppNavigation.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvLoginViewModel.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsPromptScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsReportScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsSettingsScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/watchnext/TvWorkerFactory.ktandroidTvApp/src/androidUnitTest/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsStateTest.ktdocs/README.mddocs/superpowers/plans/2026-08-12-android-hosted-diagnostics.mddocs/superpowers/specs/2026-08-12-android-hosted-diagnostics-design.mdshared/src/androidMain/kotlin/org/siloserver/silo/network/AndroidServerRegistry.ktshared/src/androidMain/kotlin/org/siloserver/silo/network/EncryptedTokenManagerImpl.ktshared/src/androidUnitTest/kotlin/org/siloserver/silo/network/EncryptedTokenManagerScopeGenerationTest.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/AuthInterceptorImpl.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/AuthScopeSnapshot.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/DiagnosticsRequestScope.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/IdentityTransitionBarrier.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/TokenManager.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/TokenManagerImpl.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/api/DiagnosticsApi.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/api/HostedDiagnosticsApi.ktshared/src/commonMain/kotlin/org/siloserver/silo/repository/AuthRepository.ktshared/src/commonTest/kotlin/org/siloserver/silo/network/IdentityTransitionBarrierTest.ktshared/src/commonTest/kotlin/org/siloserver/silo/network/api/DiagnosticsApiTest.ktshared/src/commonTest/kotlin/org/siloserver/silo/network/api/HostedDiagnosticsApiTest.ktshared/src/commonTest/kotlin/org/siloserver/silo/repository/AuthRepositoryAccountReplacementTest.kt
💤 Files with no reviewable changes (2)
- androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/watchnext/TvWorkerFactory.kt
- androidApp/src/androidMain/kotlin/org/siloserver/silo/android/downloads/AppWorkerFactory.kt
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 990dd7f95e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (4)
android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsModule.kt (1)
223-256: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract the shared purge-attempt logic.
DiagnosticsBindingPurgerandDiagnosticsAllEvidencePurgerrepeat the same first-failure-preservingattempthelper and the same live-capture step. Extract one private helper in this module and call it from both singletons. This keeps the two purge paths from diverging later.♻️ Suggested shape
+private suspend inline fun purgeAll( + includeLiveCapture: Boolean, + capture: DiagnosticsCaptureController, + steps: List<suspend () -> Unit>, +) { + var failure: Throwable? = null + suspend fun attempt(block: suspend () -> Unit) { + runCatching { block() }.onFailure { error -> if (failure == null) failure = error } + } + if (includeLiveCapture) attempt { capture.purgeCurrentEvidence() } + steps.forEach { step -> attempt(step) } + failure?.let { throw it } +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsModule.kt` around lines 223 - 256, Extract the duplicated first-failure-preserving attempt logic and conditional capture.purgeCurrentEvidence() step from DiagnosticsBindingPurger and DiagnosticsAllEvidencePurger into one private module helper. Have both singleton handlers reuse that helper while retaining their existing report, ledger, and marker purge operations and final failure propagation.androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsReportScreen.kt (1)
143-152: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winSignal notice severity with more than color.
The notice distinguishes success from failure only by text color. Users with low vision or color-vision deficiency, and screen-reader users, get no severity cue. Add an icon or a leading label so the severity is conveyed non-visually.
♻️ Example
uploadNotice?.let { notice -> Text( - notice, + if (uploadNoticeIsError) "Error: $notice" else notice, color = if (uploadNoticeIsError) { MaterialTheme.colorScheme.error } else { MaterialTheme.colorScheme.primary }, ) }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsReportScreen.kt` around lines 143 - 152, Update the uploadNotice rendering in DiagnosticsReportScreen so success and error severity are conveyed non-visually, not only through the color selected by uploadNoticeIsError. Add an appropriate leading icon or explicit accessible label tied to the same severity state, while preserving the existing notice text and color styling.android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsDeletionWorker.kt (1)
21-51: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winRun the blocking store calls on the IO dispatcher.
PendingReportStoreexposes non-suspend methods, andFilePendingReportStoreperforms synchronized file reads, writes, and directory syncs.CoroutineWorker.doWorkruns onDispatchers.Defaultby default, so these calls occupy a CPU-bound pool thread for disk I/O. Wrap the body inwithContext(Dispatchers.IO), or overridecoroutineContextin the worker.♻️ Proposed change
- override suspend fun doWork(): Result { + override suspend fun doWork(): Result = withContext(Dispatchers.IO) { var completedAll = true val reportIds = try { reports.hostedDeletionIntents() } catch (cancelled: CancellationException) { throw cancelled } catch (_: Throwable) { - return Result.retry() + return@withContext Result.retry() } @@ - return if (completedAll) Result.success() else Result.retry() + if (completedAll) Result.success() else Result.retry() }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsDeletionWorker.kt` around lines 21 - 51, Update HostedDiagnosticsDeletionWorker.doWork so the full blocking workflow, including hostedDeletionIntents, deleter.delete, and completeHostedDeletion, executes within withContext(Dispatchers.IO); preserve the existing cancellation propagation and retry/success behavior.android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStoreTest.kt (1)
261-269: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRecord the flag and assert outside the purger lambda.
assertTrue(includeLiveCapture)runs inside the callback thatDiagnosticsSettingsStoreinvokes. If the store wraps purger invocation in failure handling, theAssertionErrorbecomes a purge failure instead of a clear test failure, and the diagnosis points at the wrong cause. Capture the value and assert it after the action.♻️ Proposed change
var allEvidencePurges = 0 +val liveCaptureFlags = mutableListOf<Boolean>() val store = DiagnosticsSettingsStore( dataStore = dataStore, bindingPurger = RecordingBindingPurger(), allEvidencePurger = DiagnosticsAllEvidencePurger { includeLiveCapture -> - assertTrue(includeLiveCapture) + liveCaptureFlags += includeLiveCapture allEvidencePurges += 1 }, ) @@ assertEquals(1, allEvidencePurges) +assertEquals(listOf(true), liveCaptureFlags)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStoreTest.kt` around lines 261 - 269, Update the DiagnosticsAllEvidencePurger callback in DiagnosticsSettingsStoreTest to record the includeLiveCapture value and increment the purge count without asserting inside the lambda. After the store action completes, assert the recorded value externally so assertion failures are reported directly by the test rather than treated as purge failures.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvLoginViewModel.kt`:
- Around line 185-199: Update the device-login catch block surrounding
replaceAccountSession in TvLoginViewModel so post-commit failures preserve the
successful authentication state by setting loginSuccess/authCompleted
consistently with the credential-login path, while still stopping loading and
reporting the error without instructing the user to retry an already-committed
session.
---
Nitpick comments:
In
`@android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsModule.kt`:
- Around line 223-256: Extract the duplicated first-failure-preserving attempt
logic and conditional capture.purgeCurrentEvidence() step from
DiagnosticsBindingPurger and DiagnosticsAllEvidencePurger into one private
module helper. Have both singleton handlers reuse that helper while retaining
their existing report, ledger, and marker purge operations and final failure
propagation.
In
`@android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsDeletionWorker.kt`:
- Around line 21-51: Update HostedDiagnosticsDeletionWorker.doWork so the full
blocking workflow, including hostedDeletionIntents, deleter.delete, and
completeHostedDeletion, executes within withContext(Dispatchers.IO); preserve
the existing cancellation propagation and retry/success behavior.
In
`@android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStoreTest.kt`:
- Around line 261-269: Update the DiagnosticsAllEvidencePurger callback in
DiagnosticsSettingsStoreTest to record the includeLiveCapture value and
increment the purge count without asserting inside the lambda. After the store
action completes, assert the recorded value externally so assertion failures are
reported directly by the test rather than treated as purge failures.
In
`@androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsReportScreen.kt`:
- Around line 143-152: Update the uploadNotice rendering in
DiagnosticsReportScreen so success and error severity are conveyed non-visually,
not only through the color selected by uploadNoticeIsError. Add an appropriate
leading icon or explicit accessible label tied to the same severity state, while
preserving the existing notice text and color styling.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f4e3bd58-2521-485a-87bf-5d2a18fc3099
📒 Files selected for processing (33)
README.mdandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilder.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsCoordinator.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsManualCapture.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsModule.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStore.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploadWorker.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploader.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsViewModel.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnostics.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsDeletionWorker.ktandroid-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/PendingReportStore.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilderTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsCoordinatorTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStoreTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploaderTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsTest.ktandroid-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/PendingReportStoreTest.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/downloads/AppWorkerFactory.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsPrompt.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsReportScreen.ktandroidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsSettingsScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/auth/TvLoginViewModel.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsPromptScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsReportScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsSettingsScreen.ktandroidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/watchnext/TvWorkerFactory.ktdocs/superpowers/specs/2026-08-12-android-hosted-diagnostics-design.mdshared/src/androidMain/kotlin/org/siloserver/silo/network/AndroidServerRegistry.ktshared/src/androidMain/kotlin/org/siloserver/silo/network/EncryptedTokenManagerImpl.ktshared/src/androidUnitTest/kotlin/org/siloserver/silo/network/EncryptedTokenManagerScopeGenerationTest.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/IdentityTransitionBarrier.ktshared/src/commonMain/kotlin/org/siloserver/silo/network/TokenManagerImpl.kt
🚧 Files skipped from review as they are similar to previous changes (22)
- androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsPromptScreen.kt
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsViewModel.kt
- README.md
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploadWorker.kt
- docs/superpowers/specs/2026-08-12-android-hosted-diagnostics-design.md
- shared/src/androidMain/kotlin/org/siloserver/silo/network/AndroidServerRegistry.kt
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsManualCapture.kt
- android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/PendingReportStoreTest.kt
- shared/src/commonMain/kotlin/org/siloserver/silo/network/TokenManagerImpl.kt
- android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilderTest.kt
- shared/src/commonMain/kotlin/org/siloserver/silo/network/IdentityTransitionBarrier.kt
- androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsPrompt.kt
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsSettingsStore.kt
- shared/src/androidMain/kotlin/org/siloserver/silo/network/EncryptedTokenManagerImpl.kt
- androidApp/src/androidMain/kotlin/org/siloserver/silo/android/ui/screens/settings/diagnostics/DiagnosticsSettingsScreen.kt
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsBundleBuilder.kt
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnostics.kt
- androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsSettingsScreen.kt
- android-shared/src/androidUnitTest/kotlin/org/siloserver/silo/common/diagnostics/HostedDiagnosticsTest.kt
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsUploader.kt
- androidTvApp/src/androidMain/kotlin/org/siloserver/silo/tv/ui/screens/settings/diagnostics/TvDiagnosticsReportScreen.kt
- android-shared/src/androidMain/kotlin/org/siloserver/silo/common/diagnostics/DiagnosticsCoordinator.kt
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 859adf79a5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bd3d758108
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| is DiagnosticsUploadDecision.HostedProcessing -> { | ||
| uploadNoticeIsError = false | ||
| uploadNotice = uploadKeptMessage(decision) | ||
| } |
There was a problem hiding this comment.
Expose persisted processing reference IDs
Fresh evidence after the prior processing-state fix is that DiagnosticsReportSummary still omits hostedRemoteShortId, while this branch exposes the reference only through a remember-backed notice. If the user leaves this screen or the process is recreated while the report remains PROCESSING, the rebuilt details show the processing state but no longer display or allow copying the collector reference; the TV screen follows the same pattern. Populate the reference from the persisted report state rather than only from the upload callback.
Useful? React with 👍 / 👎.
Summary
Silo Diagnosticsdestination to Android phone and TV without adding any Silo Server dependencyValidation
Related changes
No production collector deployment is included in this PR.
Summary by CodeRabbit
New Features
Privacy & Reliability
Documentation