Skip to content

feat(miner): make queue next WIP-cap-aware via --global-wip/--per-repo-wip - #5600

Merged
JSONbored merged 1 commit into
mainfrom
wire-wip-cap-queue-next
Jul 13, 2026
Merged

feat(miner): make queue next WIP-cap-aware via --global-wip/--per-repo-wip#5600
JSONbored merged 1 commit into
mainfrom
wire-wip-cap-queue-next

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

Summary

queue next always called the naive, uncapped dequeueNext() directly, even though a WIP-cap-aware batch claimer (portfolio-queue-manager.js, used by queue claim-batch) already existed and was built/tested.

  • Adds --global-wip/--per-repo-wip flags to queue next, mirroring claim-batch's own flag names.
  • Both flags are omitted (unset/uncapped) by default, so every existing caller's behavior is byte-identical to before — queue next only becomes cap-aware when an operator explicitly opts in, matching the "off by default" convention used elsewhere in this package (ledger retention, dry-run).
  • When set, a new selectNextEligibleTarget() picks at most one atomically-claimable target via the store's existing batchClaim transaction — refuses to claim once the global or the target row's own per-repo in-progress count has reached its cap. Never claims-then-discards extra rows, and doesn't reuse the engine's diversifying batch-selection algorithm (that stays claim-batch's job — queue next keeps its existing single-highest-priority-item contract).

Scope note: the issue's .gittensory-miner.yml cap-source suggestion isn't wired here — that file is resolved from an already-cloned repo on disk (miner-goal-spec.js's resolveMinerGoalSpec), but queue next dequeues before any worktree is prepared for the claimed item, so no local copy of the target repo's yml exists yet at that point. Reading it live would require new remote-fetch plumbing this issue doesn't otherwise need. CLI flags (matching claim-batch's existing, established convention) deliver the actual acceptance criterion — "setting a WIP cap ... stops queue next from claiming once the cap is reached" — without that new dependency.

Closes #4850

Test plan

  • New selectNextEligibleTarget() unit tests: null-caps replicates pre-Wire WIP-cap-aware batch claiming into the real CLI path #4850 behavior, empty queue, global-cap-reached refusal, per-repo-cap-reached refusal (and that a different repo's row is still eligible)
  • New runQueueNext integration tests: caps enforced end-to-end, unset caps stay byte-identical to old behavior, only---per-repo-wip-set leaves global genuinely uncapped, --dry-run reports the requested caps
  • npx vitest run test/unit/miner-*.test.ts — 1667/1667 passing
  • npx tsc --noEmit clean
  • npm run build:miner clean
  • npm run command-reference:check — unaffected (miner CLI isn't in that generator's scope)
  • 100% patch coverage on touched lines/branches (verified via lcov branch-diff against this PR's hunks)

…o-wip

queue next always called the naive, uncapped dequeueNext() directly, even
though a WIP-cap-aware batch claimer (portfolio-queue-manager.js, used by
queue claim-batch) already existed. Adds --global-wip/--per-repo-wip flags
to queue next, mirroring claim-batch's own flag names.

Both flags are omitted (unset/uncapped) by default, so every existing
caller's behavior is byte-identical to before -- queue next only becomes
cap-aware when an operator explicitly opts in, matching the "off by
default" convention used elsewhere in this package (ledger retention,
dry-run). When set, a new selectNextEligibleTarget() picks at most one
atomically-claimable target via the store's existing batchClaim
transaction, refusing to claim once the global or the target row's own
per-repo in-progress count has reached its cap -- never claiming and then
discarding extra rows, and never reusing the engine's diversifying
batch-selection algorithm (that stays claim-batch's job).

Scope note: the issue's ".gittensory-miner.yml" cap-source suggestion
isn't wired here -- that file is resolved from an ALREADY-CLONED repo on
disk (miner-goal-spec.js's resolveMinerGoalSpec), but queue next dequeues
BEFORE any worktree is prepared for the claimed item, so no local copy of
the target repo's yml exists yet at that point. Reading it would require
new live-fetch plumbing this issue doesn't otherwise need. CLI flags
(matching claim-batch's existing, established convention) deliver the same
acceptance criterion -- "setting a WIP cap ... stops queue next from
claiming once the cap is reached" -- without that new dependency.

Advances #4850.
@superagent-security

Copy link
Copy Markdown
Contributor

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

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
loopover-ui 570b600 Commit Preview URL

Branch Preview URL
Jul 13 2026, 08:25 AM

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.00%. Comparing base (a7f2063) to head (570b600).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5600      +/-   ##
==========================================
- Coverage   95.02%   95.00%   -0.03%     
==========================================
  Files         573      573              
  Lines       45564    45600      +36     
  Branches    14661    14661              
==========================================
+ Hits        43296    43321      +25     
- Misses       1517     1528      +11     
  Partials      751      751              
Flag Coverage Δ
shard-1 44.01% <0.00%> (-0.05%) ⬇️
shard-2 35.79% <100.00%> (+0.07%) ⬆️
shard-3 31.90% <0.00%> (-0.25%) ⬇️
shard-4 31.74% <0.00%> (-1.10%) ⬇️
shard-5 32.90% <0.00%> (+1.06%) ⬆️
shard-6 44.35% <39.53%> (+0.17%) ⬆️

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

Files with missing lines Coverage Δ
packages/gittensory-miner/lib/cli.js 100.00% <ø> (ø)
...ckages/gittensory-miner/lib/portfolio-queue-cli.js 93.89% <100.00%> (-3.90%) ⬇️
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@JSONbored JSONbored self-assigned this Jul 13, 2026
@JSONbored
JSONbored merged commit bbcb787 into main Jul 13, 2026
19 checks passed
@JSONbored
JSONbored deleted the wire-wip-cap-queue-next branch July 13, 2026 08:30
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 13, 2026
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.

Wire WIP-cap-aware batch claiming into the real CLI path

1 participant