From cefcb24d355c3211d03beae248f8562faf54c58c Mon Sep 17 00:00:00 2001 From: JSONbored <49853598+JSONbored@users.noreply.github.com> Date: Fri, 3 Jul 2026 23:19:05 -0700 Subject: [PATCH] refactor(selfhost): consolidate triplicated self-repo-default resolver GITTENSORY_DRIFT_ISSUE_REPO's "JSONbored/gittensory" default and the resolver that reads it were independently reimplemented three times: config/gittensory-repo-focus-manifest.ts (the canonical, most complete version), services/self-dogfood-registration-pack.ts (functionally identical), and upstream/ruleset.ts (a plain `||` fallback with no non-empty/slash validation). Routes self-dogfood-registration-pack.ts and ruleset.ts through the shared resolveGittensorySelfRepoFullName; the two prior public export names (DEFAULT_SELF_DOGFOOD_REPO, resolveSelfDogfoodRepoFullName) are kept as re-exports so existing callers/tests are untouched. ruleset.ts's own validation gap is now fixed as a side effect: a malformed GITTENSORY_DRIFT_ISSUE_REPO value (e.g. missing a "/") now correctly falls back to the safe default instead of being used as-is, matching the other two implementations. Verified empirically against the existing "bad-repo-name" test case rather than assumed safe -- it still passes. --- src/services/self-dogfood-registration-pack.ts | 12 ++++++------ src/upstream/ruleset.ts | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/services/self-dogfood-registration-pack.ts b/src/services/self-dogfood-registration-pack.ts index 42bb8901bd..58124be07d 100644 --- a/src/services/self-dogfood-registration-pack.ts +++ b/src/services/self-dogfood-registration-pack.ts @@ -1,3 +1,4 @@ +import { GITTENSOR_SELF_REPO_DEFAULT, resolveGittensorySelfRepoFullName } from "../config/gittensory-repo-focus-manifest"; import { buildGittensorConfigRecommendation, buildRegistrationReadiness, @@ -8,7 +9,10 @@ import { } from "../signals/registration-readiness"; import { nowIso } from "../utils/json"; -export const DEFAULT_SELF_DOGFOOD_REPO = "JSONbored/gittensory"; +// Re-exported for backward compatibility with existing callers/tests (#2911); the actual default value and +// resolver logic live in config/gittensory-repo-focus-manifest.ts, the single source of truth shared with +// upstream/ruleset.ts. +export const DEFAULT_SELF_DOGFOOD_REPO = GITTENSOR_SELF_REPO_DEFAULT; export type SelfDogfoodActionArea = { area: string; @@ -32,11 +36,7 @@ export type SelfDogfoodRegistrationPack = { rerunHint: string; }; -export function resolveSelfDogfoodRepoFullName(env: { GITTENSORY_DRIFT_ISSUE_REPO?: string }): string { - const configured = env.GITTENSORY_DRIFT_ISSUE_REPO?.trim(); - if (!configured || !configured.includes("/")) return DEFAULT_SELF_DOGFOOD_REPO; - return configured; -} +export const resolveSelfDogfoodRepoFullName = resolveGittensorySelfRepoFullName; export function buildSelfDogfoodRegistrationPack(args: { repoFullName: string; diff --git a/src/upstream/ruleset.ts b/src/upstream/ruleset.ts index 18f01a25e8..3f7963f378 100644 --- a/src/upstream/ruleset.ts +++ b/src/upstream/ruleset.ts @@ -10,6 +10,7 @@ import { updateUpstreamDriftReportIssue, upsertUpstreamDriftReport, } from "../db/repositories"; +import { resolveGittensorySelfRepoFullName } from "../config/gittensory-repo-focus-manifest"; import { timeoutFetch } from "../github/client"; import { resolveUpstreamCommitSha } from "./commit"; import { isGlobalAgentPause } from "../settings/agent-execution"; @@ -34,7 +35,6 @@ import { errorMessage, jsonString, nowIso } from "../utils/json"; // The Gittensor upstream repo/ref defaults are single-sourced from src/scoring/model.ts (where the same // env.GITTENSOR_UPSTREAM_* override is honoured) — see DEFAULT_GITTENSOR_UPSTREAM_REPO/REF. -const DEFAULT_DRIFT_ISSUE_REPO = "JSONbored/gittensory"; const UPSTREAM_STALE_MS = 2 * 60 * 60 * 1000; const REGISTRY_HYPERPARAMETER_DRIFT_LIMIT = 100; @@ -285,7 +285,7 @@ export async function fileUpstreamDriftIssues(env: Env): Promise report.status === "open"); let created = 0;