KB-26E6 rev 12

00 — Điều 45 PG-Native Queue Law Draft — Summary (v0.2.1)

11 min read Revision 12
dieu45-draftsummaryqueue-lawv0.2.1v0.2-draftcouncil-review-round-1-addressedcouncil-review-pending-round-2user-approval-required

00 — Điều 45 PG-Native Queue Law Draft — Summary

Date: 2026-05-26 (revised at enactment — Điều 45 v1.0 BAN HÀNH) Status: v1.0 BAN HÀNH (ENACTED 2026-05-26) — User approval pass. Có thể trích dẫn như luật từ thời điểm này. Folder draft này chuyển sang historical archive sau enactment; mọi thay đổi tiếp theo phải qua amendment process. enactment_approved=true, user_approval_date=2026-05-26. v0.1 → v0.2 diff: 5 patch (§6.6 event_vs_job, §6.7 work_state_machine, §11.5 executor_boundary, §13.4 MOT clause, §15.5 silent_gap/heartbeat invariant) — xem 06-gpt-council-review-patch-v0-2.md. v0.2 → v0.2.1 diff: 3 cleanup fix (KB metadata sync, council wording an toàn, MOT KHÔNG là executor) — xem 07-v0-2-1-cleanup-patch.md. v0.2.1 → v1.0 BAN HÀNH: label-only state flip (DRAFT → ENACTED). KHÔNG sửa nội dung — xem enactment report knowledge/current-state/reports/dieu45-pg-native-queue-law-v1-0-enacted-2026-05-26.md. Law file: knowledge/dev/laws/dieu45-pg-native-queue-and-task-orchestration-law.md Survey basis: knowledge/dev/laws/dieu44-trien-khai/v0.6-system-wide-pg-native-queue-law-readiness-survey/ (PASS 2026-05-26). Drafting input: GPT proposal 2026-05-26 (received in mission prompt).


§1. Mục tiêu draft

Phát biểu 8 bất biến tối thiểu cho mọi cơ chế hàng đợi hệ thống (events / tasks / messages / jobs / trigger-in / trigger-out / customer-care future / MOT future / vector sync / staging cleanup / Information Unit two-way) trên nền PostgreSQL — KHÔNG mở rộng phạm vi qua MARK→CUT của IU như Điều 44 trien-khai hiện làm.

Draft này:

  • Ratify substrate hiện hành (event_outbox 131k+, worker, dead-letter, lease, SQL route, staging) — không phá vỡ.
  • Phát biểu ranh giới mới (signal-not-data, executor layer split, no-vector-transient nâng lên mức luật).
  • Mở chỗ cho 7 sub-design pack tương lai (pg_cron, job substrate, retry policy, NOTIFY bridge, trigger-IN vocab widening, subscription config, event_outbox partitioning).
  • KHÔNG decide các câu hỏi mở (21 câu chuyển sang design pack hoặc Council).

§2. 22 sections của law draft

§ Nội dung
§0 Tóm tắt điều hành (8 nguyên tắc cốt lõi)
§1 Mục đích + phạm vi (4-nhóm A/B/C/D, system-wide không phải cut-only)
§2 Định nghĩa (14 thuật ngữ)
§3 Áp dụng hệ thống — vocab thống nhất, no per-domain outbox
§4 Hàng đợi mang signal, không data (payload_ref pattern, hard CHECK)
§5 Nguyên tắc PG-native (PG là SoT, primitive allowed/forbidden, pg_cron boundary)
§6 Vocab vòng đời (event 9-domain × 7-stream × 2-lane, staging 7-state, DOT 3-mode × 5-status, inclusion criteria 7+7) + §6.6 event_vs_job + §6.7 work_state_machine (v0.2)
§7 Idempotency + dedup (3 lớp defense)
§8 Retry + lease + dead-letter (refusal contract liên kết D31)
§9 Scheduling + delayed execution (no pg_cron clause)
§10 Batch processing
§11 Worker / Agent / DOT / Hermes executor boundary (3-layer split) + §11.5 executor_boundary clause (v0.2) + MOT trong not_executors (v0.2.1)
§12 Trigger-in / Trigger-out (IU two-way bridge, generic vocab)
§13 Customer-care / email / MOT future scope (design seam, không Phase 1) + §13.4 Mother of Task clause strengthened (v0.2) + MOT.is_executor=false codified (v0.2.1)
§14 No-vector-in-transient — ratify D36 NVSZ 4-layer guarantee ở mức luật
§15 Observability + audit + healthcheck (liveness contract) + §15.5 silent-gap/heartbeat runtime invariant (v0.2)
§16 Compatibility matrix với Điều 30/31/35/36/37/44 + D36 NVSZ
§17 Mẫu bị cấm (14 hard-reject + 3 soft-warn)
§18 Kỷ luật triển khai (luật/design/triển khai tách biệt, 7 sub-design packs)
§19 Câu hỏi mở (21 routed)
§20 Điều khoản chuyển tiếp (substrate hiện hành tiếp tục, version-neutral)
§21 Cross-reference 13 luật
§22 Verification block (v1.0: phase_status=ENACTED, version=v1.0, ban_hanh=true, council_approved=true, enactment_approved=true, user_approval_date=2026-05-26, enactment_date=2026-05-26)

