fix(reference)!: preserve exclusion rule provenance

Record the exact matching pattern and distinguish project, default, caller, and configured-sensitive exclusions without changing ignore ordering. Include that provenance in graph commitments and validate the contract through compiled CLI and MCP consumers.

BREAKING CHANGE: Pattern-based reference graph exclusions require pattern and distinguish project-ignored and default-ignored reasons. Re-import saved graphs that omit matching patterns.
This commit is contained in:
morluto
2026-10-11 04:15:26 +08:00
parent be44b5098e
commit 6585293c56
9 changed files with 318 additions and 32 deletions
+20 -10
View File
@@ -127,15 +127,22 @@ const parseFailureSchema = z.strictObject({
reason: boundedTextSchema,
});
const exclusionSchema = z.strictObject({
path: relativePathSchema,
reason: z.enum([
"configured-secret",
"symlink-escape",
"unreadable",
"caller-excluded",
]),
});
const exclusionSchema = z.discriminatedUnion("reason", [
z.strictObject({
path: relativePathSchema,
reason: z.enum([
"configured-secret",
"project-ignored",
"default-ignored",
"caller-excluded",
]),
pattern: boundedTextSchema,
}),
z.strictObject({
path: relativePathSchema,
reason: z.enum(["symlink-escape", "unreadable"]),
}),
]);
const vcsSchema = z
.discriminatedUnion("kind", [
@@ -405,7 +412,10 @@ function checkGraphInvariants(
context,
);
checkSortedUnique(
graph.exclusions.map(({ path, reason }) => `${path}\u0000${reason}`),
graph.exclusions.map(
(exclusion) =>
`${exclusion.path}\u0000${exclusion.reason}\u0000${"pattern" in exclusion ? exclusion.pattern : ""}`,
),
"exclusions",
context,
);