Reply.md
Reply
type: module path: "@root/src/PuduLangMcp/Domain/Rpc/Reply.pudu" fidelity: Active grammar: "[[grammar/pudu]]" seam: "[[seams/Transport]]" depth_score: 0.5 depth_status: MODERATE coupling: 3 interface_stability: 0.9 tags: [module] aliases: [Reply]
Purpose
Encode results and errors as single JSON lines, and give every complete result the fields the modern protocol requires.
Interface
Signatures
export type Cache = NoCache | Cached(Int, Str) // ttlMs, cacheScope
export fn complete(fields: &Array[(Str, Json.Json)], cache: &Cache) -> Json.Json
export fn result(id: &Message.RequestId, body: &Json.Json) -> Str
export fn failure(id: &Option[Message.RequestId], problem: &RpcError.ProtocolError) -> StrGovernance
completeaddsresultType: "complete"and_metawithserverInfo {name, title, version}; aCachedhint addsttlMsandcacheScope.- Output is
Json.encode, which escapes line breaks, so every reply is exactly one line.
Linkage
- Requires: [[src/PuduLangMcp/Domain/Rpc/Message]], [[src/PuduLangMcp/Errors/RpcError]], [[src/PuduLangMcp/Constants/Protocol]], [[src/PuduLangMcp/Constants/Server]].
- Consumed by: [[src/PuduLangMcp/App/Dispatch]] and every
Apphandler that builds a body.
Algorithm
result:{"jsonrpc":"2.0","id":…,"result":body}.failure:{"jsonrpc":"2.0","id":… or null,"error":{"code","message","data"?}}.
Negative Logic (Prohibited Paths)
- No reply carries both
resultanderror. ttlMsis never negative.
Edge Cases
- A
Cachedhint with a negative ttl is written as0.
Depth
DEPTH 0.5.
Grill Log
- Q: Where are
resultTypeandserverInfoadded? A: Once, here. _Rationale:_ every handler would otherwise repeat them and one would forget. _Rejected:_ per-handler fields.
Referenced by
[[src/PuduLangMcp/Domain/Rpc/_MOC]]
