Skip to content

fix(db): rename four more repo-identity tables and guard the list against drift - #9843

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/repo-identity-rename-tables-9650
Jul 29, 2026
Merged

fix(db): rename four more repo-identity tables and guard the list against drift#9843
JSONbored merged 1 commit into
JSONbored:mainfrom
shin-core:fix/repo-identity-rename-tables-9650

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What & why

renameRepositoryIdentity (src/db/repo-identity-rename.ts) walks every repo-identity table to move a renamed repo's rows forward, but four tables carrying a repo-identity column were never walked: linked_issue_claims, bounty_lifecycle_events, webhook_events, and score_previews. A repo rename orphaned their rows under the old name. Nothing guarded the list, so it has drifted three times.

The fix

  • linked_issue_claims (PK repo_full_name, pull_number, issue_number) — fold a stray new-name row on the composite key first, keeping the pre-existing old-name row's claimed_at, exactly as pullRequests/issues do; history is never dropped for the new-name row.
  • bounty_lifecycle_events, webhook_events, score_previews — surrogate id/delivery_id primary keys with no unique constraint on the repo column, so each is a plain UPDATE … SET <col> = new WHERE <col> = old, matching the orb_webhook_events block.
  • Export RENAME_OUT_OF_SCOPE_TABLES — the eight deliberately-excluded tables the module's prose block already documents (rebuildable caches, orphaned review_targets, repo_chunks, …).
  • Completeness drift guard (describe("renameRepositoryIdentity completeness (drift guard)")): every schema.ts table with a repo_full_name/repository_full_name column must be either renamed here or exempt; no table may be both; no exempt entry may be dead. Mirrors retention.test.ts's RETENTION_POLICY completeness guard, using drizzle-orm's getTableColumns/getTableName over import * as schema.

Tests (test/unit/repo-identity-rename.test.ts)

  • linked_issue_claims: a colliding new-name row is folded and the OLD-name row's claimed_at survives (fails on main).
  • bounty_lifecycle_events / webhook_events / score_previews: rows seeded under the old name leave zero rows under it after the rename (fail on main).
  • The three drift-guard assertions (verified to catch a simulated new drift — removing a table lists it as unaccounted).

Validation

  • npm run typecheck green; npm run db:schema-drift:check green (no schema change); the suite (82 tests) green.
  • Diff coverage on the changed file is 100% (including the linked_issue_claims collision branch).
  • git diff --check <base> HEAD clean; no migration change.

Closes #9650

…inst drift

`renameRepositoryIdentity` walks every repo-identity table to move a renamed
repo's rows forward, but four tables carrying a repo-identity column were never
walked: `linked_issue_claims`, `bounty_lifecycle_events`, `webhook_events`, and
`score_previews`. A rename orphaned their rows under the old name.

Add an explicit per-table block for each (matching the module's convention):
`linked_issue_claims` (PK repo_full_name/pull_number/issue_number) folds a stray
new-name row first, keeping the pre-existing old-name row's claimed_at, exactly as
pullRequests/issues do; the other three have surrogate primary keys with no unique
constraint on the repo column, so each is a plain UPDATE with no fold.

Export `RENAME_OUT_OF_SCOPE_TABLES` (the eight deliberately-excluded tables the
prose block already documents) and add a completeness drift guard: every schema.ts
table with a repo_full_name/repository_full_name column must be renamed here or be
exempt, no table may be both, and no exempt entry may be dead — the list had
drifted three times before. Mirrors retention.test.ts's RETENTION_POLICY guard.

Closes JSONbored#9650
@shin-core
shin-core requested a review from JSONbored as a code owner July 29, 2026 13:47
@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb

loopover-orb Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-29 13:59:34 UTC

2 files · 1 AI reviewer · no blockers · CI green · clean

⏸️ Suggested Action - Manual Review

  • AI review did not produce public notes: The configured AI reviewer returned no usable public assessment for this PR head.

Review summary
AI review is unavailable for this PR head. LoopOver is holding this PR for manual review until the configured AI provider returns a usable public review summary.

Nits — 1 non-blocking
  • AI review did not produce public notes — Fix the configured AI provider, then re-run LoopOver review before relying on the result.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ⚠️ Gate result — Not blocking (Advisory; not blocking this PR.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #9650
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 (1 linked issue).
Validation posture ❌ 5/25 Preflight is holding this PR: the review lane is unavailable, so it is not ready for automated review.
Contributor workload ✅ 10/10 Author activity: 71 registered-repo PR(s), 52 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor shin-core; Gittensor profile; 71 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Review context
  • Author: shin-core
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is registered but has no active allocation in the current snapshot.
  • Public profile languages: TypeScript, JavaScript, Solidity, Dart, Python, CSS, PHP, Rust
  • Official Gittensor activity: 71 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Await review-lane availability.
  • Then work through the remaining 1 step in the Signals table above.
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.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

Decision record
  • action: hold · clause: ai_review_inconclusive
  • config: bbfd0599711e13393dd42757e3181fc303f275979113e84b2372458e033536ac · pack: oss-anti-slop · ci: passed
  • record: a5209faadf9023e019739cc3014cca836f63ac35287e4c8818c39f6a07e95928 (schema v5, head ce9c600)

🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

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

codecov Bot commented Jul 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.10%. Comparing base (60d900a) to head (ce9c600).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9843      +/-   ##
==========================================
+ Coverage   79.04%   79.10%   +0.05%     
==========================================
  Files         281      282       +1     
  Lines       58409    58576     +167     
  Branches     6698     6721      +23     
==========================================
+ Hits        46171    46337     +166     
  Misses      11955    11955              
- Partials      283      284       +1     
Flag Coverage Δ
backend 99.40% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/db/repo-identity-rename.ts 99.40% <100.00%> (ø)

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 29, 2026
@JSONbored
JSONbored merged commit 5cc8d1f into JSONbored:main Jul 29, 2026
8 checks passed
JSONbored pushed a commit that referenced this pull request Jul 29, 2026
…inst drift (#9843)

`renameRepositoryIdentity` walks every repo-identity table to move a renamed
repo's rows forward, but four tables carrying a repo-identity column were never
walked: `linked_issue_claims`, `bounty_lifecycle_events`, `webhook_events`, and
`score_previews`. A rename orphaned their rows under the old name.

Add an explicit per-table block for each (matching the module's convention):
`linked_issue_claims` (PK repo_full_name/pull_number/issue_number) folds a stray
new-name row first, keeping the pre-existing old-name row's claimed_at, exactly as
pullRequests/issues do; the other three have surrogate primary keys with no unique
constraint on the repo column, so each is a plain UPDATE with no fold.

Export `RENAME_OUT_OF_SCOPE_TABLES` (the eight deliberately-excluded tables the
prose block already documents) and add a completeness drift guard: every schema.ts
table with a repo_full_name/repository_full_name column must be renamed here or be
exempt, no table may be both, and no exempt entry may be dead — the list had
drifted three times before. Mirrors retention.test.ts's RETENTION_POLICY guard.

Closes #9650
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

db: renameRepositoryIdentity omits four more repo-identity tables, and nothing guards the list

2 participants