fix(registries): 계약 조립 실패의 reason을 적고 읽지 못한 레지스트리를 지운 것으로 세지 않는다
문제
기능 계약 조립이 실패하면(예: 없는 authProfileId) check:registries 출력은
"missing registry source src/features/loaded-feature-runtimes.ts: Installed
contract contribution is not composable" 두 줄, "FE-REG-API is not an
object registry", "FE-REG-ROUTE references unknown registry FE-REG-SCHEMA",
"breaking change missing evidence: FE-REG-API:*:*:removed" 등이다. 원인은
ContractContributionError.reason에 있는데 검사기는 message 첫 줄만 적는다.
끝의 removed 줄은 "breaking 증거를 더하라"로 읽혀 틀린 다음 행동을
제안한다(실험 E-9).
고른 방법
- source를 읽다 난 오류에 문자열 reason이 있으면 "(reason: ...)"로 함께
적는다.
- 읽지 못한 레지스트리는 따로 모은다. 그 레지스트리에 대해서는 행 검사
("is not an object registry"), 그것을 가리키는 참조 검사, 기준선 비교
(removed 증거 요구)를 하지 않는다. 같은 실패를 다른 이름으로 다시 적지
않기 위해서다. 게이트는 load 실패 한 줄로 그대로 실패한다.
- errors.md 레지스트리 표에 이 메시지 행을 더했다.
버린 대안
- 메시지 접두어를 "failed to load"로 바꾸기: 의미는 더 맞지만 기존 테스트와
CI 진단 기대값이 "missing registry source"를 쓴다. 이번에는 바꾸지 않았다.
위험·한계
- source 파일을 실수로 지운 경우에도 removed 증거 요구를 건너뛴다. 그래도
"missing registry source" 실패로 게이트는 막힌다. 레지스트리를 의도해서
지우면 governance에서도 빠지므로 removed 증거 요구는 그대로다.
- FE-REG-API와 FE-REG-SCHEMA가 같은 source라 load 실패 줄은 두 번 나온다.
검증
- RED: registry-governance에 임시 디렉터리 fixture(두 레지스트리, 하나가
다른 하나를 참조, 기준선 있음)를 더했다. source가 reason 있는 오류를
던지면 출력이 load 실패 한 줄이어야 한다. 고치기 전에는 reason이 없고
cascade 3줄이 더 나와 실패했다.
- GREEN: registry-governance 11건 통과. E-9 재실행(참조 기능 목록
operation의 authProfileId를 NOTICE_NOPE로): 출력이 "... (reason:
reference-feature/LIST_REFERENCE_RESOURCES: unknown authProfileId
NOTICE_NOPE)" 두 줄뿐이고 removed 줄이 없다.
- check:registries:fixture·check:routes:fixture·baseline-fixture가 기대
진단으로 실패한다. eslint, check:types:node, check:types:test 통과.
Refs: docs/reviews/2026-11-03-maturity-review/14-template-product-docs.md 14-06
This commit is contained in:
@@ -116,6 +116,13 @@ const owners = new Map<string, string>();
|
||||
const snapshots: RegistrySnapshot[] = [];
|
||||
const rowsByRegistry = new Map<string, RegistryRows>();
|
||||
const sourcesByRegistry = new Map<string, string>();
|
||||
/**
|
||||
* 1103/14-06. Registries whose source did not load. Their failure is already
|
||||
* reported with its cause, so the checks that read their rows (references,
|
||||
* the baseline comparison) skip them instead of reporting the same failure
|
||||
* again as a deleted registry.
|
||||
*/
|
||||
const unloadedRegistries = new Set<string>();
|
||||
const registryExtensions = [".ts", ".tsx", ".mts", ".cts"];
|
||||
|
||||
async function resolveRegistrySource(
|
||||
@@ -144,6 +151,33 @@ async function resolveRegistrySource(
|
||||
return candidates[0] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 1103/14-06. A contract composition failure (`ContractContributionError`)
|
||||
* says only "not composable"; its cause is the `reason` property.
|
||||
*/
|
||||
function loadErrorText(error: Error): string {
|
||||
const message = error.message.split("\n")[0] ?? "";
|
||||
const reason: unknown = (error as Error & { reason?: unknown }).reason;
|
||||
return typeof reason === "string" && reason.length > 0
|
||||
? `${message} (reason: ${reason})`
|
||||
: message;
|
||||
}
|
||||
|
||||
function withoutRegistries(
|
||||
snapshot: Readonly<Record<string, unknown>>,
|
||||
registryIds: ReadonlySet<string>,
|
||||
): Readonly<Record<string, unknown>> {
|
||||
if (registryIds.size === 0 || !Array.isArray(snapshot.registries)) {
|
||||
return snapshot;
|
||||
}
|
||||
return {
|
||||
...snapshot,
|
||||
registries: (snapshot.registries as Array<{ registryId?: unknown }>).filter(
|
||||
(registry) => !registryIds.has(String(registry.registryId)),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
type FieldLookup = Readonly<{
|
||||
found: boolean;
|
||||
value: unknown;
|
||||
@@ -371,8 +405,12 @@ for (const specification of governance.registries) {
|
||||
} catch (error) {
|
||||
// A source that exists but fails to load names its error, so a broken
|
||||
// import in a feature contract is not reported as a missing file.
|
||||
const reason = sourcePath && error instanceof Error ? `: ${error.message.split("\n")[0]}` : "";
|
||||
if (!rows) failures.push(`missing registry source ${specification.path}${reason}`);
|
||||
const reason = sourcePath && error instanceof Error ? `: ${loadErrorText(error)}` : "";
|
||||
if (!rows) {
|
||||
failures.push(`missing registry source ${specification.path}${reason}`);
|
||||
unloadedRegistries.add(specification.registryId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
const registryRows = projectRegistryRows(specification, rows);
|
||||
@@ -534,6 +572,7 @@ for (const specification of governance.registries) {
|
||||
for (const reference of specification.references ?? []) {
|
||||
const targetRows = rowsByRegistry.get(reference.registryId);
|
||||
if (!targetRows) {
|
||||
if (unloadedRegistries.has(reference.registryId)) continue;
|
||||
failures.push(
|
||||
`${specification.registryId} references unknown registry ${reference.registryId}`,
|
||||
);
|
||||
@@ -672,7 +711,10 @@ if (baselinePath && approvalPath && evidencePath) {
|
||||
`registry baseline approval digest mismatch: approved=${approvalResult.approvedDigest} actual=${approvalResult.actualDigest}`,
|
||||
);
|
||||
}
|
||||
const registryDiff = diffRegistrySnapshots(baseline, currentSnapshot);
|
||||
const registryDiff = diffRegistrySnapshots(
|
||||
withoutRegistries(baseline, unloadedRegistries),
|
||||
currentSnapshot,
|
||||
);
|
||||
compatibility = registryDiff;
|
||||
const evidence = JSON.parse(
|
||||
await readFile(evidencePath, "utf8"),
|
||||
|
||||
Reference in New Issue
Block a user