[CLAUDE] Docs: S146 closeout — session-model 3 owner-decision + hook 4-path + H24 auto
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m25s

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>
This commit is contained in:
pqhuy1987
2026-07-23 00:16:37 +07:00
parent a1e2416f37
commit 8b6df0a396
86 changed files with 5683 additions and 113 deletions

View File

@ -2,7 +2,7 @@
> 🔴 **Số vai canonical → [`docs/STATUS.md`](../../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à class `view-stale-role-desc`, và `agents/README` bị lấy làm **ví-dụ minh-hoạ** cho class đó trong [`lead-view-auditor.md`](lead-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** (H1 `tooling-auditor` + H2 `harvest-curator`, 2026-06-07 Harness 1 · H24 `lead-view-auditor` + `lead-omission-auditor`, **S121 W2** · trio-memory `harness-eval` + `harness-refine` + `harness-audit`, **S141**). 🔴 **Liệt-kê NHÓM, KHÔNG tổng-số** — số vai canonical → [`docs/STATUS.md`](../../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Ộ sub `model: opus` + `effort: max`** (worker-tier-pin S124 — sub cố-định KHÔNG theo lead; **đo S126:** lane no-tier resolve `claude-opus-4-8` DÙ lead=Fable = pin ăn runtime, và per-task `tier:'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 pin `claude-opus-4-8`] → all-inherit H8 S66S123 → worker-tier-pin S124 — chi-tiết ở Upgrade 2026-06-10 + S66 dưới.)*
> **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** (H1 `tooling-auditor` + H2 `harvest-curator`, 2026-06-07 Harness 1 · H24 `lead-view-auditor` + `lead-omission-auditor`, **S121 W2** · trio-memory `harness-eval` + `harness-refine` + `harness-audit`, **S141** · round-KIỂM ×3 `tooling-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`](../../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Ộ sub `model: opus` + `effort: max`** (worker-tier-pin S124 — sub cố-định KHÔNG theo lead; **đo S126:** lane no-tier resolve `claude-opus-4-8` DÙ lead=Fable = pin ăn runtime, và per-task `tier:'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 pin `claude-opus-4-8`] → all-inherit H8 S66S123 → 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/*.md` bắt LUÔN `README.md`** ⇒ ra **thừa 1** — đây là bẫy số-học thật (R2-C1: acceptance cũ `=14` **FAIL trên implementation ĐÚNG**, và ép "sửa" bằng cách **xoá `README.md`** = catastrophic-Goodhart).
> **Upgrade S52 (2026-06-08 — AI_INFRA broadcast `2026-06-08-Agent-database-codebase-agents`):** **+database-agent (read-advisory DB specialist, floor DB1DB11)** — 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_memory` strip. `codebase-agent` = **SKIP n-a** (investigator-codebase đã cover grep/audit + `csharp-lsp` Windows 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.
@ -24,7 +24,7 @@
## 🎯 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**) — xem skill matrix + decision tree + tool grant dưới. Số vai canonical → [`docs/STATUS.md`](../../docs/STATUS.md) §Sub-agents. (Cosmetic ASCII chưa vẽ lại — H1 tooling-auditor flag drift này @session-start.)
> ⓘ **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`](../../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 S141S142 đặ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.**
```
@ -124,12 +124,21 @@
├── @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: H1 = tooling-freshness · H2 = harvest-integrity · H24 = soi LEAD · trio = soi CHÍNH HỆ MEMORY (corpus agent-memory)
│ ⟂ 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
@ -183,6 +192,9 @@
| 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)
@ -223,7 +235,7 @@ MỌI agent trong roster có **4 RAG-READ MCP**: `search_memory` + `search_code`
- **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.js` **throw** nếu `checkpointApproved≠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`](../../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 OD1OD10) · `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)**. 🔸 **Cả 7 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 khai** `Write/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 trong `runs/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.js` **THROW (STOP-HARD)** + báo owner (S4c, DIRECTED REC-3 2026-07-13); role-less null → inherit lead.
- **VALID_ROLES (whitelist `hmw.js` — ĐỦ roster; số vai canonical → [`docs/STATUS.md`](../../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 OD1OD10) · `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 khai** `Write/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 trong `runs/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.js` **THROW (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 · H2 `harvest-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 ĐÓNG** `lead_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 `.md` trong `.claude/agents/`**Agent-tool registry** · (2) hằng `VALID_ROLES` trong `hmw.js`**workflow `agentType`**. 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 ĐỦ**.
- **Memory governance (M1M5 + 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ào `agent-memory/<role>` · M5 `store_memory` strip (đã 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").
@ -234,7 +246,7 @@ MỌI agent trong roster có **4 RAG-READ MCP**: `search_memory` + `search_code`
## 💾 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)**.
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.md` soft-cap **~30KB** (role + patterns + anti-patterns + 5-8 entry gần nhất) → auto-inject mỗi spawn
@ -246,15 +258,38 @@ Each agent `.claude/agent-memory/<name>/MEMORY.md` persistent diary. Spawn auto-
---
## 📊 Cost reality (budget +50% S39)
## 📊 Cost reality — **re-ground S144 (2026-07-22)**
| Component | Effective tokens billed (after caching) |
|---|---|
| 7 sub-agents spawn setup | ~1.1M (7 × ~155K cache WRITE) |
| SendMessages cached | ~500K |
| Em main session | ~250K |
| **Total per heavy session** | **~1.85M (~9× solo)** |
| **Optimized (compact + cache + skip trivial + parallel)** | **~1.05M (~5× solo)** |
🔴 **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) | **~223232K**/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`](../../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:59` VẪ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).