[CLAUDE] Docs+Skill: chốt session 6 — 3 skill refresh + 2 rule audit định kỳ

Pure docs work — 0 thay đổi code/test. 77 test vẫn pass (Domain 54 + Infra 23).

3 skill refresh stale (audit định kỳ §6.4 + §9.4 phát hiện):
- form-engine: "Phase 2 MVP missing PDF + form builder" → "Tier 3 feature-complete"
  + bỏ section duplicate "Gen mã HĐ chưa implement" (đã DONE Phase 3+6)
- permission-matrix: 12 menu cũ → ~60 menu key (Bg_*/Pe_*/PeWf_*/Catalogs)
  + inheritance roots 4 group + Budgets KHÔNG inherit (gotcha #35)
- ef-core-migration: "24 DbSet" → "52 bảng (15 migration)"

2 rule mới chốt:
- rules.md §6.4 — Audit + compact MD định kỳ (cadence + checklist + anti-pattern)
  Triết lý: KHÔNG rewrite toàn bộ. Compact + patch drift.
  Cron solution-erp-skill-audit-monthly mở rộng scope (skill + doc drift combined)
- rules.md §9.4 mở rộng cross-ref §6.4

Update STATUS Session 7+ priority + HANDOFF cảnh báo session 7 + migration-todos
Phase 9 Session 6 done sub.

Cron 2026-05-01 fire mai → combined audit theo checklist §6.4 + §9.4.

Session log đầy đủ: docs/changelog/sessions/2026-04-30-chot-session-6-md-audit-compact.md

Commit MD-only → CI skip (path filter gotcha #41).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-04-30 01:18:51 +07:00
parent f24acb699a
commit 2abbc1d867
9 changed files with 319 additions and 102 deletions

View File

@ -1,8 +1,17 @@
# HANDOFF — Brief 5 phút cho session tiếp theo
**Last updated:** 2026-04-29 tối (Phase 8 — **Budget complete + PE feature gap đóng + Tests Phase 1-2-3mini (77 test) + CI gate + Path filter + 3 gotcha CI mới (#39 #40 #41)**)
**Last updated:** 2026-04-30 (Session 6 — **MD audit + compact -288 dòng + 3 skill refresh + 2 rule mới timing test + audit định kỳ**)
## TL;DR
## TL;DR Session 6 (30/04 — không code, chỉ docs)
**Output session 6** — pure docs work, không thay đổi code/test:
-**Compact 3 file core**: STATUS -27%, HANDOFF -32%, migration-todos -35% (-288 dòng tổng). Archive 51 row Recently Done Phase 0-7 → `changelog/recently-done-archive-2026-04.md`.
-**Refresh 3 skill stale**: `form-engine` (Phase 2 MVP → Tier 3 feature-complete), `permission-matrix` (12 menu → ~60 + inheritance roots), `ef-core-migration` (24 DbSet → 52 bảng).
-**Rule mới §7 Timing test**: 1 bảng 5-row compact — feature mới = test-after, bug = test-before, critical algorithm = test-before, spec change = update test cũ, skip 5 loại.
-**Rule mới §6.4 Audit + compact MD định kỳ**: cadence + checklist + anti-pattern. Cross-ref §9.4 skill audit. KHÔNG rewrite toàn bộ.
-**77 test vẫn pass** (Domain 54 + Infra 23). 0 thay đổi code.
-**Cron 2026-05-01 fire mai** — combined audit (skill + doc drift) theo §6.4 + §9.4.
**Session 5 (29/04)** đóng gần hết feature gap + bật test gate:
@ -44,21 +53,17 @@
- ⏸️ **npm junction cache** — thử ở #111 fail `tsc not found`, rollback. Cần debug session sau (gotcha #40 doc rồi).
-**Tests Phase 3 mini (PE Workflow Designer)** — 6 test versioning logic. Total 77.
## ⚠️ CẢNH BÁO session tiếp (Session 6)
## ⚠️ CẢNH BÁO session tiếp (Session 7+)
1. **CI test gate active** mỗi commit push trigger 2 step `dotnet test` (Domain + Infrastructure) TRƯỚC build/deploy. Test fail = NO deploy. Khi feature mới có bug logic → thêm regression test trước khi commit. Workflow: code → `dotnet test SolutionErp.slnx` local → commit → push.
2. **Login email** `admin@solutionerp.local` / `Admin@123456` — domain default
chưa đổi sang `@solutions.com.vn` (chỉ demo user rebrand qua BackfillDemoEmail).
3. **Chưa xóa binding cũ `.huypham.vn`** — vẫn active fallback. Sau 1-2 ngày
verify stable → `.\migrate-domains.ps1 -RemoveOld -SkipCert` trên VPS.
4. **win-acme scheduled task "unhealthy"**cert auto-renew có thể fail
khi gần 2026-06-18. Fix: mở `wacs.exe` interactive → Manage Renewals →
recreate task.
5. **Export phiếu PDF/Excel PE** — pending vô thời hạn (user nói không quan trọng lắm). Khi cần: tái dùng `IDocumentConverter` + template `PE-TrinhDuyet.docx`.
6. **Atomic sequence Budget chưa chốt**`NS-YYYYMM-XXXX` Random.Shared. Khi format chốt → migration `AddBudgetCodeSequences` + `IBudgetCodeGenerator` SERIALIZABLE pattern (mirror Contract/PE).
7. **Versioned workflow Budget chưa có** — hardcoded `BudgetPolicy.Default` 3-step. Khi user cần admin config UI → migration `AddBudgetVersionedWorkflow` + 3 bảng + pin per Budget.
8. **Chú ý G-084:** VPS shared với VietReport — mọi reverse proxy / backend
service mới phải dùng `127.0.0.1` + bind loopback IPv4 explicit.
1. **CI test gate active** — code → `dotnet test SolutionErp.slnx` local → commit → push. Test fail = NO deploy. Workflow user §7 rules.md.
2. **Timing test rule live (§7)**: feature mới = test-after, bug = test-before BẮT BUỘC, critical algorithm = test-before merge, spec change = update test cũ + code chung commit.
3. **Doc audit cadence live (§6.4)**: cuối phase compact, đầu tháng cron audit, KHÔNG rewrite toàn bộ. Cron fire **mai (2026-05-01)** — combined skill + doc drift theo checklist.
4. **Login email** `admin@solutionerp.local` / `Admin@123456` — domain default chưa đổi sang `@solutions.com.vn` (chỉ demo user rebrand).
5. **Chưa xóa binding cũ `.huypham.vn`** — vẫn fallback. Sau verify stable → `.\migrate-domains.ps1 -RemoveOld -SkipCert` trên VPS.
6. **win-acme scheduled task "unhealthy"**fix trước cert expire 2026-06-18.
7. **Export phiếu PDF/Excel PE** — pending vô thời hạn (user nói không quan trọng).
8. **3 feature mới chưa test** (PE Opinion Upsert / Budget validate / Contract BudgetId carry) — đợi UAT phát sinh bug → áp rule §7 (regression test before fix). Hoặc soak 2-3 tuần ổn → viết happy path.
9. **G-084:** VPS shared VietReport — mọi reverse proxy mới phải `127.0.0.1` + bind loopback IPv4 explicit.
## ⭐ Skills (.claude/skills/) — PHẢI dùng khi task khớp

View File

@ -2,9 +2,9 @@
> **Update rule:** trước khi bắt đầu 1 task → ghi row vào `🔥 In Progress`. Xong → chuyển sang `✅ Recently Done`.
**Last updated:** 2026-04-29 tối (Phase 8 — **Budget complete + PE feature gap đóng + Tests Phase 1-2-3mini + CI gate + Path filter + 3 gotcha CI mới**)
**Last updated:** 2026-04-30 (Session 6 — **MD audit + compact -288 dòng + 3 skill refresh + rule timing test + rule audit định kỳ §6.4**)
## 📍 Phase hiện tại: **Feature freeze + CI optimize live** — 52 DB tables, 15 migrations, ~128 API endpoints, 31 FE pages. **77 unit test pass** (54 Domain policy + 17 Infra code generator + **6 PE Workflow versioning**) — CI fail-fast. Path filter docs-only skip = 0s cho commit MD. Manual checkout từ Gitea bypass github.com timeout (gotcha #39). 41 gotcha tổng. 30 demo user.
## 📍 Phase hiện tại: **Phase 9 active — UAT + Ops + carry over** — 52 DB tables, 15 migrations, ~128 API endpoints, 31 FE pages. **77 unit test pass** (54 Domain + 17 Infra + 6 PE WF Application) — CI fail-fast. Path filter docs-only skip 0s. 41 gotcha. 30 demo user. **6 skill (3 refresh)**. Doc audit định kỳ §6.4 chốt cron 2026-05-01 fire mai.
### 🌐 Production URLs
@ -14,41 +14,46 @@
- https://git.baocaogiaoduc.vn/vietreport-admin/solution-erp — Gitea repo + Actions
- Default admin: `admin@solutionerp.local` / `Admin@123456` ⚠️ **RE-ROTATE sau login đầu**
## 🔥 In Progress — Còn lại cho session 6
## 🔥 In Progress — Session 7+ (Phase 9 active)
### A. PE feature gap (carry over)
### A. Hard blockers (chờ user / ops)
- [ ] **Export phiếu PDF/Excel** — tái dùng `IDocumentConverter` + template `PE-TrinhDuyet.docx` (user pending — không quan trọng lắm)
- [ ] **UAT thật 1 tuần** với 2-3 user (Drafter / CCM / BOD) — hard requirement Phase 5 roadmap
- [ ] **SMTP config** → Email outbox (BLOCKED chờ user cấp host/user/pass)
- [ ] **Rotate creds** — admin + 30 demo + SA + vrapp + JWT secret + Gitea runner token
- [ ] **Schedule SQL backup daily**`scripts/backup-sql.ps1` đã sẵn, chưa schedule Task Scheduler
- [ ] **Remove binding cũ `.huypham.vn`** sau verify stable: `ssh vietreport-vps ; .\migrate-domains.ps1 -RemoveOld -SkipCert`
- [ ] **win-acme scheduled task "unhealthy"** — auto-renew fix trước 2026-06-18
### B. Optional polish (khi UAT phát sinh)
### B. Carry over feature gap
- [ ] Budget MaNganSach atomic sequence (hiện `NS-YYYYMM-XXXX` Random.Shared, chốt format chính thức sau → migration `AddBudgetCodeSequences`)
- [ ] Budget versioned workflow (admin config qua UI — hiện hardcoded `BudgetPolicy.Default`)
- [ ] Payment terms tách field (PE) — JSON blob → 6 column riêng (migration `AddPePaymentTermFields`)
- [ ] **Export phiếu PDF/Excel** PE — tái dùng `IDocumentConverter` + template `PE-TrinhDuyet.docx` (user pending — không quan trọng lắm)
### C. Optional polish (khi UAT phát sinh bug)
- [ ] Budget MaNganSach atomic sequence (hiện Random.Shared → migration `AddBudgetCodeSequences`)
- [ ] Budget versioned workflow (admin config UI thay hardcoded `BudgetPolicy.Default`)
- [ ] Payment terms PE tách field (JSON blob → 6 column riêng)
- [ ] Auto-map PE Details → Contract per-type Details khi gen HĐ
- [ ] Matrix Quotes bulk paste từ Excel
- [ ] fe-user Inbox thêm section "Phiếu Duyệt NCC chờ tôi"
### C. Tests Phase 3-5 (làm khi gặp bug recurring để justify ROI)
### D. Tests Phase 3-5 (làm khi gặp bug recurring để justify ROI — rule §7)
- [ ] **Phase 3** — Application handler tests (CQRS) với EF InMemory (~1 ngày, ~15 test)
- [ ] **Phase 4** — API smoke tests qua WebApplicationFactory (~0.5 ngày, ~7 test)
- [ ] **Phase 5** — FE Vitest cho lib utility (queryMatches, fmtMoney) (~0.5 ngày, ~10 test)
- [ ] **Phase 3 full** — Application handler tests cần UserManager DI helper (PE Opinion Upsert, Budget validate, CreateContractFromEvaluation BudgetId carry) ~15 test
- [ ] **Phase 4** — API smoke tests qua WebApplicationFactory ~7 test
- [ ] **Phase 5** — FE Vitest cho lib utility (queryMatches, fmtMoney) ~10 test
### D. Deploy / Ops chưa xong
### E. Audit định kỳ (cron tự fire)
- [ ] **Remove binding cũ `.huypham.vn`** sau verify: `ssh vietreport-vps ; cd C:\solution-erp\scripts ; .\migrate-domains.ps1 -RemoveOld -SkipCert`
- [ ] **win-acme scheduled task "unhealthy"** — auto-renew fix trước 2026-06-18.
- [ ] UAT thật 1 tuần với 2-3 user (16 demo + 14 Solutions = 30 user)
- [ ] SMTP config → Email outbox
- [ ] Rotate creds (admin + 30 demo + SA + vrapp + JWT)
- [ ] Schedule SQL backup Task Scheduler
- [ ] **2026-05-01** (mai) — `solution-erp-skill-audit-monthly` cron fire 9:00. Combined audit theo §6.4 + §9.4 (skill staleness + doc drift + count consistency). Log → `docs/changelog/skill-audit-2026-05.md`
## ✅ Recently Done (newest on top)
| Ngày | Ai | Task | Commit |
|---|---|---|---|
| 2026-04-29 | Claude | **Tests Phase 3 mini + 3 gotcha CI mới (#39 #40 #41)**`tests/.../Application/PeWorkflowAdminTests.cs` 6 test versioning logic (CreatePeWorkflowDefinition: first version IsActive=true, second deactivates first, different EvaluationType independent, persists steps ordered + approvers per step, third version increments to v3). Total **77 test** (54 Domain + 17 Infra + 6 PE WF Application). Gotcha #39 act_runner github.com TCP timeout 21s + manual checkout fix. #40 npm junction cache fail `tsc not found` rolled back. #41 paths-ignore behavior + workflow file exclusion. | (cur commit) |
| 2026-04-30 | Claude | **Session 6 — MD audit + compact + 3 skill refresh + 2 rule mới** — Compact 3 file core (-288 dòng): STATUS -27%, HANDOFF -32%, migration-todos -35%. Archive 51 row Recently Done Phase 0-7 → `changelog/recently-done-archive-2026-04.md`. Refresh 3 skill stale: `form-engine` (Phase 2 MVP → Tier 3 feature-complete + bỏ section duplicate gen mã HĐ), `permission-matrix` (12 menu → ~60 menu key + Bg_*/Pe_*/PeWf_* + inheritance roots), `ef-core-migration` (24 DbSet → 52 bảng + ERD update). Rule mới `rules.md §7 Khi nào viết test — timing rule` (5-row table compact, sau khi rút gọn từ 70 dòng overkill). Rule mới `rules.md §6.4 Audit + compact MD định kỳ` (cadence + checklist + anti-pattern, KHÔNG rewrite toàn bộ). `rules.md §9.4 Skill audit` mở rộng cross-ref §6.4. | (current) |
| 2026-04-29 | Claude | **Tests Phase 3 mini + 3 gotcha CI mới (#39 #40 #41)**`tests/.../Application/PeWorkflowAdminTests.cs` 6 test versioning logic (CreatePeWorkflowDefinition: first version IsActive=true, second deactivates first, different EvaluationType independent, persists steps ordered + approvers per step, third version increments to v3). Total **77 test** (54 Domain + 17 Infra + 6 PE WF Application). Gotcha #39 act_runner github.com TCP timeout 21s + manual checkout fix. #40 npm junction cache fail `tsc not found` rolled back. #41 paths-ignore behavior + workflow file exclusion. | `b874743` |
| 2026-04-29 | Claude | **CI Path filter docs-only skip live**`paths-ignore` trong on:push lookup `docs/**`/`**/*.md`/`.claude/skills/**`/`.gitignore`. Commit chỉ touch docs SKIP CI hoàn toàn (saving ~196s/commit, ~30% commit thuộc loại này). Verify `512880c` (docs-only) → Gitea NO trigger run #113. | `29eb5d9` · `a21790d` · `512880c` |
| 2026-04-29 | Claude | **CI manual checkout bypass github.com (fix #108/#109)** — Run #108/#109 fail TCP timeout 21s khi act_runner fetch `actions/checkout@v4` từ github.com. Replace `uses: actions/checkout@v4` + `actions/upload-artifact@v4` bằng manual `git init` + `git fetch` từ Gitea internal. Token `${{ github.token }}` auth tự sẵn per-job. Fetch by ref + depth=30. Run #110 pass 3m16s. | `14b7d18` · `26075c4` |
| 2026-04-29 | Claude | **Tests Phase 2 — Code generator format + sequence (SQLite in-memory)**`tests/SolutionErp.Infrastructure.Tests/` xUnit + EF SQLite 10. `SqliteDbFixture` + `TestApplicationDbContext` subclass override `nvarchar(max) → TEXT` (SQLite không support `max`). 17 test: ContractCodeGenerator (format RG-001 5 type + Framework year scope vs Project scope + sequence per prefix + year boundary reset + persistence verify) + PurchaseEvaluationCodeGenerator (format A/B + 3-digit pad + independent A/B sequences + year boundary). CI gate +1 step. Total 71 test pass / 2.1s. | `df5988b` |

View File

@ -84,6 +84,14 @@ Session logs: `2026-04-23-2300-purchase-evaluations.md` · `2026-04-24-chot-sess
## 📝 Phase 9 — UAT + Ops + carry over (Session 6+ active)
### ✅ Session 6 done (2026-04-30 — pure docs work)
- [x] **MD audit + compact** — STATUS -27%, HANDOFF -32%, migration-todos -35%, archive 51 row Phase 0-7 cũ
- [x] **3 skill refresh**`form-engine` Phase 2 MVP → Tier 3 feature-complete, `permission-matrix` 12 menu → ~60 + inheritance roots, `ef-core-migration` 24 DbSet → 52 bảng
- [x] **Rule mới rules.md §7** — Khi nào viết test (timing rule 5-row table)
- [x] **Rule mới rules.md §6.4** — Audit + compact MD định kỳ (cadence + checklist + anti-pattern)
- [x] **rules.md §9.4** — Mở rộng skill audit cross-ref §6.4
### A. Hard blockers (chờ user / ops)
- [ ] UAT thật 1 tuần với 2-3 user (30 demo: 16 sample + 14 Solutions thật)

View File

@ -0,0 +1,157 @@
# Session log — 2026-04-30 chốt session 6 — MD audit + compact + 3 skill refresh + 2 rule mới
**Topic:** Pure docs work — audit toàn bộ MD, compact 3 file core, refresh 3 skill stale, chốt 2 rule mới (timing test §7 + audit định kỳ §6.4). 0 thay đổi code/test.
**Dev:** Claude (Opus 4.7) + user (pqhuy1987@gmail.com)
**Duration:** ~2 giờ (bao gồm Q&A về unit test philosophy)
**Base commit:** `b874743` (chốt session 5)
## Commits session 6
- `d2298fa` — Docs: chốt rule timing unit test (1 bảng 5-row compact)
- `f24acb6` — Docs: compact 3 file core (-273 dòng tổng)
- (commit chốt session 6 này)
## A. Q&A unit test philosophy
User hỏi:
1. Ý nghĩa unit test? Lợi ích?
2. Khi spec đổi (không phải bug) thì test thế nào?
3. Khi bug fix thì test thế nào?
4. Có nên áp rule? → user confirm.
5. Rule mới có overkill không? → user nhận xét sắc.
6. Có nên rewrite MD định kỳ? → user hỏi nghiêm túc.
**Outcome:**
- Chốt rule timing test (rules.md §7) — 1 bảng 5-row compact, sau khi rút gọn từ 70 dòng overkill ban đầu
- Chốt rule audit + compact MD định kỳ (rules.md §6.4) — KHÔNG rewrite toàn bộ
- Lưu feedback memory `feedback_unittest_timing.md` cho session sau
## B. MD compact (commit `f24acb6`)
| File | Trước | Sau | Δ |
|---|---|---|---|
| STATUS.md | 196 | 144 | -27% |
| HANDOFF.md | 460 | 313 | -32% |
| migration-todos.md | 210 | 136 | -35% |
| recently-done-archive-2026-04.md | (mới) | 61 | archive 51 row Phase 0-7 |
**Pattern:**
- STATUS Recently Done > 30 row → archive cũ vào `changelog/recently-done-archive-{YYYY-MM}.md`
- HANDOFF section duplicate (Versioned WF / File active / Git state) → cross-ref thay vì copy
- migration-todos Phase done → collapse thành 1 paragraph + cross-ref session log
**0 information loss** — tất cả nội dung vẫn còn ở file gốc (gotchas, rules, architecture, schema-diagram, session logs).
## C. 3 skill refresh (commit chốt session)
### form-engine/SKILL.md
- Status: "Phase 2 MVP — missing PDF + form builder" → "Tier 3 feature-complete"
- Known limitations: 6 row → 4 row, đánh dấu DONE Phase 8
- "Gen mã HĐ chưa implement" → DONE Phase 3+6, cross-ref `contract-workflow` skill (bỏ duplicate)
### permission-matrix/SKILL.md
- Description: 12 menu + 48 policy → ~60 menu + ~240 policy
- Menu tree section: 12 menu cũ → ~60 với Pe_*/PeWf_*/Bg_*/Catalogs đầy đủ
- Inheritance roots: 4 group (Contracts/Workflows/PE/PeWorkflows). Budgets KHÔNG inherit (gotcha #35).
### ef-core-migration/SKILL.md
- Code pointers: "ApplicationDbContext.cs — 24 DbSet" → "DbSet cho 52 bảng (15 migration)"
- Related: "ERD 24 bảng" → "ERD 52 bảng + §11 PE + §12 Budget + §13 PEDeptOpinions"
## D. 2 rule mới chốt
### rules.md §7 — Khi nào viết test (timing rule)
```
| Tình huống | Quy tắc |
| Feature mới | Test-after: UAT 2-3 lần ổn → viết test (≤1 commit theo sau) |
| Bug fix | Test-before BẮT BUỘC: reproduce bằng test failing → fix → green |
| Critical algorithm (codegen/guard/financial/security) | Test-before merge |
| Spec change | Update test cũ + code, commit chung. KHÔNG xóa, KHÔNG skip. |
| Skip | DTO mapping, CRUD master, FE snapshot, wrapper, migration backfill |
```
Rút gọn từ 70 dòng overkill (decision tree ASCII + triết lý chung + bảng critical algorithm chi tiết) còn 6 dòng. User nhận xét đúng — overkill thật.
### rules.md §6.4 — Audit + compact MD định kỳ
| Tần suất | Action | Effort |
|---|---|---|
| Cuối session | Update STATUS + HANDOFF | ~10 phút |
| Cuối phase (~1 tháng) | Compact STATUS Recently Done > 30 row → archive | ~30 phút |
| Đầu mỗi tháng (cron) | Audit skill + doc drift + count consistency, patch (Edit, không rewrite) | ~45 phút |
| Khi trigger riêng | Selective rewrite 1 file (drift > 30%) | 1-2 giờ |
| KHÔNG BAO GIỜ | Rewrite toàn bộ docs | — |
**Doc audit checklist** (mở rộng từ §9.4 skill audit, chạy cùng cron):
1. `dotnet test` count khớp STATUS/CLAUDE/HANDOFF
2. `ls migrations/` count khớp ef-core-migration skill
3. `grep '#[0-9]\+' gotchas.md` count khớp HANDOFF/STATUS
4. STATUS Recently Done > 30 row → đề xuất archive
5. HANDOFF section duplicate → đề xuất bỏ
6. Skill SKILL.md mention "Phase N MVP" mà N <= phase hiện tại → stale
7. Output report → human review patch (Edit, KHÔNG Write toàn file)
**§9.4 Skill audit** mở rộng cross-ref §6.4 — chạy chung cron `solution-erp-skill-audit-monthly`.
## E. Verify state cuối session
```
✅ 77 test pass (Domain 54 + Infra 23) — chạy `dotnet test SolutionErp.slnx`
✅ 15 migration / 52 bảng / 41 gotcha — khớp docs
✅ 6 skill (3 refresh trong session)
✅ Cron 2026-05-01 ready fire mai (combined audit)
✅ MEMORY.md có 3 entry (project + node CI/CD + unit test timing)
```
## F. Files touched session 6
```
docs/rules.md (mod: §7 Timing test rule + §6.4 doc audit + §9.4 cross-ref)
docs/STATUS.md (mod: Phase 9 active + Session 6 Recently Done + cron 05-01)
docs/HANDOFF.md (mod: TL;DR session 6 + cảnh báo session 7+, bỏ 3 section duplicate)
docs/changelog/migration-todos.md (mod: Phase 6-7 collapse, Phase 9 + Session 6 done sub)
docs/changelog/recently-done-archive-2026-04.md (NEW: 51 row archive)
docs/changelog/sessions/2026-04-30-chot-session-6-md-audit-compact.md (NEW: file này)
.claude/skills/form-engine/SKILL.md (mod: refresh Phase 2 MVP → Tier 3 done)
.claude/skills/permission-matrix/SKILL.md (mod: refresh 12 menu → ~60 + inheritance roots)
.claude/skills/ef-core-migration/SKILL.md (mod: refresh count 24 → 52)
CLAUDE.md (root) (mod: timing test compact 1 dòng)
~/.claude/.../memory/feedback_unittest_timing.md (NEW: feedback memory)
~/.claude/.../memory/MEMORY.md (mod: index +1 entry)
```
## G. Cảnh báo session 7
1. **Cron `solution-erp-skill-audit-monthly` fire 2026-05-01 9:00** — combined audit theo §6.4 + §9.4 checklist. Log → `docs/changelog/skill-audit-2026-05.md`. Session sau verify cron đã fire OK.
2. **Hard blockers ops vẫn chờ user** — UAT 1 tuần / SMTP / rotate creds / SQL backup schedule.
3. **3 feature mới chưa test** (PE Opinion Upsert / Budget validate / Contract BudgetId carry) — đợi UAT phát sinh bug → áp §7 rule (regression test before fix).
4. **win-acme** schedule task unhealthy — fix trước cert expire 2026-06-18.
5. **MD compact pattern** lần kế: cuối Phase 9 (sau UAT) — STATUS Recently Done > 30 row archive lần 2.
## H. Lessons learned session 6
1. **User feedback on overkill** — Claude tendency là viết quá dài. Lần đầu rule timing test = 70 dòng (decision tree ASCII + triết lý + bảng chi tiết). User catch ngay → rút còn 6 dòng. Bài học: skill audit phải có "compact pass" sau draft đầu.
2. **Rewrite vs compact** — User hỏi nghiêm túc "rewrite toàn bộ định kỳ" và push back tốt khi tôi suggest 4 chiến lược (compact / audit / selective rewrite / never full rewrite). Confirm: drift là normal, fix bằng patch, KHÔNG rewrite.
3. **Skill staleness là silent killer**`form-engine` lifeline "Phase 2 MVP missing PDF" survived qua nhiều session vì chỉ Claude đọc trước khi auto-invoke. User không thấy trực tiếp. Cron audit định kỳ là cơ chế duy nhất catch được.
4. **Feedback memory path** — Lưu rule vào memory file giúp session sau (không có conversation history) tự áp dụng. 3 entry hiện tại: project overview / Node CI/CD pin / unit test timing. Không bloat — chỉ rule actionable.
5. **Path filter CI làm việc cực tốt cho docs-heavy session** — session 6 có 3 commit, đều skip CI (0s deploy). Saving lớn nếu maintain pattern này.
## I. Stats sau session 6
| | Trước S6 | Sau S6 |
|---|---:|---:|
| BE LOC | ~13050 | ~13050 (no code change) |
| DB tables | 52 | 52 |
| Migrations | 15 | 15 |
| API endpoints | ~128 | ~128 |
| FE pages | ~31 | ~31 |
| Tests | 77 | 77 (no test change) |
| Gotchas | 41 | 41 |
| **Skill** | 6 (3 stale) | **6 (3 refresh)** |
| **Docs lines core 3 file** | 866 | **593** (-273, -32%) |
| **Memory entries** | 2 | **3** (+unit test timing) |
| Demo user | 30 | 30 |
| Commits S6 | 0 | **3** (rule + compact + chốt) |
| Session log files | 17 | **18** |

View File

@ -270,6 +270,41 @@ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Thêm pattern → update skill tương ứng ở `.claude/skills/`
- Phase đổi → update [`STATUS.md`](STATUS.md) + [`HANDOFF.md`](HANDOFF.md) + [`changelog/migration-todos.md`](changelog/migration-todos.md)
### 6.4 Audit + compact MD định kỳ
**Triết lý:** KHÔNG rewrite toàn bộ. Chỉ **compact + patch drift** định kỳ. Test/code là source of truth, MD theo sau.
**Cadence + trigger:**
| Tần suất | Action | Effort | Trigger |
|---|---|---|---|
| **Cuối session** (đã làm tự động) | Update STATUS Recently Done + HANDOFF cảnh báo session tiếp | ~10 phút | Mỗi session có code commit |
| **Cuối phase** (~1 tháng) | Compact STATUS Recently Done > 30 row → `changelog/recently-done-archive-{YYYY-MM}.md`. Collapse migration-todos Phase done thành 1 paragraph cross-ref session log | ~30 phút | Phase đóng |
| **Đầu mỗi tháng** (cron `solution-erp-skill-audit-monthly`) | Audit skill + doc drift + count consistency. Patch stale qua Edit (KHÔNG rewrite). Log kết quả | ~45 phút | 9:00 ngày 1 mỗi tháng |
| **Khi trigger riêng** | Selective rewrite 1 file (skill drift > 30%, architecture redesign, phase major) | 1-2 giờ | Quantitative trigger |
| **KHÔNG BAO GIỜ** | Rewrite toàn bộ docs | — | — |
**Doc audit checklist (mở rộng từ §9.4 skill audit, chạy cùng cron):**
```
1. dotnet test SolutionErp.slnx → verify count khớp STATUS/CLAUDE/HANDOFF
2. ls migrations/ → verify count khớp ef-core-migration skill + database-guide
3. grep '#[0-9]\+' gotchas.md → verify khớp count claim trong HANDOFF/STATUS
4. ls .claude/skills/ → verify khớp count trong rules §9 + skills/README
5. STATUS Recently Done > 30 row? → đề xuất archive cũ
6. HANDOFF có section duplicate file khác (PROJECT-MAP/workflow/git log)? → đề xuất bỏ
7. Skill SKILL.md mention "Phase N MVP" mà N <= phase hiện tại? → stale, refresh
8. Output report stale items + suggest patches → human review
9. Log vào docs/changelog/skill-audit-{YYYY-MM}.md (1 page max)
```
**Anti-pattern (đã trải nghiệm):**
- ❌ Rewrite toàn bộ MD định kỳ — mất context, paraphrase mất nuance, ROI thấp
- ❌ Bulk-clone 3rd party docs — đã từ chối ở Skill governance §9.5
- ❌ Skip audit "vì sắp UAT/sắp deploy" — drift tích lũy → onboard agent mới sai
**Trigger override:** User nói "audit MD", "kiểm tra docs", "định kỳ kiểm tra", "compact docs" → chạy doc audit ngay không đợi cron.
## 7. Testing (Phase 8 active — 77 test pass + CI gate live)
### Stack đã apply
@ -410,37 +445,37 @@ when-to-use:
## Related (dẫn chiếu gotcha #N, docs/...)
```
### 9.4 Audit định kỳ — mỗi 4 tuần
### 9.4 Audit định kỳ — mỗi đầu tháng (chạy chung với doc audit §6.4)
**Cadence:** Mỗi đầu tháng (hoặc thứ Hai tuần đầu tháng), chạy audit skill list:
**Cadence:** Đầu mỗi tháng, cron `solution-erp-skill-audit-monthly` fire 9:00 ngày 1 → chạy combined audit (skill + doc drift theo §6.4 checklist).
**Skill audit phần riêng (mỗi skill SKILL.md):**
```
1. Đọc .claude/skills/README.md — list 6 skill hiện có
2. Cross-check với:
- docs/STATUS.md "Recently Done" — feature mới nào chưa có skill cover?
- docs/gotchas.md — gotcha mới (>3 dòng) nào nên gom thành skill mới?
- migration-todos.md "In Progress" / "Next up" — task lớn sắp tới có cần skill?
3. Check repo nguồn skill 3rd party có gì mới:
- https://github.com/alirezarezvani/claude-skills (default-branch)
- Anthropic skills built-in (xem system reminder skill list)
4. Đánh giá staleness:
- Mỗi skill: SKILL.md có còn match code thực tế không?
- Trigger phrases có còn hiệu quả?
- Code pointers có còn đúng path?
5. Hành động:
- Skill stale → update SKILL.md + commit `[CLAUDE] Skill: refresh <name>`
2. Cross-check stale:
- SKILL.md mention "Phase N MVP" mà N < phase hiện tại → stale
- Code pointers paths có còn tồn tại không (Glob check)
- Count claim (vd "24 DbSet", "13 migration") khớp thực tế không
- Trigger phrases có còn hiệu quả không
3. Cross-check feature gap:
- docs/STATUS.md Recently Done — feature mới nào chưa có skill cover?
- docs/gotchas.md — gotcha mới (>3 dòng / cluster) nào nên gom thành skill?
- migration-todos.md — task lớn sắp tới có cần skill mới?
4. Hành động:
- Skill stale → Edit SKILL.md (KHÔNG rewrite) + commit `[CLAUDE] Skill: refresh <name>`
- Skill cần thêm → tạo theo §9.2 §9.3 + commit `[CLAUDE] Skill: add <name>`
- Skill không còn cần → archive vào .claude/skills/_archived/ + commit
6. Update bảng §9.1 trong rules.md + .claude/skills/README.md + docs/CLAUDE.md count
7. Log vào docs/changelog/skill-audit-{YYYY-MM}.md (1 page max)
5. Update bảng §9.1 trong rules.md + .claude/skills/README.md + docs/CLAUDE.md count
6. Log skill + doc drift report vào docs/changelog/skill-audit-{YYYY-MM}.md (1 page max)
```
**Trigger:** Khi user nói "audit skill", "check skill list", "skill staleness", "định kỳ kiểm tra skill" → chạy workflow này.
**Trigger:** User nói "audit skill", "check skill list", "skill staleness", "audit MD", "kiểm tra docs", "định kỳ kiểm tra" → chạy combined audit (§6.4 + §9.4) ngay không đợi cron.
**Lịch chính thức:**
- Tháng 1, 2, 3, ... — đầu tháng audit (1 buổi sáng)
- Hoặc khi bắt đầu Phase mới (vd Phase 6) → audit ngay trước phase
- Hoặc khi `docs/gotchas.md` vượt mốc (cứ +5 gotcha thì xem có gom thành skill được không)
**Threshold trigger ngoài cron:**
- `gotchas.md` +5 gotcha mới → audit (xem có gom thành skill mới được không)
- Phase mới đóng → audit ngay (track stale từ feature mới)
- Skill drift > 30% (count check, path broken, mention phase cũ) → selective rewrite
### 9.5 Anti-patterns