- Split config into LaunchSnapshot (frozen security keys: ollama, applescript, toolBlocklist, confirmationPolicy, logging) and PerTurnSnapshot (mutable: provider, tts, stt, featureFlags) per SEC-05 - OllamaConfig.init(from:) rejects non-localhost hosts at decode time with ConfigError.invalidOllamaHost (AGENT-05) - AppleScriptPolicy has no skipAllowlist/bypass/regex field (SEC-08); reflection test ConfigSplitTests.test_noSkipAllowlistKey enforces - FeatureFlags lives in PerTurnSnapshot only (OBS-05); reflection test LaunchSnapshotTests.test_featureFlagsNotInLaunchSnapshot enforces - SchemaMigrator: currentVersion=1, v1->v1 pass-through, future versions throw ConfigError.futureSchema - ConfigLoader.loadSnapshots: peek schemaVersion, migrate, decode both snapshots; wraps DecodingError into ConfigError.malformed - ConfigStore actor holds launch + streams perTurn updates (file- watcher wiring is Plan 03 scope) - Bundled default-config.json resource - Tests: 15/15 pass covering all behaviors listed in the plan - Deletes Plan 01 placeholders Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
34 lines
1.5 KiB
Swift
34 lines
1.5 KiB
Swift
import XCTest
|
|
@testable import Config
|
|
|
|
final class ConfigSplitTests: XCTestCase {
|
|
func test_securityKeysInLaunchOnly() throws {
|
|
let launch = try ConfigTestFixtures.launch()
|
|
let mirror = Mirror(reflecting: launch)
|
|
let names = Set(mirror.children.compactMap { $0.label })
|
|
for key in ["ollama", "applescript", "toolBlocklist", "confirmationPolicy", "logging"] {
|
|
XCTAssertTrue(names.contains(key), "LaunchSnapshot missing security key: \(key)")
|
|
}
|
|
}
|
|
|
|
func test_nonSecurityKeysInPerTurnOnly() throws {
|
|
let perTurn = try ConfigTestFixtures.perTurn(flags: [:])
|
|
let mirror = Mirror(reflecting: perTurn)
|
|
let names = Set(mirror.children.compactMap { $0.label })
|
|
for key in ["provider", "tts", "stt", "featureFlags"] {
|
|
XCTAssertTrue(names.contains(key), "PerTurnSnapshot missing key: \(key)")
|
|
}
|
|
}
|
|
|
|
func test_noSkipAllowlistKey() {
|
|
// SEC-08: reflect over AppleScriptPolicy and assert no allowlist-like field exists.
|
|
let policy = AppleScriptPolicy(confirmationRequired: true)
|
|
let mirror = Mirror(reflecting: policy)
|
|
let names = mirror.children.compactMap { ($0.label ?? "").lowercased() }
|
|
for forbidden in ["skipallowlist", "skip_allowlist", "allowlist", "bypass", "regex"] {
|
|
XCTAssertFalse(names.contains(forbidden),
|
|
"SEC-08 violation: AppleScriptPolicy has forbidden field '\(forbidden)'")
|
|
}
|
|
}
|
|
}
|