Skip to content

Retire legacy agents, add CMM optimization with LP solver#189

Open
Redliana wants to merge 12 commits intolanl:mainfrom
Redliana:codex/retire-legacy-agents
Open

Retire legacy agents, add CMM optimization with LP solver#189
Redliana wants to merge 12 commits intolanl:mainfrom
Redliana:codex/retire-legacy-agents

Conversation

@Redliana
Copy link
Copy Markdown

@Redliana Redliana commented Feb 23, 2026

Summary

  • Retire legacy arxiv and websearch agents; modernize workflows and tests
  • Implement CMM RAG pipeline with chunking, embeddings, taxonomy, reranking, and vectorstore agents
  • Add deterministic supply-chain optimization tool with Pydantic validation and greedy heuristic
  • Add scipy/HiGHS LP solver as default optimization backend with shadow prices (dual values)
  • Create real-world NdPr oxide scenarios modeling China MOFCOM 2025 export controls (pre-shock, post-April, post-December)
  • Build Streamlit dashboard with dynamic scenario file selector, Sankey flows, capacity gauges, cost waterfall, and shadow price comparison charts

Test plan

  • uv run pytest tests/tools/test_lp_solver.py tests/tools/test_cmm_supply_chain_optimization_tool.py -v — 28 tests pass
  • uv run ruff check src/ursa/tools/_lp_solver.py scripts/cmm_dashboard.py — lint clean
  • uv 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

nmwashton and others added 10 commits February 20, 2026 09:35
- 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>
@Redliana Redliana changed the title Retire legacy agents, add CMM RAG pipeline and demo infrastructure Retire legacy agents, add CMM optimization with LP solver Feb 25, 2026
nmwashton and others added 2 commits February 24, 2026 21:21
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>
@mikegros
Copy link
Copy Markdown
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.

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.

3 participants