diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b812042..4691937d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ #### 옮기는 법 1. **HTTP 스키마 행에 `direction`·`unknownFieldPolicy`를 적는다.** descriptor의 입력·응답·실패 검증기로 쓰이는 스키마의 FE-REG-SCHEMA 행이 둘 중 하나를 빼면 `tests/unit/schema-metadata-policy.test.ts`(`test:unit`)가 `row states no direction, used as <방향>`이나 `row states no unknownFieldPolicy, validator <탐침 결과>`로 실패한다. 행이 아예 없으면 같은 메시지와 `no FE-REG-SCHEMA row`가 나온다. 라우트에만 쓰는 행은 그대로 둬도 된다. 객체가 아닌 본문의 검증기(`responseBody: "NONE"` 출력의 `z.undefined()` 등)는 탐침이 정책을 판정할 수 없어 `direction`만 요구한다. memento-web이 2026-11-03 조치 절 "옮기는 법" 5단계로 더하는 43행도 두 칸을 적는다 (1106/07-02) -2. **`src/presentation/i18n/catalog.ts`를 고친 제품은 `form.resendLater`를 한국어·영어 두 catalog에 더한다.** 결과 불명 요청을 같은 키로 다시 보낸 시도가 쓰기 전에 거절되면(같은 요청이 매번 받는 입력 검증 거절은 빼고) 폼이 이 문구를 보인다. 키가 없으면 그 자리에 `common.unavailable` 문구가 나오고, 한 언어에만 있으면 `check:i18n`이 실패한다 (1106/03-01) +2. **`src/presentation/i18n/catalog.ts`를 고친 제품은 `form.resendLater`를 한국어·영어 두 catalog에 더한다.** 결과 불명 요청을 같은 키로 다시 보낸 시도가 쓰기 전에 거절되면(짝 백엔드 표의 400 `VALIDATION_FAILED`·`IDEMPOTENCY_KEY_INVALID`는 빼고) 폼이 이 문구를 보인다. 키가 없으면 그 자리에 `common.unavailable` 문구가 나오고, 한 언어에만 있으면 `check:i18n`이 실패한다 (1106/03-01) 3. **디자인 토큰 CSS를 고친 제품은 `src/presentation/design-system/tokens/component.css`의 `--dialog-backdrop-weight`·`--dialog-backdrop`·`--dialog-backdrop-on-surface`를 가져온다.** `primitives.css`의 `.ui-dialog::backdrop`과 `:root:has(.ui-dialog[open])`이 이 토큰을 읽는다. 빠지면 modal 가림막이 투명해지고, 그것을 잡는 검사는 없다. memento는 이 파일을 고쳤다 (1106/08-03) 4. **IDEMPOTENT로 선언한 쓰기가 두 번 적용해도 결과가 같은지 확인한다.** `...commandMutationIdentity()`로 받은 정책은 이제 `resendSafe`를 싣는다. 그래서 IDEMPOTENT 쓰기는 결과 불명 뒤 재전송 버튼이 그려지고, 같은 입력 저장이 `UNKNOWN_EFFECT_PENDING`으로 거절되지 않는다. 백엔드가 중복을 막지 못하는 쓰기를 IDEMPOTENT로 적었다면 사용자가 다시 보내 같은 항목이 둘 생길 수 있다(매뉴얼 02 결정표 3절). memento-web의 IDEMPOTENT 쓰기는 아래 절 2단계로 옮기면 여기에 든다. `commandMutationIdentity` 결과를 `toEqual`로 비교하던 테스트는 `resendSafe`를 더한다 (1106/03-03) 5. **CI 계약 기준선을 자기 값으로 다시 기록한 제품은 받은 뒤 다시 기록한다.** FE-GATE-027의 명령 순서가 바뀌어 `gateShapeSha256`이 바뀌었다. `CI_CONTRACT_BASELINE_OWNER=<팀> CI_CONTRACT_BASELINE_REASON=<이유> corepack pnpm update:ci-contract-baseline`. 다시 기록하지 않으면 `check:ci`가 기준선 차이로 실패한다 (1106/13-01) @@ -48,8 +48,8 @@ | [계약] | `test:a11y`(FE-GATE-009)의 report(`scripts/write-a11y-report.ts`)가 설치된 descriptor로 한 자원을 읽는 라우트를 찾는다. 로그인이 필요한 라우트의 `paramsSchema`가, 경로 파라미터가 있고 빈 목록을 거부하는 GET의 입력 스키마인 경우다. 그 라우트에 실패 화면 기록(`artifacts/tests/a11y-data-state/`)이 없으면 `a11y.json not written:`으로 실패하고 `a11y.json`을 쓰지 않는다. 접근성 spec의 라우트 test는 시작할 때 자기 기록을 지운다. `paramsSchema`가 GET 입력과 다른 상세 라우트는 전처럼 기록만으로 정해진다. 그 GET을 부르지 않는 페이지의 라우트(하위 항목 작성 폼 등)가 GET 입력 스키마를 `paramsSchema`로 쓰면 이 검사가 실패한다. 그 라우트에 자기 `paramsSchema`를 따로 둔다 (1106/11-01) | `scripts/lib/a11y-data-state.ts`, `scripts/write-a11y-report.ts`, `tests/e2e/accessibility.spec.ts` | `9c4cddc`, `95141f1` | | [계약] | `tests/unit/schema-metadata-policy.test.ts`가 descriptor의 입력·응답·실패 검증기로 쓰인 스키마 행이 `direction`·`unknownFieldPolicy`를 적지 않으면 실패한다. 전에는 건너뛰어서, 응답 DTO를 strict로 바꿔도 `check:registries`와 `test:unit` 어느 쪽도 보지 않았다. 템플릿 HTTP 행과 생성기가 쓰는 행은 이미 두 칸을 적는다. 탐침이 객체에 닿지 못하는 검증기(객체가 아닌 본문)는 `direction`만 요구한다. 위 "먼저 할 일" 1단계 (1106/07-02) | `tests/unit/schema-metadata-policy.test.ts`, `docs/manual/01-add-a-feature.md`, `docs/manual/reference/errors.md` | `e7b1b01`, `efe11f1` | | [계약] | 제품 기능 제거 드릴의 `tests` 잔여에, 본문이 기능 ID나 폴더 이름을 적힌 그대로(대소문자 구분) 한 이름(앞뒤가 `[A-Za-z0-9_-]`가 아님)으로 적은 Playwright spec(`*.spec.[cm]?[jt]sx?`)이 든다. `-`가 든 이름만 찾는다. `messages`·`status` 같은 한 단어 ID는 템플릿 spec이 평범한 단어로 쓰므로 찾지 않는다. vitest는 spec을 돌지 않아 `test:all`도 잡지 못했다. vitest 테스트 본문은 전처럼 보지 않는다. 매뉴얼 01 11단계와 `errors.md`의 판정 문장을 고쳤다 (1106/16-01) | `scripts/lib/feature-residue.ts`, `docs/manual/` | `af3344b`, `eb03dab` | -| [계약] | KEYED 결과 불명 요청을 같은 키로 다시 보낸 시도가 쓰기 전 거절(429, 401, 403, 503 `RATE_LIMIT_*`, 422 `IDEMPOTENT_REQUEST_MISMATCH`, 기능이 선언한 code)이나 보내기 전 실패(`NOT_STARTED`)로 끝나면, 훅이 결과 불명과 intent·키를 남긴다. 전에는 그 판정을 논리 요청 전체의 판정으로 써서 다음 저장이 새 키로 나갔다. 실패는 그대로 돌려주고, `Retry-After`는 다음 재전송의 대기 시각이 되고, 낙관적 층은 되돌리지 않고 불확실로 둔다. 폼은 결과 불명 화면(확인·다시 보내기)을 그대로 두고 `form.resendLater` 문구로 feedback에 포커스를 옮긴다. 같은 요청이 매번 받는 거절(`isRefusedOnEveryAttempt`: 입력 검증 `VALIDATION_REJECTED`, 400 `VALIDATION_FAILED`, 400 `IDEMPOTENCY_KEY_INVALID`)은 첫 요청도 거절됐다는 뜻이라 결과 불명을 풀고, 폼은 필드 오류를 보이고 저장을 다시 받는다. 처음 보낸 요청의 `NOT_APPLIED`와 재전송의 성공은 전처럼 정리한다. 메인 세션 결정 D10과 그 보충이다. 위 "먼저 할 일" 2단계 (1106/03-01) | `src/presentation/adapters/query/application-query.ts`, `src/presentation/forms/use-app-form.ts`, `src/contracts/errors.ts`, `src/presentation/i18n/catalog.ts`, `docs/operations/api-contract-and-server-state-recovery.md` | `2568587`, `80e7f1d` | -| [계약] | `commandMutationIdentity`가 `resendSafe`(`retrySemantics`가 `KEYED`나 `IDEMPOTENT`)도 돌려주고, `BoundMutation`에 선택 칸 `resendSafe?`가 생겼다(추가만). 결과 불명 뒤 재전송 버튼과 같은 입력 재제출 거절(아래 절 0929/03-03 행)이 키 유무 대신 "키가 있거나 `resendSafe`"를 본다. 그래서 IDEMPOTENT 쓰기도 다시 보낼 수 있다. 그 재전송도 위 1106/03-01 행의 규칙을 따른다. 기능 분류기가 적용 안 됨으로 읽는 404·412 같은 code는 첫 요청이 이미 적용됐을 때 흔한 답이라 결과 불명을 남기고, 입력 검증 거절만 푼다. 칸이 없는 손 정책과 NEVER는 전과 같다. 위 "먼저 할 일" 4단계 (1106/03-03) | `src/contracts/server-state.ts`, `src/presentation/adapters/query/application-query.ts`, `src/application/view-models/async-state.ts`, `docs/manual/` | `815ea58`, `80e7f1d` | +| [계약] | KEYED 결과 불명 요청을 같은 키로 다시 보낸 시도가 쓰기 전 거절(429, 401, 403, 503 `RATE_LIMIT_*`, 422 `IDEMPOTENT_REQUEST_MISMATCH`, 기능이 선언한 code)이나 보내기 전 실패(`NOT_STARTED`)로 끝나면, 훅이 결과 불명과 intent·키를 남긴다. 전에는 그 판정을 논리 요청 전체의 판정으로 써서 다음 저장이 새 키로 나갔다. 실패는 그대로 돌려주고, `Retry-After`는 다음 재전송의 대기 시각이 되고, 낙관적 층은 되돌리지 않고 불확실로 둔다. 폼은 결과 불명 화면(확인·다시 보내기)을 그대로 두고 `form.resendLater` 문구로 feedback에 포커스를 옮긴다. 같은 요청이 매번 받는 거절은 첫 요청도 거절됐다는 뜻이라 결과 불명을 풀고, 폼은 필드 오류를 보이고 저장을 다시 받는다. 짝 백엔드 표의 code만 그렇게 읽는다. 지금은 400 `VALIDATION_FAILED`(필드 목록이 있든 없든)와 400 `IDEMPOTENCY_KEY_INVALID`다(`isRefusedOnEveryAttempt`). 기능의 `mapProblem`이 정한 kind(`VALIDATION_REJECTED`)는 보지 않는다. 기능 code는 상태 규칙일 수 있다. 그래서 백엔드의 `VALIDATION_FAILED`는 요청 내용만 보는 검사여야 한다(계약 문서 6.1절). 처음 보낸 요청의 `NOT_APPLIED`와 재전송의 성공은 전처럼 정리한다. 메인 세션 결정 D10과 그 보충 둘이다. 위 "먼저 할 일" 2단계 (1106/03-01) | `src/presentation/adapters/query/application-query.ts`, `src/presentation/forms/use-app-form.ts`, `src/contracts/errors.ts`, `src/presentation/i18n/catalog.ts`, `docs/operations/api-contract-and-server-state-recovery.md`, `docs/architecture/backend-api-and-server-state-contract.md` | `2568587`, `80e7f1d`, `b41990c`, `6142cc8` | +| [계약] | `commandMutationIdentity`가 `resendSafe`(`retrySemantics`가 `KEYED`나 `IDEMPOTENT`)도 돌려주고, `BoundMutation`에 선택 칸 `resendSafe?`가 생겼다(추가만). 결과 불명 뒤 재전송 버튼과 같은 입력 재제출 거절(아래 절 0929/03-03 행)이 키 유무 대신 "키가 있거나 `resendSafe`"를 본다. 그래서 IDEMPOTENT 쓰기도 다시 보낼 수 있다. 그 재전송도 위 1106/03-01 행의 규칙을 따른다. 기능 분류기가 적용 안 됨으로 읽는 404·412 같은 code는 첫 요청이 이미 적용됐을 때 흔한 답이라 결과 불명을 남기고, 짝 백엔드 표의 두 400만 푼다. 칸이 없는 손 정책과 NEVER는 전과 같다. 위 "먼저 할 일" 4단계 (1106/03-03) | `src/contracts/server-state.ts`, `src/presentation/adapters/query/application-query.ts`, `src/application/view-models/async-state.ts`, `docs/manual/` | `815ea58`, `80e7f1d`, `b41990c` | | [계약] **BREAKING** | `createBoundedPollCoordinator`와 `BoundedPollCoordinatorDependencies`에 타입 인자 `Operation extends BoundedPollOperation = BoundedPollOperation`이 생겼다. `operation`과 `execute`의 `input.operation`이 그 타입이라, 실행기 호출이 기능 descriptor의 입력·출력 타입으로 검사된다. 런타임 동작은 같다. realtime 설계 9.2절에 V3 실행기 결과 kind마다 poll 결과(kind, retryable, `retryAfterMs`)를 적은 표가 생겼다. 표대로 조합하면 401·403은 요청 한 번으로 lease를 끝낸다. 표는 조합 코드가 따를 규칙이고 강제하지 않는다. 위 "먼저 할 일" 6단계 (1106/04-02) | `src/adapters/realtime/polling/bounded-poll-coordinator.ts`, `src/application/policies/bounded-polling.ts`, `docs/architecture/realtime-events-web-push-and-bounded-polling.md` | `6f06e77` | | [계약] | `PublicResponseCacheAdminPort.activateRelease`의 옵션에 `replaceUnreadablePointer?: boolean`이 생겼다(추가만). `true`면 active pointer 본문을 읽지 못한 이유와 상관없이, 손상 pointer처럼 검증된 후보로 rollback 목록 없이 덮어쓴다. 기본값은 전처럼 멈춤이다. 켜면 일시 오류에서도 rollback 목록을 잃고, 다음 cleanup이 새 활성 release 밖의 owned release cache를 모두 지운다. 언제 쓰는지는 운영 문서에 있다 (1106/02-01) | `src/application/ports/browser-file-storage/cache-storage-ports.ts`, `src/adapters/cache-storage/public-response-cache-adapter.ts`, `docs/operations/client-cache-and-storage-recovery.md`, `docs/architecture/browser-file-and-origin-storage.md` | `4cef2a2` | | [계약] | 열린 modal의 가림막이 스크롤바 자리(`scrollbar-gutter: stable`, 1105/15-05)까지 덮는다. modal이 열린 동안 `:root:has(.ui-dialog[open])`이 root 배경을 가림막을 페이지 바탕에 겹친 불투명 색(`--dialog-backdrop-on-surface`)으로 바꾸고, `body`가 페이지 바탕(`--color-surface`)을 직접 칠한다. `component.css`에 토큰 셋(`--dialog-backdrop-weight` 55%, `--dialog-backdrop`, `--dialog-backdrop-on-surface`)이 생겼다. 새 시각 검사 `tests/visual/scrollbar-gutter.visual.spec.ts`가 스크롤바를 숨기지 않은 Chromium에서 그 자리 색을 본다. compact 골든 1장(`app-shell-compact-pseudo-drawer`)을 다시 찍었다. header 띠는 남는다(디자인 시스템 문서 8.2절). 위 "먼저 할 일" 3단계 (1106/08-03) | `src/presentation/design-system/tokens/component.css`, `src/presentation/styles/theme/base.css`, `src/presentation/styles/theme/primitives.css`, `tests/visual/` | `7625dc4` | @@ -74,7 +74,7 @@ - 일부: 실행 격리. `check:bundle`은 이제 `RUN_OUTPUT_ROOT`가 있으면 멈춘다. 같은 모양일 수 있는 `check:app-build-input:bundle`, `check:optional-recipes --require-dist`, release candidate 조립은 보지 않았다 (1105/12-04, 1106/12-02). - 일부: poll 조합 코드가 `input.operation`을 무시하고 다른 descriptor를 넘기는 것은 여전히 막지 않는다. 이제 `input.operation`이 descriptor 타입을 가져 그 길을 쓰기가 더 쉽다. 9.2절 표는 규칙이고, 템플릿은 poll `execute` 기본 구현을 주지 않는다 (1103/04-01, 1106/04-02). - 일부: reconnect `attempt` 안에서 연결을 만드는 조합 코드는 설정 오류가 여전히 서버 장애로 보인다. 규칙만 적었다 (1106/04-01). -- 일부: 결과 불명 재전송이 rate limit에 막힌 동안 결과 불명 화면이 남고, 다시 보내기는 `Retry-After`(상한 5초)를 기다린다. 폼 밖에서 부른 같은 입력 재저장이 `NOT_APPLIED`로 끝나면 훅은 키를 지키지만 폼은 retry-later를 보인다. 기능이 선언한 결정적 거절(생성 기능의 400 `_INVALID`)은 어느 쪽인지 알 수 없어 재전송 뒤에도 결과 불명으로 남는다. 출구는 결과 불명 화면의 확인이다 (1106/03-01). +- 일부: 결과 불명 재전송이 rate limit에 막힌 동안 결과 불명 화면이 남고, 다시 보내기는 `Retry-After`(상한 5초)를 기다린다. 폼 밖에서 부른 같은 입력 재저장이 `NOT_APPLIED`로 끝나면 훅은 키를 지키지만 폼은 retry-later를 보인다. 기능이 선언한 결정적 거절(생성 기능의 400 `_INVALID`)과 problem details를 읽는 기능의 422 입력 검증(참조 기능은 모든 422를 필드 오류로 읽는다)은 어느 쪽인지 알 수 없어 재전송 뒤에도 결과 불명으로 남는다. 출구는 결과 불명 화면의 확인이다 (1106/03-01). - 일부: 기능 제거 드릴은 route ID나 URL만 적은 spec과 한 단어 기능 ID만 적은 spec을 잡지 못하고, 다운스트림 spec이 다른 이유로 `-`가 든 기능 ID를 한 이름으로 적으면 거짓 양성이 난다. 부분 문자열 검색의 거짓 양성과 dist 빌드 잔여 검사는 그대로다 (1106/16-01, 1105/16-04). - 일부: `:has()`를 모르는 브라우저(Firefox 121 미만 등)는 전처럼 가림막 옆에 띠가 남는다. 오른쪽 drawer, RTL, Firefox, WebKit은 보지 않았다 (1106/08-03). - 일부: Cache Storage release marker 본문이 계속 읽히지 않으면 stage가 marker를 다시 쓰지 않는다. `replaceUnreadablePointer`는 active pointer만 푼다 (1105/02-02, 1106/02-01). diff --git a/docs/architecture/backend-api-and-server-state-contract.md b/docs/architecture/backend-api-and-server-state-contract.md index 57bc3da1..f6131c85 100644 --- a/docs/architecture/backend-api-and-server-state-contract.md +++ b/docs/architecture/backend-api-and-server-state-contract.md @@ -338,6 +338,10 @@ mutation이 400·409·422로 실패하면 프론트는 그 요청이 적용됐 `IDEMPOTENCY_RECOVERY_REQUIRED`, §4의 503 `REQUEST_TIMEOUT`이다. 실행기가 자동으로 다시 보내는 것은 KEYED 명령의 503 `IDEMPOTENCY_UNAVAILABLE`뿐이다. 나머지는 결과 불명 화면에서 사용자가 같은 키로 다시 보낸다. +- 같은 키 재전송이 400 `VALIDATION_FAILED`로 거절되면 첫 요청도 거절된 것으로 보고 결과 + 불명을 풀므로(1106/03-01, `src/contracts/errors.ts` `isRefusedOnEveryAttempt`), + `VALIDATION_FAILED`는 요청 내용만 보는 검사여야 하고, 시각이나 데이터베이스를 읽는 + 규칙은 기능이 선언한 code로 내며 그 code는 결과 불명을 풀지 않는다. - §4의 503 `RATE_LIMIT_UNAVAILABLE`(rate-limit 저장소 응답 없음, `Retry-After` 있음)과 503 `RATE_LIMIT_INCOMPATIBLE`(rate-limit 제공자가 계약과 맞지 않음)은 status와 code가 함께 맞으면 기능 분류기와 상관없이 `NOT_APPLIED`다(1105/03-02, `backend-envelope.ts` diff --git a/docs/operations/api-contract-and-server-state-recovery.md b/docs/operations/api-contract-and-server-state-recovery.md index 4179a062..74e0ed3e 100644 --- a/docs/operations/api-contract-and-server-state-recovery.md +++ b/docs/operations/api-contract-and-server-state-recovery.md @@ -260,10 +260,12 @@ diagnostics에만 남고 `api.request.failed`에는 세지 않는다(03-07). 그 `IDEMPOTENT_REQUEST_MISMATCH`, 기능이 선언한 code) 보내지 못하면(`NOT_STARTED`) 그 시도만 적용되지 않은 것이다. 결과 불명과 key는 그대로다. 폼은 "잠시 뒤 같은 요청으로 다시 보내 주세요"와 결과 불명 화면(확인, 다시 보내기)을 보이고 저장을 받지 않는다. - 401은 다시 로그인 안내가 먼저다. 예외는 같은 요청이 매번 받는 거절이다. 입력 검증 - (`VALIDATION_REJECTED`, 400 `VALIDATION_FAILED`)과 400 `IDEMPOTENCY_KEY_INVALID`는 첫 - 요청도 거절됐다는 뜻이라 결과 불명을 풀고, 폼은 필드 오류를 보이고 저장을 다시 - 받는다(1106/03-01, `src/contracts/errors.ts` `isRefusedOnEveryAttempt`). + 401은 다시 로그인 안내가 먼저다. 예외는 같은 요청이 매번 받는 거절이다. 짝 백엔드 표의 + 400 `VALIDATION_FAILED`(필드 목록이 있든 없든)와 400 `IDEMPOTENCY_KEY_INVALID`만 첫 + 요청도 거절됐다는 뜻으로 읽어 결과 불명을 풀고, 폼은 필드 오류를 보이고 저장을 다시 + 받는다. 기능의 `mapProblem`이 정한 kind(`VALIDATION_REJECTED`)는 보지 않는다. 기능 + code는 상태 규칙일 수 있다(1106/03-01, `src/contracts/errors.ts` + `isRefusedOnEveryAttempt`). 키가 없는 command(`NEVER`)는 서버가 두 번째 요청을 가려내지 못하므로 재전송 버튼을 그리지 않는다(`canResendUnknownEffect`, 0929/03-03). 같은 canonical input의 재저장도 보내지 않는다. 훅의 `submit`이 `NOT_STARTED` `DUPLICATE_IN_FLIGHT`(code diff --git a/src/contracts/errors.ts b/src/contracts/errors.ts index 9290d49f..f6b98b62 100644 --- a/src/contracts/errors.ts +++ b/src/contracts/errors.ts @@ -260,17 +260,18 @@ export const REFUSALS_OF_EVERY_ATTEMPT: Readonly> = }); /** - * 1106/03-01 (D10 supplement). A `NOT_APPLIED` refusal the same request gets - * on every attempt: input validation (`VALIDATION_REJECTED`) or a row above. - * A resend of an unknown request that meets one shows the first attempt was - * refused too, so the request is settled. Not one: a refusal before the - * idempotency check or one that changes over time (429, 401, 403, 503 - * RATE_LIMIT_*), a code a feature declared refused before its write (it may - * be a rule on changing state), any other code, and `NOT_STARTED`. + * 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 + * together. A resend of an unknown request that meets one shows the first + * attempt was refused too, so the request is settled. Not one: a refusal + * before the idempotency check or one that changes over time (429, 401, + * 403, 503 RATE_LIMIT_*), a code a feature declared refused before its + * write (it may be a rule on changing state), any other code, and + * `NOT_STARTED`. The kind is not read: a feature's `mapProblem` sets it, and + * it maps its own codes, or every 422, to `VALIDATION_REJECTED`. */ export function isRefusedOnEveryAttempt(failure: AppFailure): boolean { if (failure.effect !== "NOT_APPLIED") return false; - if (failure.kind === "VALIDATION_REJECTED") return true; return ( Object.hasOwn(REFUSALS_OF_EVERY_ATTEMPT, failure.code) && REFUSALS_OF_EVERY_ATTEMPT[failure.code] === failure.httpStatus diff --git a/src/presentation/adapters/query/application-query.ts b/src/presentation/adapters/query/application-query.ts index 03bdca14..5837e348 100644 --- a/src/presentation/adapters/query/application-query.ts +++ b/src/presentation/adapters/query/application-query.ts @@ -636,10 +636,10 @@ export function useApplicationMutation( // that this attempt did not apply; the first may have. The request // stays unknown with its intent, so the next save or resend carries // the same key, never a new one (backend http-contract.md §2). A - // refusal every attempt of the request gets (input validation, a key - // the server's rule rejects) shows the first was refused too, so the - // request is settled and the form can take a corrected save - // (isRefusedOnEveryAttempt, D10 supplement). + // refusal every attempt of the request gets (the paired backend's 400 + // VALIDATION_FAILED and IDEMPOTENCY_KEY_INVALID) shows the first was + // refused too, so the request is settled and the form can take a + // corrected save (isRefusedOnEveryAttempt, D10 supplement). const resendLeavesUnknown = (failure: AppFailure): boolean => replayed !== undefined && (!scope || scope.isCurrent()) && diff --git a/tests/component/application-mutation-admission.test.tsx b/tests/component/application-mutation-admission.test.tsx index a07c961b..944c8a9a 100644 --- a/tests/component/application-mutation-admission.test.tsx +++ b/tests/component/application-mutation-admission.test.tsx @@ -759,6 +759,26 @@ describe("application mutation intent admission", () => { effect: "NOT_APPLIED", }), ], + // Final review FR-01. The kind is the feature's mapProblem: the + // scaffold maps its declared code to a field error, and the reference + // gateway maps every 422 to one, whatever the code. + [ + "refused with a declared code the feature maps to a field error", + createFailure("VALIDATION_REJECTED", "CREATE_REPLAYED", 0, { + code: "WORKLOG_INVALID", + httpStatus: 400, + effect: "NOT_APPLIED", + validationIssues: [{ path: "name", code: "INVALID" }], + }), + ], + [ + "refused with 422 IDEMPOTENT_REQUEST_MISMATCH read as a field error", + createFailure("VALIDATION_REJECTED", "CREATE_REPLAYED", 0, { + code: "IDEMPOTENT_REQUEST_MISMATCH", + httpStatus: 422, + effect: "NOT_APPLIED", + }), + ], ])("keeps the request unknown with its key when the resend is %s", async (_label, refusal) => { const { hook, intents } = renderKeyedCreate([ unknown, diff --git a/tests/features/reference-feature/reference-page.test.tsx b/tests/features/reference-feature/reference-page.test.tsx index 71052085..783915ac 100644 --- a/tests/features/reference-feature/reference-page.test.tsx +++ b/tests/features/reference-feature/reference-page.test.tsx @@ -415,9 +415,10 @@ describe("reference feature page states", () => { /** * 1106/03-01 (D10 supplement). The form is never held for good after a * same-key resend. A refusal that may change (429) keeps the result - * unknown and the confirm and resend actions on screen. A field error the - * request gets on every attempt settles it: the field shows the error and - * the save is on again. + * unknown and the confirm and resend actions on screen. So does a 422 + * (final review FR-01): this feature's gateway reads every 422 as a field + * error whatever its code, and only the paired backend's own table codes + * settle a resent request. */ async function resendAnUnknownCreate(resendAnswer: ReferenceResult) { const user = userEvent.setup(); @@ -467,30 +468,26 @@ describe("reference feature page states", () => { expect(await screen.findByText("저장했습니다.")).toBeVisible(); }); - it("shows the field error and saves again when the resend is refused on its input", async () => { - const { user, name, createResource } = await resendAnUnknownCreate({ + it("keeps the confirm on screen when the resend is refused with a 422", async () => { + const { user, name } = await resendAnUnknownCreate({ ok: false, error: createFailure("VALIDATION_REJECTED", "CREATE_REFERENCE_RESOURCE", 0, { + code: "REFERENCE_RESOURCE_REJECTED", effect: "NOT_APPLIED", httpStatus: 422, validationIssues: [{ path: "name", code: "REQUIRED" }], }), }); - await waitFor(() => expect(name).toHaveAttribute("aria-invalid", "true")); - expect(screen.queryByText("변경 결과를 확인할 수 없습니다.")).not.toBeInTheDocument(); - expect(screen.getByRole("button", { name: "저장" })).toBeEnabled(); - await user.clear(name); - await user.type(name, "Corrected"); - await user.click(screen.getByRole("button", { name: "저장" })); + expect( + await screen.findByText(KO_MESSAGES["form.resendLater"]), + ).toBeVisible(); + expect(screen.getByText("변경 결과를 확인할 수 없습니다.")).toBeVisible(); + expect(name).not.toHaveAttribute("aria-invalid"); + expect(screen.getByRole("button", { name: "저장" })).toBeDisabled(); + await user.click(screen.getByRole("button", { name: "변경됨으로 확인" })); expect(await screen.findByText("저장했습니다.")).toBeVisible(); - const keys = createResource.mock.calls.map(([, context]) => context?.intent?.idempotencyKey); - expect(keys).toEqual([ - "reference-page-key-1", - "reference-page-key-1", - "reference-page-key-2", - ]); }); it.each([ @@ -729,7 +726,9 @@ describe("reference feature page states", () => { * 1106/08-01. The form the user came back to did not start the save * still running, and holds none of its result (review probe 08-R1). */ - async function leaveDuringSaveAndComeBack() { + async function leaveDuringSaveAndComeBack( + ...laterAnswers: readonly ReferenceResult[] + ) { const user = userEvent.setup(); let release: | ((result: ReferenceResult) => void) @@ -742,6 +741,7 @@ describe("reference feature page states", () => { release = resolve; }), ); + for (const answer of laterAnswers) createResource.mockResolvedValueOnce(answer); renderReference( inputWith({ createResource }), "/examples/reference-resources/new", @@ -761,12 +761,56 @@ describe("reference feature page states", () => { expect(await screen.findByText("변경 사항을 저장하고 있습니다.")).toBeVisible(); return { user, + createResource, release(result: ReferenceResult) { release?.(result); }, }; } + // 1106/03-01 (final review FR-01). The remounted form shows other values + // than the save it did not start; its resend sends that save, with its + // key. A 422 IDEMPOTENT_REQUEST_MISMATCH there says the key already + // reached the server, so the first request may have applied: it stays + // unknown and the confirm stays on screen. + it("keeps a resent request unknown on a remounted form when the server answers 422 IDEMPOTENT_REQUEST_MISMATCH", async () => { + const { user, createResource, release } = await leaveDuringSaveAndComeBack({ + ok: false, + error: createFailure("VALIDATION_REJECTED", "CREATE_REFERENCE_RESOURCE", 0, { + code: "IDEMPOTENT_REQUEST_MISMATCH", + effect: "NOT_APPLIED", + httpStatus: 422, + }), + }); + release({ + ok: false, + error: createFailure("SERVER_FAILURE", "CREATE_REFERENCE_RESOURCE", 0, { + effect: "MAYBE_APPLIED", + }), + }); + await screen.findByRole("button", { name: "같은 요청으로 다시 보내기" }); + await user.type( + screen.getByRole("textbox", { name: /새 항목 이름/ }), + "Second item", + ); + + await user.click( + screen.getByRole("button", { name: "같은 요청으로 다시 보내기" }), + ); + await waitFor(() => expect(createResource).toHaveBeenCalledTimes(2)); + + expect( + await screen.findByText(KO_MESSAGES["form.resendLater"]), + ).toBeVisible(); + expect(screen.getByText("변경 결과를 확인할 수 없습니다.")).toBeVisible(); + expect(screen.getByRole("button", { name: "변경됨으로 확인" })).toBeVisible(); + const [first, second] = createResource.mock.calls; + expect(second?.[0]).toEqual(first?.[0]); + expect(second?.[1]?.intent?.idempotencyKey).toBe( + first?.[1]?.intent?.idempotencyKey, + ); + }); + // 1106/08-01 (A). Confirming that save from the remounted form used to // show nothing and drop focus to the body: the form had no submitted // values to settle.