From d8352762966349345f142e67448fb0bc4efd27c0 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Tue, 1 Sep 2026 14:42:29 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EA=B0=9C=EB=85=90=20=EA=B4=80=EA=B3=84?= =?UTF-8?q?=20=EB=9D=BC=EB=B2=A8=EC=9D=84=20=EA=B3=84=EC=95=BD=EC=9D=B4=20?= =?UTF-8?q?=EC=A3=BC=EB=8A=94=20=EC=9D=B4=EB=A6=84=EC=97=90=20=EB=A7=9E?= =?UTF-8?q?=EC=B6=94=EA=B3=A0=20=ED=91=9C=EB=A5=BC=20=EA=B3=84=EC=95=BD?= =?UTF-8?q?=EC=97=90=20=EB=AC=B6=EB=8A=94=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 개념 화면에 `relatedRecords` 가 한글 라벨 없이 나왔다. 앞선 커밋에서 개념 라벨 표를 다른 유형에서 유추해 네 키(supportingCases 등)를 적었는데 계약이 주는 이름은 `relatedRecords` 하나였다 — 하나도 맞지 않았다. 같은 실수를 Reference 에서도 했다(`originCases` 라고 적혀 있었다). 세 번째라 표를 계약에 묶는다: 계약 문서에서 관계 이름을 읽어, 라벨이 없는 이름과 계약에 없는 이름을 양쪽으로 잡는다. `primaryProject` 는 관계가 아니라 소속이므로 제외한다 — 머리말이 이미 보여 준다. 개념은 관계를 한 묶음으로 받으므로 그 묶음만 명시적으로 골라 넘긴다. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_011nAjrqNHGPNngN4aUbcyvJ --- .../http/http-public-content-gateway.ts | 14 ++-- .../features/tech-log/relation-labels.test.ts | 67 +++++++++++++++++++ 2 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 tests/features/tech-log/relation-labels.test.ts diff --git a/src/features/tech-log/adapters/http/http-public-content-gateway.ts b/src/features/tech-log/adapters/http/http-public-content-gateway.ts index 74d9dae..d150fcd 100644 --- a/src/features/tech-log/adapters/http/http-public-content-gateway.ts +++ b/src/features/tech-log/adapters/http/http-public-content-gateway.ts @@ -83,11 +83,15 @@ export const REFERENCE_RELATION_LABELS = Object.freeze({ relatedReferences: "함께 보는 기준", }); +/* + 개념의 관계는 계약이 `relatedRecords` 한 묶음으로 준다 — 다른 유형처럼 여러 묶음으로 + 나뉘지 않는다. 처음에 다른 유형에서 유추해 네 키를 적었더니 하나도 맞지 않아 화면에 + `relatedRecords` 가 그대로 나왔다. 응답을 보고 적은 이름이다. + + `primaryProject` 는 관계가 아니라 이 개념이 속한 프로젝트다 — 머리말이 이미 보여 준다. +*/ export const CONCEPT_RELATION_LABELS = Object.freeze({ - supportingCases: "이 개념을 확인한 기록", - relatedReferences: "함께 보는 기준", - relatedConcepts: "이어지는 개념", - relatedDecisions: "이 개념을 쓴 결정", + relatedRecords: "이 개념과 이어지는 기록", }); export const QUESTION_RELATION_LABELS = Object.freeze({ @@ -290,7 +294,7 @@ export function createHttpPublicContentGateway( primaryTopic: body.primaryTopic as never, primaryProject: body.primaryProject as never, publishedAt: body.publishedAt as string, - relations: flattenRelations(groups, CONCEPT_RELATION_LABELS), + relations: flattenRelations({ relatedRecords: groups.relatedRecords }, CONCEPT_RELATION_LABELS), }), kind: "CONCEPT", basisVersion: (body.basisVersion as string) ?? "", diff --git a/tests/features/tech-log/relation-labels.test.ts b/tests/features/tech-log/relation-labels.test.ts new file mode 100644 index 0000000..fbfb422 --- /dev/null +++ b/tests/features/tech-log/relation-labels.test.ts @@ -0,0 +1,67 @@ +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import { test } from "vitest"; + +import { + CASE_RELATION_LABELS, + CONCEPT_RELATION_LABELS, + QUESTION_RELATION_LABELS, + REFERENCE_RELATION_LABELS, +} from "../../../src/features/tech-log/adapters/http/http-public-content-gateway.ts"; + +/** + * 관계 묶음의 이름을 사람이 읽는 말로 바꾸는 표. 라벨이 없는 키는 계약의 이름이 그대로 화면에 + * 나온다 — 실제로 Reference 에 `supportingCases` 가, 개념에 `relatedRecords` 가 한글 라벨 없이 + * 나왔다. 둘 다 표의 키를 다른 유형에서 유추해 적었기 때문이다. + * + *

그래서 계약이 실제로 주는 이름을 계약 문서에서 읽어 대조한다. + */ +const CONTRACT = readFileSync( + "src/features/tech-log/contracts/public/public-api.openapi.yaml", + "utf8", +); + +/** 관계가 아니라 소속을 알려 주는 칸. 머리말이 이미 보여 주므로 관계 목록에 넣지 않는다. */ +const NOT_A_RELATION = new Set(["primaryProject"]); + +function contractRelationKeys(schema: string): string[] { + const block = new RegExp(`\\n ${schema}DetailResponse:[\\s\\S]*?(?=\\n [A-Z]\\w+:|$)`).exec( + CONTRACT, + ); + assert.ok(block, `${schema}DetailResponse 스키마를 찾지 못했다`); + const relations = /relations:\n([\s\S]*?)(?=\n {8}[a-z]\w*:\n|$)/.exec(block[0]); + assert.ok(relations, `${schema} 에 relations 가 없다`); + return [...new Set([...relations[1].matchAll(/\n {12}(\w+):/gu)].map((m) => m[1]))] + .filter((key) => !NOT_A_RELATION.has(key)) + .sort(); +} + +const CASES = [ + { schema: "Case", labels: CASE_RELATION_LABELS }, + { schema: "Reference", labels: REFERENCE_RELATION_LABELS }, + { schema: "Question", labels: QUESTION_RELATION_LABELS }, + { schema: "Concept", labels: CONCEPT_RELATION_LABELS }, +] as const; + +test("계약이 주는 관계 이름은 모두 한글 라벨을 갖는다", () => { + for (const { schema, labels } of CASES) { + for (const key of contractRelationKeys(schema)) { + assert.ok( + key in labels, + `${schema}: '${key}' 에 라벨이 없다 — 이 이름이 그대로 화면에 나온다`, + ); + } + } +}); + +test("라벨 표에 계약에 없는 이름을 적지 않는다", () => { + for (const { schema, labels } of CASES) { + const contractKeys = new Set(contractRelationKeys(schema)); + for (const key of Object.keys(labels)) { + assert.ok( + contractKeys.has(key), + `${schema}: '${key}' 는 계약에 없다 — 다른 유형에서 유추한 이름일 수 있다`, + ); + } + } +});