update model_parameter_schemas
set json_schema = jsonb_set(json_schema, '{properties,input_size,enum}', '[512,640,1024]'::jsonb, true)
where id = 'schema-vision-segmenter-v1';

insert into model_versions(
    id, model_group, version, status, scenes, metrics, display_name,
    release_notes, dataset_version, runtime_requirements, created_by
) values
('model-vision-detector-cpu100', 'vision-detector', 'cpu-v1.0.0', 'candidate',
 '[]', '{}', 'PP-YOLOE-SOD-s CPU 本地版',
 '本地 CPU 单并发配置，模型制品安装后启用真实 ONNX 推理', 'rail-visible-cpu-local',
 '{"profile":"cpu-local","family":"PP-YOLOE-SOD","runtime":"ONNX Runtime CPU","provider":"CPUExecutionProvider","precision":"FP32","input_size":640,"batch_size":1,"memory_gb":2}', '算法平台'),
('model-vision-segmenter-cpu100', 'vision-segmenter', 'cpu-v1.0.0', 'candidate',
 '[]', '{}', 'PP-LiteSeg-STDC1 CPU 本地版',
 '本地 CPU 轻量语义分割配置，采用按需加载', 'rail-segment-cpu-local',
 '{"profile":"cpu-local","family":"PP-LiteSeg","runtime":"ONNX Runtime CPU","provider":"CPUExecutionProvider","precision":"FP32","input_size":512,"batch_size":1,"memory_gb":2}', '算法平台'),
('model-thermal-cpu100', 'thermal-analyzer', 'cpu-v1.0.0', 'candidate',
 '[]', '{}', 'PP-YOLOE-s 与 PatchCore CPU 本地版',
 '目标定位、辐射测温解算和异常检测的本地组合配置', 'rail-thermal-cpu-local',
 '{"profile":"cpu-local","family":"PP-YOLOE/PatchCore","runtime":"ONNX Runtime CPU","provider":"CPUExecutionProvider","precision":"FP32","input_size":512,"batch_size":1,"memory_gb":2}', '算法平台'),
('model-pointcloud-cpu100', 'pointcloud-analyzer', 'cpu-v1.0.0', 'candidate',
 '[]', '{}', 'Open3D 几何分析 CPU 本地版',
 '点云降采样、去噪、ICP 配准和距离差分本地流水线', 'rail-pointcloud-cpu-local',
 '{"profile":"cpu-local","family":"Open3D","runtime":"Open3D CPU","provider":"CPU","precision":"FP64","batch_size":1,"max_point_count":500000,"memory_gb":3}', '算法平台'),
('model-change-cpu100', 'change-detector', 'cpu-v1.0.0', 'candidate',
 '[]', '{}', 'BIT-R18 CPU 本地版',
 'BIT-R18 ONNX 优先，未安装制品时使用 OpenCV 双时相差分基线', 'rail-change-cpu-local',
 '{"profile":"cpu-local","family":"BIT-R18","runtime":"ONNX Runtime CPU / OpenCV CPU","provider":"CPUExecutionProvider","precision":"FP32","input_size":512,"batch_size":1,"memory_gb":2}', '算法平台')
on conflict (id) do update set
    display_name=excluded.display_name,
    release_notes=excluded.release_notes,
    dataset_version=excluded.dataset_version,
    runtime_requirements=excluded.runtime_requirements;

insert into model_artifacts(
    id, model_version_id, artifact_type, object_key, sha256, size_bytes,
    runtime_constraints, validation_status, validation_report
) values
('artifact-model-vision-detector-cpu100', 'model-vision-detector-cpu100', 'ONNX',
 'models/vision-detector/ppyoloe-sod-s/model.onnx', encode(sha256('cpu:vision-detector'::bytea), 'hex'), 0,
 '{"provider":"CPUExecutionProvider","precision":"FP32","batch_size":1}', 'pending', '{"artifact_installed":false}'),
('artifact-model-vision-segmenter-cpu100', 'model-vision-segmenter-cpu100', 'ONNX',
 'models/vision-segmenter/pp-liteseg-stdc1/model.onnx', encode(sha256('cpu:vision-segmenter'::bytea), 'hex'), 0,
 '{"provider":"CPUExecutionProvider","precision":"FP32","batch_size":1}', 'pending', '{"artifact_installed":false}'),
