From f329cc8042cc4c462627ca6fc2e5557ab68ae0bb Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Fri, 25 Sep 2026 22:52:18 +0900 Subject: [PATCH] fix(telemetry): keep a never-sent unauthenticated request out of api.request.failed (03-07) With no credential V3 sends nothing and returns UNAUTHENTICATED without a status, yet it was counted as an API failure, so signed-out states raised the failure rate. Diagnostics still record it once; telemetry does not. Co-Authored-By: Claude Opus 5.5 --- ...D-07-diagnostics-and-telemetry-exporter.md | 4 +- src/bootstrap/runtime-adapters.ts | 7 ++++ .../http-execution-v3-observability.test.ts | 38 +++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/docs/architecture/decisions/VD-07-diagnostics-and-telemetry-exporter.md b/docs/architecture/decisions/VD-07-diagnostics-and-telemetry-exporter.md index 713f66ec..524a55bb 100644 --- a/docs/architecture/decisions/VD-07-diagnostics-and-telemetry-exporter.md +++ b/docs/architecture/decisions/VD-07-diagnostics-and-telemetry-exporter.md @@ -51,7 +51,9 @@ vendor 결정 전에는 안전한 기본값이 아니다. key와 닫힌 value policy를 contract·fixture·이 ADR에 동시에 추가한 뒤에만 전달한다. 5-2. caller cancellation과 scope fence는 API failure가 아니다. diagnostics는 한 - 번 남기고 `api.request.failed`는 발행하지 않는다. + 번 남기고 `api.request.failed`는 발행하지 않는다. 자격증명이 없어 한 번도 + 보내지 않은 `UNAUTHENTICATED`(응답 status 없음)도 같다(03-07, + `src/bootstrap/runtime-adapters.ts` `isTerminalNonAbortFailure`). 5-3. `routeId`는 installed operation-executor 경계의 필수 입력이다. feature gateway가 소유한 low-cardinality route identity를 URL에서 재구성하지 않는다. 6. `app.boot.failed`, `ui.render.failed`, `release.mismatch.detected`, diff --git a/src/bootstrap/runtime-adapters.ts b/src/bootstrap/runtime-adapters.ts index 22306b3d..87bdfbdf 100644 --- a/src/bootstrap/runtime-adapters.ts +++ b/src/bootstrap/runtime-adapters.ts @@ -285,6 +285,13 @@ function isTerminalNonAbortFailure( ): boolean { if (observation.outcome === "SUCCESS") return false; if (observation.outcome === "CANCELLED") return false; + // 03-07. No credential, nothing sent: a client state, not an API failure. + if ( + observation.outcome === "UNAUTHENTICATED" && + observation.status === undefined + ) { + return false; + } if ( observation.cancellationOwner !== undefined && CALLER_OWNED_CANCELLATION.has(observation.cancellationOwner) diff --git a/tests/integration/http-execution-v3-observability.test.ts b/tests/integration/http-execution-v3-observability.test.ts index 50d2d328..19de1375 100644 --- a/tests/integration/http-execution-v3-observability.test.ts +++ b/tests/integration/http-execution-v3-observability.test.ts @@ -210,6 +210,44 @@ describe("V3 HTTP observability projection", () => { expect(JSON.stringify(sinks.telemetry)).not.toContain("server-ref-7"); }); + it("keeps a never-sent unauthenticated request out of telemetry (03-07)", async () => { + const sinks = recordingSinks(); + const fetcher = vi.fn(); + const executor = createContractHttpExecutor({ + baseUrl: "https://api.example/", + maxRetryAttempts: 0, + attachCredentials: () => ({ kind: "UNAUTHENTICATED" as const }), + fetcher: fetcher as unknown as typeof fetch, + observe: sinks.projector, + }); + + const outcome = await executor.execute( + TEST_LIST_HTTP_CONTRACT, + { limit: 5 }, + { routeId: ROUTE_ID, scope: scopeSnapshot() }, + ); + + expect(outcome.kind).toBe("UNAUTHENTICATED"); + expect(fetcher).not.toHaveBeenCalled(); + expect(sinks.diagnostics).toHaveLength(1); + expect(sinks.telemetry).toHaveLength(0); + + // A server 401 is still an API failure. + const answered = recordingSinks(); + await createContractHttpExecutor({ + baseUrl: "https://api.example/", + maxRetryAttempts: 0, + attachCredentials: () => ({ kind: "READY" as const, headers: {} }), + fetcher: (async () => new Response(null, { status: 401 })) as unknown as typeof fetch, + observe: answered.projector, + }).execute( + TEST_LIST_HTTP_CONTRACT, + { limit: 5 }, + { routeId: ROUTE_ID, scope: scopeSnapshot() }, + ); + expect(answered.telemetry).toHaveLength(1); + }); + it("does not emit failure telemetry for caller cancellation or scope fencing", async () => { const cancelled = recordingSinks(); const callerController = new AbortController();