[CLAUDE] Docs: S111 adopt H22 WAL session-continuity — sổ WAL ≤40 + Stop-hook wal-flush.ps1 persist-only VERIFIED-RUNTIME ×2 (12071c5/67be443 hot-reload ENV-DEPENDENT) + /pause·/tiep 1-đường + BƯỚC 0.7/§5.0/§6.4 + FLIP run-trace ≥3-task + engine PHẦN N + detector C5 + mark RC-…12-07-2026-11-43-45 + D10 paths-ignore anh-directed + email 9cdcda2f3c83 (invest/reviewer Fable per-invocation 0-garble · WF wf_5ba3daf6-fe0 3-Opus RUN-TRACE · reviewer PASS_WITH_FIXES 8/8-fix · squash §5.0 dogfood-THẬT K=2)
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m11s

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-07-12 11:45:14 +07:00
parent 318a271930
commit 8aa3869637
30 changed files with 767 additions and 5 deletions

View File

@ -23,12 +23,13 @@ Phân biệt RAW (prefix `sub-`) vs VERIFIED (suffix `-synthesis.md`) bằng **T
| | DEFAULT return-delta-only (§J4) | RUN-TRACE mode (§J6) |
|---|---|---|
| Khi dùng | fan-out NH (~2-3 phút, read/analyze — vd recon) | workflow DÀI / sinh nhiều detail / cần audit-trail |
| Khi dùng | fan-out NH (<3 task **VÀ** ước 5 phút; read/analyze vd recon) | workflow DÀI / sinh nhiều detail / cần audit-trail |
| Bắt buộc? (sàn H22 S111) | mode-A hợp lệ cho fan-out NHỎ | **BẮT BUỘC khi run ≥3 task HOẶC ước chạy >5 phút** (`args.run` per-agent-file `sub-<role>-<i>.md`) |
| Sub ghi file? | KHÔNG chỉ return `memoryDelta` + `findings` | write-sub GHI full-detail vào `runs/<run-id>/sub-<role>-<i>.md` (phẳng); read-only sub `findings` + `subMdPath` em main scribe |
| Lead làm | VERIFY + APPEND @P3 (B3) | đọc `sub-<role>-<i>.md` on-demand + ghi `<stage>-synthesis.md` per-turn (C4) + H2 gom @session-end (B5, backstop) |
| Rủi ro mất detail | (delta lossy) chấp nhận cho việc nhẹ | KHÔNG (full-detail giữ trong run-folder tracked) |
> Mặc định DEFAULT. RUN-TRACE chỉ bật khi workflow dài/nhiều detail/cần dấu-vết (set `args.run = {name, dir}`). KHÔNG bắt mọi fan-out tạo run-folder.
> **Sàn H22 (S111) — FLIP policy:** mode-A return-delta-only VẪN hợp lệ cho fan-out NHỎ, NHƯNG **run ≥3 task HOẶC ước chạy >5 phút = BẮT BUỘC RUN-TRACE mode** (`args.run` → per-agent-file `sub-<role>-<i>.md` trong run-folder). Lý-do: chết giữa run vẫn còn vật-liệu trên đĩa để `/tiep` nối lại — **per-TURN ≠ per-TASK: returns mất khi chết giữa turn, nhưng file trên disk còn**. Fan-out NHỎ dưới ngưỡng → DEFAULT return-delta-only vẫn OK (KHÔNG bắt MỌI fan-out tạo run-folder).
## Quy trình RUN-TRACE (B1B6)
1. **B3 SCAFFOLD TRƯỚC (em main @P1):** tạo `runs/<run-id>/` + `run.md` (FLAT KHÔNG cần `sub-md/`/`harvest/` subfolder hay `.gitkeep`; file `sub-*`/`*-synthesis.md` sinh phẳng cùng cấp khi fan-out chạy). *(🧊 bước "ghi OPEN-beat vào `runs/_ledger.md`" retired H18-B S100 — orphan-authority = folder-scan.)* `hmw.js` chạy JS-sandbox **no-filesystem** KHÔNG tự tạo folder; **em main Write @P1** TRƯỚC khi invoke Workflow. (Đây fragile-point quên scaffold = run mất dấu-vết âm-thầm; xem `runs/README.md` §C7.)

View File

