KB-275C

03 — Safety Rules

4 min read Revision 1
start-heresafety-rulesabsolute-noguardrailsno-vector-staging-zoneno-bypassno-production-documents

03 — Safety Rules

10 rule cứng. Vi phạm bất kỳ rule nào = dừng ngay, báo operator, không tự sửa.

1. MARK pending data lưu vào No-Vector Staging Zone

iu_core.iu_staging_record + iu_core.iu_staging_payload ❌ KB documents ❌ public.information_unit ❌ Qdrant ❌ Bất kỳ chỗ nào khác

Vì sao: KB là context (đã duyệt + vector hóa). Pending MARK chưa được duyệt — nếu vào KB sẽ bị vector hóa, vi phạm "no-vector-on-staging" và làm bẩn KB.

2. Final report mới upload KB

✅ Sau khi macro PASS + verify đầy đủ ❌ Pending MARK payload (manifest / coverage_proof / mark_report) trong khi đang chạy

Vì sao: Tách "rác đang xử lý" khỏi "trí thức đã duyệt". KB không phải là staging area.

3. Không vector hóa staging payload

Cấm tuyệt đối:

  • INSERT vào iu_vector_sync_point cho bất kỳ staging row nào
  • Gọi Qdrant với staging content
  • Set vector_excluded=false trên iu_staging_record (CHECK constraint chặn)

Vì sao: 4-layer structural guarantee bảo vệ chính rule này. Vi phạm = phá core safety design.

4. Không CUT nếu chưa VERIFY-MARK + approved manifest

Đường duy nhất đến CUT: MARK → VERIFY-MARK (apply=true) → APPROVED → CUT.

G3 (not_approved) sẽ refuse. Cũng cần approved_at, approved_by, approval_doc_id cả ba NOT NULL.

Cấm:

  • Set thủ công iu_staging_record.lifecycle_status='approved' (CHECK constraint sẽ chặn nếu thiếu approved_at/by)
  • Gọi fn_iu_cut_from_manifest với hash bịa
  • Tạo dot_iu_command_run row giả với run_status='applied'

5. Không bỏ qua VERIFY-CUT

Sau mỗi CUT (kể cả BEGIN/ROLLBACK proof), PHẢI chạy:

SELECT fn_iu_op_verify_cut(<run_id>::uuid, 'operator');

Verify-cut kiểm tra: Axis A (source order), Axis B (vocab), Axis C (parent-child), no_vector_ok. Nếu verdict != verified → cut sai → rollback ngay (nếu chưa COMMIT) hoặc báo operator.

6. Không động production_documents

Bảng này KHÔNG tồn tại trong DB directus (đã verify). Nếu câu SQL của bạn chứa "production_documents" → BUG. Dừng, kiểm tra lại scope.

7. Không động Qdrant

Aliases không gọi Qdrant. Bạn cũng không. Vector hóa là một bước riêng do operator quyết định, gated bởi iu_core.composer_enabled + Qdrant write path — cả hai không thuộc phạm vi MARK/CUT operator surface.

8. Không deploy Nuxt

Out of scope tuyệt đối với operator cutting agent.

9. Không enable retention global

❌ UPDATE dot_config SET value='true' WHERE key='iu_core.retention_enabled';
❌ SELECT fn_iu_staging_cleanup(true, ...);

Operator alias chỉ có dry-run (fn_iu_op_cleanup_dry_run). Apply cleanup là operator-direct call ngoài alias.

10. Không dùng prompt dài / macro dài

Toàn bộ vận hành 1 file = 4 lệnh ngắn (MARK + VERIFY MARK + CUT + VERIFY CUT). Nếu bạn thấy đang viết prompt >50 dòng để cut 1 file → bạn làm sai. Dừng, đọc lại 01-short-command-cheatsheet.md.

Quy trình khi vi phạm tình huống

  1. STOP — không tự sửa, không tự bypass.
  2. REPORT — báo operator bằng 1 câu rõ ràng:
    • Rule nào bị vi phạm
    • Lệnh nào gây ra
    • Trạng thái hiện tại (rolled back? committed?)
  3. WAIT — chờ operator quyết định.

Bonus: ranh giới agent

Agent ĐƯỢC Agent KHÔNG ĐƯỢC
Fetch KB source Upload pending MARK vào KB
Author manifest theo 80000x doctrine Bịa cut_manifest digest
Gọi 5 fn_iu_op_* aliases qua psql Gọi fn_iu_cut_from_manifest trực tiếp với hash tự bịa
Mở composer gate qua alias arg UPDATE dot_config thủ công ngoài TX
Dry-run cleanup Apply cleanup
Báo cáo kết quả ngắn Viết "macro" dài cho 1 file
Đọc 100000x + 110000x reports Trích 90000x / 91000x làm tham chiếu vận hành
Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-iu-core-cutting-operator-start-here/03-safety-rules.md