test(miner): add real concurrent-process races test for claim-ledger and portfolio-queue - #5464
Conversation
…and portfolio-queue (JSONbored#4867) Only worktree-allocator.js had a dedicated multi-process collision test before; claim-ledger and portfolio-queue atomicity was only exercised per-function, single process. Spawns real Node child processes racing the same on-disk SQLite file (mirroring acquire-child.mjs's fixture pattern) and asserts no double-claim, double-dequeue, or corrupted state under real concurrent load.
|
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 #5464 +/- ##
==========================================
- Coverage 94.71% 94.67% -0.04%
==========================================
Files 555 555
Lines 44529 44529
Branches 14666 14666
==========================================
- Hits 42175 42158 -17
- Misses 1619 1636 +17
Partials 735 735
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-12 21:14:24 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
[BETA] Chat with GittensoryAsk Gittensory 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://gittensory.aethereal.dev/docs/gittensory-commands 🟩 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 Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
packages/gittensory-miner/lib/worktree-allocator.jshad a dedicated multi-process collision test (test/unit/miner-worktree-allocator-collisions.test.ts) before this PR — the claim-ledger and portfolio-queue stores' atomicity was only exercised per-function (single process, sequential calls), never under real concurrent load from two actual OS processes racing the same on-disk SQLite file.test/unit/miner-concurrent-store-races.test.ts, closely mirroring the existing worktree-allocator collision test's structure (spawn real Node child processes, barrier them on a stdin"go"signal after each reportsREADY, then assert the resulting on-disk state):(repoFullName, issueNumber)simultaneously — asserts exactly one active row results (no duplicate/corrupted rows despite the concurrent UPSERT), plus a sibling test that two processes claiming different issues both succeed with distinct rows.dequeueNext()on a single queued item — asserts exactly one process wins the atomicUPDATE...RETURNINGclaim and the other getsnull(no double-dequeue), plus an N-processes/N-items variant asserting all N claims are distinct with zero duplicates.test/fixtures/miner-worktree-allocator/acquire-child.mjs's exact shape:test/fixtures/miner-concurrent-stores/claim-child.mjsand.../dequeue-child.mjs.INSERT...ON CONFLICTfor claims,UPDATE...RETURNINGfor dequeue). No claim-conflict "who wins" resolution logic is touched or added.Fixes #4867
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 — this change lives entirely underpackages/gittensory-miner/**-adjacent test files (test/unit/**,test/fixtures/**), which are outside vitest'scoverage.includeglob (thepackages/gittensory-miner/**source itself is what's exercised, and it sits outsidecoverage.includetoo), socodecov/patchcannot measure this directly — consistent with how the existing worktree-allocator collision test is also uncounted.npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run build:minernpm run test:miner-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:testnpm run ui:buildnpm audit --audit-level=moderateThis PR is the test addition: 6 new tests (4 real cross-process races + 2 fixture-argument-validation guards), all driving the real stores via real spawned
nodechild processes against real on-disk SQLite files (no mocking of the concurrency behavior under test). Ran the new file 4 times in a row locally to check for timing flakiness — stable every time (6/6 passing, ~0.6–1.4s total).Safety
UI Evidencesection below — N/A, no visible/UI change.UI Evidence
Not applicable — this PR only adds cross-process integration tests for two local SQLite-backed stores; there is no visible UI change.
Notes
ON CONFLICTupsert for claims,UPDATE...RETURNINGsubquery for dequeue) already hold correctly under real concurrent load; this PR only makes that guarantee test-verified instead of merely load-bearing-by-inspection.