Repository navigation
feat(desktop): enforce automation effects and isolate test state - #13556
Conversation
Reuse unique defaults-domain ownership and XCTest teardown in the auth fixtures repaired by #13260. Both chat repeating timer owners from #13468 now use a shared invalidating token; drive elapsed time and callbacks through a manual scheduler to exercise completion, retargeting, cancel and release. Ratchet existing direct shared-defaults mutations at 292, with narrow local integration reasons, in the existing quality guard and manifest lanes. Verification: make setup; 15 Python checker tests; both named local manifest checks; strict Swift 6 isolated type checks. A temporary SwiftPM fixture using the exact changed timer classes/test methods and defaults support passed six XCTest cases. Removing token deinit invalidation made two release tests fail. Integrated desktop compilation and historical suite sequencing are delegated to the parent task after combining worktrees; no live app was launched. Failure-Class: FC-run-loop-timer-outlives-owner
There was a problem hiding this comment.
2 issues found across 45 files
Confidence score: 3/5
- In
desktop/macos/Desktop/Sources/MainWindow/Pages/TasksPage.swift,dump_tasksis labeled with.localStatedespite only reading SQLite, so--read-onlydispatch rejects the intended probe withrequiresEffects; align its declared effects with its read-only behavior. - In
desktop/macos/Desktop/Sources/MainWindow/ChatFirst/ChatFirstAutomationRuntime.swift,chat_first_open_related_tasksadvertises.remoteWritewithout performing or queuing a remote write, which makes action discovery report an inaccurate effect union; remove.remoteWriteand retain only the effects it actually uses.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="desktop/macos/Desktop/Sources/MainWindow/Pages/TasksPage.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/MainWindow/Pages/TasksPage.swift:2855">
P2: `dump_tasks` is declared `effects: [.localState]`, but it only reads from SQLite and mutates no local/UI/stored state, so the new `--read-only` dispatch rejects it with `requiresEffects`. This is the probe intended for proving writes landed without mutation, so it should be callable read-only. Declare it with an empty effects set (`.localState` is documented as "mutates local app, UI, or stored state").</violation>
</file>
<file name="desktop/macos/Desktop/Sources/MainWindow/ChatFirst/ChatFirstAutomationRuntime.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/MainWindow/ChatFirst/ChatFirstAutomationRuntime.swift:67">
P2: `chat_first_open_related_tasks` does not perform or queue a remote write, but this declaration advertises one. Remove `.remoteWrite` so action discovery reports the actual effect union; retain `.localState` and any network-read effect caused by mounting Tasks.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
|
||
| registry.register( | ||
| name: "open_task_details", | ||
| effects: [.localState], |
There was a problem hiding this comment.
P2: dump_tasks is declared effects: [.localState], but it only reads from SQLite and mutates no local/UI/stored state, so the new --read-only dispatch rejects it with requiresEffects. This is the probe intended for proving writes landed without mutation, so it should be callable read-only. Declare it with an empty effects set (.localState is documented as "mutates local app, UI, or stored state").
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/MainWindow/Pages/TasksPage.swift, line 2855:
<comment>`dump_tasks` is declared `effects: [.localState]`, but it only reads from SQLite and mutates no local/UI/stored state, so the new `--read-only` dispatch rejects it with `requiresEffects`. This is the probe intended for proving writes landed without mutation, so it should be callable read-only. Declare it with an empty effects set (`.localState` is documented as "mutates local app, UI, or stored state").</comment>
<file context>
@@ -2851,6 +2852,7 @@ class TasksViewModel: ObservableObject {
registry.register(
name: "open_task_details",
+ effects: [.localState],
summary: "Open a task's detail panel by id — the same panel a row click opens. Omit the id to close it.",
params: ["id"]
</file context>
| effects: [.localState], | |
| effects: [], |
|
|
||
| registry.register( | ||
| name: "chat_first_request_prompt_materialization", | ||
| effects: [.localState, .networkOrModel, .remoteWrite], |
There was a problem hiding this comment.
P2: chat_first_open_related_tasks does not perform or queue a remote write, but this declaration advertises one. Remove .remoteWrite so action discovery reports the actual effect union; retain .localState and any network-read effect caused by mounting Tasks.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At desktop/macos/Desktop/Sources/MainWindow/ChatFirst/ChatFirstAutomationRuntime.swift, line 67:
<comment>`chat_first_open_related_tasks` does not perform or queue a remote write, but this declaration advertises one. Remove `.remoteWrite` so action discovery reports the actual effect union; retain `.localState` and any network-read effect caused by mounting Tasks.</comment>
<file context>
@@ -64,11 +64,11 @@ final class ChatFirstAutomationRuntime: ObservableObject {
registry.register(
name: "chat_first_request_prompt_materialization",
+ effects: [.localState, .networkOrModel, .remoteWrite],
summary: "Run the normal foreground materialization path from mounted main Chat",
params: ["timeoutMs"],
</file context>
| effects: [.localState, .networkOrModel, .remoteWrite], | |
| effects: [.localState, .networkOrModel], |
|
Reviewed both unresolved effect-declaration threads against the handlers and the effect contract added by this PR; keeping both declarations as-is — no code change warranted.
|
…delivery persistence
Desktop automation inferred safety from action names, allowing mutating probes and loading snapshots to appear read-only. Require typed effects at every registration, derive discovery descriptions from them, and add opt-in
omi-ctl action <name> --read-onlydispatch that rejects effects before calling handlers. Migrate the entire registry, including asynchronous and parameter-dependent effects, and pin historical misleading probes in registry/HTTP regression tests.Add a shared defaults-domain fixture with teardown ownership, a cancellable run-loop timer token with automatic invalidation, and an injected clock/scheduler for deterministic chat-scroll tests. Migrate the two owner-projection defaults fixtures and chat glide/pinner timers. Extend the existing test-quality ratchet to reject growth beyond the current 292 direct shared-defaults mutations; narrowly documented integration exceptions remain possible. Existing debt is preserved for gradual migration.
These are declared product effects, not a sandbox: Swift still needs correct effect annotations. The defaults matcher covers direct mutations, not aliases. Timer lifetime tests retain real run-loop coverage alongside deterministic clock tests. No app launch or backend access was used for validation.
Validation in
/Volumes/scratch/worktrees/omi/desktop-agent-guardrails, based ond5cbd548f6, using host Xcode 26.6 / 17F113:git pushgate passes, including debug compilation (82.95s), desktop tool/launcher fixtures, and metadata validation.make setupandOMI_PR_BODY_FILE=/tmp/omi-agent-guardrails-pr-body.md make preflight: 29 checks pass (93.69s); metadata checks pass, including exact growth allowances below.xcrun swift build --package-path desktop/macos/Desktop --build-testspasses. This caught and corrected actor-region ownership in the actual migrated projection tests.CFFIXED_USER_HOME=<task-owned directory> xcrun swift test --package-path desktop/macos/Desktop -j 4 --filter 'DesktopAutomationActionEffectTests|DesktopAutomationBridgeRouteTests|DesktopAutomationSecondaryActionTests|AgentContinuityGauntletTests|IsolatedTestDefaultsTests|UserScrollDetectorTests|ChatScrollLiveEdgeTests|ChatPressPromotionPolicyTests|KernelTurnRecordedProjectionTests': 145 tests pass, including actual run-loop lifetime and injected clock coverage.Hosted pinned Xcode 16.4 validation remains CI evidence. Flow coverage was checked statically; chat-hermetic now asserts actual common-runloop timer validity after cancel and owner release via chat_timer_lifetime_probe. The probe is executed by the focused Swift suite; no full live UI flow was run.
Product invariants preserved: INV-CHAT-1, INV-CHAT-2, INV-NAV-1, INV-VOICE-1, INV-TASK-1, INV-TASK-2.
Failure-Class: FC-run-loop-timer-outlives-owner
Line-Count-Exception: desktop/macos/Desktop/Sources/DesktopAutomationBridge.swift | 5067 -> 5166 | Compiler-required effect declarations at existing registration owners; the enum policy is extracted into its own file.
Line-Count-Exception: desktop/macos/Desktop/Sources/FloatingControlBar/RealtimeHubController.swift | 1641 -> 1643 | Compiler-required effect declarations at existing registration owners; the enum policy is extracted into its own file.
Line-Count-Exception: desktop/macos/Desktop/Sources/MainWindow/Pages/MemoriesPage.swift | 3657 -> 3661 | Compiler-required effect declarations at existing registration owners; the enum policy is extracted into its own file.
Line-Count-Exception: desktop/macos/Desktop/Sources/MainWindow/Pages/TasksPage.swift | 6495 -> 6503 | Compiler-required effect declarations at existing registration owners; the enum policy is extracted into its own file.