@ -6,7 +6,7 @@
export const meta = {
name: 'hmw',
description: 'HMW P2 execute (SOLUTION_ERP) — fan-out 9-agent roster có MEMORY-PACK slice (qua args vì script không đọc file) + return findings + checklistEvidence + memoryDelta (spawn-record 4-field). 2 MODE (Harness 2, 06-07): (A) DEFAULT return-delta-only — fan-out nhẹ, sub KHÔNG ghi file, git-diff verify. (B) RUN-TRACE mode (args.run, Harness-10) — workflow DÀI, em main scaffold .claude/workflows/runs/<run-id>/ TRACKED FLAT (run.md + sub-<role>-<i>.md + <stage>-synthesis.md phẳng cùng cấp) @P1, sub ghi full-detail vào CHỈ sub-<role>-<i>.md mình (B4/B6), harvest per-turn primary (C4) + H2 gom @session-end = backstop verify-idempotent. taskList thoải mái (queue theo slot, không cap cứng). memoryDelta KHÔNG tự ghi — em main VERIFY + APPEND-only @P3 (no-overwrite-unverified, B3). Model H8 all-inherit (Harness-8 2026-06-16): role-có-frontmatter inherit top-tier lead · role-less inherit · per-task tier:\'fable\'|\'opus\' escape-hatch. Scope = repo SOLUTION_ERP ONLY (S1 — KHÔNG fan-out repo/corpus khác).',
description: 'HMW P2 execute (SOLUTION_ERP) — fan-out 9-agent roster có MEMORY-PACK slice (qua args vì script không đọc file) + return findings + checklistEvidence + memoryDelta (spawn-record 4-field). 2 MODE (Harness 2, 06-07): (A) DEFAULT return-delta-only — fan-out NHỎ (<3 task VÀ ≤5 phút), sub KHÔNG ghi file, git-diff verify. (B) RUN-TRACE mode (args.run, Harness-10) — 🔴 BẮT BUỘC khi run ≥3 task HOẶC ước >5 phút (sàn H22 S111; script no-fs KHÔNG tự ép — enforcement = em-main scaffold @P1 + set args.run) — workflow DÀI, em main scaffold .claude/workflows/runs/<run-id>/ TRACKED FLAT (run.md + sub-<role>-<i>.md + <stage>-synthesis.md phẳng cùng cấp) @P1, sub ghi full-detail vào CHỈ sub-<role>-<i>.md mình (B4/B6), harvest per-turn primary (C4) + H2 gom @session-end = backstop verify-idempotent. taskList thoải mái (queue theo slot, không cap cứng). memoryDelta KHÔNG tự ghi — em main VERIFY + APPEND-only @P3 (no-overwrite-unverified, B3). Model H8 all-inherit (Harness-8 2026-06-16): role-có-frontmatter inherit top-tier lead · role-less inherit · per-task tier:\'fable\'|\'opus\' escape-hatch. Scope = repo SOLUTION_ERP ONLY (S1 — KHÔNG fan-out repo/corpus khác).',
phases: [{ title: 'Execute', detail: 'fan-out memory-pack-injected agents, structured return' }],
}
@ -16,7 +16,7 @@ export const meta = {
// spec: '<acceptance-criteria / context chung>',
// checkpointApproved: true, // em main set SAU khi BÁO {số agent·vai·task} @inform (S2)
// taskList: [ { role:<VALID_ROLES|null>, label:'..', prompt:'..', tier:'fable'|'opus'? }, ... ] // tier = per-task model override (H4.5)
// run: { name:'<run-id>', dir:'.claude/workflows/runs/<run-id>' } // OPTIONAL — bật RUN-TRACE mode (B, Harness-10 TRACKED). Folder + run.md em main ĐÃ scaffold @P1 (script no-fs). [legacy alias: args.wave]
// run: { name:'<run-id>', dir:'.claude/workflows/runs/<run-id>' } // 🔴 BẮT BUỘC khi run ≥3 task HOẶC ước >5 phút (sàn H22 S111 — chết giữa run còn vật-liệu đĩa cho /tiep; dưới ngưỡng = tùy chọn) — bật RUN-TRACE mode (B, Harness-10 TRACKED). Folder + run.md em main ĐÃ scaffold @P1 (script no-fs). [legacy alias: args.wave]
// }
const VALID_ROLES = [

View File

@ -0,0 +1,19 @@
# implement-synthesis — 2026-07-12-h22-wal-adopt (S111, WF `wf_5ba3daf6-fe0`)
> Lead verified per-turn (C4). 3/3 worker Opus DONE · 0 error · 0 empty · ~322K tok · 7.8'. Git-diff P3: **residual 0** — mọi file M/?? accounted (3 lane + em-main + broadcasts pull). Raw: `sub-task-0/1/2.md` cùng cấp.
## Verdict per-lane (lead re-verify độc lập trên disk)
- **W1 `w1-pause-tiep` — PASS 10/10 acceptance.** `pause.md` 47L + `tiep.md` 42L, port trung thực §4+§6 (fidelity-map từng bước → dòng-nguồn trong sub-task-0.md); né X4 (không kéo squash vào /pause) + X5 (không nhắc hook trong commit thủ-công). ⚡ Hệ đăng-ký skill `/pause`+`/tiep` NGAY giữa phiên (system-reminder) — data-point hot-reload #1b; hiệu-lực đầy-đủ verify phiên mới.
- **W2 `w2-session-cmds` — PASS pure-insert 3 điểm.** session-start +9 (BƯỚC 0.7 @47-54, sau 0.6 trước Phase-1, "CHỜ anh chọn" = ngoại-lệ duy-nhất, con-trỏ tiep.md B1) · session-end +10 (§5.0 @111 squash `origin/main..HEAD` + biên push-chết + review-diff wal-paths AS-10; §6.4 @143 reset-WAL trước footer). Deletion-check `^-[^-]` = 0 (insert-only, 0.5/0.5b/0.6 untouched).
- **W3 `w3-hook-readme` — PASS (lead verify disk — return bị notification-truncate, vô hại).** `wal-flush.ps1` 20L đúng skeleton ASCII (per-path add + CAND + try/catch + exit 0; 0 push/content/block) · workflows/README flip-policy đúng sàn (+bảng row "Bắt buộc?"; mode-A nhỏ vẫn hợp lệ) · runs/README +11 section taskList-snapshot (điều-kiện áp + wf: 5-trường + X6 memory-pack-re-derive).
## ⚡ Finding vượt kỳ vọng (lead, sau WF)
**Hook-FIRE VERIFIED-RUNTIME CÙNG PHIÊN**`12071c5 "wal: flush 20260712T1105"` fire ở Stop cuối turn lead (TRƯỚC cả khi WF xong), chứa đúng 4 file 3-path, CAND chuẩn, không push. Broadcast honest-(c) giả định "hook chỉ nạp lúc khởi-động phiên" → trên harness NÀY = hot-reload (ENV-DEPENDENT, không fleet-generalize — triage-S5 lesson). Hệ quả: row #6 "chạy tay 2 ca" THỪA (bằng chứng mạnh hơn đã có); ca-2 (0-delta exit-0 im lặng) quan sát tự nhiên các turn sau.
## memoryDelta harvest (3 worker role-less → nhà = synthesis này, run-trace pattern; C4 per-turn)
- **W1:** task=D3 port 2 command /pause /tiep · verdict=PASS 10/10, isolation sạch · learned=port command từ broadcast: map TỪNG bước→dòng-nguồn (fidelity table) + né dead-end bằng chỉ-viết-phần-được-giao (không kéo §5 vào /pause = né X4) · surprise=skill-registry đăng-ký /pause /tiep NGAY sau Write (hot-reload); git-status lộ ~13 file sibling-task — worker phải tự phân-định scope mình vs sibling tránh em-main hiểu nhầm.
- **W2:** task=D4+D5 point-insert BƯỚC 0.7 + §5.0/§6.4 · verdict=PASS 3+4 acceptance, insert-only 0-deletion · learned=point-insert giữ số cũ (X10) + grep-acceptance đếm được ngay trong return; "origin/main..HEAD" chỉ xuất hiện 1 lần literal (dòng lệnh) — reword phần prose tránh double-count · surprise=footer session-end phải đứng SAU §6.4 (reset = bước cuối THẬT — vị trí footer là ranh giới ngữ nghĩa, không chỉ cosmetic).
- **W3:** task=D2 PS1-hook + D6 policy-flip 2 README · verdict=PASS (lead disk-verify) · learned=PS1 port giữ skeleton lead-verified + pure-ASCII comment (#30); flip-policy giữ mode-A-nhỏ-hợp-lệ tránh over-mandate · surprise=(return notification-truncate — chi tiết trong sub-task-2.md; per-agent-file cứu đúng như N9 mô tả: return mất một phần, disk còn nguyên).

View File

@ -0,0 +1,19 @@
# Run — 2026-07-12-h22-wal-adopt (S111)
- **Đề-bài:** Adopt Harness-22 — WAL session-continuity (sổ `.claude/WAL.md` ≤40 dòng + Stop-hook persist-only + cặp `/pause`·`/tiep` + delta mở/đóng phiên + WAL-cho-workflow relaunch-cắt-gọt). Nguồn: broadcast `2026-07-11-Governance-harness-22-wal-session-continuity` (body-sha `3de0758a6377` verified) + notify `c64a7ac2a1bb`, pulled 2026-07-12 hash 4/4 MATCH.
- **Lệnh anh (owner-gated, H21 semantic):** `/check-email AI_INFRA và /adap-apply … /fable-real invest và review - đề tài là harness mà AI_INFRA apply xuống. Sau đó hwm cho Opus 4.8 MAX xử lý. Xong thì session-end` — vai engine-đắt anh gán: `investigator-codebase` (ground-truth) + `reviewer` (cổng-cuối); worker thực thi = Opus 4.8 MAX qua HMW.
- **Spec:** [`spec-h22-wal-adopt-12-07-2026.md`](spec-h22-wal-adopt-12-07-2026.md) — engine-propose bởi investigator-codebase (Fable-real single-deep-pass, READY_WITH_NUANCES 14N, 0-garble) → lead verified + CHỈNH 3 điểm (hook PS1 path-independent [2-context PATH conflict] · row#9 node-check · gitattributes giữ) → lead ghi (single-writer, H21 note-c).
- **Pipeline:** STAGE-1 pull+verify (done) → invest-Fable (done) → spec (done) → WF implement **`wf_5ba3daf6-fe0`** 3-worker-Opus RUN-TRACE (done 3/3, 0-error ~322K tok) → em-main still-mine (row#1/#2/#8/#9 done) → reviewer-Fable cổng-cuối (next) → adap-report/email/mark → STAGE-2 move + commit + cicd → session-end.
- **Run-id workflow:** WF-implement: **`wf_5ba3daf6-fe0`** (3/3 DONE) · invest-Fable + reviewer-Fable: spawn-direct (không qua workflow).
- **First-hand pre-check (lead, trước spec):** `bash` PATH = 2-context NGƯỢC nhau (PS-context → WSL-hỏng · cmd-context → Git-Bash) → hook PS1 · `.claude/settings.json` CHƯA tồn tại (tạo mới) · `.gitattributes` ĐÃ có (append) · repo TRONG Dropbox ((e) nguyên văn).
- **⚡ Finding runtime S111:** Stop-hook **HOT-RELOAD + FIRE ngay giữa phiên** — commit `12071c5 "wal: flush 20260712T1105"` (11:05:39, KHÔNG cần restart) 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), không push. → **N.3 STAGED-until-verified nâng VERIFIED-RUNTIME S111 cùng phiên** (caveat ENV-DEPENDENT giữ — data-point #2 sau skill-registry hot-reload; phiên mới re-check 1 lần trong pilot).
## taskList snapshot
> (H22 — ghi trước launch; snapshot này ghi hồi-tố NGAY SAU run đầu vì chuẩn mới sinh ra TRONG chính run này — các run sau ghi TRƯỚC launch.)
| # | role | label | prompt-gist |
|---|---|---|---|
| 0 | (role-less, tier:opus) | w1-pause-tiep | TẠO `.claude/commands/pause.md` + `tiep.md` — port broadcast §4+§6, /pause 5-bước + /tiep 4-bước + nhánh wf: relaunch-cắt-gọt |
| 1 | (role-less, tier:opus) | w2-session-cmds | EDIT session-start.md (BƯỚC 0.7 WAL-check) + session-end.md (§5.0 squash + §6.4 reset) — point-insert, no-renumber |
| 2 | (role-less, tier:opus) | w3-hook-readme | TẠO `.claude/hooks/wal-flush.ps1` (PS1-port skeleton lead-verified) + EDIT workflows/README.md flip-policy + runs/README.md taskList-snapshot template |

View File

@ -0,0 +1,48 @@
# SPEC — h22-wal-adopt — 12-07-2026 (S111)
> **Provenance (H21 note-c):** engine-propose = investigator-codebase **Fable-real single-deep-pass** (lệnh-A anh gõ `/fable-real invest và review — đề tài harness AI_INFRA apply xuống`; return SẠCH 0-garble, VERDICT `READY_WITH_NUANCES` 14 nuance N1-N14) → **lead verified + CHỈNH 3 điểm**: (1) **D2 hook = PowerShell `.ps1` variant** thay bash-nguồn — evidence xung-đột 2-context: lead đo PS-context `Get-Command bash` → `C:\WINDOWS\system32\bash.exe` WSL-HỎNG (execvpe fail) vs invest đo cmd-context `where bash` → Git-Bash đứng trước; exec-env hook thật KHÔNG xác định được trong phiên → chọn path-independent `powershell.exe` (system32, tuyệt đối); port NGUYÊN semantics sàn (per-path add + CAND commit + exit-0 mọi nhánh + 0 content/push/block); script-RUN verify tay được ngay phiên này — hook-FIRE vẫn phiên mới (N1 STAGED giữ) · (2) row #9 acceptance = `node --check` PASS (precedent S110 X7, bỏ wording mơ hồ) · (3) `.gitattributes` `*.sh text eol=lf` VẪN append (phòng-hờ .sh tương lai + fleet-parity, vô hại — repo hiện 0 file .sh) → **lead tự ghi file này** (single-writer). Worker KHÔNG tự đọc file — lead bơm nguyên văn qua args (hmw.js pattern).
## Mục 1 — Tính-năng / đề-bài
Adopt **Harness-22 WAL session-continuity** (broadcast `2026-07-11-Governance-harness-22-wal-session-continuity`, body-sha `3de0758a6377` verified): sổ `.claude/WAL.md` ≤40 dòng ghi-đè-không-append (chain-bằng-chứng `[x]/[!]/[ ]` + next 1-mệnh-lệnh + verify-trước-next, ground-truth thắng, cấm secret) · Stop-hook `.claude/hooks/wal-flush.ps1` persist-only per-path+CAND+exit-0 (**STAGED-until-verified** — hook nạp lúc khởi-động phiên, phiên này KHÔNG THỂ verify fire) + `.gitattributes` `*.sh text eol=lf` append · cặp `/pause` `/tiep` (MỘT đường recovery duy nhất) · delta session-start (**BƯỚC 0.7 MỚI** WAL-check — ngoại-lệ CHỜ duy nhất) + session-end (**§5.0** squash `wal:` trailing chưa-push + **§6.4** reset-WAL bước cuối) · WAL-cho-workflow (mandate run-trace ≥3-task/>5', taskList-snapshot vào run.md, dòng `wf:` 5-trường, harvest-liền C4 + per-agent-file + honest per-turn≠per-task N9, /tiep = relaunch-cắt-gọt + memory-pack re-derive tươi, resume-run-id = bonus SAME-SESSION-ONLY) · codify engine **PHẦN N** + CAVEAT:402 honest-update + rules §5.2 exception `wal:` + CLAUDE.md 2-dòng con-trỏ + honest (a)-(e) áp SE (e = Dropbox 2-chiều: risk index.lock + bonus .git-sync durability).
**Xong nghĩa là (DoD grep-được):** `Test-Path .claude/WAL.md`=True và ≤40 dòng · `.claude/hooks/wal-flush.ps1` chạy tay exit-0 + tạo commit `wal:` thật (script-RUN verified; hook-FIRE = phiên mới) · grep `"Stop"` `.claude/settings.json` ≥1 · grep `*.sh text eol=lf` `.gitattributes` =1 · grep `wal:` `docs/rules.md` ≥1 · grep `BƯỚC 0.7` session-start.md =1 · grep `reset --soft` session-end.md ≥1 · engine grep `PHẦN N` ≥1 + `STAGED-until-verified` ≥1 + honest (a)-(e) đủ 5 · CLAUDE.md grep `/tiep` ≥1 · workflows/README.md vùng :31 có `BẮT BUỘC` · adap-report + email AI_INFRA + mark-proposal trình anh (CHƯA stamp) · HANDOFF NEXT-anh có pilot-checklist + restart-CLI note.
## Mục 2 — Cách implement
### Quyết định thiết kế
- **D1 — WAL.md:** template rỗng nguồn §2 NGUYÊN VĂN; tracked (verify idiom N12: `git check-ignore` exit-1 = NOT-IGNORED cho re-included path `!.claude/**` .gitignore:82-83 — đừng đọc exit-code trần); ghi-đè toàn-file mỗi lần; lead single-writer nội-dung sau MỖI subtask đổi trạng-thái; dogfood ghi-chain ngay trong phiên S111 này.
- **D2 — Hook (LEAD-CHỈNH PS1):** `.claude/hooks/wal-flush.ps1` port NGUYÊN logic nguồn §3: 3 path cố định `.claude/WAL.md` + `.claude/agent-memory/` + `.claude/workflows/runs/` (N3 — GIỮ NGUYÊN, AS-6 không tăng: 2 json churn `.mfe-state`/`.archive-strikes` đã gitignored :124-125, `memory-budget.json` tracked đổi-hiếm-owner-directed; hook chỉ commit LOCAL, CI trigger lúc PUSH, squash → push-set ≡ hôm nay); **per-path `git add` từng cái** (X3 — add đa-pathspec = all-or-nothing khi 1 path vắng, bài học đắt nguồn) + CAND-list chỉ path thực-có-staged + commit `-m "wal: flush <yyyyMMddTHHmm>"` KHÔNG Co-Authored-By + **exit 0 MỌI nhánh** (try/catch bọc toàn thân; Stop-hook exit≠0 có hành vi riêng — CẤM); KHÔNG content-gen, KHÔNG push, KHÔNG block-stop, KHÔNG path ngoài list. `settings.json` CREATE MỚI (N1 — file chưa tồn tại, merge-concern moot) nested-schema: `{"hooks":{"Stop":[{"hooks":[{"type":"command","command":"powershell.exe -ExecutionPolicy Bypass -File .claude/hooks/wal-flush.ps1"}]}]}}`. **Status = STAGED-until-verified** (X5): codify + enable cùng commit nhưng CẤM claim "đang chạy" trước khi thấy commit `wal:` do HOOK sinh trong `git log` phiên MỚI (script-RUN tay ≠ hook-FIRE); honest-note (c) nguồn: nếu phiên mới không fire → thử biến-thể phẳng rồi verify lại.
- **D3 — /pause /tiep:** GIỮ tên nguồn (N11 — 16 command hiện có, 0 trùng); `.claude/commands/pause.md` = logic nguồn §4 /pause 5-bước (ngừng-spawn → flush-dirty → WAL-đúng-schema → commit ĐÍCH-DANH `wal: pause` KHÔNG `git add -A` → báo-cáo + DỪNG HẲN; bất-biến: commit TRƯỚC tuyên-bố an-toàn); `.claude/commands/tiep.md` = nguồn §4 /tiep 4-bước + nhánh `wf:` §6 (đọc WAL → không-tồn-tại/toàn-`[x]` = báo "không có mạch dở" DỪNG SẠCH → chạy TOÀN BỘ verify → lệch = TIN GROUND-TRUTH sửa WAL trước → thực-thi next; mục `wf:` → relaunch-CẮT-GỌT: đọc run-folder + taskList-snapshot, grep run-id trong log-phiên = bằng-chứng đích-danh task-đã-xong, harvest-hồi-tố partial-honest [lead verify rồi append], relaunch CHỈ task còn lại + memory-pack RE-DERIVE TƯƠI); /tiep verify đọc CẢ `git status` + disk run-folder KHÔNG chỉ git-log (N9); CẤM nạp transcript cũ; field `session:` khác phiên = BÌNH-THƯỜNG, chỉ cảnh-báo nếu `updated` mới hơn lúc phiên hiện-tại bắt đầu.
- **D4 — session-start:** **BƯỚC 0.7 MỚI** chèn sau BƯỚC 0.6 (:37-45) TRƯỚC Phase 1 READ (:47) — chặn trước read-set ~368K = token-save lớn nhất (N6); nội dung: đọc `.claude/WAL.md` → có `[!]` hoặc `[ ]` → báo "có mạch dở, `/tiep` để nối" + **CHỜ anh chọn** (ngoại-lệ CHỜ DUY NHẤT của quy-trình no-wait; chỉ là CON-TRỎ — quy-trình recovery viết ở MỘT chỗ = tiep.md); chain rỗng/toàn-`[x]` → tiếp bình-thường. GIỮ NGUYÊN số 0.5/0.5b/0.6 (X10, precedent D4 S110 chống renumber-churn).
- **D5 — session-end:** **§5.0 MỚI** ngay trước §5.1 (:111): đếm K = subject liên-tục `^wal:` từ HEAD xuống trong `git log --format=%s origin/main..HEAD` (span CHƯA-push — không bao giờ rewrite đã-push X4) → K>0 → `git reset --soft HEAD~K` gộp vào commit-chốt; K=0 → skip; biên N7: (i) push chết phiên trước → HEAD=chốt-cũ-chưa-push KHÔNG bị fold (đếm dừng ở subject ≠wal:), được push lần này; (ii) wal: sandwiched dưới chốt → GIỮ (noise chấp nhận, per nguồn §5); +1 dòng N14: "squash xong = điểm review-diff wal-paths (AS-10 backstop dời về đây, KHÔNG mất — push vẫn gated em-main)". **§6.4 MỚI** sau §6.3 (:129) TRƯỚC footer :139: reset WAL về template rỗng = bước CUỐI (hook sẽ commit lần reset thành wal-commit trailing sau turn cuối — vô-hại, phiên sau squash).
- **D6 — WAL-cho-workflow:** `workflows/README.md:31` + bảng :24 FLIP policy: mode-A vẫn cho fan-out NHỎ, nhưng **run ≥3 task HOẶC ước >5 phút = BẮT BUỘC RUN-TRACE mode (args.run — per-agent-file trong run-folder)** (sàn H22 owner nguồn đã chốt); run.md template +section `## taskList snapshot` (role · label · prompt-gist) ghi TRƯỚC launch (N10); dòng `wf:<mục-đích> run=<folder> runId=<id|pending> args=<snapshot-ref> done=<k>/<N> harvested=<yes|no|partial>` vào WAL NGAY SAU launch, lead điền runId khi có; harvest-LIỀN mỗi task xong = C4 per-turn (ĐÃ CÓ — hmw.js:99 + session-end:51) + honest-note granularity N9 (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); memory-pack KHÔNG snapshot (X6 — re-derive tươi lúc /tiep; hiện đã compliant: pack qua args hmw.js:15); resume-by-run-id = bonus SAME-SESSION-ONLY (engine Workflow docs "same-session only" — CẤM claim cross-session, honest-note (d)).
- **D7 — Codify:** engine `docs/governance/harness-11-engine.md` **PHẦN N MỚI** (trước CAVEAT :401): schema WAL + 2 tầng ghi (lead nội-dung ⟂ hook persist) + hook ĐƯỢC làm {git add 3-path, CAND-commit `wal:`} / KHÔNG-ĐƯỢC {content-gen, push, block-stop, path-ngoài-list, exit≠0} + STAGED-until-verified + honest (a)-(e) áp SE [(a) pilot chưa chạy tại SE — kill-test/đổi-acc/hook-fire = phiên mới+anh; (b) SE 0-mark-cấm-hook, N2 mô-tả-vs-luật, thứ-tự codify-trước-enable ĐÃ tôn trọng cùng-commit; (c) nested-schema default, fallback flat nếu phiên mới không fire; (d) resume-run-id same-session-only; (e) Dropbox 2-chiều: risk index.lock thấp-nhưng-có fail-open tự-lành + bonus .git-sync = 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]; CAVEAT :402 honest-update: thêm ngoại-lệ đích-danh "Stop-hook wal-flush persist-only (PHẦN N) — 0-content, fail-open, KHÔNG phải gate (E.3-compatible)"; `docs/rules.md` §5.2 (:213-221) append exception: "ngoại-lệ DUY-NHẤT: commit `wal:` (Stop-hook persist + /pause + WAL-reset) — máy sinh, KHÔNG Co-Authored-By, bị squash vào commit-chốt trước push (session-end §5.0)"; root `CLAUDE.md` 2 dòng con-trỏ: "Mạch việc dở nằm ở `.claude/WAL.md`; nối lại DUY-NHẤT bằng `/tiep` — kể cả khi anh gõ 'làm tiếp' bằng text thường. Không tự recovery cách khác."
- **D8 — hmw.js :9/:19 comment-only** (em-main, X7 KHÔNG đổi code): :9 meta note mode-A default → "+ mandate H22: ≥3-task/>5' PHẢI RUN-TRACE (em-main scaffold + set args.run — script no-fs không tự ép, enforcement = convention lead)"; :19 `run: OPTIONAL` → wording mandate-ref.
- **D9 — Mark H22 MỚI** trình anh cuối phiên (P4 report-before-stamp §L.b(h)) — KHÔNG tự stamp (X5-mark); đề xuất §-target: `engine PHẦN N` + `.claude/hooks/` + `session-start BƯỚC 0.7` / `session-end §5.0+§6.4` (≙ AI_INFRA H-22 CANONICAL §I4 + §H1).
- **D10 — Optional KHÔNG-block (owner-OK sau):** deploy.yml paths-ignore +`.claude/agent-memory/**` +`.claude/workflows/runs/**` (precedent `.claude/skills/**` :23) — triệt noise CI khi budget.json đổi; ghi option vào adap-report + HANDOFF, KHÔNG làm trong run này.
### Ràng buộc thật
Worker Opus edit-DIRECT trong PHẠM VI file được giao (3 lane disjoint; residual → em-main git-diff revert AS-10) · WAL.md + .gitattributes + settings.json + engine + rules + CLAUDE.md + hmw.js + adap-report + email + mark-proposal + HANDOFF = em-main · command .md + hook = restart-CLI/phiên-mới mới ăn (S27 + ENV-DEPENDENT S110) → pilot-checklist nằm HANDOFF NEXT-anh · HISTORY (session-log, archive verbatim, adap-report cũ, diary) GIỮ nguyên văn · script-RUN tay verify trong phiên ≠ hook-FIRE (phiên mới).
### Đường chết cần né
(X1) đụng `hmw-mode.on`/BƯỚC 0.5/`ultra-*` — HỆ KHÁC (HMW consent) · (X2) hook thêm content-gen/push/block-stop · (X3) add/commit đa-pathspec all-or-nothing · (X4) rewrite commit đã-push khi squash · (X5) claim hook "đang chạy" trước verify phiên mới (ghost-wire S100) · (X6) snapshot memory-pack · (X7) đổi code hmw.js (chỉ comment) · (X8) WAL append thay ghi-đè / vượt 40 dòng / chứa secret · (X9) commit script .sh trước khi .gitattributes có `*.sh` (n/a với .ps1 nhưng giữ thứ-tự: gitattributes trước) · (X10) renumber BƯỚC/§ cũ · (X11) tự stamp mark.
## Mục 3 — Checklist thực hiện
| # | Vai | Deliverable | Acceptance (đo được) |
|---|---|---|---|
| 1 | em-main | `.gitattributes` append `*.sh text eol=lf` (X9-first) + `.claude/WAL.md` template nguồn §2 | grep `*.sh text eol=lf` =1; `Test-Path .claude/WAL.md`=True; `(gc).Count` ≤40; check-ignore idiom → NOT-IGNORED |
| 2 | em-main | `.claude/settings.json` CREATE hooks-entry PS1 + STAGED-note trong engine | grep `"Stop"` =1; grep `wal-flush.ps1` =1; engine grep `STAGED-until-verified` ≥1 |
| 3 | worker-opus-1 (edit-direct, file MỚI) | `.claude/commands/pause.md` + `.claude/commands/tiep.md` (D3) | 2 file frontmatter `description:`; tiep grep "transcript"≥1(CẤM) + "ground-truth"≥1 + "wf:"≥1 + nhánh WAL-rỗng-dừng-sạch + "git status"≥1; pause grep "wal: pause"≥1 + "git add -A"≥1(CẤM-context) + trỏ /tiep |
| 4 | worker-opus-2 (edit-direct) | session-start.md BƯỚC 0.7 (D4) | grep "BƯỚC 0.7"=1; "CHỜ"≥1 vùng 0.7; git-diff KHÔNG chạm 0.5/0.5b/0.6/Phase-1+ |
| 5 | worker-opus-2 (edit-direct) | session-end.md §5.0 + §6.4 (D5) | grep "origin/main..HEAD"=1; "reset --soft"=1; "KHÔNG rewrite"≥1; "review-diff wal-paths"≥1; §6.4 sau 6.3 trước footer |
| 6 | worker-opus-3 (edit-direct, file MỚI) | `.claude/hooks/wal-flush.ps1` (D2 PS1-port) | lead chạy tay `powershell -ExecutionPolicy Bypass -File` exit-0 ×2 ca (có-delta → commit `wal:` thật; 0-delta → exit-0 im lặng); grep "exit 0"≥2 + try/catch; per-path loop + CAND; 0 push/content/block |
| 7 | worker-opus-3 (edit-direct) | workflows/README.md policy-flip :31+bảng + run.md template +`## taskList snapshot` (D6) | vùng :31 có "BẮT BUỘC" + "≥3"/"5 phút"; grep "taskList snapshot"≥1; mode-A vẫn hợp lệ cho fan-out nhỏ |
| 8 | em-main | engine PHẦN N + CAVEAT:402 + rules §5.2 + CLAUDE.md pointer (D7) | grep "PHẦN N"≥1; :402 có "ngoại-lệ"; rules grep "wal:"≥1; CLAUDE.md grep "/tiep"≥1; honest a-e đủ 5 trong PHẦN N |
| 9 | em-main | hmw.js :9/:19 comment-only (D8) | `node --check .claude/workflows/hmw.js` PASS; grep "OPTIONAL" :19 vùng = 0 (thay mandate-ref); git-diff hmw.js chỉ comment-line |
| 10 | em-main | WAL.md dogfood ghi-chain S111 + run.md update + adap-report + email AI_INFRA + mark-proposal (D9) | WAL chain ≥3 mục [x] bằng-chứng lệnh; report nêu ĐÚNG NẤC "khung dựng + STAGED + script-RUN-verified, hook-FIRE + pilot = phiên mới"; ACTIVE-MARKS CHƯA đổi; AskUserQuestion trình |
| 11 | reviewer-Fable (vai anh gán trong lệnh) | Cổng-cuối biên-test + sweep | fault-inject cây tạm: hook thiếu-1-path vẫn commit path-còn + exit-0; WAL >40-dòng bị bắt; /tiep WAL-rỗng dừng sạch; grep toàn-repo con-trỏ recovery = MỘT đường /tiep; honest a-e present; 0.5/hmw-mode/ultra-* untouched; spec-compliance từng row |
| 12 | em-main | HANDOFF pilot-checklist + restart-CLI note + STATUS blurb | NEXT-anh có: restart CLI · phiên mới verify hook-FIRE (git log `wal:`) · kill-giữa-chain → /tiep · đổi-acc · squash dry-run thật · pause-roundtrip 1 workflow THẬT |
**Map sàn-H22 → row:** ① sổ WAL ≤40/schema/ghi-đè → #1+#10 · ② hai tầng ghi (lead⟂hook persist-only 0-content fail-open per-path) → #2+#6+#8 · ③ /pause+/tiep 1-đường → #3+#11 · ④ delta mở/đóng (WAL-check · squash chưa-push · reset cuối) → #4+#5 · ⑤ WAL-workflow (snapshot args · wf: · harvest-liền · relaunch-cắt-gọt · mandate per-agent-file · trung-thực mất-mát) → #7+#8+#3(nhánh wf:) · honest (a)-(e) → #8+#10.

View File

@ -0,0 +1,55 @@
# sub-task-0 — D3: tạo 2 command file `/pause` + `/tiep` (Harness-22 WAL session-continuity)
**Role:** implementer (Write tool) · **Scope:** CHỈ 2 file MỚI + file này. Không đè gì.
**Nguồn FROZEN đã đọc:** `broadcasts/inbox/2026-07-11-Governance-harness-22-wal-session-continuity.md` (§4 dòng 101-120 + §6 dòng 130-140). KHÔNG tự đọc spec-file (nhận phần liên-quan qua prompt).
**Format mẫu:** `.claude/commands/send-email.md` dòng 1-4 (frontmatter `description:` + `argument-hint:`).
## Deliverables (2 file MỚI — đều `??` untracked, xác-nhận không đè)
| File | Dòng | Nội-dung |
|---|---|---|
| `.claude/commands/pause.md` | 47 | `/pause` — chốt điểm dừng chủ-động, 5 bước tuần-tự + bất-biến + con-trỏ `/tiep` |
| `.claude/commands/tiep.md` | 42 | `/tiep` — recovery MỘT đường, 4 bước + nhánh `wf:` + khối CẤM |
> Cả 2 file tự-động đăng-ký thành slash-command (hệ báo skill `pause`/`tiep` xuất-hiện sau Write) → frontmatter hợp-lệ, well-formed.
## Port-fidelity map → broadcast (trung-thực, không bịa)
### pause.md ← §4 phần `/pause` (broadcast dòng 103-111)
- Bước 1 (dòng 15-17) ← BC 105: NGỪNG spawn; sắp-xong <~2' → chờ+harvest-liền; còn lâu → KHÔNG chờ, WAL `[!]` đủ trường, workflow = dòng `wf:` 5-trường (port nguyên `wf:<mục-đích> run= runId= args= done=k/N harvested=no`).
- Bước 2 (dòng 19-21) ← BC 106: flush dirty; ghi-chú-dở dài để run-folder/work-state, KHÔNG nhét vào WAL.
- Bước 3 (dòng 23-27) ← BC 107 + §2 (BC 34-37): chain kèm BẰNG-CHỨNG · `next:` 1 mệnh-lệnh · `verify:` lệnh chạy-được cho từng `[!]` · **ghi-đè toàn-file ≤40 dòng · CẤM secret**.
- Bước 4 (dòng 29-32) ← BC 108: commit ĐÍCH-DANH (WAL + path persist + file dở) msg `wal: pause` · **TUYỆT ĐỐI KHÔNG `git add -A`** · KHÔNG push [Dropbox `.git` cloud-sync = local durable].
- Bước 5 (dòng 34-42) ← BC 109: báo goal / mục `[!]` đầu / workflow bỏ lại / "an-toàn để thoát, đổi acc, tắt máy" → DỪNG HẲN.
- Bất-biến (dòng 45) ← BC 111: commit bước-4 TRƯỚC tuyên-bố bước-5.
- Con-trỏ (dòng 47) ← §7 mục 5 (BC 154): "Nối lại = `/tiep` (MỘT đường recovery duy-nhất)".
### tiep.md ← §4 phần `/tiep` (BC 113-120) + nhánh `wf:` §6 (BC 130-140)
- Bước 1 (dòng 14-15) ← BC 115: đọc WAL; không tồn-tại / chain toàn `[x]` → "không có mạch dở" **DỪNG SẠCH**.
- Bước 2 (dòng 17-20) ← BC 116 + SE-tailor N9: chạy TOÀN BỘ `verify:` **VÀ** đọc `git status` + disk run-folder (per-turn≠per-task: returns mất được nhưng per-agent-file trên đĩa còn) — đây là delta SE thêm theo prompt, so chain.
- Bước 3 (dòng 22-24) ← BC 117: LỆCH → TIN GROUND-TRUTH (sửa WAL, báo lệch, rồi mới chạy) · KHỚP → thực-thi từ `next:`, nối chain thứ-tự.
- Bước 4 (dòng 26-32) ← BC 118 + §6 (BC 137-138): mục `wf:` → recovery-workflow: đọc run-folder + `## taskList snapshot` trong run.md; grep run-id trong log-phiên (glob — grep ĐÍCH-DANH, KHÔNG nạp toàn transcript); harvest-hồi-tố partial-honest; **RELAUNCH đã-cắt-gọt chỉ task CÒN LẠI + memory-pack DẪN-XUẤT-LẠI TƯƠI (CẤM snapshot pack cũ)**; resume-by-run-id = bonus SAME-SESSION-ONLY, CẤM claim cross-session.
- Khối CẤM (dòng 38-40) ← BC 120: CẤM giả-định bước xong nếu `verify:` không chứng-minh · **CẤM nạp lại transcript cũ** (WAL+ground-truth đủ; thiếu → HỎI anh).
- Field `session:` (dòng 42) ← BC 120: khác phiên = BÌNH-THƯỜNG (use-case); chỉ cảnh-báo nếu `updated:` mới hơn lúc phiên hiện-tại bắt đầu (dấu phiên song-song).
## Dead-ends né được (checklist X)
- **X4** (rewrite commit đã-push): pause.md chỉ "KHÔNG push" + rationale Dropbox-durable. KHÔNG hề nhắc squash/reset/rewrite (đó là §5 delta = task khác). ✅
- **X8** (WAL append / >40 / secret): pause.md bước-3 ghi rõ "ghi-đè toàn-file (KHÔNG append), cứng ≤40 dòng, CẤM secret". ✅
- **X5** (claim hook 'đang chạy'): 2 file KHÔNG nhắc Stop-hook. Commit bước-4 là commit THỦ-CÔNG của lệnh `/pause`, độc-lập hook. ✅
- **X1/X7/X10:** không đụng hmw-mode/BƯỚC-0.5/ultra-*/hmw.js; file MỚI nên không renumber gì. ✅
- **Isolation:** git-status → chỉ `.claude/commands/pause.md` + `.claude/commands/tiep.md``??` do tôi tạo; các M/?? khác (session-*.md, .gitattributes, hooks/, settings.json, CLAUDE.md, rules.md…) = sibling D-task, KHÔNG do tôi. ✅
## Acceptance (row #3) — grep-count evidence
| Check | Kết-quả | Line |
|---|---|---|
| pause.md frontmatter `description:` | PASS | L2 |
| pause.md `wal: pause` ≥1 | PASS (3×) | L2, L29, L30 |
| pause.md `git add -A` ≥1 (câu CẤM) | PASS (1×) | L31 "TUYỆT ĐỐI KHÔNG `git add -A`" |
| pause.md trỏ `/tiep` | PASS (5×) | L47 con-trỏ cuối "Nối lại = `/tiep`" |
| tiep.md frontmatter `description:` | PASS | L2 |
| tiep.md `transcript` ≥1 (câu CẤM) | PASS (2×) | L40 "CẤM nạp lại transcript cũ" + L29 |
| tiep.md `ground-truth` ≥1 | PASS (3×) | L17, L40 (lowercase), L2 |
| tiep.md `wf:` ≥1 | PASS (3×) | L2, L26, L27 |
| tiep.md nhánh WAL-rỗng-dừng-sạch | PASS | L15 "chain toàn `[x]` → 'không có mạch dở' → DỪNG SẠCH" |
| tiep.md `git status` ≥1 | PASS (4×) | L19, L23, L40, L2 |
**Verdict: 10/10 acceptance PASS.** 2 file well-formed (auto-đăng-ký slash-command), port trung-thực, isolation sạch.

View File

@ -0,0 +1,51 @@
# sub-task-1 — EDIT 2 session-command (D4+D5 spec) — H22 WAL session-continuity
**Role:** implementer (Write/Edit) · **Run:** 2026-07-12-h22-wal-adopt · **Scope FILE giao:** `.claude/commands/session-start.md` + `.claude/commands/session-end.md` (KHÔNG file khác).
## Việc đã làm (3 point-insert, KHÔNG renumber — X10 né)
### (1) session-start.md — CHÈN BƯỚC 0.7 MỚI
- **Vị-trí:** ngay SAU khối BƯỚC 0.6 (dòng flip-chain `…BƯỚC 0.6 probe MỖI phiên…`) và TRƯỚC `## Phase 1 — READ`. Hunk `@@ -44,6 +44,15 @@` = insert-only +9 dòng.
- **Heading:** `## 📋 BƯỚC 0.7 — WAL-check mạch-việc-dở (H22 — adopt S111)` (dòng 47).
- **Nội-dung:** em main đọc `.claude/WAL.md` → nhánh (a) file-vắng/chain-rỗng/toàn-`[x]` → báo 1 dòng "WAL sạch — không có mạch dở" rồi tiếp Phase 1 (no-wait); nhánh (b) chain có `[!]`/`[ ]` → BÁO goal + mục `[!]` đầu + câu "gõ `/tiep` để nối, hoặc bảo em bootstrap tiếp bỏ mạch" → **CHỜ anh chọn** = NGOẠI-LỆ CHỜ DUY-NHẤT của no-wait (BƯỚC 0 GIỮ no-wait).
- **B1 con-trỏ-canonical:** ghi rõ bước này CHỈ LÀ CON-TRỎ, recovery-logic viết ở MỘT CHỖ = `[.claude/commands/tiep.md](tiep.md)` (KHÔNG copy verify/relaunch vào đây). Lý-do chặn TRƯỚC Phase 1 READ = tiết-kiệm read-set ~368K khi anh chọn /tiep.
- Thứ-tự BƯỚC sau chèn: 0 → 0.5 → 0.5b → 0.6 → **0.7 (47)** → Phase 1 (56). Không đụng 0.5/0.5b/0.6.
### (2a) session-end.md — CHÈN §5.0 MỚI (TRƯỚC §5.1)
- **Vị-trí:** giữa `## Phase 5 — COMMIT (release)``### 5.1 Release + commit`. Hunk `@@ -108,6 +108,12 @@` = insert-only.
- **Heading:** `### 5.0 Squash wal:-trailing chưa-push (H22 — TRƯỚC commit-chốt)` (dòng 111).
- **Nội-dung:** `git log --format=%s origin/main..HEAD` → đếm K = số subject LIÊN-TỤC bắt đầu `wal:` từ HEAD xuống (DỪNG khi gặp subject khác); K=0→skip; K>0→`git reset --soft HEAD~K` gộp vào commit-chốt §5.1.
- **Hard-safety (X4 né — KHÔNG gợi rewrite pushed):** phạm-vi = CHỈ commit CHƯA-push (ahead-of-remote) → **"KHÔNG BAO GIỜ rewrite commit đã-push"**; wal: kẹp sâu (sandwiched dưới commit thường chưa-push) → GIỮ NGUYÊN chấp-nhận noise. Biên push-chết-giữa-phiên-trước: HEAD=chốt-cũ-chưa-push → đếm dừng tại đó, chốt cũ KHÔNG fold, push lần này.
- **AS-10 backstop:** +1 dòng "squash xong = điểm **review-diff wal-paths**" (hook đã commit local residual-write nếu có → review diff path WAL/agent-memory/runs tại đây trước chốt; push vẫn gated em-main).
- ⚠️ `origin/main..HEAD` chỉ xuất-hiện 1 LẦN (trong lệnh git log); dòng "Phạm-vi" reword "khoảng ahead-of-remote" KHÔNG lặp literal → thoả acceptance grep=1. `reset --soft` cũng 1 lần duy nhất.
### (2b) session-end.md — CHÈN §6.4 MỚI (SAU §6.3, TRƯỚC footer)
- **Vị-trí:** sau dòng cuối §6.3 (`…"N/A (no infra adoption this session)".`) và TRƯỚC `---` + footer `**Trigger sau Phase 6:**`. Hunk `@@ -134,6 +140,10 @@` = insert-only.
- **Heading:** `### 6.4 Reset WAL (H22 — bước CUỐI)` (dòng 143; footer dòng 149).
- **Nội-dung:** ghi-đè `.claude/WAL.md` về template rỗng (`updated`/`session`/`branch`=`—` · `goal`=`(trống — không có mạch dở)` · `chain`=`(rỗng)` · `next`/`verify`=`(trống)`); note Stop-hook sẽ commit reset thành wal-commit trailing sau turn cuối = vô-hại, phiên sau squash ở §5.0. Framing future-tense "hook sẽ commit" (X5 né — KHÔNG claim hook đang-chạy phiên này).
## Acceptance evidence (grep-count)
| # | Check | Kết-quả | Verdict |
|---|---|---|---|
| 4a | session-start `grep -c 'BƯỚC 0.7'` | 1 | PASS |
| 4b | `'CHỜ'` trong vùng 0.7 (dòng 52, giữa 47…56) | 1 (≥1) | PASS |
| 4c | git-diff KHÔNG chạm 0.5/0.5b/0.6/Phase-1 | insert-only, 0 deletion | PASS |
| 5a | session-end `grep -c 'origin/main..HEAD'` | 1 | PASS |
| 5b | `grep -c 'reset --soft'` | 1 | PASS |
| 5c | `'KHÔNG'` gần `'rewrite'` (dòng 113 §5.0) | ≥1 | PASS |
| 5d | `grep -c 'review-diff wal-paths'` | 1 (≥1) | PASS |
| 5e | §6.4(143) SAU §6.3(135) TRƯỚC footer(149) | đúng thứ-tự | PASS |
## Isolation (B6 audit)
- `git diff --stat` file giao: `session-end.md +10`, `session-start.md +9` = 19 insertion, insert-only (grep `^-[^-]` diff = 0 content-deletion).
- Tôi CHỈ Edit 2 file giao + Write file này (`sub-task-1.md`). KHÔNG đụng file nào khác.
- `git status` toàn-repo có nhiều file M/?? (pause.md, tiep.md, hooks/, settings.json, CLAUDE.md, harness-11-engine.md, rules.md, .gitattributes, broadcasts/_index.md, 2 README) = **sibling-task cùng wave H22 (shared tree)**, KHÔNG phải write của tôi.
## Dead-ends né (theo spec)
- X1: KHÔNG đụng hmw-mode.on / BƯỚC 0.5/0.5b/0.6 / ultra-*.md.
- X4: wording §5.0 khẳng-định "KHÔNG BAO GIỜ rewrite commit đã-push", reset chỉ khoảng chưa-push.
- X5: §6.4 dùng "hook SẼ commit" (future) — KHÔNG claim hook đang-chạy phiên này.
- X8: §6.4 reset = ghi-đè template rỗng ~8 dòng (≤40), no secret.
- X10: 0.7/5.0/6.4 = số MỚI chèn-điểm, KHÔNG renumber mục cũ.
- KHÔNG commit (em-main commit cuối phiên).
- KHÔNG đọc spec-file (nhận qua prompt); chỉ đọc broadcast FROZEN + 2 file giao.

View File

@ -0,0 +1,87 @@
# sub-task-2 — H22 hook PS1 + FLIP policy workflow (D2+D6)
**Role:** implementer-backend (Write/Edit-capable) · **Run:** 2026-07-12-h22-wal-adopt · **Spec:** D2 (hook PS1) + D6 (FLIP RUN-TRACE policy)
## Scope (3 deliverables, isolation-clean)
1. CREATE `.claude/hooks/wal-flush.ps1` (folder mới)
2. EDIT `.claude/workflows/README.md` — FLIP 2-mode policy
3. EDIT `.claude/workflows/runs/README.md` — add `## taskList snapshot` section
Không đụng file nào khác. `git status` cho thấy nhiều file M/?? khác = việc của sibling-task trong cùng fan-out song-song (session-*.md, .gitattributes, pause.md, tiep.md, settings.json, CLAUDE.md, rules.md, harness-11-engine.md, broadcasts/*) — KHÔNG phải write của tôi.
---
## (1) `.claude/hooks/wal-flush.ps1` — port bash→PS 5.1, persist-only
Port nguyên semantics từ broadcast §3 (bash `wal-flush.sh`, dòng 82-97) sang PowerShell 5.1 dùng skeleton lead-verified. **Chỉnh cosmetic DUY-NHẤT: 2 em-dash `—` trong comment → hyphen `-`** để đạt pure-ASCII (lesson #30 — tránh mojibake .ps1). KHÔNG thêm logic ngoài skeleton.
Nội dung final (788 bytes, pure-ASCII, LF, no-BOM):
```
# wal-flush.ps1 - WAL persist-only Stop hook (H22 S111). KHONG sinh noi dung, KHONG push, KHONG block.
# Fail-open MOI nhanh: exit 0 ke ca loi (Stop-hook exit!=0 co hanh vi rieng - CAM).
# Per-path add + CAND commit (X3: add/commit da-pathspec = all-or-nothing khi 1 path vang).
try {
$root = if ($env:CLAUDE_PROJECT_DIR) { $env:CLAUDE_PROJECT_DIR } else { "." }
Set-Location $root
$paths = @(".claude/WAL.md", ".claude/agent-memory/", ".claude/workflows/runs/")
$cand = @()
foreach ($p in $paths) {
git add -- $p 2>$null
git diff --cached --quiet -- $p 2>$null
if ($LASTEXITCODE -ne 0) { $cand += $p }
}
if ($cand.Count -gt 0) {
$ts = Get-Date -Format "yyyyMMddTHHmm"
git commit -q -m "wal: flush $ts" -- $cand 2>$null | Out-Null
}
} catch { }
exit 0
```
### Semantics-fidelity bash→PS (từng dòng khớp):
| bash §3 | PS 5.1 | Khớp |
|---|---|---|
| `cd "${CLAUDE_PROJECT_DIR:-.}" \|\| exit 0` | `$root = if($env:CLAUDE_PROJECT_DIR){...}else{"."}; Set-Location $root` (trong try/catch→exit 0) | ✅ fail-open |
| `P=".claude/WAL.md .claude/agent-memory/ .claude/workflows/runs/"` | `$paths = @(3 path y-hệt)` | ✅ 3 path |
| `git add -- "$p"` per-path | `git add -- $p 2>$null` per-path | ✅ per-path (X3 all-or-nothing tránh) |
| `git diff --cached --quiet \|\| CAND+=p` | `git diff --cached --quiet; if($LASTEXITCODE -ne 0){$cand+=$p}` | ✅ exit!=0 = có staged |
| `[ -z "$CAND" ] && exit 0` | `if($cand.Count -gt 0){commit}` | ✅ chỉ commit khi non-empty |
| `git commit -q -m "wal: flush $(date +%Y%m%dT%H%M)" -- $CAND` | `$ts=Get-Date -Format "yyyyMMddTHHmm"; git commit -q -m "wal: flush $ts" -- $cand` | ✅ (T literal trong .NET format, khớp `%Y%m%dT%H%M`) |
| `exit 0` cuối | `exit 0` cuối | ✅ fail-open mọi nhánh |
### Guard-rail đã verify (dead-ends né):
- **X2 (0 content-gen / 0 push / 0 block):** grep Set-Content/Out-File/Add-Content/echo/`>>` = NONE-OK · `git push` = NO-GIT-PUSH-OK (chỉ 'push' trong comment `KHONG push`) · `exit [1-9]` = NONE-OK (chỉ `exit 0`).
- **X8:** hook chỉ add/commit path cố-định (WAL + agent-memory + runs), message `wal: flush <ts>` KHÔNG Co-Authored-By, KHÔNG secret.
- **lesson #30:** byte-scan = 788 bytes, 0 non-ASCII; BOM = `23 20 77` (`# w`, no BOM); PSParser.Tokenize = PARSE-OK.
## (2) `.claude/workflows/README.md` — FLIP 2-mode policy
Vùng `## 2 MODE memory` (mode-table + câu chốt). 2 edit:
- **+1 row bảng** sau "Khi dùng": `| Bắt buộc? (sàn H22 S111) | mode-A hợp lệ cho fan-out NHỎ | **BẮT BUỘC khi run ≥3 task HOẶC ước chạy >5 phút** (args.run → per-agent-file sub-<role>-<i>.md) |` — 3-col khớp header, table structure intact.
- **Sửa "Khi dùng" DEFAULT cell:** "fan-out NHẸ (~2-3 phút…)" → "fan-out NHỎ (<3 task **VÀ** ước 5 phút; read/analyze vd recon)".
- **Thay câu chốt** `> Mặc định DEFAULT…` `> **Sàn H22 (S111) — FLIP policy:** mode-A return-delta-only VẪN hợp lệ cho fan-out NHỎ, NHƯNG run ≥3 task HOẶC ước chạy >5 phút = BẮT BUỘC RUN-TRACE mode… Lý-do: chết giữa run vẫn còn vật-liệu trên đĩa để /tiep nối — per-TURN ≠ per-TASK: returns mất khi chết giữa turn, file trên disk còn.`
GIỮ nguyên 3 row còn lại (Sub ghi file / Lead làm / Rủi ro) + heading. KHÔNG renumber (X10).
## (3) `.claude/workflows/runs/README.md` — add taskList snapshot section
Chèn section mới `## taskList snapshot (H22 — ghi TRƯỚC launch)` GIỮA C2 C3 (anchor = C3 heading; KHÔNG renumber C1-C8, X10). Nội dung: template `## taskList snapshot` trong run.md (role · label · prompt-gist 1-dòng) ghi TRƯỚC launch + dòng WAL `wf:` 5-trường (`wf:<mục-đích> run= runId=<id|pending> args= done=<k>/<N> harvested=<yes|no|partial>`) ghi NGAY SAU launch + memory-pack KHÔNG snapshot (X6, re-derive tươi lúc /tiep).
---
## ACCEPTANCE (row #6+#7) — evidence
| Tiêu-chí | Verdict | Evidence |
|---|---|---|
| ps1 `exit 0` 1 dòng cuối | PASS | grep -c 'exit 0'=2 (comment+final); `tail -1`=`exit 0` |
| ps1 try/catch present | PASS | L4 `try {` · L18 `} catch { }` |
| ps1 per-path foreach | PASS | L9 `foreach ($p in $paths)` |
| ps1 $cand present | PASS | 4 occurrences |
| ps1 0 push / 0 content-gen / 0 block | PASS | no `git push`; no Set-Content/Out-File/echo/`>>`; no `exit [1-9]` |
| workflows/README 'BẮT BUỘC'+'≥3'+'5 phút', mode-A-nhỏ hợp lệ | PASS | L27+L32 'BẮT BUỘC'; 'run 3 task'; '>5 phút'/'≤5 phút'; L32 'VẪN hợp lệ cho fan-out NHỎ' |
| runs/README 'taskList snapshot'≥1 + 'wf:'≥1 | PASS | grep -c 'taskList snapshot'=3; grep -c 'wf:'=2 |
## Verify commands run
- `PSParser.Tokenize` → PARSE-OK
- byte-scan → 788 bytes / 0 non-ASCII / no-BOM / no-CRLF
- grep sweep 3 file → tất cả tiêu-chí PASS
- `git status --porcelain` → 3 file của tôi (+ sibling-task files KHÔNG phải của tôi)

View File

@ -42,6 +42,17 @@ runs/<run-id>/
---
## taskList snapshot (H22 — ghi TRƯỚC launch)
Sàn WAL-cho-workflow (Harness-22 S111) — chống đốt-lại-token + mất-memory khi chết GIỮA workflow. **Điều-kiện áp:** run WAL-hóa = **≥3 task HOẶC ước chạy >5 phút** (khớp `../README.md` FLIP-policy) → BẮT BUỘC RUN-TRACE + 2 vật-liệu dưới ghi xuống đĩa TRƯỚC/NGAY-SAU launch:
- **Section `## taskList snapshot` trong `run.md` — ghi TRƯỚC khi phóng.** Mỗi `run.md` PHẢI có section này liệt-kê từng task sắp phóng: **(role · label · prompt-gist 1-dòng)** — đủ vật-liệu để `/tiep` relaunch-cắt-gọt các task CÒN LẠI mà KHÔNG cần transcript cũ. (= "snapshot tham-số" mục ⑤ broadcast H22: ghi {danh-sách-task · spec} xuống đĩa trước launch.)
- **Dòng WAL `wf:` (5 trường) — ghi NGAY SAU launch** vào `.claude/WAL.md`, lead điền `runId` khi engine trả về:
`wf:<mục-đích> run=<run-folder> runId=<id|pending> args=<snapshot-ref> done=<k>/<N> harvested=<yes|no|partial>`
`run=` trỏ `runs/<run-id>/`; `args=` trỏ section `## taskList snapshot` trong `run.md` (KHÔNG nhét spec dài vào WAL); `done=<k>/<N>` + `harvested=partial` cập-nhật khi harvest-liền mỗi task xong.
- 🔴 **memory-pack KHÔNG snapshot (X6):** re-derive TƯƠI lúc `/tiep` — snapshot memory-pack cũ sẽ lỗi-thời sau khi đã harvest phần đã-xong.
---
## C3 — Git-tracked: VERIFY **2 nấc tách-bạch** (chỗ hay nhầm)
Run-folder PHẢI git **TRACKED** (re-include qua `.gitignore:83 !.claude/**`, last-match-wins). Verify ĐỦ **2 nấc** — đừng dừng ở nấc 1: