20B-P2 — Context-Pack KB Delete Manifest Dry-Run Prompt
20B-P2 — Context-Pack KB Delete Manifest (Dry-Run)
Date: 2026-05-05 | Status: PROMPT — chờ dispatch Controlling: GPT P2 directive + gate structure P1✅→P2→P3→P4 Scope: Lập danh sách chính xác docs cần xóa. KHÔNG xóa. Prior: 20B-P1 PASS — vòi đã khóa
§0. Mission
Lập manifest xóa: liệt kê từng doc dưới prefix context-pack/ trên KB, kiểm recovery basis (FS + PG), đánh dấu delete candidate. Không xóa gì.
§1. Pre-read
Đọc 4 tài liệu từ KB:
knowledge/dev/laws/dieu44-trien-khai/reports/20b-p1-stop-context-pack-kb-upload-report.mdknowledge/dev/laws/dieu44-trien-khai/reviews/opus-review-20b-p1-report-and-p2-proposal-2026-05-05.mdknowledge/dev/laws/dieu44-trien-khai/reviews/gpt-review-20b-p1-report-and-p2-directive-2026-05-05.mdknowledge/dev/laws/dieu44-trien-khai/reports/20a-20b-p0-search-vector-hygiene-inspection-report.md
§2. Thu thập dữ liệu — KB docs
Dùng Agent Data list_documents(path="context-pack/") để lấy full list.
Ghi lại:
- Total count
- Mỗi doc:
document_id(= path)
Parse build_id từ path pattern context-pack/<build_id>/<filename>.
Group by build_id → đếm docs/build.
§3. Thu thập dữ liệu — Recovery basis
3.1 Filesystem (batch — 1 lệnh)
# Lấy tất cả build dirs trên FS
ls -d /opt/incomex/context-pack-staging/*/ 2>/dev/null | sed 's|.*/\(.*\)/|\1|' | sort > /tmp/fs_builds.txt
wc -l /tmp/fs_builds.txt
head -5 /tmp/fs_builds.txt
tail -5 /tmp/fs_builds.txt
3.2 PG manifest (batch — 1 query)
docker exec -i postgres psql -U directus -d directus <<'SQL'
-- Tất cả builds trong manifest với status + section count
SELECT
m.build_id,
m.publish_status,
m.kb_mirror_status,
m.health_status,
m.logical_checksum_sha256 IS NOT NULL AS has_checksum,
count(s.id) AS section_count
FROM context_pack_manifest m
LEFT JOIN context_pack_sections s ON s.manifest_id = m.id
GROUP BY m.build_id, m.publish_status, m.kb_mirror_status, m.health_status, m.logical_checksum_sha256
ORDER BY m.build_id;
SQL
Lưu output → so khớp với KB build list.
3.3 Cross-reference
Với mỗi build_id từ KB list:
- FS tồn tại? → check trong
/tmp/fs_builds.txt - PG manifest row tồn tại? → check trong PG query output
- PG section rows? →
section_counttừ query
§4. Build manifest table
Mỗi document trong list phải có:
| Field | Mô tả |
|---|---|
document_id |
Path đầy đủ trên KB |
build_id |
Parse từ path |
filename |
Tên file (e.g. PROJECT_MAP.md) |
delete_candidate |
true / false |
reason |
Vì sao xóa hoặc giữ |
recovery_status |
fs+pg / pg_only / fs_only / missing_recovery |
would_keep_if_latest_only |
true nếu build này = latest complete build, false nếu không |
Latest complete build = build có nhiều sections nhất trong số builds gần nhất (dự kiến 20260504-040018-372b48 với 9 files, nhưng confirm từ data thực).
Delete candidate logic:
- Tất cả docs =
delete_candidate=true(vì P1 đã khóa upload, KB mirror không còn reader) would_keep_if_latest_only= column phụ để GPT/User có option giữ latest nếu muốn
§5. Validation checks
-
Không có doc non-context-pack lẫn vào: Mọi
document_idphải bắt đầu bằngcontext-pack/. Nếu có doc không khớp → flag, không đưa vào delete list. -
Count check: So sánh actual count với 1.174 (từ report trước). Nếu khác → giải thích drift (e.g. build mới chạy giữa chừng trước P1 khóa vòi). Không auto fail.
-
Recovery coverage: Bao nhiêu % builds có
fs+pg? Nếu có buildmissing_recovery→ flag riêng, vẫn liệt kê nhưng ghi cảnh báo.
§6. Report
Upload tại: knowledge/dev/laws/dieu44-trien-khai/reports/20b-p2-context-pack-kb-delete-manifest-dryrun-report.md
Report structure:
# 20B-P2 — Context-Pack KB Delete Manifest (Dry-Run)
## Summary
- Total KB docs under context-pack/: [N]
- Drift from 1.174: [explain if any]
- Total builds: [N]
- Builds with fs+pg recovery: [N] / [total]
- Builds with missing_recovery: [N] (list)
- Latest complete build: [build_id] ([N] files)
- Non-context-pack docs found: [0 / list]
## Build summary table
| build_id | kb_docs | fs_exists | pg_manifest | pg_sections | recovery_status | is_latest_complete |
|---|---|---|---|---|---|---|
## Full document manifest
| document_id | build_id | filename | delete_candidate | reason | recovery_status | would_keep_if_latest_only |
|---|---|---|---|---|---|---|
(Nếu >200 rows, ghi top 20 + bottom 20 + summary stats. Full list có thể ghi file VPS nếu cần.)
## Decision for GPT/User
- Option A: Delete ALL [N] docs (KB mirror fully redundant)
- Option B: Delete all except latest complete build ([N-9] docs)
- Recommendation: [A or B + lý do]
§7. Hard Boundaries
- ❌ Không deleteDocument
- ❌ Không deindex
- ❌ Không DOT patch
- ❌ Không Đ43 patch
- ❌ Không cron
- ❌ Không filesystem cleanup
- ❌ Không service restart
- ❌ Không Pack 2C/IU
- ❌ Không hỏi lại User
§8. Nôm na
Lập sổ kiểm kê từng bản photocopy cũ trên kệ: bản nào, thuộc đợt nào, có bản gốc trong kho lạnh không, có ghi sổ không. Cuối cùng đề xuất: xóa hết hay giữ đợt mới nhất. Chưa dọn gì.
20B-P2 Prompt | 2026-05-05 | Dry-run manifest only. No delete. Chờ dispatch.