9 Commits

Author SHA1 Message Date
281536fd73 Merge pull request 'Add API Q1 CAPA: root cause, corrective action gate, effectiveness verification' (#1) from feature/api-q1-capa into main
Reviewed-on: #1
2026-08-04 19:52:19 +00:00
ang3l12
c1cd1bc9df Add API Q1 CAPA: root cause, corrective action gate, effectiveness verification
Implements tester feedback against API Q1 §5.9.1.2 / §6.4.2:

- Root Cause field + 6M Root Cause Category lookup (Man/Machine/Method/
  Material/Measurement/Environment), separate from Deviation Detail/Category
- "Corrective Action Required?" Yes/No gate on every NCR with a required
  justification
- Corrective action plan with owner + due date; owner is notified by email
- Effectiveness verification (result, notes, server-stamped verifier/date)
  required before an NCR can close when corrective action is required —
  costing returns 409 listing the missing pieces
- Recurring-issue flag with bidirectional NCR-to-NCR links; prior NCRs show
  a warning when later NCRs reference them
- Dashboard metrics: % root cause completed, % CAPA verified effective,
  avg CAPA close time, overdue CAPA count, NCRs by root cause category
- CAPA section in the NCR detail UI, printable PDF, CSV export, and the
  vw_ncr_full Power BI view; admin list manager for root cause categories
- Migrations 0003 (schema + seeded 6M lookup) and 0004 (view refresh);
  demo seed data exercises every metric

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-04 13:49:08 -06:00
ang3l12
8d48f774bb Use NCR business number in URLs (/ncrs/NCR-2026-0021)
Detail routes, queue navigation, and notification email links now use the
business identifier instead of the database id — friendlier for end users
quoting NCR numbers. The API resolves both forms (case-insensitive number,
or legacy numeric id) so existing bookmarks and email links keep working.
Adds regression tests incl. a guard that /ncrs/export.csv isn't shadowed
by the path parameter.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-28 11:15:16 -06:00
ang3l12
12383b2225 Fix dev user switcher tooltip covering dropdown options
The MUI Tooltip stayed anchored while the Select menu was open (the select
keeps focus) and overlapped the first user options. Use a native title
attribute instead, which browsers suppress while the popup is open.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-28 10:22:13 -06:00
ang3l12
ba6a61a5bf Fix alembic env crashing on URL-encoded password characters
Passing the DB URL through config.set_main_option() runs it through
ConfigParser, which treats '%' as interpolation syntax — so any password
character that URL-encodes to %xx ('!', '@', '#', ...) crashed migrations
('invalid interpolation syntax'). Build the engine directly from the URL
instead of routing it through the ini config.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 13:58:06 -06:00
ang3l12
45f1c56a52 Default MySQL image to mysql:8.0-debian
The Oracle Linux based mysql:8.4 image requires x86-64-v2 and fails on the
PESCO Docker host even with the Proxmox CPU type set to host. The Debian
build runs on baseline x86-64; MYSQL_IMAGE still allows overriding.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 13:54:39 -06:00
ang3l12
36ee982ca3 Make MySQL image configurable for CPUs without x86-64-v2
mysql:8.4 (Oracle Linux 9 build) aborts with 'Fatal glibc error: CPU does
not support x86-64-v2' on generic VM CPU types (kvm64/qemu64) and pre-2009
hardware. MYSQL_IMAGE env var (default mysql:8.4) lets such hosts run the
baseline-x86-64 mysql:8.0-debian build instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 13:49:50 -06:00
ang3l12
2c25fabd42 Fix MySQL init script: executable bit + scope shell options in subshell
Without the exec bit the MySQL entrypoint sources the script instead of
executing it, leaking set -euo pipefail into MySQL's own startup shell and
aborting first-time initialization (container exits -> unhealthy -> compose
dependency failure).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 13:45:27 -06:00
ang3l12
dea316b113 Initial commit: PESCO NCR system
Complete Non-Conformance Report system replacing the PowerApps/SharePoint
prototype: FastAPI + SQLAlchemy 2 (async) + Alembic + MySQL 8 backend,
React 18 + Vite + TypeScript + MUI frontend, Entra ID auth (MSAL / JWKS,
group-gated), Microsoft Graph delegated Mail.Send notifications (OBO),
six-stage workflow state machine with server-side enforcement, atomic
NCR-YYYY-NNNN numbering, attachments with camera capture, immutable
field-level audit trail, admin reopen, reports + CSV export, WeasyPrint
PDF traveler, Power BI reporting views + read-only DB user, documented
VISUAL ERP job-lookup stub, pytest suite (26 tests), docker-compose
deployment.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 11:41:22 -06:00