KB-5454 rev 5

05 — Next Design Backlog (Post-Điều 45 Ban Hành)

11 min read Revision 5
dieu45-draftdesign-backlogsub-design-packsDP1-DP7post-ban-hanh

05 — Next Design Backlog (Post-Điều 45 Ban Hành)

Date: 2026-05-26 (revised post-GPT Council Round 1 — v0.2) Scope: 7 sub-design packs có thể dispatch sau khi Điều 45 v1.0 BAN HÀNH. v0.2 update: Patch GPT Round 1 đã ràng buộc thêm 5 invariants. DP2/DP3 phải tuân work_state_machine §6.7 (≥9 states). DP4 (NOTIFY bridge) phải tuân silent_gap §15.5. Mọi DP phải tuân executor_boundary §11.5 (executor đăng ký healthcheck TRƯỚC khi enable). Mỗi DP có scope rõ ràng, prerequisites, deliverable, owner suggestion. KHÔNG dispatch ngay — chờ Điều 45 ratification.


§1. Tổng quan

DP Tiêu đề Mức ưu tiên (gợi ý) Đụng §luật Pre-req Estimated effort
DP1 pg_cron adoption decision P0 §5.4, §9.4 Packaging verify High
DP2 Job substrate shape decision P0 §1.2.D, §3.1 Use case enum High
DP3 Retry policy concrete + max_attempts P1 §8.1, §8.2 DP2 first Medium
DP4 NOTIFY bridge (event_universal channel) P2 §5.4, §15.4 DP1 decision Medium
DP5 Trigger-IN vocab widening P1 §12.1, §3.2 event_type_registry ratification process Medium
DP6 Subscription comprehensive config P2 §11.4, §16.1 D37 D37 agency vocab freeze Low
DP7 event_outbox partitioning P3 §15 risk Volume > 1M rows Medium

P0 = Critical, P1 = High, P2 = Medium, P3 = Low (deferred until threshold).

Ngoài 7 DP, có 3 housekeeping tasks cần làm trước hoặc song song:

HK Tiêu đề Action
HK1 iu_notification_event legacy deprecate Q7 — drop hoặc keep as view
HK2 Worker silent gap audit Q25 — Hermes log audit
HK3 event_outbox unique index introspection Q5 — \d event_outbox + DP doc

§2. DP1 — pg_cron adoption decision

§2.1 Mục đích

Quyết định cài pg_cron hay tiếp tục external invocation cho mọi cron-style work (worker tick, cleanup tick, retention tick, healthcheck tick).

§2.2 Pre-requisites

  • ✅ Điều 45 v1.0 ban hành.
  • ⬜ Verify pg_cron 1.6+ available trên Debian pgdg-16 source.
  • ⬜ Inventory current external cadence: worker tick (Hermes), retention (manual), staging cleanup (manual), health check (Hermes).
  • ⬜ Estimate downtime cost nếu cài pg_cron (CREATE EXTENSION on production).

§2.3 Deliverables

  • DP1 design pack:
    • Decision: install / no-install / hybrid.
    • Nếu install: list of cron jobs (worker tick, cleanup, retention, healthcheck), schedule expressions, owner.
    • Nếu install: extension installation runbook + rollback.
    • Migration plan với gate (route_worker_enabled flag).
    • Test plan: cron job fires + idempotency + non-overlap.
  • Sửa Điều 45 §5.4, §9.4 nếu install (qua amendment process).

§2.4 Owner suggestion

DOT Governance (Điều 35) — vì cron tick là một loại DOT-like ops.

§2.5 Risk

  • pg_cron postgres restart cần thiết khi install (ALTER SYSTEM shared_preload_libraries).
  • pg_cron PG 18 packaging chưa verify (relevant nếu sau này upgrade).

§3. DP2 — Job substrate shape decision

§3.1 Mục đích

Quyết định long-running Agent/Hermes/MOT/worker job lưu đâu.

§3.2 Pre-requisites

  • ✅ Điều 45 v1.0 ban hành.
  • ⬜ Inventory current external job patterns:
    • Hermes context-pack build.
    • Codex DOT runs.
    • Agent (Opus/GPT/Gemini) session-based work.
    • Staging cleanup sweeps.
    • Vector sync ingestion.
    • MOT workflow (chưa có spec).
  • ⬜ List which need claim/start/done semantics vs which fit event-only.