Total length: ~56 kchars sau patch v0.2.1.


§3. Quyết định bổ sung của Claude (vs GPT proposal)

GPT đề xuất 20 sections. Claude đã giữ 100% đề xuất GPT và bổ sung thêm:

  1. §0 Tóm tắt điều hành — bắt buộc theo pattern của Điều 31/35/37 hiện hành.
  2. §2 Definitions mở rộng từ 10 mục GPT đề xuất lên 14 mục (bổ sung: queue substrate, safe_payload, delivery_lane, event_stream, event_domain, correlation_id) — vì những thuật ngữ này xuất hiện CHECK-cứng trên PG và phải có định nghĩa luật rõ.
  3. §6.4 Inclusion criteria 7+7 — ratify rubric 23-P3D4C0X §M.3 ở mức luật, vì đây là ranh giới giữa "đủ điều kiện vào queue" và "activity log thường" — không có rubric thì queue sẽ trôi thành activity log (đúng cảnh báo của doc gốc).
  4. §11.1 Three-layer ASCII diagram (Producer / Queue / Executor) — vì §11 boundary là mới và cần trực quan.
  5. §17 Anti-patterns table với 14 hard-reject + 3 soft-warn — vì luật cần áp lực rõ ràng để enforce. Đề xuất GPT có "Prohibited patterns" tổng quát, Claude cụ thể hoá.
  6. §19 Open questions cross-link với 21/28 câu trong survey 08-… để tránh duplicate.
  7. §22 Verification block — bắt buộc theo pattern của các luật ban hành (D31/D35/D37).

Claude KHÔNG bác bỏ bất kỳ phần nào của GPT proposal. Tuy nhiên có 2 điểm Claude diễn giải khác (xem §6 dưới đây).


§4. Điểm cốt lõi khác biệt vs proposal GPT

Mục GPT proposal Claude draft Lý do
Tên Vietnamese "Luật Hàng Đợi & Điều Phối Tác Vụ PG-native" Giữ nguyên OK
Section count 20 22 (thêm §0 + §22) Đồng nhất với pattern law hiện hành (D31/D35/D37 đều có §0 + verification block)
Customer-care/email/MOT "future scope" "design seam only — KHÔNG normative Phase 1" Để tránh đẩy substrate ra trước khi có spec rõ (xem §13.3). Customer-care domain chưa có table; nếu nâng lên normative giờ thì luật sẽ governs cái chưa tồn tại — tạo lỗ hổng.
Pub/Sub clone clause "Do not model the law as Google Pub/Sub clone" Đặt ở §0 + §17 hard-reject (distributed queue ngoài PG) Reframe theo hướng dương: nêu primitive PG được phép thay vì cấm Pub/Sub bằng tên.
PG18 "stay on 16.13 for queue law" §5 + §20.5 + §22 Phát biểu rõ luật version-neutral sau ban hành — feature PG 18 OK dùng trong design pack nhưng không là tiền điều kiện luật.
Transitional clause §20 §20 + §3.3 (fn name preservation) + §18.2 (Phase 1 không tạo bảng mới) Mở rộng để xử lý 2 risks survey nêu: tên hàm fn_iu_* cho domain rộng hơn, 4-day worker silent gap.

§5. Mức độ bao phủ Pass-Criteria của mission

