Skip to content

Instantly share code, notes, and snippets.

@Fannolo
Created October 31, 2026 15:16
Show Gist options
  • Select an option

  • Save Fannolo/db8a61221086e9e306a0526c132958b9 to your computer and use it in GitHub Desktop.

Select an option

Save Fannolo/db8a61221086e9e306a0526c132958b9 to your computer and use it in GitHub Desktop.
Swift settings migration verification: core regression tests and isolated native WebSocket probe
import Foundation
@testable import T3Code
@main struct RuntimeProbe {
static func main() async throws {
let pairingURL = try String(contentsOfFile: CommandLine.arguments[1], encoding: .utf8)
let store = EnvironmentStore(fileURL: URL(fileURLWithPath: "/tmp/t3-swift-settings-probe-environments.json"))
let credentials = InMemoryCredentialStore()
let pairing = PairingService(environmentStore: store, credentialStore: credentials)
let environment = try await pairing.pair(url: pairingURL, label: "Settings compatibility probe")
let client = T3Client(environment: environment, credentialStore: credentials)
await client.connect()
let rpc = await client.rpc
do {
let _: JSONValue = try await rpc.request("server.getSettings", as: JSONValue.self)
fatalError("Expected installed server to reject legacy request")
} catch {
guard error.localizedDescription.contains("Unknown request tag: server.getSettings") else { throw error }
print("PASS baseline: installed nightly rejects server.getSettings")
}
let before = try await client.serverSettings()
let next = !before.newWorktreesStartFromOrigin
let _: JSONValue = try await rpc.request("server.updateSettings", payload: .object([
"patch": .object(["newWorktreesStartFromOrigin": .bool(next)]),
]), as: JSONValue.self)
let after = try await client.serverSettings()
precondition(after.newWorktreesStartFromOrigin == next)
print("PASS migrated settings read sees saved changes over native URLSession WebSocket")
let _: JSONValue = try await rpc.request("server.updateSettings", payload: .object([
"patch": .object(["reviewGuidesEnabled": .bool(true)]),
]), as: JSONValue.self)
let reviewGuides = try await client.reviewGuidesEnabled()
precondition(reviewGuides)
print("PASS review-guide flag reads configuration.settings")
try await client.setProviderEnabled(instanceID: "codex", driver: "codex", enabled: false)
let config: JSONValue = try await rpc.request("server.getConfig", as: JSONValue.self)
precondition(config["settings"]?["providerInstances"]?["codex"]?["enabled"] == .bool(false))
print("PASS provider toggle writes settings after reading configuration.settings")
await client.disconnect()
}
}
Before fix: same regression tests with the two production files restored from the PR parent
Test Suite 'Selected tests' started at 2026-10-31 16:13:54.506.
Test Suite 'SettingsCompatibilityPackageTests.xctest' started at 2026-10-31 16:13:54.511.
Test Suite 'T3ClientServerConfigTests' started at 2026-10-31 16:13:54.511.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testProviderToggleAndReviewGuidesReadSettingsFromConfiguration]' started.
/private/tmp/t3-swift-settings-harness/Core/WebSocketRPC.swift:561: error: -[SettingsCompatibilityTests.T3ClientServerConfigTests testProviderToggleAndReviewGuidesReadSettingsFromConfiguration] : failed: caught error: "remote("Unknown request tag: server.getSettings")"
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testProviderToggleAndReviewGuidesReadSettingsFromConfiguration]' failed (0.114 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSettingsReadsStayFreshWhenTheLegacyMethodIsUnavailable]' started.
/private/tmp/t3-swift-settings-harness/Core/WebSocketRPC.swift:561: error: -[SettingsCompatibilityTests.T3ClientServerConfigTests testSettingsReadsStayFreshWhenTheLegacyMethodIsUnavailable] : failed: caught error: "remote("Unknown request tag: server.getSettings")"
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSettingsReadsStayFreshWhenTheLegacyMethodIsUnavailable]' failed (0.003 seconds).
Test Suite 'T3ClientServerConfigTests' failed at 2026-10-31 16:13:54.628.
Executed 2 tests, with 2 failures (2 unexpected) in 0.117 (0.117) seconds
Test Suite 'SettingsCompatibilityPackageTests.xctest' failed at 2026-10-31 16:13:54.629.
Executed 2 tests, with 2 failures (2 unexpected) in 0.117 (0.118) seconds
Test Suite 'Selected tests' failed at 2026-10-31 16:13:54.629.
Executed 2 tests, with 2 failures (2 unexpected) in 0.117 (0.123) seconds
After fix: actual Core sources and T3ClientServerConfigTests
Test Suite 'Selected tests' started at 2026-10-31 16:15:33.485.
Test Suite 'SettingsCompatibilityPackageTests.xctest' started at 2026-10-31 16:15:33.491.
Test Suite 'T3ClientServerConfigTests' started at 2026-10-31 16:15:33.491.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testBootstrapAndListenerShareSubscriptionThenReplayFoldedConfig]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testBootstrapAndListenerShareSubscriptionThenReplayFoldedConfig]' passed (0.006 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testCapableSnapshotPreservesSourcesUntilAnExplicitUpdate]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testCapableSnapshotPreservesSourcesUntilAnExplicitUpdate]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testDisconnectCancelsPendingBootstrapAndRejectsStaleStreamCallbacks]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testDisconnectCancelsPendingBootstrapAndRejectsStaleStreamCallbacks]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testFailedQuestionAttachmentUploadDoesNotSubmitTheAnswer]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testFailedQuestionAttachmentUploadDoesNotSubmitTheAnswer]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testLateSourceUpdatesAreNotPublishedWithoutTheCapability]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testLateSourceUpdatesAreNotPublishedWithoutTheCapability]' passed (0.002 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testOnlyExplicitUnsupportedMethodFallsBackToUnaryConfig]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testOnlyExplicitUnsupportedMethodFallsBackToUnaryConfig]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testProviderToggleAndReviewGuidesReadSettingsFromConfiguration]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testProviderToggleAndReviewGuidesReadSettingsFromConfiguration]' passed (0.002 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testQuestionAttachmentsRequireTheServerCapabilityBeforeUploading]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testQuestionAttachmentsRequireTheServerCapabilityBeforeUploading]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testQuestionAttachmentsUploadBeforeDispatchAndDoNotSendInlineData]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testQuestionAttachmentsUploadBeforeDispatchAndDoNotSendInlineData]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testReconnectToOlderServerClearsSources]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testReconnectToOlderServerClearsSources]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testRefreshPreservesSourceAndSettingsUpdatesReceivedDuringTheRequest]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testRefreshPreservesSourceAndSettingsUpdatesReceivedDuringTheRequest]' passed (0.001 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testResetCreditIsNotReplayedAfterASocketFailure]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testResetCreditIsNotReplayedAfterASocketFailure]' passed (0.365 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testResetCreditUsesTheSelectedInstance]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testResetCreditUsesTheSelectedInstance]' passed (0.003 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSettingsReadsStayFreshWhenTheLegacyMethodIsUnavailable]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSettingsReadsStayFreshWhenTheLegacyMethodIsUnavailable]' passed (0.004 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSilentSubscriptionBootstrapTimesOutAndCancellationDoesNotLeaveAWaiter]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSilentSubscriptionBootstrapTimesOutAndCancellationDoesNotLeaveAWaiter]' passed (0.030 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSourceUpdatesReplaceTheFullSetIncludingEmpty]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testSourceUpdatesReplaceTheFullSetIncludingEmpty]' passed (0.005 seconds).
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testUnknownUsageUnavailableReasonKeepsTheProviderInConfig]' started.
Test Case '-[SettingsCompatibilityTests.T3ClientServerConfigTests testUnknownUsageUnavailableReasonKeepsTheProviderInConfig]' passed (0.001 seconds).
Test Suite 'T3ClientServerConfigTests' passed at 2026-10-31 16:15:33.919.
Executed 17 tests, with 0 failures (0 unexpected) in 0.427 (0.429) seconds
Test Suite 'SettingsCompatibilityPackageTests.xctest' passed at 2026-10-31 16:15:33.919.
Executed 17 tests, with 0 failures (0 unexpected) in 0.427 (0.429) seconds
Test Suite 'Selected tests' passed at 2026-10-31 16:15:33.919.
Executed 17 tests, with 0 failures (0 unexpected) in 0.427 (0.434) seconds
Native URLSession probe against isolated 0.1.6-nightly.20261030.3904 server
PASS baseline: installed nightly rejects server.getSettings
PASS migrated settings read sees saved changes over native URLSession WebSocket
PASS review-guide flag reads configuration.settings
PASS provider toggle writes settings after reading configuration.settings
Full iOS app build limitation, before production edits:
Xcode 26.3 (17C529), iOS 26.3 simulator.
FeatureThreadToolsToolbar.swift:60: @SwiftUI.Environment(\.toolbarVerticalEdge) fails to compile with this SDK.
The Core test package avoids that UI file. The iOS feature suites and installed TestFlight app were not run.
#!/usr/bin/env bash
set -euo pipefail
# Run from the t3code checkout at the PR head. The SDK-dependent app UI is excluded.
repo="$(git rev-parse --show-toplevel)"
work="$(mktemp -d "${TMPDIR:-/tmp}/t3-settings-tests.XXXXXX")"
mkdir -p "$work/Tests"
ln -s "$repo/apps/swift-ios/Core" "$work/Core"
ln -s "$repo/apps/swift-ios/Tests/CoreTests/T3ClientServerConfigTests.swift" "$work/Tests/T3ClientServerConfigTests.swift"
cat > "$work/Package.swift" <<'SWIFT'
// swift-tools-version: 6.0
import PackageDescription
let package = Package(name: "SettingsCompatibility", platforms: [.macOS(.v15)], targets: [
.target(name: "T3Code", path: "Core", exclude: ["T3Client+MCPApps.swift"]),
.testTarget(name: "SettingsCompatibilityTests", dependencies: ["T3Code"], path: "Tests"),
], swiftLanguageModes: [.v5])
SWIFT
# The excluded MCP adapter depends on FeatureMCPOperation in the app layer.
# All settings, configuration, transport, and persistence code is compiled unchanged.
swift test --package-path "$work" --filter T3ClientServerConfigTests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment