[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

@ -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** (`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 · **`harness-eval` · `harness-refine` · `harness-audit`** ← +S141, bộ-ba đồng-kiểm memory). 🔴 Danh-sách này là **BẢN SAO** — nguồn thật = `hmw.js` VALID_ROLES (khối hằng-số `VALID_ROLES`, tra bằng tên **KHÔNG bằng số dòng** — [n6] line-range cũ `:22-36` đã lệch khi enum dài thêm); 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) → **+3 trio-memory S141 (14→17)** — 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.)*
- **(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 · **`harness-eval` · `harness-refine` · `harness-audit`** ← +S141, bộ-ba đồng-kiểm memory · **`tooling-harvest-audit` · `h24-audit` · `sleep-audit`** ← +S145, round-KIỂM ×3 [tooling-harvest · soi-lead · nén-ngủ]). 🔴 Danh-sách này là **BẢN SAO** — nguồn thật = `hmw.js` VALID_ROLES (khối hằng-số `VALID_ROLES`, tra bằng tên **KHÔNG bằng số dòng** — [n6] line-range cũ `:22-36` đã lệch khi enum dài thêm); 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) → **+3 trio-memory S141 (14→17)****+3 round-KIỂM `tooling-harvest-audit`/`h24-audit`/`sleep-audit` S145 (17→20)** — 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.
@ -403,13 +403,23 @@ SE đã có RAG golden-set harness (KHÔNG phải gap): `eval/golden-set-solutio
> Adopt S111 (2026-07-12) từ broadcast `2026-07-11-Governance-harness-22-wal-session-continuity` (body-sha `3de0758a` verified; ≙ AI_INFRA CANONICAL §I4 + §H1). Giải: phiên chết giữa mạch việc (limit/crash/tắt-máy/đổi-acc/chết-giữa-workflow) → mất trí-nhớ chưa-ghi + đốt-lại token. **"WAL" ở đây = sổ-liên-tục-phiên** — KHÁC "WAL RUN-LEDGER hai-nhịp" đã retired H18-B (trùng chữ, khác cơ-chế; alias-map awareness).
- **N.1 Sổ WAL (🔴):** `.claude/WAL.md` **≤40 dòng, ghi-đè toàn-file KHÔNG append**; `chain:` mục `[x]/[!]/[ ]` **KÈM bằng-chứng lệnh** (không mô-tả suông) + `next:` đúng 1 mệnh-lệnh + `verify:` ≥1 lệnh CHẠY ĐƯỢC, chạy TRƯỚC next — **ground-truth thắng WAL** (lệch → sửa WAL cho khớp thực-tế rồi mới đi). **CẤM secret** (file được commit). Template rỗng → `session-end §6.4`.
- **N.2 Hai tầng ghi (🔴):** tầng NỘI-DUNG = **lead single-writer** (D9-consistent), ghi lại sau MỖI subtask đổi trạng-thái (kể cả lúc phóng + thu workflow-run). Tầng PERSIST = **Stop-hook `.claude/hooks/wal-flush.ps1`** deterministic (PS1 — chọn path-independent vì PATH-order bash 2-context Windows ngược nhau, lead-verified S111): hook **ĐƯỢC làm đúng 2 việc** = `git add` per-path 3 path cố định {`.claude/WAL.md` · `.claude/agent-memory/` · `.claude/workflows/runs/`} + commit CAND-only message `wal: flush <ts>`; hook **KHÔNG-ĐƯỢC** = sinh/sửa nội-dung · push · block-stop · đụng path ngoài list · exit≠0 (fail-open MỌI nhánh). Per-path add + CAND chống bẫy all-or-nothing đa-pathspec (bài học test-proven nguồn).
- **N.3 Trạng-thái hook = ✅ VERIFIED-RUNTIME S111 CÙNG PHIÊN (nâng từ STAGED-until-verified — chống ghost-wire S100 bằng bằng-chứng THẬT):** hooks-entry `.claude/settings.json` ghi S111 → Stop-hook **HOT-RELOAD + FIRE ngay giữa phiên** (KHÔNG cần restart): commit **`12071c5 "wal: flush 20260712T1105"`** chứa ĐÚNG 4 file thuộc 3 path cố định (WAL.md + diary invest + run.md + spec), CAND-commit chuẩn (settings.json/broadcasts/docs đứng NGOÀI — persist-only đúng thiết kế), 0 push. Giả-định honest-(c) nguồn "hook chỉ nạp lúc khởi-động phiên" → trên harness NÀY = hot-reload; ⚠️ **ENV-DEPENDENT** (data-point #2 sau skill-registry hot-reload S107/S111 — hub từng NGƯỢC kết quả, KHÔNG fleet-generalize; phiên MỚI vẫn re-check 1 lần trong pilot-checklist, không fire → thử schema phẳng). *(Nấc trước khi có bằng-chứng = STAGED-until-verified: CẤM claim "đang chạy" khi chưa thấy wal:-commit do hook sinh — nguyên tắc GIỮ cho mọi hook tương-lai.)*
- **N.2 Hai tầng ghi (🔴):** tầng NỘI-DUNG = **lead single-writer** (D9-consistent), ghi lại sau MỖI subtask đổi trạng-thái (kể cả lúc phóng + thu workflow-run). Tầng PERSIST = **Stop-hook `.claude/hooks/wal-flush.ps1`** deterministic (PS1 — chọn path-independent vì PATH-order bash 2-context Windows ngược nhau, lead-verified S111): hook **ĐƯỢC làm đúng 2 việc** = `git add` per-path **4 path cố định** {`.claude/WAL.md` · `.claude/agent-memory/` · `.claude/workflows/runs/` · `.claude/sessions/`} + commit CAND-only message `wal: flush <ts>`; hook **KHÔNG-ĐƯỢC** = sinh/sửa nội-dung · push · block-stop · đụng path ngoài list · exit≠0 (fail-open MỌI nhánh). Per-path add + CAND chống bẫy all-or-nothing đa-pathspec (bài học test-proven nguồn). 🔄 **Cardinality 3→4 @S146** (thêm `.claude/sessions/` cho session-model per-pause context-map): con-số này là **LUẬT GỐC mà hook thi-hành** ⇒ mọi đổi cardinality phải **grep MỌI consumer cùng-commit** (hook `wal-flush.ps1` · Sàn-3 `/tiep §0` "điểm mù" · `.session-counter.json _why_this_path` "outside all …" · auto-memory H22) — sửa write-site mà sót read-site = vỡ chính floor recovery (lớp S87/S88). Bản-ghi LỊCH-SỬ (adap-report có ngày · diary vai · `WAL.md`) **KHÔNG rewrite** — chúng mô-tả trạng-thái lúc đó.
- **N.3 Trạng-thái hook = ✅ VERIFIED-RUNTIME S111 CÙNG PHIÊN (nâng từ STAGED-until-verified — chống ghost-wire S100 bằng bằng-chứng THẬT):** hooks-entry `.claude/settings.json` ghi S111 → Stop-hook **HOT-RELOAD + FIRE ngay giữa phiên** (KHÔNG cần restart): commit **`12071c5 "wal: flush 20260712T1105"`** chứa ĐÚNG 4 file thuộc tập path cố định **lúc S111** (WAL.md + diary invest + run.md + spec — khi đó `.claude/sessions/` chưa tồn-tại; tập hiện-hành = N.2 bản 4-path @S146), CAND-commit chuẩn (settings.json/broadcasts/docs đứng NGOÀI — persist-only đúng thiết kế), 0 push. Giả-định honest-(c) nguồn "hook chỉ nạp lúc khởi-động phiên" → trên harness NÀY = hot-reload; ⚠️ **ENV-DEPENDENT** (data-point #2 sau skill-registry hot-reload S107/S111 — hub từng NGƯỢC kết quả, KHÔNG fleet-generalize; phiên MỚI vẫn re-check 1 lần trong pilot-checklist, không fire → thử schema phẳng). *(Nấc trước khi có bằng-chứng = STAGED-until-verified: CẤM claim "đang chạy" khi chưa thấy wal:-commit do hook sinh — nguyên tắc GIỮ cho mọi hook tương-lai.)*
- **N.4 Một đường recovery (🔴):** `/pause` (chốt điểm dừng: flush-dirty → WAL-đúng-schema → commit đích-danh `wal: pause` TRƯỚC tuyên-bố an-toàn → DỪNG HẲN) + `/tiep` (đọc WAL → chạy TOÀN BỘ verify + `git status` + disk run-folder → lệch = tin ground-truth → thực-thi next; nhánh `wf:` = relaunch-cắt-gọt). **MỌI con-trỏ recovery trỏ về MỘT chỗ = `/tiep`** (kể cả anh gõ "làm tiếp" text thường); CẤM nạp lại transcript cũ. Delta session-cmd: `session-start BƯỚC 0.7` WAL-check (ngoại-lệ CHỜ duy-nhất, chỉ con-trỏ) · `session-end §5.0` squash `wal:`-trailing CHƯA-push (`origin/main..HEAD`, KHÔNG BAO GIỜ rewrite đã-push; squash-điểm = review-diff wal-paths, AS-10 backstop dời về đây không mất) · `§6.4` reset WAL = bước cuối.
- **N.5 WAL-cho-workflow (🔴 sàn owner-nguồn):** run **≥3 task HOẶC ước >5 phút = BẮT BUỘC RUN-TRACE mode** (`args.run` — per-agent-file `sub-<role>-<i>.md`; chết giữa run còn vật-liệu trên đĩa); run.md +`## taskList snapshot` ghi TRƯỚC launch (spec đã on-disk per H21 — sàn {task-list · spec} đủ); dòng `wf:<mục-đích> run= runId= args= done=k/N harvested=` vào WAL NGAY SAU launch; **harvest-LIỀN** mỗi task xong (C4 per-turn ĐÃ CÓ — honest granularity: per-TURN ≠ per-TASK, `parallel()` trả cả batch cuối turn + Stop-hook cũng fire ở turn-boundary → chết GIỮA turn = returns mất, per-agent-file trên DISK là lớp cứu → `/tiep` đọc CẢ disk); `/tiep` nhánh wf: = **relaunch-ĐÃ-CẮT-GỌT** (grep run-id log-phiên = bằng-chứng đích-danh · harvest-hồi-tố partial-honest · relaunch CHỈ task còn lại · memory-pack **RE-DERIVE TƯƠI, CẤM snapshot**); resume-by-run-id = bonus **SAME-SESSION-ONLY** (CẤM claim cross-session). Trung-thực mất-mát tối-đa: agent song-song đang-chạy tại thời-điểm chết mất phần dở; run nhỏ ngoài diện WAL-hóa có thể mất cả run — rủi-ro chấp-nhận công-khai.
- **N.6 Commit-convention exception:** commit `wal:` (hook-flush + `/pause` + WAL-reset) = **ngoại-lệ DUY-NHẤT** của format `[CLAUDE] <scope>` — máy sinh, KHÔNG Co-Authored-By, bị squash vào commit-chốt trước push (`rules.md §5.2` mirror).
- **N.7 Honest (a)-(e) áp SE:** (a) **pilot CHƯA chạy đủ tại SE** — dựng + codify + **hook-FIRE-verified S111** (`12071c5`/`67be443`; script-RUN tay BỎ — bằng-chứng mạnh hơn thay thế + reviewer fault-inject 2-ca bịt nhánh 0-delta); kill-test / đổi-acc / squash-thật / pause-roundtrip-workflow = phiên mới + anh (HANDOFF pilot-checklist) · (b) SE **0 mark cấm-hook** (5 Active-High không đụng); engine CAVEAT "No-OS-hook" = MÔ-TẢ hiện-trạng đã honest-update ngoại-lệ đích-danh; E.3 chỉ cấm hook-làm-GATE — persist-only 0-content tương-thích; thứ-tự codify-trước-enable tôn trọng CÙNG-COMMIT S111 · (c) schema hooks nested = default, verify ở PHIÊN MỚI, không fire → thử flat · (d) resume-run-id cross-session CHƯA kiểm-chứng — đường chính = relaunch-cắt-gọt · (e) **repo SE TRONG Dropbox — 2 chiều:** risk `index.lock` khi cloud-sync đụng git (thấp-nhưng-có; hook fail-open tự-lành lượt sau) + bonus Dropbox sync cả `.git` → commit local CHƯA-push vẫn sống qua tắt-máy/đổi-máy → `/pause` không cần push vẫn durable.
- **N.8 Probe-tại-điểm-dừng — predicate 4-vế (🔴 FLOOR + 🟡 form) — LUẬT-HOME của C7 (hub-answer, adopt S146):** điểm dừng (`/pause` · `/tiep` · `session-start` · `session-end`) **KHÔNG chạy việc khác**, NHƯNG được phép gọi **probe** nếu script thoả **ĐỦ 4 vế** (thiếu 1 vế = KHÔNG phải probe, cấm gọi tại điểm dừng):
- **(i) read-only** — chỉ ĐỌC (parse JSON/config · đo byte bằng `Get-Item` · liệt dir). 0 mutation, 0 network, 0 API-call.
- **(ii) KHÔNG spawn con** — không Agent/Workflow/sub-vai, không `Start-Process`/job-nền/`Invoke-Expression`. Điểm dừng KHÔNG được đẻ việc mới (đó chính là cái C7 cấm).
- **(iii) KHÔNG write** — không sinh/sửa/xoá file, không `git add|commit|push`, không đụng counter/memory/luật. Chạy 2 lần liên-tiếp phải cho cùng trạng-thái đĩa.
- **(iv) lỗi → in `probe-loi (khong chan)` → ĐI TIẾP — 🔴 [LOAD-BEARING]:** MỌI nhánh `exit 0`; probe hỏng KHÔNG chặn, KHÔNG treo, KHÔNG làm `/pause` mất quyền tuyên-bố "an-toàn để thoát". Đây là vế biến probe từ *thêm-một-điểm-hỏng* thành *thêm-một-hiển-thị*.
- **FLOOR (🔴 bất-biến — port-nguyên khi tailor, 3 tính-chất):** **read-only** · **non-blocking** (fail-open + no-hang + `exit 0` mọi nhánh) · **gỡ-được-không-hậu-quả** (xoá lời-gọi probe khỏi thân command ⇒ mất HIỂN-THỊ, KHÔNG mất state, KHÔNG đổi nhánh quyết-định nào — đây là **phép thử phân-biệt probe ⟂ gate**; nếu gỡ đi mà hành-vi đổi thì nó là gate, thuộc §E.3, không thuộc N.8).
- **FORM (🟡 tailor được):** wording token in ra (`probe-loi (khong chan)` — ASCII-only theo gotcha #30) · số vế / chuỗi định-dạng dòng-nợ · vị-trí gọi trong thân command · **interpreter = em-main đọc dòng in** (KHÔNG phải OS-gate; exit-code không cưỡng-chế gì — nhất-quán CAVEAT No-OS-hook).
- **Reword tập-cấm (🔴 KHÔNG phải cấm-tất):** luật "điểm dừng không chạy thứ khác" đọc đúng = **cấm ĐẮT / cấm side-effect** (spawn vai · audit-rerun · đo lại instrument · ghi memory/luật · push) — **CHO PHÉP probe read-only non-blocking theo N.8**. Command chỉ **TRỎ** `engine §N.8`, **CẤM chép predicate sang 2 nơi** (B1 derived-trỏ-canonical; predicate đổi 1 chỗ, consumer không drift).
- **Trạng-thái đo S146 (fault-inject 2-chiều, `timeout 60` bọc để quan-sát no-hang):** `scripts/nhip-no-probe.ps1` = ✅ **thoả cả 4 vế** (lành → 1 dòng `NHIP-NO: …` đầy-đủ, exit 0 · `-RepoRoot` bậy → `probe-loi (khong chan)`, exit 0, không treo; catch tổng `:203-208`). `scripts/distill-shard-probe.ps1` = thoả (i)(ii)(iii) + no-hang, **(iv) mới NỬA**: nhánh có-xử (thiếu `memory-budget.json` `:23` · thiếu key `distill_trigger` `:27`) in token + `exit 0`, nhưng **không có try/catch tổng** với `$ErrorActionPreference='Stop'` `:17` ⇒ exception (vd `-RepoRoot` bậy tại `Resolve-Path` `:18`, hoặc JSON hỏng tại `ConvertFrom-Json` `:25`) thoát ra stderr + **exit 1**, KHÔNG in token ⇒ **FLOOR đủ (read-only · non-blocking-thực-tế · gỡ-được) / FORM thiếu**. Vá = bọc try/catch tổng → `probe-loi (khong chan)` + `exit 0` (thuộc chủ-file script, KHÔNG tự sửa trong lượt này).
**Honest nấc §N:** mechanized-THẬT = hook-script deterministic (persist) + template + acceptance grep; convention = lead ghi nội-dung WAL sau mỗi subtask (kỷ-luật, không công-cụ-ép) + squash/reset trong thân session-end do em-main kích. Dogfood S111 = tầng nội-dung (WAL-chain thật trong phiên adopt) + script-RUN tay; hook-FIRE + full-pilot = nấc kế.
---