Skip to content

Phase 1: Correctness, units, CI, rename, polish#1

Open
Gavand1969 wants to merge 1 commit into
mainfrom
fixes-and-polish
Open

Phase 1: Correctness, units, CI, rename, polish#1
Gavand1969 wants to merge 1 commit into
mainfrom
fixes-and-polish

Conversation

@Gavand1969

Copy link
Copy Markdown
Owner

This PR addresses every issue from the code review.

Correctness fixes

  • solve_base_stock: removed dead fill_rate line and corrected the Type-II formula. Was 1 - E_B * D / D which is dimensionally wrong; now 1 - E[B per cycle] / mu_L.
  • Inventory lead-time units: the previous sigma_L = sigma_d * sqrt(L) mixed years (L) and daily sigma. Standardized everything to days, with lead_time_days in the API. Internal: mu_L = (D/365) * L_days.
  • Little's Law check: was raw abs(L - lam*W) which is meaningless at high rho. Now a relative residual |L - lam W| / max(|L|, 1).
  • Simulation warm-up: fixed off-by-one (was resetting at last warmup customer, not first measurement customer). Raised default warmup from 10% to max(100, N/5).
  • Production CORS: ALLOWED_ORIGIN is now required when ENVIRONMENT=production. Loud failure instead of silent empty list.

Engineering polish

  • Cached anthropic.AsyncAnthropic at module level instead of per-request.
  • Added pyproject.toml with ruff + mypy + pytest config.
  • Added .github/workflows/ci.yml so the test badge in README actually works.

Renames

  • Sim2Real -> Sim2Sim everywhere (README, page title, hero, brand, docstrings, CSS, JS).

Tests

  • Was 57 tests passing, now 64 passing.
  • Added test classes for reorder-point and base-stock covering: basic formulas, monotonicity in service level, zero-variability edge case, fill-rate range invariant.

All tests green locally.

- Rename Sim2Real -> Sim2Sim across README, page, hero, docstrings, CSS, JS
- Add GitHub Actions CI workflow (fixes broken badge)
- Fix solve_base_stock dead code; correct Type-II fill-rate formula
  (1 - E[B per cycle] / mu_L, not E_B * D / D)
- Standardize inventory lead-time to DAYS everywhere
  (lead_time_days param; sigma_L = sigma_d * sqrt(L_days)) for unit consistency
- Add _little_law_residual: relative Little's Law diagnostic instead of absolute
- Simulation: fix warm-up off-by-one; raise default warmup to max(100, N/5)
- Production CORS: require ALLOWED_ORIGIN (fail loudly on empty)
- Cache Anthropic client lazily at module level
- Add pyproject.toml with ruff + mypy + pytest config
- README polish: live demo placeholder, screenshot, monetization note
- Add 7 new tests for reorder-point and base-stock (57 -> 64 passing)
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.

1 participant