feat(mentor): museion-tools MCP server (#23)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Headless --serve-mcp role in the app binary: NDJSON JSON-RPC on stdio exposing query_learnings and submit_fix_cards (ADR-0006 cards, anchor-validated; stale lands flagged, never rejected), registered into the museion profile at provisioning. Cards persist per piece under <piece>/cards/ and surface in a floating Fix Cards palette with pass-stamped provenance. Live dogfood drove the shape: session/prompt waits pass length (the 15 s request default abandoned working turns), a liveness row and a persisted Debug checkbox (off) split writing sessions from debug chatter, the verdict references findings by title only while the cards carry the detail (persona v1.3 — tools work in silence), and the #24 pass rails (pass bar, TurnOutcome seam, snapshots) ride in. Three-reviewer audit round: piece-path shape guard closes the JSON-drop and substring-oracle holes, nested submit rawInput parsing (the flat parser never matched the live rail), missing stopReason never advances a pass, 1 MB stdin cap, card scan off MainActor. 296 tests green; every behavioral fix flip-verified. Closes #23
This commit is contained in:
1 parent
c2e94fd825
commit
683ddf8426
29 files changed
+2626
-169
No files matched your search
@@ -32,10 +32,14 @@ struct ProfileProvisionerFailureTests {
|
||||
#expect(model.hasFailure)
|
||||
}
|
||||
|
||||
@Test func `provisioning never writes mcp_servers into the profile config`() {
|
||||
// #44 negative invariant: a pre-existing engine-owned config.yaml stays
|
||||
// byte-identical through a failed AND a successful pass — no museion-tools entry.
|
||||
@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
|
||||
// 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.
|
||||
let binDir = provTempDir("mcp")
|
||||
let binary = makeFakeHermes(at: binDir, mode: "ok")
|
||||
let profileRoot = (binDir as NSString).appendingPathComponent("profiles")
|
||||
let profileDir = (profileRoot as NSString).appendingPathComponent("museion")
|
||||
let configPath = (profileDir as NSString).appendingPathComponent("config.yaml")
|
||||
@@ -50,27 +54,61 @@ struct ProfileProvisionerFailureTests {
|
||||
)
|
||||
try? FileManager.default.createDirectory(atPath: profileDir, withIntermediateDirectories: true)
|
||||
try? config.write(toFile: configPath, atomically: true, encoding: .utf8)
|
||||
let binary = makeFakeHermes(at: binDir, mode: "ok")
|
||||
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)
|
||||
guard case .failed = failed else {
|
||||
Issue.record("expected copy failure, got \(failed)")
|
||||
return
|
||||
}
|
||||
#expect((try? String(contentsOfFile: configPath, encoding: .utf8)) == config)
|
||||
#expect(configUntouched())
|
||||
|
||||
// The failed pass copied both real skills before hitting the missing entry
|
||||
// (partial progress is the point — retry resumes additively), so the clean
|
||||
// re-run finds them present.
|
||||
let seeded = ProfileProvisioner.perform(hermesBinary: binary, profileRoot: profileRoot, payloadRoot: goodPayload)
|
||||
#expect(seeded == .seeded(copied: 0, present: 2))
|
||||
#expect((try? String(contentsOfFile: configPath, encoding: .utf8)) == config)
|
||||
// Skipped pass: nil serverBinaryPath is the test seam — nothing
|
||||
// registers, config untouched.
|
||||
let skipped = ProfileProvisioner.perform(
|
||||
hermesBinary: binary,
|
||||
profileRoot: profileRoot,
|
||||
payloadRoot: goodPayload,
|
||||
serverBinaryPath: nil,
|
||||
)
|
||||
#expect(skipped == .seeded(copied: 0, present: 2))
|
||||
#expect(configUntouched())
|
||||
#expect(!FileManager.default.fileExists(atPath: (binDir as NSString).appendingPathComponent("mcp-add-invocation")))
|
||||
|
||||
// #44, fresh-profile case: a profile the fake hermes just created carries
|
||||
// no config.yaml at all — provisioning never writes one.
|
||||
let freshRoot = (provTempDir("fresh-mcp") as NSString).appendingPathComponent("profiles")
|
||||
_ = ProfileProvisioner.perform(hermesBinary: binary, profileRoot: freshRoot, payloadRoot: goodPayload)
|
||||
let freshConfig = ((freshRoot as NSString).appendingPathComponent("museion") as NSString).appendingPathComponent("config.yaml")
|
||||
// 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.
|
||||
let registered = ProfileProvisioner.perform(
|
||||
hermesBinary: binary,
|
||||
profileRoot: profileRoot,
|
||||
payloadRoot: goodPayload,
|
||||
serverBinaryPath: "/fake/Museion.app/Contents/MacOS/Museion",
|
||||
)
|
||||
#expect(registered == .seeded(copied: 0, present: 2))
|
||||
#expect(configUntouched())
|
||||
#expect(FileManager.default.fileExists(atPath: (binDir as NSString).appendingPathComponent("mcp-registered")))
|
||||
let invocation = (try? String(
|
||||
contentsOfFile: (binDir as NSString).appendingPathComponent("mcp-add-invocation"),
|
||||
encoding: .utf8,
|
||||
)) ?? ""
|
||||
#expect(invocation.contains("mcp add museion-tools"))
|
||||
|
||||
// #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.
|
||||
let freshBinDir = provTempDir("fresh-mcp")
|
||||
let freshRoot = (freshBinDir as NSString).appendingPathComponent("profiles")
|
||||
_ = ProfileProvisioner.perform(
|
||||
hermesBinary: makeFakeHermes(at: freshBinDir, mode: "ok"),
|
||||
profileRoot: freshRoot,
|
||||
payloadRoot: goodPayload,
|
||||
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))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user