T-2432 · Dedicated cloud container, distinct app and local store identities, and independent MCP defaults.
Ready for draft PR
1,355 simulator tests passed, including the environment Settings UI test. Lint and network-denied synthetic-store probes passed. Review findings were fixed. macOS test execution stalled in OS sandbox initialization before main; Debug compiled. Actual Debug CloudKit access requires the documented manual capability setup and has not been exercised.
f78a7bc330d57f80a98e7e174d72184a5500a6f7 feat: isolate Debug and Release environments (T-2432) Transit can keep a development copy alongside the daily app. Each copy has its own preferences and database. They use different default MCP addresses, so both can run. Debug can sync to its own cloud container after it is registered.
AppPersistencePolicy selects identities, default ports and explicit cloud IDs. SyncManager retains the Release default configuration and uses the existing explicit Debug store URL for development. One Xcode build flag selects both platform-specific Debug cloud entitlements and the startup Info.plist flag. Counter allocators use the selected container explicitly. Standard defaults domains and receipt sidecars remain store scoped.
Build flavor is independent of CloudKit environment: the recovered Release dataset remains Development. Tests gate before ModelContainer and CKContainer construction. Debug rejects a Release cloud container selector. Cloud failures retain the existing in-memory fallback, with effective sync disabled. Explicit user-selected ports survive; distinct defaults do not prevent an intentional conflicting override. The local-only Debug default avoids provisioning changes and preserves the existing development store.
Transit/Transit/Services/AppPersistencePolicy.swift
Why it matters. Prevents development from opening the recovered live backend.
What to look at. Mode identity and cloud selectors
Transit/Transit.xcodeproj/project.pbxproj
Why it matters. Normal development remains usable before manual Apple setup.
What to look at. TRANSIT_DEVELOPMENT_CLOUD_SYNC
Transit/Transit/MCP/MCPSettings.swift
Why it matters. Both apps can listen without conflicting defaults.
What to look at. Default port policy, preserved saved overrides, modern discovery name
| Severity | Area | Finding | Resolution |
|---|---|---|---|
| major | Test helpers | Throwing configuration could not pass through nonthrowing test helper. | Helper rethrows and affected tests propagate errors. |
| major | Modern discovery | Debug modern HTTP discovery retained Release server name. | Modern and legacy identity use shared policy. |
| minor | Product paths | Install and closed-store harness paths assumed Transit.app in Debug. | Updated active paths for TransitDevelopment and preserved historical cleanup evidence paths. |
Source: local run at 2026-10-09T10:08:53Z · snapshot f78a7bc330d57f80a98e7e174d72184a5500a6f7
Baseline: none
Execution: passed · JUnit: 1 file · Coverage: none · Baseline: absent
Coverage scope: as the project configures it
Totals: 1355 passed · 0 failed · 0 skipped · 0 errored · 0 flaky
Derived by declaration name, from the diff (no baseline run).
Files that import a changed file on the left, changed files in the centre, files a changed file imports on the right. Snapshot working-tree against base b0f5d766d1c62cdf85be079c759b76847e4404a8.
30 files: 26 code · 4 docs. Click to expand.
diff --git a/Makefile b/Makefileindex cb80d265..9ac273a3 100644--- a/Makefile+++ b/Makefile@@ -6,7 +6,9 @@ SHELL = /bin/bash SCHEME = Transit PROJECT = Transit/Transit.xcodeproj CONFIG ?= Debug-BUNDLE_ID = $(if $(filter Debug,$(CONFIG)),me.nore.ig.Transit.development,me.nore.ig.Transit)+IS_DEVELOPMENT = $(if $(filter TransitDevelopment,$(SCHEME)),YES,$(if $(filter Debug,$(CONFIG)),YES,NO))+BUNDLE_ID = $(if $(filter YES,$(IS_DEVELOPMENT)),me.nore.ig.Transit.development,me.nore.ig.Transit)+APP_PRODUCT = $(if $(filter YES,$(IS_DEVELOPMENT)),TransitDevelopment,Transit) # Pipe through xcbeautify if available, otherwise raw output XCBEAUTIFY := $(shell command -v xcbeautify 2>/dev/null)@@ -323,7 +325,7 @@ install: prepare-cache-dirs @echo "Installing on device..." xcrun devicectl device install app \ --device $(DEVICE_ID) \- $(DERIVED_DATA)/Build/Products/$(CONFIG)-iphoneos/Transit.app+ $(DERIVED_DATA)/Build/Products/$(CONFIG)-iphoneos/$(APP_PRODUCT).app .PHONY: run run: install
diff --git a/Transit/Configuration/DevelopmentCloud.entitlements b/Transit/Configuration/DevelopmentCloud.entitlementsnew file mode 100644index 00000000..84527ef9--- /dev/null+++ b/Transit/Configuration/DevelopmentCloud.entitlements@@ -0,0 +1,22 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>aps-environment</key>+ <string>development</string>+ <key>com.apple.developer.icloud-container-environment</key>+ <string>Development</string>+ <key>com.apple.developer.icloud-container-identifiers</key>+ <array>+ <string>iCloud.me.nore.ig.Transit.development</string>+ </array>+ <key>com.apple.developer.icloud-services</key>+ <array>+ <string>CloudKit</string>+ </array>+ <key>com.apple.security.network.client</key>+ <true/>+ <key>com.apple.security.network.server</key>+ <true/>+</dict>+</plist>
diff --git a/Transit/Configuration/DevelopmentCloudMac.entitlements b/Transit/Configuration/DevelopmentCloudMac.entitlementsnew file mode 100644index 00000000..a0ae5517--- /dev/null+++ b/Transit/Configuration/DevelopmentCloudMac.entitlements@@ -0,0 +1,22 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.developer.aps-environment</key>+ <string>development</string>+ <key>com.apple.developer.icloud-container-environment</key>+ <string>Development</string>+ <key>com.apple.developer.icloud-container-identifiers</key>+ <array>+ <string>iCloud.me.nore.ig.Transit.development</string>+ </array>+ <key>com.apple.developer.icloud-services</key>+ <array>+ <string>CloudKit</string>+ </array>+ <key>com.apple.security.network.client</key>+ <true/>+ <key>com.apple.security.network.server</key>+ <true/>+</dict>+</plist>
diff --git a/Transit/Configuration/DevelopmentInfo.plist b/Transit/Configuration/DevelopmentInfo.plistindex bcaee967..5fe528b6 100644--- a/Transit/Configuration/DevelopmentInfo.plist+++ b/Transit/Configuration/DevelopmentInfo.plist@@ -2,15 +2,17 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>+ <key>TransitDevelopmentCloudSync</key>+ <string>$(TRANSIT_DEVELOPMENT_CLOUD_SYNC)</string> <key>UIApplicationShortcutItems</key> <array> <dict>- <key>UIApplicationShortcutItemType</key>- <string>com.arjen.transit.new-task</string>- <key>UIApplicationShortcutItemTitle</key>- <string>New Task</string> <key>UIApplicationShortcutItemIconSymbolName</key> <string>plus.square</string>+ <key>UIApplicationShortcutItemTitle</key>+ <string>New Task</string>+ <key>UIApplicationShortcutItemType</key>+ <string>com.arjen.transit.new-task</string> </dict> </array> </dict>
diff --git a/Transit/Transit.xcodeproj/project.pbxproj b/Transit/Transit.xcodeproj/project.pbxprojindex 47fa36d9..578950e0 100644--- a/Transit/Transit.xcodeproj/project.pbxproj+++ b/Transit/Transit.xcodeproj/project.pbxproj@@ -422,7 +422,12 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;- CODE_SIGN_ENTITLEMENTS = Configuration/Development.entitlements;+ TRANSIT_DEVELOPMENT_CLOUD_SYNC = NO;+ TRANSIT_DEVELOPMENT_ENTITLEMENTS_NO = Configuration/Development.entitlements;+ TRANSIT_DEVELOPMENT_ENTITLEMENTS_YES = Configuration/DevelopmentCloud.entitlements;+ "TRANSIT_DEVELOPMENT_ENTITLEMENTS_YES[sdk=macosx*]" = Configuration/DevelopmentCloudMac.entitlements;+ CODE_SIGN_ENTITLEMENTS = "$(TRANSIT_DEVELOPMENT_ENTITLEMENTS_$(TRANSIT_DEVELOPMENT_CLOUD_SYNC))";+ INFOPLIST_KEY_TransitDevelopmentCloudSync = "$(TRANSIT_DEVELOPMENT_CLOUD_SYNC)"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1;@@ -451,7 +456,8 @@ MACOSX_DEPLOYMENT_TARGET = 26.0; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = me.nore.ig.Transit.development;- PRODUCT_NAME = "$(TARGET_NAME)";+ PRODUCT_NAME = TransitDevelopment;+ PRODUCT_MODULE_NAME = Transit; PROVISIONING_PROFILE_SPECIFIER = ""; REGISTER_APP_GROUPS = NO; SDKROOT = auto;@@ -645,6 +651,8 @@ MACOSX_DEPLOYMENT_TARGET = 26.2; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = me.nore.ig.Transit.development.tests;+ TRANSIT_TEST_HOST_APP = TransitDevelopment.app;+ TRANSIT_TEST_HOST_EXECUTABLE = TransitDevelopment; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; STRING_CATALOG_GENERATE_SYMBOLS = NO;@@ -654,7 +662,7 @@ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2,7";- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Transit.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Transit";+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/$(TRANSIT_TEST_HOST_APP)/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/$(TRANSIT_TEST_HOST_EXECUTABLE)"; XROS_DEPLOYMENT_TARGET = 26.2; }; name = Debug;@@ -671,6 +679,8 @@ MACOSX_DEPLOYMENT_TARGET = 26.2; MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = me.nore.ig.TransitTests;+ TRANSIT_TEST_HOST_APP = Transit.app;+ TRANSIT_TEST_HOST_EXECUTABLE = Transit; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = auto; STRING_CATALOG_GENERATE_SYMBOLS = NO;@@ -680,7 +690,7 @@ SWIFT_UPCOMING_FEATURE_MEMBER_IMPORT_VISIBILITY = YES; SWIFT_VERSION = 6.0; TARGETED_DEVICE_FAMILY = "1,2,7";- TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Transit.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/Transit";+ TEST_HOST = "$(BUILT_PRODUCTS_DIR)/$(TRANSIT_TEST_HOST_APP)/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/$(TRANSIT_TEST_HOST_EXECUTABLE)"; XROS_DEPLOYMENT_TARGET = 26.2; }; name = Release;@@ -742,7 +752,12 @@ PRODUCT_MODULE_NAME = Transit; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;- CODE_SIGN_ENTITLEMENTS = Configuration/Development.entitlements;+ TRANSIT_DEVELOPMENT_CLOUD_SYNC = NO;+ TRANSIT_DEVELOPMENT_ENTITLEMENTS_NO = Configuration/Development.entitlements;+ TRANSIT_DEVELOPMENT_ENTITLEMENTS_YES = Configuration/DevelopmentCloud.entitlements;+ "TRANSIT_DEVELOPMENT_ENTITLEMENTS_YES[sdk=macosx*]" = Configuration/DevelopmentCloudMac.entitlements;+ CODE_SIGN_ENTITLEMENTS = "$(TRANSIT_DEVELOPMENT_ENTITLEMENTS_$(TRANSIT_DEVELOPMENT_CLOUD_SYNC))";+ INFOPLIST_KEY_TransitDevelopmentCloudSync = "$(TRANSIT_DEVELOPMENT_CLOUD_SYNC)"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1;@@ -794,7 +809,12 @@ PRODUCT_MODULE_NAME = Transit; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;- CODE_SIGN_ENTITLEMENTS = Configuration/Development.entitlements;+ TRANSIT_DEVELOPMENT_CLOUD_SYNC = NO;+ TRANSIT_DEVELOPMENT_ENTITLEMENTS_NO = Configuration/Development.entitlements;+ TRANSIT_DEVELOPMENT_ENTITLEMENTS_YES = Configuration/DevelopmentCloud.entitlements;+ "TRANSIT_DEVELOPMENT_ENTITLEMENTS_YES[sdk=macosx*]" = Configuration/DevelopmentCloudMac.entitlements;+ CODE_SIGN_ENTITLEMENTS = "$(TRANSIT_DEVELOPMENT_ENTITLEMENTS_$(TRANSIT_DEVELOPMENT_CLOUD_SYNC))";+ INFOPLIST_KEY_TransitDevelopmentCloudSync = "$(TRANSIT_DEVELOPMENT_CLOUD_SYNC)"; CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1;
diff --git a/Transit/Transit/MCP/MCPServer+Routing.swift b/Transit/Transit/MCP/MCPServer+Routing.swiftindex 6a1741a9..acaf9fb5 100644--- a/Transit/Transit/MCP/MCPServer+Routing.swift+++ b/Transit/Transit/MCP/MCPServer+Routing.swift@@ -75,7 +75,7 @@ extension MCPServer { case .discover: let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0" return encodedResponse(try MCPModernDiscovery.encodeDiscovery(id: modern.id,- identity: MCPModernServerIdentity(name: "transit", version: version)))+ identity: MCPModernServerIdentity(name: AppPersistencePolicy.serverName, version: version))) case .listTools: return encodedResponse(try MCPModernDiscovery.encodeTools(id: modern.id, tools: MCPToolDefinitions.modernTools(includingMaintenance: maintenanceEnabled,
diff --git a/Transit/Transit/MCP/MCPSettings.swift b/Transit/Transit/MCP/MCPSettings.swiftindex dc4be5c9..7bebf7e4 100644--- a/Transit/Transit/MCP/MCPSettings.swift+++ b/Transit/Transit/MCP/MCPSettings.swift@@ -15,7 +15,11 @@ final class MCPSettings { @MainActor var subscriptionBroadcaster: MCPToolListChangeBroadcaster { toolListChangeBroadcaster }- static let defaultPort = 3141+ static var defaultPort: Int {+ let mode: AppPersistencePolicy.Mode = AppPersistencePolicy.isDevelopmentBuild ? .development : .production+ return mode.defaultMCPPort+ }+ private let defaults: UserDefaults /// Valid TCP port range. Port 0 means "any available port" to the OS and is /// not a usable fixed address for the MCP server, so it is excluded.@@ -31,11 +35,11 @@ final class MCPSettings { } var isEnabled: Bool {- didSet { UserDefaults.standard.set(isEnabled, forKey: Self.enabledKey) }+ didSet { defaults.set(isEnabled, forKey: Self.enabledKey) } } var port: Int {- didSet { UserDefaults.standard.set(port, forKey: Self.portKey) }+ didSet { defaults.set(port, forKey: Self.portKey) } } /// Availability reads never hop to MainActor or inspect preferences.@@ -47,7 +51,7 @@ final class MCPSettings { didSet { let enabled = maintenanceToolsEnabled maintenanceAvailability.withLockedValue { $0 = enabled }- UserDefaults.standard.set(maintenanceToolsEnabled, forKey: Self.maintenanceToolsKey)+ defaults.set(maintenanceToolsEnabled, forKey: Self.maintenanceToolsKey) guard maintenanceToolsEnabled != oldValue else { return } toolListChangeBroadcaster.notifyToolsListChanged() }@@ -61,11 +65,12 @@ final class MCPSettings { toolListChangeBroadcaster.activeStreamCount } - init() {- self.isEnabled = UserDefaults.standard.bool(forKey: Self.enabledKey)- let stored = UserDefaults.standard.integer(forKey: Self.portKey)- self.port = stored > 0 ? stored : Self.defaultPort- let maintenanceEnabled = UserDefaults.standard.bool(forKey: Self.maintenanceToolsKey)+ init(mode: AppPersistencePolicy.Mode? = nil, defaults: UserDefaults = .standard) {+ self.defaults = defaults+ self.isEnabled = defaults.bool(forKey: Self.enabledKey)+ let stored = defaults.integer(forKey: Self.portKey)+ self.port = Self.isValidPort(stored) ? stored : (mode?.defaultMCPPort ?? Self.defaultPort)+ let maintenanceEnabled = defaults.bool(forKey: Self.maintenanceToolsKey) self.maintenanceToolsEnabled = maintenanceEnabled maintenanceAvailability.withLockedValue { $0 = maintenanceEnabled } }
diff --git a/Transit/Transit/MCP/MCPToolHandler.swift b/Transit/Transit/MCP/MCPToolHandler.swiftindex 286e8f5a..5238997b 100644--- a/Transit/Transit/MCP/MCPToolHandler.swift+++ b/Transit/Transit/MCP/MCPToolHandler.swift@@ -274,7 +274,8 @@ final class MCPToolHandler { let result = MCPInitializeResult( protocolVersion: protocolVersion, capabilities: MCPServerCapabilities(tools: MCPToolsCapability(listChanged: true)),- serverInfo: MCPServerInfo(name: "transit", version: version)+ serverInfo: MCPServerInfo(+ name: AppPersistencePolicy.serverName, version: version) ) return JSONRPCResponse.success(id: id, result: result) }
diff --git a/Transit/Transit/Services/AppDisplayIDAllocators.swift b/Transit/Transit/Services/AppDisplayIDAllocators.swiftindex d923df95..e5363d63 100644--- a/Transit/Transit/Services/AppDisplayIDAllocators.swift+++ b/Transit/Transit/Services/AppDisplayIDAllocators.swift@@ -1,3 +1,4 @@+import CloudKit import Foundation /// Selects counter adapters before any CloudKit container is constructed.@@ -10,8 +11,8 @@ enum AppDisplayIDAllocators { static func make( mode: AppPersistencePolicy.Mode, syncActive: Bool,- cloudFactory: (String) -> DisplayIDAllocator = {- DisplayIDAllocator(counterRecordName: $0, isCloudSyncActive: true)+ cloudFactory: (String, String) -> DisplayIDAllocator = {+ DisplayIDAllocator(container: CKContainer(identifier: $1), counterRecordName: $0, isCloudSyncActive: true) } ) -> Pair { guard mode.permitsCloudSync && syncActive else {@@ -20,7 +21,8 @@ enum AppDisplayIDAllocators { milestones: DisplayIDAllocator(store: DisabledCounterStore(), isCloudSyncActive: false) ) }- return Pair(tasks: cloudFactory("global-counter"), milestones: cloudFactory("milestone-counter"))+ return Pair(tasks: cloudFactory("global-counter", mode.cloudKitContainerID),+ milestones: cloudFactory("milestone-counter", mode.cloudKitContainerID)) } }
diff --git a/Transit/Transit/Services/AppPersistencePolicy.swift b/Transit/Transit/Services/AppPersistencePolicy.swiftindex c9b972d7..f24d1b26 100644--- a/Transit/Transit/Services/AppPersistencePolicy.swift+++ b/Transit/Transit/Services/AppPersistencePolicy.swift@@ -12,9 +12,22 @@ nonisolated enum AppPersistencePolicy { case uiTest var usesMemoryStore: Bool { self == .unitTest || self == .uiTest }- var permitsCloudSync: Bool { self == .production }+ var permitsCloudSync: Bool { self == .production || self == .development } var permitsBackgroundServices: Bool { !usesMemoryStore }- var permitsAutomaticMCPStartup: Bool { self == .production }+ var permitsAutomaticMCPStartup: Bool { !usesMemoryStore }++ var defaultMCPPort: Int { self == .production ? 3141 : 3142 }+ var displayName: String {+ switch self {+ case .production: "Release"+ case .development: "Debug"+ case .unitTest: "Debug (unit test)"+ case .uiTest: "Debug (UI test)"+ }+ }+ var cloudKitContainerID: String {+ self == .production ? "iCloud.me.nore.ig.Transit" : "iCloud.me.nore.ig.Transit.development"+ } } enum Failure: Error, Equatable {@@ -58,6 +71,14 @@ nonisolated enum AppPersistencePolicy { return .production } + static var serverName: String { isDevelopmentBuild ? "transit-debug" : "transit" }++ /// The build flag and entitlement selector are paired in the Xcode configuration.+ static var developmentCloudSyncEnabled: Bool {+ let value = Bundle.main.object(forInfoDictionaryKey: "TransitDevelopmentCloudSync")+ return value as? String == "YES" || value as? Bool == true+ }+ static var isDevelopmentBuild: Bool { #if DEBUG || TRANSIT_DEVELOPMENT true
diff --git a/Transit/Transit/Services/IsolatedPersistenceConfiguration.swift b/Transit/Transit/Services/IsolatedPersistenceConfiguration.swiftindex f9937753..f4ba7e97 100644--- a/Transit/Transit/Services/IsolatedPersistenceConfiguration.swift+++ b/Transit/Transit/Services/IsolatedPersistenceConfiguration.swift@@ -2,13 +2,19 @@ import Foundation import SwiftData enum IsolatedPersistenceConfiguration {- enum Failure: Error { case productionModeNotAllowed }+ enum Failure: Error { case productionModeNotAllowed, invalidCloudContainer } static func make( mode: AppPersistencePolicy.Mode, schema: Schema,- applicationSupportDirectory: URL = .applicationSupportDirectory+ applicationSupportDirectory: URL = .applicationSupportDirectory,+ cloudKitContainerID: String? = nil ) throws -> ModelConfiguration { guard mode != .production else { throw Failure.productionModeNotAllowed }+ if let cloudKitContainerID {+ guard mode == .development && cloudKitContainerID == mode.cloudKitContainerID else {+ throw Failure.invalidCloudContainer+ }+ } if mode.usesMemoryStore { return ModelConfiguration(schema: schema, isStoredInMemoryOnly: true, groupContainer: .none, cloudKitDatabase: .none)@@ -17,6 +23,6 @@ enum IsolatedPersistenceConfiguration { try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) return ModelConfiguration("TransitDevelopment", schema: schema, url: directory.appendingPathComponent("development.store"),- cloudKitDatabase: .none)+ cloudKitDatabase: cloudKitContainerID.map { .private($0) } ?? .none) } }
diff --git a/Transit/Transit/Services/SyncManager.swift b/Transit/Transit/Services/SyncManager.swiftindex fc010a42..e9f87124 100644--- a/Transit/Transit/Services/SyncManager.swift+++ b/Transit/Transit/Services/SyncManager.swift@@ -24,7 +24,8 @@ final class SyncManager { /// Matches the @AppStorage key used in SettingsView. private static let syncEnabledKey = "syncEnabled"- private static let cloudKitContainerID = "iCloud.me.nore.ig.Transit"+ let mode: AppPersistencePolicy.Mode+ private let defaults: UserDefaults private static let logger = Logger(subsystem: "me.nore.ig.Transit", category: "SyncManager") private(set) var isSyncEnabled: Bool@@ -56,6 +57,8 @@ final class SyncManager { init( cloudSyncAllowed: Bool = true,+ mode: AppPersistencePolicy.Mode = .production,+ defaults: UserDefaults = .standard, heartbeatFetcher: @escaping HeartbeatFetcher = { context, descriptor in try context.fetch(descriptor) },@@ -64,7 +67,8 @@ final class SyncManager { } ) { // Default to enabled if never set- let defaults = UserDefaults.standard+ self.mode = mode+ self.defaults = defaults if cloudSyncAllowed && defaults.object(forKey: Self.syncEnabledKey) == nil { defaults.set(true, forKey: Self.syncEnabledKey) }@@ -86,7 +90,7 @@ final class SyncManager { func setSyncEnabled(_ enabled: Bool) { guard cloudSyncAllowed else { return } isSyncEnabled = enabled- UserDefaults.standard.set(enabled, forKey: Self.syncEnabledKey)+ defaults.set(enabled, forKey: Self.syncEnabledKey) } /// Records the CloudKit mode the live `ModelContainer` was actually created with.@@ -101,12 +105,18 @@ final class SyncManager { /// Creates a ModelConfiguration based on the current sync preference, and records /// that mode as the active one.- func makeModelConfiguration(schema: Schema) -> ModelConfiguration {+ func makeModelConfiguration(schema: Schema) throws -> ModelConfiguration { recordActiveCloudSync(isSyncEnabled)+ if mode != .production {+ return try IsolatedPersistenceConfiguration.make(+ mode: mode, schema: schema,+ cloudKitContainerID: isCloudSyncActive ? mode.cloudKitContainerID : nil+ )+ } if isSyncEnabled { return ModelConfiguration( schema: schema,- cloudKitDatabase: .private(Self.cloudKitContainerID)+ cloudKitDatabase: .private(mode.cloudKitContainerID) ) } else { return ModelConfiguration(
diff --git a/Transit/Transit/TransitApp.swift b/Transit/Transit/TransitApp.swiftindex 876226cf..7a53b8ab 100644--- a/Transit/Transit/TransitApp.swift+++ b/Transit/Transit/TransitApp.swift@@ -40,21 +40,19 @@ struct TransitApp: App { // swiftlint:disable:next function_body_length init() { let mode = Self.persistenceMode- let syncManager = SyncManager(cloudSyncAllowed: mode.permitsCloudSync)+ let debugCloudEnabled = AppPersistencePolicy.developmentCloudSyncEnabled+ let cloudAllowed = mode.permitsCloudSync && (mode == .production || debugCloudEnabled)+ let syncManager = SyncManager(cloudSyncAllowed: cloudAllowed, mode: mode) self.syncManager = syncManager let schema = Schema([ Project.self, TransitTask.self, Comment.self, Milestone.self, SyncHeartbeat.self, MCPWriteReceipt.self, TaskLinkOccurrence.self, TaskLinkRemovalEvidence.self, TaskConsolidationEvent.self ]) let config: ModelConfiguration- if mode != .production {- do {- config = try IsolatedPersistenceConfiguration.make(mode: mode, schema: schema)- } catch {- fatalError("Unable to create isolated storage: \(error)")- }- } else {- config = syncManager.makeModelConfiguration(schema: schema)+ do {+ config = try syncManager.makeModelConfiguration(schema: schema)+ } catch {+ fatalError("Unable to create isolated storage: \(error)") } AppIsolationSmoke.preflight(mode: mode, configuration: config) let containerResult = ContainerFactory.makeContainer(schema: schema, configuration: config)@@ -134,7 +132,7 @@ struct TransitApp: App { appDelegate.quickActionService = quickActionService #endif #if os(macOS)- let mcpSettings = MCPSettings()+ let mcpSettings = MCPSettings(mode: mode) self.mcpSettings = mcpSettings let writeServices = MCPWriteCommandServices( tasks: taskService, projects: projectService,
diff --git a/Transit/Transit/Views/Settings/SettingsView.swift b/Transit/Transit/Views/Settings/SettingsView.swiftindex b0ed91f0..6326c9c0 100644--- a/Transit/Transit/Views/Settings/SettingsView.swift+++ b/Transit/Transit/Views/Settings/SettingsView.swift@@ -109,6 +109,7 @@ struct SettingsView: View { Section("General") { TextField("Your Name", text: $userDisplayName) LabeledContent("About Transit", value: appVersion)+ environmentDetails VStack(alignment: .leading, spacing: 4) { Toggle("iCloud Sync", isOn: syncPreference) .disabled(!syncManager.cloudSyncAllowed)@@ -183,6 +184,20 @@ struct SettingsView: View { } } + private var environmentDetails: some View {+ VStack(alignment: .leading, spacing: 4) {+ Text(syncManager.mode.displayName)+ .accessibilityIdentifier("settings.environment")+ Text(syncManager.isCloudSyncActive+ ? syncManager.mode.cloudKitContainerID+ + (syncManager.mode == .development ? " · Development" : "")+ : "Local storage · iCloud inactive")+ .font(.caption)+ .foregroundStyle(.secondary)+ .textSelection(.enabled)+ }+ }+ private var appVersion: String { Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0" }@@ -393,7 +408,8 @@ extension SettingsView { ) { FormRow("Setup", labelWidth: Self.labelWidth) { let command =- "claude mcp add transit --transport http http://localhost:\(setupPort)/mcp"+ "claude mcp add \(syncManager.mode == .production ? "transit" : "transit-debug") "+ + "--transport http http://localhost:\(setupPort)/mcp" Text(command) .font(.caption.monospaced()) .textSelection(.enabled)@@ -445,6 +461,9 @@ extension SettingsView { fileprivate var macOSGeneralSection: some View { LiquidGlassSection { Grid(alignment: .leadingFirstTextBaseline, horizontalSpacing: 16, verticalSpacing: 14) {+ FormRow("Environment", labelWidth: Self.labelWidth) {+ environmentDetails+ } FormRow("Your Name", labelWidth: Self.labelWidth) { TextField("", text: $userDisplayName) }
diff --git a/Transit/TransitTests/AppEnvironmentTests.swift b/Transit/TransitTests/AppEnvironmentTests.swiftnew file mode 100644index 00000000..e9d94cb7--- /dev/null+++ b/Transit/TransitTests/AppEnvironmentTests.swift@@ -0,0 +1,44 @@+import Foundation+import SwiftData+import Testing+@testable import Transit++@MainActor+@Suite(.serialized)+struct AppEnvironmentTests {+ @Test func debugConfigurationCannotBindReleaseCloud() throws {+ let schema = Schema([Project.self])+ #expect(throws: IsolatedPersistenceConfiguration.Failure.invalidCloudContainer) {+ try IsolatedPersistenceConfiguration.make(mode: .development, schema: schema,+ cloudKitContainerID: AppPersistencePolicy.Mode.production.cloudKitContainerID)+ }+ #expect(throws: IsolatedPersistenceConfiguration.Failure.invalidCloudContainer) {+ try IsolatedPersistenceConfiguration.make(mode: .unitTest, schema: schema,+ cloudKitContainerID: AppPersistencePolicy.Mode.development.cloudKitContainerID)+ }+ }++ #if os(macOS)+ @Test func independentMCPDefaultsAndExplicitOverrides() throws {+ let releaseName = "transit-release-fixture-" + UUID().uuidString+ let debugName = "transit-debug-fixture-" + UUID().uuidString+ let release = try #require(UserDefaults(suiteName: releaseName))+ let debug = try #require(UserDefaults(suiteName: debugName))+ defer {+ release.removePersistentDomain(forName: releaseName)+ debug.removePersistentDomain(forName: debugName)+ }+ let releaseSettings = MCPSettings(mode: .production, defaults: release)+ let debugSettings = MCPSettings(mode: .development, defaults: debug)+ #expect(releaseSettings.port == 3141 && debugSettings.port == 3142)+ releaseSettings.port = 3201+ debugSettings.port = 3202+ #expect(MCPSettings(mode: .production, defaults: release).port == 3201)+ #expect(MCPSettings(mode: .development, defaults: debug).port == 3202)+ debugSettings.isEnabled = true+ #expect(!releaseSettings.isEnabled)+ debug.set(70000, forKey: "mcpServerPort")+ #expect(MCPSettings(mode: .development, defaults: debug).port == 3142)+ }+ #endif+}
diff --git a/Transit/TransitTests/MCPModernRouterIntegrationTests.swift b/Transit/TransitTests/MCPModernRouterIntegrationTests.swiftindex eb14deae..fd2927c0 100644--- a/Transit/TransitTests/MCPModernRouterIntegrationTests.swift+++ b/Transit/TransitTests/MCPModernRouterIntegrationTests.swift@@ -19,6 +19,11 @@ struct MCPModernRouterIntegrationTests { #expect(result["resultType"] as? String == "complete") #expect(result["ttlMs"] as? Int == 0) #expect(result["cacheScope"] as? String == "public")+ if method == "server/discover" {+ let metadata = try #require(result["_meta"] as? [String: Any])+ let identity = try #require(metadata["io.modelcontextprotocol/serverInfo"] as? [String: Any])+ #expect(identity["name"] as? String == "transit-debug")+ } if method == "tools/list" { let tools = try #require(result["tools"] as? [[String: Any]]) let names = tools.compactMap { $0["name"] as? String }
diff --git a/Transit/TransitTests/SyncDisabledGatingTests.swift b/Transit/TransitTests/SyncDisabledGatingTests.swiftindex fe35cb33..388e15c3 100644--- a/Transit/TransitTests/SyncDisabledGatingTests.swift+++ b/Transit/TransitTests/SyncDisabledGatingTests.swift@@ -26,7 +26,7 @@ struct SyncDisabledGatingTests { } /// Saves and restores the "syncEnabled" default around a body that mutates it.- private func withSavedDefaults(_ body: () -> Void) {+ private func withSavedDefaults(_ body: () throws -> Void) rethrows { let key = "syncEnabled" let previous = UserDefaults.standard.object(forKey: key) defer {@@ -36,7 +36,7 @@ struct SyncDisabledGatingTests { UserDefaults.standard.removeObject(forKey: key) } }- body()+ try body() } // MARK: - T-1797: allocator never reaches the counter store@@ -251,15 +251,15 @@ struct SyncDisabledGatingTests { // MARK: - T-1857: preference vs. active mode @Test- func makeModelConfiguration_recordsTheModeTheContainerWasBuiltWith() {- withSavedDefaults {+ func makeModelConfiguration_recordsTheModeTheContainerWasBuiltWith() throws {+ try withSavedDefaults { UserDefaults.standard.set(false, forKey: "syncEnabled") let manager = SyncManager() let schema = Schema([ Project.self, TransitTask.self, Comment.self, Milestone.self, SyncHeartbeat.self, MCPWriteReceipt.self ]) - _ = manager.makeModelConfiguration(schema: schema)+ _ = try manager.makeModelConfiguration(schema: schema) #expect(manager.isCloudSyncActive == false) #expect(manager.syncChangeRequiresRestart == false)@@ -267,14 +267,14 @@ struct SyncDisabledGatingTests { } @Test- func setSyncEnabled_doesNotChangeTheActiveMode_andFlagsRestartRequired() {- withSavedDefaults {+ func setSyncEnabled_doesNotChangeTheActiveMode_andFlagsRestartRequired() throws {+ try withSavedDefaults { UserDefaults.standard.set(true, forKey: "syncEnabled") let manager = SyncManager() let schema = Schema([ Project.self, TransitTask.self, Comment.self, Milestone.self, SyncHeartbeat.self, MCPWriteReceipt.self ])- _ = manager.makeModelConfiguration(schema: schema)+ _ = try manager.makeModelConfiguration(schema: schema) #expect(manager.isCloudSyncActive == true) manager.setSyncEnabled(false)
diff --git a/Transit/TransitUITests/TransitUITests.swift b/Transit/TransitUITests/TransitUITests.swiftindex ddaec4c0..b819bd5f 100644--- a/Transit/TransitUITests/TransitUITests.swift+++ b/Transit/TransitUITests/TransitUITests.swift@@ -38,6 +38,9 @@ final class TransitUITests: XCTestCase { app.tapTransitToolbarButton(identifier: "dashboard.settingsButton", overflowLabel: "Settings") // [req 12.1] Settings view is pushed onto the navigation stack+ let environment = app.staticTexts["settings.environment"]+ XCTAssertTrue(environment.waitForExistence(timeout: 5))+ XCTAssertEqual(environment.label, "Debug (UI test)") let settingsTitle = app.navigationBars["Settings"] XCTAssertTrue(settingsTitle.waitForExistence(timeout: 5)) }
diff --git a/tests/development-isolation/BootstrapProbe.swift b/tests/development-isolation/BootstrapProbe.swiftindex 7ab67c77..fa3f59e8 100644--- a/tests/development-isolation/BootstrapProbe.swift+++ b/tests/development-isolation/BootstrapProbe.swift@@ -3,6 +3,7 @@ import SwiftData @main struct BootstrapProbe {+ // swiftlint:disable:next function_body_length @MainActor static func main() async throws { let schema = Schema([Project.self, TransitTask.self, Comment.self, Milestone.self, SyncHeartbeat.self, MCPWriteReceipt.self])@@ -18,12 +19,12 @@ struct BootstrapProbe { context.insert(task) try context.save() var calls: [String] = []- let factory: (String) -> DisplayIDAllocator = { name in- calls.append(name)+ let factory: (String, String) -> DisplayIDAllocator = { name, container in+ calls.append(container + ":" + name) return DisplayIDAllocator(store: DisabledCounterStore(), isCloudSyncActive: true) } for mode in [AppPersistencePolicy.Mode.development, .unitTest, .uiTest, .production] {- for active in [false, true] where mode != .production || !active {+ for active in [false, true] where !mode.permitsCloudSync || !active { let pair = AppDisplayIDAllocators.make(mode: mode, syncActive: active, cloudFactory: factory) for allocator in [pair.tasks, pair.milestones] { precondition(!allocator.isCloudSyncActive)@@ -51,7 +52,13 @@ struct BootstrapProbe { let production = AppDisplayIDAllocators.make(mode: .production, syncActive: true, cloudFactory: factory) precondition(production.tasks.isCloudSyncActive && production.milestones.isCloudSyncActive)- precondition(calls == ["global-counter", "milestone-counter"])+ precondition(calls == ["iCloud.me.nore.ig.Transit:global-counter",+ "iCloud.me.nore.ig.Transit:milestone-counter"])+ calls.removeAll()+ let development = AppDisplayIDAllocators.make(mode: .development, syncActive: true, cloudFactory: factory)+ precondition(development.tasks.isCloudSyncActive && development.milestones.isCloudSyncActive)+ precondition(calls == ["iCloud.me.nore.ig.Transit.development:global-counter",+ "iCloud.me.nore.ig.Transit.development:milestone-counter"]) print("Bootstrap passed: isolated factory calls=0; active production counter names preserved") } }
diff --git a/tests/development-isolation/MigrationProbe.swift b/tests/development-isolation/MigrationProbe.swiftindex 9cd15c2e..a382f60c 100644--- a/tests/development-isolation/MigrationProbe.swift+++ b/tests/development-isolation/MigrationProbe.swift@@ -99,6 +99,15 @@ struct MigrationProbe { let expected = url.deletingLastPathComponent() .appendingPathComponent("TransitDevelopment/development.store") precondition(configuration.url == expected && !configuration.isStoredInMemoryOnly)+ precondition(configuration.cloudKitContainerIdentifier == nil)+ precondition(configuration.groupAppContainerIdentifier == nil)+ let cloud = try IsolatedPersistenceConfiguration.make(mode: .development, schema: schema,+ applicationSupportDirectory: url.deletingLastPathComponent(),+ cloudKitContainerID: AppPersistencePolicy.Mode.development.cloudKitContainerID)+ precondition(cloud.url == configuration.url && cloud.groupAppContainerIdentifier == nil)+ precondition(cloud.cloudKitContainerIdentifier == "iCloud.me.nore.ig.Transit.development")+ // Inspect the configuration only; never construct a cloud-backed container.+ for mode in [AppPersistencePolicy.Mode.unitTest, .uiTest] { let memory = try IsolatedPersistenceConfiguration.make(mode: mode, schema: schema) precondition(memory.isStoredInMemoryOnly)
diff --git a/tests/development-isolation/PolicyProbe.swift b/tests/development-isolation/PolicyProbe.swiftindex 4c91d40f..740a7b92 100644--- a/tests/development-isolation/PolicyProbe.swift+++ b/tests/development-isolation/PolicyProbe.swift@@ -32,7 +32,11 @@ struct PolicyProbe { try expect(mode(development, Policy.developmentBundleID, ["XCTestConfigurationFilePath": "/synthetic/test-config"]), .unitTest) }- precondition(!Policy.Mode.development.permitsCloudSync)+ precondition(Policy.Mode.development.permitsCloudSync)+ precondition(!Policy.Mode.unitTest.permitsCloudSync && !Policy.Mode.uiTest.permitsCloudSync)+ precondition(Policy.Mode.development.cloudKitContainerID != Policy.Mode.production.cloudKitContainerID)+ precondition(Policy.Mode.production.defaultMCPPort == 3141)+ precondition(Policy.Mode.development.defaultMCPPort == 3142) precondition(!Policy.Mode.unitTest.permitsBackgroundServices) precondition(Policy.Mode.uiTest.usesMemoryStore) print("Persistence policy checks passed")
diff --git a/tests/development-isolation/configuration_guard.py b/tests/development-isolation/configuration_guard.pyindex 98e29f86..4e66f0e1 100644--- a/tests/development-isolation/configuration_guard.py+++ b/tests/development-isolation/configuration_guard.py@@ -23,7 +23,16 @@ for target in objects.values(): isolated = name == "TransitDevelopment" or configuration["name"] == "Debug" if isolated: assert settings["PRODUCT_BUNDLE_IDENTIFIER"] == "me.nore.ig.Transit.development"- entitlements = plistlib.loads((root / "Transit" / settings["CODE_SIGN_ENTITLEMENTS"]).read_bytes())+ assert settings["TRANSIT_DEVELOPMENT_CLOUD_SYNC"] == "NO"+ assert settings["CODE_SIGN_ENTITLEMENTS"] == "$(TRANSIT_DEVELOPMENT_ENTITLEMENTS_$(TRANSIT_DEVELOPMENT_CLOUD_SYNC))"+ entitlements = plistlib.loads((root / "Transit" / settings["TRANSIT_DEVELOPMENT_ENTITLEMENTS_NO"]).read_bytes())+ for suffix, push_key in [("", "aps-environment"), ("[sdk=macosx*]", "com.apple.developer.aps-environment")]:+ cloud = plistlib.loads((root / "Transit" / settings["TRANSIT_DEVELOPMENT_ENTITLEMENTS_YES" + suffix]).read_bytes())+ assert cloud["com.apple.developer.icloud-container-identifiers"] == ["iCloud.me.nore.ig.Transit.development"]+ assert cloud["com.apple.developer.icloud-container-environment"] == "Development"+ assert cloud[push_key] == "development"+ assert not cloud.get("com.apple.security.application-groups")+ assert ("aps-environment" if suffix else "com.apple.developer.aps-environment") not in cloud assert not any("icloud" in key or "aps-environment" in key or "application-groups" in key for key in entitlements), entitlements assert settings["REGISTER_APP_GROUPS"] == "NO"
diff --git a/tests/safe-task-consolidation/run_closed_store.py b/tests/safe-task-consolidation/run_closed_store.pyindex e1b1c6ef..c1d5a2d4 100644--- a/tests/safe-task-consolidation/run_closed_store.py+++ b/tests/safe-task-consolidation/run_closed_store.py@@ -33,7 +33,7 @@ def drained(products, stage_pid=None): capture_output=True, text=True, check=True) roots = {str(products), str(products).removeprefix("/private")} paths = [root + suffix for root in roots for suffix in- ("/Debug/Transit.app/Contents/MacOS/Transit", "/Debug/TransitTests.xctest")]+ ("/Debug/TransitDevelopment.app/Contents/MacOS/TransitDevelopment", "/Debug/TransitTests.xctest")] owned = [line for line in inspection.stdout.splitlines() if any(path in line for path in paths) or (stage_pid is not None and line.strip().split(maxsplit=1)[0] == str(stage_pid))]
diff --git a/tests/typed-task-links/prepare_unit_run.py b/tests/typed-task-links/prepare_unit_run.pyindex fe13960e..2df3fcfc 100644--- a/tests/typed-task-links/prepare_unit_run.py+++ b/tests/typed-task-links/prepare_unit_run.py@@ -36,10 +36,10 @@ def require(condition, message): def validated_unit_run(products): """Revalidate signed host and return the existing unit-only migration selection."""- host = products / "Debug/Transit.app"+ host = products / "Debug/TransitDevelopment.app" info = plistlib.loads((host / "Contents/Info.plist").read_bytes()) require(info["CFBundleIdentifier"] == "me.nore.ig.Transit.development", "Unexpected host identity")- require(info["CFBundleExecutable"] == "Transit", "Unexpected host executable")+ require(info["CFBundleExecutable"] == "TransitDevelopment", "Unexpected host executable") subprocess.run(["/usr/bin/codesign", "--verify", "--strict", str(host)], check=True) signature = subprocess.run( ["/usr/bin/codesign", "-d", "--entitlements", ":-", str(host)],
diff --git a/tests/typed-task-links/run_closed_store.py b/tests/typed-task-links/run_closed_store.pyindex c5603f07..fa6d68ed 100644--- a/tests/typed-task-links/run_closed_store.py+++ b/tests/typed-task-links/run_closed_store.py@@ -32,7 +32,7 @@ def drained(products, stage_pid=None): capture_output=True, text=True, check=True) roots = {str(products), str(products).removeprefix("/private")} paths = [root + suffix for root in roots for suffix in- ("/Debug/Transit.app/Contents/MacOS/Transit", "/Debug/TransitTests.xctest")]+ ("/Debug/TransitDevelopment.app/Contents/MacOS/TransitDevelopment", "/Debug/TransitTests.xctest")] owned = [line for line in inspection.stdout.splitlines() if any(path in line for path in paths) or (stage_pid is not None and line.strip().split(maxsplit=1)[0] == str(stage_pid))]
diff --git a/tests/typed-task-links/run_commit_diagnostic.py b/tests/typed-task-links/run_commit_diagnostic.pyindex 61fa8d1a..04863aa6 100644--- a/tests/typed-task-links/run_commit_diagnostic.py+++ b/tests/typed-task-links/run_commit_diagnostic.py@@ -139,7 +139,7 @@ def main(): unit["EnvironmentVariables"].pop(flag, None) unit["EnvironmentVariables"][environment_flag] = "1" roots = {str(original), str(products), str(products).removeprefix("/private")}- executables = {root + "/Debug/Transit.app/Contents/MacOS/Transit" for root in roots}+ executables = {root + "/Debug/TransitDevelopment.app/Contents/MacOS/TransitDevelopment" for root in roots} bundles = {root + "/Debug/TransitTests.xctest" for root in roots} require(not host_processes(processes(), executables, bundles), "Existing build host; no launch allowed") with derived.open("xb") as stream:
diff --git a/CLAUDE.md b/CLAUDE.mdindex b00be907..04f1d2af 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -12,7 +12,7 @@ Transit is a native Apple task tracker (iOS 26 / iPadOS 26 / macOS 26) for a sin - **`SWIFT_DEFAULT_ACTOR_ISOLATION = MainActor`** — every type is `@MainActor` by default (see gotchas below) - **SwiftData** with **CloudKit** (private database) for cross-device sync - **App Intents** framework for CLI/automation integration via Shortcuts-- **MCP server** (macOS only) — HTTP-based JSON-RPC server using Hummingbird, configurable port (default 3141)+- **MCP server** (macOS only) — HTTP-based JSON-RPC server using Hummingbird, configurable port (Release default 3141, Debug default 3142) - **Liquid Glass** design language: `.glassEffect()`, `.buttonStyle(.glass)` / `.buttonStyle(.glassProminent)` - **Xcode File System Sync** enabled — Xcode auto-discovers files from disk, no need to edit pbxproj @@ -53,6 +53,8 @@ xcodebuild test -project Transit/Transit.xcodeproj -scheme Transit \ - **Before pushing (pre-push-review)**: Use `make test` and `make test-ui` — runs the full test suite on iOS Simulator - **For commits**: No tests required — lint only (`make lint`) +See [docs/environments.md](docs/environments.md) for isolated Debug/Release identities and the explicit dedicated Debug CloudKit signing setup. Routine Debug is local-only; Release retains its existing CloudKit Development backend.+ ## Architecture Overview ### Data Model
diff --git a/README.md b/README.mdindex b8d4ef4c..4719fab7 100644--- a/README.md+++ b/README.md@@ -82,3 +82,7 @@ The ten standalone write tools require an `idempotencyKey`. Task/milestone updat - `docs/transit-design-doc.md` — full design document - `docs/agent-notes/` — implementation notes on architecture and technical constraints - `CLAUDE.md` — guidance for Claude Code when working in this repository++## Debug and Release coexistence++See [environment setup](docs/environments.md) for separate app identities, local stores and defaults, the dedicated Debug iCloud opt-in, and MCP defaults (Debug 3142, Release 3141). The existing Release CloudKit Development dataset is preserved.
diff --git a/docs/agent-notes/mcp-server.md b/docs/agent-notes/mcp-server.mdindex d4762ec1..3782ed6b 100644--- a/docs/agent-notes/mcp-server.md+++ b/docs/agent-notes/mcp-server.md@@ -12,7 +12,7 @@ Claude Code ←→ HTTP POST + request-scoped POST/SSE /mcp (localhost:3141) ← - **Transport**: Latest-only MCP `2026-07-28` at `POST /mcp`: server/discover, tools/list, tools/call and request-scoped subscriptions/listen SSE. No initialize, session ID, GET listener or wire arrays. Required metadata/headers and result schemas are documented in [the result contract](../mcp-result-contract.md). - **HTTP server**: Hummingbird 2.x (SwiftNIO-based), binds to `127.0.0.1` only-- **Lifecycle**: Opt-in via Settings toggle. Default port 3141.+- **Lifecycle**: Opt-in via Settings toggle. Default ports: Release 3141, Debug 3142. See [environment setup](../environments.md) for separate client names and signing. ## Files
diff --git a/docs/environments.md b/docs/environments.mdnew file mode 100644index 00000000..93de7c10--- /dev/null+++ b/docs/environments.md@@ -0,0 +1,51 @@+# Separate Transit environments (T-2432)++Debug and Release may coexist. Build each into its own DerivedData directory and keep both app bundles when copying them elsewhere: Debug produces `TransitDevelopment.app`; Release produces `Transit.app`. `TransitDevelopment` is also an explicit development target whose optimized builds retain Debug identity.++| Binding | Release | Debug / TransitDevelopment |+| --- | --- | --- |+| Bundle / standard defaults domain | `me.nore.ig.Transit` | `me.nore.ig.Transit.development` |+| Local SwiftData storage | Existing default configuration and URL | Existing `Application Support/TransitDevelopment/development.store` |+| CloudKit private database | `iCloud.me.nore.ig.Transit` | `iCloud.me.nore.ig.Transit.development` when opted in |+| CloudKit environment | Existing recovered **Development** dataset | **Development** in the separate container |+| Default MCP port | 3141 | 3142 |+| MCP identity / client setup name | `transit` | `transit-debug` |++Release identity, entitlements, default store selection and existing preferences are preserved. Release here names the application build, not CloudKit Production. Do not promote schemas, change its CloudKit environment, reset its container, or migrate data as part of enabling Debug. A future move of the live app to CloudKit Production requires a separately reviewed data transition.++Debug has no App Group entitlement, and its persistent configuration uses an explicit private store URL, bypassing automatic group-container selection. Standard UserDefaults (theme, name, sync preference, MCP settings) use its separate bundle domain. MCP receipts and reservation sidecars follow each selected store URL. Test modes retain in-memory storage, no cloud containers, disabled counters, disposable sidecars and no automatic MCP startup, even when a cloud-capable development binary is used.++## Enable the dedicated Debug cloud backend++Ordinary Debug remains local-only until the new Apple capabilities are ready. The single build setting `TRANSIT_DEVELOPMENT_CLOUD_SYNC=YES` selects both the platform-correct dedicated cloud entitlement file and the corresponding startup flag. Settings identifies the running app and active backend. No fallback redirects Debug to the Release container.++Required developer setup (manual, once):++1. In Apple Developer for team `V24684SCZN`, register/verify App ID `me.nore.ig.Transit.development` and iCloud container `iCloud.me.nore.ig.Transit.development`.+2. Enable CloudKit and Push Notifications for that development App ID, associate **only** the new container, and refresh the development profiles for the platforms you use. Do not modify the Release App ID or its container association.+3. Set `TRANSIT_DEVELOPMENT_CLOUD_SYNC=YES` for your development build, using the existing development signing identity. For example:++```sh+xcodebuild build -project Transit/Transit.xcodeproj -scheme TransitDevelopment \+ -configuration Debug -destination 'platform=macOS' \+ -derivedDataPath DerivedData/DebugCloud TRANSIT_DEVELOPMENT_CLOUD_SYNC=YES+```++The source prepares `DevelopmentCloud.entitlements` for iOS and `DevelopmentCloudMac.entitlements` for macOS, each explicitly selecting CloudKit Development and only the dedicated Debug container. This implementation does not create Apple resources, auto-register profiles, initialize a schema on a live cloud account during verification, launch production, or install either app. Actual Debug cloud sync must be checked after this setup; an unsigned build cannot demonstrate iCloud access.++Keep `TRANSIT_DEVELOPMENT_CLOUD_SYNC=NO` for local-only development and routine tests. Unit/UI test launch policy prohibits CloudKit regardless of the build setting. Turning sync on/off remains restart-scoped; the current store and ID counter retain their launch-fixed backend until relaunch.++## MCP connections++On first use, enable each app's MCP server in its own Settings. The selected valid port is persisted in that app's defaults domain; existing explicit overrides are preserved, including an intentionally shared port (the server reports a bind failure). Different defaults prevent a collision without rewriting a user's port choice.++```sh+claude mcp add transit --transport http http://localhost:3141/mcp+claude mcp add transit-debug --transport http http://localhost:3142/mcp+```++Use the running listener's port shown in Settings if overridden. MCP `server/discover` identifies development binaries as `transit-debug`, including optimized `TransitDevelopment` builds. Settings reports `Debug`, `Release`, or the isolated test environment along with the active cloud container or local-only status.++## Verification boundaries++`make test-development-configuration` audits bundle IDs, build flags, entitlements and test launches. `make test-development-isolation` uses synthetic stores under a network-denying sandbox and denies access to the Release container and Group Containers. Unit regression fixtures check independent MCP defaults and explicit overrides, invalid Debug cloud binding rejection, and the existing sync launch behavior. Tests do not open recovered Release storage or contact either CloudKit backend.