From 17de0fd7d1beb3ab7a830e4d9f523d53d0f5899c Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Mon, 13 Jul 2026 21:44:18 -0700 Subject: [PATCH] fix(queue): migrate data-fidelity repair from isRegistered to isInstalled repairDataFidelity filtered repositories.filter(isRegistered) to decide which repos' cached labels/issues/PRs get freshness-checked and repaired. This is cache hygiene for any repo gittensory reviews, unrelated to subnet economics -- and it drives dispatch of the backfill-registered-repos job family #5021 already retargeted to isInstalled, so both should agree on the same scoping signal. Closes #5020 --- src/queue/processors.ts | 5 ++++- test/unit/queue.test.ts | 43 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/src/queue/processors.ts b/src/queue/processors.ts index 780540134c..92c1617478 100644 --- a/src/queue/processors.ts +++ b/src/queue/processors.ts @@ -4364,7 +4364,10 @@ export async function repairDataFidelity( segmentsByRepo.set(segment.repoFullName, complete); } } - const registeredRepos = repositories.filter((repo) => repo.isRegistered); + // #5020: cache hygiene for cached labels/issues/PRs has nothing to do with subnet economics -- scope to + // repos this instance actually operates on (isInstalled), matching #5021's retarget of the underlying + // backfill job this function dispatches. + const registeredRepos = repositories.filter((repo) => repo.isInstalled); const freshnessSlo = buildFreshnessSloReport({ repoCount: registeredRepos.length, segments, diff --git a/test/unit/queue.test.ts b/test/unit/queue.test.ts index e8e9ac5ed8..fd1c75594c 100644 --- a/test/unit/queue.test.ts +++ b/test/unit/queue.test.ts @@ -752,9 +752,12 @@ describe("queue processors", () => { "we-promise/sure": { emission_share: 0.02, issue_discovery_share: 0, label_multipliers: {}, trusted_label_pipeline: false }, }, { kind: "raw-github", url: "fixture://registry" }, - "2026-05-25T00:00:00.000Z", + "2026-05-23T00:00:00.000Z", ), ); + // repairDataFidelity now gates on isInstalled, not isRegistered (#5020). + await upsertRepositoryFromGitHub(env, { name: "gittensory", full_name: "JSONbored/gittensory", private: true, owner: { login: "JSONbored" } }, 9410); + await upsertRepositoryFromGitHub(env, { name: "sure", full_name: "we-promise/sure", private: true, owner: { login: "we-promise" } }, 9411); await upsertRepoSyncSegment(env, completeSegment("JSONbored/gittensory", "labels")); await upsertRepoSyncSegment(env, completeSegment("JSONbored/gittensory", "open_issues")); @@ -770,6 +773,35 @@ describe("queue processors", () => { ); }); + it("dispatches fidelity repair by isInstalled, not isRegistered (#5020 regression)", async () => { + const sent: import("../../src/types").JobMessage[] = []; + const env = createTestEnv({ + JOBS: { + async send(message: import("../../src/types").JobMessage) { + sent.push(message); + }, + } as unknown as Queue, + }); + // Installed but not gittensor-subnet-registered: cache hygiene for cached labels/issues/PRs has + // nothing to do with subnet economics, so this repo MUST still be covered. + await upsertRepositoryFromGitHub(env, { name: "installed-not-registered", full_name: "acme/installed-not-registered", private: false, owner: { login: "acme" } }, 9415); + // Subnet-registered but not installed on this instance: this repo must NOT be covered. + await persistRegistrySnapshot( + env, + normalizeRegistryPayload( + { "acme/registered-not-installed": { emission_share: 0.01, issue_discovery_share: 0, label_multipliers: {}, trusted_label_pipeline: false } }, + { kind: "raw-github", url: "fixture://registry" }, + "2026-05-23T00:00:00.000Z", + ), + ); + + await processJob(env, { type: "repair-data-fidelity", requestedBy: "api" }); + + const repairedRepos = sent.map((message) => (message as { repoFullName?: string }).repoFullName); + expect(repairedRepos).toContain("acme/installed-not-registered"); + expect(repairedRepos).not.toContain("acme/registered-not-installed"); + }); + it("marks fidelity repair completed when only signal refreshes are needed", async () => { vi.useFakeTimers(); vi.setSystemTime(new Date("2026-05-25T01:00:00.000Z")); @@ -790,9 +822,12 @@ describe("queue processors", () => { "we-promise/sure": { emission_share: 0.02, issue_discovery_share: 0, label_multipliers: {}, trusted_label_pipeline: false }, }, { kind: "raw-github", url: "fixture://registry" }, - "2026-05-25T00:00:00.000Z", + "2026-05-23T00:00:00.000Z", ), ); + // repairDataFidelity now gates on isInstalled, not isRegistered (#5020). + await upsertRepositoryFromGitHub(env, { name: "gittensory", full_name: "JSONbored/gittensory", private: true, owner: { login: "JSONbored" } }, 9412); + await upsertRepositoryFromGitHub(env, { name: "sure", full_name: "we-promise/sure", private: true, owner: { login: "we-promise" } }, 9413); for (const repoFullName of ["JSONbored/gittensory", "we-promise/sure"]) { await upsertRepoSyncSegment(env, completeSegment(repoFullName, "labels")); await upsertRepoSyncSegment(env, completeSegment(repoFullName, "open_issues")); @@ -838,9 +873,11 @@ describe("queue processors", () => { normalizeRegistryPayload( { "JSONbored/gittensory": { emission_share: 0.01, issue_discovery_share: 0, label_multipliers: {}, trusted_label_pipeline: false } }, { kind: "raw-github", url: "fixture://registry" }, - "2026-05-25T00:00:00.000Z", + "2026-05-23T00:00:00.000Z", ), ); + // repairDataFidelity now gates on isInstalled, not isRegistered (#5020). + await upsertRepositoryFromGitHub(env, { name: "gittensory", full_name: "JSONbored/gittensory", private: true, owner: { login: "JSONbored" } }, 9414); await upsertRepoSyncSegment(env, completeSegment("JSONbored/gittensory", "labels")); await upsertRepoSyncSegment(env, completeSegment("JSONbored/gittensory", "open_issues")); await upsertRepoSyncSegment(env, completeSegment("JSONbored/gittensory", "open_pull_requests"));