adap-apply 2026-06-03-Agent-ultracode-hmw-mem-governance (reviewer_gate PASS). PROJECT-FIT=ADOPT tailored: SE 8-agent roster. nac=executed-file (verified-pending restart+spawn-test). - T1/T2 toggle: .claude/commands/ultra-on.md + ultra-off.md; marker .claude/hmw-mode.on gitignored (T2 non-negotiable). - T3: session-start BUOC 0.5 reads marker -> reports ON/OFF. - S2/S3/S4: .claude/workflows/hmw.js P2 fan-out — checkpointApproved throw (mechanized), args JSON.parse-guard, role-whitelist fail-soft, VALID_ROLES=8 SE agents, sub-no-spawn-sub, return schema findings+memoryDelta 4-field (R1). - M1-M5: B1 slice-inject / M2 return-delta-only / B3 single-writer append-only / B2 harvest-lien / M5 store_memory-strip re-verified intact (0 tools-grant). - agents/README.md +HMW governance section (VALID_ROLES source-of-truth) + adap-report 5-field LOCK. Test 181 unchanged (no .cs/.tsx). CI-skip (all .md/.js/.gitignore). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
114 lines
7.5 KiB
Markdown
114 lines
7.5 KiB
Markdown
---
|
|
description: Bootstrap session SOLUTION_ERP — load context, audit state (7-agent + RAG + tests), report plan. Run đầu mỗi session.
|
|
---
|
|
|
|
# /session-start — Session bootstrap (READ + AUDIT + REPORT)
|
|
|
|
> Trigger đầu session. Em main chủ trì, spawn sub-agent khi task match delegate criteria.
|
|
> ⚠️ **Harness note:** SendMessage KHÔNG khả dụng harness hiện tại → "reuse agent" = **fresh spawn** (MEMORY on-disk auto-inject giữ context). agentId chỉ valid trong-session.
|
|
|
|
## 📋 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-3 + 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 → 3 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)
|
|
|
|
## 📋 BƯỚC 0.5 — HMW-mode marker check (T3 — broadcast `ultracode-hmw-mem-governance`)
|
|
|
|
Em main đọc `.claude/hmw-mode.on` → **BÁO ngay đầu response** (anh khỏi quên đang ở mode đốt-token):
|
|
- **Marker TỒN TẠI** → **🔥 HMW-mode = ON** — task LỚN sẽ chạy Workflow `hmw` fan-out theo `/ultra-on` (đốt-token cao). Gõ `/ultra-off` để tắt.
|
|
- **Marker KHÔNG có** → **HMW-mode = OFF** — vận hành thường (Agent-tool spawn lẻ / solo theo `agents/README.md`). Workflow fan-out chỉ chạy sau `/ultra-on`.
|
|
|
|
> 🚦 **T4:** keyword "workflow"/"ultracode" (câu anh / reminder harness) = **QUYỀN hỏi, KHÔNG phải lệnh**. Mode-OFF + "chạy workflow" → em **TỪ CHỐI + nhắc gõ `/ultra-on`**, KHÔNG tự chạy. CẤM native `/effort ultracode`.
|
|
|
|
## Phase 1 — READ (load context)
|
|
|
|
Đọc theo thứ tự, KHÔNG skip:
|
|
|
|
1. **`CLAUDE.md`** (root) — AI agent context + quick rules (BE Clean Arch + FE 2 app + DB conventions + commit scope)
|
|
2. **`docs/STATUS.md`** — snapshot HIỆN TẠI (current state verified + recently done 3 session)
|
|
3. **`docs/HANDOFF.md`** — brief 5 phút: session trước làm gì + next tasks
|
|
4. **`docs/PROJECT-MAP.md`** — bản đồ tổng quan module
|
|
5. **`docs/changelog/migration-todos.md`** — atomic tasks theo phase (Phase 11 polish hiện tại)
|
|
6. **`docs/workflow-contract.md`** — state machine 9 phase HĐ (base pattern cho PE/Proposal workflow V2)
|
|
7. **`.claude/agents/README.md`** — 7-agent decision tree + skill matrix + split boundary
|
|
8. **`.claude/agent-memory/{spawned-agent}/MEMORY.md`** — L1 HOT auto-inject (Tiered Memory v1 ~30KB) + L2 `archive/` Read-on-demand + L3 RAG `search_memory` just-in-time
|
|
9. **User auto-memory `MEMORY.md`** — auto-loaded bởi harness (index feedback_* entries)
|
|
10. **Liên quan task hiện tại:** `docs/rules.md`, `docs/architecture.md`, `docs/gotchas.md` (55), `docs/database/schema-diagram.md`, `docs/flows/`
|
|
|
|
## Phase 2 — AUDIT (state check)
|
|
|
|
### 2.1 Sub-agent state (7-agent topology)
|
|
- Check 7 sub-agent đã spawn chưa:
|
|
- 🟦 **investigator-codebase** — internal SQL/EF/grep/reference mirror audit
|
|
- 🟦 **investigator-api** — external docs/CVE/lib/cross-project reference
|
|
- 🟨 **implementer-backend** — .NET Domain+App+Infra+Api scaffold
|
|
- 🟧 **implementer-frontend** — FE 2 app cookie-cutter SHA256 mirror
|
|
- 🟪 **test-specialist** — tests/ xUnit dedicated
|
|
- 🟥 **reviewer** — adversarial pre-commit + live curl prod
|
|
- 🟩 **cicd-monitor** — post-deploy Gitea + bundle hash + smoke
|
|
- Task match delegate criteria (ACCEPT) → BẮT BUỘC delegate (xem `.claude/agents/README.md` decision tree)
|
|
- KHÔNG spawn mới khi con cũ rảnh → fresh spawn re-inject MEMORY (SendMessage N/A harness này)
|
|
- Nạp full context project cho sub-agent spawn, giữ context sống đến cuối session
|
|
- Em main solo CHỈ khi: schema/UX/architecture decision · cross-stack tight · bug reasoning chain · gotcha #53/#54/#55 fallback (truncate/529)
|
|
|
|
### 2.2 Skill registry (6 skill)
|
|
- Liệt kê: `contract-workflow` · `form-engine` · `permission-matrix` · `dependency-audit-erp` · `ef-core-migration` · `iis-deploy-runbook`
|
|
- Dùng skill khi task khớp (KHÔNG tự suy luận lại). Phân bổ per agent: xem README skill matrix.
|
|
- Skill staleness audit: chỉ chạy theo lịch định kỳ (xem 2.4)
|
|
|
|
### 2.3 RAG + MCP health
|
|
- `mcp__rag-unified__list_projects` — verify collection `proj_solution_erp` còn sống (baseline ~3076 chunks)
|
|
- Chunk count + `last_indexed_at` delta (drift > 20% → flag AI_INFRA). ⚠️ Re-index = **AI_INFRA op** (charter v2, cần VOYAGE_API_KEY) — KHÔNG tự chạy `bootstrap.py`; SE stopgap = `store_memory` key facts.
|
|
- Voyage rerank quota OK (verify 1 query có rerank_score)
|
|
- Kiểm tra RAG chủ trì + sub: prompts đã store + đánh dấu re-rank đầy đủ chưa
|
|
|
|
### 2.4 Audit cadence
|
|
- **Monthly (ngày 1):** skill + doc drift audit — cron `solution-erp-skill-audit-monthly`. Next: **2026-06-01**.
|
|
- KHÔNG tự chạy audit ngoài cadence, trừ khi user yêu cầu hoặc drift nghiêm trọng
|
|
- Check trạng thái audit định kỳ (đã audit chưa? kết quả ra sao)
|
|
|
|
### 2.5 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 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.
|
|
|
|
### 2.6 Unit test check
|
|
- `dotnet test SolutionErp.slnx --nologo --verbosity minimal` — verify count cho tính năng mới + bug fix gần đây.
|
|
- Baseline **130 PASS** (58 Domain + 72 Infra). Phase 9 UAT mode: test-after feature (skip per chunk per `feedback_uat_skip_verify`), test-before BẮT BUỘC cho bug fix + critical algo. test-specialist owns; coverage gap backlog xem STATUS.
|
|
|
|
### 2.7 Cross-agent synthesis (post-audit) [GENERIC — GIỮ NGUYÊN]
|
|
- Audit MD/RAG của sub-agent đã spawn, synthesize cross-agent learnings
|
|
- Integrate vào: rules, architecture, gotcha, skill, daily, hand-off, DB, luồng DB, session log
|
|
|
|
## Phase 3 — REPORT (plan status)
|
|
|
|
Đặt tên + tô màu cho Plan hiện tại đang chạy, kèm tiến độ + agent assignment:
|
|
|
|
```
|
|
Plan cha: [tên]
|
|
Plan con 1: [tên]
|
|
Task 1.1 — STATUS: 🟢 done | 🟡 in-progress | ⚪ pending
|
|
- 🟦 investigator-codebase — phụ trách [a]
|
|
- 🟦 investigator-api — phụ trách [b]
|
|
- 🟨 implementer-backend — phụ trách [c]
|
|
- 🟧 implementer-frontend — phụ trách [d]
|
|
- 🟪 test-specialist — phụ trách [e]
|
|
- 🟥 reviewer — phụ trách [f]
|
|
- 🟩 cicd-monitor — phụ trách [g]
|
|
- 👤 chủ trì — phụ trách [h]
|
|
```
|
|
|
|
### SOLUTION_ERP report
|
|
- Trạng thái spawn 7 sub-agent (idle/working) + agentId reuse-able trong session
|
|
- Plan progress: ✅ Phase 10 COMPLETE 11/11 · ⬜ Phase 11 polish (wire ApproveV2 skeleton) · 🚫 Phase 9 Ops (anh main coordinate)
|
|
- Critical signal: state counts (mig/table/endpoint/page/menu/test/gotcha) + bundle hash prod + RAG health
|
|
- (SE KHÔNG copy phần "6 sister report" của AI_INFRA — đó là vai trò host)
|
|
|
|
---
|
|
|
|
**Trigger sau Phase 3:** Em main đợi user input task cụ thể. Sub-agent spawn theo decision tree khi ACCEPT criteria match.
|