# Skill + Doc Audit — 2026-05 (late) — Drift trigger sớm

> **Cadence chính:** Cron `solution-erp-skill-audit-monthly` 9:00 ngày 1 mỗi tháng. **Next scheduled:** 2026-06-01.
> **Lần này:** chạy SỚM 2026-05-22 trigger bởi drift threshold §9.4 "+5 gotcha mới → audit cluster" (actual +8: 41→49 từ baseline 2026-05-04).
> **Workflow:** combined audit theo `docs/rules.md §6.4` (doc drift) + `§9.4` (skill staleness).
> **Origin:** em main flagged drift trong session 27 start setup; bro confirm OK proceed curate + audit cùng session.

## Phase 0 — Trigger context

| Metric | 2026-05-04 baseline | 2026-05-22 actual | Δ | Threshold trigger? |
|---|---:|---:|---:|---|
| Migrations | 16 | 31 | +15 | YES — > +5 (major schema) |
| Tests | 83 | 111 | +28 | YES — > +5 |
| Gotchas | 41 | 49 | **+8** | **YES — §9.4 "+5 gotcha mới"** |
| Skills | 6 | 6 | 0 | — |
| Memory user-level | 14 | 23 | +9 | — |
| DB tables | 55 | 59 | +4 | — |
| Active prod users | 18 | 33 | +15 | — (data not skill drift) |

**Decision:** Trigger audit SỚM thay vì đợi 2026-06-01 — drift cluster vượt 30% threshold §9.4.

## Phase 1 — Skill staleness patches applied

5 patches (Edit, KHÔNG rewrite) per rule §6.4 + §6.5:

| File:line | Stale → Patched | Reason |
|---|---|---|
| `.claude/skills/README.md:20` | `26 migration history` → `31 migration history (Init → RefactorSkipToFinalToApproverLevel)` + Session 23 t1 marker | Mig drift 26→31 |
| `.claude/skills/README.md:90` | `44 bẫy` → `49 bẫy (S25 +#48 SQLite tie-break, #49 dual-phase UI confusion)` | Gotcha drift 44→49 |
| `.claude/skills/ef-core-migration/SKILL.md:3` (description) | `26 migration sẵn (Init → AddPeLevelOpinionsForV2)` → `31 migration sẵn (Init → RefactorSkipToFinalToApproverLevel Mig 31 S23 t1 F2 per-Approver-slot swap)` | Description drift + frontmatter description trigger semantic match |
| `.claude/skills/ef-core-migration/SKILL.md:19` (heading) | `## Migration history (26 migration hiện có)` → `(31 migration hiện có)` | Section heading drift |
| `.claude/skills/ef-core-migration/SKILL.md:80` (Tests note) | `Total 77 test pass / ~3s` → `Total 111 test pass / ~5s` + cumulative S22-S25 regression breakdown | Test count drift 77→111 (+34) |
| `.claude/skills/ef-core-migration/SKILL.md:258` | `DbSet cho 59 bảng (26 migration)` → `(31 migration)` | Code pointer drift |
| `.claude/skills/dependency-audit-erp/SKILL.md:153` | `41 bẫy` → `49 bẫy` + add #48 + #49 cross-ref | Gotcha drift 41→49 |

**Total diff:** ~12 LOC patched. KHÔNG rewrite toàn bộ. KHÔNG cắt narrative gốc.

## Phase 2 — KEEP (rule §6.5 không cắt narrative)

Stale references PRESERVED vì là historical context:

- `contract-workflow/SKILL.md:367` `96→77 test pass (drop 19 N-stage/2-stage legacy)` — historical narrative Mig 21 drastic refactor. KEEP per §6.5 (kể chuyện cumulative).
- `permission-matrix/SKILL.md:16` `Status (post Session 6 — 2026-04-30)` — section header timestamp historical, KHÔNG drift critical.
- `migration-todos.md` mentions `77 test` / `16 mig` — historical session record. KEEP per §6.5.
- `skill-audit-2026-05.md` — historical audit record. KEEP unchanged.
- Session logs `changelog/sessions/*.md` — ALL preserved chronologically. KEEP.

## Phase 3 — Feature gap audit

**Feature mới S20-S26 nào chưa có skill cover?**

| Feature | Period | Skill cover? | Decision |
|---|---|---|---|
| ApprovalWorkflow V2 schema (Mig 22-25) | S17-S18 | Cross-ref `contract-workflow` + `ef-core-migration` Mig history | Existing skills cover, KHÔNG tạo skill mới |
| Per-NV admin opt-in flag pattern (Mig 29-31) | S21-S23 | Memory `feedback_per_nv_permission_scope.md` (user-level) | Pattern reusable cross-project — memory user-level sufficient (admin role + Mig schema discriminator), KHÔNG skill project-local |
| Multi-agent setup 4 sub-agents | S20-S21 | Memory `feedback_multi_agent_setup.md` + `.claude/agents/README.md` | Em main coordination guide — KHÔNG skill (setup-once pattern) |
| RAG Hybrid Cách A global MCP | S26 | Memory `feedback_rag_hybrid_pattern.md` + `feedback_rag_distributed_ownership.md` | Cross-project pattern — memory user-level sufficient |
| Plan AG PE List tree view UI | S26 | Pattern 19 trong `implementer/MEMORY.md` (HTML details + Tailwind named groups + localStorage Set) | Sub-agent memory — KHÔNG tạo skill cho UI pattern 1×fix |
| Mig 28-31 per-NV refactor + Plan N+O 10-surface-point checklist | S21-S23 | `cicd-monitor/MEMORY.md` 10-point checklist promoted to foundation | Cross-agent learning — em đã promote vào cicd-monitor MEMORY.md foundation section curate session 2026-05-22 |
| Gotcha #48 (SQLite tie-break multi-Changelog) | S25 Plan AB | `cicd-monitor/MEMORY.md` gotcha #48 section added curate 2026-05-22 + Reviewer 5-category Cat 5 reinforced | Cross-ref to skill `contract-workflow` (test pattern) — defer to next audit nếu pattern proven cross-module |
| FE merge synthetic audit + userMap fallback (Plan AC2 + AF) | S25 | Memory `feedback_fe_merge_synthetic_audit.md` + `feedback_fe_usermap_fallback.md` (user-level) | Pattern reusable cross-project (Contract V2 + Budget V2 future) — KHÔNG skill |

