# RUN — Supplier Excel-Import investigation (Phase B unpark)

- **folder:** `2026-07-12-S112-supplier-excel-import`
- **session:** S112 (2026-07-12) · **lead:** Opus 4.8 MAX (owner-choice `/model claude-opus-4-8`)
- **command:** `/fable-clone vai invest/review đề tài import excel` + "hmw cho Opus 4.8 MAX" (anh-directed)
- **mode:** HMW RUN-TRACE (≥3 task) · **engine:** fable-clone ensemble (per-invocation H21) · model=opus effort=inherit(xhigh)
- **input:** `C:\Users\pqhuy\Downloads\Data base - 1_7_2027 (3).xlsx` (scouted — 30 cột, 4 NCC, header 4-dòng, #REF! cols)
- **spec:** `spec-supplier-excel-import-12-07-2026.md`

## taskList snapshot
| Stage | Role (same-role ensemble) | Lane | Lens |
|---|---|---|---|
| Investigate | investigator-codebase | A | Column→Field mapping (30 cột → 27 field) |
| Investigate | investigator-codebase | B | Existing code + approach (lib xlsx? 3 approach tradeoff) |
| Investigate | investigator-codebase | C | Data-integrity / edge-case (dedup, parser, #REF!, NAS path) |
| Review | reviewer | 0 | Adversarial verify (0-silent-loss · dedup · approach · 27-field fidelity) |

## write-model
- N lane **RETURN-only** (fable-clone floor) → em-main **single-writer** synthesis + sub-`<role>`-`<i>`.md from returns.
- em-main stamp `[engine: fable-clone-ensemble · Opus-S112]` @harvest (1 memory entry / role).

## deliverable
Design-doc: mapping ĐỦ 30 cột → 27 field + 3 approach tradeoff + reviewer verdict → **anh quyết approach + scope**. KHÔNG code lượt này.

## synthesis (em-main single-writer — wf_e2f23a84-933, 4/4 clean, ~416K tok Opus)

> ⚠️ Sub-file naming: journal completion-order ≠ LANES order → `sub-invest-codebase-B-approach.md` HOLDS Lane C (dedup/edge) content · `sub-invest-codebase-C-edge.md` HOLDS Lane B (approach) content. Content correct, filenames swapped (harvest reads content).

**REVIEWER VERDICT: PASS_WITH_CONCERNS.** Design sound; every in-repo file:line verified KHỚP (0 fabrication); 27/27 field bijective, 0 silent loss. 1 MAJOR + 4 MINOR refine it before build.

### Load-bearing findings
1. **Schema 100% ready** — 30 Excel col → 27 field bijective (1 ignore STT, 27 direct col2-28, 2 audit-provenance col29-30 = owner-call). Mig 62's 18-field expansion purpose-built for this Excel. 0 invented field.
2. **🎁 Approach B ĐÃ SHIP** — spec "seed fills partial" is WRONG: `DbInitializer.cs:2775-2782` fills all 30 fields for the 4 NCC, prod-verified (Mig 62 `778fc98` Run #488). **This exact file's 4 NCC are already in prod.**
3. **ClosedXML 0.105 already in `SolutionErp.Infrastructure.csproj:8`** (0 new dep); read-idiom `XlsxRenderer.cs:18-25`; IFormFile plumbing in 3 controllers. NamGroup `HrEmployeeImportService` = complete upload→preview→confirm pattern to port (⚠️ MINOR: unverifiable from this env — repo ERP_MINI_FINAL absent).
4. **🔴 MAJOR (reviewer caught, all 3 lanes missed):** dedup Code = `Ordinal` (case-sensitive) vs DB unique-index default = case-INSENSITIVE collation → Approach A with case-variant Code → dict-miss → INSERT → hard unique-violation 500. **Precondition:** normalize Code (Trim+UPPER or OrdinalIgnoreCase) before dedup+store+preview.
5. **Must-knows:** import writes entity directly with fill-where-non-empty, NOT via `UpdateSupplierCommand` (blind absolute-set → NULL-clobber #73); read by absolute cell index NOT `CellsUsed()` (skips empties → drift); parser anchors r4 + fingerprint-guard; 2-pass all-or-nothing (~4-20 rows).

### 3 approach
| | Effort | Reusable | Verdict |
|---|---|---|---|
| **A upload endpoint** | MED (port NamGroup) | ✅ | best if NCC keep coming; needs MAJOR fix first |
| **B extend seed** | ~0 (ĐÃ SHIP file này) | ❌ | done for these 4 NCC; no update-sync |
| **C import-command** | MED | ~ | bỏ — cắt preview = cắt lá chắn cho Excel bẩn |

### 5 owner decisions
1. Col 29-30 (NGÀY/NGƯỜI CẬP NHẬT) → ignore / Note / +2 field Mig 63?
2. Code = col4 "TÊN VIẾT TẮT" confirmed (= mã HĐ key RG-001)?
3. Reusable tool needed? → A ; chỉ file này → B đã xong.
4. Re-import existing Code → fill-nulls (safe) vs overwrite-non-empty (updates, destructive)?
5. PHÂN LOẠI unknown value → reject-row vs default NhaCungCap?

**Harvest:** pending @closeout — em-main append 1 entry investigator-codebase + 1 reviewer, stamp `[engine: fable-clone-ensemble · Opus-S112]`.
