diff --git a/CLAUDE.md b/CLAUDE.md index fba72f9..d26441a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -332,7 +332,7 @@ a lighthouse is loaded. - No external dependencies — `Package.swift` stays dependency-free - Atomic writes (`options: .atomic`) for all state persistence -- User input sanitized at `SynapseCore.init` boundary (strips `/`, `\`, `:`, `.` from folder names) +- Explicit user input validated at the throwing `SynapseCore.init(folderName:user:baseOverride:)` boundary; safe names are preserved exactly. Separators/control characters are rejected, and ambiguous legacy aliases require an explicit owner decision. The built-in default initializer remains nonthrowing. - Errors → stderr (`StandardErrorStream`); stdout is machine-readable output only - Tests use unique UUID folder names for isolation — never break this pattern, never share state between test cases - All bedrock output types must be `Sendable` — they cross actor isolation boundaries diff --git a/Sources/SynapseCore/Circuit/SynapticCircuit.swift b/Sources/SynapseCore/Circuit/SynapticCircuit.swift index ba86573..6633176 100644 --- a/Sources/SynapseCore/Circuit/SynapticCircuit.swift +++ b/Sources/SynapseCore/Circuit/SynapticCircuit.swift @@ -363,6 +363,7 @@ public actor SynapticCircuit { } } } + guard !next.isEmpty else { break } frontier = next depth += 1 } diff --git a/Sources/SynapseCore/SynapseCore.swift b/Sources/SynapseCore/SynapseCore.swift index f3a34f8..3e5d567 100644 --- a/Sources/SynapseCore/SynapseCore.swift +++ b/Sources/SynapseCore/SynapseCore.swift @@ -312,36 +312,38 @@ public class SynapseCore { /// - Parameters: /// - folderName: top-level app-support folder name. - /// - user: per-user namespace (sanitized for path traversal). + /// - user: explicit per-user namespace (validated without rewriting). /// - baseOverride: dependency-injection seam for the storage root that /// normally resolves to `~/Library/Application Support`. Injecting a /// temp (or deliberately read-only) directory lets tests exercise real /// disk-I/O failure paths — e.g. verifying `saveWeights` returns /// `false` when the destination is unwritable (ADR-005). `nil` keeps /// the production location; no behaviour change for normal callers. - public init(folderName: String = "ContextSynapse", user: String = "default", baseOverride: URL? = nil) { - // Validate and sanitize user input to prevent directory traversal - // Remove path separators and dots to prevent traversal attacks - let sanitizedUser = user - .components(separatedBy: CharacterSet(charactersIn: "/\\:.")) - .joined() + // The built-in default namespace remains source-compatible for GUI callers. + public convenience init(folderName: String = "ContextSynapse", baseOverride: URL? = nil) { + self.init(folderName: folderName, storageUser: "default", baseOverride: baseOverride) + } - // Ensure the sanitized user is not empty and is alphanumeric with limited special chars - guard !sanitizedUser.isEmpty, - sanitizedUser.rangeOfCharacter(from: CharacterSet.alphanumerics.union(CharacterSet(charactersIn: "-_"))) != nil else { - fatalError("Invalid user identifier: must contain alphanumeric characters") - } + /// Explicit identifiers are validated, never rewritten. Failures happen + /// before any directory creation, profile update, or default-state seeding. + public convenience init(folderName: String = "ContextSynapse", user: String, baseOverride: URL? = nil) throws { + let root = baseOverride ?? FileManager.default.homeDirectoryForCurrentUser + .appendingPathComponent("Library").appendingPathComponent("Application Support") + try UserStorage.validate(user, usersDir: root.appendingPathComponent(folderName).appendingPathComponent("users")) + self.init(folderName: folderName, storageUser: user, baseOverride: baseOverride) + } + private init(folderName: String, storageUser: String, baseOverride: URL?) { let home = fm.homeDirectoryForCurrentUser let storageRoot = baseOverride ?? home.appendingPathComponent("Library").appendingPathComponent("Application Support") let baseDir = storageRoot.appendingPathComponent(folderName) self.appSupport = baseDir self.usersDir = baseDir.appendingPathComponent("users") - self.currentUser = sanitizedUser + self.currentUser = storageUser // Create user-specific directories - let userDir = usersDir.appendingPathComponent(sanitizedUser) + let userDir = usersDir.appendingPathComponent(storageUser) self.configURL = userDir.appendingPathComponent("config.json") self.regionsURL = userDir.appendingPathComponent("regions.json") self.logDir = userDir.appendingPathComponent("logs") @@ -827,7 +829,7 @@ public class SynapseCore { } /// Switch to a different user (requires reinitializing SynapseCore) - public static func switchUser(to user: String, folderName: String = "ContextSynapse") -> SynapseCore { - return SynapseCore(folderName: folderName, user: user) + public static func switchUser(to user: String, folderName: String = "ContextSynapse") throws -> SynapseCore { + return try SynapseCore(folderName: folderName, user: user) } } diff --git a/Sources/SynapseCore/UserStorage.swift b/Sources/SynapseCore/UserStorage.swift new file mode 100644 index 0000000..a345876 --- /dev/null +++ b/Sources/SynapseCore/UserStorage.swift @@ -0,0 +1,67 @@ +import Foundation + +/// Path safety without lossy identity normalization. Existing space-named +/// directories remain in place; ambiguous historical aliases need an explicit +/// choice by the owner, not an automatic migration that could claim another user. +enum UserStorage { + enum ValidationError: LocalizedError { + case invalidIdentifier + case ambiguousLegacy(String) + case conflictingOwner + + var errorDescription: String? { + switch self { + case .invalidIdentifier: + return "Use a single name containing a letter or digit, without path separators, colon, or control characters (at most 200 UTF-8 bytes)." + case .ambiguousLegacy(let key): + return "Existing state uses the legacy name '\(key)'. Select that stored name explicitly or back up and rename its directory; ownership cannot be inferred safely." + case .conflictingOwner: + return "This directory belongs to a different identifier. Use its exact stored name." + } + } + } + + static func validate(_ user: String, usersDir: URL) throws { + let forbidden = CharacterSet.controlCharacters.union(CharacterSet(charactersIn: "/\\:")) + guard !user.isEmpty, user.utf8.count <= 200, + user.rangeOfCharacter(from: forbidden) == nil, + user.rangeOfCharacter(from: .alphanumerics) != nil else { + throw ValidationError.invalidIdentifier + } + let fm = FileManager.default + let directory = usersDir.appendingPathComponent(user) + if fm.fileExists(atPath: directory.path) { + // Refuse case/normalization aliases on case-insensitive volumes even + // if the old directory has no profile. Never overwrite its identity. + let names = try fm.contentsOfDirectory(atPath: usersDir.path) + guard names.contains(user) else { throw ValidationError.conflictingOwner } + let profileURL = directory.appendingPathComponent("profile.json") + if fm.fileExists(atPath: profileURL.path) { + let profile = try JSONDecoder().decode(UserProfile.self, from: Data(contentsOf: profileURL)) + guard profile.id == user else { throw ValidationError.conflictingOwner } + } + } else { + // Preserve exact existing owners (including Default/DEFAULT), but + // reserve new case variants of the built-in namespace. + guard user.lowercased() != "default" || user == "default" else { + throw ValidationError.invalidIdentifier + } + let legacy = user.components(separatedBy: CharacterSet(charactersIn: "/\\:.")).joined() + if legacy != user, !legacy.isEmpty, + fm.fileExists(atPath: usersDir.appendingPathComponent(legacy).path) { + // Report the name as stored on disk: on a case-insensitive volume + // `legacy` may match a directory spelled differently, and only the + // stored spelling passes the exact-name check above. + throw ValidationError.ambiguousLegacy(storedName(matching: legacy, in: usersDir) ?? legacy) + } + } + } + + /// The directory entry that `name` resolves to on this volume: an exact + /// match first, then a case- or normalization-insensitive one. + static func storedName(matching name: String, in usersDir: URL) -> String? { + guard let names = try? FileManager.default.contentsOfDirectory(atPath: usersDir.path) else { return nil } + if names.contains(name) { return name } + return names.first { $0.compare(name, options: [.caseInsensitive]) == .orderedSame } + } +} diff --git a/Sources/contextsynapse/main.swift b/Sources/contextsynapse/main.swift index 367cb02..aacc5c3 100644 --- a/Sources/contextsynapse/main.swift +++ b/Sources/contextsynapse/main.swift @@ -20,14 +20,24 @@ if instrumentFlags.contains(where: args.contains) && stateFlags.contains(where: var selectedUser = "default" var scanIndex = 1 while scanIndex < args.count { - if args[scanIndex] == "--user", scanIndex + 1 < args.count { + if args[scanIndex] == "--user" { + guard scanIndex + 1 < args.count, !args[scanIndex + 1].hasPrefix("--") else { + fputs("--user requires an identifier\n", stderr) + exit(2) + } selectedUser = args[scanIndex + 1] break } scanIndex += 1 } -let core = SynapseCore(user: selectedUser) +let core: SynapseCore +do { + core = try SynapseCore(user: selectedUser) +} catch { + fputs("Invalid --user: \(error.localizedDescription)\n", stderr) + exit(2) +} // MARK: - Instrument verbs (record / export-events / events-summary) // Terminal commands that append to or read the observation ledger, then exit. diff --git a/Tests/PR40CircuitTests.swift b/Tests/PR40CircuitTests.swift new file mode 100644 index 0000000..a9e1244 --- /dev/null +++ b/Tests/PR40CircuitTests.swift @@ -0,0 +1,31 @@ +import XCTest +@testable import SynapseCore + +final class PR40CircuitTests: XCTestCase { + func testUpdatingEdgeWeightPreservesEdgeIdentity() async throws { + let circuit = SynapticCircuit() + let source = SynapticNode(synapseID: "source") + let target = SynapticNode(synapseID: "target") + let edge = CircuitEdge(source: source.id, target: target.id, weight: 0.2) + await circuit.register(source) + await circuit.register(target) + await circuit.connect(edge) + await circuit.updateEdgeWeight(id: edge.id, weight: 0.8) + await circuit.updateEdgeWeight(id: edge.id, weight: 0.5) + let snapshot = await circuit.snapshot() + XCTAssertEqual(snapshot.edges.count, 1) + XCTAssertEqual(snapshot.edges.first?.id, edge.id) + XCTAssertEqual(snapshot.edges.first?.weight, 0.5) + } + + func testFaultInjectionReportsIsolatedNodeAsTooIsolated() async throws { + let circuit = SynapticCircuit() + await circuit.register(SynapticNode(synapseID: "isolated")) + _ = await circuit.forwardPass() + let report = await circuit.injectFault(intoSynapse: "isolated", severity: 1.0) + XCTAssertEqual(report.propagationDepth, 0) + XCTAssertEqual(report.affectedNodeCount, 0) + XCTAssertTrue(report.isTooIsolated) + XCTAssertFalse(report.isHealthy) + } +} diff --git a/Tests/PersistenceFailureTests.swift b/Tests/PersistenceFailureTests.swift index a4b8c1a..234ccf3 100644 --- a/Tests/PersistenceFailureTests.swift +++ b/Tests/PersistenceFailureTests.swift @@ -32,7 +32,7 @@ final class PersistenceFailureTests: XCTestCase { let root = try makeReadOnlyRoot() defer { makeWritableAgain(root) } - let core = SynapseCore(folderName: "CS_\(UUID().uuidString)", + let core = try SynapseCore(folderName: "CS_\(UUID().uuidString)", user: "u", baseOverride: root) @@ -46,7 +46,7 @@ final class PersistenceFailureTests: XCTestCase { let root = try makeReadOnlyRoot() defer { makeWritableAgain(root) } - let core = SynapseCore(folderName: "CS_\(UUID().uuidString)", + let core = try SynapseCore(folderName: "CS_\(UUID().uuidString)", user: "u", baseOverride: root) @@ -70,7 +70,7 @@ final class PersistenceFailureTests: XCTestCase { try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true) defer { try? FileManager.default.removeItem(at: root) } - let core = SynapseCore(folderName: "CS_\(UUID().uuidString)", + let core = try SynapseCore(folderName: "CS_\(UUID().uuidString)", user: "u", baseOverride: root) diff --git a/Tests/UserIdentifierCLITests.swift b/Tests/UserIdentifierCLITests.swift new file mode 100644 index 0000000..beb5be3 --- /dev/null +++ b/Tests/UserIdentifierCLITests.swift @@ -0,0 +1,35 @@ +import XCTest +import Foundation + +final class UserIdentifierCLITests: XCTestCase { + func testInvalidUserExitsNormallyWithoutCreatingState() throws { + let repository = URL(fileURLWithPath: #filePath).deletingLastPathComponent().deletingLastPathComponent() + let executable = repository.appendingPathComponent(".build/debug/contextsynapse") + // Fail rather than skip: build the CLI before running integration tests. + XCTAssertTrue(FileManager.default.isExecutableFile(atPath: executable.path)) + for arguments in [["--user", "🔥"], ["--user", "***"], ["--user", "../Ada"], ["--user", ""], ["--user"], ["--user", "--export"]] { + let home = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) + try FileManager.default.createDirectory(at: home, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: home) } + let process = Process() + process.executableURL = executable + process.arguments = arguments + process.currentDirectoryURL = repository + var environment = ProcessInfo.processInfo.environment + environment["HOME"] = home.path + environment["CFFIXED_USER_HOME"] = home.path + process.environment = environment + let errorPipe = Pipe() + process.standardError = errorPipe + process.standardOutput = FileHandle.nullDevice + process.standardInput = FileHandle.nullDevice + try process.run() + process.waitUntilExit() + let error = String(decoding: errorPipe.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self) + XCTAssertEqual(process.terminationReason, .exit, arguments.description) + XCTAssertEqual(process.terminationStatus, 2, arguments.description) + XCTAssertTrue(error.contains("--user"), error) + XCTAssertFalse(FileManager.default.fileExists(atPath: home.appendingPathComponent("Library/Application Support/ContextSynapse").path)) + } + } +} diff --git a/Tests/UserStorageTests.swift b/Tests/UserStorageTests.swift new file mode 100644 index 0000000..770cbea --- /dev/null +++ b/Tests/UserStorageTests.swift @@ -0,0 +1,167 @@ +import XCTest +import Foundation +@testable import SynapseCore + +final class UserStorageTests: XCTestCase { + private func withRoot(_ body: (URL) throws -> Void) throws { + let root = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) + try FileManager.default.createDirectory(at: root, withIntermediateDirectories: true) + defer { try? FileManager.default.removeItem(at: root) } + try body(root) + } + + func testDistinctIdentifiersDoNotShareState() throws { + try withRoot { root in + // Create the punctuated name first: it must never be silently stripped. + let names = ["Ada.Name", "Ada Name", "AdaName"] + var paths = Set() + for name in names { + let core = try SynapseCore(user: name, baseOverride: root) + paths.insert(core.configURL.path) + XCTAssertTrue(core.saveLighthouse(SynapseContent(id: name, text: name))) + } + XCTAssertEqual(paths.count, 3) + for name in names { + let core = try SynapseCore(user: name, baseOverride: root) + XCTAssertEqual(core.loadLighthouseRecord()?.text, name) + } + } + } + + func testExistingSpaceNamedDirectoryIsPreserved() throws { + try withRoot { root in + let userDir = root.appendingPathComponent("ContextSynapse/users/Ada Name") + try FileManager.default.createDirectory(at: userDir.appendingPathComponent("logs"), withIntermediateDirectories: true) + let seed = SynapseCore(folderName: "Seed", baseOverride: root) + var weights = seed.defaultWeights() + weights.intents["Create"] = 2.75 + try JSONEncoder().encode(weights).write(to: userDir.appendingPathComponent("config.json")) + let regions = [Region(name: "preserved", vector: [1, 0])] + try JSONEncoder().encode(regions).write(to: userDir.appendingPathComponent("regions.json")) + let marker = Data("preserved".utf8) + for path in ["logs/old.json", "session.json", "referee.json"] { + try marker.write(to: userDir.appendingPathComponent(path)) + } + let core = try SynapseCore(user: "Ada Name", baseOverride: root) + XCTAssertEqual(core.loadOrCreateDefaultWeights().intents["Create"], 2.75) + XCTAssertEqual(core.loadOrSeedRegions().first?.name, "preserved") + for path in ["logs/old.json", "session.json", "referee.json"] { + XCTAssertEqual(try Data(contentsOf: userDir.appendingPathComponent(path)), marker) + } + XCTAssertFalse(FileManager.default.fileExists(atPath: root.appendingPathComponent("ContextSynapse/users/AdaName").path)) + } + } + + func testAmbiguousLegacyDirectoryIsNotClaimedOrModified() throws { + try withRoot { root in + let owner = try SynapseCore(user: "AdaName", baseOverride: root) + let before = try Data(contentsOf: owner.configURL) + XCTAssertThrowsError(try SynapseCore(user: "Ada.Name", baseOverride: root)) + XCTAssertEqual(try Data(contentsOf: owner.configURL), before) + XCTAssertFalse(FileManager.default.fileExists(atPath: root.appendingPathComponent("ContextSynapse/users/Ada.Name").path)) + } + } + + func testAmbiguousLegacyNamesTheStoredSpelling() throws { + try withRoot { root in + _ = try SynapseCore(user: "adaname", baseOverride: root) + let usersDir = root.appendingPathComponent("ContextSynapse/users") + guard FileManager.default.fileExists(atPath: usersDir.appendingPathComponent("AdaName").path) else { + throw XCTSkip("Case-sensitive volume: the legacy alias cannot differ from the stored name by case.") + } + var reported: String? + XCTAssertThrowsError(try UserStorage.validate("Ada.Name", usersDir: usersDir)) { error in + if case UserStorage.ValidationError.ambiguousLegacy(let key) = error { + reported = key + } else { + XCTFail("Expected ambiguousLegacy, got \(error)") + } + } + // The reported name must be the one that opens the stored state. + XCTAssertEqual(reported, "adaname") + if let reported { + XCTAssertNoThrow(try UserStorage.validate(reported, usersDir: usersDir)) + } + } + } + + func testConflictingProfileIsNotOverwritten() throws { + try withRoot { root in + let directory = root.appendingPathComponent("ContextSynapse/users/Ada") + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + let profile = UserProfile(id: "ada", displayName: "owner", createdAt: "old", lastUsedAt: "old") + let bytes = try JSONEncoder().encode(profile) + let url = directory.appendingPathComponent("profile.json") + try bytes.write(to: url) + XCTAssertThrowsError(try SynapseCore(user: "Ada", baseOverride: root)) + XCTAssertEqual(try Data(contentsOf: url), bytes) + XCTAssertFalse(FileManager.default.fileExists(atPath: directory.appendingPathComponent("config.json").path)) + } + } + + func testExistingDefaultCaseVariantRetainsItsOwnerAndState() throws { + for name in ["Default", "DEFAULT"] { + try withRoot { root in + let directory = root.appendingPathComponent("ContextSynapse/users/" + name) + try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true) + let profile = UserProfile(id: name, displayName: name, createdAt: "old", lastUsedAt: "old") + let profileURL = directory.appendingPathComponent("profile.json") + try JSONEncoder().encode(profile).write(to: profileURL) + let marker = Data("existing session".utf8) + try marker.write(to: directory.appendingPathComponent("session.json")) + let core = try SynapseCore(user: name, baseOverride: root) + XCTAssertEqual(core.currentUser, name) + XCTAssertEqual(try Data(contentsOf: directory.appendingPathComponent("session.json")), marker) + let owner = try JSONDecoder().decode(UserProfile.self, from: Data(contentsOf: profileURL)) + XCTAssertEqual(owner.id, name) + } + } + } + + func testNewDefaultCaseVariantsAreRejectedBeforeWrites() throws { + try withRoot { root in + for name in ["Default", "DEFAULT"] { + XCTAssertThrowsError(try SynapseCore(user: name, baseOverride: root)) + } + XCTAssertFalse(FileManager.default.fileExists(atPath: root.appendingPathComponent("ContextSynapse").path)) + } + } + + func testInvalidIdentifiersThrowBeforeCreatingState() throws { + try withRoot { root in + for name in ["", "🔥", "***", "..", "../Ada", "Ada/B", "Ada\\B", "Ada:B", "Ada\nB"] { + XCTAssertThrowsError(try SynapseCore(user: name, baseOverride: root), name) + } + XCTAssertFalse(FileManager.default.fileExists(atPath: root.appendingPathComponent("ContextSynapse").path)) + } + } + + func testLegacyPunctuatedLighthouseMigratesAndClearDoesNotResurrectIt() throws { + try withRoot { root in + let legacy = root.appendingPathComponent("ContextSynapse/Ada.Name/lighthouse.json") + try FileManager.default.createDirectory(at: legacy.deletingLastPathComponent(), withIntermediateDirectories: true) + let record = LighthouseRecord(id: "anchor", text: "preserved", setAt: "2026-09-01T00:00:00Z") + try JSONEncoder().encode(record).write(to: legacy) + let core = try SynapseCore(user: "Ada.Name", baseOverride: root) + XCTAssertEqual(core.loadLighthouseRecord(), record) + XCTAssertTrue(FileManager.default.fileExists(atPath: core.lighthouseURL.path)) + XCTAssertFalse(FileManager.default.fileExists(atPath: legacy.path)) + core.clearLighthouse() + XCTAssertNil(core.loadLighthouseRecord()) + } + } + + func testFailedLighthouseMigrationKeepsLegacyRecord() throws { + try withRoot { root in + let core = try SynapseCore(user: "Ada.Name", baseOverride: root) + let legacy = core.appSupport.appendingPathComponent("Ada.Name/lighthouse.json") + try FileManager.default.createDirectory(at: legacy.deletingLastPathComponent(), withIntermediateDirectories: true) + let record = LighthouseRecord(id: "anchor", text: "preserved", setAt: "2026-09-01T00:00:00Z") + try JSONEncoder().encode(record).write(to: legacy) + // A directory at the destination makes an atomic file replacement fail. + try FileManager.default.createDirectory(at: core.lighthouseURL, withIntermediateDirectories: false) + XCTAssertEqual(core.loadLighthouseRecord(), record) + XCTAssertTrue(FileManager.default.fileExists(atPath: legacy.path)) + } + } +} diff --git a/docs/journal/DECISIONS.md b/docs/journal/DECISIONS.md index 64c920e..9934a50 100644 --- a/docs/journal/DECISIONS.md +++ b/docs/journal/DECISIONS.md @@ -295,3 +295,10 @@ - 2026-10-29 · Implement explicit `--fork-shadow `, `--return-primary`, and `--promote-shadow` commands. Each fork gets a separate UUID-addressed lighthouse/session directory; a single atomic contexts.json index write selects the active context. Primary files are retained across return and promotion, prior primary IDs remain in the index, and failed pointer writes preserve the old selection. No nested forks or inferred anchors; weights/referee remain shared. CLI run logs carry context IDs and shadow queries emit a return breadcrumb. SwiftUI selection and a retained-shadow resume/list UI remain deferred. Reverse: stop writers and restore the previous index from backup/retained priorPrimaries IDs; preserve all context data. - 2026-10-29 · Address Shadow Context review gaps: selected lighthouse reads use a caught error path; tests assert a persisted shadow epoch and synapse, not merely file existence. Mixed instrument/context-state commands now fail before initialization, and CLAUDE.md documents why standalone instrument commands precede context loading. Verified release-independent debug build and five focused tests. Reverse: revert this focused patch only with equivalent persistence and error-path coverage. + +- 2026-10-05 · Reconcile PR #40 with current main before storage repair: keep main's edge identity, LighthouseStore migration, strict concurrency, GUI persistence seam and later session/ledger work; retain PR #40's isolated-frontier depth fix and move its new circuit coverage to a sibling test file · PR #44 contains overlapping older implementations but is not an ancestor of main; its unique-added-file check against main is empty, which alone does not establish commit equivalence. No PR was closed or merged · reverse: revert the PR #40 repair commit, not the earlier main changes. +- 2026-10-05 · Preserve safe raw user names (including spaces and dots) instead of dropping characters; reject invalid input with a recoverable error before state writes; refuse ambiguous legacy aliases and profile/case conflicts rather than guessing ownership · preserves existing space-named config/regions/logs/session state and uses main's raw-name lighthouse migration. A historical dot-stripped directory must be selected explicitly or backed up and renamed by its owner · reverse: provide an explicit, owner-confirmed migration tool before relaxing ambiguity checks. + +## 2026-10-29 — PR #40 final review repair + +- 2026-10-29 · Preserve existing exact-owned `Default`/`DEFAULT` namespaces before rejecting creation of new variants of the built-in default. Greptile identified that the early validation guard made legacy saved state inaccessible. Move the reservation to the new-directory branch and test existing ownership/session preservation plus rejection before writes. Reverse: revert this focused validation adjustment only if a replacement preserves existing owners.