test(db): cover pruneExpiredRecords' two defensive ?? 0 arms (#8370)#8451
Conversation
…ed#8370) Neither the dry-run row?.n ?? 0 fallback (line 75) nor the delete-loop result.meta?.changes ?? 0 fallback (line 85) had direct test coverage, unlike the identical pattern on this file's sibling function dedupeSignalSnapshots, which already has dedicated tests for both. Mirrors that exact mocking approach: env.DB.prepare returning a row/meta shape missing the relevant field, asserting the function falls back to 0 rather than throwing or producing NaN. No production-code changes.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Warning ⏸️ LoopOver review result - manual review recommendedReview updated: 2026-07-24 13:59:30 UTC
Review summary Nits — 4 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.
|
|
LoopOver is closing this pull request on the maintainer's behalf (conflicts with the base branch — resolve and open a fresh PR). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed. |
Summary
pruneExpiredRecords's two defensive?? 0fallback arms (src/db/retention.ts:75dry-runrow?.n ?? 0, and:85delete-loopresult.meta?.changes ?? 0) had zero direct test coverage, unlike the identical pattern on this file's sibling functiondedupeSignalSnapshots, which already has dedicated tests for both equivalent arms.dedupeSignalSnapshots's existing tests exactly: mockenv.DB.prepareto return a row/metashape missing the relevant field, and assert the function falls back to0rather than throwing or producingNaN.src/db/retention.tswas changed, per the issue's explicit scope.Closes #8370
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally;codecov/patchrequires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
test/unit/retention.test.ts(test-only, nosrc/production-code change) — no UI/MCP/workers/OpenAPI surface is affected. Verified vianpx vitest run test/unit/retention.test.ts: all 21 tests pass, including the 2 new ones. Coverage on the target lines (verified directly againstcoverage/lcov.info): line 75's branch now showsBRDA:75,10,0,25/BRDA:75,10,1,1and line 85's showsBRDA:85,11,0,21/BRDA:85,11,1,1— both the truthy and nullish-fallback sides of both?? 0arms are hit, closing the previously-uncovered branch the issue identified.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots. (N/A — no visible UI changes.)Notes
src/db/retention.tsitself is unchanged, exactly as the issue scoped it.