KB-6453

P3D B3-F1c-c Directus Flow + Operation Seed SQL (COMPILED, NOT EXECUTED)

5 min read Revision 1

P3D — B3-F1c-c Directus Flow + Operation Seed (COMPILED)

Date: 2026-05-13 Mode: COMPILE-ONLY. NOT EXECUTED. Source pattern: live [DOT-REG] Count Refresh (6h) flow + operation (id e79e00c7-1980-481c-812f-0574c6d718c8 / op af413588-d0f3-4d0f-8123-060c1bcb6069) compiled_from_assumptions: false candidate_cadence_requires_review: true


Probed precedent (live)

directus_flows row (Count Refresh):
  id        = e79e00c7-1980-481c-812f-0574c6d718c8
  name      = [DOT-REG] Count Refresh (6h)
  trigger   = schedule
  status    = active
  options   = {"cron": "0 */6 * * *"}
  operation = af413588-d0f3-4d0f-8123-060c1bcb6069  (FK to root operation)

directus_operations row:
  id         = af413588-d0f3-4d0f-8123-060c1bcb6069
  key        = call_refresh_api
  type       = request
  position_x = 19
  position_y = 1
  flow       = e79e00c7-1980-481c-812f-0574c6d718c8
  options    = {
    "url":     "http://incomex-nuxt:3000/api/registry/refresh-counts",
    "body":    "{}",
    "method":  "POST",
    "headers": [{"value": "application/json", "header": "Content-Type"}]
  }

Schema columns used (verified live against information_schema.columns):

  • directus_flows: id, name, icon, color, description, status, trigger, accountability, options, operation, date_created, user_created
  • directus_operations: id, name, key, type, position_x, position_y, options, resolve, reject, flow, date_created, user_created

Compiled seed SQL (NOT EXECUTED)

-- =========================================================================
-- B3-F1c-c Scheduler: birth_onboarding_full_scan
-- DO NOT EXECUTE. Awaiting GPT review of compiled artifacts.
-- Cadence is CANDIDATE — derived from dot_config policy seed (must match).
-- =========================================================================

BEGIN;

-- Generate UUIDs once and reuse (the literals below are placeholders;
-- replace with freshly generated UUIDs at execution time, OR use
-- gen_random_uuid() if pgcrypto is enabled on this DB).
DO $$
DECLARE
  v_flow_id   uuid := gen_random_uuid();
  v_op_id     uuid := gen_random_uuid();
  v_now       timestamp := CURRENT_TIMESTAMP;
BEGIN
  -- 1. Flow row (schedule trigger, matches Count Refresh precedent)
  INSERT INTO directus_flows (
    id, name, icon, color, description, status, trigger,
    accountability, options, operation, date_created, user_created
  ) VALUES (
    v_flow_id::text,
    '[BIRTH] Onboarding Full Scan (candidate 6h)',
    'health_and_safety',
    NULL,
    'B3-F1c-c. Calls Nuxt endpoint that invokes fn_birth_onboarding_full_scan(). Cadence is a CANDIDATE pending GPT/user review.',
    'active',
    'schedule',
    'all',
    '{"cron": "0 */6 * * *"}'::jsonb,        -- candidate_cadence; MUST match dot_config policy.birth_full_scan.cadence_cron
    v_op_id::text,
    v_now,
    NULL
  );

  -- 2. Root operation row (request, matches Count Refresh precedent EXACTLY for shape)
  INSERT INTO directus_operations (
    id, name, key, type, position_x, position_y, options,
    resolve, reject, flow, date_created, user_created
  ) VALUES (
    v_op_id::text,
    'Call birth onboarding full scan endpoint',
    'call_birth_full_scan_api',
    'request',
    19,
    1,
    '{
      "url":     "http://incomex-nuxt:3000/api/birth/onboarding/full-scan",
      "body":    "{}",
      "method":  "POST",
      "headers": [{"value": "application/json", "header": "Content-Type"}]
    }'::jsonb,
    NULL,
    NULL,
    v_flow_id::text,
    v_now,
    NULL
  );
END $$;

COMMIT;

Pattern compliance check

Aspect Precedent (Count Refresh) Compiled artifact Match
trigger schedule schedule
status active active
options.cron shape {"cron": "..."} {"cron": "0 */6 * * *"} ✓ shape, candidate value
operation.type request request
operation.options.url shape http://incomex-nuxt:3000/api/... http://incomex-nuxt:3000/api/birth/onboarding/full-scan
operation.options.body "{}" "{}"
operation.options.method POST POST
operation.options.headers [{header,value}] [{header,value}]
auth none (internal Docker net) none

Caveat

The Nuxt endpoint at /api/birth/onboarding/full-scan does NOT yet exist and the pattern for calling a PG function from Nuxt is not discoverable in the live Nuxt codebase (see report §3). Executing this seed before the endpoint is built and reviewed will produce HTTP errors at each scheduled run. Hold execution until both:

  1. A reviewed Nuxt endpoint dispatch pattern lands, AND
  2. GPT/user approves candidate_cadence.

B3-F1c-c Scheduler Artifacts | COMPILE-ONLY | 2026-05-13

Back to Knowledge Hub knowledge/dev/laws/dieu44-trien-khai/artifacts/p3d-birth-system-b3f1c-c-directus-flow-seed.sql.md