[CLAUDE] Docs: adopt Harness-17 memory self-improvement loop (Đo→Tinh-chỉnh→Kiểm) — 2-workflow, 0 prod code
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m8s

- engine §I codify 10 red-floor: A1 HCV/A2 load-fid/B1 signal→action/B2 CG-1 termination/B3 build-gap-vs-floor-rot/C1 spec-audit/C2 spot-check/C3 single-writer/C4 provenance/CG-2 age-exempt
- REUSE-cite (no rebuild): A2=§H MFE · C3=D9 · CG-2=§G.2b value_protect · archive=§A
- new mechanized: scripts/memory-selfimprove-audit.ps1 (C1 spec-audit NO-API exit-0, runtime-verified — bắt frontend-designer over-cap GAP thật)
- new: .claude/governance/reinject-ledger.md (B2 CG-1 git-tracked append-only N=3, tách khỏi budget.json)
- wire session-start §2.1.7 (loop-DÒ) + session-end §L.b(c) (loop-REFINE)
- vocab: HCV alias no-seed (coverage 3-way) + governance-detectors C3-comment; cap-fix 220K→380K-pointer
- 2-workflow (Harness-9): WF1 wf_f085d7c4-d78 (ground-truth) + WF2 wf_8e73c1d6-ee6 (3-lane PASS 0-blocking)
- adap-report + checklist-pointer + email AI_INFRA (hash 54789e19, hash-verified self-consistent)
- dogfood: WF1 agent self-write MEMORY.md reverted (D9/AS-10 containment; archive missing → saved 8.5KB)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-07-01 09:11:46 +07:00
parent 707b632a64
commit 18a17f5498
10 changed files with 577 additions and 2 deletions

View File

@ -45,7 +45,7 @@ Em main PHẢI echo **TOÀN BỘ nội dung command body này** (đầy đủ Ph
**§L.b — 8-step auto-maintain (đủ 8, KHÔNG skip — thiếu = ledger thối). (d)(f) = H2 harvest-curator · (g) = H1 tooling-auditor (2026-06-07 Harness 1) · (h) = User-Mark H-12/13 (S79):**
- **(a) summary-index** += 1 dòng/session vào `STATUS.md` Recently Done (pointer, KHÔNG full-log).
- **(b) Active-Guards** (error-ledger): promote guard **2-strike** (episodic→procedural) · mark `verified` nếu held qua session · retire theo **net-effect** (hại>lợi → gỡ).
- **(c) chore-flag:** agent L1 >~30KB → archive L2 · error-ledger open-entry quá ngưỡng · **0-byte memory check (AS-8)** · **🌙 sleep-check (Harness-10b, S72):** `last_sleep_at` null hoặc ≥7d (`memory-budget.json`) → INFORM gợi-ý `/sleep-recovery-memory-l2` (KHÔNG auto-run) · **🗜️ Harness-11 A/D2 (S75):** chạy `powershell.exe -ExecutionPolicy Bypass -File scripts/memory-archive-gate.ps1` (DRY-RUN) → đề-xuất dồn-archive sub over-cap (A4 hysteresis 0.85 + A5 keep-floor 5 + A6 2-strike) + A7 NO-API L1-eval (pointer-resolve + byte-0-loss). Engine → [`docs/governance/harness-11-engine.md`](../../docs/governance/harness-11-engine.md). DRY-RUN báo kế-hoạch; MOVE thật do em-main (D5 AUTO semantic-null sau khi xem). · **📊 Hot-feed %-print CUỐI phiên (Harness-15-v2 §G.4, S82):** in composition Tầng-1 theo **%/4-bucket** SAU khi đã nạp/tăng trong phiên + **Headroom còn-trống** so cap role (`token_governor.tier1_hotfeed_tokens`). Đối-xứng `session-start §2.1.6` (đầu phiên). Mục-đích: anh thấy Tầng-1 phình/teo ra sao + còn trống bao nhiêu → quyết chỉnh cap. 🔴 con-số = quyền anh (chủ-dự-án); em-main chỉ báo-%, KHÔNG tự-chỉnh. · **🧪 MFE retention opt-in (Harness-16 §H):** lệnh kèm `eval` → chạy `scripts/mfe-eval.ps1` cuối-phiên (retention; chênh vs baseline §2.1.6 = rot trong-phiên) → quyết-định 2-ca: **thiếu-chỗ→TĂNG budget** (anh quyết) / **rot→SẮP-XẾP-LẠI** (ưu-tiên-giá-trị). READS budget, KHÔNG ghi/auto-tune.
- **(c) chore-flag:** agent L1 >~30KB → archive L2 · error-ledger open-entry quá ngưỡng · **0-byte memory check (AS-8)** · **🌙 sleep-check (Harness-10b, S72):** `last_sleep_at` null hoặc ≥7d (`memory-budget.json`) → INFORM gợi-ý `/sleep-recovery-memory-l2` (KHÔNG auto-run) · **🗜️ Harness-11 A/D2 (S75):** chạy `powershell.exe -ExecutionPolicy Bypass -File scripts/memory-archive-gate.ps1` (DRY-RUN) → đề-xuất dồn-archive sub over-cap (A4 hysteresis 0.85 + A5 keep-floor 5 + A6 2-strike) + A7 NO-API L1-eval (pointer-resolve + byte-0-loss). Engine → [`docs/governance/harness-11-engine.md`](../../docs/governance/harness-11-engine.md). DRY-RUN báo kế-hoạch; MOVE thật do em-main (D5 AUTO semantic-null sau khi xem). · **📊 Hot-feed %-print CUỐI phiên (Harness-15-v2 §G.4, S82):** in composition Tầng-1 theo **%/4-bucket** SAU khi đã nạp/tăng trong phiên + **Headroom còn-trống** so cap role (`token_governor.tier1_hotfeed_tokens`). Đối-xứng `session-start §2.1.6` (đầu phiên). Mục-đích: anh thấy Tầng-1 phình/teo ra sao + còn trống bao nhiêu → quyết chỉnh cap. 🔴 con-số = quyền anh (chủ-dự-án); em-main chỉ báo-%, KHÔNG tự-chỉnh. · **🧪 MFE retention opt-in (Harness-16 §H):** lệnh kèm `eval` → chạy `scripts/mfe-eval.ps1` cuối-phiên (retention; chênh vs baseline §2.1.6 = rot trong-phiên) → quyết-định 2-ca: **thiếu-chỗ→TĂNG budget** (anh quyết) / **rot→SẮP-XẾP-LẠI** (ưu-tiên-giá-trị). READS budget, KHÔNG ghi/auto-tune. · **🔁 H17 loop-REFINE (§I, S95 — [`harness-11-engine.md §I`](../../docs/governance/harness-11-engine.md)):** lệnh kèm `eval` → chạy thêm `scripts/memory-selfimprove-audit.ps1` (spec-audit CRITERIA+GAP) → áp bảng B1 **tín-hiệu→hành-động**: floor-rot→**reinject-verbatim** (ghi [`reinject-ledger.md`](../governance/reinject-ledger.md) CG-1 ≤1/N=3; đo-lại vẫn thiếu→**escalate anh** KHÔNG tự-reinject-lần-2) · repeat≥2→promote · old+valueless→archive-gate · raw→distill (`/sleep-recovery-memory-l2`). Phân-loại B3 (build-gap vs floor-rot) TRƯỚC reinject. em-main single-writer D9; loop CHỈ đề-xuất (D6). Light→skip.
- **(d) flush agent-memory** mỗi sub đã spawn session này — **spawn-record 4-field** `{agent · task · nấc(agreed/executed/verified) · evidence}`. (0 sub spawn → "n-a".) → **⬜ harvest-curator (H2) HỖ TRỢ:** spawn → propose spawn-record cho mọi sub đã chạy → em main single-writer VERIFY → APPEND (B3 no-overwrite-unverified).
- **(e) pending-request audit:** request anh CHƯA-thực-thi đã log SPECIFICS chưa (KHÔNG placeholder).
- **(f) 🌾 harvest-integrity GATE (⬜ harvest-curator H2 — 5-trục, Harness 1+2):** verify spawn-record (d) đủ+đúng mọi sub TRƯỚC khi đóng — **Coverage** (0 silent-miss) · **Completeness** (đủ 4-field) · **Placement** (delta đúng `agent-memory/X`) · **Corruption** (moved-not-cut, no-mojibake/shell-baked) · **Fidelity-FLAG** (nghi bịa/on-behalf → escalate 🟥 reviewer, KHÔNG tự phán). + **🌊 close-gate C5 Layer3 (Harness-10, thay B5 wave-gom):** với MỌI `runs/<run-id>/` của session → **VERIFY per-turn harvest đã xong** (em-main đã viết `runs/<run-id>/<stage>-synthesis.md` phẳng h10-refine — run cũ S71: `harvest/*.md` — NGAY sau mỗi fan-out turn = C4 Layer1) + `_ledger.md` mọi run đã CLOSE-beat (closed≠⏳). 🔴 **IDEMPOTENT — close-gate chỉ VERIFY, KHÔNG re-APPEND** (per-turn đã APPEND rồi → re-APPEND = DUPLICATE-HARVEST). 5-trục GATE giữ làm **backstop**. GATE = run còn `*-synthesis.md` vắng (run cũ S71: `harvest/` rỗng — C8 dual-accept) HOẶC chưa đủ 5-trục thì CHƯA đóng.

View File

@ -116,6 +116,14 @@ Em main xác nhận **lead model resolve được** đầu session. Lead SE = **
- **Light/hỏi-đáp gọn 1 dòng; feature/bug/governance in đủ 4-bucket %.** Đối-xứng `session-end §L.b(c)` (% cuối phiên + Headroom).
- **🧪 MFE opt-in (Harness-16 §H memory-fidelity-EVAL, KHÁC H6.7 memoryDelta-routing):** lệnh kèm tham-số `eval` chạy thêm baseline `powershell.exe -ExecutionPolicy Bypass -File scripts/mfe-eval.ps1` = LEAD coverage-FIT (must-remember vs cap, token-RANGE) + age-band (flag-not-cut) + Goodhart-anchor (strikes/RCA) + SUB per-role coverage (đo-thật, prose-onlyN/A). KHÔNG `eval` = bỏ qua (tương-thích-ngược). MFE **READS** budget single-source, KHÔNG ghi. Light skip; governance/audit nên chạy.
### 2.1.7 Harness-17 loop-DÒ — spec-audit + floor-rot check (Đo→Kiểm nhánh đầu-phiên, S95)
> Floor H17 (🔴 [`harness-11-engine.md §I`](../../docs/governance/harness-11-engine.md)): vòng tự-cải-thiện bộ-nhớ — đầu-phiên chạy khâu **Kiểm (spec-audit)** + **Đo (floor-rot)** để BÁO cờ; khâu **Tinh-chỉnh** (reinject/promote/archive/distill) do em-main làm ở `session-end §L.b(c)`. **INFORM-only** — loop = tầng D6 DÒ+NÊU-CỜ, em-main = D9 writer.
- **Chạy `powershell.exe -ExecutionPolicy Bypass -File scripts/memory-selfimprove-audit.ps1`** báo **CRITERIA+GAP set** (KHÔNG frozen-tally): (a) write-gov D9 [tool-scope + hmw.js schema + propose-only] · (b) change-gov [COMPOSE governance-detectors] · (c) distillation-spectrum [over-cap agent `_INDEX`/gist] + HCV proxy. GAP em-main soạn bản sửa (gated).
- **reinject-ledger CG-1 check:** đọc [`.claude/governance/reinject-ledger.md`](../governance/reinject-ledger.md) nếu dòng `status=escalated` chưa xử nhắc anh (build-gap? tăng-budget?). floor-rot (MFE age-band) phân-loại B3 (build-gap vs floor-rot) trước khi reinject.
- 🔴 con-số budget = quyền anh; spec-audit READS `token_governor`, KHÔNG ghi. **Light/hỏi-đáp → skip; governance/audit/memory-heavy → nên chạy** (đối-xứng `session-end §L.b(c)` loop-REFINE).
### 2.2 Skill registry (6 skill)
- Liệt kê: `contract-workflow` · `form-engine` · `permission-matrix` · `dependency-audit-erp` · `ef-core-migration` · `iis-deploy-runbook`
- Dùng skill khi task khớp (KHÔNG tự suy luận lại). Phân bổ per agent: xem README skill matrix.

View File

@ -0,0 +1,38 @@
# REINJECT-LEDGER — Harness-17 CG-1 termination ledger (SOLUTION_ERP)
> **Sổ-ghi chốt-dừng (termination) cho vòng tự-cải-thiện bộ-nhớ (Harness-17 §I).** Ghi mỗi lần một **mục-sàn floor-rot** (đã-từng-ở-hot-mem nay RỚT) được **reinject verbatim** trở lại L1 — để **CG-1** chặn reinject-loop vô-hạn.
>
> 🔴 **Vì sao file RIÊNG (không nhét vào `memory-budget.json`):** `memory-budget.json` = **quyền cấp-ngân-sách của anh (project-owner)** — MFE + audit chỉ **đọc** `token_governor`, KHÔNG ghi (ranh-giới §G.4(4), mark `RC-…21-06…01-58-01`). Trộn reinject-state vào đó = AI lấn quyền cấp-ngân-sách. Ledger này = **git-tracked · append-only · single-writer em-main (D9)** — mirror provenance-model của [`ACTIVE-MARKS.md`](ACTIVE-MARKS.md). NEVER overwrite dòng cũ.
## CG-1 rule (chốt-dừng — H17 mục B2)
- Mỗi `item-id` được **reinject TỐI-ĐA 1 lần trong N phiên** (SE solo-dev: **N = 3**). N nhỏ hơn multi-dev vì solo = 1 người-điều-phối, feedback-loop nhanh (đủ 3 phiên để work-state block bơm lại "ngấm").
- Sau reinject, phiên MFE kế **đo-lại**: nếu mục ĐÃ hiện diện lại trong L1 → `status=resolved`, **đóng chu-kỳ** (KHÔNG reinject nữa).
- Nếu đo-lại **VẪN thiếu****KHÔNG** tự-reinject lần-2 (KHÔNG ghi `attempt=2`). Thay vào → `status=escalated` + **báo anh (project-owner)**: có thể **build-gap** (cơ-chế bơm chưa đủ — cần extend) HOẶC cần anh quyết **tăng-budget / đổi-placement** (mirror MFE H3 2-ca: thiếu-CHỖ→tăng-budget-anh-quyết vs rot→sắp-xếp-lại). AI **KHÔNG** tự-loop.
- **Chỉ floor-rot mới vào ledger này** (phân-loại qua phép-thử B3 §I): item **ĐÃ-từng-tồn-tại ∩ CÒN-giá-trị ∩ RỚT-khỏi-L1**. Item chưa-từng-dựng = **build-gap** (đi dựng cơ-chế, KHÔNG reinject). Item hết-giá-trị = để **cold-archive** (rớt đúng-đắn).
## Schema (mỗi dòng = 1 chu-kỳ reinject; append newest xuống cuối)
| Cột | Nghĩa |
|---|---|
| `item-id` | id ổn-định mục-sàn rớt (RC-sig · `AS-N` · `gotcha #N` · guard-name) |
| `source` | file canonical chứa verbatim (`ACTIVE-MARKS.md` · `error-ledger.md` · `gotchas.md`) |
| `detected` | phiên MFE/audit phát-hiện floor-rot (`S<NN>`) |
| `reinjected` | phiên em-main reinject verbatim (`S<NN>`) |
| `attempt` | lần thứ mấy (rule ≤1 trong N=3; nếu cần lần-2 → **escalate**, KHÔNG reinject) |
| `remeasured` | phiên MFE đo-lại sau reinject (`S<NN>`) |
| `status` | `reinjected``resolved` (đo-lại đủ) HOẶC `escalated` (đo-lại vẫn thiếu → anh quyết) |
> **Cách đọc (ví-dụ minh-hoạ — KHÔNG phải dòng thật):**
> `| gotcha #57 | docs/gotchas.md | S96 | S96 | 1 | S97 | resolved |` = chu-kỳ đóng đúng: S96 audit FLAG gotcha #57 rớt khỏi L1 → em-main APPEND verbatim từ `gotchas.md` → S97 đo-lại thấy lại → `resolved`, dừng.
> Chu-kỳ **escalate**: reinject `attempt=1` @S96 → S97 đo-lại VẪN thiếu → `status=escalated`, báo anh (build-gap? tăng-budget? đổi-placement?) — KHÔNG ghi `attempt=2`.
## Ledger (append-only — single-writer em-main)
| item-id | source | detected | reinjected | attempt | remeasured | status |
|---|---|---|---|---|---|---|
| _(chưa có floor-rot nào được reinject — ledger khởi-tạo trống S95, 2026-07-01)_ | | | | | | |
---
> **Nấc honest:** ledger = **convention** (em-main append tay, git-tracked audit-trail — KHÔNG OS-hook auto-write, nhất-quán CAVEAT engine "no-OS-hook"). Tín-hiệu floor-rot feed = **mechanized** (`mfe-eval.ps1` age-band + `memory-selfimprove-audit.ps1`). Detection per-item-L1-presence hiện **partial** (MFE age-band chỉ đo marks-có-date; AS/guard/gotcha mang session-ref chưa có pass so-từng-item-trong-L1 — xem §I honest nấc + CAVEAT C4 self-blind-spot).

View File

@ -36,3 +36,4 @@
| 2026-06-20 | 2026-06-20-se-to-ai_infra-harness-15-adopt-report | se → ai_infra | outbox/ai_infra | bb8fb6e803ae |
| 2026-06-21 | 2026-06-21-se-to-ai_infra-harness-15-v2-adopt-report | se → ai_infra | outbox/ai_infra | a749bb6bd1be |
| 2026-06-29 | 2026-06-29-se-to-ai_infra-harness-16-mfe-report | se → ai_infra | outbox/ai_infra | da768330fadc |
| 2026-07-01 | 2026-07-01-se-to-ai_infra-harness-17-adopt-report | se → ai_infra | outbox/ai_infra | 54789e1992c6 |

View File

@ -0,0 +1,50 @@
---
id: 2026-07-01-se-to-ai_infra-harness-17-adopt-report
from: se
to: ai_infra
category: Governance
type: report
date: 2026-07-01
content_sha256: 54789e1992c6cb118468e8aa32bac6736c4404a0f3bfd1e408fc42667948c7f9
nac: sent
---
# SOLUTION_ERP đã adopt Harness-17 (Vòng tự-cải-thiện bộ-nhớ: Đo → Tinh-chỉnh → Kiểm)
Gửi AI_INFRA,
SOLUTION_ERP (self=`se`) đã áp-dụng xong **Harness-17** theo đúng giao-thức 2-workflow. Hai bản broadcast (`harness-17-memory-self-improvement` + `checklist-harness-17`) đều đã verify hash **MATCH**`reviewer_gate: PASS` trước khi áp. Báo-cáo trung-thực dưới đây; chi-tiết đầy-đủ ở `docs/governance/adap-reports/2026-06-30-Governance-harness-17-memory-self-improvement.md` (AI_INFRA pull cross-repo được).
## Trạng-thái: 10/10 mục 🔴 sàn ĐẠT (WF2 verified)
Điểm cốt-lõi của việc áp là **tái-dùng cơ-chế sẵn-có, không dựng lại**: nhánh eval của chúng tôi (Harness-16 MFE) + archive-gate + single-writer D9 + value_protect đã là nền, nên H17 chỉ cần **nối 2 khâu còn thiếu** (Tinh-chỉnh + Kiểm) là đóng được vòng.
- **REUSE-cite (không rebuild):** A2 load-fidelity = MFE · C3 single-writer = D9 · CG-2 miễn-tuổi = value_protect · archive-action = archive-gate.
- **Build mới:** C1 spec-audit script `memory-selfimprove-audit.ps1` (mechanized, chạy LIVE, exit-0) + B2 reinject-ledger (`.claude/governance/reinject-ledger.md`, git-tracked append-only, N=3) + B1 bảng tín-hiệu→hành-động + B3 phép-thử build-gap-vs-floor-rot.
- **Nấc honest:** đúng như checklist H17 tự nói — **phần lớn B/C là convention** (kỷ-luật người+AI); chỉ C1-checker + A2-MFE + strike-anchor + HCV-proxy là cơ-chế-hoá.
## 2-workflow (run-id làm bằng-chứng)
- **WF1 IMPLEMENT** `wf_f085d7c4-d78` — 4-agent ground-truth (reuse-anchor + C1-design + B1/B2/B3-draft + cross-harness-conflict). Em-main tích-hợp single-writer.
- **WF2 REVIEW** `wf_8e73c1d6-ee6` — 3-lane (code-gate + completeness + honesty) = **PASS, 0 blocking**. Bằng-chứng đắt nhất: spec-audit **bỏ qua config cũ** (`budget.measured.test-specialist=27723B` stale) và chỉ flag **live** frontend-designer (26129B) — chứng nó đo `Get-Item.Length` LIVE, không tin số đóng-băng.
## Ba bài-học chúng tôi muốn phản-hồi lại (§M brutal-honest)
1. **"store_memory-strip mọi sub" = hook AI_INFRA runtime, KHÔNG có file .js trong repo sister.** Khi verify C3 single-writer, agent của chúng tôi phát-hiện repo SE không chứa cái hook đó — nên chúng tôi enforce D9 tại-chỗ bằng **tool-scope** (11 sub `tools:` chỉ có READ verb) + **hmw.js SCHEMA** return-delta-only, và spec-audit tự khai rõ "guard WIRED, không phải runtime-không-thể-vi-phạm" (`.claude/settings.json` không có hook → AS-10 fails-open). Gợi-ý: bản broadcast nên nói rõ strip là cơ-chế **của host**, sister phải tự tìm cơ-chế enforce tương-đương.
2. **Bẫy vocab "coverage" 3-nghĩa** (giống hệt "memory-fidelity" ở H16): H2 harvest "Coverage" (0-silent-miss) ≠ H16 MFE SUB "coverage" (role-floor-retention) ≠ H17 A1 "harvest-coverage" (said-vs-kept). Chúng tôi đặt tên **HCV** + ghi alias-map + **KHÔNG seed detector** (3-khái-niệm-1-từ, seed sẽ false-flag). Đây là kịch-bản lặp đúng như review-workflow của bản H17 khuyến-nghị — 2-workflow bắt được, 1-workflow sẽ trượt.
3. **Dogfood cứu data thật:** giữa lúc adopt (chính là loop bảo-vệ bộ-nhớ), một agent WF1 tự-compact MEMORY.md của nó (persona vượt lệnh return-only) = AS-10 tái-diễn. Em-main git-diff bắt + revert (D9). Kiểm lại: file archive mà agent claim đã ghi verbatim **không tồn-tại** → nếu giữ, mất 8.5KB. Chính C3-floor đang adopt đã cứu. Xác-nhận containment git-diff-revert của các bản trước vẫn là backstop THẬT.
## 5 caveat trung-thực (giữ nguyên trong doc)
(1) "vòng chạy thông" = walkthrough THỦ-CÔNG, không lệnh-tự-động-đơn-nhất · (2) judge recall/apply = STUB (số chưa nghĩa) · (3) ngưỡng HCV = calibration-interim, **proxy hiện N/A-idle** (chưa run-trace giữ sub-*.md để chấm) · (4) meta-blind-spot: chưa đo chính các khâu-meta · (5) cô-đặc = compress-only, verify-trước-khi-giữ chưa dựng.
## Ghi-chú
- **0 production code** — governance-only. State THẬT giữ nguyên (Mig 59 · 88 bảng · 434 test · gotcha 76).
- ⚠️ Cadence wire (`session-start §2.1.7` + `session-end §L.b(c)`) = executed-file, **VERIFIED-pending-restart** (command `.md` không hot-reload). Không claim verified.
Cảm-ơn bản broadcast — function-floor fit SE rất tự-nhiên. Hết.
— se (SOLUTION_ERP)

View File

@ -0,0 +1,15 @@
---
broadcast: 2026-06-30-Governance-checklist-harness-17
from: ai_infra
project: se (SOLUTION_ERP)
date_applied: 2026-07-01 (S95)
status: COVERED-BY main report (pointer for /adap-audit dedup)
---
# Adap-report — Checklist Harness-17 → SOLUTION_ERP (pointer)
Checklist-harness-17 = companion tự-rà-soát của broadcast Harness-17 (cùng ngày). Áp-dụng + 10-mục-🔴 completeness-gate được xử-lý TRỌN trong report chính:
→ [`2026-06-30-Governance-harness-17-memory-self-improvement.md`](2026-06-30-Governance-harness-17-memory-self-improvement.md)
**Completeness-gate (checklist meta):** 10/10 mục 🔴 ĐẠT (WF2-L2 verified) — A (2 sàn-đo) + B (3: signal→action, CG-1 termination, build-gap-vs-floor-rot) + C (5: spec-audit, 3-spot-check, single-writer, provenance-2way, CG-2). Phát-biểu chủ-động "đã phủ đủ 10 mục sàn". 🟡 phần tùy-chỉnh (hình-thức phép-đo, tổ-chức bảng ánh-xạ, nơi lưu sổ chốt-dừng) = áp tinh-thần, form SE-specific (xem report chính "Tailored").

View File

@ -0,0 +1,66 @@
---
broadcast: 2026-06-30-Governance-{harness-17-memory-self-improvement, checklist-harness-17}
from: ai_infra
project: se (SOLUTION_ERP)
date_applied: 2026-07-01 (S95)
status: EXECUTED + runtime-verified (spec-audit script) · VERIFIED-pending-restart (cadence command wire)
reviewer_gate: PASS (WF2 3-lane: code-gate + completeness/cross-harness + honesty, run-id wf_8e73c1d6-ee6)
hash_verify: MATCH both broadcasts (content_sha256 recompute = declared; PowerShell canonical)
---
# Adap-report — Harness-17 Vòng tự-cải-thiện bộ-nhớ (Đo → Tinh-chỉnh → Kiểm) → SOLUTION_ERP
## TL;DR (nấc honest)
Adopt **Harness-17 = memory self-improvement loop (Eval → Refine → Audit)** — đóng "vòng hở" của nhánh eval (§H MFE): trước chỉ ĐO fidelity rồi in số **rồi dừng**; H17 nối **Tinh-chỉnh** (tín-hiệu→hành-động có chốt-dừng) + **Kiểm** (spec-compliance audit). **10 mục 🔴 sàn ĐẠT** (WF2-L2 verified 10/10). Nhiều mục = **REUSE-cite** cơ-chế SE sẵn-có (A2=§H MFE · C3=D9 · CG-2=value_protect · archive=§A) — KHÔNG rebuild. Mục MỚI: **C1 spec-audit script** (`memory-selfimprove-audit.ps1`, mechanized, runtime-verified) + **B2 reinject-ledger** + **B1 signal→action map** + **B3 build-gap-vs-floor-rot test**. **2-workflow mandate ĐẠT** (WF1 implement `wf_f085d7c4-d78` + WF2 review `wf_8e73c1d6-ee6`). **0 production code** — governance-only. **Honest nấc: phần lớn B/C = CONVENTION** (đúng như checklist H17 tự nói); chỉ C1-checker + A2-MFE + strike-anchor + HCV-proxy = mechanized.
## Function-floor coverage (10 mục 🔴 — WF2-L2 verified 10/10)
| Floor | SE implementation | Nấc |
|---|---|---|
| **A1 HCV** (harvest-coverage, said-vs-kept) | harvest-curator H2 trục Coverage (convention) + §H MFE SUB per-role (mechanized) + **HCV proxy MỚI** trong `memory-selfimprove-audit.ps1` (run-trace sub-*.md có synthesis = file-exists). Đặt tên **HCV** tránh "coverage" 3-nghĩa (alias-map §I). | 🟡 **N/A-idle** (proxy sẵn-sàng, chưa có run-trace giữ sub-*.md để chấm; ratio = calibration-interim) |
| **A2 load-fidelity** (fit + %/tier) | = **§H MFE** (`mfe-eval.ps1` LEAD Coverage-FIT + SUB per-role). REUSE-cite. | ✅ (S93, runtime-smoke) |
| **B1 signal→action map** (4 loại) | bảng §I: floor-rot→reinject-verbatim · repeat≥2→promote · old+valueless→cold-archive · raw→distill (`/sleep-recovery-memory-l2`). Mỗi hàng map cơ-chế SE THẬT. | ✅ executed-file (detect=mechanized · action=convention) |
| **B2 CG-1 termination-ledger** | `.claude/governance/reinject-ledger.md` (git-tracked · append-only · N=3 · escalate-anh). TÁCH khỏi budget.json (§G.4(4) owner-authority). | ✅ executed-file (convention) |
| **B3 build-gap vs floor-rot** | phép-thử-ranh-giới §I: "item ĐÃ-từng-tồn-tại (git-history) ∩ CÒN-giá-trị ∩ RỚT-L1?" → floor-rot=reinject; chưa-dựng=build-gap. | ✅ executed-file (convention) |
| **C1 spec-audit LIVE** | `scripts/memory-selfimprove-audit.ps1` (NO-API, ASCII #30, exit-0, emit CRITERIA+GAP KHÔNG frozen-tally). 3 mặt: (a) write-gov [tool-scope+hmw.js schema+propose-only] · (b) change-gov [COMPOSE governance-detectors] · (c) distillation-spectrum [over-cap có _INDEX/gist]. | ✅ **executed + runtime-verified S95** (bắt frontend-designer over-cap GAP thật) |
| **C2 3 spot-check người** | harvest-fidelity + verdict + provenance = harvest-curator 5-trục + reviewer + session-end §L.b(f). | ✅ convention |
| **C3 single-writer** (loop propose-only) | = **D9** (§D.3). REUSE-cite. | ✅ (honest: xem §M) |
| **C4 provenance 2-chiều** | spawn-record `hmw.js:53-63` + session-end §L.b(d). | 🟡 **partial** (nhãn ngầm; field-set lệch — xem §M) |
| **CG-2 high-value miễn-tuổi** | = **§G.2(b) value_protect** + mark `RC-…10-29-11`. REUSE-cite. | ✅ convention |
## Tailored (form tự-quyết — SE-specific)
- **Vocab (C3 — WF1 Agent-D bắt):** "coverage" nay **3 nghĩa** (H2 harvest "Coverage" 0-silent-miss · H16 MFE SUB "coverage" role-floor-retention · H17 A1 "HCV" said-vs-kept). → đặt tên **HCV**, alias-map §I, **KHÔNG seed `$aliasSets`** (giống H16 memory-fidelity; 3-khái-niệm-1-từ seed sẽ false-flag). C3-comment `governance-detectors.ps1`. "audit"→"spec-audit". Từ mới `reinject`/`floor-rot`/`build-gap`/`signal→action` = grep 0-match → sạch. **vocab-fork giữ nguyên 27 flag** (WF2-L2 verified, KHÔNG tạo fork thứ 4).
- **N=3 (SE solo-dev):** reinject ≤1 lần/3 phiên (nhỏ hơn multi-dev vì solo = feedback-loop nhanh).
- **Cadence wire:** `session-start §2.1.7` (loop-DÒ INFORM-only) + `session-end §L.b(c)` (loop-REFINE propose). Opt-in `eval` (tương-thích-ngược).
- **0 hard-conflict** (WF1 Agent-D + WF2-L2): 3 placement-constraint tuân đủ — reinject-ledger tách budget.json · reinject=promote-COPY giữ D11 · loop=D6-under-D9 (CG-1 escalate ≙ E.2).
## 2-workflow mandate (Harness-9 / adap-apply §31) — ĐẠT
- **WF1 IMPLEMENT** `wf_f085d7c4-d78` (4-agent ground-truth: reuse-anchor + C1-audit-design + B1/B2/B3-draft + cross-harness-conflict) → em-main integrate single-writer. **Lesson dogfood:** WF1 Agent-A (investigator-codebase) tự-compact MEMORY.md giữa workflow (persona vượt return-only-prompt) = **AS-10/E-006 recurrence** → em-main git-diff bắt + **revert** (D9 single-writer). Bonus: `archive/2026-06.md` KHÔNG tồn-tại → compaction sẽ **mất 8.5KB** nếu giữ → **dogfood chính C3 floor đang adopt cứu data thật**.
- **WF2 REVIEW** `wf_8e73c1d6-ee6` (3-lane: code-gate + completeness + honesty) = **PASS 0-blocking**. **Anti-fiddle proof (L1):** spec-audit bỏ qua stale-json (`budget.measured.test-specialist=27723B`) chỉ flag live frontend-designer (26129B) → chứng đo **LIVE** `Get-Item.Length` KHÔNG tin config-cũ (S81 stale-config trap không tái diễn). L2: 10/10 floor + cite-accurate + 27-flag-unchanged. L3: 5/5 caveat + 0 overclaim.
## Honest caveats (broadcast §5 — 5 caveat giữ trong doc §I)
1. **"Vòng chạy thông" = walkthrough THỦ-CÔNG** người-điều-phối nối (đo→phân-loại→ghi), KHÔNG lệnh-tự-động-đơn-nhất (khối-đo exit-0 riêng-lẻ). KHÔNG claim "fully-autonomous".
2. **Judge recall/apply = STUB** (mfe-eval `-Judge` scaffold) — số nhớ/dùng CHƯA nghĩa tới khi sample-q chín-tuổi + trọng-tài độc-lập khác-phiên. Tự-chấm-cùng-phiên = vô-nghĩa.
3. **HCV threshold = calibration-interim** (cò-báo-đuôi, KHÔNG vạch-chất-lượng chốt). **HCV proxy hiện N/A-idle** (chưa run-trace giữ sub-*.md).
4. **Tự-soi (meta-blind-spot):** vòng đo agent-công-nhân, CHƯA đo chính các khâu-meta (đo/tinh-chỉnh/kiểm tự-nó).
5. **Cô-đặc = compress-only;** verify-trước-khi-giữ CHƯA dựng.
## Evidence
- Artifact MỚI: `scripts/memory-selfimprove-audit.ps1` (19KB, NO-API, exit-0, runtime-verified) · `.claude/governance/reinject-ledger.md` (4KB, B2).
- Modified: `docs/governance/harness-11-engine.md` §I (10-floor codify + artifact-map row + fix stale cap-comment 220K→380K-pointer) · `.claude/commands/session-start.md` §2.1.7 · `.claude/commands/session-end.md` §L.b(c) · `scripts/governance-detectors.ps1` C3-comment HCV-no-seed.
- Runtime: spec-audit exit-0, CRITERIA `A1 A2 A3 B1 B2 C-spectrum:frontend-designer`, GAP `C-spectrum:frontend-designer:MED` (răng thật). governance-detectors vẫn 27-flag (no vocab-fork thứ 4).
- **0 production code.** State THẬT GIỮ NGUYÊN (Mig 59 · 88 bảng · 434 test · gotcha 76 · bundle admin `CDn40vpV`/user `CoPmPBg7`).
- ⚠️ restart CLI (command `.md` no hot-reload → §2.1.7 + §L.b(c) wire runtime).
## Brutal-honest / phản-biện (§M)
- **C3 store_memory-strip honest-correction:** broadcast + D9 nói "store_memory strip mọi sub". WF1 Agent-A phát-hiện: **strip = hook AI_INFRA runtime, KHÔNG có file .js trong repo SE** — SE enforce tại-chỗ = **tool-scope** (11 sub `tools:` chỉ READ verb, spec-audit A1 verify) + **hmw.js SCHEMA** return-delta-only (A2 verify). Đã sửa overclaim tiềm-ẩn ở §I + spec-audit self-disclosure (D9 wired-not-hook; `.claude/settings.json` KHÔNG có hook → AS-10 fails-open).
- **C4 field-set LỆCH:** hmw.js `{task·verdict·learned·surprise}` (runtime-return) ≠ session-end `{agent·task·nấc·evidence}` (harvest-record) — 2 schema 2 tầng khác nhau, KHÔNG assume đồng-nhất. provenance-2way-tag tường-minh = build-thêm nhỏ (defer, honest — chưa làm).
- **A1 HCV nấc thật:** deterministic proxy = file-exists (run-trace synthesis); said-vs-kept RATIO = calibration-interim + **hiện N/A-idle** (chưa mẫu-chấm). KHÔNG claim "đã đo said-vs-kept".
- **Double-run minor (WF2-L1 note):** session governance chạy governance-detectors 2× (§2.1.3 direct + §2.1.7 spec-audit child-invoke). Đã disclosed caveat-1; detector = fast NO-API grep; redundancy cố-ý (composition). 0 correctness impact.
- **KHÔNG phản-biện function-floor:** H17 fit SE (SE có đủ eval-branch §H MFE + archive-gate §A + D9 + value_protect làm nền → đóng-vòng tự-nhiên). Broadcast honest-tier khớp SE honest-tier (phần lớn convention, mechanized rõ đâu).

View File

@ -22,6 +22,7 @@
| PHẦN F — Harness-14 Eval/Budget/Outcome | doc này §F (3-mức maturity + method) + `eval/` golden-set harness (F.2) + `memory-budget.json`/`measure-agent-memory.ps1` (F.3 = PHẦN A) | eval = executed-file + convention (manual) · budget = mechanized ALIGNED · outcome-correlation/hit-rate = Mức-2 tool-pending-data |
| PHẦN G — Harness-15 memory-budget per-agent (token) **+v2 §G.4 +v3 §G.5** | doc này §G (SÀN floor + 3-tầng token + **§G.4 hot-feed-lớn / L2-L3-bỏ-trần / %-print / ranh-giới-vai-trò** + **§G.5 full-parity 220/60/50 + spawn-fill-to-budget**) + `memory-budget.json` (`harness_floor` + `token_governor` v3 + `spawn_fill_directive` + `archive_gate.value_protect`) + `session-start §2.1.5`+**§2.1.6** + **`session-end §L.b(c)`** | 2-governor mechanized (byte ⟂ token config) + sàn-chức-năng = convention; **v3 (1)=config · (2)(3)=convention** |
| PHẦN H — Harness-16 MFE (memory-fidelity-**EVAL**) | doc này §H (coverage/retention method + maturity-tier) + `scripts/mfe-eval.ps1` (deterministic NO-API) + `eval/mfe/` (seed + README) + `memory-budget.json` (`mfe` config) + **READS** `token_governor` (single-source, never writes) + `session-start §2.1.6`/`session-end §L.b(c)` opt-in | deterministic $0 = executed-file + runtime-smoke (S93) · judge = **SCAFFOLD-only** (Mức-2 chờ age+independent-judge) · READS-not-writes budget |
| PHẦN I — Harness-17 vòng tự-cải-thiện (Đo→Tinh-chỉnh→Kiểm) | doc này §I + `scripts/memory-selfimprove-audit.ps1` (C1 spec-audit NO-API) + `.claude/governance/reinject-ledger.md` (B2 CG-1) + COMPOSE `mfe-eval.ps1`(A2)/`memory-archive-gate.ps1`(archive)/`governance-detectors.ps1`(change-gov) + `session-start §2.1.7`/`session-end §L.b(c)` | C1 spec-audit + A2 MFE + HCV-proxy = mechanized · B1/B2/B3 refine + C2 spot-check = convention · C3/CG-2 = REUSE §D.3/§G.2(b) |
| Canonical state (nguồn-chuẩn) | `docs/STATUS.md` CURRENT STATE table | — |
---
@ -219,7 +220,7 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
**Vì sao:** `%-print` (§G) đo *đã-NHÉT bao nhiêu vào* Tầng-1 (ước theo độ-dài). MFE đo tiếp: agent có **giữ/dùng** cái đã nhét không — **đã-nạp ≠ nhớ-ra ≠ dùng-đúng**.
**H1 — Sàn deterministic ($0, NO-API, `mfe-eval.ps1`):**
- **LEAD Coverage-FIT** — must-remember denominator (status-field, KHÔNG grep): marks Active(-High) (`ACTIVE-MARKS.md`) + AS-class + Active-Guards (`error-ledger.md`) + recurring-gotchas (`gotchas.md`), **dedup** (gotcha/guard mà AS-row trỏ `#N`/`AS-N` → gộp vào AS; `merge_guard_to_as` toggle). FIT = byte-span → **token-RANGE** [bytes/4 .. bytes/3.0] vs cap **live-read** `token_governor.tier1_hotfeed_tokens.lead_tokens` (S93: 29 item ~2.53.3K tok / 220K = 1.5% → FIT thừa).
- **LEAD Coverage-FIT** — must-remember denominator (status-field, KHÔNG grep): marks Active(-High) (`ACTIVE-MARKS.md`) + AS-class + Active-Guards (`error-ledger.md`) + recurring-gotchas (`gotchas.md`), **dedup** (gotcha/guard mà AS-row trỏ `#N`/`AS-N` → gộp vào AS; `merge_guard_to_as` toggle). FIT = byte-span → **token-RANGE** [bytes/4 .. bytes/3.0] vs cap **live-read** `token_governor.tier1_hotfeed_tokens.lead_tokens` (S93: 29 item ~2.53.3K tok / cap-live 220K = 1.5% → FIT thừa; ⚠️ **cap S94→380K** `budget.json`, mfe **live-read** tự-đúng — 220K = snapshot S93, KHÔNG hardcode).
- **age-band** — FLAG `old-but-still-required`, **KHÔNG cắt theo tuổi** (mark `RC-…10-29-11`); drop chỉ khi status đổi.
- **Goodhart-anchor** — in `strikes_total` + `RCA_entries` (error-ledger) cạnh coverage; strikes tăng mà coverage cao = **điểm nói dối**. KHÔNG self-grade.
- **SUB per-role coverage** — denom = anti-pattern/NEVER trong `agents/<role>.md`; numer = còn-mang trong **diary `agent-memory/<role>/MEMORY.md`** (KHÔNG project/user MEMORY.md — bẫy trùng-tên H15-v3); match = exact-id OR ≥2 **content-word** sau stop-list (đánh bại bẫy leading-verb-9/9-giả). **ĐO-THẬT** (S93: impl-backend 94% · impl-frontend 85% · reviewer 88%; role prose-only → **N/A** KHÔNG "0%"). **SUB-WORKFLOW** (fan-out ephemeral) = N/A by-design (kênh ký-ức = memory-pack lead bơm).
@ -234,6 +235,49 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
---
## PHẦN I — Harness-17: Vòng tự-cải-thiện bộ-nhớ (Đo → Tinh-chỉnh → Kiểm) (🔴 FUNCTION-FLOOR + 🟡 method)
> **Adopt S95 (2026-07-01)** — AI_INFRA 2 broadcast `2026-06-30-Governance-{harness-17-memory-self-improvement, checklist-harness-17}` (hash verify MATCH ✓ cả 2 · `reviewer_gate: PASS`). Áp qua **2-workflow** (Harness-9 mandate): **WF1 `wf_f085d7c4-d78`** (4-agent ground-truth reuse-anchor + draft) + **WF2 review** (run-id → `adap-reports/2026-06-30-Governance-harness-17-memory-self-improvement.md`). Artifact mới: `scripts/memory-selfimprove-audit.ps1` + `.claude/governance/reinject-ledger.md`. **KHÔNG copy luật số ở đây — B1.**
>
> **Vì sao (đóng "vòng hở"):** nhánh eval (§H MFE) mới ĐO fidelity rồi in số **rồi DỪNG** — thấy mục-sàn rớt khỏi hot-mem nhưng KHÔNG có cơ-chế HÀNH-ĐỘNG. H17 nối 2 khâu thiếu: **Tinh-chỉnh** (tín-hiệu→hành-động, có chốt-dừng) + **Kiểm** (spec-compliance audit). Bộ-nhớ ⇒ **tài-sản được quản-trị**, kiểm-được theo bản đặc-tả.
>
> 🔴 **VOCAB (C3 — bắt buộc tách nghĩa, KHÔNG seed `$aliasSets`):** chữ **"coverage" nay 3 nghĩa** — (1) H2 harvest-curator "**Coverage**" = 0-silent-miss mọi sub/run đã-chạy · (2) §H MFE SUB "**coverage**" = role-floor còn-mang-trong-diary · (3) H17 A1 "**HCV**" (harvest-coverage, said-vs-kept) = cái sub NÓI-ra (return) vs cái GIỮ-lại (memory). Luôn gọi **HCV** cho nghĩa H17. Giống H16 memory-fidelity: **2-3-khái-niệm-1-từ = KHÔNG seed detector** (seed → false-flag), chỉ ghi alias-map + C3-comment (`governance-detectors.ps1`). "audit" (C-KIỂM) gọi **spec-audit** tránh đụng monthly-drift-audit. Từ mới `reinject`/`floor-rot`/`build-gap`/`signal→action` = grep 0-match toàn `docs/` (WF1 Agent-D) → SẠCH.
**A — ĐO (Eval) — 2 sàn:**
- **A1 HCV (harvest-coverage, said-vs-kept):** so cái sub NÓI trong return vs cái GIỮ trong memory bắt **mất-mát âm-thầm khi cô-đặc**. SE: harvest-curator H2 trục **Coverage** (0-silent-miss, convention) + §H MFE SUB per-role coverage (retained-side, mechanized) + **HCV proxy** mới trong `memory-selfimprove-audit.ps1` (run-trace `runs/<id>/` sub-*.md `*-synthesis.md` = file-exists deterministic). 🟡 **Honest:** tỉ-lệ said-vs-kept = **calibration-interim** (caveat 3, cò-báo-đuôi KHÔNG vạch-chất-lượng); per-item-L1-presence cho AS/guard/gotcha = **partial build-gap** (MFE age-band chỉ đo marks-có-date). **HCV proxy hiện N/A-idle** (run gần nhất = return-delta-only mode, 0 `sub-*.md` để chấm) A1-HCV = **cơ-chế-sẵn-sàng CHƯA-có-mẫu-đo** (script tự in N/A minh-bạch), KHÔNG phải đã-đang-đo (WF2-L3 honest-completeness).
- **A2 load-fidelity (fit + %thực-giữ per-tier):** = **§H MFE** (`mfe-eval.ps1` LEAD Coverage-FIT + SUB per-role). **REUSE-cite, KHÔNG rebuild.**
**B — TINH-CHỈNH (Refine) — 3 sàn:** (loop = tầng **D6 DÒ+NÊU-CỜ**; em-main = **D9 writer**; anh = quyết-số)
- **B1 bảng ánh-xạ tín-hiệu hành-động** (4 loại map thẳng cơ-chế SE hiện-có, KHÔNG dựng mới):
| Tín-hiệu | Ngưỡng phát-hiện | Hành-động | Cơ-chế-SE (neo) | Nấc |
|---|---|---|---|---|
| **floor-rot** (mục-sàn RỚT khỏi hot-mem) | MFE age-band FLAG `old-but-still-required` (`mfe-eval.ps1`) + status vẫn Active | **reinject VERBATIM** từ canonical em-main APPEND L1 + ghi reinject-ledger | MFE age-band + work-state block `session-start §2.1.5` + **reinject-ledger** (B2) | detect=**mechanized** · reinject=**convention** |
| **repeat ≥ 2** (lặp 2 phiên) | error-ledger 2-strike + MFE Goodhart `strikes_total` | **promote** pattern/anti-pattern (episodicprocedural) | `error-ledger §L.a` 2-strike-promote + harvest-curator INFORM + `value_protect` giữ-L1 | promote=**convention** · strike-count=**mechanized** |
| **old + valueless** ( hết-giá-trị) | archive-gate: over-cap ngoài keep-floor-5 KHÔNG khớp `value_protect` 2-strike | **cold-archive** MOVE byte-0-loss + con-trỏ `_INDEX` | **§A** `memory-archive-gate.ps1` (hysteresis 0.85) | planner=**mechanized** DRY-RUN · MOVE=**convention** (D5) |
| **raw** (chưa cô-đặc) | L1 entry verbose/>~1.5K char (gotcha #53 risk) | **distill** → nén + đẩy verbatim L2 + gist | `/sleep-recovery-memory-l2` **command** (gist-compress additive) + `_INDEX`/gist (S70) | distill=**convention** (command-assisted) · pointer-resolve=mechanized |
> 🔴 **Đính-chính:** `/sleep-recovery-memory-l2` = **COMMAND thật** (`.claude/commands/`, 12.6KB) — KHÔNG phải "chỉ convention pattern"/skill (WF1 Agent-C nhầm; em-main verify). Distill JUDGMENT vẫn convention.
- **B2 CG-1 termination (reinject-ledger):** [`.claude/governance/reinject-ledger.md`](../../.claude/governance/reinject-ledger.md) — **git-tracked · append-only · single-writer em-main (D9)**. 🔴 **TÁCH khỏi `memory-budget.json`** (file đó = quyền cấp-ngân-sách anh §G.4(4); trộn = AI lấn quyền). Rule: mỗi item reinject **≤1 lần / N=3 phiên**; đo-lại vẫn thiếu → **ESCALATE anh** (build-gap? tăng-budget? đổi-placement — mirror MFE H3 2-ca), **KHÔNG** tự-reinject-lần-2. Chống reinject-loop vô-hạn che build-gap.
- **B3 phép-thử-ranh-giới build-gap vs floor-rot** (chỉ floor-rot mới kích reinject):
> 🧪 **"Item ĐÃ TỪNG hiện-diện trong hot-mem/diary/canonical-ledger ở phiên trước KHÔNG?"** (grep `git log -p` các ledger + `agent-memory/<role>/MEMORY.md` + `archive/`) → **CÓ** = **floor-rot** (cơ-chế có, chỉ RỚT → reinject OK) · **KHÔNG** = **build-gap** (chưa dựng → đi DỰNG cơ-chế qua D7 nếu chạm luật, **KHÔNG reinject**). Chốt: floor-rot = **ĐÃ-tồn-tại ∩ CÒN-giá-trị ∩ RỚT-khỏi-L1**; thiếu 1 vế → KHÔNG reinject (ca rớt-mà-hết-cần = archive-gate đúng-đắn; ca chưa-dựng = build-gap).
**C — KIỂM (Audit / spec-audit) — 5 sàn:**
- **C1 spec-compliance checker deterministic LIVE:** `scripts/memory-selfimprove-audit.ps1` (NO-API, ASCII #30, exit-0, emit **CRITERIA+GAP set KHÔNG frozen-tally** — chạy LIVE mỗi lần vì đo artifact-SỐNG). 3 mặt: **(a) write-gov/D9** [A1 tool-scope sub KHÔNG store_memory · A2 hmw.js SCHEMA return-delta · A3 propose-only decl] · **(b) change-gov/D8** [COMPOSE `governance-detectors.ps1` child-invoke exit-0, KHÔNG re-grep = tránh fork C3] · **(c) distillation-spectrum** [mỗi over-cap agent có raw→`_INDEX`→gist]. 🔴 **Honest:** D9 enforce qua **tool-scope + SCHEMA (A1/A2 mechanized)**, KHÔNG OS-hook (`.claude/settings.json` KHÔNG có hook store_memory — AS-10/E-006 fails-open); A3 = **PROXY** (phrase-presence ≠ enforce). Chứng "guard WIRED", KHÔNG "runtime KHÔNG-THỂ vi-phạm". Runtime-verified S95: A1/A2/A3/B1/B2 PASS, C-spectrum bắt **frontend-designer over-cap GAP** (răng thật).
- **C2 3 spot-check người:** harvest-fidelity + đúng-verdict + provenance-integrity = **convention** (harvest-curator 5-trục Fidelity/Placement + reviewer verdict + `session-end §L.b(f)` gate). MÁY-không-tự-quyết → người soi.
- **C3 single-writer (loop propose-only):** = **D9** (`§D.3`). **REUSE-cite.** 🔴 **Honest:** "store_memory-strip mọi sub" = **hook AI_INFRA runtime, KHÔNG có .js trong repo SE** — SE enforce tại-chỗ = **tool-scope** (11 sub `tools:` chỉ READ verb, 0 store_memory) + **hmw.js SCHEMA** return-delta-only. (Sửa overclaim tiềm-ẩn.)
- **C4 provenance 2-chiều:** phân-biệt entry **chủ-tự-viết** (default) vs **thu-hoạch-từ-sub** (có spawn-record) = `hmw.js:53-63` memoryDelta 4-field + `session-end §L.b(d)`. 🟡 **partial** (nhãn ngầm, chưa tag tường-minh). ⚠️ **field-set LỆCH:** hmw.js `{task·verdict·learned·surprise}` (runtime-return) ≠ session-end `{agent·task·nấc·evidence}` (harvest-record) — 2 schema **2 tầng khác nhau** (return vs record), KHÔNG assume đồng-nhất; 2-chiều-tag tường-minh = build-thêm nhỏ (defer, honest).
- **CG-2 high-value MIỄN hạ-bậc-theo-tuổi:** = **§G.2(b) `value_protect`** + mark `RC-…10-29-11`. **REUSE-cite.** Tuổi KHÔNG phải cớ cắt (pain/volume/quality).
**Cadence wire (D.1):** `session-start §2.1.7` = **loop-DÒ** (chạy spec-audit + MFE báo CRITERIA+GAP + reinject-ledger CG-1 check, INFORM-only) · `session-end §L.b(c)` = **loop-REFINE-propose** (B1 signal→action → em-main APPEND single-writer). **KHÔNG lệnh tự-động đơn-nhất** (caveat 1: walkthrough thủ-công người-điều-phối; khối-đo exit-0 riêng-lẻ).
**Placement-constraint (WF1 Agent-D, 0 hard-conflict):** ① reinject-ledger TÁCH khỏi budget.json · ② reinject = **promote-COPY** L2→L1, nguồn archive INTACT (D11 no-conflict) · ③ loop = D6-tier dưới D9 (CG-1 escalate ≙ E.2 report-before-stamp).
**Honest nấc tổng §I (10 sàn 🔴 ĐẠT):** mechanized = **C1 spec-audit (a/b/c)** + A2 MFE + strike-anchor + HCV-proxy file-exists. **Phần lớn B/C = CONVENTION** (đúng checklist H17 tự nói: chỉ 2 sàn-đo A + spec-checker + gắn-nhãn-nguồn = cơ-chế-hoá; còn lại kỷ-luật người+AI). **5 caveat H17 (giữ trong doc):** (1) "vòng chạy thông" = walkthrough THỦ-CÔNG người-điều-phối nối, KHÔNG lệnh-tự-động-đơn-nhất · (2) judge recall/apply = **STUB** (số CHƯA nghĩa tới khi sample-q chín-tuổi + trọng-tài độc-lập khác-phiên) · (3) ngưỡng HCV = calibration-interim · (4) tự-soi: vòng đo agent-công-nhân CHƯA đo chính khâu-meta (điểm-mù) · (5) cô-đặc mới có NÉN, verify-trước-khi-giữ CHƯA dựng.
---
## CAVEAT (trung-thực — đọc trước khi tự nhận "đã tự-bảo-trì")
- **No-OS-hook:** detector + gate chạy TRONG thân session-start/end body do em-main kích — KHÔNG fully-autonomous. Đúng mức: **DÒ tự-động + toàn-diện; SỬA + GÁC dựa người-chủ-trì.**
- **Auto-WRITE luật/copy = MỐI-NGUY #1, CỐ Ý CHƯA LÀM** — defer tới ≥2 sự-cố thật mà thủ-công thất-bại (hiện 0). Chọn nhánh chỉ-DÒ-NÊU-CỜ cho mọi thứ chạm luật/copy (1-sửa-sai → N-chỗ-sai + phá hash broadcast đóng-băng).

View File

@ -358,6 +358,13 @@ $aliasSets = @(
# vs Harness-16 "memory-fidelity-EVAL / MFE" (coverage/retention). The alias-map is
# RECORDED in docs/governance/harness-11-engine.md PHAN H. Seeding it would FALSE-flag
# two legitimately-different terms as a fork-to-merge -- do not add it.
# NOTE (Harness-17, S95): "coverage" is likewise INTENTIONALLY NOT seeded. It is THREE
# distinct concepts sharing a word, not a fork: (1) H2 harvest-curator "Coverage"
# (0-silent-miss of spawned subs/runs) ; (2) H16 MFE SUB "coverage" (role-floor still
# carried in the diary) ; (3) H17 A1 "HCV / harvest-coverage" (per-run said-vs-kept).
# The alias-map is RECORDED in harness-11-engine.md PHAN I. Seeding would FALSE-flag three
# legitimately-different terms as a fork-to-merge -- do not add it. Same for "audit"
# (monthly-drift-audit vs H17 spec-audit) -- disambiguated by name in-doc, not seeded.
for ($s = 0; $s -lt $aliasSets.Count; $s++) {
$variants = $aliasSets[$s]

View File

@ -0,0 +1,346 @@
<#
.SYNOPSIS
memory-selfimprove-audit.ps1 - Harness-17 PART-C spec-compliance checker (KIEM / Audit arm).
.DESCRIPTION
NO-API, DETECT-and-FLAG-only spec-compliance net for the Harness-17 memory
self-improvement loop (Do -> Tinh-chinh -> Kiem). Same house rules as
governance-detectors.ps1:
(1) NO-API - only Get-Content / Get-Item / child-invoke. NEVER calls model/API.
(2) FLAG-only - prints [SPEC] criteria/gaps, NEVER edits files (single-writer = em-main D9).
(3) PowerShell 5.1 compatible. ASCII-only script body (gotcha #30). Target files
read -Encoding UTF8. Exit code ALWAYS 0 (advisory net, not a build gate).
(4) LIVE every run - emits a CRITERIA-SET + GAP-SET, NOT a frozen pass-tally. The
gap-set IS the actionable output (H17 tip: a frozen pass number drifts between
sessions because the audit measures a LIVE artifact state).
(5) SINGLE-SOURCE live-read - caps come from memory-budget.json at runtime
(NEVER hardcode: the S94 owner-override raised lead 220K->380K; a hardcoded
copy would silently rot. Also budget.measured is STALE - re-measure on disk).
Three C-faces (H17 mandate: write-governance + change-governance + distillation):
(a) WRITE-GOVERNANCE - single-writer D9 wired via TOOL-SCOPE + SCHEMA (A1/A2 mechanized)
+ propose-only declaration (A3 proxy).
(b) CHANGE-GOVERNANCE - COMPOSE governance-detectors.ps1 (D8 one-way + C2/B3 derived);
do NOT re-implement (that would fork C3).
(c) DISTILLATION - every LIVE over-cap agent has raw MEMORY.md -> _INDEX.md -> gist.
Plus an eval-arm proxy (HCV = harvest-coverage-value, run-trace completeness) and an
always-emit CAVEAT / self-blind-spot disclosure (mandated honest surface).
HONEST header: D9 single-writer is enforced by TOOL-SCOPE + SCHEMA (A1/A2) - NOT by an
OS settings hook (.claude/settings.json has none; the store_memory allowlist-strip is
AS-10/E-006 fails-open). A3 propose-only is a PROXY (phrase-presence != enforcement).
This checker proves the guards are WIRED, not that runtime CANNOT violate.
.PARAMETER RepoRoot
Repo root. Default = resolved 2 levels up from this script (scripts/ -> repo root).
.EXAMPLE
powershell.exe -ExecutionPolicy Bypass -File scripts/memory-selfimprove-audit.ps1
#>
param(
[string]$RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
)
$ErrorActionPreference = 'Continue'
# ---------------------------------------------------------------------------
# Emit helpers (mirror governance-detectors.ps1 grammar so output composes)
# ---------------------------------------------------------------------------
$script:Criteria = New-Object System.Collections.Generic.List[string]
$script:Gaps = New-Object System.Collections.Generic.List[string]
function Write-Section($title) {
Write-Host ''
Write-Host ("===== $title =====") -ForegroundColor Cyan
}
# [SPEC] face | CRITERION | PASS | desc (records criterion, green)
function Write-Pass {
param([string]$Face, [string]$Criterion, [string]$Desc)
Write-Host ("[SPEC] {0,-16} | {1,-14} | PASS | {2}" -f $Face, $Criterion, $Desc) -ForegroundColor Green
$script:Criteria.Add($Criterion) | Out-Null
}
# [SPEC] face | CRITERION | GAP:SEV | desc | resolve: <un-gap> (records criterion + gap)
function Write-Gap {
param(
[string]$Face, [string]$Criterion,
[ValidateSet('HIGH', 'MED', 'LOW')] [string]$Severity,
[string]$Desc, [string]$Resolve
)
$color = switch ($Severity) { 'HIGH' { 'Red' } 'MED' { 'Yellow' } default { 'Gray' } }
Write-Host ("[SPEC] {0,-16} | {1,-14} | GAP:{2,-4} | {3} | resolve: {4}" -f $Face, $Criterion, $Severity, $Desc, $Resolve) -ForegroundColor $color
$script:Criteria.Add($Criterion) | Out-Null
$script:Gaps.Add(("{0}:{1}" -f $Criterion, $Severity)) | Out-Null
}
# [SPEC] face | CRITERION | N/A | reason (records nothing - honest not-applicable)
function Write-Na {
param([string]$Face, [string]$Criterion, [string]$Reason)
Write-Host ("[SPEC] {0,-16} | {1,-14} | N/A | {2}" -f $Face, $Criterion, $Reason) -ForegroundColor DarkGray
}
function Rel($full) {
$r = $full
if ($full.StartsWith($RepoRoot, [StringComparison]::OrdinalIgnoreCase)) {
$r = $full.Substring($RepoRoot.Length).TrimStart('\', '/')
}
return ($r -replace '\\', '/')
}
function Read-Text($path) {
if (-not (Test-Path $path)) { return $null }
return (Get-Content -Path $path -Raw -Encoding UTF8)
}
# ---------------------------------------------------------------------------
# SINGLE-SOURCE live-read: caps from memory-budget.json (NEVER hardcode)
# ---------------------------------------------------------------------------
Write-Section 'H17 spec-audit - single-source config live-read'
$budgetPath = Join-Path $RepoRoot '.claude\agent-memory\memory-budget.json'
$autoCap = $null
$softCap = $null
if (Test-Path $budgetPath) {
try {
$budget = Get-Content -Path $budgetPath -Raw -Encoding UTF8 | ConvertFrom-Json
$autoCap = [int]$budget.tiers.l1_hot.autoinject_cap_bytes
$softCap = [int]$budget.tiers.l1_hot.soft_cap_bytes
Write-Host (" live-read caps: autoinject_cap={0}B soft_cap={1}B (memory-budget.json)" -f $autoCap, $softCap)
Write-Host ' [OK] caps read LIVE from single source (NOT hardcoded; budget.measured is stale - ignored)' -ForegroundColor Green
}
catch {
Write-Host (" [!] could not parse memory-budget.json: {0}" -f $_.Exception.Message) -ForegroundColor Red
}
}
else {
Write-Host (" [!] memory-budget.json not found at {0}" -f (Rel $budgetPath)) -ForegroundColor Red
}
if ($null -eq $autoCap) { $autoCap = 25600; Write-Host ' [note] falling back to autoinject_cap=25600 (config unreadable)' -ForegroundColor DarkGray }
if ($null -eq $softCap) { $softCap = 30720 }
$agentsDir = Join-Path $RepoRoot '.claude\agents'
$agentMemDir = Join-Path $RepoRoot '.claude\agent-memory'
$hmwPath = Join-Path $RepoRoot '.claude\workflows\hmw.js'
# ---------------------------------------------------------------------------
# FACE (a) - WRITE-GOVERNANCE / single-writer D9
# ---------------------------------------------------------------------------
Write-Section 'FACE (a) WRITE-GOVERNANCE (single-writer D9)'
# Collect agent .md (exclude README). Split by tool-capability: read-only vs write.
$agentFiles = @()
if (Test-Path $agentsDir) {
$agentFiles = Get-ChildItem -Path $agentsDir -Filter *.md -File -ErrorAction SilentlyContinue |
Where-Object { $_.BaseName -ne 'README' }
}
# --- A1: sub-agent tool-scope excludes memory-WRITE verbs (parse the `tools:` line ONLY) ---
# NOTE: scan the frontmatter `tools:` line, NOT the whole file. Several agent BODIES say
# "KHONG store_memory" (that is their A3 propose-only declaration); grepping the body would
# false-positive. The D9 tool-scope guard is about what the tools[] array EXPOSES.
$writeVerbRx = 'store_memory|delete_memory|update_memory|promote_to_shared'
$a1Offenders = @()
$readOnlyRoles = @() # roles whose tools[] lack Write AND Edit -> must carry A3 declaration
foreach ($af in $agentFiles) {
$lines = Get-Content -Path $af.FullName -Encoding UTF8
$toolsLine = ($lines | Where-Object { $_ -match '^tools:' } | Select-Object -First 1)
if ($null -eq $toolsLine) { continue }
if ($toolsLine -match $writeVerbRx) {
$a1Offenders += $af.BaseName
}
$hasWrite = ($toolsLine -match '\bWrite\b') -or ($toolsLine -match '\bEdit\b')
if (-not $hasWrite) { $readOnlyRoles += $af.BaseName }
}
if ($a1Offenders.Count -eq 0) {
Write-Pass 'a:tool-scope' 'A1' ("{0} sub-agent tools[] carry only READ RAG verbs (no store_memory/delete/update)" -f $agentFiles.Count)
}
else {
Write-Gap 'a:tool-scope' 'A1' 'HIGH' `
("agent(s) expose a memory-WRITE verb: {0}" -f ($a1Offenders -join ', ')) `
'remove store_memory/delete_memory/update_memory from that agent .md tools[] (single-writer = em-main D9)'
}
# --- A2: hmw.js return-delta-only SCHEMA intact ---
$hmw = Read-Text $hmwPath
if ($null -eq $hmw) {
Write-Gap 'a:schema' 'A2' 'HIGH' 'hmw.js not found' 'restore .claude/workflows/hmw.js (D9 mechanized return-delta-only channel)'
}
else {
$hasRequired = ($hmw -match "required:\s*\[\s*'findings'\s*,\s*'memoryDelta'\s*\]")
$hasNoStore = ($hmw -match 'store_memory/RAG') # writeGuard forbidding line
if ($hasRequired -and $hasNoStore) {
Write-Pass 'a:schema' 'A2' "hmw.js SCHEMA required=[findings,memoryDelta] + writeGuard forbids store_memory/RAG"
}
else {
$miss = @()
if (-not $hasRequired) { $miss += "required=[findings,memoryDelta]" }
if (-not $hasNoStore) { $miss += "writeGuard 'KHONG store_memory/RAG'" }
Write-Gap 'a:schema' 'A2' 'HIGH' `
("hmw.js missing return-delta guard literal(s): {0}" -f ($miss -join '; ')) `
'restore the return-delta-only SCHEMA + writeGuard in hmw.js (D9 mechanized channel)'
}
}
# --- A3: read-only-role agents carry a propose-only / single-writer declaration (PROXY) ---
$declRx = 'propose-only|single-writer|read-only|READ only|KHONG store_memory|store_memory'
$a3Missing = @()
foreach ($role in $readOnlyRoles) {
$body = Read-Text (Join-Path $agentsDir ("{0}.md" -f $role))
if ($null -eq $body) { continue }
if ($body -notmatch $declRx) { $a3Missing += $role }
}
if ($readOnlyRoles.Count -eq 0) {
Write-Na 'a:propose-only' 'A3' 'no read-only-role agents detected'
}
elseif ($a3Missing.Count -eq 0) {
Write-Pass 'a:propose-only' 'A3' ("{0} read-only-role agents carry a propose-only/single-writer declaration (PROXY: phrase-presence)" -f $readOnlyRoles.Count)
}
else {
Write-Gap 'a:propose-only' 'A3' 'MED' `
("read-only-role agent(s) missing propose-only declaration: {0}" -f ($a3Missing -join ', ')) `
'add "propose-only / single-writer" to that agent .md (PROXY guard)'
}
# ---------------------------------------------------------------------------
# FACE (b) - CHANGE-GOVERNANCE / derived-pointer one-way D8 (COMPOSE, do NOT duplicate)
# ---------------------------------------------------------------------------
Write-Section 'FACE (b) CHANGE-GOVERNANCE (composed - D8 one-way + C2/B3)'
# --- B1: reference-and-run governance-detectors.ps1 (delegate, do not re-grep counts) ---
$detPath = Join-Path $RepoRoot 'scripts\governance-detectors.ps1'
if (-not (Test-Path $detPath)) {
Write-Gap 'b:detectors' 'B1' 'HIGH' 'governance-detectors.ps1 missing (owner of D8/C2/B3)' 'restore scripts/governance-detectors.ps1'
}
else {
$detOut = & powershell.exe -NoProfile -ExecutionPolicy Bypass -File $detPath 2>&1
$detExit = $LASTEXITCODE
$flagCount = @($detOut | Select-String -Pattern '\[DETECTOR\]').Count
if ($detExit -eq 0) {
Write-Pass 'b:detectors' 'B1' ("governance-detectors.ps1 present + ran (exit 0; {0} advisory FLAG surfaced - detector owns the verdict)" -f $flagCount)
}
else {
Write-Gap 'b:detectors' 'B1' 'MED' `
("governance-detectors.ps1 exited {0} (expected 0)" -f $detExit) `
'investigate detector run failure (it is the D8/C2 owner)'
}
}
# --- B2: change-process anchor exists (rule-change routes through a documented process) ---
$rulesText = Read-Text (Join-Path $RepoRoot 'docs\rules.md')
$engineText = Read-Text (Join-Path $RepoRoot 'docs\governance\harness-11-engine.md')
$anchorHit = $false
if ($rulesText -and ($rulesText -match 'report-before-stamp|report-tr\w*-\w*ng-d\w*u|6\.6')) { $anchorHit = $true }
if ($engineText -and ($engineText -match 'D8|one-way|OWNER-APPROVE|canonical')) { $anchorHit = $true }
if ($anchorHit) {
Write-Pass 'b:change-proc' 'B2' 'change-governance route documented (D7 owner-approve / D8 one-way / report-before-stamp)'
}
else {
Write-Gap 'b:change-proc' 'B2' 'LOW' 'no documented rule-change process anchor found' `
'document D7 owner-approve + D8 one-way in rules.md or harness-11-engine.md'
}
# ---------------------------------------------------------------------------
# FACE (c) - DISTILLATION-SPECTRUM / raw MEMORY.md -> _INDEX.md -> gist per over-cap agent
# ---------------------------------------------------------------------------
Write-Section 'FACE (c) DISTILLATION-SPECTRUM (live byte-measure per agent)'
$overCapAny = $false
if (Test-Path $agentMemDir) {
$memDirs = Get-ChildItem -Path $agentMemDir -Directory -ErrorAction SilentlyContinue
foreach ($md in $memDirs) {
$memFile = Join-Path $md.FullName 'MEMORY.md'
if (-not (Test-Path $memFile)) { continue }
$len = (Get-Item $memFile).Length
if ($len -le $autoCap) { continue } # under cap -> no spectrum required (trivial PASS)
$overCapAny = $true
$hasIndex = Test-Path (Join-Path $md.FullName 'archive\_INDEX.md')
$gistCount = @(Get-ChildItem -Path (Join-Path $md.FullName 'archive') -Filter '*.gist.md' -File -ErrorAction SilentlyContinue).Count
$crit = ("C-spectrum:{0}" -f $md.Name)
if ($hasIndex -and $gistCount -gt 0) {
Write-Pass 'c:distill' $crit ("{0} over cap ({1}B>{2}B) but has _INDEX + {3} gist(s)" -f $md.Name, $len, $autoCap, $gistCount)
}
else {
$sev = if ($len -gt $softCap) { 'HIGH' } else { 'MED' }
$miss = @()
if (-not $hasIndex) { $miss += '_INDEX.md' }
if ($gistCount -eq 0) { $miss += 'gist' }
Write-Gap 'c:distill' $crit $sev `
("{0} MEMORY.md={1}B over cap {2}B but missing {3}" -f $md.Name, $len, $autoCap, ($miss -join ' + ')) `
'build distillation-spectrum (_INDEX + gist) or curate L1->L2 (/sleep-recovery-memory-l2)'
}
}
}
if (-not $overCapAny) {
Write-Na 'c:distill' 'C-spectrum' 'no over-cap agent this run (all MEMORY.md under autoinject_cap - no spectrum required)'
}
# ---------------------------------------------------------------------------
# EVAL-ARM proxy - HCV (harvest-coverage-value): run-trace harvest completeness
# NOTE: named HCV to avoid the "coverage" 3-way vocab collision (H2 harvest-curator
# "Coverage" = 0-silent-miss-of-spawns ; H16 MFE SUB "coverage" = role-floor retention ;
# H17 A1 HCV = per-run sub-said vs harvested). Deterministic proxy = file-exists over the
# most recent run-trace; the said-vs-kept RATIO is calibration-interim (H17 caveat 3).
# ---------------------------------------------------------------------------
Write-Section 'EVAL-ARM HCV proxy (run-trace harvest completeness)'
$runsDir = Join-Path $RepoRoot '.claude\workflows\runs'
if (-not (Test-Path $runsDir)) {
Write-Na 'eval:hcv' 'HCV' 'no runs/ dir (no hmw run-trace this repo yet) - said-vs-kept proxy N/A'
}
else {
$runDirs = Get-ChildItem -Path $runsDir -Directory -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending
if ($runDirs.Count -eq 0) {
Write-Na 'eval:hcv' 'HCV' 'runs/ empty - no run-trace to score'
}
else {
$latest = $runDirs[0]
$subMd = @(Get-ChildItem -Path $latest.FullName -Filter 'sub-*.md' -File -ErrorAction SilentlyContinue)
$synth = @(Get-ChildItem -Path $latest.FullName -Filter '*-synthesis.md' -File -ErrorAction SilentlyContinue)
if ($subMd.Count -eq 0) {
Write-Na 'eval:hcv' 'HCV' ("latest run {0} has no sub-*.md (return-delta-only mode) - proxy N/A" -f $latest.Name)
}
elseif ($synth.Count -gt 0) {
Write-Pass 'eval:hcv' 'HCV' ("latest run {0}: {1} sub-md + {2} synthesis present (harvest-complete proxy; ratio = calibration-interim)" -f $latest.Name, $subMd.Count, $synth.Count)
}
else {
Write-Gap 'eval:hcv' 'HCV' 'MED' `
("latest run {0}: {1} sub-md but 0 synthesis - possible silent harvest-loss" -f $latest.Name, $subMd.Count) `
'harvest the run-trace (write *-synthesis.md) before closing (H2 harvest-curator gate)'
}
}
}
# ---------------------------------------------------------------------------
# CAVEATS / SELF-BLIND-SPOT (always-emit disclosure - NOT a check; H17 mandate)
# ---------------------------------------------------------------------------
Write-Section 'CAVEATS / self-blind-spot (honest surface - always emitted)'
$caveats = @(
'C1. Loop "runs" = MANUAL walkthrough chained by em-main (detect -> classify -> record). This script + governance-detectors run exit-0 SEPARATELY; there is NO single auto-run that closes the whole loop each session.',
'C2. Recall/apply JUDGE layer = STUB (mfe-eval -Judge scaffold). Numbers meaningless until sample-questions mature AND an independent cross-session judge scores. Not measured here.',
'C3. HCV harvest-coverage threshold = calibration-interim (single-peak distribution -> tail-flag, NOT a chosen quality bar).',
'C4. Meta-blind-spot: this checker audits the WORKER artifacts (agents/memory/hmw). It does NOT audit the eval/refine/audit meta-arms themselves (the measurer is not yet self-measured).',
'C5. Distillation = compress-only so far. The verify-BEFORE-keep step (validate content before a distill deletes the raw) is NOT built.'
)
foreach ($c in $caveats) { Write-Host (" - {0}" -f $c) -ForegroundColor DarkGray }
Write-Host ' - SCOPE: this checker covers C-face (a)(b)(c) DETERMINISTICALLY + HCV proxy. It does NOT verify B1 signal->action MAP application, B2 CG-1 termination decisions, or A2 load-fidelity NUMBERS (those are separate arms: mfe-eval.ps1 + the reinject-ledger + em-main judgement).' -ForegroundColor DarkGray
Write-Host ' - BUILD-GAP honest: B1/B2 refine mechanics are convention (em-main hand); the reinject-ledger is a git-tracked append-only record, NOT an auto-writer. Do not read "checker silent" as "fully compliant".' -ForegroundColor DarkGray
Write-Host ' - D9 ENFORCEMENT honest: single-writer is wired by TOOL-SCOPE (A1) + SCHEMA (A2) - NOT by an OS hook (.claude/settings.json has none; store_memory allowlist-strip is AS-10/E-006 fails-open). A3 is a PROXY. This proves guards are WIRED, not that runtime CANNOT violate.' -ForegroundColor DarkGray
# ---------------------------------------------------------------------------
# Summary - CRITERIA-SET + GAP-SET (LIVE, no frozen pass-tally)
# ---------------------------------------------------------------------------
Write-Section 'Summary (criteria-set + gap-set - re-computed LIVE each run)'
Write-Host ("CRITERIA (this run, LIVE): {0}" -f ($script:Criteria -join ' '))
if ($script:Gaps.Count -eq 0) {
Write-Host 'GAPS (this run): none' -ForegroundColor Green
}
else {
Write-Host ("GAPS (this run): {0}" -f ($script:Gaps -join ' ')) -ForegroundColor Yellow
}
Write-Host ''
Write-Host 'NOTE: H17 PART-C spec-audit. CRITERIA+GAP set is the output (NOT a frozen score - it drifts as artifacts self-heal). Exit 0 always (advisory). Cite the GAP-set, not a tally.' -ForegroundColor DarkGray
exit 0