-- Migration 042: Seed Inference Registry
-- Populates initial endpoint profiles and model deployments for the
-- existing Ollama and vLLM services.
--
-- Task 18.1: Create the current Ollama endpoint profile
-- Task 18.2: Create the current vLLM OpenAI-compatible endpoint profile
-- Task 18.3: Create model deployments matching actual runtime state
--
-- This is a DATA migration. The schema was created in 040_inference_registry.sql.
-- Uses ON CONFLICT DO NOTHING for idempotency.

-- ─── 18.1: Ollama endpoint profile ───────────────────────────────────────────
INSERT INTO inference_endpoints (id, name, protocol, base_url, auth_secret_ref, auth_scheme, default_headers, health_path, enabled)
VALUES (
    'a0000000-0000-4000-8000-000000000001'::uuid,
    'stonks-ollama',
    'ollama_native',
    'http://ollama.ollama-service.svc.cluster.local:11434',
    NULL,
    'none',
    '{}',
    '/api/tags',
    TRUE
)
ON CONFLICT (name) DO NOTHING;

-- ─── 18.2: vLLM OpenAI-compatible endpoint profile ──────────────────────────
INSERT INTO inference_endpoints (id, name, protocol, base_url, auth_secret_ref, auth_scheme, default_headers, health_path, enabled)
VALUES (
    'a0000000-0000-4000-8000-000000000002'::uuid,
    'stonks-vllm',
    'openai_chat',
    'http://kube-vllm.stonks-oracle.svc.cluster.local:8000',
    NULL,
    'none',
    '{}',
    '/health',
    TRUE
)
ON CONFLICT (name) DO NOTHING;

-- ─── 18.3: Model deployments ─────────────────────────────────────────────────

-- Ollama model deployment (qwen3.5:9b served via Ollama native protocol)
INSERT INTO model_deployments (id, endpoint_id, served_model_name, display_name, capabilities, context_window, max_output_tokens, quantization, runtime_metadata, enabled)
VALUES (
    'b0000000-0000-4000-8000-000000000001'::uuid,
    'a0000000-0000-4000-8000-000000000001'::uuid,
    'qwen3.5:9b',
    'Qwen 3.5 9B (Ollama)',
    '{"chat_completions": true, "json_schema": false, "json_object": true, "seed": false, "usage": false, "max_completion_tokens": false, "model_listing": true}',
    32768,
    32768,
    NULL,
    '{"source": "ollama_native", "notes": "Ollama-served model with native JSON mode"}',
    TRUE
)
ON CONFLICT (endpoint_id, served_model_name) DO NOTHING;

-- vLLM model deployment (AxionML/Qwen3.5-9B-NVFP4 on RTX 4070 Ti SUPER)
INSERT INTO model_deployments (id, endpoint_id, served_model_name, display_name, capabilities, context_window, max_output_tokens, quantization, runtime_metadata, enabled)
VALUES (
    'b0000000-0000-4000-8000-000000000002'::uuid,
    'a0000000-0000-4000-8000-000000000002'::uuid,
    'AxionML/Qwen3.5-9B-NVFP4',
    'Qwen 3.5 9B NVFP4 (vLLM)',
    '{"chat_completions": true, "json_schema": true, "json_object": true, "seed": true, "usage": true, "max_completion_tokens": true, "model_listing": true}',
    8192,
    2048,
    'NVFP4',
    '{"gpu": "RTX 4070 Ti SUPER", "gpu_memory_utilization": 0.80, "max_num_seqs": 8, "vllm_structured_outputs": true}',
    TRUE
)
ON CONFLICT (endpoint_id, served_model_name) DO NOTHING;
