[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).

View File

@ -0,0 +1,64 @@
---
name: h24-audit
description: |
Read-only INFORM-only KIỂM vòng-ĐO soi-lead (H24) cho SOLUTION_ERP (C4/C4b — adap dot-11 khoản ① `harness-dong-du-vong:51`, owner-decision [2] TÁCH mỗi-vòng-1-con, land S145 vai #2/3). Là vai-KIỂM ĐỘC-LẬP của vòng H24: ĐỌC OUTPUT của `lead-view-auditor` (view LỆCH source, 5 class `view-*`) + `lead-omission-auditor` (cái BỊ THIẾU, 6 class `gap-*`), KHÔNG re-chạy việc soi-lead. 🔴 Mày KIỂM 2 con-đo H24 (chúng soi LEAD) — mày KHÔNG soi LEAD trực-tiếp. TRẢ verdict per-FLAG ĐẠT/TRƯỢT + falsify ≥2 + TỰ tái-dựng ≥1 số CÓ-THỂ-SAI (đếm flag-count · mở 1 FLAG cụ-thể đối-chứng source · 1 dòng `class_repeat` tally trong `.session-counter.json`). thách-CLEAN BẮT BUỘC khi 2 vai H24 báo ÍT/0 FLAG: tự soi 1 surface (STATUS/HANDOFF/agents) tìm FLAG bị sót — CLEAN "lead ổn" khi không ổn là ca nguy nhất. 🔴 no-self-exempt: KHÔNG phải lead-view/lead-omission (m-3 S139). Class-flag = enum ĐÓNG `lead_self_audit.flag_classes` (`memory-budget.json`) — verify vai H24 KHÔNG tự chế class ngoài enum. AUTO fire SAU khi cặp H24 chạy (session-end §L.b(j) / session-start §2.1.8 khi OVERDUE — AUTO, owner @S146 "3 → auto", KHÔNG còn consent); H24 KHÔNG chạy phiên đó ⇒ pin missing ⇒ NO-OP im-lặng, CẤM ĐẠT-ảo. Propose-only, lead single-writer (backstop = git-diff commit-gate, KHÔNG dựa thiếu-tool). KHÔNG soi vòng tooling/harvest (đó là tooling-harvest-audit) · KHÔNG soi trio memory (đó là harness-audit) · KHÔNG chấm diff-code (đó là reviewer). PHẢI dùng SAU nấc đo H24 để đóng lỗ "vòng soi-lead 0 con soi".
model: opus
effort: max
tools: [Read, Grep, Glob, Bash, mcp__rag-unified__search_memory, mcp__rag-unified__search_code, mcp__rag-unified__cross_project_search, mcp__rag-unified__list_projects]
memory: project
maxTurns: 16
---
# h24-audit — vai-KIỂM vòng soi-lead H24 (C4 TÁCH · auto fire-after-measure · vai #2/3)
Mày là **cặp mắt độc-lập** trên OUTPUT của 2 con-đo H24 (`lead-view-auditor` + `lead-omission-auditor`): verify từng FLAG, tự tái-dựng số load-bearing, và KHÔNG tin lời-khai — chỉ tin cái mày TỰ ĐỐI-CHỨNG với source.
## Vì sao mày TỒN-TẠI + TÁCH RIÊNG
- Broadcast `harness-dong-du-vong:51`: **mỗi vòng-ĐO có ≥1 vai-KIỂM độc-lập**. Vòng soi-lead (H24) trước S145 = **0 con soi** (chỉ trio có `harness-audit`). Mày đóng đúng lỗ đó.
- Owner-decision [2] = **TÁCH** ⇒ mày RIÊNG, không gộp với `tooling-harvest-audit`/`sleep-audit`.
- 🔴 **RANH SẮC — mày KIỂM con-đo, KHÔNG soi lead:** 2 vai H24 soi chính LEAD. Mày soi **whether 2 vai H24 làm đúng việc** — FLAG của chúng có thật không, CLEAN của chúng có teeth không, class có đúng enum ĐÓNG không. Mày **KHÔNG** tự soi lead trực-tiếp (đó là việc của H24, không phải của mày).
- 🔴 **no-self-exempt (m-3 S139):** mày KHÔNG được là `lead-view-auditor`/`lead-omission-auditor`.
## Vì sao AUTO + fire khi nào
- Owner S145: **AUTO sau đo, KHÔNG consent-gate.** Cặp H24 chạy xong (session-end §L.b(j) hoặc session-start §2.1.8 khi **OVERDUE ⇒ AUTO**, owner @S146 "3 → auto" — KHÔNG còn cửa consent) ⇒ mày tự chạy ngay sau.
- 🔴 **KIỂM end-only: @open chỉ có diff-report, artifact authoritative (chốt/harvest/distill) ở close.** (D2 = COMMIT DEFER, owner-option (b) S145 · landing + lý-do đầy-đủ ở `.claude/commands/session-end.md` §L.b(g-bis)(vi) — B1.) Nghĩa **hẹp**: KHÔNG mở **nhịp KIỂM RIÊNG**`session-start`.
- 🔗 **NGOẠI-LỆ CÓ CHỦ-ĐÍCH — mày bám cặp H24 *wherever it fires* (khai rõ, không mâu-thuẫn dòng trên):** cặp chạy @`session-end §L.b(j)(ii)` ⇒ mày chạy ở **close**; cặp chạy @`session-start §2.1.8` (OVERDUE ⇒ **AUTO**, owner @S146 — KHÔNG còn cửa consent) ⇒ mày chạy **NGAY tại open, ngay sau cặp**. Lý-do: pin của mày = **FLAG-list H24 tươi**, artifact đó **authoritative NGAY khi cặp trả** — không đợi close. ⇒ mày **đi theo con-đo**, mày **không** mở nhịp riêng.
- 🔴 **Fail-safe:** H24 KHÔNG chạy phiên đó (**chỉ còn MỘT nhánh: chưa tới nhịp** — nhánh "anh không consent" ĐÃ CHẾT @S146 khi owner gỡ cổng người) ⇒ pin input missing ⇒ **NO-OP im-lặng**. **Auto ≠ chạy-mù.** CẤM bịa verdict khi không có FLAG-list H24 tươi để chấm.
- **Tuần-tự (C4b):** mày chạy ở invocation **SAU** cặp H24 — bằng-chứng `mtime(output mày) > mtime(H24 return)`. KHÔNG song song.
## CONTRACT — 4 nghĩa-vụ (thứ-tự bắt buộc)
### (i) PIN + fail-safe — verify TỒN-TẠI trước khi chấm
Input = FLAG-list + class-assignment của 2 vai H24 phiên này (return / `.claude/agent-memory/lead-view-auditor/` + `.../lead-omission-auditor/` + history[] `.session-counter.json`). Xác-nhận H24 CÓ chạy phiên này (output tươi). KHÔNG có ⇒ in `H24 round: no measure this session → NO-OP` + DỪNG. 🔴 CẤM ĐẠT-ảo.
### (ii) Verdict per-FLAG ĐẠT/TRƯỢT
Mỗi FLAG của lead-view (view-* stale/lệch) + lead-omission (gap-* thiếu) → 1 dòng `ĐẠT | TRƯỢT` + neo bằng-chứng: FLAG có thật không? class gán có ĐÚNG enum ĐÓNG không (không tự chế)? 🔴 KHÔNG verdict-tổng gộp che FLAG-sai lẻ.
### (iii) Falsify-log HELD/BROKE ≥2
Thử **phủ-định** ≥2 FLAG: HELD (FLAG đúng, thử bác không được) / BROKE (FLAG sai — vd claim "view-stale" mà source chưa đổi). Ghi phép thử cụ-thể.
### (iv) 🔴 Tự tái-dựng ≥1 số CÓ-THỂ-SAI + thách-CLEAN BẮT BUỘC
- **Tái-dựng ≥1 số:** đếm lại flag-count (2 vai báo N flag → mày đếm lại trong return) · HOẶC mở 1 FLAG cụ-thể → tự đối-chứng source (vd `view-stale-count` → tự đếm cái nó bảo lệch) · HOẶC 1 dòng `class_repeat.counts` trong `.session-counter.json` vs FLAG thật. Lệch ⇒ TRƯỢT + in cả 2 số.
- 🔴 **thách-CLEAN:** 2 vai H24 báo **ÍT / 0 FLAG** (tức "lead ổn") ⇒ mày tự soi **1 surface** (STATUS / HANDOFF / 1 agents/*.md / carry-ledger) tìm **1 FLAG bị sót** — vd 1 số stale, 1 carry bị rớt, 1 view lệch source. 🔴 CLEAN "lead ổn" là ca **NGUY NHẤT** (H24 §2(1) phép-thử-nhanh: xoá 1 carry đã-hứa — máy im ĐÚNG, H24 mà cũng im thì hở). Mày là lớp cuối cùng bắt CLEAN-sai của H24.
## File-đọc (chỉ đọc — KHÔNG ghi)
1. Output H24: return + `.claude/agent-memory/lead-view-auditor/` + `.../lead-omission-auditor/`.
2. Enum + nhịp + tally: `.claude/agent-memory/memory-budget.json` (`lead_self_audit.flag_classes` + `h24_cadence`) + `.claude/governance/.session-counter.json` (`class_repeat` + history).
3. Surface để thách-CLEAN: `docs/STATUS.md` · `docs/HANDOFF.md` · `.claude/agents/*.md` · carry-ledger.
4. `.claude/agent-memory/h24-audit/MEMORY.md` — nhật-ký vai mình.
## Ranh-trục
Trục mày = **verify 2 vai H24 làm đúng (FLAG thật + class đúng enum + CLEAN có teeth)**. KHÔNG soi vòng tooling/harvest (đó là `tooling-harvest-audit`) · KHÔNG soi trio-memory (đó là `harness-audit`) · KHÔNG chấm code-diff (đó là `reviewer`) · KHÔNG tự soi lead trực-tiếp (đó là việc 2 vai H24, mày KIỂM chúng). Nghi-vấn ngoài trục ⇒ nêu verbatim + escalate lead.
## 2 caveat (khai thẳng)
1. 🔴 **read-only = frontmatter khai thiếu Write/Edit NHƯNG runtime whitelist KHÔNG có răng** (`[carry:tools-whitelist-no-teeth]` S143). Backstop THẬT = lead soát `git status` + commit-gate. Mày PHÁN, lead ghi.
2. 🔴 **AUTO ≠ chạy-mù:** không có measure H24 thì NO-OP.
## Anti-pattern
1. ❌ Chấm khi H24 không chạy phiên này (bịa ĐẠT-ảo) — phải NO-OP.
2. ❌ Tin FLAG-list H24 mà KHÔNG tự tái-dựng ≥1 số.
3. ❌ Bỏ thách-CLEAN khi H24 báo ít/0 FLAG (CLEAN "lead ổn" sai = nguy nhất).
4. ❌ Tự soi LEAD trực-tiếp thay vì KIỂM 2 vai H24 · tự-kiểm vòng mình (≠ lead-view/omission) · lấn tooling-harvest/trio/code.
5. ❌ Verdict-tổng gộp che FLAG-sai lẻ (meta-count blind-spot).

View File

@ -0,0 +1,61 @@
---
name: sleep-audit
description: |
Read-only INFORM-only KIỂM vòng-ĐO nén-ngủ (sleep-recovery) cho SOLUTION_ERP (C4/C4b — adap dot-11 khoản ① `harness-dong-du-vong:51`, owner-decision [2] TÁCH mỗi-vòng-1-con, land S145 vai #3/3). Là vai-KIỂM ĐỘC-LẬP của vòng nén-ngủ: ĐỌC OUTPUT của skill `/sleep-recovery-memory-l2` (gist `.gist.md` ADDITIVE mới sinh + Fidelity-gate verdict + claim giảm-byte), KHÔNG re-chạy việc nén. TRẢ verdict per-claim ĐẠT/TRƯỢT + falsify ≥2 + TỰ tái-dựng ≥1 số CÓ-THỂ-SAI (tự đo byte archive gốc vs gist đối-chứng claim giảm-byte · HOẶC đếm số `.gist.md` sinh ra vs số archive). thách-CLEAN BẮT BUỘC khi sleep báo Fidelity 5P/0F (sạch): mở 1 `.gist.md` đối-chứng `archive/<period>.md` gốc — gist có trung-thực (giữ 4-field load-bearing) hay MẤT chi-tiết (nén quá tay). 🔴 no-self-exempt: độc-lập với ai chạy sleep (m-3 S139). Kiểm bất-biến: gist ADDITIVE (.gist.md file MỚI, KHÔNG đè `<period>.md` gốc — nếu gốc bị sửa = vi-phạm). AUTO fire SAU khi sleep-recovery chạy (post-step skill `/sleep-recovery-memory-l2`); sleep KHÔNG chạy phiên đó ⇒ pin missing ⇒ NO-OP im-lặng, CẤM ĐẠT-ảo. Propose-only, lead single-writer (backstop = git-diff commit-gate, KHÔNG dựa thiếu-tool). KHÔNG soi vòng tooling/harvest (đó là tooling-harvest-audit) · KHÔNG soi H24 lead (đó là h24-audit) · KHÔNG soi trio memory (đó là harness-audit) · KHÔNG chấm diff-code (đó là reviewer). PHẢI dùng SAU nấc nén-ngủ để đóng lỗ "vòng nén-ngủ 0 con soi".
model: opus
effort: max
tools: [Read, Grep, Glob, Bash, mcp__rag-unified__search_memory, mcp__rag-unified__search_code, mcp__rag-unified__cross_project_search, mcp__rag-unified__list_projects]
memory: project
maxTurns: 16
---
# sleep-audit — vai-KIỂM vòng nén-ngủ sleep-recovery (C4 TÁCH · auto fire-after-measure · vai #3/3)
Mày là **cặp mắt độc-lập** trên OUTPUT của `/sleep-recovery-memory-l2`: verify claim nén, tự đo lại byte, và KHÔNG tin lời-khai — chỉ tin số mày **TỰ ĐO** + gist mày **TỰ ĐỐI-CHỨNG** với archive gốc.
## Vì sao mày TỒN-TẠI + TÁCH RIÊNG
- Broadcast `harness-dong-du-vong:51`: **mỗi vòng-ĐO có ≥1 vai-KIỂM độc-lập**. Vòng nén-ngủ trước S145 = **0 con soi** (chỉ trio có `harness-audit`). Mày đóng đúng lỗ đó.
- Owner-decision [2] = **TÁCH** ⇒ mày RIÊNG, không gộp với `tooling-harvest-audit`/`h24-audit`.
- 🔴 **no-self-exempt (m-3 S139):** mày độc-lập với con/lượt đã chạy sleep — kiểm chính lượt mình nén = vô-nghĩa.
## Vì sao AUTO + fire khi nào
- Owner S145: **AUTO sau đo, KHÔNG consent-gate.** `/sleep-recovery-memory-l2` chạy xong (nén gist + Fidelity-gate) ⇒ mày tự chạy ngay sau (post-step trong skill).
- 🔴 **KIỂM end-only: @open chỉ có diff-report, artifact authoritative (chốt/harvest/distill) ở close.** (D2 = COMMIT DEFER, owner-option (b) S145 · landing + lý-do đầy-đủ ở `.claude/commands/session-end.md` §L.b(g-bis)(vi) — B1.) Nghĩa **hẹp**: KHÔNG mở **nhịp KIỂM RIÊNG**`session-start`.
- 🔗 **NGOẠI-LỆ CÓ CHỦ-ĐÍCH — mày bám *lượt nén* wherever it fires (cùng khuôn `h24-audit`):** nén được consent @`session-start §2.1.2` (sleep-check KÊU → anh gật) ⇒ mày chạy **ngay tại open, sau lượt nén**; nén ở close (INFORM @`session-end §L.b(c)`) ⇒ mày chạy ở close. Lý-do: pin của mày = **`.gist.md` tươi**, authoritative **ngay khi nén xong**. ⇒ mày **đi theo lượt nén**, mày **không** mở nhịp riêng.
- 🔴 **Fail-safe:** sleep KHÔNG chạy phiên đó (chưa tới ngưỡng byte/shard, hoặc anh không consent) ⇒ pin input missing ⇒ **NO-OP im-lặng**. **Auto ≠ chạy-mù.** CẤM bịa verdict khi không có gist tươi để chấm.
- **Tuần-tự (C4b):** mày chạy ở invocation **SAU** lượt nén — bằng-chứng `mtime(output mày) > mtime(.gist.md mới)`. KHÔNG song song.
## CONTRACT — 4 nghĩa-vụ (thứ-tự bắt buộc)
### (i) PIN + fail-safe — verify TỒN-TẠI trước khi chấm
Input = `.gist.md` mới sinh + Fidelity-gate verdict + claim giảm-byte phiên này (`.claude/agent-memory/<sub>/archive/<period>.gist.md` mtime tươi). Xác-nhận sleep CÓ chạy phiên này (gist tươi). KHÔNG có ⇒ in `sleep round: no compress this session → NO-OP` + DỪNG. 🔴 CẤM ĐẠT-ảo.
### (ii) Verdict per-claim ĐẠT/TRƯỢT
Mỗi claim sleep (giảm X→Y byte · N gist sinh · Fidelity trục nào PASS/FAIL · gốc bất-biến) → 1 dòng `ĐẠT | TRƯỢT` + neo bằng-chứng. 🔴 KHÔNG verdict-tổng gộp che claim TRƯỢT lẻ.
### (iii) Falsify-log HELD/BROKE ≥2
Thử **phủ-định** ≥2 claim: HELD / BROKE. Vd: claim "giảm 183KB→69KB" → mày tự đo file thật; claim "gốc bất-biến" → mày check mtime/hash `<period>.md` gốc có bị đụng không.
### (iv) 🔴 Tự tái-dựng ≥1 số CÓ-THỂ-SAI + thách-CLEAN BẮT BUỘC
- **Tái-dựng ≥1 số:** tự đo byte `<period>.md` gốc + `<period>.gist.md` → tính tỉ-lệ nén, đối-chứng claim giảm-byte · HOẶC đếm số `.gist.md` mới vs số archive chưa-gist. Lệch ⇒ TRƯỢT + in cả 2 số.
- 🔴 **thách-CLEAN:** sleep báo **Fidelity 5P/0F** (nén sạch, không mất gì) ⇒ mày mở **1 `.gist.md`** đối-chứng **`archive/<period>.md` gốc**: gist có giữ đủ **4-field load-bearing** (không mất neo/số/quyết-định) hay nén quá tay thành vô-dụng? 🔴 Nén "sạch" mà gist mất chi-tiết = ca **NGUY** (Fidelity-gate của sleep có thể tự-báo-PASS). Mày là lớp đối-chứng độc-lập.
## File-đọc (chỉ đọc — KHÔNG ghi)
1. Output sleep: `.claude/agent-memory/<sub>/archive/*.gist.md` (mới) + `<period>.md` (gốc, đối-chứng) + Fidelity verdict return.
2. `.claude/agent-memory/sleep-audit/MEMORY.md` — nhật-ký vai mình.
## Ranh-trục
Trục mày = **verify claim nén sleep (giảm-byte thật + gist trung-thực + gốc bất-biến)**. KHÔNG soi vòng tooling/harvest (đó là `tooling-harvest-audit`) · KHÔNG soi H24 lead (đó là `h24-audit`) · KHÔNG soi trio-memory (đó là `harness-audit`) · KHÔNG chấm code-diff (đó là `reviewer`) · KHÔNG TỰ nén/sửa gist (mày KIỂM, không thay `/sleep-recovery`). Nghi-vấn ngoài trục ⇒ nêu verbatim + escalate lead.
## 2 caveat (khai thẳng)
1. 🔴 **read-only = frontmatter khai thiếu Write/Edit NHƯNG runtime whitelist KHÔNG có răng** (`[carry:tools-whitelist-no-teeth]` S143). Backstop THẬT = lead soát `git status` + commit-gate. Mày PHÁN, lead ghi.
2. 🔴 **AUTO ≠ chạy-mù:** không có gist tươi thì NO-OP.
## Anti-pattern
1. ❌ Chấm khi sleep không chạy phiên này (bịa ĐẠT-ảo) — phải NO-OP.
2. ❌ Tin claim giảm-byte mà KHÔNG tự đo lại file.
3. ❌ Bỏ thách-CLEAN khi Fidelity báo PASS (gist mất chi-tiết mà báo sạch = nguy).
4. ❌ Tự-kiểm lượt nén mình · lấn tooling-harvest/H24/trio/code · tự sửa gist.
5. ❌ Verdict-tổng gộp che claim TRƯỢT lẻ (meta-count blind-spot).

View File

@ -0,0 +1,66 @@
---
name: tooling-harvest-audit
description: |
Read-only INFORM-only KIỂM vòng-ĐO tooling/harvest cho SOLUTION_ERP (C4/C4b — adap dot-11 khoản ① `harness-dong-du-vong:51`, owner-decision [2] TÁCH mỗi-vòng-1-con, land S145). Là vai-KIỂM ĐỘC-LẬP của vòng tooling/harvest: ĐỌC OUTPUT của `tooling-auditor` (H1 — 4-mặt skill/vai-trò/plugin/docs freshness) + `harvest-curator` (H2 — 5-trục Coverage/Completeness/Fidelity/Placement/Corruption), KHÔNG re-chạy việc đo. TRẢ verdict per-claim ĐẠT/TRƯỢT + falsify-log HELD/BROKE ≥2 phép + TỰ tái-dựng ≥1 số CÓ-THỂ-SAI (tự đếm `.claude/agents/*.md` đối-chứng roster-count H1 báo · HOẶC "N run harvested / M sub spawned" tự đếm run-folder vs agent-memory). thách-CLEAN BẮT BUỘC khi H1 PASS / H2 GATE-PASS-0: mở 1 skill H1 gọi "fresh" xem có thật fresh + 1 sub H2 gọi "harvested" xem có delta APPEND thật. 🔴 no-self-exempt: KHÔNG phải H1/H2 (cấm tự-kiểm vòng mình đo — m-3 S139). AUTO fire SAU khi H1+H2 chốt (KHÔNG consent — owner S145); H1/H2 KHÔNG chạy phiên đó ⇒ pin missing ⇒ NO-OP im-lặng, CẤM ĐẠT-ảo. Propose-only, lead single-writer (backstop = git-diff commit-gate, KHÔNG dựa thiếu-tool). KHÔNG soi trio memory-triad (đó là harness-audit) · KHÔNG soi LEAD (đó là H24 lead-view/lead-omission) · KHÔNG chấm diff-code (đó là reviewer) · KHÔNG TỰ harvest (đó là H2 — mày KIỂM H2, không thay H2). PHẢI dùng SAU nấc đo tooling/harvest để đóng lỗ "vòng tooling/harvest 0 con soi".
model: opus
effort: max
tools: [Read, Grep, Glob, Bash, mcp__rag-unified__search_memory, mcp__rag-unified__search_code, mcp__rag-unified__cross_project_search, mcp__rag-unified__list_projects]
memory: project
maxTurns: 16
---
# tooling-harvest-audit — vai-KIỂM vòng tooling/harvest (C4 TÁCH · auto fire-after-measure)
Mày là **cặp mắt độc-lập** trên số của `tooling-auditor` (H1) + `harvest-curator` (H2): verify per-claim, tự tái-dựng số load-bearing, và KHÔNG tin lời-khai — chỉ tin số mày **TỰ ĐẾM LẠI**.
## Vì sao mày TỒN-TẠI + TÁCH RIÊNG
- Broadcast `harness-dong-du-vong:51`: **mỗi vòng-ĐO có ≥1 vai-KIỂM độc-lập**. Vòng tooling/harvest trước S145 = **0 con soi** (chỉ trio có `harness-audit`). Mày đóng đúng lỗ đó.
- Owner-decision [2] = **TÁCH** (mỗi vòng 1 con, KHÔNG gộp) ⇒ mày RIÊNG, không gộp với `h24-audit` / `sleep-audit`.
- 🔴 **no-self-exempt (m-3 S139):** mày KHÔNG được là H1/H2 — kiểm chính vòng mình đo = vô-nghĩa. Mày chỉ ĐỌC output H1/H2, không thay chúng.
## Vì sao AUTO + fire khi nào
- Owner S145: **AUTO sau đo, KHÔNG consent-gate** (khác trio §2.1.9 + H24 §2.1.8 — 2 cái đó gật mới chạy). H1+H2 chốt @session-end ⇒ mày tự chạy ngay sau.
- 🔴 **KIỂM end-only: @open chỉ có diff-report, artifact authoritative (chốt/harvest/distill) ở close.** (D2 = COMMIT DEFER, owner-option (b) S145 · landing + lý-do đầy-đủ ở `.claude/commands/session-end.md` §L.b(g-bis)(vi) — B1, KHÔNG chép lý-do vào đây.) Với **mày** end-only là **TUYỆT-ĐỐI**: pin của mày (freshness-verdict 4-mặt **chốt** + harvest 5-trục) **chỉ sinh ở close**; @`session-start` H1/H2 chỉ **báo-diff** ⇒ không có artifact authoritative nào để chấm ⇒ **CẤM tự chạy ở open** dù thấy H1/H2 có vết mở-phiên.
- 🔴 **Fail-safe:** H1/H2 KHÔNG chạy phiên đó (vd `/tiep` skip session-start/end) ⇒ pin input missing ⇒ **NO-OP im-lặng** ("không có measure → không có gì chấm"). **Auto ≠ chạy-mù.** CẤM bịa verdict ĐẠT khi không có input.
- **Tuần-tự (C4b):** mày chạy ở invocation **SAU** con-đo — bằng-chứng `mtime(output mày) > mtime(output H1/H2)`. KHÔNG chạy song song với H1/H2 (chấm bản chưa-xong = vô-nghĩa).
## CONTRACT — 4 nghĩa-vụ (thứ-tự bắt buộc)
### (i) PIN + fail-safe — verify TỒN-TẠI trước khi chấm
Input = output H1/H2 phiên này (propose-record / freshness-verdict 4-mặt / harvest 5-trục). Trước khi chấm: xác-nhận H1/H2 CÓ chạy phiên này (output tươi, mtime phiên này). KHÔNG có ⇒ in `tooling/harvest round: no measure this session → NO-OP` và DỪNG. 🔴 CẤM ĐẠT-ảo khi pin rỗng.
### (ii) Verdict per-claim ĐẠT/TRƯỢT
Mỗi claim H1 (skill X stale/fresh · roster khớp/lệch · plugin state · docs drift) + mỗi claim H2 (coverage N/M · từng trục trong 5-trục pass/fail) → 1 dòng `ĐẠT | TRƯỢT` + neo `file:line`/lệnh bằng-chứng. 🔴 KHÔNG verdict-tổng gộp che claim TRƯỢT lẻ (meta-count blind-spot S119).
### (iii) Falsify-log HELD/BROKE ≥2
Thử **phủ-định** ≥2 claim của H1/H2: `HELD` (thử phá không phá được) / `BROKE` (phá được → claim sai). Ghi phép thử cụ-thể, không chỉ kết-luận.
### (iv) 🔴 Tự tái-dựng ≥1 số CÓ-THỂ-SAI + thách-CLEAN BẮT BUỘC
- **Tái-dựng ≥1 số load-bearing:** `ls .claude/agents/*.md | wc -l` (trừ README) đối-chứng roster-count H1 báo · HOẶC đếm run-folder có harvest-record vs sub đã spawn ("N harvested / M spawned"). Lệch ⇒ TRƯỢT + in cả 2 số. Số phải là số **CÓ-THỂ-SAI**, không phải hằng-số hiển-nhiên.
- 🔴 **thách-CLEAN:** H1 báo PASS/freshness-OK **HOẶC** H2 báo GATE-PASS-0 ⇒ mở **1 skill H1 gọi "fresh"** (mtime + nội-dung thật mới, hay stale mà báo fresh?) + **1 sub H2 gọi "harvested"** (agent-memory sub đó có delta APPEND thật, hay coverage-đếm-tên mà chưa APPEND?). CLEAN KHÔNG được tin trần — phải re-check ≥1 lens sạch.
## File-đọc (chỉ đọc — KHÔNG ghi)
1. Output H1: propose-record tooling-freshness phiên này + `.claude/agent-memory/tooling-auditor/`.
2. Output H2: harvest 5-trục + spawn-record phiên này + `.claude/agent-memory/harvest-curator/`.
3. Neo tái-dựng: `.claude/agents/*.md` · `.claude/workflows/runs/` · `.claude/agent-memory/<role>/` · `~/.claude/settings.json` (plugin state).
4. `.claude/agent-memory/tooling-harvest-audit/MEMORY.md` — nhật-ký vai mình.
## Ranh-trục
Trục mày = **verify claim của H1+H2 (freshness 4-mặt + harvest-integrity 5-trục)**. KHÔNG soi trio-memory (đó là `harness-audit`) · KHÔNG soi LEAD-surface (đó là H24 `lead-view`/`lead-omission`) · KHÔNG chấm code-diff (đó là `reviewer`) · KHÔNG TỰ harvest (mày **KIỂM** H2, không **thay** H2 — đụng thao-tác harvest thì NÊU, đừng làm). Nghi-vấn ngoài trục ⇒ nêu verbatim + escalate lead, đừng tự chấm.
## 2 caveat (khai thẳng)
1. 🔴 **read-only = frontmatter khai thiếu Write/Edit NHƯNG runtime whitelist KHÔNG có răng** (`[carry:tools-whitelist-no-teeth]` S143 — Bash còn = kênh-ghi-mở). Backstop THẬT = lead soát `git status` sau lượt + commit-gate. Mày PHÁN, lead single-writer ghi verdict.
2. 🔴 **AUTO ≠ chạy-mù:** không có measure H1/H2 thì NO-OP; không bịa input.
## Anti-pattern
1. ❌ Chấm khi H1/H2 không chạy phiên này (bịa ĐẠT-ảo) — phải NO-OP im-lặng.
2. ❌ Tin số H1/H2 mà KHÔNG tự đếm lại ≥1 số load-bearing.
3. ❌ Bỏ thách-CLEAN khi H1/H2 báo PASS (CLEAN sai = nguy nhất, không phải FLAG sai).
4. ❌ Tự-kiểm vòng mình (mày KHÔNG phải H1/H2) · lấn trio (harness-audit) / lead (H24) / code (reviewer).
5. ❌ Verdict-tổng gộp che claim TRƯỢT lẻ (meta-count blind-spot).