Repository navigation
SCA-103: add macOS failure diagnostic context - #10523
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61092337bc
ℹ️ 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".
| if let context { | ||
| scope.setContext(value: context.values, key: "failure_diagnostics") |
There was a problem hiding this comment.
Preserve storage context when filtering transient errors
When a storage caller passes ENOSPC, EDQUOT, EROFS, or the corresponding Cocoa wrapper, isNonActionableTransient(error) returns earlier in logError, before this new context is attached. recordBetaLogError also receives no context, so the volume, file-size, and termination diagnostics are discarded in precisely the full/read-only-disk scenarios these call sites are intended to diagnose. Preserve the bounded context in an allowed diagnostic trail or event even when the underlying error is noise-filtered.
AGENTS.md reference: desktop/macos/AGENTS.md:L41-L43
Useful? React with 👍 / 👎.
| logError( | ||
| "Agent runtime bridge failed to start", | ||
| context: bridgeStartFailureContext(failure)) |
There was a problem hiding this comment.
Avoid emitting a second bridge-start Sentry event
Every failed startup now emits this logError, then the propagated BridgeError reaches ChatProvider.presentBridgeStartupFailure, which unconditionally emits another logError at ChatProvider.swift:1666. Neither error is classified as transient, and the deduplication messages differ, so a single failed attempt creates two separate Sentry captures (under different diagnostic areas). Attach the context to the existing surface-level report or otherwise ensure only one incident is emitted.
Useful? React with 👍 / 👎.
| "binary_present_checked": true, | ||
| "binary_present": binaryPresent, |
There was a problem hiding this comment.
Report whether the binary check actually ran
For startup failures occurring before findNodeBinary and findBridgeScript are evaluated—such as an authorization failure or an unknown harness mode—the state is initialized with startupBinaryPresent = false, but this diagnostic always claims the check ran. Those failures are therefore reported as a confirmed missing binary even though no binary probe occurred; track a separate checked flag and set it only when the probes execute.
Useful? React with 👍 / 👎.
|
@cursor address review comments and fix failing IC |
|
Addressed all three Codex review items and the CI gaps that were blocking the PR. The branch is merged; summary below. Review fixes
CI fixes
Commits
Swift unit tests were not run on this Linux VM (no Xcode). PR #10523 is merged; Desktop Swift jobs on the final SHA were disrupted by superseded/cancelled runs, so if you need a clean post-merge Swift CI signal, re-run Desktop Swift Build & Tests on |
- Preserve storage failure_diagnostics on transient errors via beta trail - Emit one bridge-start Sentry event from ChatProvider with pending context - Track binary_present_checked only after node/bridge probes run - Add e2e flow covers and unreleased changelog fragment Co-authored-by: David Zhang <[email protected]>
73a11a7 to
fe5253d
Compare
…st contracts Three pre-existing Desktop Swift test failures from #10523 (chore: add storage and bridge diagnostics) were never caught on main because the Desktop Swift CI path-filter skips the build for non-Swift commits. PR #10530's Swift compile fixes trigger the full suite, exposing them. Fixes: 1. AgentRuntimeBridgeLifecycle.StartFailure rawValue now snake_case (handshake_timed_out) matching the bounded telemetry convention the test asserts. 2. DesktopDiagnosticsManager.cloudIncidentSnapshotKeys now includes path_class/database_file_size_bytes/volume_free_bytes/volume_total_bytes so StorageFailureDiagnostics context survives into beta trail snapshots. 3. RewindStorageErrorClassificationTests source-inspection updated for the CGImage frame logError that now carries structured context (multi-line).
…st contracts Three pre-existing Desktop Swift test failures from #10523 (chore: add storage and bridge diagnostics) were never caught on main because the Desktop Swift CI path-filter skips the build for non-Swift commits. PR #10530's Swift compile fixes trigger the full suite, exposing them. Fixes: 1. AgentRuntimeBridgeLifecycle.StartFailure rawValue now snake_case (handshake_timed_out) matching the bounded telemetry convention the test asserts. 2. DesktopDiagnosticsManager.cloudIncidentSnapshotKeys now includes path_class/database_file_size_bytes/volume_free_bytes/volume_total_bytes so StorageFailureDiagnostics context survives into beta trail snapshots. 3. RewindStorageErrorClassificationTests source-inspection updated for the CGImage frame logError that now carries structured context (multi-line).
…st contracts Three pre-existing Desktop Swift test failures from #10523 (chore: add storage and bridge diagnostics) were never caught on main because the Desktop Swift CI path-filter skips the build for non-Swift commits. PR #10530's Swift compile fixes trigger the full suite, exposing them. Fixes: 1. AgentRuntimeBridgeLifecycle.StartFailure rawValue now snake_case (handshake_timed_out) matching the bounded telemetry convention the test asserts. 2. DesktopDiagnosticsManager.cloudIncidentSnapshotKeys now includes path_class/database_file_size_bytes/volume_free_bytes/volume_total_bytes so StorageFailureDiagnostics context survives into beta trail snapshots. 3. RewindStorageErrorClassificationTests source-inspection updated for the CGImage frame logError that now carries structured context (multi-line).
BasedHardware#10523 added a DesktopLocalProfile.applicationSupportURL() reference to FocusAssistant.swift's goals-load error path, but the file only imported Foundation. DesktopLocalProfile lives in the separate OmiSupport SwiftPM target, so the build fails with "cannot find 'DesktopLocalProfile' in scope" on every PR whose Desktop Swift CI runs the build. Main's own CI stayed green because non-Swift commits path-filter the build step. Adds import OmiSupport — the exact pattern every other source file that references DesktopLocalProfile already follows (12 call sites). Failure-Class: none
#10523 Two pre-existing Desktop Swift test failures from #10523 (storage and bridge diagnostics) surface because this PR's build fix triggers the full Swift suite, which main's path-filtered CI skips for non-Swift commits. 1. DesktopDiagnosticsManager.cloudIncidentSnapshotKeys now includes path_class, database_file_size_bytes, volume_free_bytes, and volume_total_bytes so StorageFailureDiagnostics context survives into the beta trail snapshot the test asserts. 2. RewindStorageErrorClassificationTests source-inspection updated for the CGImage frame logError that now carries structured context (multi-line call), matching the call shape in RewindIndexer.swift. Mirrors the fix already landed on main (5c22fd5) which is not in this branch's ancestry. Failure-Class: none
## Summary **`main` does not compile.** The desktop Swift package has been broken since 2026-07-25 05:55 UTC. This restores it, and separately unblocks the local pre-push desktop gate on current Xcode. ## Part 1 — the broken build `desktop-swift-ci` on merge commit `3a63002ea9` ([run 30146613366](https://github.com/BasedHardware/omi/actions/runs/30146613366)) **failed**. Every later main run reported success only because it changed no Swift and skipped the lane, so the red state stayed invisible for ~12 hours. Three compile errors, all introduced by `d0215a40a0` ("chore(desktop): add storage and bridge diagnostics", #10523): | Error | Cause | |---|---| | `FocusAssistant.swift:694: cannot find 'DesktopLocalProfile' in scope` | missing `import OmiSupport` | | `RewindIndexer.swift:441: cannot find 'DesktopLocalProfile' in scope` | missing `import OmiSupport` | | `ChatProvider.swift:1667: non-sendable result type 'DesktopErrorDiagnosticContext?' cannot be sent from actor-isolated context` | type is not `Sendable` but crosses an actor boundary | `DesktopLocalProfile` is a `package enum` in the **separate** `OmiSupport` target (`Package.swift` excludes `Sources/OmiSupport` from the `Omi Computer` target), so a file that uses it needs the import. Every pre-existing caller — `AuthService.swift`, `OmiApp.swift`, `AgentVMService.swift` — already has it. The two new call sites did not. `DesktopErrorDiagnosticContext` is produced on whichever actor detected the failure (`AgentRuntimeProcess`) and consumed on `@MainActor` `ChatProvider`, so it must be `Sendable`. Its element type becomes `any Sendable` rather than `Any`, which makes the compiler enforce the scalar-only contract the type's own doc comment already states: > Callers must construct these from enums, booleans, and numeric measurements; paths, exception messages, identifiers, and user content do not belong here. Every existing value is already `String`/`Int`/`Int64`/`Bool`, so **no construction site changes** — only the two declarations. **Scope was measured, not guessed.** I scanned every `Sources/` file outside the `OmiSupport`/`Theme`/`OmiWAL`/`VoiceTurnDomain` targets for all four symbols `OmiSupport` exports (`DesktopLocalProfile`, `DesktopStorageIdentity`, `DesktopDevRuntimeManifest`, `DesktopDevRuntimeManifestStore`). Exactly three files use one without importing; the third, `AppBuild.swift`, mentions `DesktopStorageIdentity` only inside a doc comment and correctly needs no import. ## Part 2 — the local gate on Swift 6.2 Separate commit, separate concern. `scripts/pre-push` runs `xcrun swift build -c debug` against whatever Xcode is selected locally — deliberately, per `desktop/macos/AGENTS.md:249`: *"never promote it to the full pinned-Xcode suite ... that push-time budget belongs to CI."* CI pins Xcode 16.4. On Xcode 26.2 / Swift 6.2.3 the package additionally fails: ``` Sources/Rewind/Core/RewindDatabase.swift:10:22: error: static property 'terminationInProgress' is not concurrency-safe because it is nonisolated global shared mutable state ``` Every access already goes through `terminationLock` — `isTerminationInProgress` reads under it, and the sole write at line 352 takes it — so the property *is* correctly synchronized; the compiler cannot see an `NSLock`. `nonisolated(unsafe)` states that invariant where the compiler can act on it. No runtime behavior changes, and the spelling has been valid since Swift 5.10, comfortably below the pinned toolchain. Effect: the debug build a contributor is asked to run before every push now succeeds on current Xcode instead of failing on code they did not touch. Closes #10570. ## Verification Clean worktree at `origin/main` (`cb918cf0ba`) + this diff, Xcode 26.2 (17C52) / Apple Swift 6.2.3: ``` xcrun swift build -c debug --package-path . -> Build complete! (189.40s), exit 0 xcrun swift build -c debug --build-tests --package-path . -> Build complete!, exit 0 ``` Negative direction, because a fix that was never seen failing is not known to fix anything: - Without either commit, the same command reproduces all three Part 1 errors, matching CI's Xcode 16.4 log ([run 30167210176](https://github.com/BasedHardware/omi/actions/runs/30167210176), job 89702239163) line-for-line. - Reverting **only** the `nonisolated(unsafe)` hunk reproduces the Part 2 error alone, so that annotation is load-bearing rather than decorative. `terminationInProgress` appears **0** times in CI's log and `DesktopLocalProfile` **98** times, which is how the two parts were separated: Part 1 is what CI sees, Part 2 is what only a newer local toolchain sees. ### What I did not verify I did not run the desktop Swift **test suite**, only its compile (`--build-tests` links `Omi ComputerPackageTests` successfully). The suite needs the pinned Xcode 16.4 for a trustworthy result and this machine has 26.2; CI is the authority and runs it on this PR. No test source is touched by this diff. ## A gap this exposed, not fixed here Worth stating so it is not mistaken for covered. The desktop Swift check **never passed** on #10523 — its runs went `failure`, `cancelled`, `cancelled`, `cancelled`, then `skipped`. The final `cancelled` was caused by the merge itself: `desktop-swift-ci.yml` includes `closed` in its PR trigger with `cancel-in-progress: ${{ github.event_name == 'pull_request' }}`, so merging a PR supersedes its own in-flight verification, and the resulting `closed` run reports `skipping`. That behavior is deliberate and contract-tested (`test_closed_prs_release_the_same_pr_concurrency_group_without_allocating_a_runner` — it protects scarce macOS runner capacity when a PR is abandoned). It is correct for a PR closed *unmerged* and load-bearing in the wrong direction for one closed *by merging*. Changing it means distinguishing `github.event.pull_request.merged`, which trades runner capacity for merge safety — a call for the owner of that contract, and not something I can verify without merging it. Filed separately as #10575 with the full timeline rather than bundled into a build fix. ## Product invariants affected - **INV-AUTH-1** (`docs/product/invariants/auth-session.md`) Path-matched via `desktop/macos/Desktop/Sources/Rewind/Core/RewindDatabase.swift`. The change there is a `nonisolated(unsafe)` annotation on an already-lock-guarded private static; it touches no session invalidation policy, 401 handling, or ownership transition, and its guard tests are unmodified. ## Failure class Failure-Class: none Two ordinary instance fixes. No registered class covers "a symbol from a sibling SwiftPM target was used without importing it" — that is what the compiler is for, and it did catch it; the miss was in the merge gate, which is #10575's subject and not repaired here. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10576?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
`main` does not compile. `desktop-swift-ci` on the merge commit 3a63002 (run 30146613366) failed, and every later main run reported success only because it changed no Swift and skipped the lane, so the red state went unnoticed for ~12h. Three compile errors, all from d0215a4 ("chore(desktop): add storage and bridge diagnostics", BasedHardware#10523): Sources/ProactiveAssistants/.../FocusAssistant.swift:694: cannot find 'DesktopLocalProfile' in scope Sources/Rewind/Services/RewindIndexer.swift:441: cannot find 'DesktopLocalProfile' in scope Sources/Providers/ChatProvider.swift:1667: non-sendable result type 'DesktopErrorDiagnosticContext?' cannot be sent from actor-isolated context `DesktopLocalProfile` is `package enum` in the separate `OmiSupport` target; both new call sites use it without `import OmiSupport`. Every pre-existing caller (AuthService.swift, OmiApp.swift, ...) already imports it. `DesktopErrorDiagnosticContext` is produced on whichever actor detected the failure and consumed on `@MainActor` ChatProvider, so it must be `Sendable`. Its element type becomes `any Sendable` rather than `Any`, which makes the compiler enforce the scalar-only contract its own doc comment already states ("enums, booleans, and numeric measurements; paths, exception messages, identifiers, and user content do not belong here"). Every existing value is already String/Int/Int64/Bool, so no construction site changes. Scope was measured, not guessed: a scan of all Sources/ files outside the OmiSupport/Theme/OmiWAL/VoiceTurnDomain targets for the four symbols OmiSupport exports found exactly three candidates, one of which (AppBuild.swift, DesktopStorageIdentity) is a doc comment and needs no import. Ships a changelog fragment rather than the `no-changelog-needed` label: the label satisfies only the PR run, and these are product `Sources/` paths with no push-lane path exemption, so the label would redden main on the merge push (the case check-desktop-changelog.py:32 warns about). Verification, on a clean worktree at origin/main (cb918cf) + this diff: xcrun swift build -c debug --package-path . -> Build complete! (189.40s), exit 0 xcrun swift build -c debug --build-tests --package-path . -> Build complete!, exit 0 Before the fix the same command reproduced all three errors, matching CI's Xcode 16.4 log for run 30167210176 job 89702239163 line-for-line. Failure-Class: none Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
## Summary - add a bounded, shared Sentry diagnostic-context surface for macOS failures - attach volume, SQLite/POSIX, file-size, termination, and coarse path-class context to Rewind storage failures - attach typed startup stage, preconditions, elapsed/timeout, and exit-code context to failed agent-runtime starts - cover context values and the no-path allow-list in Swift tests - register the existing single-owner authority ratchet that now guards recurring failure-class declarations Closes SCA-103 ## Product invariants affected - INV-AUTH-1 - INV-CHAT-1 ## Failure class Failure-Class: none ## Verification - `git diff --cached --check` — passed before commit. - `scripts/pr-preflight --suggest` — identifies `INV-AUTH-1`, `INV-CHAT-1`, and `Failure-Class: none`; the PR body declares all three. - `python3 .github/scripts/check_failure_class_guard_ratchet.py --pr-body-file /tmp/pr-10523-body.md` — passed after recording the existing single-owner authority guard. - `python3 .github/scripts/test_check_failure_class_guard_ratchet.py` — 13 passed. - `scripts/failure-class validate --base origin/main --head HEAD --pr-body-file /tmp/pr-10523-body.md` — passed. - `make preflight` — started and completed `check-manifest-contract` successfully; the command's remaining output was not available from the local runner after its process detached, so it is not claimed as passed. - `xcrun swift test -c debug --package-path desktop/macos/Desktop --filter 'DesktopErrorTelemetryTests|SentryBeforeSendScrubTests'` — not completed: initial SwiftPM dependency hydration left the package `.build` lock occupied; subsequent runs waited on that lock. No test success is claimed. No app bundle was launched: this change affects failure-only diagnostics and does not alter user-facing behavior. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/10523?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->


Summary
Closes SCA-103
Product invariants affected
Failure class
Failure-Class: none
Verification
git diff --cached --check— passed before commit.scripts/pr-preflight --suggest— identifiesINV-AUTH-1,INV-CHAT-1, andFailure-Class: none; the PR body declares all three.python3 .github/scripts/check_failure_class_guard_ratchet.py --pr-body-file /tmp/pr-10523-body.md— passed after recording the existing single-owner authority guard.python3 .github/scripts/test_check_failure_class_guard_ratchet.py— 13 passed.scripts/failure-class validate --base origin/main --head HEAD --pr-body-file /tmp/pr-10523-body.md— passed.make preflight— started and completedcheck-manifest-contractsuccessfully; the command's remaining output was not available from the local runner after its process detached, so it is not claimed as passed.xcrun swift test -c debug --package-path desktop/macos/Desktop --filter 'DesktopErrorTelemetryTests|SentryBeforeSendScrubTests'— not completed: initial SwiftPM dependency hydration left the package.buildlock occupied; subsequent runs waited on that lock. No test success is claimed.No app bundle was launched: this change affects failure-only diagnostics and does not alter user-facing behavior.