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
@@ -0,0 +1,137 @@
|
||||
//
|
||||
// ProfileSkillMigrationTests.swift
|
||||
// MuseionTests
|
||||
//
|
||||
// Scenario: Copy-era dirs migrate to master symlinks on byte-match (#134/
|
||||
// #133) — Given today's museion profile whose skills landed as real
|
||||
// directory copies, when the provisioner passes, then a dir still
|
||||
// byte-matching the payload swaps to a symlink into the master (content
|
||||
// identical through the swap); a diverged dir stays a copy; untracked user
|
||||
// skills are never touched. Own file — ProfileSurfaceTests crossed its
|
||||
// type-body ceiling (MCPToolsPromoteTests precedent); shares the harness.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@testable import Museion
|
||||
import Testing
|
||||
|
||||
@Suite("ProfileSkillMigrationTests")
|
||||
struct ProfileSkillMigrationTests {
|
||||
@Test func `copy-era dir byte-matching the shipped set migrates to a master symlink`() {
|
||||
let binDir = provTempDir("migrate")
|
||||
let profileRoot = (binDir as NSString).appendingPathComponent("profiles")
|
||||
let master = provTempDir("master")
|
||||
let payload = makeShippedPayload(at: provTempDir("payload"))
|
||||
let fileManager = FileManager.default
|
||||
// Today's museion: copy-era REAL dirs from the old seeding — one
|
||||
// pristine, one carrying Finder's .DS_Store noise (not a user edit).
|
||||
let museionSkills = (profileRoot as NSString).appendingPathComponent("museion/skills")
|
||||
for name in ["serif-writing", "deslop"] {
|
||||
try? fileManager.createDirectory(atPath: museionSkills, withIntermediateDirectories: true)
|
||||
try? fileManager.copyItem(
|
||||
atPath: (payload as NSString).appendingPathComponent(name),
|
||||
toPath: (museionSkills as NSString).appendingPathComponent(name),
|
||||
)
|
||||
}
|
||||
try? "junk".write(
|
||||
toFile: ((museionSkills as NSString).appendingPathComponent("deslop") as NSString).appendingPathComponent(".DS_Store"),
|
||||
atomically: true,
|
||||
encoding: .utf8,
|
||||
)
|
||||
_ = ProfileProvisioner.perform(
|
||||
hermesBinary: makeFakeHermes(at: binDir, mode: "ok"),
|
||||
profileRoot: profileRoot,
|
||||
payloadRoot: payload,
|
||||
masterRoot: master,
|
||||
serverBinaryPath: "/fake/Museion",
|
||||
)
|
||||
for name in ["serif-writing", "deslop"] {
|
||||
let link = (museionSkills as NSString).appendingPathComponent(name)
|
||||
let target = try? fileManager.destinationOfSymbolicLink(atPath: link)
|
||||
#expect(target == (master as NSString).appendingPathComponent(name), "\(name) migrated")
|
||||
// Content identical through the swap.
|
||||
#expect(readSkillBody(link).contains("\(name) body"))
|
||||
}
|
||||
}
|
||||
|
||||
@Test func `diverged dir stays a copy and untracked skills stay untouched`() {
|
||||
let binDir = provTempDir("diverged")
|
||||
let profileRoot = (binDir as NSString).appendingPathComponent("profiles")
|
||||
let master = provTempDir("master")
|
||||
let payload = makeShippedPayload(at: provTempDir("payload"))
|
||||
let fileManager = FileManager.default
|
||||
// A writer-modified copy-era dir and a user skill the manifest never
|
||||
// tracked — neither may be touched (G3a).
|
||||
let museionSkills = (profileRoot as NSString).appendingPathComponent("museion/skills")
|
||||
try? fileManager.createDirectory(atPath: museionSkills, withIntermediateDirectories: true)
|
||||
try? fileManager.copyItem(
|
||||
atPath: (payload as NSString).appendingPathComponent("serif-writing"),
|
||||
toPath: (museionSkills as NSString).appendingPathComponent("serif-writing"),
|
||||
)
|
||||
try? "the writer's own version".write(
|
||||
toFile: ((museionSkills as NSString).appendingPathComponent("serif-writing") as NSString).appendingPathComponent("SKILL.md"),
|
||||
atomically: true,
|
||||
encoding: .utf8,
|
||||
)
|
||||
let userSkill = (museionSkills as NSString).appendingPathComponent("my-own-skill")
|
||||
try? fileManager.createDirectory(atPath: userSkill, withIntermediateDirectories: true)
|
||||
try? "precious".write(
|
||||
toFile: (userSkill as NSString).appendingPathComponent("SKILL.md"),
|
||||
atomically: true,
|
||||
encoding: .utf8,
|
||||
)
|
||||
_ = ProfileProvisioner.perform(
|
||||
hermesBinary: makeFakeHermes(at: binDir, mode: "ok"),
|
||||
profileRoot: profileRoot,
|
||||
payloadRoot: payload,
|
||||
masterRoot: master,
|
||||
serverBinaryPath: "/fake/Museion",
|
||||
)
|
||||
// Diverged: still a REAL dir, edits intact.
|
||||
let diverged = (museionSkills as NSString).appendingPathComponent("serif-writing")
|
||||
#expect((try? fileManager.destinationOfSymbolicLink(atPath: diverged)) == nil)
|
||||
#expect(readSkillBody(diverged) == "the writer's own version")
|
||||
// Untracked: never linked, never altered.
|
||||
#expect((try? fileManager.destinationOfSymbolicLink(atPath: userSkill)) == nil)
|
||||
#expect(readSkillBody(userSkill) == "precious")
|
||||
}
|
||||
|
||||
@Test func `symlinked entry inside a copy-era dir refuses the migration`() {
|
||||
// Finish-audit: the copy-era tree is untrusted — a symlinked SKILL.md
|
||||
// must fail the byte-match (never be followed) and the dir stays a
|
||||
// copy, the planted link untouched.
|
||||
let binDir = provTempDir("symlinkrefuse")
|
||||
let profileRoot = (binDir as NSString).appendingPathComponent("profiles")
|
||||
let master = provTempDir("master")
|
||||
let payload = makeShippedPayload(at: provTempDir("payload"))
|
||||
let fileManager = FileManager.default
|
||||
let museionSkills = (profileRoot as NSString).appendingPathComponent("museion/skills")
|
||||
try? fileManager.createDirectory(atPath: museionSkills, withIntermediateDirectories: true)
|
||||
try? fileManager.copyItem(
|
||||
atPath: (payload as NSString).appendingPathComponent("serif-writing"),
|
||||
toPath: (museionSkills as NSString).appendingPathComponent("serif-writing"),
|
||||
)
|
||||
let skillDir = (museionSkills as NSString).appendingPathComponent("serif-writing")
|
||||
let elsewhere = provTempDir("elsewhere")
|
||||
try? "elsewhere".write(
|
||||
toFile: (elsewhere as NSString).appendingPathComponent("SKILL.md"),
|
||||
atomically: true,
|
||||
encoding: .utf8,
|
||||
)
|
||||
try? fileManager.removeItem(atPath: (skillDir as NSString).appendingPathComponent("SKILL.md"))
|
||||
try? fileManager.createSymbolicLink(
|
||||
atPath: (skillDir as NSString).appendingPathComponent("SKILL.md"),
|
||||
withDestinationPath: (elsewhere as NSString).appendingPathComponent("SKILL.md"),
|
||||
)
|
||||
_ = ProfileProvisioner.perform(
|
||||
hermesBinary: makeFakeHermes(at: binDir, mode: "ok"),
|
||||
profileRoot: profileRoot,
|
||||
payloadRoot: payload,
|
||||
masterRoot: master,
|
||||
serverBinaryPath: "/fake/Museion",
|
||||
)
|
||||
// The dir is still a REAL dir (no migration), the planted link intact.
|
||||
#expect((try? fileManager.destinationOfSymbolicLink(atPath: skillDir)) == nil)
|
||||
#expect(readSkillBody(skillDir) == "elsewhere")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user