Skip to content

feat(mes): Week 4 — Work orders, products, schedule-aware TEEP#142

Open
Mikecranesync wants to merge 2 commits into
mainfrom
feat/mes-week4-work-orders
Open

feat(mes): Week 4 — Work orders, products, schedule-aware TEEP#142
Mikecranesync wants to merge 2 commits into
mainfrom
feat/mes-week4-work-orders

Conversation

@Mikecranesync
Copy link
Copy Markdown
Owner

Summary

  • Work order CRUD: POST, GET, GET/{id}, PATCH/{id}/status with enforced state machine (PENDING→ACTIVE→COMPLETE/CANCELLED)
  • Product management: POST /api/mes/products + GET /api/mes/products — creates SKUs with ideal_cycle_sec so OEE Performance uses the correct target rate
  • One-ACTIVE-per-line constraint enforced at the DB layer (409 on violation)
  • compute_oee() now accepts utilisation param (default 1.0 — full Week 3 backward compat); TEEP = OEE × utilisation
  • _active_utilisation() queries schedules table — returns 1.0 when no schedules exist (no regression), 0.0 when outside any shift, 1.0 when inside a shift
  • 18 new tests, zero regressions — full suite 66/66

Test plan

  • pytest tests/test_work_orders.py -v — 18/18 pass (TEEP math, CRUD, state transitions, 409 constraint, product endpoints)
  • pytest tests/ -v — 66/66 pass (no regressions against Weeks 1–3)
  • TEEP scales correctly with utilisation: 1.0 → TEEP=OEE, 0.5 → TEEP=OEE×0.5, 0.0 → TEEP=0

Closes

Closes MIRA#322

🤖 Generated with Claude Code

CharlieNode and others added 2 commits April 16, 2026 00:51
Adds OEE computation engine, 60-second tick loop, fleet endpoints:
- compute_oee() pure function: A×P×Q with clamp/rounding (PRD §10 AC#3, AC#5)
- 30-tick alert at OEE < 60% per line (OEE_ALERT_TICKS=30)
- ItemCount delta tracking from HR100 (cumulative register)
- run_time_in_window() SQL: sums RUNNING seconds in last tick window
- 4 new endpoints: /oee, /oee/history, /oee/summary, /kpis
- oee_calculator background task wired into FastAPI lifespan
- 16 new tests, zero regressions (48/48 suite)

Closes MIRA#321

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
…sts, 66 total pass)

Work order CRUD + product management:
- POST/GET /api/mes/products — create SKU with ideal_cycle_sec
- POST /api/mes/work-orders — creates PENDING; validates line + product + unique order_number
- GET /api/mes/work-orders — list with ?line_id= / ?status= filters
- GET /api/mes/work-orders/{id} — detail
- PATCH /api/mes/work-orders/{id}/status — enforced transitions (PENDING→ACTIVE→COMPLETE/CANCELLED)
- 409 when second ACTIVE work order attempted on same line

Schedule-aware TEEP:
- compute_oee() gains utilisation param (default 1.0 — Week 3 backward compat)
- TEEP = OEE × utilisation (clamped 0-1)
- _active_utilisation() queries schedules table; falls back to 1.0 when no schedules exist

18 new tests, zero regressions (66/66 suite)
Closes MIRA#322

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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