Skip to content

Map addition limits by ProcessID rather than AssetRef - #1495

Open
tsmbland wants to merge 5 commits into
mainfrom
process_addition_limits
Open

Map addition limits by ProcessID rather than AssetRef#1495
tsmbland wants to merge 5 commits into
mainfrom
process_addition_limits

Conversation

@tsmbland

@tsmbland tsmbland commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

Description

I think it's a bit clearer to make the addition limits map HashMap<ProcessID, Capacity> rather than HashMap<AssetRef, Capacity>, and this will also be more consistent with the eventual implementation for total capacity limits.

Also changed some function/argument/variable names for clarity

Fixes # (issue)

Type of change

  • Bug fix (non-breaking change to fix an issue)
  • New feature (non-breaking change to add functionality)
  • Refactoring (non-breaking, non-functional change to improve maintainability)
  • Optimization (non-breaking change to speed up the code)
  • Breaking change (whatever its nature)
  • Documentation (improve or add documentation)

Key checklist

  • All tests pass: $ cargo test
  • The documentation builds and looks OK: $ cargo doc
  • Update release notes for the latest release if this PR adds a new feature or fixes a bug
    present in the previous release

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.29%. Comparing base (be7d3ba) to head (012783d).

Files with missing lines Patch % Lines
src/simulation/investment.rs 96.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1495      +/-   ##
==========================================
+ Coverage   90.26%   90.29%   +0.03%     
==========================================
  Files          60       60              
  Lines        8614     8645      +31     
  Branches     8614     8645      +31     
==========================================
+ Hits         7775     7806      +31     
  Misses        525      525              
  Partials      314      314              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tsmbland tsmbland changed the title Make addition limits map process-level Map addition limits by ProcessID rather than AssetRef Aug 19, 2026
@tsmbland
tsmbland marked this pull request as ready for review August 19, 2026 12:40
Copilot AI lite review requested due to automatic review settings August 19, 2026 12:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors how investment/addition limits are tracked during asset selection by mapping limits per ProcessID instead of per AssetRef, aligning the selection logic with process-level constraints and simplifying downstream usage.

Changes:

  • Replace candidate investment limit tracking (HashMap<AssetRef, Capacity>) with agent-scaled process addition limits (HashMap<ProcessID, Capacity>).
  • Add Process::agent_addition_limit(...) and update market/investment selection flows to use it.
  • Rename selection-state variables/functions to reflect “retention” and “addition limits” semantics more clearly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/simulation/market.rs Computes agent-scaled process addition limits from agent search space; updates cycle logic to use Process::agent_addition_limit; updates tests.
src/simulation/investment.rs Threads HashMap<ProcessID, Capacity> through selection; updates limit enforcement and selection-state bookkeeping names.
src/process.rs Introduces agent_addition_limit helper on Process to compute portion-scaled addition limits.
src/asset.rs Removes asset-level max_installable_capacity in favour of process-level limit calculation; removes related unit test.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/simulation/market.rs
Comment thread src/simulation/investment.rs
tsmbland and others added 2 commits August 19, 2026 13:44
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

@AdrianDAlessandro AdrianDAlessandro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all makes sense. I'll have to change what I've done is #1496 to match it, but this approach is better, so I'll build from here.

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.

4 participants