fix(acp): repair mentor bridge for adapter 0.21.5
Two bugs after the engine update, both found via a live NDJSON repro against the real binary: session/new now requires mcpServers in the ACP SDK schema (NewSessionRequest). Museion sent only cwd, the engine answered -32602, the handshake threw, and the pane showed "the mentor engine stopped" — a validation rejection dressed as a crash. Send the honest empty list; Museion ships no MCP servers (#44 invariant, now pinned on the wire by a strict fake in tests). The advisory version-drift note compared raw strings: the gate records the derived version from `acp --version` (0.21.5+2177.g735e426) while initialize answers the base version (agentInfo.version -> 0.21.5), fabricating drift on every launch. Compare base versions (strip +build metadata); real drift still fires. Wire facts re-verified against adapter 0.21.5; docs updated.
This commit is contained in:
1 parent
e5490ed290
commit
de76a50cc6
6 files changed
+97
-11
No files matched your search
@@ -186,10 +186,13 @@ final class MentorSessionModel {
|
||||
|
||||
// Advisory version verify against state.json's recorded version
|
||||
// (map decision: one os_log line + both versions in the pane; never blocks).
|
||||
// The gate records the derived version (`acp --version` → 0.21.5+2177.g735e426);
|
||||
// the handshake answers the base version (agentInfo.version → 0.21.5) — compare
|
||||
// bases so build metadata never fabricates drift.
|
||||
var note: String?
|
||||
if let version {
|
||||
let recorded = recordedVersionProvider()
|
||||
if let recorded, recorded != version {
|
||||
if let recorded, Self.baseVersion(of: recorded) != Self.baseVersion(of: version) {
|
||||
note = "Engine \(version) differs from the recorded \(recorded)"
|
||||
Logger(subsystem: "com.babylondreams.Museion", category: "acp")
|
||||
.warning("engine version drift: running \(version, privacy: .public), recorded \(recorded, privacy: .public)")
|
||||
@@ -197,10 +200,14 @@ final class MentorSessionModel {
|
||||
}
|
||||
versionNote = note
|
||||
|
||||
// New session — cwd ~ (map decision).
|
||||
// New session — cwd ~ (map decision). Adapter ≥0.21.5 requires mcpServers
|
||||
// (ACP SDK NewSessionRequest); Museion ships none, so the honest empty list.
|
||||
let newResult = try await client.request(
|
||||
"session/new",
|
||||
params: .object(["cwd": .string(cwdProvider())]),
|
||||
params: .object([
|
||||
"cwd": .string(cwdProvider()),
|
||||
"mcpServers": .array([]),
|
||||
]),
|
||||
)
|
||||
guard let sid = newResult?.objectValue?["sessionId"]?.stringValue else {
|
||||
throw ACPEngineClient.TransportError(message: "session/new returned no sessionId")
|
||||
@@ -271,6 +278,12 @@ final class MentorSessionModel {
|
||||
}
|
||||
}
|
||||
|
||||
/// Base version of a version string — the part before `+` build metadata
|
||||
/// (PEP 440 local version segment). `0.21.5+2177.g735e426` → `0.21.5`.
|
||||
nonisolated static func baseVersion(of version: String) -> String {
|
||||
version.split(separator: "+", maxSplits: 1, omittingEmptySubsequences: false).first.map(String.init) ?? version
|
||||
}
|
||||
|
||||
// MARK: - Notification decoding
|
||||
|
||||
private func handleNotification(method: String, params: JSONValue?) {
|
||||
|
||||
Reference in new issue
Block a user