[CLAUDE] Docs: S40 adopt /session-start + /session-end slash commands (bulletin MUC 3)

- .claude/commands/session-start.md (3 phase READ/AUDIT/REPORT) + session-end.md (6 phase FLUSH/WRITE/VERIFY/REPORT/COMMIT/EVAL)
- Adapted: 7-agent topology (not 4 default) + charter v2 (RAG eval/re-index = AI_INFRA op) + SendMessage N/A harness caveat
- Placeholders filled: MD core + 6 skill + dotnet test SolutionErp.slnx + commit scope + proj_solution_erp + cron 2026-06-01
- 0 leftover {{placeholder}}/comment. Activate: anh main restart CLI (slash KHONG hot-reload)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-05-29 18:20:20 +07:00
parent 6f08d1f0eb
commit c8ff5e108b
2 changed files with 217 additions and 0 deletions

View File

@ -0,0 +1,112 @@
---
description: Đóng session SOLUTION_ERP — flush 7-agent memory, sync MD/RAG, commit + push, eval. Run cuối mỗi session.
---
# /session-end — Session closeout (FLUSH + WRITE + VERIFY + REPORT + COMMIT + EVAL)
> Trigger cuối session. Em main chủ trì, gọi lại sub-agent đã spawn.
> ⚠️ **Harness note:** SendMessage KHÔNG khả dụng → "flush con đã spawn" = agent đã tự update MEMORY khi return (BẮT BUỘC trong agent frontmatter). Em main đọc lại MEMORY on-disk để synthesize, KHÔNG cần re-spawn chỉ để flush.
## 📋 BƯỚC 0 — Show command body (visibility, no wait)
Em main PHẢI echo **TOÀN BỘ nội dung command body này** (đầy đủ Phase 1-6 + sub-section + guard rule) trong response đầu tiên ĐỂ ANH USER ĐỌC LẠI.
**Quy trình (KHÔNG wait confirm):**
1. Em echo full content command (raw markdown, KHÔNG tóm tắt, KHÔNG cắt)
2. Em proceed execute Phase 1 → 6 sequential ngay
3. Anh user điều chỉnh **cuối session** nếu cần thay đổi nội dung command (KHÔNG mid-flow interrupt)
## Phase 1 — FLUSH (sub-agent memory)
**Điều kiện:** Chỉ xử lý con đã spawn trong session. KHÔNG spawn mới chỉ để flush (agent đã update MEMORY khi return).
1. Đọc MEMORY.md update của sub-agent đã spawn (Tiered L1 HOT):
- 🟦 **investigator-codebase** — research findings + audit results + schema/count grounding
- 🟦 **investigator-api** — external docs/CVE/lib eval + cross-project port + RAG fleet
- 🟨 **implementer-backend** — BE patterns applied + scope refusals (ACCEPT vs REFUSE)
- 🟧 **implementer-frontend** — FE mirror SHA256 + Pattern 16-bis 4-place + KIND_CONFIG
- 🟪 **test-specialist** — test bundle added + coverage gap + spec drift detected
- 🟥 **reviewer** — anti-patterns observed + Smart Friend catches + claim verification
- 🟢 **cicd-monitor** — Run verdict + bundle hash rotate + Mig prod + corpus drift
2. Synthesize cross-agent learnings → integrate vào:
- User auto-memory `MEMORY.md` (index — append entry mới, KHÔNG rewrite)
- `docs/rules.md`, `docs/architecture.md`, `docs/gotchas.md`, `docs/database/`, `docs/flows/`
- rules, architecture, gotcha, skill, daily, hand-off (`docs/HANDOFF.md`), DB, luồng DB, session log (`docs/changelog/sessions/`)
## Phase 2 — WRITE (update MD/RAG)
### 2.1 UPDATE/Re-rank MD/RAG đã thay đổi
- `docs/STATUS.md` (In Progress → Recently Done) + `docs/HANDOFF.md` (tiering: giữ current+2-3 session, archive cũ → session logs per `feedback_status_handoff_tiering`)
- rules, architecture, gotcha, skill, hand-off, DB, luồng DB, session log
### 2.2 Skill registry
- Liệt kê 6 skill. Dùng skill khi task khớp (KHÔNG tự suy luận lại)
- Skill staleness audit chỉ chạy theo lịch định kỳ (cron 2026-06-01)
- Phân bổ skill mới phù hợp per agent (README matrix)
### 2.3 Memory entry mới
- Add memory entry NẾU phát hiện rule/gotcha/decision quan trọng chưa có (vd `feedback_*`)
- **KHÔNG rewrite toàn bộ memory** — chỉ append entry mới + update MEMORY.md index 1 dòng
### 2.4 Quy tắc consolidate MD/RAG (CRITICAL — đọc kỹ) [GENERIC — GIỮ NGUYÊN]
- **Thứ 1:** Rất quan trọng, đọc kỹ lại quy tắc consolidate đúng cách, những thứ quan trọng KHÔNG đc cắt, chỉ phân tầng cho gọn lại, và xóa double. Phân tầng để các session sau đọc lại đúng chính xác context, không bị over context, rất quan trọng đấy.
- **Thứ 2:** Nếu MD/RAG không có gì cần điều chỉnh thì KHÔNG cần phải cố gắng điều chỉnh, điều này cũng rất quan trọng.
## Phase 3 — VERIFY (test + state)
### 3.1 Unit test verify
- `dotnet test SolutionErp.slnx --nologo --verbosity minimal` — verify count tăng đúng (vd 130 → 132 nếu thêm 2 test). Update STATUS Recently Done.
- Phase 9 UAT mode: feature test-after (có thể skip per chunk), vẫn `npm run build` × 2 app. Nếu chỉ docs/infra → ghi "N/A".
### 3.2 Sub-agent state
- Kiểm tra trạng thái spawn sub-agent (7-agent)
- Task bất kỳ phải phân việc đầy đủ đúng vai trò split boundary (BE→backend, FE→frontend, test→test-specialist)
### 3.3 RAG + MCP state
- RAG corpus health (chunk count delta, `last_indexed_at`). Re-index full = AI_INFRA op (charter v2).
- MCP `rag-unified` stdio launch verify (5 tool)
- Re-rank coverage: prompts đã store + đánh dấu re-rank đầy đủ chưa
## Phase 4 — REPORT (plan status)
Đặt tên + tô màu cho Plan hiện tại, tiến độ + agent assignment:
```
Plan cha: [tên]
Plan con: [tên]
Task: [tên] — STATUS: 🟢 done | 🟡 in-progress | ⚪ pending
- 🟦 investigator-codebase — [a] - 🟦 investigator-api — [b]
- 🟨 implementer-backend — [c] - 🟧 implementer-frontend — [d]
- 🟪 test-specialist — [e] - 🟥 reviewer — [f]
- 🟩 cicd-monitor — [g] - 👤 chủ trì — [h]
```
### SOLUTION_ERP report (per-session)
- Tóm tắt việc done + commit SHA + CI Run verdict + bundle hash rotate + plan progress
- (SE KHÔNG copy phần "6 sister report" của AI_INFRA host)
## Phase 5 — COMMIT (release)
### 5.1 Release + commit
- Kiểm tra release, commit task vừa hoàn thành. ⚠️ Update `SolutionErp.slnx` nếu có `.cs/.csproj` mới.
- Format: `[CLAUDE] <scope>: <imperative message>` + `Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>`
- Scope: `Contract · PurchaseEvaluation · Budget · Form · Workflow · Supplier · Auth · Admin · Api · App · Domain · Infra · FE-Admin · FE-User · Tests · Docs · CICD · Scripts · Skill`
### 5.2 Push remote
- `git push origin main``git.baocaogiaoduc.vn/vietreport-admin/solution-erp`
- Docs-only commit → CI skip per gotcha #41 (paths-ignore `docs/**` + `**/*.md` + `.claude/skills/**`). Code commit → spawn 🟩 cicd-monitor verify deploy.
## Phase 6 — EVAL (chunk + RAG)
### 6.1 Chunk MD/RAG update
- Cập nhật chunk MD/RAG content mới (Proposal/WorkflowApps/Phase 11...). SE-side: `mcp__rag-unified__store_memory` key facts (stopgap content-gap).
### 6.2 RAG eval
- ⚠️ **Charter v2:** RAG eval + full re-index (`bootstrap.py`, golden set, recall@5) = **AI_INFRA op** (cần VOYAGE_API_KEY). SE KHÔNG tự chạy.
- SE-side closeout: (a) verify `store_memory` chunk retrievable (1 `search_memory` rerank check); (b) flag drift/staleness lên AI_INFRA nếu `last_indexed` lag nhiều; (c) báo cáo broadcast nếu adopt infra change.
---
**Trigger sau Phase 6:** Session đóng. Working memory có thể `/clear` an toàn (persistent memory đã flush + commit + push).