Skip to content

fix(selfhost): canonicalize repo-doc refresh repos - #3605

Merged
JSONbored merged 1 commit into
mainfrom
codex/fix-mixed-case-repo-names-bypass
Jul 5, 2026
Merged

fix(selfhost): canonicalize repo-doc refresh repos#3605
JSONbored merged 1 commit into
mainfrom
codex/fix-mixed-case-repo-names-bypass

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Motivation

  • Prevent mixed-case owner/repo names from bypassing per-repository pause/dry-run settings when performing on-demand repo-doc refreshes by ensuring the stored repository canonical name is used for settings and write operations.

Description

  • Resolve the stored repository record with getRepository and derive a canonicalRepoFullName before calling getRepositorySettings, openRepoDocPullRequest, or recording attempt snapshots in performRepoDocRefresh (src/github/repo-doc-refresh-runner.ts).
  • Import getRepository alongside existing DB helpers and use the canonical name for settings lookup, PR-opening, and attempt recording to avoid casing mismatches.
  • Add regression tests in test/unit/repo-doc-refresh-runner.test.ts that cover the uninstalled-repo fallback and a mixed-case caller path that must respect the stored agentPaused setting.

Testing

  • Ran npm run typecheck which succeeded with no TypeScript errors.
  • Ran the targeted unit tests with npx vitest run test/unit/repo-doc-refresh-runner.test.ts and all tests in that file passed.
  • Attempted the full local gate with npm run test:ci, but the run was interrupted/blocked by unrelated long-running failures/timeouts in existing test suites (test/unit/queue.test.ts and test/unit/backfill.test.ts) in the local environment, so the full gate was not completed here.

Codex Task

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.11%. Comparing base (15ace01) to head (a69f0c9).
⚠️ Report is 24 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3605   +/-   ##
=======================================
  Coverage   93.11%   93.11%           
=======================================
  Files         305      305           
  Lines       31532    31534    +2     
  Branches    11509    11510    +1     
=======================================
+ Hits        29361    29363    +2     
  Misses       1517     1517           
  Partials      654      654           
Files with missing lines Coverage Δ
src/github/repo-doc-refresh-runner.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 5, 2026
@loopover-orb

loopover-orb Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Warning

🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨

⏸️ Gittensory review result - manual review recommended

Review updated: 2026-07-05 19:39:39 UTC

2 files · 1 AI reviewer · 2 blockers · readiness 93/100 · CI green · clean

⏸️ Suggested Action - Manual Review

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.

Review summary
This fix resolves getRepository(env, repoFullName) once in performRepoDocRefresh and threads the resulting canonical fullName through getRepositorySettings, openRepoDocPullRequest, and recordRepoDocRefreshAttempt, closing a real bypass where a mixed-case caller (e.g. the MCP on-demand trigger) could miss a stored agentPaused/settings row keyed by the canonical casing. The new mixed-case test (test/unit/repo-doc-refresh-runner.test.ts) actually drives the real path — it seeds settings under lowercase 'owner/widgets', calls performRepoDocRefresh with 'Owner/Widgets', and asserts the paused mode is honored and the attempt is recorded only under the canonical name — so this isn't a fabricated-state test, and CI is green. The uninstalled-repo fallback (repository is null) correctly falls back to the raw repoFullName for both settings lookup and attempt recording, which is the same pre-fix behavior for that case.

Nits — 5 non-blocking
  • src/github/repo-doc-refresh-runner.ts:59-62 adds one extra getRepository DB round-trip per refresh call — negligible for this single-repo, on-demand path but worth noting if this function is ever called in a hot loop.
  • The PR description doesn't cite a specific tracked issue number this closes, only referencing the pre-existing feat(selfhost): scheduled + on-demand refresh for repo-doc generation #3003 code comment — worth confirming there's an eligible open issue this bypass fix is linked to per repo contribution policy.
  • test/unit/repo-doc-refresh-runner.test.ts's new mixed-case test asserts getLastRepoDocRefreshAttemptedAt(env, 'Owner/Widgets') is null but doesn't also assert the openRepoDocPullRequest call itself received the canonical name (it infers this indirectly via the paused-mode outcome) — an explicit spy/assert on the call argument would make the canonicalization guarantee more directly verifiable.
  • Consider adding a short code comment at src/github/repo-doc-refresh-runner.ts:59 noting why canonicalRepoFullName falls back to the raw repoFullName (uninstalled repo) so future readers don't assume getRepository always succeeds.
  • If getRepository's name lookup isn't already case-insensitive at the DB layer, confirm that here (not shown in this diff) since the whole fix depends on it resolving 'Owner/Widgets' to the stored 'owner/widgets' row.

Concerns raised — review before merging

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • Maintainer requires a linked issue — Link the relevant issue (for example Closes #123) before opening the PR.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ⚠️ Missing No linked issue or no-issue rationale found.
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (no linked issue context).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 56 registered-repo PR(s), 46 merged, 493 issue(s).
Contributor context ✅ Confirmed Gittensor contributor JSONbored; Gittensor profile; 56 PR(s), 493 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: JSONbored
  • Role context: owner (maintainer lane)
  • Public audience mode: oss maintainer
  • Lane context: Repository registration is not available in the local Gittensory cache.
  • Public profile languages: Python, TypeScript, JavaScript, Ruby, Go, Kotlin, MDX, Shell
  • Official Gittensor activity: 56 PR(s), 493 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Treat this as maintainer-lane context rather than normal contributor-lane activity.
  • Explain no-issue PR.
  • No action.
  • Link the issue being solved, or explicitly explain why this is a no-issue PR.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 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.

  • Re-run Gittensory review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 5, 2026
@JSONbored
JSONbored merged commit 99461c7 into main Jul 5, 2026
10 checks passed
@JSONbored
JSONbored deleted the codex/fix-mixed-case-repo-names-bypass branch July 5, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. manual-review Gittensor contributor context

Development

Successfully merging this pull request may close these issues.

1 participant