feat(miner): add the ContributionProfile local cache store + doctor/migrate integration - #7001
Conversation
…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 didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more.
|
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-17 18:00:42 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk 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.
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.
|
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
discoverrun 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'sopenLocalStoreDb+resolveLocalStoreDbPathand stamps the schema version viaapplySchemaMigrations, identical torun-state.jsand its siblings — so it's picked up bydoctorandmigratethe same way they are. It uses theminer_contribution_profiletable 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 }(ornull);put(profile)keys on the profile's ownrepoFullName. Both take an injectablenowMsso TTL/staleness tests are deterministic.Fails closed
A cache must never break
discoverwhen its file is corrupt or hand-edited:profile_jsondoesn't parse →get()returnsnull(a miss), not a throw.fetched_at→ treated as stale, so it's re-extracted rather than trusted.Doctor + migrate integration
Added
contribution-profiletodoctor'sstore-integrity:*sweep (status.js) and tomigrate'sSTORESlist (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 afterworktree-allocator, and the migrate test's "eleven → twelve stores" label is updated.Validation
src/**-gated file:contribution-profile-cache.js(39/39 statements, 17/17 branches, 11/11 functions), plus the 2 changed lines each instatus.jsandmigrate-cli.js— zero uncovered, zero partial.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 latestmain.One pre-existing failure, not mine — verified, not assumed:
miner-status.test.ts's "resolves the state dir…" fails identically on cleanmainwith 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
.d.ts, the two 2-line doctor/migrate additions, the build-list entry, and three test files. Wanted paths (packages/,test/).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.site//CNAME/lovablechanges.Closes #6797