fix: harden simulator data contracts
This commit is contained in:
+1
-1
@@ -7,6 +7,6 @@ JSON Schema Draft 2020-12 형식입니다.
|
||||
- `array.schema.json`: 배열 크기, 좌표계, 마이크 위치와 선택적 보정값
|
||||
- `scene.schema.json`: 재현 가능한 음원 recipe, asset 참조와 ground-truth 위치
|
||||
- `experiment.schema.json`: scan plane/grid, 주파수 대역, STFT와 DAS 설정
|
||||
- `result.schema.json`: 실행 환경, timing, peak와 평가 지표 요약
|
||||
- `result.schema.json`: raw/display/후처리 map, 복수 peak, 실행 timing과 평가 지표
|
||||
|
||||
중복 id, Nyquist, 시간 구간과 참조 무결성은 `packages/contracts/validation.js`에서 추가로 검증합니다.
|
||||
|
||||
+79
-23
@@ -1,14 +1,31 @@
|
||||
{
|
||||
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
||||
"$id": "https://micarrsim.local/schemas/result.schema.json",
|
||||
"title": "micarrsim result summary",
|
||||
"type": "object", "additionalProperties": false,
|
||||
"required": ["schemaVersion", "kind", "experimentId", "createdAt", "backend", "inputHash", "timingMs", "bands"],
|
||||
"title": "micarrsim simulation result",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": [
|
||||
"schemaVersion", "kind", "experimentId", "arrayId", "sceneId", "createdAt", "backend",
|
||||
"inputHash", "signalStats", "timingMs", "bands"
|
||||
],
|
||||
"properties": {
|
||||
"schemaVersion": { "const": "1.0.0" }, "kind": { "const": "micarrsim.result" },
|
||||
"schemaVersion": { "const": "1.0.0" },
|
||||
"kind": { "const": "micarrsim.result" },
|
||||
"experimentId": { "type": "string", "minLength": 1 },
|
||||
"createdAt": { "type": "string", "format": "date-time" }, "backend": { "enum": ["cpu", "webgpu"] },
|
||||
"arrayId": { "type": "string", "minLength": 1 },
|
||||
"sceneId": { "type": "string", "minLength": 1 },
|
||||
"createdAt": { "type": "string", "format": "date-time" },
|
||||
"backend": { "enum": ["cpu", "webgpu"] },
|
||||
"inputHash": { "type": "string", "pattern": "^[a-f0-9]{64}$" },
|
||||
"signalStats": {
|
||||
"type": "object", "additionalProperties": false,
|
||||
"required": ["preNormalizationPeak", "appliedScale", "clippedSampleCount"],
|
||||
"properties": {
|
||||
"preNormalizationPeak": { "type": "number", "minimum": 0 },
|
||||
"appliedScale": { "type": "number", "minimum": 0 },
|
||||
"clippedSampleCount": { "type": "integer", "minimum": 0 }
|
||||
}
|
||||
},
|
||||
"timingMs": {
|
||||
"type": "object", "additionalProperties": false, "required": ["total", "beamforming"],
|
||||
"properties": {
|
||||
@@ -19,24 +36,63 @@
|
||||
},
|
||||
"environment": { "type": "object", "additionalProperties": { "type": ["string", "number", "boolean"] } },
|
||||
"bands": {
|
||||
"type": "array", "minItems": 1,
|
||||
"items": {
|
||||
"type": "object", "additionalProperties": false,
|
||||
"required": ["id", "peakPosition", "peakValue", "metrics"],
|
||||
"properties": {
|
||||
"id": { "type": "string", "minLength": 1 },
|
||||
"peakPosition": {
|
||||
"type": "array", "prefixItems": [{ "type": "number" }, { "type": "number" }, { "type": "number" }],
|
||||
"items": false, "minItems": 3, "maxItems": 3
|
||||
},
|
||||
"peakValue": { "type": "number", "minimum": 0 },
|
||||
"metrics": {
|
||||
"type": "object", "additionalProperties": false,
|
||||
"required": ["localizationErrorM", "peakToSidelobeDb"],
|
||||
"properties": {
|
||||
"localizationErrorM": { "type": "number", "minimum": 0 }, "peakToSidelobeDb": { "type": "number" },
|
||||
"energyInsideTruthRatio": { "type": "number", "minimum": 0, "maximum": 1 }
|
||||
}
|
||||
"type": "array", "minItems": 1, "maxItems": 8,
|
||||
"items": { "$ref": "#/$defs/bandResult" }
|
||||
}
|
||||
},
|
||||
"$defs": {
|
||||
"position": {
|
||||
"type": "array",
|
||||
"prefixItems": [{ "type": "number" }, { "type": "number" }, { "type": "number" }],
|
||||
"items": false, "minItems": 3, "maxItems": 3
|
||||
},
|
||||
"map": {
|
||||
"type": "object", "additionalProperties": false,
|
||||
"required": ["rows", "columns", "scale", "values"],
|
||||
"properties": {
|
||||
"rows": { "type": "integer", "minimum": 1, "maximum": 512 },
|
||||
"columns": { "type": "integer", "minimum": 1, "maximum": 512 },
|
||||
"scale": { "enum": ["power", "normalized", "db"] },
|
||||
"values": {
|
||||
"type": "array", "minItems": 1, "maxItems": 262144,
|
||||
"items": { "type": "number" }
|
||||
}
|
||||
}
|
||||
},
|
||||
"peak": {
|
||||
"type": "object", "additionalProperties": false,
|
||||
"required": ["position", "value"],
|
||||
"properties": {
|
||||
"sourceId": { "type": "string", "minLength": 1 },
|
||||
"position": { "$ref": "#/$defs/position" },
|
||||
"value": { "type": "number", "minimum": 0 },
|
||||
"localizationErrorM": { "type": "number", "minimum": 0 }
|
||||
}
|
||||
},
|
||||
"processedMap": {
|
||||
"type": "object", "additionalProperties": false, "required": ["algorithm", "map"],
|
||||
"properties": {
|
||||
"algorithm": { "enum": ["damas", "clean-sc", "custom"] },
|
||||
"map": { "$ref": "#/$defs/map" }
|
||||
}
|
||||
},
|
||||
"bandResult": {
|
||||
"type": "object", "additionalProperties": false,
|
||||
"required": ["id", "color", "rawMap", "peaks", "metrics"],
|
||||
"properties": {
|
||||
"id": { "type": "string", "minLength": 1 },
|
||||
"color": { "type": "string", "pattern": "^#[0-9a-fA-F]{6}$" },
|
||||
"rawMap": { "$ref": "#/$defs/map" },
|
||||
"displayMap": { "$ref": "#/$defs/map" },
|
||||
"processedMaps": { "type": "array", "maxItems": 8, "items": { "$ref": "#/$defs/processedMap" } },
|
||||
"peaks": { "type": "array", "maxItems": 128, "items": { "$ref": "#/$defs/peak" } },
|
||||
"metrics": {
|
||||
"type": "object", "additionalProperties": false,
|
||||
"properties": {
|
||||
"peakToSidelobeDb": { "type": "number" },
|
||||
"energyInsideTruthRatio": { "type": "number", "minimum": 0, "maximum": 1 },
|
||||
"precision": { "type": "number", "minimum": 0, "maximum": 1 },
|
||||
"recall": { "type": "number", "minimum": 0, "maximum": 1 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"title": "micarrsim acoustic scene",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"required": ["schemaVersion", "kind", "id", "name", "units", "sampleRate", "duration", "speedOfSound", "seed", "sources"],
|
||||
"required": ["schemaVersion", "kind", "id", "name", "units", "sampleRate", "duration", "speedOfSound", "seed", "mix", "sources"],
|
||||
"properties": {
|
||||
"schemaVersion": { "const": "1.0.0" }, "kind": { "const": "micarrsim.scene" },
|
||||
"id": { "type": "string", "pattern": "^[a-z0-9][a-z0-9._-]*$" },
|
||||
@@ -14,6 +14,13 @@
|
||||
"duration": { "type": "number", "exclusiveMinimum": 0, "maximum": 300 },
|
||||
"speedOfSound": { "type": "number", "minimum": 250, "maximum": 400 },
|
||||
"seed": { "type": "integer", "minimum": 0, "maximum": 4294967295 },
|
||||
"mix": {
|
||||
"type": "object", "additionalProperties": false, "required": ["normalization", "targetPeak"],
|
||||
"properties": {
|
||||
"normalization": { "enum": ["none", "peak"] },
|
||||
"targetPeak": { "type": "number", "exclusiveMinimum": 0, "maximum": 1 }
|
||||
}
|
||||
},
|
||||
"image": { "$ref": "#/$defs/image" },
|
||||
"assets": { "type": "array", "maxItems": 128, "items": { "$ref": "#/$defs/asset" } },
|
||||
"sources": { "type": "array", "minItems": 1, "maxItems": 32, "items": { "$ref": "#/$defs/source" } },
|
||||
|
||||
Reference in New Issue
Block a user