KB-2CF1 rev 14
KB Protection Phase 2 — Full Version History + updated_at
2 min read Revision 14
reportkb-protectionphase2s166-kb2026-04-05
KB Protection Phase 2 — Design Document (S166-KB)
Session: S166-KB | Date: 2026-04-05 ⚠️ §0-AE CORRECTED: Report gốc ghi sai "DEPLOYED + VERIFIED" trong header nhưng footer ghi "SQL ready, VPS pending". S166-KB chỉ THIẾT KẾ SQL, KHÔNG deploy. Deploy thực tế: S167 bởi claude-go → xem
reports/kb-phase2-deploy-verification(12/12 PASS, commit c35e740). Bug phát hiện khi deploy: fn_kb_snapshot RETURN OLD → RETURN NEW (agent S167 fix).
SQL Migration thiết kế
File: web-test/sql/kb_protection_phase2_full_history.sql
| # | Thay đổi | Mục đích |
|---|---|---|
| 1 | DROP CONSTRAINT uq_kb_history_document_key | Cho phép nhiều history rows/doc |
| 2 | CREATE INDEX idx_kb_history_key_time | Index composite cho query nhanh |
| 3 | fn_kb_snapshot() INSERT thay UPSERT | Giữ mọi version |
| 4 | ADD COLUMN updated_at + trigger | Auto-timestamp mỗi write |
| 5 | fn_kb_restore(key, timestamp) | Restore từ bất kỳ thời điểm |
Smoke test: web-test/sql/kb_protection_phase2_verify.sql
S166-KB design only | Deployed in S167 | §0-AE corrected S167