Skip to content

fix(db): fold five raw-SQL repo-identity tables and widen the drift guard past Drizzle - #10125

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10053
Jul 31, 2026
Merged

fix(db): fold five raw-SQL repo-identity tables and widen the drift guard past Drizzle#10125
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10053

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(db): fold five raw-SQL repo-identity tables and widen the drift guard past Drizzle

decision_records, decision_audit_labels, submitter_outcome_log, ai_review_verdict_flips,
and alert_dedup_claims were never moved by renameRepositoryIdentity, so a repo rename
silently orphaned the contributor's decision trail, the human adjudication labels, the
windowed submitter-reputation signal, the verdict-flip guard state, and the alert
dedup claims. The completeness drift guard only enumerated schema.ts's Drizzle tables,
so it couldn't see any of them -- it now also replays migrations/*.sql the way
scripts/check-schema-drift.ts does and checks the raw-SQL-only tables that surfaces.

Closes #10053

…uard past Drizzle

decision_records, decision_audit_labels, submitter_outcome_log, ai_review_verdict_flips,
and alert_dedup_claims were never moved by renameRepositoryIdentity, so a repo rename
silently orphaned the contributor's decision trail, the human adjudication labels, the
windowed submitter-reputation signal, the verdict-flip guard state, and the alert
dedup claims. The completeness drift guard only enumerated schema.ts's Drizzle tables,
so it couldn't see any of them -- it now also replays migrations/*.sql the way
scripts/check-schema-drift.ts does and checks the raw-SQL-only tables that surfaces.
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 31, 2026 08:03
@loopover-orb

loopover-orb Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-31 08:17:18 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR extends renameRepositoryIdentity to fold five previously-unhandled raw-SQL-only tables (decision_records, decision_audit_labels, submitter_outcome_log, ai_review_verdict_flips, alert_dedup_claims) that a repo rename was silently orphaning, and widens the completeness drift guard to replay migrations/*.sql and catch raw-SQL-only tables the old guard (which only enumerated schema.ts's Drizzle tables) was structurally blind to. I traced each fold against its real constraint (verified in migrations comments cited in the diff) and the collision-fold logic is consistent with the existing shapes already used elsewhere in this file — decision_records deliberately leaves `id` untouched because it's committed inside the decision-ledger hash chain, which is the right call and is proven by the loadCalibrationPairs cross-table join test. Tests cover both the plain-rename and collision-fold paths for every new table plus a real regression test for getSubmitterReputation across a rename, and the PR closes the linked #10053.

Nits — 6 non-blocking
  • src/db/repo-identity-rename.ts's submitter_outcome_log and alert_dedup_claims folds issue one DELETE per colliding row inside a for-loop instead of a bulk inArray/composite-tuple delete like most other tables in this file use — fine given rename-event rarity, but worth a comment noting why (composite-key IN isn't portable) since a reviewer will otherwise wonder why this table breaks the file's own pattern.
  • The file is now 713 lines / adds a 5th nesting level at one block (per the external size/nesting flags) — acceptable under this module's own documented 'one explicit block per table, no shared helper' convention, but if more raw-SQL tables keep landing here it may be worth revisiting that convention.
  • The new drift-guard test's RAW_IDENTITY_COLUMNS set includes generic names like `repo`/`project` that are known to appear on non-identity tables (repo_chunks, review_targets) — currently safe only because those are already in RENAME_OUT_OF_SCOPE_TABLES; a future raw-SQL table with an unrelated `project`/`repo` column would need to remember to add itself there too.
  • Consider a short module-header note (near the existing rationale block) on why submitter_outcome_log/alert_dedup_claims use per-row loops instead of the bulk-delete pattern used elsewhere, to preempt reviewer questions.
  • If more raw-SQL identity tables are expected to land per db(repo-identity-rename): fold the five raw-SQL-only repo-identity tables, and widen the drift guard past Drizzle #10053-style issues, consider whether the per-table block convention should be revisited before the file grows further.
  • Readiness score is below the configured threshold — Use the readiness panel as advisory maintainer context; the score does not block this PR.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #10053
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ⚠️ 12/25 Preflight needs author follow-up before maintainer review.
Contributor workload ✅ 10/10 Author activity: 98 registered-repo PR(s), 67 merged, 3 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 98 PR(s), 3 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The diff adds fold logic for all five named tables (decision_records, decision_audit_labels, submitter_outcome_log, ai_review_verdict_flips, alert_dedup_claims) each using the constraint-appropriate shape (plain rename vs. composite-tuple collision handling vs. PK+substring rewrite), matches the issue's explicit requirement that decision_records.id stay untouched, and widens the drift guard by rep

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 98 PR(s), 3 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add a concise scope and risk note.
  • Then work through the remaining 2 steps 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 <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> 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.

🟩 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

@superagent-security

Copy link
Copy Markdown
Contributor

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

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

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.85%. Comparing base (c877ed6) to head (fba7c3b).
⚠️ Report is 7 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main   #10125       +/-   ##
===========================================
- Coverage   91.95%   79.85%   -12.10%     
===========================================
  Files         931      283      -648     
  Lines      113924    58881    -55043     
  Branches    27506     6919    -20587     
===========================================
- Hits       104760    47022    -57738     
- Misses       7863    11570     +3707     
+ Partials     1301      289     -1012     
Flag Coverage Δ
backend 99.47% <100.00%> (+3.80%) ⬆️

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.47% <100.00%> (+0.07%) ⬆️

... and 781 files with indirect coverage changes

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit 72ec3ae into JSONbored:main Jul 31, 2026
8 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

db(repo-identity-rename): fold the five raw-SQL-only repo-identity tables, and widen the drift guard past Drizzle

1 participant