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:
@@ -175,7 +175,11 @@ describe("historical source graph", () => {
|
||||
},
|
||||
(input: HistoricalSourceGraphInput) => {
|
||||
input.exclusions = [
|
||||
{ path: "private.env", reason: "configured-secret" },
|
||||
{
|
||||
path: "private.env",
|
||||
reason: "configured-secret",
|
||||
pattern: ".env",
|
||||
},
|
||||
];
|
||||
input.inventory_state = "partial";
|
||||
},
|
||||
@@ -188,6 +192,20 @@ describe("historical source graph", () => {
|
||||
}
|
||||
});
|
||||
|
||||
it("commits the matched pattern for each exclusion", () => {
|
||||
const graphWith = (pattern: string) =>
|
||||
createHistoricalSourceGraph({
|
||||
...graphInput(),
|
||||
inventory_state: "partial",
|
||||
exclusions: [
|
||||
{ path: "private.env", reason: "configured-secret", pattern },
|
||||
],
|
||||
});
|
||||
expect(graphWith(".env").root_sha256).not.toBe(
|
||||
graphWith("*.env").root_sha256,
|
||||
);
|
||||
});
|
||||
|
||||
it("retains actual external targets and rejects placeholder targets", () => {
|
||||
const input = { ...graphInput(), inventory_state: "partial" as const };
|
||||
input.entries[2] = symlinkEntry({
|
||||
@@ -300,7 +318,13 @@ describe("partial historical source graphs", () => {
|
||||
{ entries: partial.entries },
|
||||
{ parse_failures: partial.parse_failures },
|
||||
{
|
||||
exclusions: [{ path: "secret", reason: "configured-secret" as const }],
|
||||
exclusions: [
|
||||
{
|
||||
path: "secret",
|
||||
reason: "configured-secret" as const,
|
||||
pattern: "secret",
|
||||
},
|
||||
],
|
||||
},
|
||||
{ limitations: ["Incomplete"] },
|
||||
{
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user