Skip to content

feat(miner-portfolio): define PortfolioQueueManager types + pure bucketing primitives #2326

Description

@JSONbored

The miner's local queue needs a deterministic, pure data-structure layer before any enforcement logic can sit on top of it. This issue is foundation-only: types + pure functions for a bucketed, WIP-capped, cross-repo-diversified queue — no I/O, no SQLite, no wiring into a real run loop yet.

Mirror the shape of src/services/plan-dag.ts (pure PlanDag/PlanStep types + buildPlanDag/validatePlanDag/nextReadySteps free functions, no class, no side effects) for a new PortfolioQueue concept: items bucketed by repo, a per-bucket and global WIP cap, and a pure nextEligibleItems(queue, caps) selector that respects both caps and prefers under-represented repos (cross-repo diversification) using the same kind of stable-sort/min-based tie-breaking src/signals/duplicate-winner.ts already uses for cluster elections.

Deliverables

  • New packages/gittensory-engine/src/portfolio/queue.ts (or equivalent path under the new shared engine package) exporting PortfolioQueueItem, PortfolioQueue, PortfolioCaps types
  • Pure enqueueItem(queue, item), dequeueItem(queue, itemId), nextEligibleItems(queue, caps) functions — no Date.now(), no randomness, deterministic given the same input
  • Cross-repo diversification: nextEligibleItems never returns two consecutive items from the same repo bucket while another repo bucket has eligible items waiting
  • Unit tests covering: empty queue, single-repo queue at WIP cap, multi-repo diversification ordering, and a full/blocked-queue edge case
  • JSDoc header explaining this is pure bookkeeping — no enforcement decision, no write action — consistent with how plan-dag.ts documents itself as stateless

References

  • src/services/plan-dag.ts (134 lines) — the pure DAG/type pattern to mirror
  • src/signals/duplicate-winner.ts (60 lines) — the min-based deterministic election pattern to reuse for tie-breaking
  • packages/gittensory-engine/ (new shared engine package per the miner architecture skeleton)

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions