[CLAUDE] Docs: S42-S43 close-out — Phase 11 P11-A+P11-B session log + HANDOFF tier + gotcha #56

- Session log S42-S43 (P11-A WorkflowApps ApproveV2 + P11-B LeaveBalance, 8 commit chain)
- HANDOFF tiering: +S43 +S42, trim S40-S38 → session logs
- gotcha #56 CWD-drift stray memory (cd trước spawn → agent ghi nhầm fe-user/.claude, 3× S42-S43)
- STATUS gotchas 55→56
- cicd-monitor MEMORY (Run #367 P11-B verdict)

User memory: +feedback_high_to_max_multiagent_quality (High lọt 2 bug, Max 0 bug; WIRE FE
đọc reference proven + FK-invariant-at-write-doors + Max re-review cross-stack).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-06-01 12:04:34 +07:00
parent efc5f5f657
commit 197c72f352
5 changed files with 119 additions and 44 deletions

View File

@ -2,7 +2,38 @@
> **Tiering rule (S40):** giữ **2-3 session gần nhất**. Cũ hơn → `docs/changelog/sessions/`. Full brief history pre-S40 → `docs/_archive/HANDOFF-preS40-fullhistory.md`.
**Last updated:** 2026-05-29 (Session 41 — RAG corpus cleanup w/ AI_INFRA: exclude `**/`-fix + re-bootstrap 3080→2406 + 5/5 store_memory preserved)
**Last updated:** 2026-05-30 (Session 42-43 — Phase 11 P11-A wire ApproveV2 4 WorkflowApps + P11-B LeaveBalance. Mig 41+42, 154 test, deployed prod #364-367)
---
## S43 (2026-05-30) — Phase 11 P11-B: LeaveBalance business logic
**Commit `82d7fcf` → Gitea #367 PASS, deployed prod.** Agents Max → 0 bug lọt.
**Done:**
- **Mig 42 `AddLeaveBalances`** — `LeaveBalances` (User×LeaveType×Year + Entitled/Used/Adjustment, UNIQUE composite + FK LeaveTypes Restrict). 90→91 tables.
- **Trừ phép** hook `ApproveLeaveRequestHandler` terminal DaDuyet — exactly-once (guard chặn re-approve), auto-create từ `DaysPerYear`, `UsedDays+=NumDays`, Year=StartDate.Year. Policy cho phép âm + cảnh báo.
- **FK invariant guard** Create+Update validate LeaveTypeId tồn tại → Conflict (đóng cửa tránh 500 kẹt đơn lúc deduction FK insert). grep xác nhận 2 write site duy nhất.
- **CQRS** GetMy/GetUser/Adjust (admin `[Authorize(Roles=Admin)]`) + embed balance NGƯỜI TẠO vào leave detail. **FE** block "Số dư phép" + cảnh báo vượt (kind=leave).
- **Test** 144→**154** (+11 + repair 2 template terminal FK). Reviewer Max PASS (exactly-once + FK fully closed; 2 minor defer: concurrency no-RowVersion + stale comment).
**Carry-over (chưa đụng):** `M BROADCAST-OUT...md` + `?? .mcp.json` (từ S40). · RAG S42-S43 chưa index (stopgap store_memory). · cicd flag: skill IIS path stale + agent-memory .md trigger CI.
**Next S44 (anh pick):** P11-C (Vehicle+Driver Mig 43) / P11-D (ItTicket SLA) / P11-E (AttendanceReport+Excel) / P11-F (MaTicket) · Phase 9 Ops · coord carry-over.
---
## S42 (2026-05-30) — Phase 11 P11-A: wire ApproveV2 + LevelOpinions 4 WorkflowApps + Max re-review fix
**4 commit `e7b66cd`+`75df04e`+`e47ef1d`+docs → #364-366 PASS.** 7-agent.
**Done:**
- **Mig 41 `WireWorkflowAppsApprovalV2`** — 4 `{Module}LevelOpinions` + `WorkflowAppCodeSequences` (atomic MaDonTu) + 4 RejectedFromStatus + enum TravelRequest=9. 84→89 tables. Cookie-cutter mirror Proposal (Mig 38).
- **BE** 30 handler + 8 route × 4 module (Leave/OT/Travel/Vehicle) + seed 4 WF. **FE** WorkflowAppDetailPage declarative 4-kind.
- **⚠️ Max re-review (agents High) bắt + fix 2 bug FE picker:** (#1) pinWorkflow PUT partial→400 (#2) fetch shape sai (copy nhầm ProposalCreatePage hỏng). Fix: dedicated `PUT /{id}/workflow` + fetch mirror PE/Contract. **Bonus** fix ProposalCreatePage latent S37 bug.
- **Test** +14 (ApproveV2 11 + SetWorkflow 3). 130→144.
**Lesson:** WIRE FE phải đọc reference proven (không đoán); Max re-review cross-stack bắt buộc (→ gotcha #56 CWD-drift + memory `feedback_high_to_max_multiagent_quality`). Detail → `docs/changelog/sessions/2026-05-30-S42-S43-phase11-p11a-p11b.md`.
---
@ -26,43 +57,10 @@
---
## S40 (2026-05-29) — Init + consolidation + bulletin adoption + RAG recovery
## S40-S38 (older) → session logs
**10 commit `d2f52ba..37536fd`** (all docs/infra → CI skip). KHÔNG product code/schema.
- **S40** (2026-05-29) init audit 10-mục + doc consolidation (STATUS/HANDOFF 393KB→9KB zero-loss archive) + AI_INFRA bulletin adopt 4/4 (Tiered Memory v1 + /session-start /session-end slash commands LIVE) + RAG MCP recovery (quit+relaunch FRESH). **Concurrency carry-over** (BROADCAST 2 + `.mcp.json`) bắt nguồn đây — vẫn chưa đụng (xem S43).
- **S39** (2026-05-29) infra: Opus 4.8 1M + multi-agent split 4→7 (+investigator/implementer split +test-specialist) + budget +50% + gotcha #54/#55.
- **S38** (2026-05-28) 🎊 Phase 10 COMPLETE 11/11 — Mig 39+40 skeleton combo (Đơn từ/Đặt xe/Ticket/Chấm công/Dashboard NS). ApproveV2+LevelOpinions+LeaveBalance DEFER Phase 11 (→ làm xong S42-S43).
**Done:**
-**Init audit 10-mục** — 7-agent live, RAG re-rank PASS, 130 test confirm, state re-grounded từ code.
-**Doc consolidation** — STATUS 170KB→5.7KB + HANDOFF 224KB→3.4KB (393KB→9KB, full archive `docs/_archive/` zero-loss). Count re-ground: endpoints **211**, FE pages **65** (36+29), menu **~53**, **tables 84 đúng** (DbSet 77 + Identity 7). CLAUDE.md root patch.
-**Curate 4 agent MEMORY** >25KB→<8.4KB (foundation preserved + git verbatim `d2f52ba`).
- **AI_INFRA bulletin 2026-05-29 adopt 4/4:** MỤC1 charter v2 ack · MỤC2 **Tiered Memory Policy v1** (L1 HOT ~30KB / L2 archive / L3 RAG, bỏ hard 25KB) · MỤC3 **/session-start + /session-end slash command LIVE** · MỤC4 RAG v1.3 compliant + rag.json extra_corpus slug BUG FIX.
- **Broadcast AI_INFRA** (adoption + infra retrospective + 5 đề xuất) file `docs/governance/BROADCAST-OUT-*` + RAG `store_memory` (rerank 0.91-0.96 cross-project discoverable).
** NEW slash command LIVE:** `/session-start` + `/session-end` (`.claude/commands/`) dùng thay paste prompt thủ công.
** RAG MCP outage S40:** máy treo full C MCP rớt nhiều lần. Recovery: **quit hẳn + relaunch FRESH + approve trust `.mcp.json`** (KHÔNG resume cached config). server.py/env/key/Qdrant verified healthy (lỗi thuần Claude Code client). Memory `[[rag-mcp-recovery-and-concurrency]]`.
** CONCURRENCY CHƯA giải quyết:** session SE **thứ 2 chạy song song** S40 append "BROADCAST 2" vào `docs/governance/BROADCAST-OUT-SOLUTION-ERP-2026-05-29.md` (**UNCOMMITTED**, M trong git) + `.mcp.json` untracked. Anh main quyết: commit chung / để session kia tự / gộp dup. **TRÁNH 2 session SE cùng sửa repo.**
** Standing items đã broadcast cho AI_INFRA (infra op):** re-index SE (path fix 27 memory entries + S38-S40 content) · registry sync · verify auto_reindex hook (last_indexed lag) · **search_code corpus gap** (chỉ index .md, thiếu src/*.cs + fe/*.tsx) · chunk 512 trial 2026-06-16.
**Next S41 (anh main pick) — FOCUS PRODUCT:**
1. **Phase 11 P11-A** wire ApproveV2 + LevelOpinions 4 module (full 5-agent end-to-end)
2. **Test coverage gaps** 🟪 test-specialist Gap1 (Holiday UNIQUE CRITICAL) + Gap3 (gotcha #44 ~50 LOC)
3. **Phase 9 Ops** (anh main coordinate: SMTP + rotate creds + UAT)
4. (coord) Giải quyết concurrency: BROADCAST 2 uncommitted + `.mcp.json` untracked
---
## S39 (2026-05-29) — ⚙️ INFRA: Opus 4.8 1M + Multi-agent 4→7 + budget +50%
Pure infra/governance, 1 commit `fd0554a` (docs CI skip). 7 agent: 🟦 investigator-codebase (internal SQL/EF/grep) + 🟦 investigator-api (external docs/CVE/lib) + 🟨 implementer-backend (.NET) + 🟧 implementer-frontend (FE 2 app) + 🟪 test-specialist (tests/) + 🟥 reviewer + 🟩 cicd-monitor. `model: inherit` (Opus 4.8 1M). 5 RAG MCP/agent. Skill re-distribute (README matrix). 2 gotcha NEW: **#54** (529 Overload spawn fail em main solo fallback) + **#55** (truncation mid-exploration brief 8K + pre-supply snippet).
detail `docs/changelog/sessions/2026-05-29-S36-S39-phase10-complete-7agent.md`
## S38 (2026-05-28) — 🎊 PHASE 10 COMPLETE 11/11
Mig 39+40 + BE ~1100 LOC mega + FE 5 file × 2 app SHA256 IDENTICAL + 8 menu. Run #247 PASS 3m25s. G-O4 Đơn từ + G-O5 Đặt xe + G-O6 Ticket CNTT + G-P1 Chấm công + G-H3 Dashboard NS (SKELETON combo). Trade-off commit: ApproveV2 advance level + LevelOpinions + LeaveBalance + CodeGen atomic + Vehicle/Driver catalog + auto-assign/SLA **DEFER Phase 11**. NEW prod: sidebar Văn phòng số 11 sub-menu + Nhân sự Dashboard + GPS check-in + ticket kanban.
same session log
---
> **Older S37→S6:** per-session logs đầy đủ trong `docs/changelog/sessions/` + `docs/_archive/HANDOFF-preS40-fullhistory.md`.
Detail đầy đủ → `docs/changelog/sessions/` + `docs/_archive/HANDOFF-preS40-fullhistory.md`.

View File

@ -17,7 +17,7 @@
| FE pages | **67** | WorkflowAppDetailPage (admin+user SHA256 identical) |
| Menu keys | **~53** | BE `MenuKeys` const (FE menuKeys.ts mirror 54) |
| Tests | **154 PASS** | 58 Domain + 96 Infra · 0 fail / 0 skip · +11 LeaveBalance/guard S43 |
| Gotchas | **55** | `docs/gotchas.md` (latest #54 529-fallback, #55 truncation-mid-exploration) |
| Gotchas | **56** | `docs/gotchas.md` (latest #56 CWD-drift stray memory S42-43) |
| User memory | 27 | + `MEMORY.md` index |
| Skills | 6 | 3 domain + 3 ops |
| Sub-agents | **7** | Opus 4.8 1M (S39 split 4→7) |

View File

@ -0,0 +1,60 @@
# Session S42-S43 — 2026-05-30 — Phase 11 P11-A + P11-B (WorkflowApps ApproveV2 + LeaveBalance)
> 7-agent end-to-end. S42 P11-A wire + Max re-review fix. S43 P11-B LeaveBalance. Agents upgrade High→Max giữa S42-S43 → chất lượng cải thiện rõ rệt.
## Commit chain (8)
| SHA | Scope | Gitea |
|---|---|---|
| `e7b66cd` | P11-A wire ApproveV2 + LevelOpinions 4 module + Mig 41 | #364 PASS |
| `75df04e` | P11-A fix 2 bug picker (Max re-review) + SetWorkflow endpoint | #365 PASS |
| `e47ef1d` | ProposalCreatePage workflow dropdown shape (latent S37 bug, chip task) | (range) |
| `ffb2062`+`0db5e1f` | Docs STATUS reconcile P11-A | CI-skip |
| `82d7fcf` | P11-B LeaveBalance + Mig 42 | #367 PASS |
| `efc5f5f` | Docs STATUS P11-B | CI-skip |
## S42 — P11-A: wire ApproveV2 + LevelOpinions 4 WorkflowApps module
**Reference:** Proposal (Mig 38) = mirror 1:1 (cùng namespace Office, cùng WorkflowAppStatus 5-state) — tốt hơn PE/Contract.
**Schema (Mig 41 `WireWorkflowAppsApprovalV2`):** +4 `{Leave,Ot,Travel,Vehicle}LevelOpinions` (UNIQUE composite + Cascade parent + Restrict Level) + `WorkflowAppCodeSequences` (shared atomic MaDonTu — gộp P11-F cho 4 module) + 4 cột `RejectedFromStatus` + enum `TravelRequest=9`. 84→89 tables.
**BE:** 30 handler (GetById/Update/Submit/Approve-UPSERT-advance/Reject/Return) × 4 module + 8 controller route + seed 4 WF mẫu (QT-NP/OT/CT/XE-V2-001, AppType 5/6/7/9). ItTicket KHÔNG đụng (kanban).
**FE:** `WorkflowAppDetailPage.tsx` declarative 4-kind (admin+user SHA256 identical) — status + opinion timeline + Submit/Approve/Reject/Return.
**⚠️ Max re-review phát hiện 2 BUG FE picker (agents chạy High để lọt):**
1. `pinWorkflow` PUT `/{id}` chỉ gửi `{approvalWorkflowId}` → UpdateDraft validator (Reason/NumDays) fail → 400.
2. fetch workflow expect flat array nhưng endpoint trả `AwAdminOverviewDto {types:[...]}` → picker rỗng/crash. Agent copy nhầm pattern hỏng `ProposalCreatePage` thay vì proven PE/Contract.
**Fix:** dedicated endpoint `PUT /{id}/workflow` (set workflow only, verify ApplicableType) + fetch mirror `data.types.find(t=>applicableType===X)?.history.filter(isUserSelectable)`. **Bonus:** ProposalCreatePage có bug #2 có sẵn từ S37 (latent) → chip task `e47ef1d`.
**Test:** +11 ApproveV2 + +3 SetWorkflow. Auth-verified prod dropdown shape thật.
## S43 — P11-B: LeaveBalance business logic
**Decision (anh main chốt):** (1) số dư không đủ → **cho phép + cảnh báo** (âm OK) · (2) FE **tích hợp trang đơn nghỉ** (không trang riêng).
**Schema (Mig 42 `AddLeaveBalances`):** `LeaveBalances` (User×LeaveType×Year + Entitled/Used/Adjustment, UNIQUE composite + FK LeaveTypes Restrict, decimal 5,2). Remaining = Entitled+AdjustmentUsed (computed). 90→91 tables.
**Trừ phép:** hook `ApproveLeaveRequestHandler` nhánh terminal DaDuyet — **exactly-once** (guard Status!=DaGuiDuyet chặn re-approve), upsert auto-create từ DaysPerYear, UsedDays+=NumDays, Year=StartDate.Year.
**FK invariant guard (em Max-review thêm sau test reveal):** Create + UpdateDraft validate LeaveTypeId tồn tại → ConflictException. Đóng cửa hẳn (grep xác nhận 2 write site duy nhất) → bogus type không thể tới deduction FK insert (tránh 500 kẹt đơn).
**CQRS:** GetMy (self lazy-merge active LeaveType) + GetUser (admin) + Adjust (admin upsert). Embed balance NGƯỜI TẠO vào leave detail DTO (approver xem đúng — KHÔNG dùng /my = viewer).
**FE:** block "Số dư phép" + cảnh báo vượt (kind=leave, SHA256 identical).
**Test:** +11 (deduction single/multi-level/accumulate/negative/reject-return-no-deduct + lazy-merge + adjust + Create guard) + repair 2 template terminal FK-fail. 130→**154 PASS**.
## Lessons (→ gotcha/memory)
- **High→Max upgrade tác động lớn:** P11-A High → truncate 3× + lọt 2 FE bug + 1 sai run-id. P11-B Max → 0 truncate, test-specialist tự tìm FK risk, reviewer thorough no-truncate, 0 bug lọt. → memory `feedback_high_to_max_multiagent_quality`.
- **WIRE FE phải đọc reference proven (không đoán):** 2 bug P11-A do agent đoán endpoint/shape. Brief FE agent BẮT BUỘC chỉ file reference proven cụ thể.
- **FK-invariant-at-write-doors pattern:** thêm deduction/insert có FK → enforce FK validity tại MỌI write door (Create+Update), không assume. Test reveal gap.
- **Gotcha #56 CWD-drift stray memory:** `cd` trước spawn → agent ghi MEMORY nhầm `fe-user/.claude`. 3× recover.
## State cuối
42 mig · 91 tables · ~241 endpoint · 67 FE page · **154 test** · 56 gotcha · bundle `Krjvg_3j`/`6sNStgxa`. Phase 11: P11-A + P11-B DONE. Next: P11-C..F.
## Carry-over (chưa đụng)
- `M docs/governance/BROADCAST-OUT-...-2026-05-29.md` + `?? .mcp.json` (untracked) — anh main quyết (từ S40).
- RAG `solution_erp` last_indexed S41 (2407 chunks) — S42-S43 content chưa index, stopgap store_memory. Flag AI_INFRA re-index.
- cicd flag: skill `iis-deploy-runbook` IIS path stale · `.claude/agent-memory/**/*.md` không trong paths-ignore (memory commit trigger CI).

View File

@ -1029,6 +1029,21 @@ for h in resp.points: # ← .points không phải iterable trực tiếp
---
### 56. Sub-agent ghi MEMORY nhầm path do CWD drift (Session 42-43 × 3 occurrence)
**Triệu chứng:** Sau khi em main `cd fe-user` (PowerShell npm build) rồi spawn agent trong CÙNG message → agent (test-specialist S42, reviewer + cicd-monitor S43) ghi MEMORY vào `fe-user/.claude/agent-memory/<name>/` thay vì root `.claude/agent-memory/<name>/`. Agent KHÔNG thấy root MEMORY (CWD=fe-user) → viết lại minimal from scratch (mất history L1). Stray `?? fe-user/.claude/` untracked, dễ commit nhầm.
**Root cause:** Agent relative-path resolution dùng CWD shell hiện tại (đã drift sang fe-user do `cd` trước đó — PowerShell CWD persist cross-call). Path memory relative `.claude/...` → resolve sai gốc.
**Mitigation:**
- KHÔNG `cd` (đặc biệt PowerShell) TRƯỚC khi spawn agent. Dùng absolute path / `dotnet --project` / `git -C` / `npm --prefix` thay `cd`.
- Em main recovery: đọc stray → merge entry mới vào root MEMORY (append Recent activity) → `rm -rf fe-user/.claude` → KHÔNG stage stray.
- Stage chọn lọc (`git add <path cụ thể>`, KHÔNG `-A`) để stray + carry-over không lọt commit.
**References:** S42 test-specialist + S43 reviewer/cicd-monitor — cùng pattern, 3× recover thủ công.
---
## Checklist debug bug mới
1. Build pass không? → fail → check using + package version compat