Cadence audit (2026-06-01), docs-only -> CI-skip. investigator-codebase drift scan (ground-truth from disk) -> em main patch. No code touched, 154 test unchanged. Drift fixes (42 count corrections): 40->42 mig, 84/59/55/47->91 tables, 130/111->154 test, 52/49->56 gotcha across CLAUDE.md, docs/CLAUDE.md, ef-core-migration + dependency-audit skills, schema-diagram, database-guide. schema-diagram migration table extended Mig 17-42; ef-core history Mig 27-42; detailed-section gap (Mig 27-42 modules) flagged explicit (deferred, not silent). AI_INFRA bundle 06-01 (federated, full scope): - A: RAG T1/T2 auto-ack - C: hygiene 7/7 agent-mem L1 <=16KB; "25KB"->"~30KB tiered" wording x7 - D: #4 self-sustaining adoption-report step -> /session-end Phase 6.3 - E/F: report + ledger -> docs/governance/ Carry-over .mcp.json + BROADCAST-05-29 left untouched (concurrency rule). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
121 lines
7.7 KiB
Markdown
121 lines
7.7 KiB
Markdown
---
|
||
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.
|
||
|
||
### 6.3 INFRA-ADOPTION report (cadence #4 — self-sustaining, AI_INFRA bundle 2026-06-01)
|
||
- NẾU session này adopt bất kỳ infra/governance change từ AI_INFRA (RAG fix / session-cmd / hygiene / charter / Gov-v2) → **tự-sinh adoption-report §E** TRƯỚC khi đóng (KHÔNG cần anh nhắc):
|
||
- **SERVER-VERIFIABLE** (Gitea url): chain N commit sha (origin synced, tree clean)
|
||
- Per-§: §A RAG · §B Gov · §C Hygiene (X/7 agent-mem L1 ≤30KB · bloat>50KB=0 — đo byte thật) · §D session-cmd (KHUNG added `<sha>` / skip `<đã-có>`) · §E evidence (sha list + integrity moved-not-cut) · §F mirror ledger committed `<sha>`
|
||
- **NẤC:** agreed / executed / VERIFIED-self. Caveat by-design: L2 gitignored · CANONICAL-pull = trust.
|
||
- Surface report cho anh main relay AI_INFRA (1 lần báo = ACK+executed+evidence). Em main `/session-start` kế watch + double-check → cơ chế 2 chiều tự duy trì.
|
||
- Session KHÔNG adopt infra gì → ghi "N/A (no infra adoption this session)".
|
||
|
||
---
|
||
|
||
**Trigger sau Phase 6:** Session đóng. Working memory có thể `/clear` an toàn (persistent memory đã flush + commit + push).
|