[CLAUDE] Docs+Memory: Session 29 FINAL wrap — Plan CA + Plan B Contract V2 cumulative
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 3m31s

20 commits S29 push 4 CI Runs PASS (#229+#230 Plan CA, #231+#232 Plan B).
2 big plans END-TO-END deployed prod.

Changes (docs + memory + scripts — CI skip per paths-ignore):

docs/:
- STATUS.md: S29 FINAL wrap header với cumulative summary 20 commits +
  multi-agent ROI ~565K + 8 patterns NEW + state stats (33 mig, 60 tables,
  51 gotcha, 14 AppRoles, 34 active users, 4× bundle rotate)
- HANDOFF.md: S29 FINAL wrap header với end-to-end V2 capability + pending S30+
  follow-up (anh restart CLI MCP RAG hot-reload, UAT verify V2, test bundle
  Plan B, curate dedicated session)
- gotchas.md: +gotcha #51 INFRASTRUCTURE vs DEMO seed phân biệt (Plan B
  Hotfix CICD lesson) với decision tree + seed classification table
- changelog/sessions/2026-05-22-s29-plan-ca-plan-b-contract-v2-wire.md:
  Session log đầy đủ 20 commits + 4× Smart Friend pattern proven + 8
  patterns NEW + file-touched list + NEW capability end-to-end test plan

.claude/agent-memory/:
- 4 MEMORY.md flush S29 wrap entry FIFO each agent perspective:
  - Investigator (25.2 KB just over threshold) — Plan CA + Plan B pre-flight
    2 spawn + 3 patterns NEW (terrain map, V1+V2 coexist, reference templates)
  - Implementer (35.4 KB over hard threshold, defer curate S30) — 5 spawn
    cookie-cutter + E3 stopped + Pattern 12-bis NEW (cross-module entity mirror)
  - Reviewer (23.0 KB compacted) — 4 spawn 2 MAJOR catches + Cat 3 security
    cross-module validation foundation reinforced
  - CICD Monitor (24.9 KB) — 4 Runs verify + CRITICAL DemoSeed gate catch +
    Stage 4.6 sqlcmd seed verify foundation + Discovery #6 gotcha #51 cross-ref
- implementer/pattern_master_page_mirror.md (NEW Plan CA Chunk B Pattern 16-bis)

scripts/:
- plan-ca-{verify-menu,verify-perms,run-perms}.{sql,ps1} (5 verify scripts)
- plan-b-{verify-prod,run-verify}.{sql,ps1} (2 verify scripts)

Smart Friend pattern proven 4× cumulative S22 #44 + S25 #48 + S29 Reviewer
#ApplicableType + S29 CICD #DemoSeed.

Pending S30+:
- Anh restart CLI hot-reload MCP RAG cho 4 sub-agents (commit b51fc94)
- Anh UAT verify V2 contract end-to-end (Drafter → CCM approve → DaPhatHanh)
- Test bundle Plan B (regression ApproveV2Async + ApplicableType validation)
- Curate dedicated session 4 MEMORY (Implementer 35.4 KB priority)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-05-22 13:29:49 +07:00
parent 38f1c4d2d9
commit e199603420
22 changed files with 2216 additions and 153 deletions

View File

