Skip to content

feat(cascades): suggest split weights from download counts (fixes #5) - #24

Open
NePreby wants to merge 8 commits into
Flow-Pulse:mainfrom
NePreby:feat/suggest-split-weights-downloads
Open

NePreby wants to merge 8 commits into
Flow-Pulse:mainfrom
NePreby:feat/suggest-split-weights-downloads

Conversation

@NePreby

@NePreby NePreby commented Nov 6, 2026

Copy link
Copy Markdown

Overview

Resolves #5 by implementing download-based proportional split weight suggestions for dependencies in the split architecture cascade.

Changes

  1. Hamilton-Hare Largest Remainder Allocator (allocateWeightsByDownloads in frontend/src/lib/manifest.ts):

    • Strictly enforces the sum of basis points to equal targetBps (default 9000, 90.00%) with zero rounding drift.
    • Guarantees each dependency receives at least minFloorBps (default 50 bps / 0.50%) when feasible, scaling down floor dynamically for large trees.
    • Allocates proportional integer quotas from unreserved basis points, sorting remainders in descending order to assign single basis points.
    • Safely handles negative / NaN downloads, empty lists, single dependencies, and zero-download fallbacks to equalWeights.
  2. Registry Download Fetchers:

    • fetchCrateDownloads(name): Queries https://crates.io/api/v1/crates/{name} -> crate.downloads.
    • fetchNpmDownloads(name): Queries https://api.npmjs.org/downloads/point/last-month/{name} -> downloads.
    • suggestDependencyWeights(deps, targetBps, minFloorBps): Queries download metrics in parallel across ecosystems.
  3. User Interface Integration (frontend/src/pages/Cascades.tsx):

    • Added Suggest weights button in the Split architecture section header aside (next to Equalize).
    • Integrated loading spinner during parallel fetching and auto-updates rows in place.
  4. Unit Tests (frontend/src/lib/__tests__/weights.test.ts):

    • 12 comprehensive test cases covering zero downloads, floor scaling, single item, remainder distribution, crates.io/npm mock parsing, and parallel suggestion integration.
    • Verified 70/70 passing tests and clean tsc -b.

Closes #5.


Bounty Payout Wallet (TRC20 USDT / TRX):
TMqmJjRgVS21NL2eFtfyHciTxvE4BqGmEv

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggest split weights from download counts

1 participant