KB-B262

20B-P3 — Context-Pack KB Purge Execution Prompt

7 min read Revision 1
vector-hygiene20b-p3purgedeletecontext-packprompt

20B-P3 — Context-Pack KB Purge Execution

Date: 2026-05-05 | Status: PROMPT — chờ dispatch Controlling: GPT Option A decision + gate structure P1✅→P2✅→P3→P4 Scope: Archive 8 orphan docs → delete toàn bộ 1.175 context-pack docs → verify → search regression Prior: P1 PASS (vòi khóa), P2 PASS (manifest 1.175 docs)


§0. Mission

Lau sàn: xóa toàn bộ context-pack docs khỏi KB/vector. Trước khi xóa, lưu 8 docs không có recovery ở đâu khác vào VPS backup.


§1. Pre-read

Đọc 4 tài liệu từ KB:

  1. knowledge/dev/laws/dieu44-trien-khai/reports/20b-p2-context-pack-kb-delete-manifest-dryrun-report.md
  2. knowledge/dev/laws/dieu44-trien-khai/reviews/opus-review-20b-p2-manifest-and-p3-proposal-2026-05-05.md
  3. knowledge/dev/laws/dieu44-trien-khai/reviews/gpt-review-20b-p2-manifest-and-p3-option-decision-2026-05-05.md
  4. knowledge/dev/laws/dieu44-trien-khai/reports/20b-p1-stop-context-pack-kb-upload-report.md

§2. Reconfirm current list

list_documents(path="context-pack/")
  • Count tất cả docs
  • Expected: ~1.175 (có thể ±vài nếu drift)
  • Gate check: Tất cả docs phải bắt đầu bằng context-pack/. Nếu có doc nào không khớp prefix → loại khỏi delete list, flag trong report.
  • Nếu count khác biệt lớn (>10 so với 1.175) → dừng, report anomaly, KHÔNG delete.

§3. Archive 8 missing_recovery docs

Build: 20260418-023221-0bfb97

8 docs cần archive (từ P2 manifest):

context-pack/20260418-023221-0bfb97/ARCHITECTURE.mmd
context-pack/20260418-023221-0bfb97/DB_MAP.md
context-pack/20260418-023221-0bfb97/DOT_REGISTRY.md
context-pack/20260418-023221-0bfb97/ENTITIES_OVERVIEW.md
context-pack/20260418-023221-0bfb97/LAWS_INDEX.md
context-pack/20260418-023221-0bfb97/PROJECT_MAP.md
context-pack/20260418-023221-0bfb97/RED_ZONES.md
context-pack/20260418-023221-0bfb97/project-map.json

Archive steps

# Tạo thư mục archive
mkdir -p /opt/incomex/backups/context-pack-orphans/20260418-023221-0bfb97/

Với mỗi doc: dùng Agent Data get_document hoặc get_document_for_rewrite để lấy full content + metadata → ghi ra file:

# Ví dụ cho mỗi doc:
cat > /opt/incomex/backups/context-pack-orphans/20260418-023221-0bfb97/ARCHITECTURE.mmd <<'EOF'
[full content từ get_document]
EOF

Sau khi ghi 8 files, tạo manifest:

cat > /opt/incomex/backups/context-pack-orphans/20260418-023221-0bfb97/_manifest.txt <<'EOF'
# Archive manifest — 20B-P3
# Build: 20260418-023221-0bfb97
# Archived: [timestamp]
# Reason: missing_recovery — no FS, no PG manifest
# Source: KB Agent Data (pre-purge)

document_id | filename | archived
context-pack/20260418-023221-0bfb97/ARCHITECTURE.mmd | ARCHITECTURE.mmd | yes/no
context-pack/20260418-023221-0bfb97/DB_MAP.md | DB_MAP.md | yes/no
... (8 rows)
EOF

Archive gate

ls -la /opt/incomex/backups/context-pack-orphans/20260418-023221-0bfb97/
# Expected: 8 content files + 1 _manifest.txt = 9 files

Nếu archive không đủ 8 files → KHÔNG tiếp tục delete. Report partial. STOP.


