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.
This commit is contained in:
Nathan Hangen 2026-05-10 21:36:32 -04:00
parent f13bd3c4c6
commit 4c24bac0e9

View file

@ -138,7 +138,12 @@ export async function shutdownMetrics(): Promise<void> {
}
}
/** 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<T>(
tool: string,
fn: () => Promise<T>,