@ -0,0 +1,325 @@
# Session 27 — 2026-05-22 — Memory Curate + RAG Manual Control + Multi-agent Setup Fix
**Dev:** Claude em main SOLUTION_ERP (sub-agent registry empty cả session - pitfall #1+#2 confirmed) + bro pqhuy
**Duration:** ~5h (start ~17:00 → end ~22:00 GMT+7)
**Base commit:** `d99069a` (S26 chốt cuối Plan AG6)
**Final commits:** TBD (anh push manual sau approve)
---
## 🎯 Làm được
### Plan A.3 — RAG Manual Control + Custom Dashboard
🟧 **5 PS scripts**`D:\.claude-rag\scripts\` (em main solo cookie-cutter mirror — Implementer Case 2 ACCEPT criteria miss vì registry empty):
- `start.ps1` (2.4 KB) - Qdrant background + health check (initial 3s warmup + TimeoutSec 5)
- `stop.ps1` (1.4 KB) - Graceful stop + verify
- `status.ps1` (6.2 KB) - 6-section terminal report colored
- `dashboard.ps1` (17.4 KB) - Generate custom HTML + open browser
- `boot.ps1` (1.4 KB) - Auto-boot sequence (Startup shortcut)
🟧 **6 `$PROFILE` aliases:** rag-start / rag-stop / rag-status / rag-dashboard / rag-restart / rag-boot
🟧 **Auto-boot Startup folder shortcut** `%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\rag-boot.lnk` — auto-run boot.ps1 mỗi lần Windows boot.
🟧 **Custom MCP Dashboard HTML** `D:\.claude-rag\dashboard.html` (13.3 KB auto-gen) — 7 panels: Qdrant + MCP + Collections + Voyage + System + Agent MEMORY + Recent Logs. Auto-refresh 60s. Anthropic orange theme.
### Plan A.4 — RAG Onboarding Guide
🟧 **`docs/guides/rag-onboarding-guide.md`** (26.3 KB / ~440 lines / 13 sections + §A2):
- 13 sections: TL;DR, Background, Pre-check, Bootstrap 3 step, 6 MCP tools matrix, 4 sub-agent brief, Permission, Workflow, Troubleshooting, Tunings, Best practices, Status monitoring §12, Distributed Approach B §13
- §A2 Cấu trúc chuẩn em main pioneer (replaces Plan A.2 skip với full file tree + 8-step bootstrap checklist + 4 Gotcha discoveries S26-S27)
- Native Qdrant vs Custom MCP dashboard comparison table
### Memory Curate (3 việc anh chốt OK)
🟧 **4 MEMORY curate** -60% size cumulative:
- cicd-monitor: 72.4 KB → 15.8 KB (-78%)
- implementer: 38.8 KB → 22.0 KB (-43%)
- investigator: 34.9 KB → 16.3 KB (-53%)
- reviewer: 34.5 KB → 17.9 KB (-48%)
- Archive total 115 KB preserved verbose entries (rule §6.5 compliance)
🟧 **Audit drift §6.4 + §9.4** sớm (trigger +8 gotcha vượt threshold):
- 5 file patched: 4 `26 migration → 31 migration` + 1 `41 bẫy → 49 bẫy`
- Audit log file: `docs/changelog/skill-audit-2026-05-late.md`
- KEEP narrative §6.5: contract-workflow `96→77 test` historical preserved
### Plan F1 — Qdrant Native Dashboard Fix (UAT catch by anh)
🟧 **Root cause:** Qdrant Windows binary zip không bundle Web UI static files. Log warn `Static content folder for Web UI './static' does not exist` + `http://localhost:6333/dashboard` returns 404. Em pioneer S26 chỉ download `qdrant-x86_64-pc-windows-msvc.zip` (28.3 MB binary) không biết Web UI cần download riêng.
🟧 **Fix:** Download `dist-qdrant.zip` v0.2.12 (6.59 MB, released 2026-05-21 — 0.3 ngày trước) từ qdrant-web-ui GitHub releases + extract vào `D:\.claude-rag\qdrant-bin\static\` + flatten `dist/` subfolder up + restart Qdrant → HTTP 200 "UI | Qdrant" ✓
🟧 **Custom Dashboard panel link "Qdrant Native Dashboard"** giờ work end-to-end.
### Plan F2 — Multi-agent Setup Pitfalls Fix (VIPIX guide catch)
🚨 **Critical discovery:** VIPIX project xuất `docs/guides/multi-agent-pitfalls.md` 2026-05-22 — anh share cho em audit SOLUTION_ERP setup. Em phát hiện:
- 4 file `.claude/agents/*.md` dùng `model: claude-opus-4-7` (full ID = 200K fallback, KHÔNG 1M Opus)
- 4 file dùng non-standard field `effort: max` → silent reject possible
- → Registry chưa load cả session S27 (Agent error: "Agent type 'investigator' not found")
🟧 **Fix applied 4 file:** `model: inherit` (kế thừa 1M Opus parent) + remove `effort: max`. Pending CLI restart cho hot-reload (pitfall #1).
🟧 **Memory user-level NEW:** `feedback_subagent_setup_pitfalls.md` (235 lines) - cross-project pitfall checklist VIPIX + SOLUTION_ERP evidence. Integrated vào MEMORY.md index.
---
## ⚠️ Anti-pattern phá vỡ S27 (retrospective analysis)
Em chủ trì kiêm **5 roles** cả session vì registry empty:
| Task S27 | Implementer ACCEPT fit? | Outcome |
|---|---|---|
| C1 Curate cicd-monitor 72KB | ❌ REFUSE #1 (judgment §6.5) | Em solo CORRECT |
| C2-C4 Curate 3 agent MEMORY | ❌ REFUSE #1 | Em solo CORRECT |
| C5 Audit drift §6.4 + §9.4 | ❌ REFUSE #1 | Em solo CORRECT |
| **A3.1 Write 5 PS scripts** | ✅ **ACCEPT Case 2 (5 file cookie-cutter mirror)** | **Em miss delegate** |
| A3.2 Dashboard HTML + generator | ❌ REFUSE #2/#7 (first time pattern) | Em solo CORRECT |
| A4 Onboarding guide 440 lines | ❌ REFUSE #2 (docs judgment) | Em solo CORRECT |
| F1 Qdrant Web UI fix | ❌ REFUSE #4 (bug reasoning chain) | Em solo CORRECT |
| **F2 4 agent files fix** | ✅ **ACCEPT Case 1 (4 file mechanical same edit)** | **Em miss delegate** |
**Verdict:** 2/8 task lẽ ra delegate Implementer (Case 1+2) nhưng registry empty → em main forced solo. Net loss ~30 phút time + miss cookie-cutter mirror discipline.
**Reviewer Smart Friend guard miss critical:**
- Em main S27 write rag-onboarding-guide.md claim "Qdrant Native Dashboard `http://localhost:6333/dashboard`" WITHOUT actual verify
- Anh pqhuy UAT browser catch 404 → escalate
- → Reviewer pre-commit spawn (nếu registry load) sẽ catch Cat 1 "Wire claim verify" — em main self-review compromised
---
## E2E verified
### Plan A.3 verify
| Item | Status | Notes |
|---|---|---|
| 5 PS scripts execute | ✅ | rag-status / rag-start / rag-stop tested live |
| Custom Dashboard HTML | ✅ | 13.3 KB, 7 panels rendered, browser opened |
| `$PROFILE` aliases | ✅ | 6 functions loaded via `. $PROFILE` |
| Startup shortcut | ✅ | `rag-boot.lnk` 1378 bytes created |
| ASCII-only PS source | ✅ | Em fix 3 file (stop/boot/dashboard) sau Unicode mangling issue |
### Plan F1 verify
| Item | Status |
|---|---|
| Qdrant native dashboard HTTP 200 | ✅ "UI | Qdrant" title |
| Collections API live | ✅ proj_solution_erp returned |
| static/ folder size | 16.07 MB (Web UI v0.2.12) |
### Plan F2 verify (partial)
| Item | Status |
|---|---|
| 4 file edit `model: inherit` | ✅ Applied |
| 4 file remove `effort: max` | ✅ Applied |
| Sub-agent spawn test | ❌ Pitfall #1 - need CLI restart |
| Re-spawn post fix | ❌ Still "Agent type not found" |
| Registry hot-reload | ❌ Pending anh restart Claude Code CLI |
### Memory curate verify
| Agent | Before | After | Status |
|---|---:|---:|---|
| cicd-monitor | 72.4 KB | 15.8 KB | ✅ -78% |
| implementer | 38.8 KB | 22.0 KB | ✅ -43% |
| investigator | 34.9 KB | 16.3 KB | ✅ -53% |
| reviewer | 34.5 KB | 17.9 KB | ✅ -48% |
| **Total** | **180.6 KB** | **72.0 KB** | **-60%** |
---
## 🐛 Bug gặp + fix
| Bug | Fix |
|---|---|
| PowerShell 5.1 mangling Unicode `✓ → âœ"` trong .ps1 source | Replace ASCII-only `[OK]/[FAIL]/->/*/` trong PS code (HTML output unicode OK) |
| `dashboard.ps1` parser fail với emoji 🧠🗄️🔌 trong here-string HTML | Rewrite ASCII-only PS source, dùng CSS-styled `icon-box` div thay emoji |
| Qdrant native `localhost:6333/dashboard` 404 | Download `dist-qdrant.zip` v0.2.12 + extract `static/` + flatten + restart |
| `start.ps1` health check timeout 30s fail false alarm | Adjust to 3s warmup + TimeoutSec 5 |
| Qdrant crashed OOM "allocation 8.4MB failed" mid-session | rag-restart recovers (data persisted) |
| 4 sub-agent `model: claude-opus-4-7` silent fallback 200K | Fix `model: inherit` per VIPIX pitfall #2 |
| Sub-agent `effort: max` non-standard field silent reject | Remove field |
| Re-bootstrap fail pydantic serialization error | Defer S28 — debug needed |
---
## 📚 Docs updates
| File | Update |
|---|---|
| `docs/STATUS.md` | Last updated S27 chốt cuối (Memory curate + RAG manual control + multi-agent fix) |
| `docs/HANDOFF.md` | TL;DR S27 với pitfall lesson + Plan B Contract V2 Pending S28 |
| `docs/changelog/sessions/2026-05-22-s27-memory-curate-rag-dashboard-multi-agent-fix.md` | File này — session log đầy đủ |
| `docs/guides/rag-onboarding-guide.md` | NEW 26.3 KB / 440 lines / 13 sections + §A2 cấu trúc chuẩn |
| `docs/changelog/skill-audit-2026-05-late.md` | NEW audit log drift trigger sớm (~100 lines) |
| `.claude/agents/*.md` × 4 | Fix `model: inherit` + remove `effort: max` |
| `.claude/agent-memory/*/MEMORY.md` × 4 | Curate (-60%) + S27 entry proxy flush |
| `.claude/agent-memory/*/archive/2026-05-*.md` × 4 | NEW archive files preserve verbose Q1 entries |
| `.claude/skills/README.md` | `26 migration → 31` + `44 bẫy → 49` |
| `.claude/skills/ef-core-migration/SKILL.md` | 4 patch count drift |
| `.claude/skills/dependency-audit-erp/SKILL.md` | `41 bẫy → 49 bẫy` |
| Memory user-level `feedback_subagent_setup_pitfalls.md` | NEW 235 lines cross-project pitfall checklist |
| Memory user-level `feedback_rag_hybrid_pattern.md` | +1 bài học #8 (Qdrant Web UI static missing fix) |
| Memory user-level `MEMORY.md` index | +1 entry feedback_subagent_setup_pitfalls |
---
## 🤝 Handoff S28+
### Pending priority HIGH
1. **Anh restart Claude Code CLI** → verify 4 sub-agent load post `model: inherit` fix. Spawn test Investigator IMMEDIATELY mỗi session start (per `feedback_subagent_setup_pitfalls.md` §4).
2. **Plan B Contract V2 wire** (carry từ S25/S26) — kick off với 4 sub-agent ACTIVE: Investigator pre-flight + Implementer Case 2 mirror PE Mig 22-23 + Reviewer pre-commit + CICD Monitor post-push.
3. **Re-bootstrap RAG** SOLUTION_ERP để index S27 changes (rag-onboarding-guide.md + skill-audit-late + 4 MEMORY updates + feedback_subagent_setup_pitfalls). Bootstrap fail pydantic — debug + retry S28.
### Pending priority MEDIUM
4. **Audit S20-S26 memory log "Investigator spawn" claims** — verify history retroactive (có thật spawn hay nhầm general-purpose default?). Defer dedicated investigation S28+.
5. **Plan AI Phase 5** distributed bootstrap 4 project khác (NamGroup/DH/Ashico/Vipix) — em main project đó tự làm khi anh mở Claude Code project (Approach B distributed).
6. **Test debt catch-up Plan C bundle** (S22+1 + S25 + S26 bug fix chưa add regression — UAT mode defer per §7).
### Pending priority LOW
7. Benchmark RAG recall@10 golden dataset 100 query (gap optional)
8. Disaster recovery weekly backup Qdrant data → Dropbox (gap optional)
9. Gotcha #48 SQLite tie-break + #49 dual-phase UI confusion add `docs/gotchas.md` (carry từ S25)
---
## 📊 Thông số cumulative S27
| Metric | S26 chốt | S27 chốt | Δ |
|---|---|---|---|
| DB tables | 59 | 59 | 0 |
| Migrations | 31 | 31 | 0 |
| Endpoints | ~146 | ~146 | 0 |
| FE pages | 35 | 35 | 0 |
| Unit tests | 111 | 111 | 0 (UAT mode defer per §7) |
| Gotchas | 49 | 49 | 0 (gotcha #48, #49 still pending docs add) |
| Memory user-level | 23 | **24** | **+1 (`feedback_subagent_setup_pitfalls.md` NEW)** |
| Skills project-local | 6 | 6 | 0 |
| Sub-agents | 4 (broken registry) | 4 (fixed, pending CLI restart) | 0 count, +1 fix |
| Docs files | — | **+2** | `rag-onboarding-guide.md` + `skill-audit-2026-05-late.md` |
| PS Scripts infra | 0 | **+5** | `D:\.claude-rag\scripts\*.ps1` |
| Custom Dashboard | 0 | **+1** | `dashboard.html` auto-gen |
| Agent MEMORY total | 180.6 KB | 72.0 KB | **-60%** (115 KB archived) |
| Commits remote | `e23f51c..d99069a` | unchanged | **0 push S27** (all local + memory + docs - anh chốt push thủ công) |
### Multi-agent ROI S27
| Agent | Spawn | Actual outcome |
|---|---|---|
| 🟦 Investigator | 0 (registry empty) | Em main solo audit + curate |
| 🟨 Implementer | 0 (registry empty) | Em main solo 5 PS scripts + 4 file fix (lẽ ra delegate Case 1+2) |
| 🟥 Reviewer | 0 (registry empty) | Em main self-review compromised (miss Qdrant 404) |
| 🟩 CICD Monitor | 0 (no remote push) | N/A |
| 👤 Em main solo | continuous | ~5h cả 8 task + meta-discovery pitfall |
**Net learning S27:** Pitfall discovery + fix infrastructure → S28+ multi-agent CÓ THỂ work properly sau CLI restart. Anti-pattern em main solo = forced không phải choice.
---
## 🎓 Patterns reusable cross-project (S27 NEW)
1. **Multi-agent setup pitfall checklist** - 4 pitfall VIPIX + SOLUTION_ERP evidence (`feedback_subagent_setup_pitfalls.md`)
2. **PS scripts ASCII-only discipline** - HTML output unicode OK, PS source phải ASCII (CSS-styled badges + icon-box thay emoji)
3. **Qdrant Windows binary 2-step setup** - binary + Web UI static download separate (gotcha #8 `feedback_rag_hybrid_pattern.md`)
4. **Custom Dashboard PS generator pattern** - here-string HTML template + collect data via Invoke-RestMethod + Out-File UTF-8 + Start-Process browser
5. **Memory curate proxy pattern khi registry empty** - em main update sub-agent MEMORY trực tiếp với retrospective analysis (REFUSE log validation + ACCEPT miss flag)
6. **Audit log file separate khi drift sớm** - `skill-audit-YYYY-MM-late.md` thay vì rewrite existing audit log (preserve historical trail per §6.5)
7. **Dashboard SNAPSHOT vs LIVE distinction** - static HTML generated by PS = snapshot tại 1 thời điểm, browser meta refresh KHÔNG re-run PS. Anti-pattern em pioneer commit: meta refresh 60s falsely impression live. Fix: add prominent timestamp + warning banner + link to Qdrant native dashboard (LIVE API fetch). Pattern reusable cho bất kỳ custom dashboard PowerShell.
8. **NSSM Windows Service Option 4b upgrade pattern** - Qdrant binary natively no `--service` flag → wrap với NSSM (3 MB binary download from nssm.cc release/2.24, retry 503 transient). install-service.ps1 + fix-service-start.ps1 elevated scripts ready. Auto-start boot-time + auto-restart on crash + survive logout. Recipe transferable cho bất kỳ database/server binary cần Windows Service mode mà không có native support.
9. **Hybrid context loading discipline (Cách A defensive)** - Layer 1 blanket auto-load ~120K (CLAUDE+STATUS+HANDOFF+MEMORY index+skills+sub-agents) + Layer 2 RAG retrieve on-demand via 6 MCP tools. Decision gate per project MD size: < 200K skip RAG / 200K-1M lazy / > 1M MANDATORY. Token budget zones 5-tier (green/warning/approach/critical). 7 anti-patterns avoid (Read full session log cũ, search vague, em main solo qualify Implementer Case 1/2, skip store_memory, heavy session > 6h). Onboarding §A3 NEW comprehensive.
---
## 🔧 Plan A.3+ Upgrade Post-Wrap — Option 4b NSSM Windows Service
> **Trigger:** Anh phản biện "Qdrant nên auto-start như database server thường (PostgreSQL/SQL Server đều Windows Service auto-start)" → em upgrade Option 4a (manual scripts S26 chốt) lên **Option 4b NSSM Windows Service**.
> **Done:** Post-initial wrap-up cùng session S27 — anh chạy 2 elevated PS scripts → service Running successfully.
### NSSM install + service registration
🟧 **Download NSSM 2.24** ~351 KB từ `https://nssm.cc/release/nssm-2.24.zip` (retry 1× sau 503 transient) → extract `D:\.claude-rag\nssm\nssm.exe` (323 KB win64 binary)
🟧 **install-service.ps1** (5.4 KB elevated script):
- Verify Admin privileges
- Remove old service nếu exist (idempotent)
- `nssm install Qdrant qdrant.exe` + AppDirectory `D:\.claude-rag\qdrant-bin`
- Log paths `logs/qdrant-service.log` + `.err` với rotation 10 MB
- `Start: SERVICE_AUTO_START` (boot-time auto-start trước login)
- `AppExit Default Restart` + `AppRestartDelay 3000` (auto-respawn 3s sau crash)
- DisplayName "Qdrant Vector DB (RAG Unified)" + Description friendly
- Start service + health verify HTTP `localhost:6333/healthz`
### Bug gặp: WAL lock conflict
🟧 **Symptom:** Step [5/6] Start failed — service Paused state, log `Can't init WAL: Kind(WouldBlock)`.
🟧 **Root cause:** Em start Qdrant manual PID 9800 ngay trước install-service.ps1 → manual process held Write-Ahead Log file lock → service không init được WAL → fail start + Paused state.
🟧 **fix-service-start.ps1** (2.4 KB elevated script) — recovery:
- Stop-Service -Force (kill Paused state)
- Kill any remaining qdrant.exe (defensive cho orphan PID)
- Wait 3s
- Start-Service Qdrant
- Verify HTTP + process PID + RAM
🟧 **Result confirmed:** Service Running PID 4476 RAM 101.8 MB. Auto-start ENABLED ✓
### 4 PS scripts updated to Service mode
🟧 **start.ps1**`Start-Service Qdrant` (cần Admin). Detect already Running + skip + show service info.
🟧 **stop.ps1**`Stop-Service Qdrant -Force` (cần Admin). Defensive kill orphan qdrant.exe nếu detected.
🟧 **status.ps1**`Get-Service Qdrant` (no Admin) thay process check + Section 1 expanded với service info (Status, StartType, DisplayName) + Process info defensive guard `try/catch` cho StartTime null khi spawn from service.
🟧 **boot.ps1** → drop Qdrant start (service auto-start) + verify service Running + regenerate Dashboard + open browser. Used by Startup folder shortcut `rag-boot.lnk`.
### Dashboard SNAPSHOT vs LIVE clarification
🟧 **Bug discovered:** Custom Dashboard `dashboard.html` show "Running" badge stale 10+ phút sau Qdrant DOWN. Root cause: `<meta http-equiv="refresh" content="60">` chỉ reload HTML cached, KHÔNG re-run PS script.
🟧 **Fix applied:** Remove meta refresh + add prominent yellow banner top:
```html
⚠ Dashboard này là STATIC SNAPSHOT tại thời điểm generated (xem timestamp).
Browser auto-refresh chỉ reload HTML cached, KHÔNG poll Qdrant API live.
Muốn data live → mở Qdrant Native Dashboard (fetch API real-time).
```
🟧 **Header timestamp** + label "SNAPSHOT (not live)" red color visible.
🟧 **Service status panel** added Get-Service info: Service (Running) / Auto-start (Automatic) / DisplayName.
### Onboarding guide §A3 NEW comprehensive
🟧 **Section §A3 Context loading Hybrid pattern** (~242 lines added) — 8 sub-sections:
- §A3.1 Why Hybrid Cách A vs Cách B vs Skip RAG (decision gate)
- §A3.2 Layer 1 Blanket auto-load checklist (~200-280 KB ≈ 50-70K tokens)
- §A3.3 Layer 2 RAG retrieve decision tree (7-branch)
- §A3.4 Token budget guidance 1M Opus (5 utilization zones)
- §A3.5 6 MCP tools examples concrete (Vietnamese + English queries)
- §A3.6 Best practices em main daily workflow (morning + in-session + EOS + monthly)
- §A3.7 7 Anti-patterns cross-project (distilled VIPIX + SOLUTION_ERP)
- §A3.8 Context monitoring + when to end session (heuristics + protocol)
### Memory user-level updates
🟧 **`feedback_rag_distributed_ownership.md`** Decision 2 upgraded Option 4a → 4b NSSM với gotcha S27 install (nssm.cc 503 transient + WAL lock conflict + Process.StartTime null guard).
### Final state Service mode
| | State |
|---|---|
| Qdrant Service | Running (Automatic) ✓ |
| HTTP /healthz | OK ✓ |
| Collection proj_solution_erp | 3460 chunks (⚠ indexed_vectors=0 HNSW broken — pending re-bootstrap S28) |
| Auto-start on Windows boot | ENABLED ✓ |
| Auto-restart on crash | ENABLED 3s delay ✓ |
| 7 PS scripts total | start/stop/status/dashboard/boot/install-service/fix-service-start |
| Onboarding guide | 42.5 KB / 682 lines / 14 sections + §A2 + §A3 |

View File

@ -0,0 +1,159 @@
# Session 29 — 2026-05-22 — Plan CA + Plan B Contract V2 wire end-to-end
> **TL;DR:** 20 commits cumulative S29 push 4 CI Runs PASS deploy production. Plan CA (Move "Cấu hình danh mục" admin → eoffice) + Plan B Contract V2 wire (mirror PE Mig 22-26). Smart Friend Reviewer + CICD Monitor cumulative 4× catches MAJOR/CRITICAL bugs pre/post deploy. 8 patterns reusable NEW.
## 🎯 Session goals (anh chốt 2026-05-22 startup S29)
1. ✅ Re-bootstrap RAG SOLUTION_ERP S27+S28 NEW content (60.9s, 2,794 chunks)
2.**Plan CA** — Move "Cấu hình danh mục dùng chung" (9 menu Master + Catalogs) từ fe-admin → fe-user/eoffice + role mới `CatalogManager`
3.**Plan B** — Contract V2 wire mirror PE Mig 22-26 (COEXIST V1+V2)
4. ✅ Add MCP RAG tools cho 4 sub-agent definitions (pending CLI restart S30)
5. ✅ End-to-end demo cross-project RAG search (NAMGROUP HRM 10 info samples)
## 📦 Commits cumulative S29 — 20 commits push `3cb54e0..38f1c4d`
### Plan CA — 7 commits
| # | SHA | Chunk | Owner |
|---|---|---|---|
| 1 | `06a441c` | B FE move 4 master pages (948 LOC byte-identical) | 🟨 Implementer |
| 2 | `80d39a0` | A BE Role CatalogManager + Seed permissions | 👤 Em main |
| 3 | `c995f42` | C Sidebar filter 2 app | 👤 Em main |
| 4 | `4a592cf` | D Seed demo user catalog.manager | 👤 Em main |
| 5 | `68bcedd` | D2 Hotfix password ≥12 chars S22+2 policy (Reviewer catch) | 👤 Em main |
| 6 | `e55d96b` | **Hotfix 1** resolvePath staticMap silent sidebar drop (anh UAT catch) | 👤 Em main |
| 7 | `6eec8d7` | Docs wrap (gotcha #50 + Pattern 16-bis + STATUS) | 👤 Em main |
### MCP RAG add — 1 commit
| # | SHA | Description |
|---|---|---|
| 8 | `b51fc94` | Add `mcp__rag-unified__search_memory + cross_project_search` cho 4 agent definitions (pending CLI restart hot-reload S30+) |
### Plan B Contract V2 wire — 11 commits + 1 docs wrap
| # | SHA | Chunk | Owner |
|---|---|---|---|
| 9 | `58898e8` | A1 Entity Contract +2 V2 fields | 👤 Em main |
| 10 | `a85e437` | A2 Mig 32 + Configuration + Seed sample (4,094 LOC EF auto-gen) | 🟨 Implementer |
| 11 | `138469d` | B Service ApproveV2Async branch + gen mã HĐ adapt | 👤 Em main |
| 12 | `26c98d3` | C Mig 33 ContractLevelOpinions cookie-cutter (4,265 LOC) | 🟨 Implementer |
| 13 | `1f199b0` | B2 UPSERT block + ResolveActorFullName helper | 👤 Em main |
| 14 | `ef23308` | E1 CreateContractCommand +ApprovalWorkflowId V2 | 👤 Em main |
| 15 | `62b50d1` | D FE Workspace V2 Select dropdown × 2 app | 🟨 Implementer |
| 16 | `48f6d22` | E2 ContractDetailDto + populate LevelOpinions[] | 👤 Em main |
| 17 | `14feb69` | E3 FE Section 5 LevelOpinionsV2 × 2 app (em main solo, Implementer stopped mid-task) | 👤 Em main |
| 18 | `3e92584` | **Hotfix Reviewer** ApplicableType=Contract validation guard (Reviewer MAJOR catch) | 👤 Em main |
| 19 | `38f1c4d` | **Hotfix CICD** SeedSampleContractWorkflowV2 OUT of DemoSeed gate (CICD CRITICAL catch — gotcha #51 NEW) | 👤 Em main |
| 20 | (this session log) | Docs wrap S29 + session log + flush 4 MEMORY | 👤 Em main |
## 🎯 Multi-agent ROI explosive S29
| Agent | Spawns | Tokens | Major catches |
|---|---:|---:|---|
| 🟦 **Investigator** | 2 | ~40K | Plan CA terrain map 9 menu + GOTCHA tree-inherit; Plan B audit Contract V1 + recommend 6→9 chunk re-split + 3 surprise (zero ApplicableType=3 prod, RejectedAtStepIndex drift, ContractType variants generic) |
| 🟨 **Implementer Case 2** | 5 | ~82K | Plan CA Chunk B 4 master pages mirror byte-identical; Plan B A2 Mig 32 + C Mig 33 + D FE Workspace V2 cookie-cutter; **E3 stopped mid-task** (complex FE judgment, em main solo finish) |
| 🟥 **Reviewer** | 4 | ~355K | **MAJOR Plan CA Hotfix D2:** Password ≥12 chars policy S22+2 catch BEFORE prod 401; **MAJOR Plan B Hotfix:** ApplicableType=Contract validation guard catch BEFORE security gap exploit |
| 🟩 **CICD Monitor** | 3 | ~90K | 2 fail 529 Anthropic transient → em main fallback manual smoke; **1 CRITICAL Plan B Hotfix:** SeedSampleContractWorkflowV2 gated by DemoSeed → V2 path BLOCKED prod → gotcha #51 NEW |
| 👤 **Em main Solo** | — | ~150K | Coordinate 4 agents + Chunk B/B2 cross-stack reasoning + E3 finish + 3 hotfix re-edit + 2 docs wrap |
| **TOTAL** | 14 spawn | ~715K | 4× Smart Friend cumulative wins |
## 🛡️ Smart Friend pattern proven 4× cumulative
| # | Session | Catch | Severity | Owner |
|---|---|---|---|---|
| 1 | S22 | Class-level `[Authorize(Policy)]` silent 403 (gotcha #44) | MAJOR | 🟥 Reviewer |
| 2 | S25 | Multi-Changelog SQLite tie-break test discriminator (gotcha #48) | MAJOR | 🟩 CICD Monitor |
| 3 | **S29** | Password ≥12 chars policy + ApplicableType=Contract validation | MAJOR | 🟥 Reviewer |
| 4 | **S29** | INFRASTRUCTURE vs DEMO seed gate confusion (gotcha #51) | CRITICAL | 🟩 CICD Monitor |
## 🆕 Patterns reusable NEW saved S29 (8 patterns)
1. **9-menu permission terrain map pattern** (Investigator) — inventory file paths + LOC + component parity check trước delegate chunk
2. **V1+V2 coexist boundary** (Investigator) — KHÔNG drop V1 nếu prod data pinned. Plan F precedent S22 (ABORT khi định drop V1)
3. **Reference template paths cross-module mirror** (Investigator) — cite EXACT line ranges PE → Contract V2 (Mig 23:14-31, Mig 24:14-17, ApproveV2Async 446-634, UPSERT 519-546, ResolveActor 774-783) → saving 30%+ time
4. **Pattern 12-bis cross-module entity cookie-cutter mirror** (Implementer) — entity + Mig + Config + DbSet 4-file mirror cho cross-module clone scenarios
5. **Pattern 16-bis 4-place mirror cross-app** (Implementer) — reinforced 2× Plan CA + Plan B Workspace
6. **Cross-module security validation mirror Cat 3** (Reviewer) — khi mirror entity/command cross-module, MUST mirror validation guards (ApplicableType + FK + idempotent). Easy miss
7. **INFRASTRUCTURE vs DEMO seed classification** (CICD #51) — decision tree: production cần để work end-to-end? YES → INFRASTRUCTURE ungate
8. **Race condition em main + Implementer parallel BE → stash workaround** (Implementer Plan B A2+B) — Implementer auto-stash em main WIP cho clean build. Forward: SEQUENTIAL chunks A→B→C khi cùng touch BE, NOT parallel
## 📊 State chốt S29
| Metric | Before S29 | After S29 | Δ |
|---|---:|---:|---|
| Migrations | 31 | **33** | +2 (Mig 32 Contract V2 + Mig 33 LevelOpinions) |
| DB tables | 59 | **60** | +1 (ContractLevelOpinions) |
| API endpoints | ~146 | **~148** | +1 (V2 contract create) |
| FE pages | 35 | **38** | +3 (4 master moved to fe-user — net +3 sau remove fe-admin) |
| Tests | 111 | **111** | unchanged (UAT mode skip; V2 logic NO test cover defer) |
| Gotchas | 49 | **51** | +2 (#50 staticMap silent drop + #51 INFRASTRUCTURE vs DEMO seed) |
| Memory user-level | 25 | **25** | unchanged |
| Skills | 6 | **6** | unchanged |
| Sub-agents | 4 | **4** | unchanged (MCP RAG added pending CLI restart) |
| AppRoles | 13 | **14** | +1 (CatalogManager) |
| Active prod users | 33 | **34** | +1 (catalog.manager@solutions.com.vn) |
| V1 contracts prod | 7 | **7** | preserved (no V2 contract yet) |
| RAG chunks SOLUTION_ERP | 3,462 | **2,794** | -668 (re-bootstrap clean indexing, dedup improvement) |
| Bundle hash rotate | — | **4×** | fe-admin: `BvcWrq2z→leEMWFLU→BBADl46y`, fe-user: `Bg2FNeIz→DVBLmZlt→Dgn1iU9E→DA_VI3zO` |
## 🚀 NEW capability prod end-to-end
**1. Catalog management user role:**
- Login `catalog.manager@solutions.com.vn / CatalogMgr@2026`
- fe-user sidebar: Master + 4 leaf (Suppliers + Projects + Departments) + Catalogs root + 4 sub (Units/Materials/Services/WorkItems)
- Full CRUD 9 menu, KHÔNG access fe-admin tools
**2. Contract V2 workflow path:**
- Login Drafter (vd `qs.hoang@solutions.com.vn`)
- `/contracts/new?type=1` → Workspace dropdown "Quy trình duyệt V2" có `QT-HD-V2-001`
- Pick V2 + create → contract pin `ApprovalWorkflowId`
- Submit ChoDuyet → workflow advance Step 1 Cấp 1
- Login `binh.le@solutions.com.vn` (CCM approver) → Approve
- Service `ApproveV2Async` UPSERT opinion + advance → terminal Phase=DaPhatHanh + gen mã HĐ RG-001
- Detail page Section 5 LevelOpinionsV2 render dynamic với opinion data
## ⚠️ Pending S30+ follow-up
1. **Anh restart Claude Code CLI** để 4 sub-agents pick up MCP RAG tools (commit `b51fc94`)
2. **Anh UAT verify V2 contract end-to-end** flow (Drafter → CCM approve → DaPhatHanh)
3. **Test bundle Plan B**: regression test ApproveV2Async (~150 LOC) + ApplicableType validation guard (xUnit Domain policy + Infra service test)
4. **Curate dedicated session 4 MEMORY** (Implementer 35.4KB > hard threshold)
5. **Anh UAT verify catalog manager** end-to-end (login + CRUD 9 menu)
## 📝 Files touched S29
### BE (~715 LOC actual + ~7,970 EF Designer = ~8,685)
- `src/Backend/SolutionErp.Domain/Identity/AppRoles.cs` (+6 CatalogManager)
- `src/Backend/SolutionErp.Domain/Contracts/Contract.cs` (+12 V2 fields + LevelOpinions nav)
- `src/Backend/SolutionErp.Domain/Contracts/ContractLevelOpinion.cs` (NEW 36)
- `src/Backend/SolutionErp.Application/Contracts/Services/IContractWorkflowService.cs` (+10 skipToFinal)
- `src/Backend/SolutionErp.Application/Contracts/ContractFeatures.cs` (+96 V2 + Hotfix Reviewer)
- `src/Backend/SolutionErp.Application/Contracts/Dtos/ContractDtos.cs` (+28 V2 DTO + LevelOpinion)
- `src/Backend/SolutionErp.Application/Common/Interfaces/IApplicationDbContext.cs` (+3 ContractLevelOpinions DbSet)
- `src/Backend/SolutionErp.Infrastructure/Persistence/ApplicationDbContext.cs` (+2 DbSet)
- `src/Backend/SolutionErp.Infrastructure/Persistence/Configurations/ContractConfiguration.cs` (+15 FK + Index)
- `src/Backend/SolutionErp.Infrastructure/Persistence/Configurations/ContractLevelOpinionConfiguration.cs` (NEW 37)
- `src/Backend/SolutionErp.Infrastructure/Persistence/DbInitializer.cs` (+~120 CatalogManager seed + SampleContractWorkflowV2 + ungate Hotfix CICD)
- `src/Backend/SolutionErp.Infrastructure/Services/ContractWorkflowService.cs` (+200 V2 branch + ApproveV2Async + UPSERT + ResolveActor)
- `src/Backend/SolutionErp.Infrastructure/Persistence/Migrations/20260522051059_AddApprovalWorkflowToContract.cs` (NEW Mig 32)
- `src/Backend/SolutionErp.Infrastructure/Persistence/Migrations/20260522052240_AddContractLevelOpinions.cs` (NEW Mig 33)
### FE (~1,050 LOC × 2 app sometimes byte-identical)
- `fe-user/src/pages/master/{Suppliers,Projects,Departments,Catalogs}Page.tsx` (NEW 948 byte-identical mirror admin)
- `fe-user/src/lib/menuKeys.ts` (+5 Catalogs sub-keys)
- `fe-user/src/App.tsx` (+5 master routes)
- `fe-admin/src/components/Layout.tsx` (+ADMIN_HIDDEN_MASTER_KEYS 9 keys hide)
- `fe-user/src/components/Layout.tsx` (-4 USER_HIDDEN_KEYS + 7 resolvePath staticMap Hotfix 1)
- `fe-admin/src/pages/contracts/ContractCreatePage.tsx` (+44 V2 Workspace dropdown)
- `fe-user/src/pages/contracts/ContractCreatePage.tsx` (+44 V2 Workspace mirror)
- `fe-admin/src/types/contracts.ts` (+22 V2 fields + ContractLevelOpinion)
- `fe-user/src/types/contracts.ts` (+22 V2 fields mirror)
- `fe-admin/src/components/contracts/ContractDetailContent.tsx` (+40 Section 5 V2)
- `fe-user/src/components/contracts/ContractDetailContent.tsx` (+40 Section 5 V2 mirror)
### Docs + scripts + agent setup
- `docs/STATUS.md` (S29 wrap header)
- `docs/HANDOFF.md` (S29 wrap header)
- `docs/gotchas.md` (+gotcha #50 staticMap + #51 INFRASTRUCTURE vs DEMO seed)
- `docs/changelog/sessions/2026-05-22-s29-plan-ca-plan-b-contract-v2-wire.md` (NEW this session log)
- `.claude/agents/{investigator,implementer,reviewer,cicd-monitor}.md` (+MCP RAG tools)
- `.claude/agent-memory/{investigator,implementer,reviewer,cicd-monitor}/MEMORY.md` (S29 wrap entry FIFO each agent perspective)
- `.claude/agent-memory/implementer/pattern_master_page_mirror.md` (NEW Pattern 16-bis cross-app from Plan CA Chunk B)
- `scripts/plan-ca-verify-menu.{sql,ps1}` + `plan-ca-verify-perms.{sql,ps1}` + `plan-ca-run-perms.ps1` + `plan-b-verify-prod.{sql,ps1}` + `plan-b-run-verify.ps1` (NEW verify scripts)

View File

@ -0,0 +1,116 @@
# 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?**
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ô?**
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 ). Skill description giữ Mig 31 latest semantic "F2 per-Approver-slot swap" thay plain count.
3. **Gotcha context vẫn còn ý nghĩa khi đọc rời rạc không?**
`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 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)