feat(profiles): registry + provisioning ×3
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Profiles S1 (#134, ADR-0014): one gate pass provisions all three surface profiles — museion adopted in place (never reconfigured; its glm-5.3-max stays the user's), museion-pass1/-pass2 created fresh with the #132 sonnet defaults + 24k budget via the hermes 'config set' CLI rail, marker-gated so a re-pass is a no-op and Settings changes survive; a failed provision names the profile on the #48 card. Skills move to ONE master copy under Application Support, symlinked per profile per the #133 allocation (P1 9 · P2 8 · Chat 10); copy-era dirs migrate on byte-match (.DS_Store-tolerant, symlink-refusing), diverged dirs stay copies, user skills untouched (G3a). Backup widens to one three-subdir stamp, any-live-skip-all; RESTORE.md names the three folders. Two review rounds (standards+spec, then finish-audit ponytail/ security/general) caught and fixed: the dead .DS_Store leniency in treesByteMatch, exit-code-only config-set trust, the swallowed marker write (defaults-stomp re-arm), symlink-following in the untrusted tree, and a fixture-skewed count pin. Suite: 412 passed / 414 (fork flake green in isolation 16/16; UI launch = pre-existing testmanagerd flake, failed identically pre-change). DOX: Museion/AGENTS.md, MuseionTests/AGENTS.md, ref/writing skills/AGENTS.md rewritten. Closes #134
This commit is contained in:
1 parent
2032534305
commit
610f8789bd
15 files changed
+1292
-232
No files matched your search
@@ -19,13 +19,14 @@ func backupTempDir(_ label: String) -> String {
|
||||
return dir
|
||||
}
|
||||
|
||||
/// Minimal profile fixture at `<root>/museion`: state that matters to a
|
||||
/// restore (auth.json, .env, state.db + sidecars, a skill) plus excluded
|
||||
/// entries (logs/, cache/, gateway.pid, .DS_Store, caches, locks).
|
||||
/// Minimal profile fixture at `<root>/<name>` (default the chat profile):
|
||||
/// state that matters to a restore (auth.json, .env, state.db + sidecars, a
|
||||
/// skill) plus excluded entries (logs/, cache/, gateway.pid, .DS_Store,
|
||||
/// caches, locks). #134: name parameterized for the pass profiles.
|
||||
@discardableResult
|
||||
func makeProfileFixture(at root: String) -> String {
|
||||
func makeProfileFixture(at root: String, name: String = "museion") -> String {
|
||||
let fileManager = FileManager.default
|
||||
let profile = (root as NSString).appendingPathComponent("museion")
|
||||
let profile = (root as NSString).appendingPathComponent(name)
|
||||
for dir in ["skills/serif-writing", "logs", "cache", "sessions/xyz/cache"] {
|
||||
try? fileManager.createDirectory(
|
||||
atPath: (profile as NSString).appendingPathComponent(dir),
|
||||
@@ -180,6 +181,66 @@ struct ProfileBackupTests {
|
||||
#expect(outcome == .skippedProfileMissing)
|
||||
}
|
||||
|
||||
// Scenario: One backup stamp covers three profiles (#129/#134) — Given
|
||||
// the daily backup with all three profile dirs on disk, when the pass
|
||||
// runs while every engine is idle, then one timestamped stamp carries
|
||||
// museion/, museion-pass1/, museion-pass2/ as siblings — and any live
|
||||
// engine (even a pass engine's) skips the whole stamp.
|
||||
@Test func `snapshot carries all three profile dirs`() {
|
||||
let root = backupTempDir("three")
|
||||
for name in ["museion", "museion-pass1", "museion-pass2"] {
|
||||
makeProfileFixture(at: root, name: name)
|
||||
}
|
||||
let backups = (root as NSString).appendingPathComponent("backups")
|
||||
guard case let .snapshotted(stamp) = perform(profileRoot: root, backupsRoot: backups) else {
|
||||
Issue.record("expected snapshot")
|
||||
return
|
||||
}
|
||||
let snap = backups as NSString
|
||||
let entries = (try? FileManager.default.contentsOfDirectory(atPath: (snap as NSString).appendingPathComponent(stamp))) ?? []
|
||||
#expect(Set(entries) == Set(["museion", "museion-pass1", "museion-pass2"]))
|
||||
for name in ["museion", "museion-pass1", "museion-pass2"] {
|
||||
let auth = (((snap as NSString).appendingPathComponent(stamp) as NSString).appendingPathComponent(name) as NSString)
|
||||
.appendingPathComponent("auth.json")
|
||||
#expect(FileManager.default.fileExists(atPath: auth), "\(name) payload missing")
|
||||
}
|
||||
// RESTORE.md names the three folders.
|
||||
let restoreDoc = (try? String(contentsOfFile: (snap as NSString).appendingPathComponent("RESTORE.md"), encoding: .utf8)) ?? ""
|
||||
#expect(restoreDoc.contains("museion-pass1"))
|
||||
#expect(restoreDoc.contains("museion-pass2"))
|
||||
}
|
||||
|
||||
@Test func `live pass engine skips the whole stamp`() {
|
||||
let root = backupTempDir("passlive")
|
||||
for name in ["museion", "museion-pass1", "museion-pass2"] {
|
||||
makeProfileFixture(at: root, name: name)
|
||||
}
|
||||
// A live gateway pid inside a PASS profile — chat is idle, the stamp
|
||||
// still skips: one stamp = one consistent point in time (#129).
|
||||
try? "{\"pid\": \(ProcessInfo.processInfo.processIdentifier)}".write(
|
||||
toFile: ((root as NSString).appendingPathComponent("museion-pass1") as NSString).appendingPathComponent("gateway.pid"),
|
||||
atomically: true,
|
||||
encoding: .utf8,
|
||||
)
|
||||
let outcome = perform(profileRoot: root, backupsRoot: (root as NSString).appendingPathComponent("backups"))
|
||||
#expect(outcome == .skippedEngineRunning)
|
||||
let backups = (root as NSString).appendingPathComponent("backups")
|
||||
let stamps = ((try? FileManager.default.contentsOfDirectory(atPath: backups)) ?? []).filter { $0 != "RESTORE.md" }
|
||||
#expect(stamps.isEmpty) // nothing half-written
|
||||
}
|
||||
|
||||
@Test func `missing pass profiles snapshot the rest`() {
|
||||
let root = backupTempDir("partial")
|
||||
makeProfileFixture(at: root) // only the chat profile exists
|
||||
let backups = (root as NSString).appendingPathComponent("backups")
|
||||
guard case let .snapshotted(stamp) = perform(profileRoot: root, backupsRoot: backups) else {
|
||||
Issue.record("expected snapshot over the existing profile")
|
||||
return
|
||||
}
|
||||
let entries = (try? FileManager.default.contentsOfDirectory(atPath: (backups as NSString).appendingPathComponent(stamp))) ?? []
|
||||
#expect(Set(entries) == Set(["museion"]))
|
||||
}
|
||||
|
||||
@Test func `copy failure returns failed and leaves no temp dir`() {
|
||||
let root = backupTempDir("fail")
|
||||
let profile = makeProfileFixture(at: root)
|
||||
|
||||
Reference in new issue
Block a user