fix(create-feature): 생성 기능이 scope fence로 끝난 요청을 실패로 보고하지 않는다

생성 기능의 입력(create<Base>FeatureInput)은 실패한 읽기를 telemetry
warning(<base>.list.failed 등)으로 보낸다. 그런데 abort 판정이
REQUEST_ABORTED 하나뿐이다. 로그아웃·계정 전환의 scope fence로 끝난
요청은 SCOPE_GENERATION_CHANGED로 오므로 실패로 보고된다. 테스트 전략
7.1절은 abort를 telemetry 실패로 세지 않는다고 적는다.

고른 방법: abort 판정을 src/contracts/errors.ts의 isAbortFailure 하나로
두고(REQUEST_ABORTED, SCOPE_GENERATION_CHANGED), 생성 입력이 그것을
부른다. 생성 입력 시험에 fence 경우를 더한다. 버린 대안: 생성 템플릿에
kind 둘을 적기(판정이 기능마다 사본이 된다).

생성 기능 API가 isAbortFailure를 가져오면서 기능 모양 측정의 초기
JavaScript가 바뀌었다(context 하나당 4 B → 21 B, 허용치 16 B를 넘어 기록 시험이
실패했다). 생성 코드를 바꾼 변경과 같은 커밋에서 측정 스크립트(--initial-baseline
--write)로 기록을 다시 썼다.

위험·한계: 이미 생성한 기능은 바뀌지 않는다. CHANGELOG에 그 두 줄을
옮기는 안내를 적는다. isAbortFailure는 contracts의 새 export다(추가만).

검증: tests/unit/abort-failure.test.ts, create-feature.test.ts의 새
시험이 고치기 전 코드에서 실패하고 고친 뒤 통과한다. 생성 기능 안의 새
시험은 FE-GATE-020 scaffold 드릴이 돈다(PR 본문).

Refs: 1112/01-03
This commit is contained in:
DongHyeonka
2026-11-13 04:08:19 +09:00
parent 5250ff950e
commit 241a246354
5 changed files with 66 additions and 4 deletions
+3 -3
View File
@@ -41,8 +41,8 @@
"initialJavascript": {
"gzipBytes": 194354,
"files": 17,
"firstFeatureGzipBytes": 6327,
"perFeatureGzipBytes": 539,
"perContextGzipBytes": 4
"firstFeatureGzipBytes": 6355,
"perFeatureGzipBytes": 528,
"perContextGzipBytes": 21
}
}
+15 -1
View File
@@ -884,6 +884,7 @@ export type ${pascal}CreateCommand = Readonly<{ name: string }>;
`
: "";
return `import type {} from "../../../application/ports/in/application-api.ts";
import { isAbortFailure } from "../../../contracts/errors.ts";
${write ? `import type { MutationIntent } from "../../../contracts/mutation-intent.ts";\n` : ""}import type { Result } from "../../../contracts/result.ts";
import {
failOpenTelemetryPort,
@@ -938,7 +939,8 @@ export function create${pascal}FeatureInput(
// scale-architecture.md §24, §26: telemetry is best-effort and never changes the result.
const events = failOpenTelemetryPort(telemetry);
function reported<Value>(kind: string, result: Result<Value>): Result<Value> {
if (!result.ok && result.error.kind !== "REQUEST_ABORTED") {
// An aborted or fenced request did not fail (isAbortFailure).
if (!result.ok && !isAbortFailure(result.error)) {
void events.emit({
kind,
severity: "warning",
@@ -1279,6 +1281,18 @@ describe("${names.id} application input", () => {
await expect(input.listItems()).resolves.toEqual({ ok: false, error: failure });
expect(emit).not.toHaveBeenCalled();
});
it("does not report a load a scope fence ended", async () => {
const failure = createFailure("SCOPE_GENERATION_CHANGED", "${operationId}", 0);
const emit = vi.fn<TelemetryPort["emit"]>();
const input = create${pascal}FeatureInput(
gatewayListing(async () => ({ ok: false, error: failure })),
{ telemetry: { emit } },
);
await expect(input.listItems()).resolves.toEqual({ ok: false, error: failure });
expect(emit).not.toHaveBeenCalled();
});
});
`;
}
+10
View File
@@ -259,6 +259,16 @@ export const REFUSALS_OF_EVERY_ATTEMPT: Readonly<Record<string, number>> =
IDEMPOTENCY_KEY_INVALID: 400,
});
/**
* 1112/01-03. The request did not fail: its caller aborted it
* (`REQUEST_ABORTED`) or a scope fence ended it (`SCOPE_GENERATION_CHANGED`,
* sign-out or account switch). Telemetry and terminal error screens do not
* count it (testing strategy 7.1절).
*/
export function isAbortFailure(failure: AppFailure): boolean {
return failure.kind === "REQUEST_ABORTED" || failure.kind === "SCOPE_GENERATION_CHANGED";
}
/**
* 1106/03-01 (D10 supplement and its second fix). A `NOT_APPLIED` refusal
* the same request gets on every attempt: a row above, code and status
+23
View File
@@ -0,0 +1,23 @@
import { describe, expect, it } from "vitest";
import { createFailure, isAbortFailure } from "../../src/contracts/errors.ts";
/**
* 1112/01-03. A request its caller aborted and one a scope fence ended
* (sign-out, account switch) are not failures: telemetry and terminal error
* screens must not count them (docs/design/2026-07-26-frontend-platform-testing-strategy-design.md
* 7.1절). The generated feature asked only for `REQUEST_ABORTED`, so a fenced
* request went out as `<base>.list.failed`.
*/
describe("isAbortFailure", () => {
it("counts a caller abort and a scope fence as aborts", () => {
expect(isAbortFailure(createFailure("REQUEST_ABORTED", "LIST", 0))).toBe(true);
expect(isAbortFailure(createFailure("SCOPE_GENERATION_CHANGED", "LIST", 0))).toBe(true);
});
it("does not count a timeout, a server failure or a refusal", () => {
for (const kind of ["REQUEST_TIMEOUT", "SERVER_FAILURE", "FORBIDDEN", "RATE_LIMITED"] as const) {
expect(isAbortFailure(createFailure(kind, "LIST", 0)), kind).toBe(false);
}
});
});
+15
View File
@@ -459,6 +459,21 @@ describe("create:feature context declaration", () => {
});
});
// 1112/01-03. The generated input reports a failed load, not one a scope
// fence ended (sign-out, account switch): it asks the shared rule.
describe("generated feature input telemetry", () => {
it("does not report a load a scope fence ended", () => {
const { files } = plan({ id: "invoice-feature" });
expect(files.get("src/features/invoice-feature/application/invoice-feature-api.ts")).toContain(
"isAbortFailure(result.error)",
);
expect(files.get("tests/features/invoice-feature/invoice-feature-input.test.ts")).toContain(
'createFailure("SCOPE_GENERATION_CHANGED"',
);
});
});
describe("create:feature refusals", () => {
it.each(["Invoice", "invoice_feature", "-invoice", "invoice--x", "invoice-", "", "a".repeat(41)])(
"refuses the id %j",