Ap spec-apply-hub-s145-v2 (5 axis, governance-only: 0 prod-code, 0 migration). Workflow S145 chet giua chung -> /tiep §4 relaunch-cat-gon wf_3d803740-41d 3/3 DONE. Owner-decision @S146: - session_ctx_kb = 64 TUONG-MINH (giu nguyen caveat ghost-wire: 0 reader) - session-model: scaffold IDEMPOTENT (tach cap-SO vs tao-THU-MUC) · closed.md WIRE (session-end §6.3-bis) · V2 AUTO (go cong NGUOI, GIU cong NHIP 6/15/3) Landed: C7 §N.8 predicate 4-ve · hook wal-flush.ps1 4 path (+.claude/sessions/) · San-3 tin-hieu ⑤ + ORPHAN-L · D2 KIEM end-only · §L.c completeness-gate co RANG. LIVE-VERIFY hook 4-path PASS repo THAT (da7ee8a). Session-model chay TRON VONG dau tien: pause-S146 -> resume-S146 -> ORPHAN-L can so. H24 force-fire (P=8 pause >= 1, luat auto moi): 2 vai + h24-audit -> 7 FLAG, va het: - sweep-consent sot 6 site (h24-audit.md:4 = frontmatter description) - closed.md wired-but-declared-unwired (ghost-wire CHIEU NGUOC) - owner-decision [7] BI GHI DE do tai-dung slot-index -> mat uy-quyen push 3/3 vai lane-H24 garble #53: ghi-dia-SOM cuu tron, ghi-MUON mat trang. So: orphan run-folder 3->0 · carry 14->20 (co tag [carry:*]) · +E-013 +E-014 error-ledger · +memory feedback_absence_looks_like_clean · .gitignore +lock file. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Multi-agent SOLUTION_ERP — Master Coordination Guide
🔴 Số vai canonical →
docs/STATUS.md§Sub-agents. KHÔNG chép số vào file này (B1 derived-trỏ-canonical). Bản trước S122 cứng-hoá "12-agent" ở 8 chỗ trong khi roster đã 14 — đó chính là classview-stale-role-desc, vàagents/READMEbị lấy làm ví-dụ minh-hoạ cho class đó tronglead-view-auditor.md. Vá @S122 bằng cách bỏ số, không phải bằng cách đổi số — đổi số thì roster kế lại stale.
Architecture: sub-agents worker-tier-pin
opus+effort:max(owner-decision S124 2026-07-15 — thay thế all-inherit Harness-8, trước nữa two-tier Harness-4) + em main lead frontier-class (anh chọn per-session) coordinator — nhóm product/quality (7 core S39 + frontend-designer pink S47 + database-agent read-advisory S52 + 📄 office-document S107) + nhóm monitor INFORM-only (H1tooling-auditor+ H2harvest-curator, 2026-06-07 Harness 1 · H24lead-view-auditor+lead-omission-auditor, S121 W2 · trio-memoryharness-eval+harness-refine+harness-audit, S141 · round-KIỂM ×3tooling-harvest-audit/h24-audit/sleep-audit, S145 [C4/C4b TÁCH mỗi-vòng-1-con]). 🔴 Liệt-kê NHÓM, KHÔNG tổng-số — số vai canonical →docs/STATUS.md§Sub-agents (đúng luật dòng đầu file: vá bằng BỎ số, không ĐỔI số). Tier: TOÀN BỘ submodel: opus+effort: max(worker-tier-pin S124 — sub cố-định KHÔNG theo lead; đo S126: lane no-tier resolveclaude-opus-4-8DÙ lead=Fable = pin ăn runtime, và per-tasktier:'fable'THẮNG pin trong lượt lệnh engine-đắt anh gõ. Lead runtime = per-session owner-choice (Fable ↔ Opus); lịch-sử flip-chain lead = canonical [docs/STATUS.md§Sub-agents] (🔴 S106 gộp 1-chain per anh-confirm — reader này KHÔNG enumerate/cập-nhật mỗi flip; BƯỚC 0.6 probe mỗi phiên xác-định runtime lead SỐNG) · effort Max (env machine-wide + frontmatter). SE KHÔNG có lớp helper/gopher rẻ (mọi sub đều substantive memory-bearing → worker-tier = opus+max, KHÔNG hạ thấp hơn). (Lineage: two-tier H4 [4 promote inherit + 7 demote pinclaude-opus-4-8] → all-inherit H8 S66–S123 → worker-tier-pin S124 — chi-tiết ở Upgrade 2026-06-10 + S66 dưới.) 🔍 Đếm roster = ĐO ĐĨA, đừng tin số trong doc:ls -1 .claude/agents/*.md | grep -v README | wc -l. ⚠️ Glob thôls .claude/agents/*.mdbắt LUÔNREADME.md⇒ ra thừa 1 — đây là bẫy số-học thật (R2-C1: acceptance cũ=14FAIL trên implementation ĐÚNG, và ép "sửa" bằng cách xoáREADME.md= catastrophic-Goodhart). Upgrade S52 (2026-06-08 — AI_INFRA broadcast2026-06-08-Agent-database-codebase-agents): +database-agent (read-advisory DB specialist, floor DB1–DB11) — schema/query/migration-design-review/perf/concurrency (DB11 RowVersion vá lost-update S43). Tailor READ-tier (implementer-backend vẫn author) · color OMIT (8 standard hết) ·store_memorystrip.codebase-agent= SKIP n-a (investigator-codebase đã cover grep/audit +csharp-lspWindows no-op). ✅ verified-runtime — spawned OK S53 (first real spawn, caught Mig 46 committed-but-unapplied-local drift) + S56 2× (pre-golive-verify schema-stream + golive-harden design+review). DB11 lost-update fix landed S56 (atomic ExecuteUpdate + Serializable tx, gotcha #58). Pattern: Anthropic Building Effective Agents orchestrator-workers + Cognition "writes single-threaded" hybrid + post-deploy automated watchdog. Upgrade S39 (2026-05-29): 4→7 agent (split investigator + implementer, +test-specialist) + budget +50% + 5 RAG MCP per agent. Reference BVAAU 7-agent config (adapted, NOT copied — SOLUTION_ERP 2-FE-app fit + 6 skill proven battle-test 38 session). Prior: S20t12 initial 3 + S21t1 +cicd-monitor. Upgrade S47 (2026-06-02): +frontend-designer (8th sub, pink) — FD1–FD10 visual-verification design floor (forked AI_INFRA canonical, broadcastAgent-frontend-designer-floor). +store_memorySTRIPPED khỏi MỌI sub → lead = sole RAG-writer (broadcastMemory-store-memory-strip-global); sub ghi finding → MEMORY.md (file). adap-reports:docs/governance/adap-reports/. Upgrade 2026-06-07 (Harness 1·2·3 adopt — AI_INFRA broadcast): +2 monitor sub INFORM-onlytooling-auditor(H1 tooling/docs-freshness 4-mặt) +harvest-curator(H2 harvest-integrity 5-trục) → roster 8→10, TÁCH BIỆT per anh-mandate (H1≠H2 "hay quên+nhầm"). + wave-folder memory-isolation (Harness 2 —hmw.jswave-mode +.claude/workflows/wave-*/gitignored, B1–B6). + email channelbroadcasts/(Harness 3 — cross-project comms, self-id=se). KHÔNG copy-paste AI_INFRA — tailor SE roster/stack. Upgrade 2026-06-10 (Harness-4 two-tier model — AI_INFRA broadcastharness-4-model-tier-promotion+model-fable-5-max): lead = Fable 5 (1M) Max (user-level machine-wide, SE không project-pin) · sub two-tier theo tiêu chí H4.3 (a gate≥writer · b verdict-nuôi-quyết-định · c chống-rubber-stamp · d 1M-thật): promote 4 giữinherit(reviewer·investigator-codebase·database-agent·harvest-curator) + demote 7 pinclaude-opus-4-8(full-id no-suffix — gotcha #37 cấm[1m]; runtime resolve[1m]1M trên máy chung per AI_INFRA s20).hmw.jstier-map H4.5 (role-less →'opus'· per-tasktier:'fable'|'opus'override). Email-back AI_INFRA H4.7 BẮT BUỘC. Justification per-vị-trí: adap-report2026-06-10-Governance-harness-4-model-tier-promotion.md. Upgrade S63 (2026-06-15 — Harness-5 + 6 adopt): H5 model-fallback — ⚠️ Fable 5/Mythos 5 suspended 2026-06-12 no-ETA → lead SE tạm Opus 4.8 (1M) Max (promoteinherittự theo → two-tier collapse single-tier Opus; demote-pin giữ; revert-FREE khi Fable về: đổi lead lại + spawn-test). KHÔNG sửa frontmatter · external-outage blameless KHÔNG RCA · session-start BƯỚC 0.6 check. H6 governed-ultracode — mode-ON: substantive task TỰ chạy HMW (KHÔNG đợi keyword "workflow"); workflow-agent default = inherit lead (hmw.jsrole-less'opus'→inherit) · role-fidelity (agentType ∈ VALID_ROLES) + memory-fidelity (memoryDelta→đúng agent-memory single-writer) ĐÃ sẵn từ HMW-engine. adap-report2026-06-13-Governance-harness-5-...+2026-06-15-Agent-harness-6-.... Upgrade S64 (2026-06-15 — Harness-7 writing-quality adopt): sàn chất lượng viết hướng ra ngoài (email · broadcast · adap-report · tài-liệu-sister · câu trả lời lead cho anh) phải tiếng Việt rõ nghĩa, câu hoàn chỉnh, đủ dấu câu, đúng ngữ pháp (O1); nội bộ giữ lối nén §6.4/§6.5 (O2 — bất đối xứng); reviewer +Category 6 writing-quality (O3, verified-pending-restart). Rule canonicaldocs/rules.md §1.1. adap-report2026-06-15-Governance-harness-7-writing-quality.md. body-hasha4580ea9…verified-MATCH (lesson gotcha #61: verify body-hash PHẢI đọc UTF-8 tường minh, PS5.1 default mis-decode tiếng Việt → false-mismatch). Upgrade S66 (2026-06-16 — Harness-8 all-inherit + workflow-fastest adopt): 🔴 BẮT BUỘC (anh-chốt, mọi sister; chất lượng trên chi phí). H8.1 — toàn bộ 11 sub-agent có memory →model: inherit(ăn top-tier lead), GỠ cơ chế demote two-tier của Harness-4 (7 sub pinclaude-opus-4-8đã flipinherit: 2 implementer · test-specialist · cicd-monitor · investigator-api · frontend-designer · tooling-auditor; 4 đã-inherit giữ nguyên reviewer·investigator-codebase·database-agent·harvest-curator). SE KHÔNG có helper/gopher rẻ để chừa → cả 11 lên inherit. Escape-hatch per-tasktier:'opus'(hmw.js) GIỮ cho sweep/cost. H8.2 — chạy workflow nhanh nhất: song song tối đa + xuất nhanh + lead auto-HMW cho task substantive (theo H6) — "nhanh" = parallelism, KHÔNG phải hạ model. Caveat (trung thực): runtime HIỆN KHÔNG đổi (inherit = Opus 4.8 1M vì Fable suspended H5 — trùng two-tier đã collapse); khác biệt thật khi Fable về (cả đội tự lên Fable 5 không sửa frontmatter) + H5.6 restore gọn hơn (chỉ đổi lead). Frontmatter no hot-reload → executed-file → runtime-verified S98 (2026-07-02 Fable-restore: inherit-chain spawn-test ×2 self-reportclaude-fable-5— "cả đội tự lên Fable, 0 sửa frontmatter" xảy ra đúng thiết kế).[1m]cấm trong frontmattermodel(gotcha #37). adap-report2026-06-16-Governance-harness-8-all-inherit-workflow-fastest.md. Upgrade S70 (2026-06-17 — Harness-9 L2-recovery + adap 2-workflow adopt): (1) PROCESS-mandate 🔴 BẮT BUỘC (PART 2/3, áp MỌI adap từ nay): mỗi adap 1 Harness = 2 workflow tách biệt (IMPLEMENT + REVIEW double-check RIÊNG) + REPORT về AI_INFRA kèm run-id bằng chứng; task ngắn-nhưng-cần-confirm VẪN phải review-workflow. Codify.claude/commands/adap-apply.md. (2) L2 dark-matter recovery (PART 1, tailored): archiveagent-memory/<sub>/archive/*.mdKHÔNG vào RAG → buildarchive/_INDEX.md(mục-lục 1-dòng/bản-ghi + con-trỏ substring sha-keyed, fallback Ctrl-F, KHÔNG line-hint) +<period>.gist.md(nén 4-field ADDITIVE,distill-gencounter, verbatim FROZEN) +memory-budget.json(seed-by-measure quascripts/measure-agent-memory.ps1) + budget-audit @session-start (§2.1.2) +.ragignoreguard. Rollout S70 (đầy-đủ-nhất, stage investigate→implement→audit qua 3 Workflow run-id): 4 over-cap sub (cicd-monitor · investigator-codebase · reviewer · implementer-backend). adap-report2026-06-17-Governance-harness-9-l2-recovery-and-adap-workflow.md. Upgrade S72 (2026-06-18 — Harness-10 flat-refine + checklist-v2 adopt): run-trace SUBFOLDER→FLAT (file phẳng cùng cấp:sub-<role>-<i>.mdraw +<stage>-synthesis.mdverified, KHÔNGsub-md//harvest/subdir) —hmw.js(:103subMd path) +workflows/README+runs/README+ session-start/end + decision-tree (dòng dưới) repoint. C8 migration: 5 run cũ S71 GIỮ subfolder (đừng rewrite history); close-gate dual-accept cả hai dạng. +/sleep-recovery-memory-l2(đóng A8 — port §J2-tailored SE-only: sleep-compress L2 gist additive, INFORM-only ≥7d). Anti-bypass detector (refine b): TAILORED-OUT — SE dùng Anthropic Workflow tool (no CLI-launcher bypass-surface), containment = git-diff + run-folder TRACKED + ledger orphan-scan (G-015). 3 run-id bằng-chứng: auditwf_13868efb-ea7· implementwf_ac43b5ff-7d1· review (pending). adap-report2026-06-18-Governance-harness-10-flat-refine-checklist-v2.md(pending). Upgrade S75 (2026-06-18 — Harness-11 engine bộ-nhớ-và-governance TỰ-BẢO-TRÌ adopt): engine tự-DÒ toàn-diện (luôn tươi báo cờ) + AUTO chỉ semantic-null git-diff + single-writer bar-KHÔNG-hạ (D9) + đổi-luật owner-approve (D7). 🔑 Canonical →docs/governance/harness-11-engine.md(KHÔNG copy luật ở đây — B1 dogfood). Artifact MỚI:scripts/governance-detectors.ps1(C1 broken-pointer + C2/B3 staleness + C3 vocab-fork + C4 self-exclusion, NO-API DÒ+FLAG-only, runtime-proven bắt drift root CLAUDE.md mig53→55 + 0 self-match; số flag động → run-trace) +scripts/memory-archive-gate.ps1(PHẦN A hysteresis 0.85/keep-floor 5/2-strike/A7 NO-API L1-eval) + budget.jsonarchive_gate. 3-tier D5(AUTO)/D6(DÒ+FLAG)/D7(owner-approve) + one-direction-lock D8 (canonical→derived) codify ở engine-doc. Cadence wired: D1 session-start §2.1.3 (chạy detector) · D2 session-end §L.b(c) (archive-gate). Áp qua workflow: auditwf_7fdc3bd5-930+ implementwf_c5e5844e-7c1+ reviewwf_d7ca1ff8-942+ double-checkwf_a0b68d2f-30e. adap-reportdocs/governance/adap-reports/2026-06-18-Governance-harness-11.md. Upgrade S79 (2026-06-20 — User-Mark H-12/13 canonical §P + Harness-14 Eval/Budget/Outcome adopt): áp canonical §P đầy-đủ (P1-P10) khi anh gõ/user-mark-active-high"áp đầy-đủ chính-xác nhất theo AI_INFRA". Artifact: 4 lệnh.claude/commands/user-mark-{active-high,active,medium,disable}.md(DACI report-before-stamp) + ledger.claude/governance/ACTIVE-MARKS.md(4 cấp Active-High/Active/Medium/Disable + display-filter) +harness-11-engine.md §E(cơ-chế P1-P10) +§F (Harness-14 3-mức maturity) +rules.md §6.6(objective-criteria: KHÔNG quy-mô-đội / KHÔNG thời-gian-tuổi) + session-start §2.1.4 / session-end §L.b(h) mark-display. 3 mark Active-High stamped anh-confirm S79 (RC-pqhuy1987-20-06-2026-10-29-09/10/11). completeness-gate H-6→H-13 ĐẠT (H-8 11/11 inherit no-[1m]). 4 workflow: investwf_82337f7f-95c+ reviewwf_a7cbe93e-912+ align-re-reviewwf_9d3beebb-a95+ H14-reviewwf_4d4eba6f-8a0. ⚠️ restart CLI (lệnh/session no hot-reload). adap-report 3× (…rc-signature+…harness-all-update+2026-06-20-Governance-harness-14). Upgrade S93 (2026-06-29 — Harness-16 MFE adopt): memory-fidelity-EVAL (đo nạp-vs-nhớ-vs-dùng bằng SỐ ĐO, KHÁC H6.7memoryDelta-routing-fidelity). Artifact:scripts/mfe-eval.ps1(deterministic NO-API: LEAD coverage-FIT token-RANGE + age-band flag-not-cut + Goodhart-anchor strikes/RCA · SUB per-role coverage ĐO-THẬT prose-only→N/A · sub-workflow N/A) +eval/mfe/(seed sample-questions stable-id-anchored + README) +memory-budget.json:mfeconfig + engine §H + artifact-row. Judge recall/apply = SCAFFOLD-only (chờ age-maturity + independent-judge). Wire opt-insession-start §2.1.6+session-end §L.b(c)(parameval, no-param=như cũ). 🔴 READS-not-writestoken_governor(owner-authority). C3 alias-map recorded §H (KHÔNG seed $aliasSets). 2-workflow: WF1 implement-investigatewf_4c63e1bd-99e+ WF2 reviewwf_13e3d35a-023(3-lane PASS: code-gate denom-29-re-derived + cross-harness 0-conflict + honesty 5-floor). adap-report2026-06-29-Governance-harness-16-mfe.md+ email AI_INFRA. ⚠️ restart CLI. Upgrade S107 (2026-07-10 — +office-document, 12th sub): +office-document (📄 Office document WRITE specialist) — anh giao trực tiếp S107 ("Sub chính" mảng Office). Floor OD1–OD10 (skill-first · 🔴 fidelity-to-template 100% · extract-không-bịa · round-trip verify · file-mới-không-đè-gốc · boundary-code ⟂ implementer-backend). Skill nạp: bộ 4 Office standalone (docx·xlsx·pptx·form-engine(project). VALID_ROLEShmw.js9→10. Use-case SE: extract spec Excel/Word anh gửi (Database NCC → Supplier Phase B khi unpark) · chuẩn hóa template 8 form placeholder · document deliverable · screenshot→docx #74 · verify render form-engine. ✅ verified-runtime S107 CÙNG PHIÊN — registry HOT-RELOAD agent MỚI giữa phiên (harness mới; ⚠️ ENV-DEPENDENT — hub experiment 2026-07-11 NGƯỢC kết quả [0 notice + spawn not-found ×2] → KHÔNG fleet-generalize, restart = default an toàn; S27 restart-lesson giữ cho EDIT agent hiện có, chưa re-verify) + spawn-test PASS (OD1 skill invoke · OD4 extract-honest — finding: 2 templatewwwroot/templates0 placeholder{{field}}, mẫu blank "…………..", mapping ở render-engine hoặc chưa placeholder-hóa · OD5 round-trip 37KB VN-dấu · OD7 gốc nguyên vẹn).
🎯 Architecture
ⓘ Diagram dưới = 7 core lane (pre-S47 snapshot) — KHÔNG phải roster hiện-hành. Roster THẬT = 7 core (diagram) + 🩷 frontend-designer (S47) + 🔵 database-agent (S52) + 📄 office-document (S107) + 🟫 tooling-auditor H1 + ⬜ harvest-curator H2 (2026-06-07 Harness 1) + 🔷 lead-view-auditor + 🔶 lead-omission-auditor (H24, S121 W2) + 🧪 harness-eval + 🧪 harness-refine + 🧪 harness-audit (trio-memory, S141) + 🔬 tooling-harvest-audit + 🔬 h24-audit + 🔬 sleep-audit (round-KIỂM ×3, S145 — C4/C4b TÁCH mỗi-vòng-1-con: vòng tooling/harvest · soi-lead H24 · nén-ngủ) — xem skill matrix + decision tree + tool grant dưới. Số vai canonical →
docs/STATUS.md§Sub-agents. (Cosmetic ASCII chưa vẽ lại — H1 tooling-auditor flag drift này @session-start.) 🔴 Bài S143 — enumeration TÊN cũng lão-hoá, và grep-theo-SỐ không bắt được: sweep roster wave S141–S142 đặt acceptance làgrep "roster 14|14/14|14 folder|14 vai"→ 0 hit ⇒ tuyên bố sạch. Nhưng đúng 2 dòng tự xưng là bản gốc về roster — dòng NÀY ("Roster THẬT") và:225("VALID_ROLES … ĐỦ roster") — liệt kê TÊN, không chứa con số nào ⇒ lọt lưới, giữ 14 vai qua cả wave. Acceptance cho lần sau: ĐẾM PHẦN TỬ trong mọi enumeration rồi so canonical, đừng so hình-dạng chuỗi.
┌──────────────────────────────────────────────────────────────┐
│ EM (Main) — lead frontier-class (anh chọn per-session, 1M Max)│
│ • Reasoning + write code (single-threaded principle) │
│ • Schema/UX/architecture decision + cross-stack tight coupling│
│ • Coordinate TOÀN roster sub-agent via spawn + SendMessage │
│ • Synthesize cross-agent findings + commit/push (em main only)│
│ • Fallback solo nếu spawn fail (gotcha #53 truncate / 529) │
└──────────────────────────────────────────────────────────────┘
↓ spawn + keep-alive (worker-tier-pin S124: MỌI sub `model: opus`+`effort: max` = worker-tier; lead=owner-choice/phiên; Fable qua /fable-real)
── RESEARCH (READ) ────────── ── IMPLEMENT (WRITE) ──────────── ── QUALITY ──────────
┌──────────────────┐ ┌───────┐ ┌─────────────────┐ ┌──────────┐ ┌────────┐ ┌─────────┐ ┌────────┐
│investigator- │ │invest-│ │implementer- │ │implement-│ │test- │ │reviewer │ │cicd- │
│codebase │ │igator-│ │backend │ │er- │ │special-│ │ │ │monitor │
│ │ │api │ │ │ │frontend │ │ist │ │ │ │ │
│ INTERNAL audit │ │EXTERN-│ │ .NET Domain+App │ │ FE 2 app │ │ tests/ │ │adversa- │ │post- │
│ SQL/EF/grep/ │ │AL docs│ │ +Infra+Api │ │cookie- │ │dedica- │ │rial pre-│ │deploy │
│ reference mirror │ │CVE/lib│ │ entity/CQRS/Mig │ │cutter │ │ted │ │commit + │ │Gitea + │
│ │ │/cross-│ │ /Controller │ │mirror │ │xUnit │ │live curl│ │bundle │
│ │ │project│ │ │ │SHA256 │ │ │ │ │ │+ smoke │
└──────────────────┘ └───────┘ └─────────────────┘ └──────────┘ └────────┘ └─────────┘ └────────┘
cyan blue yellow orange purple red green
🚨 RULE BẮT BUỘC (S39 updated)
Em main BẮT BUỘC phân việc cho sub-agent đúng vai trò khi ACCEPT criteria match. Budget +50% → lean toward delegate + parallel, ít em main solo fallback.
Workflow forward S39+:
- Trước mọi task → classify qua decision tree dưới
- Read-only research → split: internal codebase audit →
investigator-codebase· external docs/CVE/lib →investigator-api(có thể spawn parallel cả 2) - WRITE scaffold → split: .NET backend →
implementer-backend· FE 2 app →implementer-frontend(parallel khi independent — vd BE entity + FE types cùng lúc) - Test →
test-specialistdedicated (KHÔNG để implementer kiêm) - Deploy claim →
cicd-monitorsau push (skip docs-only gotcha #41) - Heavy diff / security / wire BE claim →
reviewerpre-commit
Em main solo CHỈ khi: schema/UX/architecture decision · cross-stack tight coupling · bug fix reasoning chain · gotcha #53 fallback (spawn truncate/529 → em main solo reliable, proven S37 BE 700 LOC + FE 4 file).
Anti-truncation rules (gotcha #53 — 5× occurrence S35-S37):
- Spawn prompt = RICH, fill-to-budget (H15-v3 S83 — supersedes old "≤8K brief"): nạp INPUT tới token-budget của sub (mem-sub 60K / wf-sub 50K per
memory-budget.json:spawn_fill_directive) bằng context GIÁ-TRỊ cao (relevant gotchas + state + full task-context + docs/memory liên-quan) — KHÔNG padding. Truncation #53 = rủi-ro RETURN của agent (vá bằng leanmemoryDeltareturn + em-main recover-disk), KHÔNG vá bằng starve INPUT. (Heuristic "≤8K brief" cũ = guard thời context-nhỏ S36, nay nghỉ.) - Tiered Memory v1: L1 HOT soft-cap ~30KB + L2 archive on-demand + L3 RAG just-in-time (per AI_INFRA policy). Investigator 32KB S37 truncate = lesson; soft-cap ~30KB tránh tái diễn.
- Agent keep entry ≤ 1.5K chars (frontmatter rule mỗi agent).
- Em main grep verify manual nếu agent return truncated mid-task.
- 529 Overload transient → em main solo fallback (KHÔNG retry loop).
🔄 Invocation decision tree (em main apply)
├── Read-only INTERNAL audit (codebase/SQL/EF diff/grep > 5 files)?
│ → investigator-codebase (cyan)
│
├── Read-only EXTERNAL (official docs / NuGet-npm CVE / lib eval / cross-project ref)?
│ → investigator-api (blue)
│ → Cả 2 investigator parallel OK khi task cần both (vd "audit current + research best practice")
│
├── DB schema-design / migration design-review / perf audit (N+1·index·projection) / transaction-concurrency (RowVersion lost-update)?
│ → database-agent (read-advisory, floor DB1–DB11) — DESIGN/REVIEW/PERF/CONCURRENCY-advise; implementer-backend AUTHOR sau
│ ⟂ vs investigator-codebase: deep DB-layer (introspection/query-plan/concurrency) vs broad codebase grep/audit
│ ⓘ Schema-design quyết-định-cuối vẫn em main solo; database-agent = deep-DB lens hỗ trợ + review implementer output
│
├── OFFICE DOCUMENT (đọc/tạo/sửa/convert docx·xlsx·pptx·pdf / extract spec file anh gửi / template form placeholder / báo cáo document / screenshot→docx #74)?
│ → office-document (📄) [OD1–OD10; skill docx·xlsx·pptx·pdf + form-engine]
│ ⟂ vs implementer-backend: C# render-engine (OpenXml/ClosedXML/LibreOffice service trong src/) = implementer-backend · office-document = FILE-level document/template/spec-extract (KHÔNG đụng src/·fe-*·tests/)
│
├── WRITE .NET backend (entity/EF Config/Mig/CQRS/Controller/DbInit)?
│ ✓ Spec deterministic · pattern proven >1× · >30min · ≤2 layer
│ → implementer-backend (yellow) [Case 1/2/3/5]
│
├── WRITE FE 2 app (page/types/component cookie-cutter mirror)?
│ ✓ UX flow chốt by em main · spec deterministic
│ → implementer-frontend (orange) [Case 1/2]
│ → BE + FE parallel khi independent (em main chốt DTO shape first)
│
├── WRITE FE DESIGN/REDESIGN (đẹp thật / UX mới / greenfield visual — KHÔNG mechanical mirror)?
│ ✓ design-system-first + visual-verification loop (Playwright screenshot ≥2 viewport → rubric → fix)
│ → frontend-designer (pink) [FD1–FD10 floor]
│ ⟂ vs implementer-frontend: đẹp/UX/thiết kế → frontend-designer · cookie-cutter SHA256 mirror theo spec → implementer-frontend (KHÔNG double-touch 1 file UI)
│
├── WRITE test (xUnit Domain policy / Infra handler / authz regression)?
│ → test-specialist (purple) [test-before bug/critical, test-after feature UAT]
│
├── After push code commit (NOT docs-only)?
│ → cicd-monitor (green) — Gitea poll + bundle hash + Mig prod + smoke
│
├── Adversarial pre-commit / heavy diff / wire BE claim / security?
│ → reviewer (red) — Smart Friend 5-category + live curl
│
├── @session-start/@session-end TOOLING-FRESHNESS audit (skill·sub-role·plugin·docs 4-mặt + drift)?
│ → tooling-auditor (H1 monitor, INFORM-only) — báo state+diff @start · chốt+new-alloc @end · em main APPEND
│
├── @session-end HARVEST-INTEGRITY gate (5-trục Coverage/Completeness/Fidelity/Placement/Corruption) / run-folder harvest (`runs/<run-id>/<stage>-synthesis.md` ← `sub-<role>-<i>.md` phẳng, Harness-10 h10-refine; run cũ S71 `harvest/`←`sub-md/`) / @session-start harvest mới?
│ → harvest-curator (H2 monitor, INFORM-only) — propose delta · em main single-writer VERIFY→APPEND · Fidelity nghi → reviewer
│
├── @session-end §L.b(g-bis) — KIỂM vòng tooling/harvest (verify OUTPUT H1+H2, AUTO sau đo, KHÔNG consent)?
│ → tooling-harvest-audit (round-KIỂM monitor, INFORM-only, C4/C4b S145 vai #1/3) — verdict per-claim + tự tái-dựng ≥1 số + thách-CLEAN · no-self-exempt ≠ H1/H2 · NO-OP nếu H1/H2 không chạy · em main VERIFY→APPEND
│
├── @session-end §L.b(j)(ii-bis) — KIỂM vòng soi-lead H24 (verify OUTPUT lead-view+lead-omission, AUTO sau cặp H24)?
│ → h24-audit (round-KIỂM monitor, INFORM-only, C4/C4b S145 vai #2/3) — verdict per-FLAG + thách-CLEAN (H24 báo ít/0 FLAG → tự soi 1 surface tìm FLAG sót) · no-self-exempt ≠ lead-view/omission · KHÔNG soi lead trực-tiếp · NO-OP nếu H24 không chạy
│
├── sau `/sleep-recovery-memory-l2` Phase 4.5 — KIỂM vòng nén-ngủ (verify gist+Fidelity, AUTO sau nén)?
│ → sleep-audit (round-KIỂM monitor, INFORM-only, C4/C4b S145 vai #3/3) — verdict per-claim + tự đo byte + thách-CLEAN (mở 1 gist vs `<period>.md` gốc) · no-self-exempt độc-lập lượt nén · NO-OP nếu 0 gist tươi
│
├── @session-start §2.1.9 / @session-end §L.b(k) — ĐỒNG-KIỂM CHÍNH-HỆ-MEMORY (độ-giữ · hành-động · đúng-spec), anh ĐÃ GẬT consent?
│ → **TUẦN TỰ 3 spawn RIÊNG** (🔴 CẤM `parallel()`; CẤM tự chạy khi chưa consent):
│ 1. harness-eval (trio-memory monitor, INFORM-only) — ĐO: đọc output instrument + budget.json → SỐ nguyên-văn + verdict
│ 2. harness-refine (…) — ĐỀ-XUẤT: đọc `harness-eval-return.md` PIN → action 4-lớp + mục "đã cân-nhắc→BÁC"
│ 3. harness-audit (…) — KIỂM: đọc run-folder PIN → ĐẠT/TRƯỢT per-claim + re-chạy ≥2 số load-bearing
│ ⟂ vs H1/H2/H24/round-KIỂM: H1 = tooling-freshness · H2 = harvest-integrity · H24 = soi LEAD · round-KIỂM ×3 (`tooling-harvest-audit`/`h24-audit`/`sleep-audit`) = KIỂM 3 vòng tooling-harvest / soi-lead H24 / nén-ngủ [đọc output con-đo vòng mình] · trio = soi CHÍNH HỆ MEMORY (corpus agent-memory)
│ ⟂ vs reviewer: trio KHÔNG chấm diff-code; đụng thao-tác harvest → NHƯỜNG harvest-curator
│ 🔴 3 vai KHÔNG có Write/Edit ⇒ lead scribe return từng con vào `runs/<run-id>/harness-{eval,refine,audit}-return.md` NGAY
│
├── Quick task < 30 min? → Em solo direct
│
└── Schema/UX/architecture/cross-stack tight/bug reasoning chain?
→ Em solo (Cognition) + investigator pre-flight optional + reviewer pre-commit
📋 Phân việc matrix — split boundary (CRITICAL)
| Layer / File | Owner |
|---|---|
src/Backend/SolutionErp.{Domain,Application,Infrastructure,Api}/** |
implementer-backend |
fe-admin/src/** + fe-user/src/** (cookie-cutter mirror scaffold theo spec) |
implementer-frontend |
| FE design/UX/redesign (aesthetic · new visual · design-system · a11y polish) | frontend-designer (self-gate rubric FD4 trước reviewer) |
tests/** |
test-specialist |
| Mig design / FK strategy / discriminator / schema | em main solo (database-agent deep-DB design-review/concurrency-advise optional + implementer-backend scaffold sau khi chốt) |
| DB schema introspection / query-perf (N+1·index) / migration design-review / concurrency RowVersion | database-agent (read-advisory — DESIGN/REVIEW/ADVISE, KHÔNG author file) |
| File Office (docx/xlsx/pptx/pdf) — template 8 form + spec-extract file anh gửi + document deliverable + screenshot→docx | office-document (📄 FILE-level — KHÔNG đụng src/·fe-*·tests/; render-engine code = implementer-backend) |
| UX flow (drawer/tab/modal) / page structure | em main solo (implementer-frontend scaffold sau khi chốt) |
| Internal SQL/EF/grep audit | investigator-codebase |
| External docs/CVE/lib/cross-project | investigator-api |
| Pre-commit verify | reviewer (NEVER write) |
| Post-deploy verify | cicd-monitor (NEVER write) |
Boundary dứt khoát: implementer-backend KHÔNG touch FE · implementer-frontend KHÔNG touch BE (chỉ Read DTO shape) · cả 2 implementer KHÔNG viết test (→ test-specialist) · test-specialist reveal prod bug → REPORT em main KHÔNG fix · frontend-designer = design/UX/đẹp (FE-only, KHÔNG BE/DB) ⟂ implementer-frontend = mechanical mirror theo spec — KHÔNG double-touch cùng 1 file UI (chồng lấn → escalate em main). office-document = FILE Office (docx/xlsx/pptx/pdf · template · spec-extract) ⟂ implementer-backend = C# render-engine trong src/ — file-level vs code-level, KHÔNG double-touch.
🛠️ Skill assignment (6 skill, re-distributed S39)
| Agent | Skills |
|---|---|
| investigator-codebase | contract-workflow + permission-matrix + ef-core-migration |
| investigator-api | dependency-audit-erp |
| implementer-backend | ef-core-migration + permission-matrix + contract-workflow + form-engine |
| implementer-frontend | permission-matrix |
| test-specialist | contract-workflow + permission-matrix |
| reviewer | dependency-audit-erp + contract-workflow + permission-matrix |
| cicd-monitor | iis-deploy-runbook + dependency-audit-erp + ef-core-migration |
| frontend-designer | frontend-design + senior-frontend + brand-guidelines + theme-factory + webapp-testing (FD2 loop) + web-artifacts-builder |
| database-agent (read-advisory S52) | sql-database-assistant (SQL Server first-class — KHÔNG cover EF-Core) + ef-core-migration (EF Core 10 pin + 3-file rule) |
| office-document (📄 S107) | docx + xlsx + pptx + pdf (bộ 4 Office standalone ~/.claude/skills/ — duplicate namespaced anthropic-skills:* → dùng standalone) + form-engine (project — template 8 form HĐ {{field}} + PDF LibreOffice + RG-001) |
| tooling-auditor (monitor H1) | ref-only — reads skill registry, KHÔNG dùng domain skill |
| harvest-curator (monitor H2) | none — deterministic 5-trục scan + Fidelity-escalate reviewer |
| lead-view-auditor (monitor H24, S121 W2) | ref-only — ĐỌC output scripts/governance-detectors.ps1 làm nền (KHÔNG chạy lại) + enum ĐÓNG lead_self_audit.flag_classes (memory-budget.json), KHÔNG dùng domain skill |
| lead-omission-auditor (monitor H24, S121 W2) | ref-only — cùng nguồn lead-view-auditor (output máy + enum ĐÓNG flag_classes); trục CÁI-THIẾU nên máy gần như mù, KHÔNG dùng domain skill |
| harness-eval (monitor trio-memory, S141) | ref-only — ĐỌC output scripts/{measure-agent-memory,mfe-eval,memory-archive-gate,crystallized-backfill,nhip-no-probe}.ps1, KHÔNG dùng domain skill |
| harness-refine (monitor trio-memory, S141) | ref-only — reads harness-eval-return.md (PIN) + reinject-ledger.md, KHÔNG dùng domain skill |
| harness-audit (monitor trio-memory, S141) | ref-only — reads run-folder PIN + memory-budget.json + scripts/; re-chạy ≥2 số load-bearing để đối-chứng |
| tooling-harvest-audit (monitor round-KIỂM, S145) | ref-only — ĐỌC output H1 tooling-auditor + H2 harvest-curator (KHÔNG chạy lại đo) + tự đếm .claude/agents/*.md/run-folder đối-chứng; no-self-exempt ≠ H1/H2; KHÔNG dùng domain skill |
| h24-audit (monitor round-KIỂM, S145) | ref-only — ĐỌC output lead-view-auditor + lead-omission-auditor FLAG (KHÔNG re-soi-lead) + flag_classes enum ĐÓNG + class_repeat; no-self-exempt ≠ 2 vai H24; KHÔNG dùng domain skill |
| sleep-audit (monitor round-KIỂM, S145) | ref-only — ĐỌC output /sleep-recovery-memory-l2 .gist.md + Fidelity verdict; tự đo byte gốc vs gist; no-self-exempt độc-lập lượt nén; KHÔNG dùng domain skill |
🔧 Tool grant (S39 — +3 RAG MCP per agent)
MỌI agent trong roster có 4 RAG-READ MCP: search_memory + search_code (BM25, prefer over Read full file — tiết kiệm token) + cross_project_search + list_projects. Base tools per role (READ: Read/Grep/Glob/Bash [+WebFetch/Search cho api] · WRITE: +Edit/Write/Skill).
2 monitor sub (tooling-auditor H1 + harvest-curator H2 — 2026-06-07): read-only toolset KHAI TRONG frontmatter =
[Read, Grep, Glob, Bash, +4 RAG-read], NOstore_memory, NO Write/Edit (mirror investigator read-set). 🔴 Đây là điều KHAI, KHÔNG phải điều ĐƯỢC CẤP — đo S143 trên 9 vai read-only (2 monitor này + 2×H24 + 3×trio + reviewer + investigator-codebase): runtime APPENDWrite+Editvào cuối tool-list bất kể frontmatter. Nhân-chứng:reviewer(frontmatter 0 Write/Edit) đã Write+Edit thật. ⇒ mọi câu "read-only" dưới đây đọc là ý-định, không phải enforcement. INFORM-only — propose → em main single-writer VERIFY→APPEND (B3). 🔴 G-015 accuracy (Harness-10 run-trace model,runs/README.md §Containment— 🧊_ledger.mdretired H18-B S100): run-folderruns/<run-id>/được git TRACKED → mọi write HIỆN trong git-diff = audit trực-tiếp. Containment: tracked-change NGOÀIruns/<run-id>/VÀ NGOÀI code-disjoint đã giao = vi-phạm (thay model Harness-2 B6 "mọi tracked-change = vi-phạm"). G-015 no-overclaim: TRACKED ≠ read-only-enforced — sub vẫn giữBash(write-channel mở qua shell/curl) → containment THẬT = em main single-writer + git-diff(in-repo) + chunk-count (RAG), KHÔNG allowlist đơn-độc.
⚠️
store_memoryGỠ khỏi MỌI sub (2026-06-02 — AI_INFRA broadcastMemory-store-memory-strip-global, adap-report cùng id). → lead (em main) = sole RAG-writer (mechanized failure-safe: sub vật-lý không gọi đượcstore_memory). Sub tìm thấy finding/pattern mới → ghi MEMORY.md (file); lead + re-index đưa vào RAG. Accuracy (G-015): đây KHÔNG = sub "read-only" — sub vẫn giữBash(+ vai write giữWrite/Edit); containment thật = defense-in-depth git-diff + Qdrant chunk-count, chưa phải allowlist đơn độc.
🔌 External skill/plugin mapping (H3 — Harness 1 adopt 2026-06-07)
Floor H3: nạp đúng skill/plugin hợp stack, gộp-vai KHÔNG phình roster. Audit (investigator-api 2026-06-07; tooling-auditor H1 re-count S53): 18 plugin registered (15 enabled / 3 disabled) user-global (
~/.claude/settings.json— +csharp-lsp +typescript-lsp +session-report vs S49's 15) + ~23 standalone skill (~/.claude/skills/). 0 agent mới — mọi cái = skill→gộp-vai-hiện-có. Nấc: enabled/available → assigned (bảng dưới = doc) → used (per-session auto-trigger). tooling-auditor (H1) rà new-alloc mỗi session-end.
| Skill/plugin (nguồn) | Value-locus | Map → vai | Ghi chú |
|---|---|---|---|
sql-database-assistant (standalone) |
skill-only | investigator-codebase + implementer-backend | SQL/EF query; đọc kèm ef-core-migration (KHÔNG override pin EF Core 10 / dbo single-schema) |
frontend-design (standalone, KHÔNG enable plugin trùng) |
skill-only | frontend-designer | duplicate plugin↔standalone → chọn standalone |
skill-creator |
skill-only | mọi sub (khi tạo skill project) | additive |
claude-md-management (claude-md-improver) |
skill+cmd | em main | doc-maintenance |
pr-review-toolkit (silent-failure-hunter / type-design-analyzer / comment-analyzer / pr-test-analyzer) |
agent-bearing | reviewer (tham-chiếu .md như CHECKLIST, KHÔNG enable agent) | giữ roster reviewer canonical |
session-report (node .mjs, Win-OK Node 20) |
skill-only | em main / cicd-monitor | optional — token/spawn-cost observability |
🔴 KHÔNG enable (tránh phình roster + name-collision — H3.3):
code-modernization(5 agent: legacy-analyst/security-auditor/test-engineer…) — SE = .NET 10 greenfield, agent-set trùng test-specialist/reviewer/investigator. Chỉ cmdmodernize-assess/mapad-hoc khi port NamGroup module.code-reviewer(×3 nguồn: pr-review-toolkit + feature-dev + standalone skill) collide rosterreviewer→ giữreviewercanonical, KHÔNG dùng plugin code-reviewer.csharp-lsp— Windows no-op (csharp-lskhông trên PATH; cầndotnet tool install --global csharp-lstrước). Defer (Bash dotnet build + grep symbol đủ).commit-commands/commit-push-pr— giả định GitHubgh; SE = Gitea → partial no-op (chỉcommit.mddùng được).
🚦 HMW-mode — Workflow fan-out governance (S49, broadcast ultracode-hmw-mem-governance)
Áp dụng KHI chạy Workflow runtime fan-out (
.claude/workflows/hmw.js). Vận hành thường (Agent-tool spawn lẻ / parallel-trong-1-message) KHÔNG đổi — decision-tree trên vẫn chuẩn. Toggle:/ultra-on·/ultra-off.
- Toggle 2-lệnh = on-ramp DUY NHẤT (T1/T2):
/ultra-ontạo marker.claude/hmw-mode.on(gitignored) + vào mode ·/ultra-offxóa. Marker = single-source-of-truth, persist qua session/compact./session-startđọc marker → BÁO ON/OFF (T3). - Keyword = QUYỀN, KHÔNG lệnh (T4): "workflow"/"ultracode" mở quyền hỏi, KHÔNG auto-run. Mode-OFF + "chạy workflow" → TỪ CHỐI + nhắc
/ultra-on. CẤM native/effort ultracode. (Bài học 515K-token false-trigger.) - Scope (S1): Workflow fan-out CHỈ repo SOLUTION_ERP — KHÔNG fan-out repo/corpus khác.
- Checkpoint (S2):
hmw.jsthrow nếucheckpointApproved≠true(mechanized tripwire anti-accidental). Em main BÁO {số agent·vai·task} @inform → set cờ → fan-out (KHÔNG chờ confirm từng lần; marker-ON=consent). Sub KHÔNG spawn sub (S3). - VALID_ROLES (whitelist
hmw.js— ĐỦ roster; số vai canonical →docs/STATUS.md§Sub-agents, B1 KHÔNG chép số):investigator-codebase·investigator-api·implementer-backend·implementer-frontend·test-specialist·reviewer·cicd-monitor·frontend-designer·database-agent(+S57 — S56 đã dùng 3× qua fail-soft WARN) ·office-document(+S107 — Office WRITE OD1–OD10) ·tooling-auditor+harvest-curator(+S110 anh-directed — H21 roster-parity lệnh-B) ·lead-view-auditor+lead-omission-auditor(+S121 W2 — H24 lead-self-audit) ·harness-eval+harness-refine+harness-audit(+S141 — trio-memory) ·tooling-harvest-audit+h24-audit+sleep-audit(+S145 — C4/C4b round-KIỂM ×3: vòng tooling/harvest · soi-lead H24 · nén-ngủ; AUTO fire-after-measure, no-self-exempt, NO-OP nếu vòng không đo). 🔸 Cả 10 monitor đều INFORM-only, lane RETURN-only (propose-only). 🔴 KHÔNG đọc "KHÔNG Write/Edit" thành cơ-chế chặn — đo S143: frontmatter 9 vai read-only không khaiWrite/Edit, nhưng runtime VẪN cấp, nối ở cuối tool-list (nhân-chứng trực-tiếp:reviewerđã Write+Edit thật trongruns/2026-07-22-S143-closeout-audit/). Whitelist = tuyên-bố ý-định; containment THẬT = em main single-writer + git-diff commit-gate. Role lạ ∉ VALID_ROLES →hmw.jsTHROW (STOP-HARD) + báo owner (S4c, DIRECTED REC-3 2026-07-13); role-less null → inherit lead.- 🔴 2 vai H24 = trục RIÊNG, KHÔNG gộp H1/H2: H1
tooling-auditor= tooling-freshness · H2harvest-curator= harvest-integrity · H24 = soi chính LEAD (lead-view-auditor= cái CÓ-nhưng-LỆCH ·lead-omission-auditor= cái BỊ THIẾU). Class-flag lấy từ enum ĐÓNGlead_self_audit.flag_classes(.claude/agent-memory/memory-budget.json) — vai KHÔNG tự chế class; nhịp =h24_cadence(cùng file), chạy theo NHỊP không phải mỗi phiên (session-start §2.1.8·session-end §L.b(j)). - ⚠️ Đổi roster = đổi 2 BỀ-MẶT ĐỘC-LẬP: (1) file
.mdtrong.claude/agents/→ Agent-tool registry · (2) hằngVALID_ROLEStronghmw.js→ workflowagentType. Sửa 1 quên 1 = vai spawn được tay nhưng THROW trong workflow (hoặc ngược lại). 🔴 Registry = ảnh-chụp lúc khởi phiên, KHÔNG hot-reload ⇒ vai mới cần RESTART + spawn-probe THẬT (session-start §0.6b) —ls+ grep VALID_ROLES là điều-kiện CẦN, KHÔNG ĐỦ.
- 🔴 2 vai H24 = trục RIÊNG, KHÔNG gộp H1/H2: H1
- Memory governance (M1–M5 + R1): B1 slice-inject (agent ← slice MEMORY của đúng vai qua
args) · M2 return-delta-only (memoryDelta{task,verdict,learned,surprise}) · B3 lead single-writer VERIFY→APPEND-only (no-overwrite-unverified) · B2 harvest-LIỀN sau mỗi workflow vàoagent-memory/<role>· M5store_memorystrip (đã S47). Containment = defense-in-depth (git-diff + Qdrant chunk-count post-P2), KHÔNG allowlist đơn-độc (G-015: sub vẫn giữ Bash/Write — KHÔNG "read-only").
Floor T/S/M/R đầy đủ →
.claude/commands/ultra-on.md. adap-report →docs/governance/adap-reports/2026-06-03-Agent-ultracode-hmw-mem-governance.md.
💾 Memory discipline
Each agent .claude/agent-memory/<name>/MEMORY.md persistent diary. Spawn auto-inject first 200 lines/25KB. Update BEFORE return (BẮT BUỘC, entry ≤ 1.5K chars). 17 folder: investigator-codebase · investigator-api · implementer-backend · implementer-frontend · test-specialist · reviewer · cicd-monitor · frontend-designer · database-agent · office-document · tooling-auditor · harvest-curator · lead-view-auditor · lead-omission-auditor (+S121 W2) · harness-eval · harness-refine · harness-audit (+S141 trio-memory). (🔬 3 vai round-KIỂM S145 tooling-harvest-audit/h24-audit/sleep-audit = vai #18/#19/#20 — folder agent-memory/<vai>/MEMORY.md tạo khi CHẠY lần đầu; tooling-harvest-audit/ đã có dir RỖNG từ spawn-probe S145 [git KHÔNG track empty-dir] ⇒ committed-state = 17 folder-có-MEMORY.md, khớp. ls thô có thể ra 18 dir gồm dir rỗng.)
Tiered Memory Policy v1 (adopt AI_INFRA bulletin 2026-05-29 — thay ngưỡng cứng ">25KB archive" bằng tiered + just-in-time; size to ≠ chất lượng, context-rot):
- L1 HOT =
MEMORY.mdsoft-cap ~30KB (role + patterns + anti-patterns + 5-8 entry gần nhất) → auto-inject mỗi spawn - L2 COLD =
archive/<YYYY-MM>.mdverbatim (activity cũ) → Read on-demand. Harness-9 (S70):archive/_INDEX.mdmục-lục 1-dòng/bản-ghi (con-trỏ substring sha-keyed, fallback Ctrl-F, frozen-additive) = inject "tấm bản-đồ"; verbatim +archive/<period>.gist.md(nén 4-field,distill-gencounter) = đọc-theo-nhu-cầu. "Inject mục-lục, KHÔNG inject lãnh-thổ." Budget-audit @session-start (§2.1.2 session-start.md) chống quên chỉnh ngân sách. - L3 SEARCHABLE = RAG
search_memory→ just-in-time - Discipline: search L3 / Read L2 TRƯỚC khi deep-dive (đừng nhồi L1). Agent nhớ vô hạn qua L2+L3, context spawn vẫn gọn. Curate khi L1 > ~30KB (KHÔNG còn hard 25KB).
End-of-session: em main SendMessage mỗi agent flush MEMORY → đọc 7 update → synthesize cross-agent → integrate project memory/session log → commit/push.
📊 Cost reality — re-ground S144 (2026-07-22)
🔴 KHAI ĐƠN-VỊ TRƯỚC (bắt buộc — cost-lens:28 cột "đốt đơn-vị NÀO"):
Bảng dưới đo bằng subagent_tokens do harness báo per-run (tổng token của sub, gồm cả phần cache-read).
⚠️ KHÁC đơn-vị bảng cũ ("Effective tokens billed (after caching)") và KHÁC cả 2 đơn-vị hub dùng ở depth-cost (vào+ra tách riêng).
⇒ KHÔNG so trực tiếp được với số hub. Xem §residual.
| Lớp spawn | Đo THẬT S144 | n | Ghi chú |
|---|---|---|---|
| Probe tối thiểu (cấm gọi tool) | ~28.0K/vai | 3 | registry-probe trio; sàn dưới của một lần spawn |
| Monitor audit đầy đủ (H1/H2) | ~223–232K/vai | 2 vai × 2 lượt | gồm lượt resume sau #53 |
| Lane invest (đọc 3 file + verify) | ~164K/lane | 5 | wf_491c05a8-6dc 819.982 / 5 |
| Lane review (chấm 1 spec + spot-check) | ~144K/lane | 3 | wf_301d3943-144 432.515 / 3 |
Phiên S144 (governance-heavy, 13 spawn + 3 workflow): ~2,3M subagent_tokens cho riêng sub.
🔴 Bài học đắt nhất của phiên: lane CHẾT vẫn ĐỐT ĐỦ
wf_491c05a8-6dc: 3/5 lane cháy maxTurns:20 ⇒ ~490K token đốt, 0 sản phẩm.
⇒ Cost thật KHÔNG tỉ lệ với kết quả — phải đếm token/lane-SỐNG, không phải token/lane-phóng.
Vá: hmw.js C1 nay LOUD-báo lane chết (trước đây .filter(Boolean) nuốt lặng ⇒ số này vô hình).
Nhánh TỰ LÀM TƯƠI (auto-toan-vong:29-31 — O-4e)
Bảng này đóng băng từ thời roster 7 vai tới nay (roster đã lớn hơn nhiều — canonical → docs/STATUS.md §Sub-agents, KHÔNG hardcode số) = đúng bệnh "số-đo-đóng-băng" hub vá.
🔴 Luật từ nay: khi roster đổi hoặc số đo lệch >30% so lần ghi trước ⇒ đọc lại + cập nhật NGAY trong phiên đó, không ghi-nhận-rồi-treo-disposition.
(Ngưỡng 30% = AI-tự-đặt, đảo được — không phải số owner.)
Residual (khai thẳng, không tô)
- 🔴 Falsifier
depth-cost:59VẪN CHƯA trả lời được: nó hỏi "bảng cost ghi đơn-vị nào, lệch mấy lần" — SE dùng đơn-vị thứ ba, muốn so phải đo lại theo đơn-vị hub (vào/ra tách). C9 chỉ đóng phần re-ground roster 7→17, KHÔNG đóng phần so-sánh-chéo-nhà. - Số cũ (~1.85M / ~9× solo) gỡ vì mẫu-số roster đã sai 7 vs 17; không giữ để so — hai đơn-vị khác nhau, so là tự lừa.
+50% budget (vs prior ~700K opt / ~1.35M heavy → now ~1.05M opt / ~2M heavy ceiling). Max 20× plan absorbs ~5× comfortable. Trade-off justify: split nhẹ hơn mỗi spawn (giảm gotcha #53 truncate) + parallel BE+FE+test (giảm wall-clock) + test-specialist clear coverage gap backlog (quality).
🎯 Project tunings (SOLUTION_ERP)
Stack: .NET 10 Clean Arch + CQRS MediatR + EF Core 10 + SQL Server + 2 React 19 Vite 8 FE + Gitea CI + Windows IIS.
State (S38 — 2026-05-28): 40 mig · 84 tables · ~223 endpoints · 53 FE pages · 130 test PASS · 53 gotchas · 27 memory · 6 skills · 7 sub-agents · Phase 10 COMPLETE 11/11 Plan G-*.
Windows MAX_PATH: project path nested + Dropbox-managed → implementer KHÔNG dùng isolation: worktree. Default branch OK.
UAT live mode (Phase 9): feedback_uat_skip_verify — skip dotnet test mỗi chunk, vẫn npm run build × 2. test-specialist test-after khi UAT confirm; test-before cho bug/critical algo.
🔗 References
- Anthropic Building Effective Agents
- Cognition "Don't Build Multi-Agents"
- BVAAU 7-agent reference:
D:\Dropbox\CONG_VIEC\BENHVIEN_A_AU\SOURCE_CODDE\.claude\agents\(adapted S39 — split trục + 5 RAG tool; SOLUTION_ERP giữ 6 skill + backend/frontend split thay domain/infra cho 2-FE-app fit) - Memory:
feedback_per_chunk_commit·feedback_uat_skip_verify·feedback_audit_reuse_before_clone·feedback_implementer_truncation_mitigation(gotcha #53)
⚠️ CLI restart required
Agent definition change (S39 split 4→7) → anh main restart Claude Code CLI để registry hot-reload (per S27 lesson — model:inherit + new agent files). Verify post-restart: spawn smoke test mỗi agent mới (investigator-api / implementer-frontend / test-specialist) confirm load OK.
Cập nhật S107 (2026-07-10): harness hiện tại HOT-RELOAD agent file MỚI giữa phiên (office-document tạo + spawn-test PASS cùng phiên, 0 restart). S27 lesson thu hẹp còn: EDIT agent đang tồn tại + command
.md(chưa re-verify hot-reload) → restart vẫn là default an toàn cho 2 ca đó. ⚠️ ENV-DEPENDENT (S110 2026-07-11 — triage-reply S5 hub): hub chạy CÙNG experiment ADD-agent-mới → kết quả NGƯỢC (0 system-notice + spawn "not found" ×2 qua turn-boundary) ⇒ hot-reload-ADD-mới KHÔNG fleet-proof, chỉ verified trên env SE tại S107; restart = default an toàn MỌI ca khi nghi ngờ.