refactor(selfhost): consolidate triplicated self-repo-default resolver - #2941
Conversation
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.
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-04 06:22:04 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Concerns raised — review before merging
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2941 +/- ##
==========================================
- Coverage 96.05% 96.05% -0.01%
==========================================
Files 259 259
Lines 28462 28459 -3
Branches 10351 10349 -2
==========================================
- Hits 27340 27335 -5
Misses 489 489
- Partials 633 635 +2
🚀 New features to boost your workflow:
|
Summary
The literal default
"JSONbored/gittensory"(as a self-repo fallback, overridable viaGITTENSORY_DRIFT_ISSUE_REPO) was independently reimplemented three times:src/config/gittensory-repo-focus-manifest.ts—GITTENSOR_SELF_REPO_DEFAULT/resolveGittensorySelfRepoFullName(the canonical, most complete implementation: validates the configured value is non-empty AND contains a/).src/services/self-dogfood-registration-pack.ts—DEFAULT_SELF_DOGFOOD_REPO/resolveSelfDogfoodRepoFullName(functionally identical logic, just written with the branches in the opposite order — confirmed by truth-table comparison, not just visual similarity).src/upstream/ruleset.ts— a bareenv.GITTENSORY_DRIFT_ISSUE_REPO || DEFAULT_DRIFT_ISSUE_REPOfallback with no validation at all.Routes the latter two through the shared
resolveGittensorySelfRepoFullName.self-dogfood-registration-pack.tskeeps its two prior export names (DEFAULT_SELF_DOGFOOD_REPO,resolveSelfDogfoodRepoFullName) as thin re-exports, sosrc/api/routes.ts's four call sites and the existing test file needed zero changes.Found and deliberately fixed the genuine validation gap the issue asked me to check for before consolidating:
upstream/ruleset.ts's bare||fallback would use a malformedGITTENSORY_DRIFT_ISSUE_REPOvalue (e.g. one missing a/) as-is, where the other two implementations would reject it and fall back to the safe default. Verified this fix doesn't break anything by running the existing test that specifically exercises this case (GITTENSORY_DRIFT_ISSUE_REPO: "bad-repo-name") — it still passes unchanged, since the code already degrades gracefully regardless of which invalid-vs-default repo string it ends up trying.Resolves #2911. Part of the #1667 self-host review-stack roadmap.
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run typecheckvitest run test/unit/self-dogfood-registration-pack.test.ts test/unit/upstream-ruleset.test.ts— 50 tests passed, including the specific "bad-repo-name" and "defaults to the gittensory maintainer when unset, empty, or whitespace-only" cases that exercise the validation-gap fixnpm run test:changed— 75 files / 1757 tests passed, 0 failednpm run actionlint/npm run test:workers/npm run build:mcp/npm run test:mcp-pack/npm audit/ui:*— not run locally; no workflow, worker-pool, MCP-package, or UI files touched. CI runs the full gate.If any required check was skipped, explain why:
test:coverage/test:cinot run locally — this diff is a pure consolidation (net -8/+8 lines across 2 files) with one deliberate, disclosed behavior narrowing (rejecting a previously-accepted malformed env value); the existing test suite already covers both the default-value and override paths for all three sites, confirmed passing above.Safety