# Session 51 (2026-06-08) — P11-C Vehicle+Driver catalogs + gotcha #57 ext

> HMW-mode ON · product feature · deployed prod. Commit `30a99aa` → Gitea Run #371 PASS ~4m18s.

## Bối cảnh
- `/session-start` bootstrap → **RAG/Qdrant DOWN** phát hiện ngay (search_memory `ConnectError 127.0.0.1:6333`; `rag-infra.ps1 -Action ensure` = AI_INFRA-repo op). Anh chọn "bỏ qua, làm product" → chạy file-based fallback cả session (ground-truth on-disk còn đáng tin hơn RAG index stale 05-29).
- Anh chọn task **P11-C Vehicle+Driver** + `/ultra-on` (HMW consent) + "làm đi / chạy luôn cho nhanh".

## Quy trình HMW (7-agent fan-out)
1. **Recon** — investigator background treo lâu → em main fallback tự recon on-disk: HrmConfigs = 4 catalog RIÊNG (LeaveType/Holiday/ShiftPattern/OtPolicy), KHÔNG discriminated; FE `:kind`-driven KIND_CONFIG Record. `TestApplicationDbContext` inherit `ApplicationDbContext` → +DbSet không cần sửa tests/. `VehicleBooking` free-text (VehicleLicense/VehicleName/DriverName), comment "defer catalog Phase 11".
2. **Schema chốt (em main solo)** — Mig 44: Vehicle {Code/Name/LicensePlate/SeatCount} + Driver {Code/Name/PhoneNumber/LicenseNumber/LicenseClass}, filtered-unique Code **từ đầu** (tránh gotcha #57).
3. **Wave 1 parallel (file-disjoint):** 🟨 implementer-backend (Mig 44 + 2 entity + 2 config + DbSet + HrmConfigFeatures Region 5/6 + Controller +2 route + MenuKeys + DbInitializer seed) ∥ 🟧 implementer-frontend (KIND_CONFIG +2 + 4-place mirror ×2 app, SHA256 identical). Build 0 err.
4. **gotcha #57 bundled (Mig 45):** test-specialist test-before → **2 RED observed** (LeaveType+ShiftPattern bare `.IsUnique()` → `SQLite Error 19`). Em main grep TOÀN BỘ config → **OtPolicy cũng bare** (bị bỏ sót khỏi backlog "2 catalog"!) → fix cả **3** config + Mig 45 + thêm OtPolicy test. 181→**186** all GREEN.
5. **🟥 reviewer (pre-commit) caught 1 MAJOR:** Driver FE↔BE required-field mismatch — FE render phoneNumber/licenseNumber/licenseClass OPTIONAL nhưng BE validator `NotEmpty()` + EF `.IsRequired()` NOT NULL → empty submit 400/500. Root = **inconsistent em-main brief** (BE "mirror Vehicle"=required vs FE spec quên required). Fix: FE +`required:true` (align all-required như Vehicle). Other cats clean.
6. **Commit `30a99aa` + push → 🟩 cicd Run #371 PASS.**

## Kết quả (verified prod)
- Mig 44+45 trong `__EFMigrationsHistory`; Vehicles+Drivers tables EXIST; tables 91→**92** (cicd `sys.tables` ground-truth — narrative "93" = +1 drift cũ).
- **gotcha #57 proof:** 5 `IX_*_Code` filtered `([IsDeleted]=(0))` (Vehicle/Driver/LeaveType/Shift/OtPolicy) — 3 HRM was NULL pre-Mig 45.
- Bundle rotate admin `DPPTx2Kw→Cg9mvltU` / user `CjoUEsoV→YgqDvsqr`. Smoke 200; /hrm-configs/{vehicles,drivers} 401 unauth + 200 authed (2 seed each).
- Test 186 (58 Domain + 128 Infra).

## gotcha #57 EXTENSION (→ worktree session)
Investigator audit (completed before kill, MEMORY line 73): **FIX 3 Master** (Department/Supplier/Project — confirmed-reachable: global `HasQueryFilter(!IsDeleted)` auto-ẩn soft-deleted khỏi Create check → check PASS → unfiltered index 500; nghịch lý global filter LÀM lộ bug). **SKIP 3**: ContractClause (no CRUD handler), MeetingRoom (Delete=IsActive not IsDeleted), EmployeeProfile (Create chặn reuse "Cần khôi phục"). **Mig 46 = 3 idx.** Anh click chip → spawn worktree session riêng (isolated) own task này; main session bỏ ext (tránh Mig 46 conflict).

## Lessons
- **Parallel fan-out contract risk:** BE∥FE file-disjoint chạy độc lập theo brief → bất kỳ inconsistency trong SHARED em-main contract chỉ lộ lúc integration. Green tests ≠ correct contract (no test chạm empty-optional path). reviewer = the net (caught it). Brief cross-stack PHẢI nhất quán required/optional 2 đầu.
- **Thoroughness grep > backlog trust:** backlog ghi "2 catalog" nhưng grep toàn bộ ra 3 (OtPolicy sót). Đừng tin count backlog — verify từ code.
- **Truncation recurrence (gotcha #53):** BE return + reviewer return + (audit) đều truncate cuối → em main ground-truth on-disk (git status/diff + read) + proxy reviewer MEMORY.
- **cicd anti-pattern #3:** transient mid-deploy bundle hash (CVbyotwa/BBlyMlJH) — KHÔNG trust tới status=success.
- **RAG MCP client reconnect ≠ Qdrant up:** client lên lại nhưng backend down → vẫn ConnectError.

## Tags
`[s51, p11-c, mig44, mig45, vehicle-driver, gotcha57, hmw-fanout, contract-mismatch-catch, rag-down]`