('artifact-model-thermal-cpu100', 'model-thermal-cpu100', 'ONNX_COMPOSITE',
 'models/thermal-analyzer/ppyoloe-s/model.onnx', encode(sha256('cpu:thermal-analyzer'::bytea), 'hex'), 0,
 '{"provider":"CPUExecutionProvider","precision":"FP32","batch_size":1}', 'pending', '{"artifact_installed":false,"secondary":"patchcore/model.onnx"}'),
('artifact-model-pointcloud-cpu100', 'model-pointcloud-cpu100', 'OPEN3D_PIPELINE',
 'builtin://open3d-geometry', encode(sha256('cpu:pointcloud-analyzer'::bytea), 'hex'), 0,
 '{"provider":"CPU","precision":"FP64","max_point_count":500000}', 'passed', '{"runtime_component":true,"contract":true}'),
('artifact-model-change-cpu100', 'model-change-cpu100', 'ONNX',
 'models/change-detector/bit-r18/model.onnx', encode(sha256('cpu:change-detector'::bytea), 'hex'), 0,
 '{"provider":"CPUExecutionProvider","precision":"FP32","batch_size":1}', 'pending', '{"artifact_installed":false,"fallback":"opencv-cpu"}')
on conflict (id) do update set
    object_key=excluded.object_key,
    runtime_constraints=excluded.runtime_constraints,
    validation_status=excluded.validation_status,
    validation_report=excluded.validation_report;

insert into model_parameter_profiles(
    id, model_group_id, model_version_id, name, revision, scope_type, scope_value,
    parameters, status, change_reason, created_by
) values
('profile-vision-detector-cpu-v1', 'group-vision-detector', 'model-vision-detector-cpu100', 'CPU 本地基线', 1, 'test',
 '{"runtime_profile":"cpu-local"}',
 '{"confidence_threshold":0.55,"nms_iou_threshold":0.45,"max_detections":100,"input_size":640,"precision":"FP32","enable_tiling":false,"tile_overlap":0.2,"save_intermediate":false}',
 'active', '个人电脑单样本推理配置', '算法平台'),
('profile-vision-segmenter-cpu-v1', 'group-vision-segmenter', 'model-vision-segmenter-cpu100', 'CPU 本地基线', 1, 'test',
 '{"runtime_profile":"cpu-local"}',
 '{"mask_threshold":0.5,"minimum_area":64,"fill_holes":true,"contour_simplification":0.8,"input_size":512,"precision":"FP32","save_intermediate":false}',
 'active', '个人电脑单样本推理配置', '算法平台'),
('profile-thermal-cpu-v1', 'group-thermal-analyzer', 'model-thermal-cpu100', 'CPU 本地基线', 1, 'test',
 '{"runtime_profile":"cpu-local"}',
 '{"emissivity":0.95,"ambient_temperature_c":25,"reflected_temperature_c":25,"distance_m":30,"humidity_percent":60,"hotspot_threshold_c":70,"relative_rise_threshold_c":20}',
 'active', '个人电脑单样本推理配置', '算法平台'),
('profile-pointcloud-cpu-v1', 'group-pointcloud-analyzer', 'model-pointcloud-cpu100', 'CPU 本地基线', 1, 'test',
 '{"runtime_profile":"cpu-local"}',
 '{"voxel_size_m":0.08,"outlier_neighbors":20,"outlier_std_ratio":2.0,"icp_max_distance_m":0.5,"icp_iterations":80,"registration_error_limit_m":0.1,"color_mode":"distance"}',
 'active', '限制为五十万点的本地几何分析配置', '算法平台'),
('profile-change-cpu-v1', 'group-change-detector', 'model-change-cpu100', 'CPU 本地基线', 1, 'test',
 '{"runtime_profile":"cpu-local"}',
 '{"target_resolution_m":0.1,"registration_precision_m":0.2,"change_threshold":0.25,"minimum_area_m2":2.0,"morphology_kernel":3,"precision":"FP32","save_intermediate":false}',
 'active', '个人电脑双时相离线分析配置', '算法平台')
on conflict (id) do update set
    parameters=excluded.parameters,
    status=excluded.status,
    change_reason=excluded.change_reason,
    updated_at=now();
