Re-audit Harness-8/9/10/10-refine + checklist v1/v2 + hmw vs canonical AI_INFRA (mandate Harness-9 B1+B2): audit wf_13868efb-ea7 -> implement wf_ac43b5ff-7d1 -> review wf_d482e10d-5dd. SE was BEHIND Harness-10 flat. - run-trace SUBFOLDER->FLAT: hmw.js (:103 subMd + :52 schema + H4.5->H8 drift) + workflows/README full-rewrite + runs/README + session-start/end + agents/README Upgrade S72 + _ledger; 5 old S71 runs KEEP subfolder (C8 dual-accept). node --check OK. - adopt 2 pending broadcasts (checklist-v2 + h10-flat-detector-refine). - port /sleep-recovery-memory-l2 (A8, J2-tailored SE-only, floor intact, live skill). - detector refine-b TAILORED-OUT (SE Workflow-tool no-CLI-bypass; containment git-diff+tracked+orphan-scan G-015). - REVIEW (B2) caught 2 IMPLEMENT-self-assess missed (hmw.js:52 schema-stale + sleep-cmd auto-check un-wired overclaim) -> fixed (auto-check WIRED: budget.json +last_sleep_at + session-start/end INFORM). +3 minor fixed. - em-main containment-check caught 1 reviewer residual-write (raw-Workflow no writeGuard) -> revert (reverse-finding #4). B3 self-correct: runs path 14->22. - sleep-recovery-memory-l2 all = NO-OP (all periods already gisted). last_sleep_at set. 0 production code. State unchanged: Mig 53 / 88 tables / 306 test / 68 gotcha / menu 54 / bundle BgNCjwsG/CBvh0vtf. adap-report + email ai_infra (5f511fe5c0f2). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
12 KiB
description
| description |
|---|
| Bootstrap session SOLUTION_ERP — load context, audit state (11-agent + RAG + tests + monitor RE-REPORT), 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):
- Em echo full content command (raw markdown, KHÔNG tóm tắt, KHÔNG cắt)
- Em proceed execute Phase 1 → 3 sequential ngay
- 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
hmwfan-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 + H6.1 (governed-ultracode, adopt S63): keyword "workflow"/"ultracode" = QUYỀN hỏi khi mode-OFF (+ "chạy workflow" → em TỪ CHỐI + nhắc gõ
/ultra-on). 🟢 Mode-ON (H6.1): task SUBSTANTIVE (≥2 bước độc-lập · multi-file · sweep/audit/review/migration/research/verify-heavy) → em TỰ author+chạy Workflow HMW (KHÔNG cần gõ "workflow"; marker-ON = consent); TRIVIAL (<2-3' · 1-file · hỏi-đáp · governance-authoring single-writer) → solo. CẤM native/effort ultracode(mất guard).
📋 BƯỚC 0.6 — Model-availability check (H5 — adopt S63)
Em main xác nhận lead model resolve được đầu session. Lead SE = Fable 5 (1M) Max (per H4). DOWN = lỗi "Model isn't available — claude-fable-5[1m]" → fallback /model claude-opus-4-8[1m] (Opus 4.8 · 1M · Max — top-tier, KHÔNG hạ §A1; KHÔNG sửa frontmatter agent — promote inherit tự theo lead → two-tier tạm collapse single-tier Opus, revert-FREE khi Fable về). Phản xạ THỦ-CÔNG (không hook tự-switch). ⚠️ Fable/Mythos suspended 2026-06-12 no-ETA → SE đang fallback Opus (em chạy claude-opus-4-8[1m] từ S62). Restore (H5.6): Fable về → đổi lead lại + spawn-test confirm self-report claude-fable-5[1m] + gỡ caveat.
Phase 1 — READ (load context)
Đọc theo thứ tự, KHÔNG skip:
CLAUDE.md(root) — AI agent context + quick rules (BE Clean Arch + FE 2 app + DB conventions + commit scope)docs/STATUS.md— snapshot HIỆN TẠI (current state verified + recently done 3 session)docs/HANDOFF.md— brief 5 phút: session trước làm gì + next tasksdocs/PROJECT-MAP.md— bản đồ tổng quan moduledocs/changelog/migration-todos.md— atomic tasks theo phase (Phase 11 polish hiện tại)docs/workflow-contract.md— state machine 9 phase HĐ (base pattern cho PE/Proposal workflow V2).claude/agents/README.md— 11-agent decision tree + skill matrix + split boundary.claude/agent-memory/{spawned-agent}/MEMORY.md— L1 HOT auto-inject (Tiered Memory v1 ~30KB) + L2archive/Read-on-demand + L3 RAGsearch_memoryjust-in-time- User auto-memory
MEMORY.md— auto-loaded bởi harness (index feedback_* entries) - Liên quan task hiện tại:
docs/rules.md,docs/architecture.md,docs/gotchas.md(68),docs/database/schema-diagram.md,docs/flows/
Phase 2 — AUDIT (state check)
2.1 Sub-agent state (11-agent topology — 9 product/quality + 2 monitor INFORM-only)
- Check 11 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
- 🩷 frontend-designer — FE design/redesign visual-verification loop (FD1–FD10)
- 🔵 database-agent — read-advisory DB lens (DB1–DB11: schema/migration-review/perf/concurrency)
- 🟪 test-specialist — tests/ xUnit dedicated
- 🟥 reviewer — adversarial pre-commit + live curl prod
- 🟩 cicd-monitor — post-deploy Gitea + bundle hash + smoke
- 🟫 tooling-auditor (monitor H1, INFORM-only) — tooling/docs-freshness 4-mặt (skill·sub-role·plugin·docs)
- ⬜ harvest-curator (monitor H2, INFORM-only) — harvest-integrity 5-trục (Coverage/Completeness/Fidelity/Placement/Corruption)
- Task match delegate criteria (ACCEPT) → BẮT BUỘC delegate (xem
.claude/agents/README.mddecision 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.1.1 Monitor RE-REPORT — H1 tooling-freshness + H2 harvest-integrity (2026-06-07 Harness 1)
Đầu session: 2 monitor sub BÁO LẠI trạng-thái + diff vs session trước (floor Harness 1 H1.2 + H2.2). INFORM-only — em main đọc + VERIFY→APPEND nếu có delta hợp-lệ (B3), KHÔNG sub tự sửa.
- 🟫 tooling-auditor (H1): spawn → báo tooling-state 4-mặt (skill · sub-role · plugin · docs) + DIFF vs last-session (THÊM/ĐỔI/XÓA/stale). Bắt drift doc-vs-thực-tế ngay đầu session (vd roster/count lệch, skill stale, plugin pending).
- ⬜ harvest-curator (H2): spawn → báo harvest-MD mới (run-trace
runs/<id>/— filesub-*/*-synthesis.mdphẳng h10-refine / sub-agent / agent-team kể từ last) + delta mồ-côi chưa-APPEND + scanruns/*/tìm OPEN-beat (ledger_ledger.mdcột closed=⏳) mà*-synthesis.mdvắng (run cũ S71:harvest/rỗng) = orphan run (C5 Layer2 post-exec rescan — bù khi C4 per-turn miss hoặc session trước chết giữa run). Bắt 0-byte memory (gotcha #53) + delta chưa thu-hoạch. - Cơ-chế = báo-lại-diff đầu session (FORM tự do trình bày). 2 monitor spawn parallel OK. Light session / hỏi-đáp → có thể skip; bug/feature/multi-agent/wave session → nên chạy.
2.1.2 Memory L2 budget-audit (Harness-9 — 2026-06-17)
Read-side "vật-chất-tối": archive
agent-memory/<sub>/archive/*.mdKHÔNG vào RAG. Inject mục-lục (archive/_INDEX.md), nội dung verbatim +.gist.mdđọc-theo-nhu-cầu. "Inject tấm bản-đồ, KHÔNG inject lãnh-thổ."
-
🌙 Sleep-check (Harness-10b, S72): trong lúc đọc
memory-budget.json(cùng file budget-audit), lấylast_sleep_at→ nếunullHOẶCtoday − last_sleep_at ≥ 7 ngày→ INFORM gợi-ý chạy/sleep-recovery-memory-l2 <agent|all>(nén L2 verbatim→gist additive). 🔴 KHÔNG auto-run — anh consent mới chạy. -
Đọc
.claude/agent-memory/memory-budget.json→ so kích-thước THẬT_INDEX.mdmỗi sub vs cap. Nếu cắt-cho-vừa-ngân-sách đang rớt dấu-mốc quan trọng → bump budget (chốt-chặn chống "quên chỉnh ngân sách"). Đo lại bằngscripts/measure-agent-memory.ps1(seed-by-measure — KHÔNG đặt cap bằng số tưởng tượng). -
L1 over-cap → curate L1→L2 (byte-exact additive) + build/refresh
_INDEX.md(con-trỏ substring sha-keyed, fallback Ctrl-F) +<period>.gist.md(nén 4-field,distill-gencounter, verbatim FROZEN). Rollout đầu: 4 over-cap sub (S70).
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 collectionproj_solution_erpcòn sống (baseline ~3076 chunks)- Chunk count +
last_indexed_atdelta (drift > 20% → flag AI_INFRA). ⚠️ Re-index = AI_INFRA op (charter v2, cần VOYAGE_API_KEY) — KHÔNG tự chạybootstrap.py; SE stopgap =store_memorykey 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 11 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.