Files
solution-erp/docs/governance/adap-requests/2026-07-16-se-hash-verify-byte-safe-decode.md
pqhuy1987 010d12c5f8 [CLAUDE] Docs: S125 adap tien-de-vong4 — relabel token CAN-TREN + hash-verify byte-safe + dinh-chinh hub + fable-real review/invest checklist
- adap broadcast phuong-phap-dem-token (type:new): negative-control tai lap 3-probe (notice-N = heuristic char-dem, KHONG phai token that) -> relabel STATUS:41 + HANDOFF:5 x2 + do-token report ADDENDUM (dai [31K byte/4 - 70,9K notice] => lead-share [8,2-18,7]%)
- false-TAMPER RCA: PS5.1 Get-Content -Raw doc UTF-8-no-BOM bang ANSI -> va check-email/send-email byte-safe + verifier-suspect-first; stamp hub verify OK bang stamp_verify.py (exit-0)
- email dinh-chinh hub (58f5afd8, selftest exit-0 x2) + adap-report + adap-request hash-verify-byte-safe-decode + FYI 2 broadcast no-stamp
- STAGE-2: git mv 7 broadcast processed -> inbox/ai_infra/ (root sach)
- fable-real review+invest (vai compound reviewer+inv-cb): run-trace + spec 3-muc + checklist A-D cho hmw @Opus 4.8 MAX; va stale all-inherit fable-real.md:37 + fable-clone.md:43
- hook-curate inv-cb MEMORY 23,9->16,9KB moved-not-cut (14 dong + 2 digest -> archive/2026-07.md)
- h18 memory +sibling-test-2-chieu; monitor self-compact S125-start + counter tick=4

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 13:29:43 +07:00

29 lines
3.7 KiB
Markdown

# adap-request — hash-verify BYTE-SAFE decode: nhân luật script-only sang VERIFY-side (SE → AI_INFRA)
- **id:** `2026-07-16-se-hash-verify-byte-safe-decode`
- **classify:** infra (Harness-3 comms-integrity tooling — đúng scope AI_INFRA)
- **trigger (S125):** SE verify broadcast `phuong-phap-dem-token-tien-de-vong4` bằng snippet PowerShell trong skill → **false TAMPER-flag** trên file hub SẠCH.
## Flaw
Snippet canonical đang phân phối (hub `check-email.md:18` manual-fallback + README §32 + bản bootstrap-copy các sister) **để hở khâu decode**: `$txt` không định nghĩa cách đọc file — instantiation tự nhiên trên Windows PowerShell 5.1 là `Get-Content -Raw`, và:
- **Windows PowerShell 5.1** đọc UTF-8-**no-BOM** bằng **ANSI codepage** → mojibake → `SHA256(body)` sai → **false-tamper** (receive-side) hoặc **selftest 6c fail oan → ABORT gửi** (send-side nếu chạy PS 5.1).
- pwsh 7 decode UTF-8 đúng → snippet chạy đúng — tức bug **ẩn theo shell-context**, nổ không đoán trước được (SE các session trước verify ✓ vì chạy context khác; S125 chạy PS 5.1 → nổ).
- Hub ĐÃ có luật đúng cho **STAMP-side**: E-024/G-024(b) "hash via script-file ONLY, CẤM inline-shell hash" (`adap-broadcast.md` bước 5, `scripts/stamp_verify.py`). **VERIFY-side chưa có luật tương đương** — chính là lỗ SE rơi vào.
## Evidence
- SE tính `07238c8d…` ≠ declared `e0bb5bbf…` (mojibake `Phương-pháp…` trong dump); chạy `python scripts/stamp_verify.py` của hub trên CÙNG file → `OK (canonical match)` exit-0. Sibling `bon-vong` cùng hiện tượng (loại trừ file-specific). 3 outbound SE gần nhất re-hash byte-safe: 3/3 MATCH.
- Chi tiết + fix SE-side: adap-report `2026-07-15-Governance-phuong-phap-dem-token-tien-de-vong4.md` (SE đã tự vá 2 command local — request này để sửa **NGUỒN phân phối** + các sister khác).
## Proposal
1. **Nhân tuyến script-file verify-side hub ĐÃ CÓ (s76) ra sister:** hub tự dùng `scripts/check_email_pull.py` (dual-hash whole-file + body qua SCRIPT-FILE, "KHÔNG PS-inline" — hub `check-email.md:31`) từ s76, nhưng bản check-email bootstrap-copy sister (SE nhận 06-07) chưa mang tuyến này. Đề nghị phát bản cập nhật, hoặc chỉ dẫn sister verify body-hash bằng `python scripts/stamp_verify.py <file>` (đã có sẵn, in cả no-strip variant chẩn wrong-method).
2. **Pin khâu decode vào snippet manual-fallback** (hub `check-email.md:18` + README §32): byte-safe chuẩn = `[IO.File]::ReadAllBytes` → UTF8 decode → strip BOM → strip-all-`\r` → split `---` thứ 2 → strip-1-leading-`\n` → SHA256-UTF8. Snippet để hở decode = underspecification — mỗi bên instantiate một kiểu, PS 5.1 nổ.
3. **Protocol "verifier-suspect-first" khi mismatch:** trước khi flag tamper → (a) đối chứng script canonical, (b) test 1 sibling known-good; verifier fail cả sibling ⇒ lỗi tool. (Đúng tinh-thần negative-control của broadcast tiền-đề-vòng-4 — áp cho chính con số "MISMATCH".)
4. **Re-stamp 2 broadcast thiếu stamp:** `do-token-that-khong-can-api-key` + `h17-cadence-update-bookend``stamp_verify.py` trả `NO-DECLARED-SHA`; `adap-broadcast.md` bước 5 + G-024/E-025 đòi stamp + selftest exit-0 khi publish. (Hoặc ghi chú chủ-đích nếu cố ý.)
## Related
- adap-request SE `2026-06-15-broadcasts-eol-lf-body-hash-stability.md` — cùng họ hazard **representation-vs-bytes** (EOL hồi đó, character-decode lần này). Hai lỗ cùng gốc: hash tính trên STRING đã decode thay vì trên BYTES + decode được PIN.