From 4c24bac0e90210afbfb036330985f581edae93ed Mon Sep 17 00:00:00 2001 From: Nathan Hangen Date: Sun, 10 May 2026 21:36:32 -0400 Subject: [PATCH] docs(mcp): document hasError contract for new error envelope shapes The detector currently matches result.isError === true because the server's catch path produces that envelope. A future handler that returns a structured error without throwing must still be classified by hasError, or the bytes histogram will sample it as success. --- gitnexus/src/mcp/metrics.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/gitnexus/src/mcp/metrics.ts b/gitnexus/src/mcp/metrics.ts index 0dc417fb4..e241d3389 100644 --- a/gitnexus/src/mcp/metrics.ts +++ b/gitnexus/src/mcp/metrics.ts @@ -138,7 +138,12 @@ export async function shutdownMetrics(): Promise { } } -/** hasError must be a boolean; never accept the error string — cypher errors echo user input. */ +/** + * hasError must be a boolean; never accept the error string — cypher errors echo user input. + * Contract: hasError returns true for any result the caller considers a failed outcome. + * If a future handler returns a structured error envelope without throwing, hasError must + * still classify it, otherwise the bytes histogram will sample it as success data. + */ export async function observe( tool: string, fn: () => Promise,