§4. Execute delete

Dùng Agent Data delete_document cho từng doc trong list từ §2.

Batch strategy

  • Xóa theo batch (ví dụ 50-100 docs/batch) nếu API hỗ trợ
  • Hoặc loop từng doc nếu chỉ có single delete
  • Log mỗi delete: document_id + success/fail
  • Không retry vô hạn: nếu 1 doc fail, ghi lại, tiếp tục. Collect failures cuối cùng.

Safety check

  • Chỉ xóa docs có path bắt đầu bằng context-pack/
  • Double-check mỗi document_id trước khi delete
  • Nếu gặp doc không khớp prefix → skip, flag

Progress tracking

Ghi progress mỗi 200 docs:

Deleted 200/1175... 400/1175... 600/1175...

§5. Verify sau delete

list_documents(path="context-pack/")
  • Expected count: 0
  • Nếu còn docs → list document_id còn lại, ghi vào report
  • Nếu count = 0 → PASS

§6. Search regression test

Chạy lại 7 query từ vector hygiene report (Q3):

  1. birth pipeline trigger
  2. DOT registry tool
  3. Điều 35 text unit
  4. orphan ghost entity
  5. universal edges relationship
  6. context pack latest build
  7. legal article amendment process

Với mỗi query, dùng search_knowledge và ghi:

  • Top 5 results (document_id + relevance score nếu có)
  • Bao nhiêu results thuộc context-pack/ (expected: 0)
  • Canonical docs có xuất hiện trong top 5 không

§7. Report

Upload tại: knowledge/dev/laws/dieu44-trien-khai/reports/20b-p3-context-pack-kb-purge-execution-report.md

# 20B-P3 — Context-Pack KB Purge Execution Report

## Archive
- 8 orphan docs archived: yes/no
- Archive path: /opt/incomex/backups/context-pack-orphans/20260418-023221-0bfb97/
- File count: [N]/9 (8 content + 1 manifest)

## Delete execution
- Total docs in delete list: [N]
- Successfully deleted: [N]
- Failed: [N] (list document_ids if any)
- Prefix safety: all docs confirmed context-pack/ prefix

## Post-delete verify
- list_documents("context-pack/") count: [N]
- Expected: 0
- Remaining docs: [list if any]

## Search regression (before → after)

| Query | Before: context-pack in top-5 | After: context-pack in top-5 | Canonical doc in top-5 after |
|---|---|---|---|
| birth pipeline trigger | [N]/5 | [N]/5 | [doc name] |
| DOT registry tool | ... | ... | ... |
| ... | ... | ... | ... |

## Verdict
PASS / PARTIAL / FAIL

## Next
- 20B-P4: FS retention cron (separate prompt)
- Đ43/20C: kb_mirror_status semantics + KB governance

§8. Hard Boundaries

  • ❌ Không DOT patch
  • ❌ Không Đ43 patch
  • ❌ Không cron
  • ❌ Không filesystem cleanup (ngoài ghi orphan archive)
  • ❌ Không search API patch
  • ❌ Không service restart
  • ❌ Không Pack 2C/IU
  • ❌ Không xóa doc nào ngoài prefix context-pack/

§9. Abort rules

Tình huống Hành động
Reconfirm count drift >10 STOP. Report anomaly.
Non-context-pack doc in list Skip doc. Flag. Continue.
Archive <8 files STOP. Không delete. Partial report.
Delete fail rate >10% Pause. Report. Chờ chỉ đạo.
Post-delete count >0 Report remaining. Không retry.

§10. Nôm na

Lau sàn: trước khi lau, lấy 8 tờ giấy duy nhất không có bản gốc → cất vào két sắt. Kiểm két đủ 8 tờ → bắt đầu lau toàn bộ 1.175 tờ. Lau xong kiểm sàn sạch chưa, rồi thử tìm sách trên kệ xem có dễ hơn không.


20B-P3 Prompt | 2026-05-05 | Option A full purge. Archive first. Chờ dispatch.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/prompts/20b-p3-context-pack-kb-purge-execution-prompt.md