Skip to main content

Module memory_envelope

Module memory_envelope 

Source
Expand description

Shared trusty-memory tools/call envelope helpers (#2424).

Why: trusty-memory direct-dispatches only its TOOL_METHODS allowlist — every chat_* tool is reachable ONLY via the MCP tools/call envelope, which the #2343 soak found the turn recorder was not using (100% of durable writes failed -32601). One shared implementation of the envelope build/unwrap keeps the write side (session::memory_sink) and the read side (tools::recall_session) on the same verified shape. What: tools_call_params, parse_tools_call_envelope, call_tool_wrapped. Test: memory_envelope::tests::*. Shared trusty-memory tools/call envelope helpers (#2424).

Why: trusty-memory’s JSON-RPC surface direct-dispatches only the methods in its TOOL_METHODS allowlist (crates/trusty-memory/src/transport/ rpc.rs); everything else — notably every chat_* tool — is reachable ONLY via the MCP-style tools/call envelope. The #2343 soak (2026-07-11) found memory_sink::write_turn’s direct-method dispatch of chat_turn_append failing -32601 Method not found on 100% of turns (#2424), while #2348’s recall_session — which already used the tools/call envelope — worked. This module is the SINGLE shared implementation of that spike-verified envelope shape (build the {"name", "arguments"} params; unwrap the STRINGIFIED JSON blob the daemon returns inside result.content[0].text) so the write side (session::memory_sink) and the read side (tools::recall_session) can never drift apart again. What: tools_call_params builds the request params; parse_tools_call_envelope unwraps a response envelope; call_tool_wrapped composes both around trusty_common::memory_rpc::call_memory_tool_at for callers that want a one-shot “call this tool, give me its parsed result” helper. Test: memory_envelope::tests::*.

Functions§

call_tool_wrapped
Call one trusty-memory tool through the tools/call envelope and return its parsed inner result.
parse_tools_call_envelope
Extract and parse the inner tool-result JSON from a tools/call response envelope.
tools_call_params
Build the params object for a JSON-RPC tools/call request.