Pass criterion Trạng thái
Điều 45 draft exists …/dieu45-pg-native-queue-and-task-orchestration-law.md (v0.2.1 rev 16)
Law placement rationale clear ✅ §16 + report 01 (mirror)
Covers tasks/messages/events/trigger/customer/email/MOT ✅ §1.2 (4 nhóm); customer/email/MOT là §13 design seam
PG-native principles explicit ✅ §5 + §17 hard-rejects
Queue carries signal not data ✅ §4
Compatibility 30/31/35/36/37/44 explicit ✅ §16 + report 03
PG16 vs PG18 clear ✅ §0 + §5.4 + §20.5 + §22
Open questions listed ✅ §19 + report 04
Event vs Job distinction (v0.2) ✅ §6.6
Work state machine invariant (v0.2) ✅ §6.7
Executor boundary (v0.2) ✅ §11.5
MOT clause strengthened (v0.2) ✅ §13.4
Silent-gap/heartbeat invariant (v0.2) ✅ §15.5
MOT not an executor (v0.2.1) ✅ §11.5 not_executors + §13.4 is_executor:false
Council wording safe (v0.2.1) ✅ §22 patch_applied + enactment_approved=false
Metadata title/tags synced (v0.2.1) ✅ KB title v0.2.1 + tags v0.2.1/v0.2-draft
KB upload/list/search verified ✅ (verified post-each-patch)
No production mutation ✅ Zero DDL/DML — file là markdown

§6. Diễn giải khác — Claude rejected None, but softened 2 GPT requirements

Mission yêu cầu "có quyền bổ sung các thông tin cần thiết, bác bỏ các thông tin không hợp lý". Claude KHÔNG bác bỏ mục nào trong GPT proposal nguyên văn. Hai mục được diễn giải mềm hơn:

§6.1 "Pub/Sub clone" anti-pattern

GPT: "Do not model the law as Google Pub/Sub clone." Claude diễn giải: chuyển từ negative ("không phải X") sang positive ("dùng PG primitive") + giữ negative ở §17 hard-reject (distributed queue ngoài PG).

Lý do: law text bằng tiếng Việt + hệ thống không có người Google. Cấm "clone của Pub/Sub" có thể được hiểu mơ hồ. Cấm "distributed queue ngoài PG làm SoT" rõ ràng và testable.

§6.2 Customer-care / email / messaging normative trong Phase 1

GPT: liệt kê customer-care/email/messaging trong scope. Claude diễn giải: liệt kê là design seam, không phải normative scope tại Phase 1 — vì hệ thống chưa có một bảng customer/email/conversation nào sống.

Lý do: nếu Phase 1 luật quy định vocab cho customer/email/MOT mà chưa có substrate, sẽ phải tạo vocab speculatively. Tốt hơn: luật forward-compatible (§13.2) — khi domain mới mở, đi qua ratification và không cần amend Điều 45 trừ khi vocab fundamentally khác.

Cả 2 mục đều là diễn giải mềm, KHÔNG bác bỏ.


§7. Vấn đề Claude không thể giải quyết trong Phase 1 luật

Claude xác nhận các vấn đề sau để mở trong luật (đẩy sang design pack):

  1. Quyết định pg_cron (D1) — cảnh báo nhưng không cấm/ép.
  2. Quyết định job substrate shape (D2) — phát biểu mở.
  3. max_attempts cụ thể (D4) — phát biểu mở.
  4. NOTIFY bridge yes/no (D5) — phát biểu mở.
  5. Worker cadence cụ thể (Q11/Q25) — phát biểu mở + §15.4 liveness contract.
  6. 21 câu khác trong survey 08-….

Đây không phải vi phạm pass criteria — 08 questions-to-answer-before-design đã được liệt kê.


§8. Non-goals reaffirmed

Phase 1 ban hành luật KHÔNG:

  • Implement queue.
  • Change event_outbox schema.
  • Run migration.
  • Add triggers.
  • Add pg_cron.
  • Change PostgreSQL version.
  • Patch START-HERE cutting operator.
  • Touch MARK/CUT aliases.

File upload là markdown documents — không phải DDL.


§9. Next step

  1. ✅ GPT review round 1 — DONE 2026-05-26 → v0.2 DRAFT patch applied (xem 06-gpt-council-review-patch-v0-2.md).
  2. ✅ v0.2.1 cleanup patch — DONE 2026-05-26 (metadata + council wording + MOT executor boundary) — xem 07-v0-2-1-cleanup-patch.md.
  3. ⏭ Gemini review round 2 — SKIPPED (optional theo Council policy).
  4. User approve — DONE 2026-05-26 → v1.0 BAN HÀNH (xem knowledge/current-state/reports/dieu45-pg-native-queue-law-v1-0-enacted-2026-05-26.md).
  5. ⏭ Post-enactment housekeeping (HK1 architecture index, HK2 cross-ref D36/D44 banners, HK3 worker silent gap audit, HK4 unique index introspect, HK5 iu_notification_event deprecate, MEMORY.md refresh).
  6. ⏭ Dispatch sub-design packs (DP1–DP7 §18.4) — chỉ sau HK1–HK2.

Folder này là historical draft archive sau 2026-05-26. Mọi thay đổi tiếp theo phải qua amendment process trên file luật BAN HÀNH, không phải qua folder này.