- STATUS/HANDOFF S97 mega-line: +fix-3 endsBeforeCeo; State → Mig 60 / 89 tables / gotcha 78 / bundle DR9q2VUy+Bgz8u4E5 (Run #482) - gotcha #78: display-flag CONFIG-vs-RUNTIME (nói dối khi instance lệch config; nặng sau opt-in flip) - session-log Part 2: endsBeforeCeo root-cause + fix + verify (test 440 + reviewer PASS 0-issue + cicd #482 bug-fixed-LIVE) - Memory harvest: test-specialist + reviewer + cicd-monitor (#482 verdict recover từ diary — #53 return-garble lần-5, root-cause structural noted) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
80 lines
9.3 KiB
Markdown
80 lines
9.3 KiB
Markdown
# S97 — PE finalize: đổi chữ "không trình tới" + đảo default checkbox (2026-07-01)
|
||
|
||
> UAT anh Kiệt FDC (tiếp buổi live S96). 2 fix nối tiếp tính năng "Cấp KẾT THÚC quy trình" (S96 `e657faa`). **em-main-led + HMW-workflow** (implement + review). FE-only, prod-verified **Run #481**.
|
||
|
||
## Bối cảnh
|
||
Anh Kiệt gửi 2 ảnh chat Zalo về phiếu "8 MEP Sub Hệ thống solar":
|
||
1. Badge trên sơ đồ duyệt ghi "không trình tới" — sai ngữ cảnh khi phiếu lên CEO. Chốt (Huy đề xuất → Kiệt "Yeb"): đổi thành **"Kết thúc tại CCM"**.
|
||
2. Checkbox "Cấp này KẾT THÚC quy trình" đang default = tick (opt-out, S96). Anh Kiệt: *"option mặc định là không chọn; khi nào chọn mới không đẩy lên"* → đảo thành **opt-in**.
|
||
|
||
## Thay đổi
|
||
FILE (mirror 2 app, SHA-identical): `fe-{admin,user}/src/components/pe/PeWorkflowPanel.tsx`
|
||
|
||
**Fix 1 — badge wording (dòng ~329-331):**
|
||
- text `"không trình tới"` → `Kết thúc tại {evaluation.finalizeLevelName ?? evaluation.finalizeStepName ?? 'cấp trên'}` (render động → "Kết thúc tại CCM" cho workflow của họ)
|
||
- tooltip title → template-literal tương ứng (`… kết thúc tại ${finalizeLevelName …} … không cần trình tới`)
|
||
- `finalizeLevelName`/`finalizeStepName` đã có sẵn trong scope (banner dòng ~280) — no new prop/DTO
|
||
|
||
**Fix 2 — đảo default checkbox opt-out→opt-in:**
|
||
- `const [applyLevelFinalize] = useState(true)` → `useState(false)` (dòng 57)
|
||
- reset onSuccess `setApplyLevelFinalize(true)` → `(false)` (dòng 221)
|
||
- helper text ternary reword (default = "TRÌNH TIẾP lên CEO", tick = "KẾT THÚC tại cấp này")
|
||
- comment S96 "default checked" → "OPT-IN" (drift cleanup, em-main — landmine)
|
||
- Logic gửi BE (dòng 200 `approverFinalizeEligible ? applyLevelFinalize : true`) + price-picker gate (dòng 496) tự đúng theo state mới — no change
|
||
|
||
**KHÔNG đụng:** BE (service dòng 867 `if (matchingLevel.AllowApproverFinalize && applyLevelFinalize)` **tôn trọng cờ FE gửi lên**) · migration · test · file FE khác. BE param default `applyLevelFinalize=true` **giữ nguyên** (fallback caller non-FE; FE luôn POST giá trị tường minh) → zero test-churn, zero prod-risk.
|
||
|
||
## Quy trình (HMW-mode ON — anh consent "ultra-on hmw")
|
||
Workflow `wf_0e01fdba-209` (implement → review pipeline):
|
||
- 🟧 **implementer-frontend**: 8 hunk (4×2 app), SHA256 identical `bcf812fd`, build admin PASS 22s + user PASS 8s, 0 TS err. Ghi chú: MEMORY.md hit PostToolUse-hook compaction giữa-spawn (23.8→11.5KB) → archive S76-79 sang `archive/2026-H1.md` (file mới; verify nội dung không mất).
|
||
- 🟥 **reviewer**: PASS 0 issue — 4 edit đúng verbatim 2 app, comment L121 + handler L664 (`e.target.checked`) giữ nguyên (đúng), 0 BE/test/mig leak, logic non-break (default-false → không ép chọn giá chốt), TS-safe (`finalizeStepName/LevelName: string|null`).
|
||
|
||
em-main: comment-drift cleanup (2 app) + verify SHA mirror (1 hash) + commit `1c8fb6a` + push.
|
||
|
||
## Deploy verify — cicd-monitor Run #481 (byte-level #77)
|
||
- **PASS** ~5m10s (18:05:56→18:11:06). Test gate 440 green.
|
||
- JS rotate (real FE proof): admin `COYAX-yQ`→`Cf0o8dx8` · user `0MU-kb4N`→`x8rppRAK`. CSS frozen `Bbtesa6B`/`BmuPz_Dy` (#69-REFINE JSX-text+bool-only). Real-size 1.64/1.54MB (anti-SPA-trap 919b).
|
||
- **Byte-level (#77) 2 app CLEAN:** NEW `Kết thúc tại` PRESENT + helper `Mặc định: duyệt xong phiếu TRÌNH TIẾP` PRESENT · OLD `không trình tới` ABSENT + `Đã BỎ tick` ABSENT → **fix shipped byte-level; UI cũ = cache (incognito), KHÔNG phải deploy-fail.**
|
||
- Mig 59 / 88 tables frozen · smoke api+admin+eoffice 200×3 + PE-list 200 items[] valid.
|
||
- Caveat: badge-text/checkbox-default không curl-verify được (cần login + phiếu thật → anh Kiệt UAT).
|
||
|
||
## Lessons
|
||
- **#53 return-garble tái diễn LẦN-4** — cicd-monitor trả prose curate-memory ("18.7KB still above 17.1KB target…") thay deploy-verdict, DÙ instruction tường minh "return verdict NOT memory-curation prose". Recover verdict từ diary (`agent-memory/cicd-monitor/MEMORY.md` S97 #481 entry) **KHÔNG re-spawn** — theo `feedback_agent_return_garble_recover`. → instruction-fix "return-verdict" **giảm-không-100%**; recover-from-diary là đường robust.
|
||
- **BE-honors-explicit-flag** → đảo default checkbox chỉ cần sửa FE `useState` (BE param default = fallback cho caller non-FE, FE luôn POST tường minh dòng 200) → zero BE/test churn, zero prod-risk. 1 UAT-flip "tưởng to" = 4 dòng × 2 app.
|
||
- **Comment-drift** — đổi behavior phải sửa comment mô tả (S96 "default checked" nằm ngay trên `useState(false)` = landmine cho reader sau). em-main cleanup trước commit.
|
||
|
||
## State (GIỮ NGUYÊN trừ bundle)
|
||
Mig 59 · 88 bảng · 440 test (45D+395I) · gotcha 77 · menu 54 · **bundle admin `Cf0o8dx8`/user `x8rppRAK` (Run #481)** · prod 21 NCC / 17 user.
|
||
|
||
## NEXT
|
||
- 🔴 **anh:** UAT **incognito** phiếu "8 MEP Sub Hệ thống solar" — xác nhận badge "Kết thúc tại CCM" + checkbox default unchecked. (+ vụ cũ "lỗi phân quyền vào phiếu": cho **số-phiếu + user** để em soi config approver.)
|
||
- **em:** đã closeout S97. Monthly re-tier STATUS/HANDOFF mega-line vẫn pending (giờ 5-blurb S97→S93).
|
||
|
||
---
|
||
|
||
## Part 2 (cùng ngày S97) — endsBeforeCeo CONFIG→RUNTIME (bug "CEO duyệt mà bị mờ")
|
||
|
||
**Bối cảnh:** anh Kiệt hỏi phiếu PE/2026/A/010 "8 MEP Sub Hệ thống solar" — CEO (Bước 3, Nguyễn Văn Trường) đã duyệt thật (16:47:30, Lịch sử duyệt) nhưng sơ đồ quy trình báo "Phiếu đã kết thúc tại CCM Cấp 2 — không qua CEO" + làm mờ Bước 3. "CEO duyệt mà ko thấy gì?"
|
||
|
||
**Root-cause:** `endsBeforeCeo` (banner + làm-mờ bước-sau) tính 100% CONFIG (`steps.Any(l => l.AllowApproverFinalize)` = workflow CÓ cấp finalize), 0% runtime. Phan Văn Chương (Bước 2 Cấp 2, cờ "Duyệt thay CEO") chọn "Trình duyệt" (opt-out) → phiếu lên CEO thật, nhưng display suy config → nói dối. `ComputeLevelStatus` blanket "Done" mọi cấp khi DaDuyet. **Nặng lên sau fix-2 (đảo default opt-in):** mặc định giờ trình tiếp CEO → nhiều phiếu lên CEO → bug phổ biến (fix = follow-up trực-tiếp của chính fix-2). → gotcha #78.
|
||
|
||
**Fix (anh chọn "fix trọn", Mig 60 `8037fa0`):**
|
||
- Field runtime `PurchaseEvaluation.EndedByLevelFinalize` (bool default false) — set `true` CHỈ ở nhánh level-finalize `ApproveV2Async` (`PurchaseEvaluationWorkflowService.cs:871`; reviewer confirm 1/5 nhánh DaDuyet, ccm-delegation/full/drafter/V1 giữ false).
|
||
- 4 projection `EndsBeforeCeo`: phiếu DaDuyet đọc runtime field; ChoDuyet giữ config heads-up. Detail (`:1153`) + List/Inbox (ternary `Phase==DaDuyet?field:subquery`, `:647/:767`) + ListApproved (đọc thẳng field `:196`, DaDuyet-only).
|
||
- FE gate làm-mờ `finalizeFlowStep` theo `endsBeforeCeo` (2 app SHA-mirror `b7abbc2f`). Banner + PeFinalizeChip đã gate sẵn.
|
||
- Migration Mig 60 + backfill Sql (dò marker "Duyệt KẾT THÚC tại" set phiếu finalize-sớm cũ; ccm-delegation comment không match → giữ false).
|
||
|
||
**Quy trình:** em-main BE core solo (schema + 6 edit + migration — tight-coupling/prod-migration) → build slnx PASS → spawn test-specialist (test-before) + implementer-frontend (FE gate mirror) song song → reviewer double-check (anh yêu cầu) → commit → cicd.
|
||
|
||
**Verify:**
|
||
- test-specialist **440 PASS** (repro `peFinButWentCeo`: cùng config-finalize NHƯNG EndedByLevelFinalize=false → EndsBeforeCeo=false) + service #6 opt-out→CEO assert false. EF-ternary translate OK.
|
||
- reviewer **PASS 0-issue** (6 category + 6 điểm nghi vấn CONFIRMED sạch): build slnx 0w/0e · test 440 · tsc×2 exit-0 · SHA mirror `b7abbc2f` · migration 3-file + backfill marker khớp exact · EF-translate confirmed (PeDraftVisibilityTests hit ternary).
|
||
- **cicd #482 PASS — bug fixed LIVE:** Mig 60 applied prod (col EXISTS default 0, backfill=0 UAT-no-marker, sys.tables **89** pre==post no-new-table), **EF-ternary SQL-Server 200-NOT-500**, PE-detail `31faef0d` **endsBeforeCeo=False phase=7** (runtime-path chạy đúng), bundle admin `Cf0o8dx8`→`DR9q2VUy`/user `x8rppRAK`→`Bgz8u4E5`, byte-#77 `endsBeforeCeo` PRESENT.
|
||
|
||
**Lessons (thêm):**
|
||
- **gotcha #78** — display/status flag phải suy RUNTIME ("instance NÀY ĐÃ làm-gì") KHÔNG CONFIG ("workflow CÓ THỂ"); đổi default opt-in/opt-out làm lệch phổ biến → soi lại mọi config-driven display.
|
||
- **#53 return-garble lần-5** — cicd-monitor #482 lại trả memory-curation ("18.1KB need under 17.1KB, trim S79/S93 stub") thay verdict. **Root-cause structural (mới):** cicd MEMORY tự-target ~17.1KB → curate-at-return → thinking-step curate = message cuối = return. Recover từ diary (#482 entry đủ Mig60+EF-200+bundle). Fix bền = giảm áp lực curate cicd (archive sớm), KHÔNG instruction. cicd = 4/5 lần garble = kẻ tái phạm dai.
|
||
- **Fix-trọn cross-stack + migration** = em-main BE core solo (reliability) + delegate FE/tests/reviewer/cicd (parallelism) — không fan-out toàn bộ vì logic tight-coupling.
|
||
|
||
**State cuối S97:** Mig 60 · 89 bảng · 440 test · gotcha 78 · menu 54 · bundle admin `DR9q2VUy`/user `Bgz8u4E5` (Run #482) · prod 21 NCC/17 user.
|