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
@@ -82,6 +82,38 @@ private func acpTempDir(_ label: String) -> String {
|
||||
return dir
|
||||
}
|
||||
|
||||
/// A strict `session/new` guard, mirroring the ACP SDK's required mcpServers
|
||||
/// (adapter ≥0.21.5 rejects the field's absence with -32602). The lenient
|
||||
/// fake above accepts anything and can't catch this bug class.
|
||||
private func makeStrictFakeACP(at dir: String, name: String = "hermes-acp-strict") -> String {
|
||||
let path = (dir as NSString).appendingPathComponent(name)
|
||||
let script = """
|
||||
#!/bin/zsh
|
||||
framing='{"jsonrpc":"2.0","id":'
|
||||
jq=/usr/bin/python3
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
method=$(echo "$line" | $jq -c 'import json,sys; print(json.load(sys.stdin).get("method",""))')
|
||||
rid=$(echo "$line" | $jq -c 'import json,sys; d=json.load(sys.stdin).get("id"); print(d if d is not None else "x")')
|
||||
if [[ "$method" == "initialize" ]]; then
|
||||
echo $framing"$rid",'"result":{"protocolVersion":1,"agentInfo":{"name":"hermes-agent","title":"Hermes","version":"9.9.9"}}}'
|
||||
elif [[ "$method" == "session/new" ]]; then
|
||||
ok=$(echo "$line" | $jq -c 'import json,sys; print("1" if "mcpServers" in json.load(sys.stdin).get("params",{}) else "0")')
|
||||
if [[ "$ok" == "1" ]]; then
|
||||
echo $framing"$rid",'"result":{"sessionId":"sess-1"}}'
|
||||
else
|
||||
echo $framing"$rid",'"error":{"code":-32602,"message":"Invalid params: mcpServers required"}}'
|
||||
fi
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
"""
|
||||
try? FileManager.default.createDirectory(atPath: dir, withIntermediateDirectories: true)
|
||||
try? script.write(toFile: path, atomically: true, encoding: .utf8)
|
||||
_ = try? FileManager.default.setAttributes([.posixPermissions: 0o755], ofItemAtPath: path)
|
||||
return path
|
||||
}
|
||||
|
||||
// MARK: - Client tests
|
||||
|
||||
@Suite("ACPClientTests")
|
||||
@@ -204,6 +236,43 @@ struct ACPClientTests {
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `build metadata does not fabricate version drift`() async {
|
||||
let fake = makeFakeACP(at: acpTempDir("metadata-drift"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
// The gate records the derived version; the handshake answers the base —
|
||||
// same engine, strings differ only in +build metadata → no note.
|
||||
model.recordedVersionProvider = { "9.9.9+2177.g735e426" }
|
||||
await model.openSession()
|
||||
guard case .ready = model.phase else {
|
||||
Issue.record("expected ready, got \(model.phase)")
|
||||
return
|
||||
}
|
||||
#expect(model.versionNote == nil)
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `real base-version drift still fires the note`() {
|
||||
#expect(MentorSessionModel.baseVersion(of: "0.21.5+2177.g735e426") == "0.21.5")
|
||||
#expect(MentorSessionModel.baseVersion(of: "0.21.5") == "0.21.5")
|
||||
#expect(MentorSessionModel.baseVersion(of: "unknown") == "unknown")
|
||||
#expect(MentorSessionModel.baseVersion(of: "0.20.6") != MentorSessionModel.baseVersion(of: "0.21.5"))
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `session new against strict mcpServers schema reaches ready`() async {
|
||||
let fake = makeStrictFakeACP(at: acpTempDir("strict"))
|
||||
let model = MentorSessionModel(binaryPath: fake)
|
||||
await model.openSession()
|
||||
guard case let .ready(sessionId) = model.phase else {
|
||||
Issue.record("expected ready against strict engine, got \(model.phase); stderr: \(model.stderrTail)")
|
||||
return
|
||||
}
|
||||
#expect(sessionId == "sess-1")
|
||||
model.shutdown()
|
||||
}
|
||||
|
||||
@MainActor
|
||||
@Test func `model crash surfaces restart prompt and fresh engine recovers`() async throws {
|
||||
let dir = acpTempDir("restart")
|
||||
|
||||
Reference in new issue
Block a user