CI / ci (push) Canceled after 0s
Wayfinder map #148's terminal slice (decisions #150 architecture, #149 UX variant A): every launch now opens straight into the workspace. The engine check (hermes acp --check) runs async from ContentView.task via AppGateState.startLaunchCheck — provisioning (x3 profiles) and the daily backup auto-fire the moment it passes (the gate era's exact onEnginePass chain, moved verbatim; once per app-launch, first window only, no-op under hosted tests). Nothing blocks: the blocking gate sheet, the placeholder logo screen, gateRaised/gateDismissed, EngineGateView, and the ProvisioningFailureCard sheet are deleted (net -350 lines with the additions). Engine state stays visible instead of interrupting: a 44x44 rail pill above Archive (8pt pulsing accent dot while checking, warning glyph on an accent-12% wash when failed, nothing at all once healthy — the slot collapses and the rail spacing closes) and mono-10 mentor-pane header states (checking... / engine missing / setup failed / hermes <base> once ready — the BASE version, never the gate's derived string; session chip renders only once ready). Failure auto-expands an anchored floating card (340pt, accent border — floats, never blocks): engine-missing carries #40's install steps with the gateless correction plus Copy, guide link, Re-check (disabled-while-checking), stderr + probed path; provisioning failure rides the same card (failing profile named, Retry inline). Focus mode recesses the card with the rail. Panes spawn the engine the moment the check lands (.task(id: binaryPath) on the nil->value arrival; a nil binary never calls openSession — that path lands the crash card). state.json semantics unchanged (About still reads it); #38's no-silent-degradation AC survives, carried by the pill. New GatelessLaunchTests pin the seam (hosted-test no-op, chain armed, pill + mentor-header visibility mappings — flip-verified); EngineGateTests byte-untouched and green; the dead deferFailure (#48's Not-Now) deleted with its test. PRD G1 amended; gateless DOX pass (Museion/AGENTS.md engine section rewritten); CHANGELOG; devlog. The #149 prototype ships lint-clean. Verified: full-scheme test 582 passed / 0 failed / 0 skipped (xcresult executed count, unit + UI), swiftformat lint clean, swiftlint 0 errors on touched files, finish-audit fanout clean (ponytail/security/general; 5 fixes applied, header-mapping pins flip-discriminated and restored). Closes #151 Closes #139
163 lines
7.0 KiB
Swift
163 lines
7.0 KiB
Swift
//
|
|
// ProfileProvisionerFailureTests.swift
|
|
// MuseionTests
|
|
//
|
|
// #48 failure path: alert state (defer/retry), config.yaml and state.json
|
|
// invariants, error excerpt surfacing. Shares the fake-binary harness with
|
|
// ProfileProvisionerTests.swift.
|
|
//
|
|
|
|
import Foundation
|
|
@testable import Museion
|
|
import Testing
|
|
|
|
@Suite("ProfileProvisionerFailureTests")
|
|
struct ProfileProvisionerFailureTests {
|
|
private let skills = defaultSkills
|
|
|
|
@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 <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. #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"
|
|
let goodPayload = makePayload(at: provTempDir("payload"), skills: skills)
|
|
// Payload whose manifest names a skill it doesn't carry → copy failure (#48 AC).
|
|
let badPayload = makePayload(at: provTempDir("bad-payload"), skills: skills)
|
|
try? "serif-writing\ndeslop\nabsent-skill\n".write(
|
|
toFile: (badPayload as NSString).appendingPathComponent("seed-manifest.txt"),
|
|
atomically: true,
|
|
encoding: .utf8,
|
|
)
|
|
try? FileManager.default.createDirectory(atPath: profileDir, withIntermediateDirectories: true)
|
|
try? config.write(toFile: configPath, atomically: true, encoding: .utf8)
|
|
func configUntouched() -> Bool {
|
|
(try? String(contentsOfFile: configPath, encoding: .utf8)) == config
|
|
}
|
|
|
|
// Failed pass: registration never reached, config untouched.
|
|
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
|
|
}
|
|
#expect(configUntouched())
|
|
|
|
// Skipped pass: nil serverBinaryPath is the test seam — nothing
|
|
// 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: 6, present: 2))
|
|
#expect(configUntouched())
|
|
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 (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: 8))
|
|
#expect(configUntouched())
|
|
#expect(FileManager.default.fileExists(atPath: (binDir as NSString).appendingPathComponent("mcp-registered-museion")))
|
|
let invocation = (try? String(
|
|
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 (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: 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)
|
|
.appendingPathComponent("config.yaml")
|
|
#expect(!FileManager.default.fileExists(atPath: freshConfig))
|
|
}
|
|
|
|
@Test func `provisioning failure leaves state json engine-gate-only`() {
|
|
let appSupport = provTempDir("state")
|
|
EngineProbe.writeState(.pass(version: "9.9", binaryPath: "/fake/hermes"), appSupportDir: appSupport)
|
|
let binDir = provTempDir("statefail")
|
|
let outcome = ProfileProvisioner.perform(
|
|
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)")
|
|
return
|
|
}
|
|
// state.json stays schemaVersion 1, engine-gate-only (#48 AC).
|
|
let record = EngineProbe.readStateRecord(appSupportDir: appSupport)
|
|
#expect(record?.schemaVersion == 1)
|
|
#expect(record?.status == "pass")
|
|
#expect(record?.engineVersion == "9.9")
|
|
}
|
|
|
|
@Test func `copy failure surfaces the file-manager error`() {
|
|
let binDir = provTempDir("catch")
|
|
let profileRoot = (binDir as NSString).appendingPathComponent("profiles")
|
|
let profileDir = (profileRoot as NSString).appendingPathComponent("museion")
|
|
try? FileManager.default.createDirectory(atPath: profileDir, withIntermediateDirectories: true)
|
|
// `skills` pre-exists as a FILE → directory creation throws → the copy
|
|
// catch branch (the only copy-error path no other test reaches).
|
|
try? "blocker".write(
|
|
toFile: (profileDir as NSString).appendingPathComponent("skills"),
|
|
atomically: true,
|
|
encoding: .utf8,
|
|
)
|
|
let outcome = ProfileProvisioner.perform(
|
|
hermesBinary: makeFakeHermes(at: binDir, mode: "ok"),
|
|
profileRoot: profileRoot,
|
|
payloadRoot: makePayload(at: provTempDir("payload"), skills: skills),
|
|
masterRoot: provTempDir("master"),
|
|
)
|
|
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:"))
|
|
}
|
|
}
|