feat(profiles): registry + provisioning ×3
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:
AlexKucera committed 2026-10-27 09:23:56 +01:00
1 parent 2032534305
commit 610f8789bd
15 files changed
+1292 -232

No files matched your search

@@ -22,25 +22,29 @@ struct ProfileProvisionerFailureTests {
let payload = makePayload(at: provTempDir("payload"), skills: skills)
let failing = makeFakeHermes(at: binDir, name: "hermes-fail", mode: "fail")
let model = ProvisioningModel()
await model.runPass(hermesBinary: failing, profileRoot: profileRoot, payloadRoot: payload)
await model.runPass(hermesBinary: failing, profileRoot: profileRoot, payloadRoot: payload, masterRoot: provTempDir("master"))
#expect(model.hasFailure)
model.deferFailure() // Not Now (#48)
#expect(!model.hasFailure)
#expect(model.lastFailure == nil)
// Next launch's silent retry fails again — the card may show again.
await model.runPass(hermesBinary: failing, profileRoot: profileRoot, payloadRoot: payload)
await model.runPass(hermesBinary: failing, profileRoot: profileRoot, payloadRoot: payload, masterRoot: provTempDir("master"))
#expect(model.hasFailure)
}
@Test func `registration only via the mcp add cli rail never hand-written yaml`() {
// #44 invariant, slice-2 form: museion-tools registration happens ONLY
// through the `hermes -p museion mcp add` CLI rail — the provisioner
// through the `hermes -p <profile> mcp add` CLI rail — the provisioner
// never writes mcp_servers YAML itself. A pre-existing engine-owned
// config.yaml stays byte-identical through a failed pass, a skipped
// (nil server) pass, AND a pass that registers via the CLI.
// (nil server) pass, AND a pass that registers via the CLI. #134: the
// config-set defaults ride the same CLI rail (ADR-0014) — the adopted
// museion is never configured, so its config.yaml is never even a
// CLI target here.
let binDir = provTempDir("mcp")
let binary = makeFakeHermes(at: binDir, mode: "ok")
let profileRoot = (binDir as NSString).appendingPathComponent("profiles")
let master = provTempDir("master") // ONE master across all three passes — a fresh one per pass would re-seed and skew the counts
let profileDir = (profileRoot as NSString).appendingPathComponent("museion")
let configPath = (profileDir as NSString).appendingPathComponent("config.yaml")
let config = "model: glm-5.3\nmcp_servers:\n weather: {}\n"
@@ -59,7 +63,12 @@ struct ProfileProvisionerFailureTests {
}
// Failed pass: registration never reached, config untouched.
let failed = ProfileProvisioner.perform(hermesBinary: binary, profileRoot: profileRoot, payloadRoot: badPayload)
let failed = ProfileProvisioner.perform(
hermesBinary: binary,
profileRoot: profileRoot,
payloadRoot: badPayload,
masterRoot: master,
)
guard case .failed = failed else {
Issue.record("expected copy failure, got \(failed)")
return
@@ -67,44 +76,52 @@ struct ProfileProvisionerFailureTests {
#expect(configUntouched())
// Skipped pass: nil serverBinaryPath is the test seam — nothing
// registers, config untouched.
// registers, config untouched. (The failed pass already seeded the
// shared master — 2 present there, only the 6 profile links copy.)
let skipped = ProfileProvisioner.perform(
hermesBinary: binary,
profileRoot: profileRoot,
payloadRoot: goodPayload,
masterRoot: master,
serverBinaryPath: nil,
)
#expect(skipped == .seeded(copied: 0, present: 2))
#expect(skipped == .seeded(copied: 6, present: 2))
#expect(configUntouched())
#expect(!FileManager.default.fileExists(atPath: (binDir as NSString).appendingPathComponent("mcp-add-invocation")))
for profile in ["museion", "museion-pass1", "museion-pass2"] {
#expect(!FileManager.default.fileExists(atPath: (binDir as NSString).appendingPathComponent("mcp-add-invocation-\(profile)")))
}
// Registering pass: the CLI rail ran (marker + invocation recorded) and
// still not one byte of config.yaml is written by the provisioner — the
// entry lands through the CLI, or not at all.
// Registering pass: the CLI rail ran (markers + invocations per
// profile) and still not one byte of config.yaml is written by the
// provisioner — the entry lands through the CLI, or not at all.
let registered = ProfileProvisioner.perform(
hermesBinary: binary,
profileRoot: profileRoot,
payloadRoot: goodPayload,
masterRoot: master,
serverBinaryPath: "/fake/Museion.app/Contents/MacOS/Museion",
)
#expect(registered == .seeded(copied: 0, present: 2))
#expect(registered == .seeded(copied: 0, present: 8))
#expect(configUntouched())
#expect(FileManager.default.fileExists(atPath: (binDir as NSString).appendingPathComponent("mcp-registered")))
#expect(FileManager.default.fileExists(atPath: (binDir as NSString).appendingPathComponent("mcp-registered-museion")))
let invocation = (try? String(
contentsOfFile: (binDir as NSString).appendingPathComponent("mcp-add-invocation"),
contentsOfFile: (binDir as NSString).appendingPathComponent("mcp-add-invocation-museion"),
encoding: .utf8,
)) ?? ""
#expect(invocation.contains("mcp add museion-tools"))
}
@Test func `fresh-profile registering pass writes no config yaml`() {
// #44, fresh-profile case (own binary dir so the add truly runs): a
// registering pass still writes no config.yaml — the CLI owns that
// file, not us.
// file, not us (the fake records invocations, writes nothing).
let freshBinDir = provTempDir("fresh-mcp")
let freshRoot = (freshBinDir as NSString).appendingPathComponent("profiles")
_ = ProfileProvisioner.perform(
hermesBinary: makeFakeHermes(at: freshBinDir, mode: "ok"),
profileRoot: freshRoot,
payloadRoot: goodPayload,
payloadRoot: makePayload(at: provTempDir("payload"), skills: skills),
masterRoot: provTempDir("master"),
serverBinaryPath: "/fake/Museion.app/Contents/MacOS/Museion",
)
let freshConfig = ((freshRoot as NSString).appendingPathComponent("museion") as NSString)
@@ -120,6 +137,7 @@ struct ProfileProvisionerFailureTests {
hermesBinary: makeFakeHermes(at: binDir, mode: "fail"),
profileRoot: (binDir as NSString).appendingPathComponent("profiles"),
payloadRoot: makePayload(at: provTempDir("payload"), skills: skills),
masterRoot: provTempDir("master"),
)
guard case .failed = outcome else {
Issue.record("expected create failure, got \(outcome)")
@@ -148,11 +166,13 @@ struct ProfileProvisionerFailureTests {
hermesBinary: makeFakeHermes(at: binDir, mode: "ok"),
profileRoot: profileRoot,
payloadRoot: makePayload(at: provTempDir("payload"), skills: skills),
masterRoot: provTempDir("master"),
)
guard case let .failed(phase, excerpt) = outcome else {
guard case let .failed(profile, phase, excerpt) = outcome else {
Issue.record("expected copy failure, got \(outcome)")
return
}
#expect(profile == "museion") // chat provisions first — its skills dir is the blocker
#expect(phase == .copy)
#expect(excerpt.hasPrefix("copy serif-writing:"))
}