KB-1283

00 — Điều 45 Phase 1 Minimal Job Substrate LIVE APPLY — Summary (PASS, 2026-05-26)

7 min read Revision 1
dieu-45phase-1job-substratelive-applypass2026-05-26minimal-substratejob-queuejob-dead-letterqueue-heartbeatinert-at-exit

00 — Điều 45 Phase 1 Minimal Job Substrate LIVE APPLY — Summary

Status: PASS — DIEU45_PHASE_1_MINIMAL_JOB_SUBSTRATE_LIVE_APPLY_PASS Date: 2026-05-26 Channel: SSH → contabo → docker exec postgres → psql workflow_admin@directus (PG 16.13) Backup: pre/post-dieu45-phase1-…dump (Fc, ~83 MB) Migration: 050-dieu45-phase1-minimal-job-substrate.sql (single TX, ON_ERROR_STOP, COMMITTED) Proof: 19-step bounded BEGIN/ROLLBACK proof — all cases pass, ROLLBACK clean to pre-state.

Mission

First live implementation step after Điều 45 v1.0 BAN HÀNH (2026-05-26) and the DP1–DP7 full design pack. Creates the safe, inert PG-native job substrate without starting workers, installing pg_cron, widening event vocab, or mutating live event_outbox traffic.

What changed live (delta vs 2026-05-26 pre-apply)

Surface Before After Delta
Tables (public.* BASE) 268 271 +3 (job_queue, job_dead_letter, queue_heartbeat)
Views (public.*) 52 55 +3 (v_queue_health, v_job_queue_backlog, v_job_dead_letter_summary)
Functions (public.*) 507 515 +8 (7 fn_job_/fn_queue_ + 1 fn_job_queue_updated_at)
dot_config rows 86 94 +8 (queue.* keys, all gates default false)
pg_dump -Fc size (bytes) 82,775,116 82,809,926 +34,810 (substrate only; no data rows)

What did NOT change (regression matrix PASS)

Surface Pre Post Status
event_outbox rows 133,784 133,784 unchanged ✓
event_outbox CHECK constraints 8 8 unchanged ✓
event_outbox columns 16 16 unchanged ✓
event_read rows 133,445 133,445 unchanged ✓
event_type_registry rows 31 31 unchanged ✓
event_subscription rows 3 3 unchanged ✓
iu_route_worker_cursor.last_run_at 2026-05-22 11:31:41 2026-05-22 11:31:41 unchanged (silent gap preserved) ✓
pg_cron extension not installed not installed unchanged ✓
Extensions btree_gist,pgcrypto,plpgsql,postgres_fdw same unchanged ✓
production_documents absent absent unchanged ✓
iu_vector_sync_point rows 152 152 unchanged (Qdrant untouched) ✓
information_unit rows 175 175 unchanged ✓
iu_route_dead_letter rows 0 0 unchanged ✓
fn_iu_op_* aliases (5) present present unchanged ✓
Điều 45 law text rev 21 rev 21 unchanged ✓
MARK/CUT aliases unchanged unchanged
START-HERE unchanged unchanged

Allowed live mutations delivered

  1. 3 new tables — fully gated, 0 rows at exit.
  2. 3 new views — read-only, always-callable.
  3. 8 new functions — all mutating functions short-circuit when their gate is false.
  4. 8 new dot_config keys — all 4 master gates (queue.{job_substrate,worker,notify,heartbeat}.enabled) default false; 4 tuning keys with conservative defaults.
  5. 2 BEFORE-UPDATE triggers on job_queue and queue_heartbeat (refresh updated_at).

Strict forbiddens — all observed

  • No event_outbox schema/CHECK/data mutation ✓
  • No event_type_registry widening ✓
  • No pg_cron install ✓
  • No worker started (queue.worker.enabled=false) ✓
  • No Qdrant touch ✓
  • No production_documents touch ✓
  • No MARK/CUT alias change ✓
  • No START-HERE patch ✓
  • No Điều 45 text edit ✓
  • No customer/email/message schema change ✓
  • No MOT runtime ✓
  • No NOTIFY emit (queue.notify.enabled=false) ✓
  • No automatic event-outbox→job_queue routing ✓

Hard Gate 0 verdict

PASS. SSH(contabo) → docker exec postgres psql -U workflow_admin -d directus confirmed. DDL BEGIN/ROLLBACK probe round-trips. pg_dump-Fc backup completes. KB design pack readable.

Phase D bounded proof verdict

PASS. 19 steps inside BEGIN/ROLLBACK:

  1. gate-OFF refusal (refused=true) ✓
  2. gate enable + 3 enqueues (priorities 50/100/100, max_attempts 3/3/1) ✓
  3. idempotency replay returns duplicate=true with same job_id
  4. payload_json denylist CHECK blocks {"vector":[…]}
  5. fn_job_claim SKIP LOCKED — proof_executor_1 claims 2 (priority order), proof_executor_2 claims remaining 1 ✓
  6. fn_job_ack succeeded; lease_owner_mismatch refused with wrong_executor
  7. transient fail → retry_waiting + backoff_sec=10 (10·2⁰) + scheduled_at +10s ✓
  8. permanent fail → dead_letter + DLQ row with triage_status='pending'
  9. heartbeat gate-OFF refusal ✓
  10. heartbeat gate ON, 2 ticks for exec_1 (ticks_total 1→2), separate counter for exec_2 ✓
  11. heartbeat metadata denylist CHECK blocks {"secret":…}
  12. fn_queue_stale_check finds 1 stale executor at default 300s and at custom 30s thresholds ✓
  13. v_queue_health exposes 16 fields including executors_stale=1, dlq_pending_count=1, retry_waiting_count=1 ✓
  14. v_job_queue_backlog and v_job_dead_letter_summary correctly grouped ✓
  15. POST-ROLLBACK: all 3 tables back to 0/0/0 rows, all 8 gates back to false

State at exit

Gate Value
queue.job_substrate.enabled false
queue.worker.enabled false
queue.notify.enabled false
queue.heartbeat.enabled false
queue.heartbeat.stale_threshold_seconds 300
queue.retry.max_attempts_default 5
queue.retry.backoff_base_sec 10
queue.lease.duration_sec 300

All 3 tables have 0 rows. No worker daemon. No NOTIFY emitter. No pg_cron. Substrate is fully inert.

Silent-gap status (live, unaltered)

iu_route_worker_cursor.last_run_at remained at 2026-05-22 11:31:41+00. At apply time the silent gap is 344,058 seconds (~95.6 hours) — continuing §15.5 violation per [[feedback-dieu45-silent-gap-violation-post-enactment]]. Phase 1 substrate is now in place; activating the heartbeat for the legacy iu_outbound_default cursor is a Phase 2 follow-up (the fn_queue_heartbeat_tick primitive needed to do so is now live).

  • Parent: [[project-dieu45-v1-0-enacted-2026-05-26]]
  • Design pack: [[project-dieu45-full-queue-orchestration-design-pack-dp1-to-dp7-pass-2026-05-26]]
  • Silent-gap lesson: [[feedback-dieu45-silent-gap-violation-post-enactment]]
  • Heartbeat pattern lesson: [[feedback-hc-executor-last-run-is-proven-heartbeat-pattern]]
  • Substrate survey: [[project-system-wide-pg-native-queue-law-readiness-survey-pass-2026-05-26]]

Next phase recommendation

Phase 2 (DP2 follow-up + DP3 lease reaper + DP4 close silent gap on iu_outbound_default). See 09-next-phase-recommendation.md.

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/v0.6-dieu45-phase-1-minimal-job-substrate-live-apply/00-summary.md