- fix-4 badge (đối xứng fix-3 endsBeforeCeo): PeFinalizeChip DaDuyet+!endsBeforeCeo → "✅ Đã được CEO duyệt" - STATUS/HANDOFF: bundle CeTA7Z82+CGaAyXen (Run #483), 3-fix→4-fix, session-log Part 3 - Memory harvest: implementer-frontend + cicd-monitor (#483 verdict clean-return, no #53 garble lần này) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
11 KiB
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":
- 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".
- 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 sangarchive/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· user0MU-kb4N→x8rppRAK. CSS frozenBbtesa6B/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ạiPRESENT + helperMặc định: duyệt xong phiếu TRÌNH TIẾPPRESENT · OLDkhông trình tớiABSENT +Đã BỎ tickABSENT → 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.mdS97 #481 entry) KHÔNG re-spawn — theofeedback_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) — settrueCHỈ ở nhánh level-finalizeApproveV2Async(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 (ternaryPhase==DaDuyet?field:subquery,:647/:767) + ListApproved (đọc thẳng field:196, DaDuyet-only). - FE gate làm-mờ
finalizeFlowSteptheoendsBeforeCeo(2 app SHA-mirrorb7abbc2f). 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
31faef0dendsBeforeCeo=False phase=7 (runtime-path chạy đúng), bundle adminCf0o8dx8→DR9q2VUy/userx8rppRAK→Bgz8u4E5, byte-#77endsBeforeCeoPRESENT.
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 sau Part 2: Mig 60 · 89 bảng · 440 test · gotcha 78 · menu 54 · bundle admin DR9q2VUy/user Bgz8u4E5 (Run #482) · prod 21 NCC/17 user.
Part 3 (cùng ngày S97) — badge "✅ Đã được CEO duyệt" (đối xứng fix-3)
Yêu cầu (anh Kiệt): "những cái nào đã đc CEO duyệt thì hiện luôn là đã đc CEO duyệt" — sau khi fix-3 làm sơ đồ hiện đúng CEO đã duyệt, anh muốn badge ở DANH SÁCH để nắm ngay không cần mở phiếu.
Fix (FE-only, 9e12e80 #483): mở rộng PeFinalizeChip.tsx (single-source-of-truth pill dùng ở mọi danh sách) — thêm prop phase?: number + nhánh: !endsBeforeCeo && phase===DaDuyet → emerald badge "✅ Đã được CEO duyệt"; giữ violet "⚑ Kết thúc · X" cho endsBeforeCeo=true. Wire phase={p.phase} ở 6 call-site (PeListPanel + PurchaseEvaluationsListPage ×2 app + InboxPage + UserDashboardPage user). Mirror 2-app SHA da9c3ed9.
"Miễn phí" về dữ liệu: badge = cách đọc khác của cùng cờ endsBeforeCeo đã fix runtime-đúng ở fix-3 → 0 BE/migration/field mới. Lợi tức của fix root-cause đúng.
Verify: implementer-frontend build ×2 PASS 0-TS-err (bắt PeListItem.phase: number → prop phase?: number không narrow-union, gotcha type-plumbing) + SHA mirror. cicd #483 PASS: bundle admin CeTA7Z82/user CGaAyXen, byte-#77 "Đã được CEO duyệt" PRESENT cả 2 app + prev-badge additive, Mig 60 frozen, smoke 200×3 + PE-list 200.
State cuối S97: Mig 60 · 89 bảng · 440 test · gotcha 78 · menu 54 · bundle admin CeTA7Z82/user CGaAyXen (Run #483) · prod 21 NCC/17 user. 4 fix PE (badge-wording + default-flip + endsBeforeCeo-runtime + CEO-duyệt-badge).