Skip to content

fix(miner): scope the policy-verdict-cache purge to its real host-scoped repo key - #10250

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

fix(miner): scope the policy-verdict-cache purge to its real host-scoped repo key#10250
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-10001

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

fix(miner): scope the policy-verdict-cache purge to its real host-scoped repo key

purgeByRepo matched repo_scope with a bare = owner/repo equality, but every real row is
keyed <apiBaseUrl>::owner/repo (policyVerdictCacheKey), so the right-to-be-forgotten purge
and its --dry-run count both silently matched zero rows for every repo. Switch both to an
escaped LIKE suffix match on the owner/repo segment across every forge host, shared via one
pattern-building helper so the real delete and the dry-run count can't diverge.

Closes #10001

…ped repo key

purgeByRepo matched repo_scope with a bare `= owner/repo` equality, but every real row is
keyed `<apiBaseUrl>::owner/repo` (policyVerdictCacheKey), so the right-to-be-forgotten purge
and its --dry-run count both silently matched zero rows for every repo. Switch both to an
escaped LIKE suffix match on the owner/repo segment across every forge host, shared via one
pattern-building helper so the real delete and the dry-run count can't diverge.
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 31, 2026 14:20
@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 14:28:10 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This fixes a real bug: policy_verdict_cache rows are keyed `<apiBaseUrl>::owner/repo` but purgeByRepo/countStoreByRepo matched with a bare equality on `owner/repo`, so right-to-be-forgotten purges silently deleted nothing. The fix switches both the real delete (policy-verdict-cache.ts's hand-written purgeByRepo) and the dry-run count (store-maintenance.ts's countStoreByRepo) to an escaped LIKE suffix match built by one shared helper (hostScopedRepoSuffixPattern), so the two paths can't diverge — same house-style split already used for worktree-allocator's extraWhereSql. Tests cover the multi-host sweep, the same-repo-untouched case, and correctly verify LIKE-wildcard escaping (`_`/`%`) plus non-prefix-match behavior, all exercising the real repo_scope shape rather than a fabricated one.

Nits — 4 non-blocking
  • packages/loopover-miner/lib/store-maintenance.ts: the doc comment states hostScopedSuffixMatch and extraWhereSql are 'mutually exclusive in practice' but nothing enforces that in countStoreByRepo — if a future spec set both, hostScopedSuffixMatch would silently take priority and extraWhereSql would be ignored; worth a runtime assertion or at least a stronger comment.
  • The magic issue numbers (6987, 10001) embedded directly in doc comments (e.g. store-maintenance.ts:39, :74) are fine as-is per this repo's existing convention (every other spec here cites its issue number the same way), so not worth a named constant.
  • policy-verdict-cache.ts's purgeByRepo bypasses store-maintenance.ts's SQL_IDENTIFIER guard entirely since the table/column are hardcoded literals in the SQL string — safe here, but worth noting it diverges from the identifier-guard discipline the rest of the file emphasizes.
  • Consider a small runtime guard (or a type-level comment enforcement) in countStoreByRepo for the case where a spec accidentally sets both hostScopedSuffixMatch and extraWhereSql, per store-maintenance.ts:39's own doc claim that they're mutually exclusive.

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 #10001
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 ⚠️ 20/25 Preflight is ready, but the PR body does not name the validation run.
Contributor workload ✅ 10/10 Author activity: 140 registered-repo PR(s), 99 merged, 3 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 140 PR(s), 3 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: significant
Linked issue satisfaction

Addressed
The PR replaces the exact-equality repo_scope match with an escaped LIKE suffix pattern shared between purgeByRepo and countStoreByRepo via hostScopedRepoSuffixPattern, matching the required extraWhereSql/countStoreByRepo lockstep pattern, correctly scoping across hosts, and escaping `_`/`%` to prevent over-matching. It also updates the JSDoc contract on purgeByRepo to owner/repo and rewrites the

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: TypeScript
  • Official Gittensor activity: 140 PR(s), 3 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Add validation command/output.
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.

🟩 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 80.64%. Comparing base (0666de7) to head (7b3f792).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10250      +/-   ##
==========================================
+ Coverage   80.60%   80.64%   +0.03%     
==========================================
  Files         283      285       +2     
  Lines       59101    59212     +111     
  Branches     7000     7023      +23     
==========================================
+ Hits        47641    47752     +111     
  Misses      11167    11167              
  Partials      293      293              
Flag Coverage Δ
backend 100.00% <100.00%> (?)

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

Files with missing lines Coverage Δ
...ackages/loopover-miner/lib/policy-verdict-cache.ts 100.00% <100.00%> (ø)
packages/loopover-miner/lib/store-maintenance.ts 100.00% <100.00%> (ø)

@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 5b24374 into JSONbored:main Jul 31, 2026
8 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 31, 2026
7 tasks
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.

miner(purge): right-to-be-forgotten never deletes a policy-verdict-cache row, and the regression test hides it

1 participant