refactor(managed): share one-item limitation lists (#17398)

This commit is contained in:
Vincent Koc
2026-12-06 13:28:45 +08:00
committed by GitHub
parent 334c46c9c7
commit a6987c820d
@@ -38,6 +38,12 @@ const limitation = (
): Limitation =>
side === undefined ? { code, message } : { code, side, message };
const oneLimitation = (
code: Limitation["code"],
message: string,
side?: "left" | "right",
): Limitation[] => [limitation(code, message, side)];
interface ComparisonItemContext {
readonly leftEvidenceId: string;
readonly rightEvidenceId: string;
@@ -454,75 +460,59 @@ const absenceLimitations = (
},
): Limitation[] => [
...(opposite.ownNameUnavailable
? [
limitation(
"unknown-within-incomplete-metadata",
`The recorded ${opposite.inventory === "method" ? "MethodDef" : "Field"} name is empty, so its nominal identity is unavailable.`,
),
]
? oneLimitation(
"unknown-within-incomplete-metadata",
`The recorded ${opposite.inventory === "method" ? "MethodDef" : "Field"} name is empty, so its nominal identity is unavailable.`,
)
: opposite.ownIdentityUnavailable
? [
limitation(
"declaring-type-name-not-resolved",
"Declared type identity could not be resolved; a bare display name cannot establish a counterpart or absence.",
),
]
? oneLimitation(
"declaring-type-name-not-resolved",
"Declared type identity could not be resolved; a bare display name cannot establish a counterpart or absence.",
)
: []),
...(!opposite.ownNameUnavailable &&
opposite.unpaired.unknownOwners.has(member.name)
? [
limitation(
"counterpart-declaring-type-name-not-resolved",
`The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired same-named member with unresolved enclosing-name identity, so absence was not established.`,
opposite.opposite,
),
]
? oneLimitation(
"counterpart-declaring-type-name-not-resolved",
`The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired same-named member with unresolved enclosing-name identity, so absence was not established.`,
opposite.opposite,
)
: []),
...(opposite.oppositeComplete
? []
: [
limitation(
"unknown-within-incomplete-metadata",
`The ${opposite.opposite} ${opposite.inventory} inventory is incomplete, so absence was not observed.`,
opposite.opposite,
),
]),
: oneLimitation(
"unknown-within-incomplete-metadata",
`The ${opposite.opposite} ${opposite.inventory} inventory is incomplete, so absence was not observed.`,
opposite.opposite,
)),
...(member.signature.parse_status === "decoded"
? []
: [
limitation(
"signature-not-decoded",
`The member's ${member.signature.parse_status} signature was compared only by exact declared type, name, and signature bytes, so a changed or renamed counterpart could not be sought.`,
),
]),
: oneLimitation(
"signature-not-decoded",
`The member's ${member.signature.parse_status} signature was compared only by exact declared type, name, and signature bytes, so a changed or renamed counterpart could not be sought.`,
)),
...(member.signature.parse_status === "decoded" &&
opposite.unpaired.undecoded.has(identity)
? [
limitation(
"counterpart-signature-not-decoded",
`The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired member with the same declared type and name whose signature was not decoded, so it may be this member with a changed signature.`,
opposite.opposite,
),
]
? oneLimitation(
"counterpart-signature-not-decoded",
`The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired member with the same declared type and name whose signature was not decoded, so it may be this member with a changed signature.`,
opposite.opposite,
)
: []),
...(unresolved(member)
? [
limitation(
"signature-not-resolved",
`The member's signature names a type REA could not name, so it was compared by raw bytes, which name types by build-local metadata row; a counterpart whose referenced type moved rows could not be found.`,
),
]
? oneLimitation(
"signature-not-resolved",
`The member's signature names a type REA could not name, so it was compared by raw bytes, which name types by build-local metadata row; a counterpart whose referenced type moved rows could not be found.`,
)
: []),
...(member.signature.parse_status === "decoded" &&
!unresolved(member) &&
opposite.unpaired.unresolved.has(identity)
? [
limitation(
"counterpart-signature-not-resolved",
`The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired member with the same declared type and name whose signature names a type REA could not name, so it may be this member.`,
opposite.opposite,
),
]
? oneLimitation(
"counterpart-signature-not-resolved",
`The ${opposite.opposite} ${opposite.inventory} inventory has an unpaired member with the same declared type and name whose signature names a type REA could not name, so it may be this member.`,
opposite.opposite,
)
: []),
];
@@ -540,19 +530,15 @@ const pairedSignatureLimitations = (
left.signature.parse_status === "malformed" ||
right.signature.parse_status === "malformed"
)
return [
limitation(
"signature-malformed",
"At least one signature is malformed; equal signature bytes do not establish an unchanged member signature.",
),
];
return oneLimitation(
"signature-malformed",
"At least one signature is malformed; equal signature bytes do not establish an unchanged member signature.",
);
return unresolved(left) || unresolved(right)
? [
limitation(
"signature-not-resolved",
"At least one signature names a type REA could not resolve; equal build-local row bytes do not establish equivalent signature types.",
),
]
? oneLimitation(
"signature-not-resolved",
"At least one signature names a type REA could not resolve; equal build-local row bytes do not establish equivalent signature types.",
)
: [];
};