Eliminate all 68 Swift 6 forward-compat build warnings#684
Merged
Conversation
A clean build of main emitted 68 warnings, every one the same root cause: the target's default MainActor isolation makes pure value types, statics, and Character extensions actor-isolated, and nonisolated contexts (the llama runtime task, sort comparators, timer closures, plain XCTest classes) reference them. Each is an error in the Swift 6 language mode, so they are all future build breaks. Fixes follow the codebase's existing pattern (CaretGeometryQuality, ObservedContentEdges): annotate pure helper enums, value-type models, and the lock-guarded log writers nonisolated. The two notification-callback warnings are real isolation decisions, resolved with MainActor.assumeIsolated since both observers register on the main queue, so entering the actor is an assertion rather than a hop. Clean rebuild from scratch now emits zero project warnings (the two appintentsmetadataprocessor notices are toolchain noise about a framework the app does not use). Full suite: 1436 tests, 0 failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A clean build of latest main emits 68 project warnings, and every one is the same class of problem: the target's
SWIFT_DEFAULT_ACTOR_ISOLATION: MainActormakes pure value types, statics, andCharacterextensions main-actor-isolated, and nonisolated contexts reference them (the llama runtime task logging throughCotabbyLogger, sort comparators, timer closures, conformances used from plain XCTest classes). Each carries the compiler's "this is an error in the Swift 6 language mode" rider, so the whole set is a queued-up future build break.The fix follows the pattern the codebase already established for
CaretGeometryQualityandObservedContentEdges: annotate pure helper enums (CotabbyLogger,TypoGate's decision,DecodeStopPolicy,OCRTextHygiene, the emoji catalog/popularity/synonym tables, and friends), value-type models (EmojiEntry,HFModelSearchResult,DisabledApplicationRule,FocusedInputIdentity, the trigger state machines), and the lock-guarded@unchecked Sendablelog writers asnonisolated. None of these have main-actor state; isolation on them was an accident of the build setting.The two notification-callback warnings (
PowerSourceMonitor,KeyboardInputSourceMonitor) are real isolation decisions rather than annotations: both observers register withqueue: .main, so the callbacks now enter the actor viaMainActor.assumeIsolated, which documents the main-queue delivery contract as a checkable assertion instead of paying a re-dispatch hop.Validation
Linked issues
None filed; this came out of a "build latest main and fix every warning" sweep.
Risk / rollout notes
nonisolatedon pure value types and statics only widens where they may be used; no call site changes behavior. The diff is +48/-41 across 30 files, almost entirely one-word annotations.MainActor.assumeIsolatedsites trap if the delivery queue ever stops being.main. That is intentional: a queue change there should be loud, not a silent data race on actor state.FileLogWriter/LLMIOFileWriterbecoming explicitlynonisolatedmatches what their@unchecked Sendable+ internalNSLockalready promised; theirnonisolated deinit(from Raise deterministic-core test coverage to 95%+ (Models 97.1%, Support 96.0%) #678) is now redundant but harmless and kept for clarity.Greptile Summary
This PR eliminates all 68 Swift 6 forward-compatibility build warnings generated by the
SWIFT_DEFAULT_ACTOR_ISOLATION: MainActorproject setting, which was accidentally isolating pure value types, static-only namespaces, andCharacterextensions to the main actor. The fixes follow the two patterns already established in the codebase.nonisolatedon value types and static-only enums (26 types across 28 files): pure structs and caseless enums (CotabbyLogger,DecodeStopPolicy,OCRTextHygiene, state-machine types, emoji catalogs, log writers, etc.) that carry no main-actor state are explicitly annotated, widening where they may be used without changing any behavior.MainActor.assumeIsolatedin main-queue callbacks (PowerSourceMonitor,KeyboardInputSourceMonitor): instead of relying on the implicit isolation that the build setting provided, bothNSWorkspace/DistributedNotificationCenterobservers registered withqueue: .mainnow explicitly assert main-actor execution, converting a silent assumption into a checkable runtime precondition.Confidence Score: 4/5
Safe to merge; all changes are additive isolation annotations with no behavioral impact on app logic, and the two MainActor.assumeIsolated sites correctly document an existing queue contract.
The diff is almost entirely one-word nonisolated additions to pure value types and static namespaces that genuinely have no main-actor state. The only non-trivial changes are the two MainActor.assumeIsolated wraps in notification callbacks that were already delivered on the main queue. One minor inconsistency: MacroTriggerInput and EmojiTriggerInput are left unannotated in files where all their sibling enums received nonisolated; this doesn't cause any current warning but leaves those two types subject to accidental re-isolation if members are added later.
MacroTriggerStateMachine.swift and EmojiPickerModels.swift — both leave their respective TriggerInput enum unannotated while annotating every other state-machine type in the same file.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[SWIFT_DEFAULT_ACTOR_ISOLATION: MainActor] -->|Before PR| B[All types implicitly @MainActor] B --> C{Type has no actor state?} C -->|Yes - pure enum/struct| D[Warning: nonisolated context references @MainActor member - error in Swift 6 mode] C -->|No - @MainActor class| E[OK] A -->|After PR| F{Classification} F -->|Pure value types / static namespaces| G[nonisolated annotation] F -->|Lock-guarded writers| H[nonisolated final class] F -->|Character extensions| I[nonisolated extension Character] F -->|Main-queue callbacks| J[MainActor.assumeIsolated] G --> K[0 warnings, usable from any context] H --> K I --> K J --> KComments Outside Diff (1)
Cotabby/Support/MacroTriggerStateMachine.swift, line 115-123 (link)MacroTriggerInputis the only enum in this file that wasn't givennonisolated; its siblingsMacroTriggerAction,MacroTriggerState, andMacroQueryGrammarall were. The same pattern appears inEmojiPickerModels.swiftwhereEmojiTriggerInputis left unannotated while every other state-machine enum in the file gets the annotation.The current 0-warning result makes sense: both
*TriggerInputenums contain only cases with no methods or stored properties, so the compiler has nothing main-actor-isolated to warn about on them. If either enum gains a static helper (e.g. a factory or description property) in a future change, it will silently re-inherit@MainActorfrom the build setting and the new member will be isolated while its callers in the now-nonisolatedstate machines are not. Addingnonisolatedhere (and onEmojiTriggerInput) would make the isolation intent explicit and keep the file internally consistent.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (1): Last reviewed commit: "fix(concurrency): eliminate all 68 Swift..." | Re-trigger Greptile