Files
solution-erp/.claude/workflows/runs/2026-07-22-S145-apply-hub-answers/sub-implement-A-c7.md
pqhuy1987 8b6df0a396
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 5m25s
[CLAUDE] Docs: S146 closeout — session-model 3 owner-decision + hook 4-path + H24 auto
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>
2026-07-23 00:16:37 +07:00

176 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# sub-implement-A-c7 — Axis A (C7 predicate 4-vế) + N.2 cardinality 3→4
> Worker-1 (`impl-A-c7`) · S146 relaunch-cắt-gọt · file sở-hữu = `docs/governance/harness-11-engine.md` DUY-NHẤT.
> Ghi-đĩa-TRONG-lúc-làm (anti-#53, bài học S123). **VERDICT: DONE** (VIỆC 3 = báo-cáo PARTIAL-về-script, không phải PARTIAL-về-task).
## Trạng-thái
- [x] B0 — đọc spec-v2 toàn-file (gồm §[4] ADDENDUM @S146) + run.md
- [x] B1 — VIỆC 1: viết **§N.8** (predicate 4-vế + tách FLOOR/FORM + reword tập-cấm) → `harness-11-engine.md:413-421`
- [x] B2 — VIỆC 2: N.2 `3 path cố định`**`4 path cố định`** (+`.claude/sessions/`) → `:406` (+N.3 `:407` gỡ literal stale, giữ sự-thật lịch-sử)
- [x] B3 — VIỆC 3: verify `scripts/distill-shard-probe.ps1` vs N.8 → **(i)(ii)(iii) PASS · (iv) NỬA** (chi-tiết dưới) — KHÔNG sửa script
- [x] B4 — VIỆC 4: fault-inject 2-chiều `scripts/nhip-no-probe.ps1` (KHÔNG đổi code) → **2/2 chiều PASS**
- [x] B5 — acceptance greps chạy thật, output dán dưới
- [x] B6 — guard LUẬT-CỨNG: 0 file `src/` `fe-*` `tests/` trong diff
---
## B0 — baseline đo TƯƠI trên đĩa (TRƯỚC khi sửa)
```
$ grep -n '3 path cố định' docs/governance/harness-11-engine.md
406:- **N.2 Hai tầng ghi (🔴):** … `git add` per-path 3 path cố định {`.claude/WAL.md` · `.claude/agent-memory/` · `.claude/workflows/runs/`} …
407:- **N.3 …** commit `12071c5 "wal: flush 20260712T1105"` chứa ĐÚNG 4 file thuộc 3 path cố định (…)
⇒ 🔴 v2 §C2b-EXT chỉ liệt N.2. Đĩa có **2 site** trong cùng file (N.2 luật-sống + N.3 bằng-chứng-lịch-sử).
$ grep -c '4 surface' docs/governance/harness-11-engine.md
0 <-- baseline = 0. Header "4 surface" nằm ở `scripts/nhip-no-probe.ps1:6-7`, KHÔNG ở file này.
⇒ acceptance "không giảm" = giữ 0 (no-op). ĐƯỜNG-CHẾT tôn-trọng: KHÔNG đụng header/`4 điểm lệnh`.
$ grep -n 'N\.8' docs/governance/harness-11-engine.md
(0 dòng) <-- N.8 chưa tồn-tại; PHẦN N = N.1…N.7 (dòng 405411). Số N.8 do lead CHỐT, worker KHÔNG tự chọn.
$ grep -rn 'nhip-no-probe.ps1' .claude/commands/
pause.md:44 · session-end.md:104 · session-end.md:131(tham-chiếu) · session-start.md:216 · tiep.md:112
⇒ **4 FILE caller THẬT** → header "4 surface" ĐÚNG. Tiền-đề v1 "→2" đã bị bác, KHÔNG đụng.
```
---
## B1 — VIỆC 1: §N.8 (`docs/governance/harness-11-engine.md:413-421`)
Chèn NGAY SAU N.7, TRƯỚC đoạn "Honest nấc §N". Cấu-trúc:
| thành-phần | nội-dung neo |
|---|---|
| 4 vế | (i) read-only · (ii) KHÔNG spawn con · (iii) KHÔNG write · (iv) lỗi → `probe-loi (khong chan)` → ĐI TIẾP 🔴 **[LOAD-BEARING]** |
| **FLOOR** 🔴 | **read-only** · **non-blocking** (fail-open + no-hang + `exit 0` mọi nhánh) · **gỡ-được-không-hậu-quả** — kèm **phép thử probe ⟂ gate**: gỡ lời-gọi mà hành-vi ĐỔI ⇒ nó là gate (§E.3), không phải probe |
| **FORM** 🟡 | wording token (ASCII-only gotcha #30) · số vế/format dòng-nợ · vị-trí gọi · **interpreter = em-main đọc dòng in**, KHÔNG OS-gate (nhất-quán CAVEAT No-OS-hook) |
| tập-cấm reword | "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Ỏ** §N.8, **CẤM chép predicate 2 nơi** (B1) |
| trạng-thái đo S146 | `nhip-no-probe.ps1` ✅ 4/4 vế · `distill-shard-probe.ps1` FLOOR-đủ / FORM-thiếu (vế-iv nửa) |
```
$ grep -n 'N\.8' docs/governance/harness-11-engine.md
413:- **N.8 Probe-tại-điểm-dừng — predicate 4-vế (🔴 FLOOR + 🟡 form) — LUẬT-HOME của C7 (hub-answer, adopt S146):** …
418: - **FLOOR (🔴 bất-biến — port-nguyên khi tailor, 3 tính-chất):** **read-only** · **non-blocking** …
420: - **Reword tập-cấm (🔴 KHÔNG phải cấm-tất):** …
$ grep -no 'FLOOR (🔴 bất-biến[^)]*)\|read-only\*\* · \*\*non-blocking\*\*[^·]*· \*\*gỡ-được-không-hậu-quả\*\*\|FORM (🟡 tailor được)' docs/governance/harness-11-engine.md
418:FLOOR (🔴 bất-biến — port-nguyên khi tailor, 3 tính-chất)
418:read-only** · **non-blocking** (fail-open + no-hang + `exit 0` mọi nhánh) · **gỡ-được-không-hậu-quả**
419:FORM (🟡 tailor được)
$ grep -no 'CHO PHÉP probe read-only non-blocking theo N.8' docs/governance/harness-11-engine.md
420:CHO PHÉP probe read-only non-blocking theo N.8
```
🔸 **Seam A↔CE:** worker-2 chèn dòng TRỎ `§N.8``pause.md:44` / `tiep.md:112`. Worker-1 **KHÔNG đụng 2 file đó** (DISJOINT-FILE) — số §N.8 = lead chốt, khớp.
---
## B2 — VIỆC 2: N.2 cardinality 3→4 (`:406`) + N.3 de-stale (`:407`)
**Sửa 1 — N.2 (LUẬT GỐC hook thi-hành):**
```
$ grep -no '4 path cố định\*\* {[^}]*}' docs/governance/harness-11-engine.md
406:4 path cố định** {`.claude/WAL.md` · `.claude/agent-memory/` · `.claude/workflows/runs/` · `.claude/sessions/`}
```
+ thêm clause lineage cuối N.2: *"🔄 Cardinality 3→4 @S146 … 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` · 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."*
**Sửa 2 — N.3 (bằng-chứng LỊCH-SỬ, xử KHÔNG falsify):** câu cũ *"chứa ĐÚNG 4 file thuộc **3 path cố định**"* mô-tả commit `12071c5` @S111.
→ đổi thành *"chứa ĐÚNG 4 file thuộc tập path cố định **lúc S111** (… — khi đó `.claude/sessions/` chưa tồn-tại; tập hiện-hành = N.2 bản 4-path @S146)"*.
**Lý-do KHÔNG đơn-giản đổi 3→4:** đổi số = **bịa lịch-sử** (commit đó KHÔNG hề phủ `sessions/`). **Lý-do KHÔNG để nguyên:** file này là **LIVE PRESCRIPTIVE** (C2b-EXT hàng 3) — không nằm trong tập 🧊 LỊCH-SỬ được miễn (adap-reports · diary vai · `WAL.md`); để literal "3 path cố định" sống trong luật-home = dạy sai + fail acceptance. Cách vá giữ **cả** sự-thật lịch-sử **và** con-trỏ tới tập hiện-hành ⇒ KHÔNG phải "rời tập-đo" (nội-dung được LÀM ĐÚNG, không phải đổi hình-dạng để né grep).
```
$ grep -n '3 path cố định' docs/governance/harness-11-engine.md
(rc=1 ; 0 dòng = PASS)
$ grep -n '3 path\|3 điểm mù\|exactly 3 paths' docs/governance/harness-11-engine.md # pattern C2b-EXT đầy-đủ
(rc=1 ; 0 dòng = PASS)
$ grep -c '4 surface' docs/governance/harness-11-engine.md
0 # = baseline, KHÔNG giảm (PASS; "4 surface" vốn không ở file này)
```
---
## B4 — VIỆC 4: fault-inject 2-chiều `scripts/nhip-no-probe.ps1` (KHÔNG đổi code)
Script không sửa (catch tổng `:203-208``Write-Host 'probe-loi (khong chan)'`; `exit 0` `:208` unconditional). Chứng bằng **CHẠY THẬT**, bọc `timeout 60` để quan-sát **no-hang**.
**(A) chiều LÀNH — chạy bình thường:**
```
$ timeout 60 powershell.exe -ExecutionPolicy Bypass -File "D:\...\scripts\nhip-no-probe.ps1"; echo "EXIT=$?"
NHIP-NO: kiem light 3/6 deep 3/15 ok | tran-bo-nho 1 over-cap | run-chua-gom 3 | pull-cach 0 ngay
EXIT=0
```
⇒ dòng NHIP-NO **đầy-đủ 4 vế**, exit 0, trả ngay (không chạm trần timeout).
**(B) chiều LỖI — ép `-RepoRoot` bậy (đường dẫn không tồn-tại):**
```
$ timeout 60 powershell.exe … -File "…\nhip-no-probe.ps1" -RepoRoot "D:\__khong-ton-tai-S146__"; echo "EXIT=$?"
probe-loi (khong chan)
EXIT=0
```
**(B2) biến-thể LỖI — RepoRoot TỒN-TẠI nhưng RỖNG (thiếu `.session-counter.json`):**
```
$ timeout 60 powershell.exe … -File "…\nhip-no-probe.ps1" -RepoRoot "<TEMP>\s146-empty-root"; echo "EXIT=$?"
probe-loi (khong chan)
EXIT=0
```
**vế-(iv) GIỮ ĐƯỢC**: in đúng token `probe-loi (khong chan)`, `exit 0`, **KHÔNG treo** (2 vector lỗi khác nhau: path-không-tồn-tại ⟂ path-tồn-tại-nhưng-thiếu-file ⇒ không phải may một nhánh). **Boundary teeth:** chiều LÀNH in nội-dung THẬT (không phải cùng token) ⇒ token lỗi không phải dương-giả.
---
## B3 — VIỆC 3: `scripts/distill-shard-probe.ps1` vs N.8 (CHỈ BÁO-CÁO, KHÔNG SỬA)
| vế N.8 | phán | bằng-chứng đọc-mã / chạy-thật |
|---|---|---|
| (i) read-only | ✅ PASS | chỉ `Test-Path` · `[IO.File]::ReadAllText` `:24` · `ConvertFrom-Json` `:25` · `Get-ChildItem` `:35,38` · `Write-Output`. 0 mutation. |
| (ii) KHÔNG spawn con | ✅ PASS | `grep -nE 'Start-Process\|Invoke-Expression\|Start-Job\|git '` = 0 hit mã-lệnh (chỉ hit comment/`Write-Output` chuỗi). |
| (iii) KHÔNG write | ✅ PASS | `grep -nE 'Set-Content\|Add-Content\|Out-File\|New-Item\|Remove-Item\|>>'` = 0 hit mã-lệnh. |
| (iv) lỗi→token→đi-tiếp | ⚠️ **NỬA** | nhánh **có-xử** OK · nhánh **exception** KHÔNG bắt ⇒ stderr + **exit 1**, KHÔNG in token. |
**Chạy thật 3 ca:**
```
$ timeout 60 powershell … -File "…\distill-shard-probe.ps1" # LÀNH
SHARD-PROBE: pending=15 | nguong=15 => IM
EXIT=0 ✅
$ timeout 60 powershell … -File "…\distill-shard-probe.ps1" -RepoRoot "D:\__khong-ton-tai-S146__"
Resolve-Path : Cannot find path 'D:\__khong-ton-tai-S146__' because it does not exist.
At …\distill-shard-probe.ps1:18 char:15
+ $root = (Resolve-Path $RepoRoot).Path
EXIT=1 ⚠️ KHÔNG in `probe-loi (khong chan)`
$ timeout 60 powershell … -File "…\distill-shard-probe.ps1" -RepoRoot "<TEMP>\s146-empty-root"
SHARD-PROBE: khong thay memory-budget.json -> probe-loi (khong chan)
EXIT=0 ✅ (nhánh CÓ-XỬ `:23`)
```
**Chẩn gốc:** `$ErrorActionPreference = 'Stop'` `:17` + **KHÔNG có try/catch tổng** ⇒ mọi terminating-error thoát nguyên (2 vector rõ: `Resolve-Path` `:18` với `-RepoRoot` bậy · `ConvertFrom-Json` `:25` khi JSON hỏng).
**Phán theo FLOOR/FORM:** **FLOOR ĐỦ** (read-only ✅ · non-blocking thực-tế ✅ — thoát ngay, no-hang, và caller `session-start.md:135` là em-main-đọc-dòng chứ không phải OS-gate nên exit≠0 không chặn phiên · gỡ-được-không-hậu-quả ✅ — gỡ lời-gọi chỉ mất INFORM sleep-check). **FORM THIẾU** (token vế-iv vắng ở nhánh exception; exit-code lệch contract "exit 0 mọi nhánh").
**Đề-xuất vá (KHÔNG tự làm — ngoài file sở-hữu):** bọc thân `:18-71` trong `try{…}catch{ Write-Output 'probe-loi (khong chan)' }` + `exit 0` cuối, y hệt `nhip-no-probe.ps1:203-208`. 1 sửa, ~4 dòng, 0 đổi hành-vi nhánh lành.
🔸 **Side-observation (ngoài scope, KHÔNG sửa):** `.claude/commands/sleep-recovery-memory-l2.md:52` khai `distill-shard-probe.ps1` chạy ở **cả** `/session-start §2.1.2` **và** `/session-end §L.b(c)`; nhưng `grep -n 'distill-shard-probe\|SHARD-PROBE' .claude/commands/session-end.md` = **0 hit** ⇒ vế "session-end" có mùi **ghost-wire class-2 (defined-but-unread)** H18. Chỉ báo, lead quyết.
---
## B5/B6 — Acceptance + guard (chạy thật)
```
$ grep -n 'N.8' docs/governance/harness-11-engine.md → 413 / 418 / 420 ✅
$ grep -n '3 path cố định' docs/governance/harness-11-engine.md → 0 dòng ✅
$ grep -c '4 surface' docs/governance/harness-11-engine.md → 0 (= baseline) ✅ không giảm
$ git diff --stat -- docs/governance/harness-11-engine.md
docs/governance/harness-11-engine.md | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
$ git diff --name-only | grep -E '^(src/|fe-admin/|fe-user/|tests/)' → rc=1, 0 hit ✅ governance-only
```
`git status --short` lúc kết: `M docs/governance/harness-11-engine.md` (của tôi) + `M .claude/commands/session-end.md`, `M .claude/governance/.session-counter.json` (**worker khác**, không đụng) + 2 file `sub-*.md` untracked. **0 commit / 0 git add / 0 push** (lead lo).
## ĐƯỜNG-CHẾT đã tôn-trọng
- KHÔNG sửa header "4 surface" / "4 điểm lệnh" (tiền-đề v1 đã bị bác; đo lại 4 caller THẬT).
- KHÔNG sửa `scripts/*.ps1` (VIỆC 3 + 4 đều report-only / run-only).
- KHÔNG đụng `pause.md` / `tiep.md` (worker-2 sở-hữu) — chỉ nêu trong N.8 rằng command TRỎ §N.8.
- KHÔNG chép predicate sang file thứ 2 (B1).