[CLAUDE] Infra: W5 - engine roster B1 + FIX bug $userMemDir hardcode (fault-inject nay CO LAP duoc)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m31s

W5a -- harness-11-engine.md: 4 hit roster -> 0 occurrence (do bang grep -o|wc -l, KHONG grep -c).
  :269 "12 sub tools:" -> "sub read-only tools:"
  :322 "MOI vai roster 12" -> "MOI vai trong roster hien-hanh" + tro canonical
  :332 GAP-1 "nhan ca 12 vai" -> "nhan TOAN roster" + lich-su 9->12->14 + tro canonical
  :345 x2 -- BAY MEGA-LINE: sua phan "(i) Vai owner-gan" roi VAN con "VALID_ROLES = 12"
       o doan SAU cua CHINH DONG DO. Sua 1 cho tuong xong = dung bay grep -c da ghi WAL 2 lan.
  + danh-sach vai khai ro la BAN SAO; nguon that = hmw.js VALID_ROLES :22-36; lech => tin hmw.js.

W5b -- scripts/governance-detectors.ps1:363 bug $userMemDir:
  TRUOC: $userMemDir = 'C:\Users\pqhuy\.claude\projects\D--Dropbox-...\memory'
  ...nam NGAY DUOI comment ghi "Derive from this machine's project slug".
  => Comment mo-ta Y DINH; code hardcode ca path tuyet-doi LAN username. Loi noi doi
     nam ngay canh dong no noi doi ve.

  2 HAI CU-THE (khong phai style):
  1) -RepoRoot <cay-tam> VAN doc user-memory THAT => fault-inject KHONG co lap duoc
     => teeth-test C1-wikilink bat-kha-thi => cong-cu dung de CHUNG-MINH-CO-RANG
        lai khong co rang cua chinh no.
  2) hardcode 'pqhuy' => may/acc khac se im lang roi xuong else-branch, va mot su
     degrade IM LANG doc y het "sach".

  SAU: $projectSlug = $RepoRoot -replace '[:\/_]', '-'
       $userMemDir  = Join-Path $env:USERPROFILE ".claude\projects\$projectSlug\memory"

  VERIFY 2 CHIEU (do that, khong suy):
  - slug derive tu RepoRoot that == literal hardcode cu, KHOP 100%; Test-Path = True
    => hanh-vi KHONG doi (TOTAL van 45, user-memory van duoc quet)
  - -RepoRoot cay-tam => slug khac => "[note] user-memory path not reachable (...fake-repo\memory)"
    => CO LAP; ro path THAT = 0 hit.

SWEEP CUOI toan repo: 8 hit / 6 file, 0 cai thuoc nhom "doc dan-xuat khai so roster SAI
nhu su-that hien-hanh" => acceptance MOI FIX#6 DAT; nhom "chua toi luot" nay RONG sau W5.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-07-15 15:12:14 +07:00
parent a09dcae999
commit c39ba9d28e
2 changed files with 24 additions and 7 deletions

View File

