Repository navigation
Description
Problem
The Swift side of the desktop app — the platform with the repo's heaviest churn and its worst failure-class chains (FC-5) — has no general static enforcement, while its sibling stacks are locked down: Rust denies clippy::unwrap_used crate-wide, Python runs strict pyright. Verified current state (2026-07-15):
- No SwiftLint, swift-format, or SwiftFormat config anywhere under
desktop/macos/(outside vendored checkouts). Desktop/Package.swift(swift-tools-version: 5.9; three small Swift library targets totaling 12 files, one 444-file executable, one test target): noswiftSettingsanywhere — no strict concurrency, no upcoming-feature flags, no warnings-as-errors.desktop-swift-ci.yml: builds on a movingmacos-15image with no toolchain pin,.buildcache keyed only byPackage.swift(notPackage.resolvedor toolchain identity), no lint step.- The AGENTS.md Formatting table covers Dart, Python, ARB, C/C++, Rust, Web — Swift is absent from the formatting contract and pre-commit hook.
- What exists: per-bug-class ratchet scripts (active in the manifest, local+CI —
check_desktop_test_quality.py,check-async-after-ratchet.py,check-userdefaults-key-ratchet.py, etc.). Real guards, but each covers one instance of a class a compiler/linter setting would close wholesale.
Burn-down scale, measured: ~236 force-unwrap-family candidates (9 try!, 15 as!, ~212 ! unwraps), 584 @MainActor occurrences, 52 actor declarations. The concurrency surface is exactly FC-5's genus — split mutation authority across main-actor singletons, timers, and detached tasks — which is what complete concurrency checking exists to catch at compile time.
End state (the contract; ambitious on purpose)
- Swift 6 language mode with complete strict concurrency on every first-party Swift target (including tests; Objective-C and system-library targets like
ObjCExceptionCatcher/CWebPare excluded — they cannot take Swift settings). Data races become compile errors. - Warnings-as-errors in CI on every strict target.
- SwiftLint via the pinned
SimplyDanny/SwiftLintPluginsSPM build-tool plugin (version-pinned inPackage.swift, attached per target,.swiftlint.ymlinsideDesktop/— the plugin cannot take arbitrary config paths), configured withonly_ruleslisting exactly the safety set:force_unwrapping,force_try,force_cast,implicitly_unwrapped_optional,fatal_error_message,legacy_random,weak_delegate, pluscustom_rulesabsorbing the regex-expressible ratchets (asyncAfterban, UserDefaults key sprawl; theDictionary(uniqueKeysWithValues:)rule keeps the existing// omi-collection-safety:escape-hatch convention).only_rulesis required — barestrict: truewould drag in default style rules. - Baseline discipline the tool doesn't provide, built explicitly: SwiftLint's baseline is a filter, not a ratchet — it neither shrinks itself nor stops someone enlarging it. A small CI guard rejects any PR that adds baseline entries and permits only removals. A narrow
swiftlint:disablepolicy (named reason required, counted by the same guard) closes the one-line bypass. - Apple
swift-format, pinned release binary (bootstrapped, not the moving Xcode-provided one — the current main branch needs Swift 6 tools; use a pinned release compatible with the CI toolchain). Pre-commit:--in-placeon stagedDesktop/**/*.swift, re-stage; CI:lint --strictover the full tree. AGENTS.md Formatting table gains its Swift row. - Dead-code detection via periphery, driven from the existing test-build index store (
--skip-build --index-store-path Desktop/.build/.../index/store) so it doesn't duplicate the expensive build; advisory first (debug-only analysis and ObjC/dynamic references produce false positives), promoted to a no-new-findings snapshot guard only if the pilot's signal-to-noise justifies its maintenance cost. - Upcoming-feature flags, only the ones that exist on the active toolchain. On 5.9:
ConciseMagicFile,BareSlashRegexLiterals, and-strict-concurrency=completeviaunsafeFlags/swiftSettings(theStrictConcurrencyfeature name arrived with Swift 6 tooling).IsolatedDefaultValuesandGlobalConcurrencyrequire 5.10+ — enabled at the tools-version bump, not before.ExistentialAnymay be enabled but is not a Swift 6 default (currently scheduled for Swift 7) — listed separately. Critical trap this issue exists to avoid: SwiftPM silently ignores unknown feature names, so flags must be verified against the pinned compiler, not assumed — fake strictness is worse than none. - Everything manifest-registered (
local+cilanes),reasonfields citing real instances (fix(desktop): crash on duplicate ids in task/apps/chat data (#6506) #9288's trap siblings; an FC-5 race for concurrency).
Sequencing (each rung an independently landable PR; enforcement always precedes burn-down)
Rung 0 — deterministic toolchain. Pin the Xcode/Swift version in CI and print it in every job; fix the .build cache key to include Package.resolved + toolchain identity. Everything downstream depends on knowing which compiler the flags run against; today's moving image makes every subsequent claim unverifiable.
Rung 1 — formatter + linter. swift-format (pinned) in pre-commit + CI; SwiftLint plugin with only_rules, committed baseline, and the down-only baseline guard. New and changed code is fully strict from this day; existing violations (~236) can only shrink. Replaced regex ratchet scripts are deleted in the same PR, each only after the SwiftLint rule catches that script's own adversarial fixture. check_desktop_test_quality.py stays — it does non-trivial lexical work (string/comment masking, token spans, escape-annotation validation) and is not force-migrated until a fixture-equivalent SwiftSyntax rule exists.
Rung 2 — leaf targets go fully strict, zero baseline. OmiSupport, then OmiWAL, then OmiTheme (not free — it has DispatchQueue.main.async and singleton state to fix): -strict-concurrency=complete + existing upcoming-feature flags + warnings-as-errors. Proves the settings on the real toolchain before the monolith. Any new target created by other work (e.g. the domain target proposed in #9832) starts strict on day one — new code is only genuinely strict when it lives in a strict target.
Rung 3 — the executable under complete concurrency, advisory. A pinned-toolchain, report-only CI job builds Omi Computer with -strict-concurrency=complete and publishes the diagnostic count per module. No baseline pretense: compiler diagnostics cannot be baselined, and SwiftPM settings are target-scoped — the executable becomes blocking only by becoming clean. The burn-down mechanism is extraction: high-churn actor domains move into new strict library targets (the #9832 pattern, repeated), shrinking the non-strict monolith until the root target can flip. Diagnostics triaged like #9840's strictness migrations: real race → filed/fixed; false positive → narrow annotation with named reason.
Rung 4 — swift-tools-version bump (5.10+, then 6.x) and language-mode 6. Enables IsolatedDefaultValues/GlobalConcurrency, converts the accumulated flags into the default, deletes them from the manifest. By this rung it is a version bump, not a migration — that is the point of rungs 0–3.
Rung 5 — periphery pilot from the index store, advisory; promotion decision recorded either way.
Proof (per rung)
- Rung 0: CI logs print the pinned toolchain; cache-hit behavior verified across a
Package.resolvedchange. - Rung 1: each gate fails on an adversarial violation; each deleted script's fixture is caught by its replacement rule first; baseline guard rejects an adversarial baseline addition.
- Rung 2: leaf targets compile warning-free under complete concurrency on the pinned toolchain in CI.
- Rung 3: per-module diagnostic counts published every run; the trend is the deliverable. Each extraction PR moves its module's count to zero.
- Feature-flag verification: a CI assertion that every enabled feature name is recognized by the active compiler (guards the silent-ignore trap).
- Manifest
reasonfields cite real caught instances.
Cut list
- No style/architecture lint rules (view-body length, naming aesthetics) — safety and correctness only; style belongs to swift-format.
- No force-migration of non-regex ratchet scripts; no promise to delete the "fleet" — several enforce architecture/ownership contracts, not lint.
- No iOS/Windows/other-target changes —
desktop/macos/Desktoponly. - No periphery blocking gate without a pilot verdict.
- No burn-down deadlines in this issue — the gates stop growth immediately; cleanup pace is owned per-module by whoever touches it (the ratchet makes slow safe).
Sizing
A program, stated honestly: rungs 0–1 are ~a day each; rung 2 is small-but-real (OmiTheme needs actual fixes); rung 3 is the long arc whose cost is the latent races it surfaces (584 @MainActor sites, 52 actors) — paid incrementally per extraction, never as a big-bang flip. Registry: this is the enforcement half of FC-5's not-covered complement — the semantic-race class becomes compiler-visible as strict targets absorb the voice/agent domains.
Activity
build(desktop): pin Xcode and SwiftPM dependency graph
fix(desktop): strengthen Package.resolved gate contract test
build(desktop): add pinned Swift tooling runner contract
build(desktop): define pinned Swift formatter contract
fix(desktop): add no-write-in-lint-mode fixture
ci(desktop): enforce pinned Swift formatting
ci(desktop): add SwiftLint safety baseline
fix(desktop): fix UserDefaults custom rule regex and excluded path
test(desktop): guard SwiftLint baseline and suppressions
ci(desktop): replace equivalent Swift safety ratchets
fix(desktop): update stale references to deleted ratchet scripts
ci(desktop): report strict-concurrency diagnostics
fix(desktop): fix strict-concurrency sentinel and ledger fail-closed
build(desktop): make OmiSupport strict
build(desktop): make OmiWAL strict
56 remaining items
ci(desktop): record Periphery pilot verdict
Strict Swift enforcement program (#9843) (#9855)
Git-on-my-level commentedon Jul 19, 2026
Closing as completed: the enforcement outcome is in place — pinned Xcode/SwiftPM inputs, Swift 6 mode with complete concurrency checking, warnings-as-errors for the production and principal test targets, pinned swift-format, pinned safety-only SwiftLint with a down-only baseline, and the recorded Periphery pilot verdict.
The remaining implementation deviations are intentional and non-blocking: SwiftLint runs through a SHA-verified CI wrapper rather than the SwiftPM plugin because the plugin cannot run cleanly in CI/release builds; two specialized test targets do not escalate warnings; and the diagnostic ledger remains available but is not published as a separate CI artifact.
build(desktop): pin Xcode and SwiftPM dependency graph
fix(desktop): strengthen Package.resolved gate contract test
build(desktop): add pinned Swift tooling runner contract
ci(desktop): enforce pinned Swift formatting
ci(desktop): add SwiftLint safety baseline
test(desktop): guard SwiftLint baseline and suppressions
ci(desktop): replace equivalent Swift safety ratchets
ci(desktop): report strict-concurrency diagnostics
build(desktop): make OmiSupport strict
build(desktop): make OmiWAL strict
Strict Swift enforcement program (BasedHardware#9843) (BasedHardware#…