[CLAUDE] Docs: S97 part-2 closeout — endsBeforeCeo config→RUNTIME (Mig 60) + gotcha #78 + memory harvest

- 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>
This commit is contained in:
pqhuy1987
2026-07-01 20:16:43 +07:00
parent 8037fa01d1
commit 07c89058d7
7 changed files with 54 additions and 16 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -49,3 +49,31 @@ Mig 59 · 88 bảng · 440 test (45D+395I) · gotcha 77 · menu 54 · **bundle a
## 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.

View File

@ -1314,6 +1314,14 @@ for h in resp.points: # ← .points không phải iterable trực tiếp
**References:** `$env:TEMP\guideshots\capture.ps1` (session-scratch) · `docs/Huong-dan-Duyet-NCC.docx`. Pattern reusable user-memory `pattern_prod_screenshot_to_docx`.
### 78. Display flag suy từ CONFIG thay RUNTIME → nói dối khi instance lệch config (nặng hơn sau opt-in/opt-out flip) (Session 97)
**Triệu chứng:** Phiếu PE/2026/A/010 CEO (Bước 3) đã duyệt thật (Lịch sử duyệt 16:47) nhưng đồ 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. Anh Kiệt: "CEO duyệt ko thấy ?".
**Cơ chế:** `endsBeforeCeo` (banner "không qua CEO" + làm-mờ bước-sau) tính theo CONFIG workflow (`steps.Any(l => l.AllowApproverFinalize)` = workflow cấp finalize) luôn true nếu workflow cấp "Duyệt thay CEO", BẤT KỂ phiếu NÀY thực sự finalize hay đã lên CEO. Phiếu opt-out finalize (approver trình tiếp) lên CEO thật nhưng display suy từ config nói dối. `ComputeLevelStatus` cũng blanket "Done" mọi cấp khi DaDuyet. **Nặng lên sau S97 đảo default checkbox opt-out→opt-in**: mặc định giờ TRÌNH TIẾP CEO nhiều phiếu lên CEO bug hiện thường xuyên (fix = follow-up trực-tiếp của chính S97 default-flip).
**Fix (root-cause, Mig 60 `8037fa0`):** thêm field RUNTIME `EndedByLevelFinalize` (set true CHỈ nhánh level-finalize service) `EndsBeforeCeo` cho phiếu DaDuyet đọc runtime thay config (ChoDuyet giữ heads-up config); FE gate làm-mờ theo `endsBeforeCeo`; backfill marker "Duyệt KẾT THÚC tại". prod-verified Run #482 (PE-detail endsBeforeCeo=False live). **Quy tắc:** flag hiển-thị/trạng-thái = "instance NÀY ĐÃ làm-gì" (RUNTIME) KHÔNG "workflow THỂ làm-gì" (CONFIG); config-flag chỉ đúng khi instance không-bao-giờ-lệch-config đổi default opt-in/opt-out làm lệch phổ-biến soi lại mọi display suy-từ-config. Liên-quan `feedback_cardinality_change_grep_consumers` · `feedback_root_cause_over_symptom`.
---
## Checklist debug bug mới