[CLAUDE] Docs: chốt Session 21 cuối (turn 1-5) — gotcha #46 + 2 memory mới + 4 agent MEMORY flush

Session 21 5-turn timeline chốt cuối (2026-05-12 0030 → 2026-05-13 1530):

| Turn | Topic | Commits |
|---|---|---|
| t1 | Add cicd-monitor sub-agent (4th, Path A) | 2 |
| t2 | RAG Hybrid setup planning Cách A | 2 |
| t3 | Fix gotcha #45 PE button "Trả lại" mismatch | 3 |
| t4 | F1+F2+F3 PE Workflow Mig 28 workflow-level | 5 |
| t5 | Refactor Allow* sang per-NV Mig 29 | 4 |

Cumulative 12 commits pushed remote `3a34831..c0af9e0`. No pending push.

**Gotcha mới #46** (`docs/gotchas.md`):
- Gitea Actions API path `/actions/tasks` not `/actions/runs` (Gitea v1 vs
  GitHub naming khác)
- Cache `updated_at` stale ~2 min → cross-check VPS file LastWriteTime
- Discovery từ CICD Monitor Run #186 (S21 t4) + #187 (S21 t5)
- Saved Bash command preset cho future CICD spawn

**2 Memory user-level mới** (`C:\Users\pqhuy\.claude\projects\D--Dropbox-CONG-VIEC-SOLUTION\memory\`):

1. `feedback_ef_migration_backfill_reorder.md` — Cross-project pattern:
   - EF auto-generated drop-then-add WRONG cho data preservation
   - Manual reorder ADD → BACKFILL SQL via migrationBuilder.Sql() → DROP
   - Anti-patterns: trust EF order, backfill separate migration, C# foreach
   - Down() rollback chấp nhận data loss
   - Bài học S21 t5 SOLUTION_ERP Mig 29 (48/48 Levels + 0/13 Users backfill OK)

2. `feedback_per_nv_permission_scope.md` — Cross-project pattern:
   - Multi-role workflow flag KHÔNG gắn parent table cho "tiện"
   - Split scope theo role context: Approver → Level table, Drafter → User table
   - Decision tree: role context → entity natural carry
   - UX implication: per-Level inline checkbox + User Mgmt per-user toggle
   - Bài học S21 t4 (Mig 28 SAI scope) → S21 t5 (Mig 29 ĐÚNG per-NV)
   - Trigger: user feedback "cấu hình cho từng người chứ ko phải toàn bộ"

**4 agent MEMORY.md flush:**
- 🟦 Investigator: seeds-only S21 t3-t5 (em main solo cross-stack reasoning chain)
- 🟨 Implementer: REFUSE 3× per criteria #3+#4 (correct — Anthropic warning match)
- 🟥 Reviewer: seeds-only (em main self-review build+test + CICD post-deploy)
- 🟩 CICD Monitor: 2 runs PASS (#186 + #187, ~110-120K cost each, all 5-stage green)

**Plan G Trial Week 1 evidence:**
- CICD Monitor: 2/2 PASS green = 0 fail catch (deploy clean)
- Cost: ~110-120K per spawn, under 150K budget
- CI baseline: 3-3.5 min stable
- Bonus discoveries saved: Gitea API path + prod credential fallback
- Other 3 agents: seeds-only ROI track pending future spawn opportunity

**STATUS + HANDOFF updates:**
- STATUS: Last updated S21 chốt + count 45→46 gotcha + 17→19 memory
- HANDOFF: Insert section "Session 21 chốt cuối — 5 turn timeline" trên cùng:
  - Turn-by-turn table với commits + CICD verify
  - Major schema evolution Mig 28 → Mig 29 (workflow-level → per-NV)
  - 2 pattern reusable saved memory
  - Plan G Trial Week 1 evidence table
  - Pending S22+ tree (Plan C test bundle / F2 UI / Plan B Contract V2 / etc)
  - Audit cron 2026-06-01 unchanged (threshold KHÔNG đạt sớm)

**MEMORY index user-level +2 entry** (memory MEMORY.md).

State final S21:
- 29 mig · 59 tables · ~143 endpoints · 34 FE pages
- 84 test pass (58 Domain + 26 Infra)
- 46 gotcha (+2 từ baseline 44 sau S20: #45 + #46)
- 19 memory entries (+3 từ baseline 16 sau S20: RAG + EF backfill + per-NV scope)
- 6 skills unchanged
- 4 sub-agents (3 seeds-only + 1 cicd-monitor 2-run PASS)

Pending: bro UAT continue. Plan C test-after bundle defer sau UAT 2-3 lần ổn.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-05-13 20:25:05 +07:00
parent c0af9e05ec
commit 3d725c42f7
7 changed files with 115 additions and 7 deletions

View File

@ -707,6 +707,46 @@ Chỗ 3 (button label `isSendBack` L205-207) đã đúng từ S17, KHÔNG đụn
- Spec Session 17: `feedback_n_stage_workflow_pattern` DEPRECATED + spec mới trong `PurchaseEvaluationWorkflowService.cs` comment L15-19
- State machine 5 trạng thái: Nháp / Đã gửi duyệt / **Trả lại (98) — Phase RIÊNG** / Từ chối / Đã duyệt
### 46. Gitea Actions API path `/tasks` not `/runs` + cache stale ~2 min (CICD Monitor S21 t4 discovery)
**Triệu chứng:** CICD Monitor sub-agent S21 t4 run đầu poll Gitea Actions runs sau push → `GET https://git.baocaogiaoduc.vn/api/v1/repos/vietreport-admin/solution-erp/actions/runs?limit=5`**404 Not Found**. Tưởng repo không có Actions enabled hoặc API endpoint sai. Debug 10 phút retry path/auth/header trước khi tìm ra đúng path.
**Root cause:** Gitea API v1 spec dùng `/actions/tasks` (NOT `/actions/runs`). Naming khác GitHub Actions API (GitHub: `/actions/runs`). Public no-auth read OK cho repo public.
**Endpoint đúng:**
```bash
GET https://git.baocaogiaoduc.vn/api/v1/repos/vietreport-admin/solution-erp/actions/tasks?limit=5
```
**Response fields:**
- `id` (task internal ID)
- `run_number` (display number Run #N)
- `head_sha` (commit triggered task)
- `status` (queued / running / success / failure / cancelled)
- `conclusion` (final state when status=success/failure)
- `created_at`, `updated_at`
- `display_title` (commit message summary)
**Match task to commit:** Filter `head_sha == $commitSha` thay vì rely on order.
**Bonus gotcha — cache stale:** `updated_at` field caches ~2 phút sau khi deploy thật xong (act_runner ghi log final, Gitea API chưa update DB ngay). Cross-check VPS file timestamps khi cần time-sensitive verify:
```powershell
ssh vietreport-vps "Get-Item C:\inetpub\solution-erp\admin\index.html | Select LastWriteTime"
ssh vietreport-vps "Get-Item C:\inetpub\solution-erp\api\SolutionErp.Api.dll | Select LastWriteTime"
```
File LastWriteTime VPS = thực sự deploy completion time (NSSM copy + IIS recycle xong).
**Phòng tránh tương lai:**
- CICD Monitor system prompt + Bash command preset đã update sang `/actions/tasks` (saved trong MEMORY S21 t4).
- Khi setup automation script với Gitea API → đọc rõ Gitea API spec v1.20+ (`https://docs.gitea.com/api/`) thay vì assume GitHub naming.
- Time-sensitive verify (vd "deploy xong chưa, có an toàn trigger task tiếp không"): KHÔNG trust API status timestamp đơn lẻ → cross với VPS file mtime hoặc curl bundle hash live.
**References:**
- CICD Monitor Run #186 (S21 t4 2026-05-13 19:13) — first discovery
- CICD Monitor Run #187 (S21 t5 2026-05-13 20:12) — confirmed pattern + cache stale bonus
- Memory `feedback_multi_agent_setup` Plan G Trial Week 1 evidence
## Checklist debug bug mới
1. Build pass không? → fail → check using + package version compat
@ -731,3 +771,4 @@ Chỗ 3 (button label `isSendBack` L205-207) đã đúng từ S17, KHÔNG đụn
20. Nếu CI vẫn trigger khi commit MD-only → paths-ignore trong on:push không match patterns đúng (#41)
21. Nếu user phàn nàn "feature work cho admin nhưng user empty/403 silent" → check class-level Authorize policy có over-restrict cho non-admin không, split per action (#44)
22. Nếu button workflow label nói "Trả lại" nhưng phiếu vẫn tiến approve → audit FE `isReject` payload condition vs button `isSendBack` label condition vs dialog `isSendBack` warning condition — phải sync 3 chỗ với CÙNG set target phase. BE thêm guard `(target ∈ terminalSet) ⇔ (decision=Reject)` chặn caller mismatch (#45)
23. Nếu Gitea Actions API trả 404 trên `/actions/runs` → đúng path là `/actions/tasks` (Gitea naming khác GitHub). Cache `updated_at` stale ~2 min → cross-check VPS file LastWriteTime cho time-sensitive verify (#46)