**KHÔNG tạo skill mới.** Tổng số skill giữ **6** (3 domain + 3 ops). Threshold §9.4 anti-pattern "viết skill chỉ để có thêm" respected.

## Phase 4 — Threshold check + decision

- ✅ `+8 gotcha` vượt threshold §9.4 (+5) → trigger audit sớm CHỐT
- ✅ Mig drift 26→31 (+5) trong 3 skill mention → patch 5 vị trí KHÔNG rewrite
- ✅ Test drift 77→111 (+34) trong 1 skill mention → patch 1 vị trí
- ✅ Skill drift < 30% (chỉ ef-core-migration + 2 cross-ref README/dependency-audit-erp)
- ✅ Memory 4 agent curate trong session cùng — synthesize cross-agent learnings vào foundation sections

## Phase 5 — Validation per §6.5

3 câu sau consolidate (per rule §6.5):

1. **Agent mới đọc 6 tháng sau có biết "tại sao chọn approach này" không?**
   ✅ Có — narrative Mig 22-31 cumulative + Plan AA/AB/AG context preserved trong session logs + memory + 4 agent MEMORY archive. Skill `ef-core-migration` Phase 9 cross-ref block thêm S22-S25 regression breakdown rationale. 10-surface-point per-NV checklist promoted to cicd-monitor MEMORY foundation cho future per-NV refactor scan.

2. **Có còn cảm giác "kể chuyện" tích lũy không, hay chỉ là instructions khô?**
   ✅ Có — Skill `ef-core-migration` test note line 80 mở rộng "cumulative S22-S25 regression breakdown: ReturnMode + DraftGuard + Reflection AuthorizePolicy + V2 actor scope reject + per-NV lookup discrimination" giữ rationale tại sao 111 test (vs 77 cũ). Skill description giữ Mig 31 latest semantic "F2 per-Approver-slot swap" thay vì plain count.

3. **Gotcha context vẫn còn ý nghĩa khi đọc rời rạc không?**
   ✅ Có — `dependency-audit-erp` line 153 +#48 SQLite tie-break + #49 dual-phase UI confusion cross-ref. Cicd-monitor MEMORY.md gotcha #48 section full narrative root cause + fix pattern + side benefit (CI test gate catches BEFORE prod). Foundation section preserved.

## Memory curate concurrent (session same as audit)

4 agent MEMORY curate cùng session 2026-05-22 (per HANDOFF S25 wrap flag):

| Agent | Before KB | After KB | Reduction | Archive file |
|---|---:|---:|---:|---|
| cicd-monitor | 72.4 | 15.8 | **-78%** | `archive/2026-05-runs.md` (58.4 KB) |
| implementer | 38.8 | 22.0 | -43% | `archive/2026-05-q1.md` (18.1 KB) |
| investigator | 34.9 | 16.3 | -53% | `archive/2026-05-q1.md` (20.2 KB) |
| reviewer | 34.5 | 17.9 | -48% | `archive/2026-05-q1.md` (18.3 KB) |
| **Total** | **180.6** | **72.0** | **-60%** | All archives 115 KB preserved |

All 4 MEMORY now under 25KB curate threshold. Rule §6.5 KEEP narrative compliance: archive files preserve FULL verbose entries cho cross-session audit retrieve. Foundation patterns + 5-category checklist + recurring gotcha patterns kept inline.

## Đề xuất next audit

- **Cron 2026-06-01** — re-trigger combined audit (cadence chính) — KHÔNG conflict với late audit này (sớm 10 ngày), chỉ re-verify drift mới phát sinh sau S27+.
- **Threshold trigger sớm** nếu:
  - +5 gotcha mới cluster (Plan B Contract V2 wire có thể phát sinh #50+)
  - Plan B Contract V2 wire complete (drastic schema change cross 4 entity — Mig 32+33 estimate)
  - Skill drift > 30% (count broken / path broken)
  - 4 agent MEMORY vượt 25KB threshold trở lại (next curate trigger trong HANDOFF)

## Stats

- Total skill: 6 (no add/archive)
- Files patched: 3 SKILL.md (ef-core-migration + dependency-audit-erp + README)
- Lines diff: ~+12 / ~7 patch
- Memory curate concurrent: 4 file -60% size cumulative
- Effort: ~30 phút audit + ~1.5h memory curate (em main solo, không spawn sub-agent — judgment scope per Cognition "writes single-threaded")
- Audit log: 1 page (file này, theo cadence rule §6.4 — KHÔNG rewrite existing skill-audit-2026-05.md)