§3.3 Phương án

Ràng buộc v0.2: Mọi phương án phải support work_state_machine §6.7 minimum 9 states (queued/leased/in_progress/succeeded/failed/retry_waiting/dead_letter/cancelled/cleaned) — §6.6 đã cấm giả định event_outbox tự thân phủ job queue.

(a) Extend event_outbox với event_domain='job':

  • Pro: single substrate, đồng nhất.
  • Con: event là append-only fact; job có mutable state (status changes). Awkward — vi phạm §6.6 nếu không kèm bảng state riêng.

(b) Tạo job_outbox parallel table:

  • Pro: clean semantics (claim/start/done/failed lifecycle).
  • Con: hai substrate; vocab tách.

(c) Event-only + idempotency log:

  • Pro: minimal change.
  • Con: job state phải sống trong consumer-specific table; không unified.

§3.4 Deliverables

  • DP2 design pack với phương án chọn + schema sketch + lifecycle vocab.
  • Sửa Điều 45 §1.2.D, §3.1 (nếu cần dispensation cho parallel substrate).

§3.5 Owner suggestion

Architecture Council — vì quyết định cấu trúc nền.


§4. DP3 — Retry policy concrete

§4.1 Mục đích

Ấn định max_attempts, backoff strategy, resolution authority cho dead-letter.

§4.2 Pre-requisites

  • ✅ Điều 45 v1.0 ban hành.
  • ✅ DP2 (job substrate) — quyết định nơi lưu retry state.
  • ⬜ Inventory failure modes thực tế: lock conflict, payload contract violation, downstream timeout, business validation fail.

§4.3 Deliverables