@ -266,7 +266,7 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
**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** (12 sub `tools:` chỉ READ verb, 0 store_memory) + **hmw.js SCHEMA** return-delta-only. (Sửa overclaim tiềm-ẩn.)
- **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** (sub read-only `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).
@ -319,7 +319,7 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
> **Adopt S101 (2026-07-03), anh-directed** (`/check-email AI_INFRA` + `/adap-apply` → "Formal adopt + RC-stamp" + "full 2-workflow"). AI_INFRA broadcast `2026-07-03-Agent-harness-19-fable-clone` (content_sha256 re-compute **MATCH ✓** `6909299a…`; +3 broadcast model-tier cùng đợt [`fable-opus` `ee00d253` · `checklist` `a7ff304b` · `v2-pin-simple` `eed277f7`] đều MATCH + đều có `reviewer_gate: PASS` → format-regression H18 [thiếu field] đã fix). Áp qua 2-workflow Harness-9: **WF1 investigate `wf_5f308fd8-744`** (3 lane wiring+mapping+adversarial, SOUND_WITH_CONCERNS — bắt 3 floor-fidelity gap; resume-after-interruption cached) + **WF2 review `wf_ed5b972f-a4d`** (→ **PASS_WITH_CONCERNS** 0-BLOCKING: Lane-A mechanism PWC [1 CONCERN marker write-only no-reader → **FIXED S101** thêm session-start BƯỚC 0.5b reader] · Lane-B gov-record PASS [RC-mark 3-floor verbatim + vacuous-honest, 7 refutation fail] · Lane-C adap-honesty PASS [4 hash MATCH indep + 12/12 + no-overclaim]. ⚠️ **GAP-3 AS-10 fired LIVE** — lanes tự-ghi reviewer-memory dù RETURN-only-intent; harness-sanctioned "intentional" → KEPT + verified → dogfood-validate §K.C "GAP-3 = convention-KHÔNG-mechanism"). **Additive** — KHÔNG thay H8 all-inherit / bracket / promote; chỉ THÊM ensemble + toggle cho 2 vị-trí phán-quyết.
**K.A — Ánh-xạ 2 vị-trí phán-quyết vào roster SE (🔴 §7 sàn — WF1-confirmed best-fit, no superior alt):**
- **(a) Cổng rà-soát cuối** = `reviewer` (adversarial 6-category + Smart-Friend anti-rubber-stamp + live-curl falsify + phân-xử mâu-thuẫn). **(b) Ground-truth/xác-minh sự-thật** = `investigator-codebase` (truy bằng-chứng gốc file:line + sqlcmd + git, chống bịa + RCA). `investigator-api` EXCLUDED (external-only) · `database-agent` EXCLUDED (DB-only subset). = cặp dogfood S101 (WF2 3-lane reviewer · WF1 3-lane investigator-codebase). **(H21 S110):** cặp này = **REFERENCE-EXAMPLE/likely-pick** (dogfood S101/S108), **KHÔNG còn auto-default** — vai do anh gán đích-danh trong lệnh (§K.E), MỌI vai roster 12 hợp-lệ.
- **(a) Cổng rà-soát cuối** = `reviewer` (adversarial 6-category + Smart-Friend anti-rubber-stamp + live-curl falsify + phân-xử mâu-thuẫn). **(b) Ground-truth/xác-minh sự-thật** = `investigator-codebase` (truy bằng-chứng gốc file:line + sqlcmd + git, chống bịa + RCA). `investigator-api` EXCLUDED (external-only) · `database-agent` EXCLUDED (DB-only subset). = cặp dogfood S101 (WF2 3-lane reviewer · WF1 3-lane investigator-codebase). **(H21 S110):** cặp này = **REFERENCE-EXAMPLE/likely-pick** (dogfood S101/S108), **KHÔNG còn auto-default** — vai do anh gán đích-danh trong lệnh (§K.E), **MỌI vai trong roster hiện-hành** hợp-lệ (số canonical → [`docs/STATUS.md`](../STATUS.md) §Sub-agents).
**K.B — Cơ-chế 2 mode thật/ảo (🔴 §4 sàn) + toggle marker (🟡 form):**
- 🧊 (retired H21 S110) **Fable-real (thật, marker `.claude/fable-real-mode.on` CÓ):** 2 vị-trí chạy **1 lần top-model trực-tiếp** (sâu nhất). Fable up=single-Fable · down (H5)=single-Opus-1M per-run fallback (KHÔNG đổi mode toàn-cục).
@ -329,7 +329,7 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
**Thay bằng §K.E per-invocation.** Marker file đã xóa S110; `.gitignore:92` giữ pattern phòng-hờ.
**K.C — 3 floor-fidelity gap (🔴 WF1-L3 bắt — pin để stamp CÓ NGHĨA, không paperwork):**
- **GAP-1 scope-creep guard:** `hmw.js` VALID_ROLES nhận cả 12 vai (9 lúc adopt S101; +office-document S107; +2 monitor S110 anh-directed), KHÔNG gate → all-inherit **CHE** leak (mọi vai top-tier nên mixed-roster "trông ổn"; Fable về + phân-tầng thì rò top-tier ensemble sang vai ngoài 2 vị-trí = vi phạm §3 hard-scope). → **lệnh-B ensemble-run = N lane CÙNG 1 vai phán-quyết** (multi-lens), KHÔNG mixed-roster fan-out.
- **GAP-1 scope-creep guard:** `hmw.js` VALID_ROLES nhận **TOÀN roster** (lịch-sử: 9 lúc adopt S101 → +`office-document` S107 +2 monitor H1/H2 S110 anh-directed**+2 monitor H24 S121 W2**; số vai canonical → [`docs/STATUS.md`](../STATUS.md) §Sub-agents, B1 KHÔNG chép số), KHÔNG gate → all-inherit **CHE** leak (mọi vai top-tier nên mixed-roster "trông ổn"; Fable về + phân-tầng thì rò top-tier ensemble sang vai ngoài 2 vị-trí = vi phạm §3 hard-scope). → **lệnh-B ensemble-run = N lane CÙNG 1 vai phán-quyết** (multi-lens), KHÔNG mixed-roster fan-out.
- **GAP-2 engine-label (§5):** `hmw.js` SCHEMA `memoryDelta{task,verdict,learned,surprise}` KHÔNG field engine → em-main **stamp nhãn engine @P3 harvest** (single-writer B3), như S101 "model-note Opus-S101". = convention KHÔNG mechanism.
- **GAP-3 AS-10 fragment:** mỗi run-trace ghi `*-synthesis.md` residual + lane giữ Bash (AS-10 fails-open) → "1 vai = 1 trí-nhớ" qua N lane giữ CHỈ bởi em-main single-writer. → **N lane RETURN-only**, em-main ghi 1 MEMORY entry/vai (+ nhãn engine).
@ -342,7 +342,7 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
| `/fable-real <vai> <đề-bài>` | **lệnh-A** single top-model | 1 vai anh gán chạy 1 lần top-model THẬT (deep pass; Fable up → single-Fable · outage → single-Opus-1M/run) |
| `/fable-clone <vai> <đề-bài>` | **lệnh-B** ensemble tier-2 | N lane đa-lăng-kính CÙNG 1 vai (`hmw.js parallel`) + em-main refute+synthesize |
- **(i) Vai owner-gán per-invocation:** `<vai>` ∈ roster 12 (`investigator-codebase` · `investigator-api` · `implementer-backend` · `implementer-frontend` · `frontend-designer` · `database-agent` · `office-document` · `test-specialist` · `reviewer` · `cicd-monitor` · `tooling-auditor` · `harvest-curator`). Thiếu/sai vai → **em-main hỏi anh 1 dòng**, KHÔNG tự đoán. Hiệu-lực CHỈ lượt đó (không marker, không sticky-mode). ✅ **VALID_ROLES = 12 đủ roster (S110 anh-directed):** 2 monitor đã bổ sung (10→12) — lệnh-B trọn roster. *(🧊 limitation cũ "2 monitor ∉ 10-vai → fail-soft default-subagent" + H6-design "monitor ngoài workflow" superseded điểm này; monitor vẫn INFORM-only, lane RETURN-only.)*
- **(i) Vai owner-gán per-invocation:** `<vai>`**roster** (`investigator-codebase` · `investigator-api` · `implementer-backend` · `implementer-frontend` · `frontend-designer` · `database-agent` · `office-document` · `test-specialist` · `reviewer` · `cicd-monitor` · `tooling-auditor` · `harvest-curator` · **`lead-view-auditor` · `lead-omission-auditor`** ← +S121 W2, H24). 🔴 Danh-sách này là **BẢN SAO** — nguồn thật = `hmw.js` VALID_ROLES `:22-36`; lệch ⇒ **tin `hmw.js`**. Số vai canonical → [`docs/STATUS.md`](../STATUS.md) §Sub-agents (B1). Thiếu/sai vai → **em-main hỏi anh 1 dòng**, KHÔNG tự đoán. Hiệu-lực CHỈ lượt đó (không marker, không sticky-mode). ✅ **VALID_ROLES = ĐỦ roster:** 2 monitor H1/H2 bổ sung S110 anh-directed (10→12) → **+2 monitor H24 S121 W2 (12→14)** — lệnh-B trọn roster. 🔴 Số canonical → [`docs/STATUS.md`](../STATUS.md) §Sub-agents, **KHÔNG chép số ở đây**. *(🧊 limitation cũ "2 monitor ∉ 10-vai → fail-soft default-subagent" + H6-design "monitor ngoài workflow" superseded điểm này; monitor vẫn INFORM-only, lane RETURN-only.)*
- **(ii) Spec-file pipeline (mỗi run engine-đắt PHẢI sinh):** `.claude/workflows/runs/<run-id>/spec-<tên-tính-năng>-<dd-mm-yyyy>.md` — 3-heading CỐ-ĐỊNH: **[1] Tính-năng/đề-bài** (13 câu) · **[2] Cách implement** (bước + quyết-định + ràng-buộc + đường-chết) · **[3] Checklist** (vai + deliverable + acceptance đo được). Luồng: engine **propose-only** → lead **verify****LEAD ghi** (single-writer) → worker **Opus MAX** thực-thi THEO spec bơm qua `args` (`hmw.js` KHÔNG đọc file spec).
- **(iii) 4 ghi-chú trung-thực (🔴 phải hiện-diện — nấc owner-gated, KHÔNG code-enforced §X8):**
- **(a)** owner-gated tầng LỆNH + kỷ-luật lead cho việc CHỌN/ELEVATE vai, **KHÔNG code-enforced** — đường code `tier:'fable'` vẫn tồn-tại, hmw.js KHÔNG ép vai-nào-được-elevate. *(REC-3 2026-07-13: hmw.js GIỜ code-enforce vai-INVALID — typo ∉ VALID_ROLES → STOP-HARD throw; đó là guard typo, KHÁC gate vai-elevation vẫn là discipline.)* Bảo-đảm elevation = MỌI đường truy về lượt owner-gõ (kỷ-luật), không phải guard chặn.

View File

@ -358,9 +358,26 @@ else {
# ---------------------------------------------------------------------------
Write-Section 'C1 - dangling wikilink'
# user-memory dir (outside repo). Derive from this machine's project slug; if not
# reachable, fall back to in-repo agent-memory only + emit a note.
$userMemDir = 'C:\Users\pqhuy\.claude\projects\D--Dropbox-CONG-VIEC-SOLUTION-SOLUTION-ERP\memory'
# user-memory dir (outside repo). DERIVED from $RepoRoot, not hardcoded.
#
# FIXED S122 W5 -- the old line was:
# $userMemDir = 'C:\Users\pqhuy\.claude\projects\D--Dropbox-...-SOLUTION-ERP\memory'
# ...directly under a comment that claimed "Derive from this machine's project slug".
# The comment described the INTENT; the code hardcoded an absolute path AND a username.
# Two concrete harms, not style:
# 1) -RepoRoot <temp-tree> still read the REAL user-memory => fault-injection could not
# isolate. The C1-wikilink teeth-test (prove the detector FLAGS on injected breakage)
# was therefore unrunnable -- the one tool built to prove teeth had no teeth itself.
# 2) Hardcoded 'pqhuy' => the script silently degrades to the else-branch on any other
# machine/account, and a silent degrade reads exactly like "clean".
#
# The Claude Code project slug IS $RepoRoot with [:\/_] collapsed to '-'. Verified S122:
# D:\Dropbox\CONG_VIEC\SOLUTION\SOLUTION_ERP -> D--Dropbox-CONG-VIEC-SOLUTION-SOLUTION-ERP
# (exact match against the previously hardcoded literal; Test-Path = True)
# and a temp RepoRoot yields a different slug whose path does NOT exist => the else-branch
# fires => fault-injection isolates. That is the whole point of deriving it.
$projectSlug = $RepoRoot -replace '[:\\/_]', '-'
$userMemDir = Join-Path $env:USERPROFILE ".claude\projects\$projectSlug\memory"
$agentMemDir = Join-Path $RepoRoot '.claude\agent-memory'
$memScopes = @()