Skip to content

Commit a8030ca

Browse files
authored
fix(review): repair stale gate-check publication state (#2351)
* fix(review): invalidate stale ai review cache inputs * fix(review): fingerprint the actual REES endpoint, not just its presence The AI-review cache fingerprint only recorded Boolean(REES_URL), so changing the configured analyzer endpoint from one URL to another kept the same cache key -- a same-head PR could reuse AI-review output produced against a different analyzer service. Fingerprint the URL value itself (still one-way-hashed by aiReviewInputFingerprint, so it never appears in the output), matching the pattern already used for the other REES_* fields. * fix(review): restrict backlogged sweeps to priority repairs only While an active per-PR regate backlog defers ordinary stale maintenance (the point of the earlier check), a repo with even one priority repair (a PR missing its current Gate check) escaped that deferral entirely and picked up a full SWEEP_MAX_PRS batch -- letting unrelated ordinary stale PRs ride along whenever any priority repair existed, contradicting the "normal maintenance yields behind repairs" intent. Cap the candidate limit to exactly the priority count when a backlog is active; a repo with no backlog still gets a normal, full-size sweep. Also documents (not fixes -- verified as a false positive) why `decision.willLabel` in the incomplete-surface audit path is safe even though `decision` can still be the un-reassigned `prelim` value there: `willLabel` is a non-optional boolean on every PublicSurfaceDecision variant, and the path is only reachable when "label" was never in prelim.actions to begin with. * test(review): mark the ai-review cache metadata fallback as provably unreachable runAiReviewForAdvisory is the sole assignment site reaching the cache-write branch, and every one of its "ok" returns sets metadata explicitly, so the nullish fallback is a type-level safeguard only.
1 parent ef8ae7c commit a8030ca

8 files changed

Lines changed: 1711 additions & 175 deletions

File tree

src/db/repositories.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3334,6 +3334,7 @@ export async function getCachedAiReview(
33343334
pullNumber: number,
33353335
headSha: string | null | undefined,
33363336
mode: string,
3337+
expectedInputFingerprint?: string | undefined,
33373338
): Promise<{ notes: string; reviewerCount: number; findings: AdvisoryFinding[]; metadata?: Record<string, unknown> | undefined } | null> {
33383339
if (!headSha) return null;
33393340
const row = await env.DB
@@ -3342,6 +3343,11 @@ export async function getCachedAiReview(
33423343
.first<{ notes: string; reviewerCount: number; mode: string; findingsJson: string | null; metadataJson: string | null }>();
33433344
if (!row || row.mode !== mode) return null;
33443345
const metadata = parseJson<Record<string, unknown>>(row.metadataJson, {});
3346+
if (
3347+
expectedInputFingerprint !== undefined &&
3348+
metadata.inputFingerprint !== expectedInputFingerprint
3349+
)
3350+
return null;
33453351
return {
33463352
notes: row.notes,
33473353
reviewerCount: row.reviewerCount,

src/env.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ declare global {
210210
REES_SHARED_SECRET?: string;
211211
REES_TIMEOUT_MS?: string;
212212
REES_ANALYZERS?: string;
213+
REES_PROFILE?: string;
213214
REES_FORWARD_GITHUB_TOKEN?: string;
214215
/** Convergence flag: the deterministic content/registry SURFACE LANE drives the gate for registry-submission
215216
* PRs (metagraphed surfaces[]/providers/candidates). Truthy ON *AND* the repo in GITTENSORY_REVIEW_REPOS —

0 commit comments

Comments
 (0)