Ràng buộc v0.2: retry policy phải tích hợp với work_state_machine §6.7 (state retry_waiting + transition retry_waiting → leased); concrete stale_threshold multiplier có thể codify trong DP3 (xem A8' §6.5 của report 04).

  • dot_config keys ratify:
    • queue.retry.default.max_attempts
    • queue.retry.default.backoff_seconds
    • queue.retry.default.backoff_strategy ∈ {constant, linear, exponential}
    • Per-domain override pattern.
  • Resolution authority table: ai (agency) được phép replay/discard/supersede dead-letter row nào.
  • Test plan replay → re-fail → re-DL idempotency.

§4.4 Owner suggestion

D31 (Integrity) + Điều 37 (agency authority).


§5. DP4 — NOTIFY bridge

§5.1 Mục đích

Quyết định có hay không bật pg_notify('event_universal', json) trigger trên event_outbox INSERT để external listener wake up sớm (parallel với mô hình kb_vector_sync).

§5.2 Pre-requisites

  • ✅ Điều 45 v1.0 ban hành.
  • ⬜ DP1 quyết định pg_cron — vì NOTIFY có thể là alternative.
  • ⬜ Inventory potential listeners: Agent Data daemon, Hermes worker, future webhook adapter.

§5.3 Deliverables

Ràng buộc v0.2: NOTIFY là wake-up signal — KHÔNG được dùng làm SoT (§5.4). Listener phải tuân executor_boundary §11.5: reconstruct work từ PG sau crash, không từ NOTIFY-only memory. Missing-NOTIFY recovery phải có poll fallback theo §15.5 (silent gap = violation).

  • DP4 design: trigger spec + payload schema (signal-only, không data) + reconnect/replay strategy.
  • Test plan: NOTIFY fires + listener idempotent + missing-NOTIFY recovery (poll fallback).
  • Sửa Điều 45 §5.4 / §15.4 nếu bật.

§5.4 Owner suggestion

D31 + Architecture Council.


§6. DP5 — Trigger-IN vocab widening

§6.1 Mục đích

Mở rộng iu_sql_event_route.target_event_domain vocab + activate first non-dry-run route.

§6.2 Pre-requisites

  • ✅ Điều 45 v1.0 ban hành.
  • ⬜ event_type_registry ratification process formalized.
  • ⬜ Use case identified: ví dụ birth_registry.entity_born from entity_species INSERT trigger.

§6.3 Deliverables

  • DP5 design: vocab widening DDL + first activated route + monitoring.
  • Test plan: SQL event → queue event đúng vocab + idempotency.
  • Sửa Điều 45 §12.1 nếu cần.

§6.4 Owner suggestion

D44 trien-khai team — vì hầu hết trigger-IN xuất phát từ IU infrastructure.


§7. DP6 — Subscription comprehensive config

§7.1 Mục đích

Hiện chỉ 3 subscription rows. Cấu hình comprehensive sao cho mỗi domain × stream có routing rõ ràng.

§7.2 Pre-requisites

  • ✅ Điều 45 v1.0 ban hành.
  • ✅ D37 agency vocab freeze.
  • ⬜ Inventory current actor pool: agencies, roles, users, AI agents.

§7.3 Deliverables

  • DP6 design: subscription matrix per (event_domain, event_stream) → recipient list.
  • Migration: INSERT rows.
  • Test plan: each domain × stream resolves to ≥1 recipient (no broadcast fallback).

§7.4 Owner suggestion

D37 Governance Organization.


§8. DP7 — event_outbox partitioning

§8.1 Mục đích

Partition event_outbox theo created_at (monthly hoặc weekly) khi volume tiếp cận ngưỡng performance.

§8.2 Pre-requisites

  • ✅ Điều 45 v1.0 ban hành.
  • ⬜ Volume reach > 1M rows hoặc query latency degrade detectable.
  • ⬜ Decide partition strategy: native PG declarative partitioning hay pg_partman.

§8.3 Deliverables

  • DP7 design: partition scheme + migration plan (no-downtime).
  • Test plan: query plan inspection + partition pruning.

§8.4 Owner suggestion

D44 trien-khai infrastructure team.


§9. Housekeeping tasks

§9.1 HK1 — iu_notification_event legacy deprecate

Action:

  • Confirm no external reader (no Directus collection, no fn reference).
  • DROP table (with backup).
  • Update 23-P3D4C0X §I doc with deprecation note.

Owner: D44 trien-khai team.

§9.2 HK2 — Worker silent gap audit

Action:

  • Hermes/Codex log audit từ 2026-05-22 → 2026-05-26.
  • Confirm: workload thực sự rỗng hay external invoker stopped?
  • Document cadence trong vận hành.

Owner: Architecture Council.

§9.3 HK3 — event_outbox unique index introspection

Action:

  • \d event_outbox trong dev session.
  • Compare với 23-P3D4C0X §C proposal.
  • Document trong DP4 or HK3 report.

Owner: D44 trien-khai team.


§10. Sequencing (gợi ý)

T0: Điều 45 v1.0 BAN HÀNH
T0+:  HK2 worker silent gap audit (1 day)
T0+:  HK3 unique index introspection (1 day)
T0+1w: DP1 pg_cron decision (week)
T0+1w: DP2 job substrate decision (week, parallel with DP1)
T0+2w: DP3 retry policy (after DP2)
T0+2w: DP5 trigger-IN vocab widening (parallel)
T0+3w: DP4 NOTIFY bridge (after DP1)
T0+4w: HK1 iu_notification_event deprecate
T0+4w: DP6 subscription comprehensive (after DP2)
T?:    DP7 partitioning (deferred until volume threshold)

KHÔNG có quyết định cuối cùng về sequencing tại tài liệu này — Council quyết.


§11. Anti-backlog rule

Mỗi DP phải:

  • Có prompt rõ ràng.
  • Có pre-requisites verified.
  • Có GPT review round 1.
  • Có Gemini review round (optional).
  • Có rollback plan trước migration.
  • Có test plan trước migration.

KHÔNG được merge DP nào với DP khác mà bỏ qua review.


§12. Tiêu chí success cho Backlog

Sau 6 tháng từ Điều 45 v1.0 ban hành, success = ≥5/7 DPs completed + ≥3/3 HKs completed + 0 substrate corruption + 0 vi phạm §17 anti-pattern phát hiện qua audit.

Failure = > 2 DPs stalled hoặc audit phát hiện vi phạm §4 (signal/data leak) hoặc §14 (NVSZ).

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-dieu45-pg-native-queue-law-draft/05-next-design-backlog.md