You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Swift test suite: shared-singleton contamination causes scheduling-dependent xctest worker crash #9029
Running the full macOS desktop Swift suite in a single swift test process, one suite reliably hard-crashes its xctest worker with no assertion failure (… started with no passed/failed). This is a scheduling-dependent crash caused by shared process-global state leaking across suites, not a bug in any one test.
Repro
cd desktop/macos
xcrun swift test --package-path Desktop # single combined process
The victim suite moves with the skip set — e.g. MemoriesViewModelObserverTests, then MemoryAuthoritativeTierSyncTests — which is the signature of cross-suite state leakage rather than a single bad test.
--no-parallel (serial) does not fix it → it is an order-dependent leak, not a data race.
Every suite passes in isolation (per-suite swift test --filter <Suite>/, 114/114 green).
Root cause
Many suites mutate process-global singletons and real on-disk state that persists across suites in the same process: RewindDatabase.shared, MemoryStorage.shared, AuthState.shared, StagedTaskStorage.shared, an on-disk SQLite file, and UserDefaults.standard.
Current mitigation
desktop/macos/test.sh was rewritten to run each suite in its own process (per-suite swift test --filter), mirroring the backend's per-file pytest isolation. This makes the gate deterministic and green. It is a mitigation, not a fix — the underlying singleton coupling remains and still bites anyone running swift test directly.
Suggested durable fix
Introduce dependency-injection / test seams for the shared singletons so suites don't share process-global state (relates to the broader singleton-count debt in the desktop app).
Update with a measured result: the combined single-process run is now green, which is the "prove combined-process stability" step this issue asks for.
Two defects, found by reproducing the crash rather than by reading the singleton list:
The process-terminating crash (fix(desktop): stop the notification-settings query from killing a non-app host #12687) — UNUserNotificationCenter.current() in the production notification-settings query. Off an app bundle it raises NSInternalInconsistencyException, which Swift cannot catch, so it terminated the run. This is what produced every symptom reported here: no assertion failure, the victim suite moving with ordering, and every suite passing in isolation.
swift test --package-path Desktop, same command each time:
tree
crash lines
result
main
1
died at 2650 tests
+ crash guard
0
3023 completed, 1 failure
+ both
0
3065/3065, 0 failures, 1 skipped
What this does and does not settle
It settles that no suite currently leaks state badly enough to fail or crash another one in a shared process. It does not mean the singleton coupling described here is gone — RewindDatabase.shared, MemoryStorage.shared, AuthState.shared, StagedTaskStorage.shared, the on-disk SQLite file and UserDefaults.standard are all still process-global, and the suites still share them. The run is green because nothing currently mutates them in an order that hurts, not because the coupling was removed. A new suite can reintroduce this at any time.
So I would treat the DI work here as still open, and keep test.sh's per-suite isolation for now. Removing that mitigation is worth doing once these two land and the combined run has been green for a while, but it should be its own PR with its own evidence rather than something folded into either fix.
Both PRs are independent of each other; the green run above needs both.
Activity
chore(desktop/test): link skip tracking to GitHub issues
test(desktop): isolate Swift suites per-process; fix stale tests; lin…
test(desktop): Rewind storage isolation harness
test(desktop): Rewind storage isolation harness
refactor: thermo-nuclear quality repayment (macOS + backend) (#9327)
aryanorastar commentedon Sep 4, 2026
Update with a measured result: the combined single-process run is now green, which is the "prove combined-process stability" step this issue asks for.
Two defects, found by reproducing the crash rather than by reading the singleton list:
UNUserNotificationCenter.current()in the production notification-settings query. Off an app bundle it raisesNSInternalInconsistencyException, which Swift cannot catch, so it terminated the run. This is what produced every symptom reported here: no assertion failure, the victim suite moving with ordering, and every suite passing in isolation.ChatDiscoverabilityTestsasserting an agent-tool declaration forlook_at_frame, which is an alias ofget_screenshotand Local API only. Broken since feat: add JIT knowledge ledger foundation and guarded adoption #12084 on 2026-08-27, unrelated to the crash.swift test --package-path Desktop, same command each time:mainWhat this does and does not settle
It settles that no suite currently leaks state badly enough to fail or crash another one in a shared process. It does not mean the singleton coupling described here is gone —
RewindDatabase.shared,MemoryStorage.shared,AuthState.shared,StagedTaskStorage.shared, the on-disk SQLite file andUserDefaults.standardare all still process-global, and the suites still share them. The run is green because nothing currently mutates them in an order that hurts, not because the coupling was removed. A new suite can reintroduce this at any time.So I would treat the DI work here as still open, and keep
test.sh's per-suite isolation for now. Removing that mitigation is worth doing once these two land and the combined run has been green for a while, but it should be its own PR with its own evidence rather than something folded into either fix.Both PRs are independent of each other; the green run above needs both.
fix(desktop): stop the notification-settings query from killing a non…