Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Tighten upgrade impact duplicate checks

Tre Dubrava939ea11de181
diff --git a/upgrade-impact/data/releases/v0.159.16.yaml b/upgrade-impact/data/releases/v0.159.16.yaml
index 6dc5b6d2c2..168cbb0499 100644
--- a/upgrade-impact/data/releases/v0.159.16.yaml
+++ b/upgrade-impact/data/releases/v0.159.16.yaml
@@ -15,9 +15,6 @@ dbSchemaChanges:
alter the `Webhook` table.
confidence: high
evidence:
- - type: file
- ref: backend/src/db/migrations/20260409120000_add-webhook-event-toggles.ts
- path: backend/src/db/migrations/20260409120000_add-webhook-event-toggles.ts
- type: file
ref: backend/src/db/migrations/20260409120000_add-webhook-event-toggles.ts
path: backend/src/db/migrations/20260409120000_add-webhook-event-toggles.ts
diff --git a/upgrade-impact/src/generate-ai.ts b/upgrade-impact/src/generate-ai.ts
index 4e431ee8ad..32fea6d506 100644
--- a/upgrade-impact/src/generate-ai.ts
+++ b/upgrade-impact/src/generate-ai.ts
@@ -5,7 +5,7 @@ import { z } from "zod";
import { ReleaseEvidenceBundle } from "./evidence.js";
import { runGit } from "./git.js";
-import { ImpactEntry, ImpactEntrySchema } from "./schema.js";
+import { Evidence, ImpactEntry, ImpactEntrySchema } from "./schema.js";
export const MODEL = "gpt-5.4";
@@ -27,7 +27,8 @@ const agenticLimits = {
maxDiffCharsPerFile: 20000,
maxFileChars: 20000,
maxTotalToolResultChars: 220000,
- maxCompletionTokens: 5000
+ maxCompletionTokens: 5000,
+ maxTurns: 20
};
const evidenceForFile = (file: string, description?: string) => ({
@@ -115,6 +116,9 @@ Write for a busy self-hosted operator deciding whether and how to upgrade:
- Do not say "the release", "this release", "code changes indicate", "evidence bundle", "identified", or "detected".
- Do not mention that no Docker, Helm, Kubernetes, or database changes exist unless that absence changes the upgrade action.
- Do not duplicate the same risk across breakingChanges, configChanges, deploymentNotes, and knownIssues. Pick one category.
+- Do not include the same evidence item twice in one entry.
+- Do not repeat a release note or PR URL across multiple entries when a more specific file diff can support the claim.
+- Before finalizing, audit the JSON for duplicate titles, duplicate descriptions, and duplicate evidence.
- Use breakingChanges for changes that can make existing auth, API, startup, database, or integrations fail after upgrade.
- Use deploymentNotes only when deployment files, self-hosting docs, Docker, Helm, Kubernetes manifests, startup/runtime, or rollout behavior changed.
- Use configChanges only for environment variables, config files, defaults, or settings that operators must update.
@@ -167,13 +171,40 @@ Evidence rules:
`;
const normalizeDraft = (draft: GeneratedDraft): GeneratedDraft => {
+ const evidenceKey = (evidence: Evidence) =>
+ [evidence.type, evidence.ref, evidence.path ?? "", evidence.url ?? ""].join("\u0000");
+
+ const dedupeEvidence = (evidenceItems: Evidence[]) => {
+ const seen = new Set<string>();
+
+ return evidenceItems.filter((evidence) => {
+ const key = evidenceKey(evidence);
+ if (seen.has(key)) {
+ return false;
+ }
+
+ seen.add(key);
+ return true;
+ });
+ };
+
+ const entryKey = (entry: ImpactEntry) =>
+ [entry.title.trim().toLowerCase(), entry.description.trim().toLowerCase()].join("\u0000");
+
const normalizeEntries = (entries: ImpactEntry[]) =>
- entries.map((entry) => ({
- ...entry,
- evidence: entry.evidence.map((evidence) =>
- evidence.type === "file" && evidence.path ? { ...evidence, ref: evidence.path } : evidence
- )
- }));
+ entries
+ .map((entry) => ({
+ ...entry,
+ evidence: dedupeEvidence(
+ entry.evidence.map((evidence) =>
+ evidence.type === "file" && evidence.path ? { ...evidence, ref: evidence.path } : evidence
+ )
+ )
+ }))
+ .filter((entry, index, normalizedEntries) => {
+ const key = entryKey(entry);
+ return normalizedEntries.findIndex((candidate) => entryKey(candidate) === key) === index;
+ });
return {
...draft,
@@ -469,7 +500,7 @@ export const generateWithOpenAiAgentic = async (bundle: ReleaseEvidenceBundle):
});
const result = await run(agent, "Generate the self-hosted upgrade impact JSON for this release.", {
- maxTurns: 20
+ maxTurns: agenticLimits.maxTurns
});
if (!result.finalOutput) {
diff --git a/upgrade-impact/src/validate.test.ts b/upgrade-impact/src/validate.test.ts
index a4032965aa..0ae3935635 100644
--- a/upgrade-impact/src/validate.test.ts
+++ b/upgrade-impact/src/validate.test.ts
@@ -161,6 +161,77 @@ const validationCases: ValidationCase[] = [
}
],
expectedErrors: [`${validRelease.version}.yaml contains invalid YAML`]
+ },
+ {
+ name: "rejects duplicate evidence within an impact entry",
+ index: makeIndex([
+ {
+ version: validRelease.version,
+ releasedAt: validRelease.releasedAt,
+ file: `releases/${validRelease.version}.yaml`
+ }
+ ]),
+ releases: [
+ {
+ fileName: `${validRelease.version}.yaml`,
+ release: makeRelease({
+ dbSchemaChanges: [
+ {
+ title: "Database schema migrations are included",
+ description: "This release includes a database migration.",
+ action: "Back up the database before upgrading.",
+ confidence: "high",
+ evidence: [
+ {
+ type: "file",
+ ref: "backend/src/db/migrations/20260429000000_example.ts",
+ path: "backend/src/db/migrations/20260429000000_example.ts"
+ },
+ {
+ type: "file",
+ ref: "backend/src/db/migrations/20260429000000_example.ts",
+ path: "backend/src/db/migrations/20260429000000_example.ts"
+ }
+ ]
+ }
+ ]
+ })
+ }
+ ],
+ expectedErrors: [`${validRelease.version}.yaml repeats evidence file:backend/src/db/migrations/20260429000000_example.ts`]
+ },
+ {
+ name: "rejects duplicate impact entry titles",
+ index: makeIndex([
+ {
+ version: validRelease.version,
+ releasedAt: validRelease.releasedAt,
+ file: `releases/${validRelease.version}.yaml`
+ }
+ ]),
+ releases: [
+ {
+ fileName: `${validRelease.version}.yaml`,
+ release: makeRelease({
+ breakingChanges: [
+ {
+ title: "Database schema migrations are included",
+ description: "The same impact is reported in another section.",
+ action: "Keep only one entry for this impact.",
+ confidence: "medium",
+ evidence: [
+ {
+ type: "file",
+ ref: "backend/src/db/migrations/20260429000000_example.ts",
+ path: "backend/src/db/migrations/20260429000000_example.ts"
+ }
+ ]
+ }
+ ]
+ })
+ }
+ ],
+ expectedErrors: [`${validRelease.version}.yaml repeats impact entry title "Database schema migrations are included"`]
}
];
diff --git a/upgrade-impact/src/validate.ts b/upgrade-impact/src/validate.ts
index 110684d5ee..792c9348f1 100644
--- a/upgrade-impact/src/validate.ts
+++ b/upgrade-impact/src/validate.ts
@@ -65,6 +65,47 @@ const validateReleaseAgainstGit = (release: ReleaseImpact, file: string, errors:
}
};
+const evidenceKey = (evidence: ReleaseImpact["breakingChanges"][number]["evidence"][number]) =>
+ [evidence.type, evidence.ref, evidence.path ?? "", evidence.url ?? ""].join("\u0000");
+
+const normalizeEntryKey = (value: string) => value.trim().toLowerCase().replace(/\s+/g, " ");
+
+const validateDuplicateContent = (release: ReleaseImpact, file: string, errors: string[]) => {
+ const seenEntryTitles = new Map<string, string>();
+ const sections = [
+ ["breakingChanges", release.breakingChanges],
+ ["dbSchemaChanges", release.dbSchemaChanges],
+ ["configChanges", release.configChanges],
+ ["deploymentNotes", release.deploymentNotes],
+ ["knownIssues", release.knownIssues]
+ ] as const;
+
+ for (const [section, entries] of sections) {
+ for (const [entryIndex, entry] of entries.entries()) {
+ const titleKey = normalizeEntryKey(entry.title);
+ const entryRef = `${section}[${entryIndex}] ${entry.title}`;
+ const previousEntryRef = seenEntryTitles.get(titleKey);
+
+ if (previousEntryRef) {
+ errors.push(`${file} repeats impact entry title "${entry.title}" in ${previousEntryRef} and ${entryRef}`);
+ } else {
+ seenEntryTitles.set(titleKey, entryRef);
+ }
+
+ const seenEvidence = new Set<string>();
+ for (const evidence of entry.evidence) {
+ const key = evidenceKey(evidence);
+
+ if (seenEvidence.has(key)) {
+ errors.push(`${file} repeats evidence ${evidence.type}:${evidence.ref} in ${entryRef}`);
+ }
+
+ seenEvidence.add(key);
+ }
+ }
+ }
+};
+
const validateReleaseFile = async (
releasesDir: string,
file: string,
@@ -115,6 +156,7 @@ const validateReleaseFile = async (
errors.push(`${file} has impactLevel none but contains impact entries`);
}
+ validateDuplicateContent(release, file, errors);
validateReleaseAgainstGit(release, file, errors, skipGitChecks);
return release;