Retire legacy agents, add CMM optimization with LP solver#189
Open
Retire legacy agents, add CMM optimization with LP solver#189
Conversation
- Replace rglob with os.walk and exclude common non-content dirs - Add batched vectorstore inserts, skip-existing, max-chunks-per-doc - Handle oversized sentences in CMMChunker with sliding-window split - Add timeout and max-input-chars bounds for OpenAI embeddings - Fall back to per-document insert on batch failure in ChromaBM25 - Update default demo scenario to ndfeb_la_y_5pct_baseline Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace silent input coercion (_to_float, _to_fraction, _normalize_input) with strict Pydantic models that reject invalid data and return structured validation errors. Add output schema models to guarantee result structure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Standalone interactive dashboard that replicates the cmm_demo notebook visualizations without requiring Jupyter. Includes single-scenario detail views (Sankey, waterfall, capacity gauges, composition bullets) and a multi-scenario comparison tab (summary table, cost bar, risk scatter, allocation comparison). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace greedy heuristic with scipy/HiGHS LP solver as the default optimization backend, providing provably optimal allocations and shadow prices (dual values). The greedy solver remains as an automatic fallback when scipy is unavailable. - Add _lp_solver.py with linprog/HiGHS formulation and dual extraction - Add ShadowPrices model and solver_backend routing to optimization tool - Create 3 real-world NdPr oxide scenarios modeling MOFCOM 2025 controls - Update dashboard with dynamic scenario file selector and shadow price charts for both single-scenario and multi-scenario comparison views - Add 11 LP solver tests covering optimality, determinism, and duals Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The leading underscore on _scenarios_json told Streamlit to skip hashing that parameter, causing stale cached results when switching between scenario files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…and demand comparison - Add demand shadow price comparison chart to multi-scenario tab (most intuitive indicator of system tightening — always increases as supply gets tighter) - Add composition constraint shadow prices to both single and multi scenario views (reveals when blend quality, not capacity, is the bottleneck) - Switch to log scale automatically when shadow price range exceeds 100x (prevents infeasible-scenario penalties from compressing feasible-scenario bars to invisibility) - Split single-scenario capacity chart by constraint type (capacity vs share cap) with stacked bars - Add explanatory captions about zero capacity shadow prices and composition bottlenecks Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
Sorry for being slow to review this. Some things have gotten in the way. Also there is A LOT in this one PR. It would be greatly preferable to have smaller, focused PRs. One thing that I think does need changing is there are a ton of CMM focused, specific agents/tools added here. I also dont think they are all really "agents" and some may need to go other places like utils, etc. For the ones that are "agents", they should probably be in self contained folders so that they can be imported like `from ursa.agents.cmm import cmm_agent" if there are still several of them. Same with the CMM related tools. There is a lot more to review, but I wanted to put a few things out there to start. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
uv run pytest tests/tools/test_lp_solver.py tests/tools/test_cmm_supply_chain_optimization_tool.py -v— 28 tests passuv run ruff check src/ursa/tools/_lp_solver.py scripts/cmm_dashboard.py— lint cleanuv run streamlit run scripts/cmm_dashboard.py— verify both scenario files load, Nd scenarios show shadow prices, CMM demo scenarios still work🤖 Generated with Claude Code