Skip to content

feat(miner): add the ContributionProfile local cache store + doctor/migrate integration - #7001

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
luciferlive112116:feat/contribution-profile-cache-6797
Jul 17, 2026
Merged

feat(miner): add the ContributionProfile local cache store + doctor/migrate integration#7001
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
luciferlive112116:feat/contribution-profile-cache-6797

Conversation

@luciferlive112116

Copy link
Copy Markdown
Contributor

Summary

The caching half of the AMS contribution-profile chain (#6793): persists the #6796 extraction output in a local SQLite store keyed by repo, so a repeated discover run against the same repo within the freshness window doesn't re-fetch and re-parse the same labels + docs every time. Depends on #6795 (schema) and #6796 (extraction) — both merged.

Mirrors the existing miner stores exactly

Nothing bespoke: it opens through local-store.js's openLocalStoreDb + resolveLocalStoreDbPath and stamps the schema version via applySchemaMigrations, identical to run-state.js and its siblings — so it's picked up by doctor and migrate the same way they are. It uses the miner_contribution_profile table name and 7-day TTL that the #6795 schema already named (CONTRIBUTION_PROFILE_STORE_TABLE, CONTRIBUTION_PROFILE_CACHE_TTL_MS), so the store and the schema agree by construction rather than each inventing a value.

get() returns { profile, fetchedAt, stale } (or null); put(profile) keys on the profile's own repoFullName. Both take an injectable nowMs so TTL/staleness tests are deterministic.

Fails closed

A cache must never break discover when its file is corrupt or hand-edited:

  • A row whose profile_json doesn't parse → get() returns null (a miss), not a throw.
  • A row with an unparseable fetched_at → treated as stale, so it's re-extracted rather than trusted.

Doctor + migrate integration

Added contribution-profile to doctor's store-integrity:* sweep (status.js) and to migrate's STORES list (migrate-cli.js). Those two lists must stay in sync — their tests assert the exact same list in the same order — so both source lists and both test lists gain the entry, appended after worktree-allocator, and the migrate test's "eleven → twelve stores" label is updated.

Validation

  • Patch coverage 100%, measured on every changed src/**-gated file: contribution-profile-cache.js (39/39 statements, 17/17 branches, 11/11 functions), plus the 2 changed lines each in status.js and migrate-cli.js — zero uncovered, zero partial.
  • Store test 10/10: path resolution, table creation, fresh/stale at the exact TTL boundary, re-put overwrite, repo isolation, corrupt-JSON and bad-timestamp fail-closed paths, invalid-input rejection, and the module-level helpers. doctor/migrate suites 44+12 with the new store's assertions passing.
  • npm run typecheck — 0 (after the standard engine rebuild) · eslint — 0/0 · prettier --check — clean · node --check (added to the miner build list) — ok · rebased on latest main.

One pre-existing failure, not mine — verified, not assumed: miner-status.test.ts's "resolves the state dir…" fails identically on clean main with my work stashed (Windows-only \ vs / path separators; it passes in CI's Linux). My own path-resolution assertion is separator-agnostic to avoid adding to that noise.

Scope & safety

  • Eight files: the store + its .d.ts, the two 2-line doctor/migrate additions, the build-list entry, and three test files. Wanted paths (packages/, test/).
  • No hot files: no src/api/routes.ts, src/mcp/server.ts, the MCP CLI bin, or the stdio-tool count pin — by design, to avoid the base-conflict/count-pin contention.
  • 100% local store — never uploads, syncs, or phones home; read/write only. No secrets; no changelog/site//CNAME/lovable changes.

Closes #6797

…igrate integration (JSONbored#6797)

Persists the JSONbored#6796 extraction output in a local SQLite store keyed by repo, so a
repeated discover run within the freshness window doesn't re-fetch/re-parse the same
labels + docs. Mirrors the existing miner stores exactly (openLocalStoreDb +
resolveLocalStoreDbPath + the schema-version stamp), keyed by owner/repo, with the
7-day TTL and miner_contribution_profile table the JSONbored#6795 schema already named.

get() returns { profile, fetchedAt, stale } and fails closed to null on a corrupt-JSON
row and to stale on an unparseable timestamp -- a hand-edited/corrupted file must never
break discover. Wired into doctor's store-integrity sweep and migrate's STORES list,
keeping both in sync (their tests assert the exact same list, in order).

Closes JSONbored#6797
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.72%. Comparing base (75e6f42) to head (b9b739c).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7001      +/-   ##
==========================================
+ Coverage   89.24%   93.72%   +4.48%     
==========================================
  Files         688      689       +1     
  Lines       68506    68543      +37     
  Branches    18740    18740              
==========================================
+ Hits        61140    64244    +3104     
+ Misses       5656     3302    -2354     
+ Partials     1710      997     -713     
Flag Coverage Δ
shard-1 43.63% <5.40%> (-0.03%) ⬇️
shard-2 36.86% <5.40%> (+<0.01%) ⬆️
shard-3 32.76% <5.40%> (-0.26%) ⬇️
shard-4 34.40% <8.10%> (?)
shard-5 31.64% <100.00%> (-0.47%) ⬇️
shard-6 46.09% <8.10%> (+0.25%) ⬆️

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

Files with missing lines Coverage Δ
...s/loopover-miner/lib/contribution-profile-cache.js 100.00% <100.00%> (ø)
packages/loopover-miner/lib/migrate-cli.js 100.00% <ø> (ø)
packages/loopover-miner/lib/status.js 94.53% <ø> (+4.68%) ⬆️

... and 99 files with indirect coverage changes

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 17, 2026
@loopover-orb

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 18:00:42 UTC

8 files · 1 AI reviewer · no blockers · readiness 98/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This adds a straightforward local SQLite cache for ContributionProfile, mirroring run-state.js's local-store.js/schema-version.js pattern exactly (openLocalStoreDb, applySchemaMigrations, injectable nowMs, and the same repoFullName normalization used elsewhere). It fails closed on corrupt JSON (returns null/miss) and unparseable timestamps (treated as stale), which matches the PR's stated intent, and it's wired into both status.js's store-integrity sweep and migrate-cli.js's STORES list in the same append position with matching test updates. No migration file is needed since this is a brand-new table with no post-baseline migrations, and the diff is narrow and consistent with its description.

Nits — 5 non-blocking

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 #6797
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 ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 172 registered-repo PR(s), 103 merged, 27 issue(s).
Contributor context ✅ Confirmed Gittensor contributor luciferlive112116; Gittensor profile; 172 PR(s), 27 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds a SQLite cache store keyed by owner/repo with a fetched_at timestamp and TTL (imported from the #6795 schema), fails closed on corrupt JSON/timestamps, integrates into both doctor's store-integrity sweep and migrate's STORES list, and includes regression tests covering read/write/expiry/staleness behavior—matching all stated requirements and deliverables.

Review context
  • Author: luciferlive112116
  • 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: 172 PR(s), 27 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AMS contribution-profile: local cache store + doctor integration

1 participant