{
	"_comment": "OperationConfig descriptor for the four typed operations (Extraction / Aggregation / Histogram / Intersection). Lives on the configs-databeacon, parallel to MappingConfig and DashboardConfig. Materialized via DataBeaconSchema:EnsureSchema; mirrored in /tmp/lab-data-platform/configs/init-platform-configs.sql for fresh deployments.",

	"SchemaName": "data-mapper-operations",
	"Version": 1,

	"Tables":
	[
		{
			"Scope": "OperationConfig",
			"DefaultIdentifier": "IDOperationConfig",
			"Domain": "Default",
			"_comment": "Operator-authored intent doc. The data-mapper bridge compiles it into a UV Operation graph based on OperationType. UV owns execution; this table only captures intent.",
			"Schema":
			[
				{ "Column": "IDOperationConfig",       "Type": "AutoIdentity", "Size": "Default" },
				{ "Column": "GUIDOperationConfig",     "Type": "AutoGUID",     "Size": "36" },
				{ "Column": "CreateDate",              "Type": "CreateDate",   "Size": "Default" },
				{ "Column": "CreatingIDUser",          "Type": "CreateIDUser", "Size": "int" },
				{ "Column": "UpdateDate",              "Type": "UpdateDate",   "Size": "Default" },
				{ "Column": "UpdatingIDUser",          "Type": "UpdateIDUser", "Size": "int" },
				{ "Column": "Deleted",                 "Type": "Deleted",      "Size": "Default" },
				{ "Column": "DeleteDate",              "Type": "DeleteDate",   "Size": "Default" },
				{ "Column": "DeletingIDUser",          "Type": "DeleteIDUser", "Size": "int" },
				{ "Column": "Hash",                    "Type": "String",       "Size": "200" },
				{ "Column": "Scope",                   "Type": "String",       "Size": "200" },
				{ "Column": "Name",                    "Type": "String",       "Size": "200" },
				{ "Column": "Description",             "Type": "String",       "Size": "Default" },
				{ "Column": "OperationType",           "Type": "String",       "Size": "32" },
				{ "Column": "SourceBeaconName",        "Type": "String",       "Size": "200" },
				{ "Column": "SourceConnectionHash",    "Type": "String",       "Size": "200" },
				{ "Column": "SourceEntity",            "Type": "String",       "Size": "200" },
				{ "Column": "TargetBeaconName",        "Type": "String",       "Size": "200" },
				{ "Column": "TargetConnectionHash",    "Type": "String",       "Size": "200" },
				{ "Column": "TargetTable",             "Type": "String",       "Size": "200" },
				{ "Column": "OperationConfiguration",  "Type": "String",       "Size": "Default" },
				{ "Column": "DependsOn",                 "Type": "String",       "Size": "Default" },
				{ "Column": "ResetMode",                 "Type": "String",       "Size": "16"      },
				{ "Column": "Concurrency",               "Type": "Integer",      "Size": "int"     },
				{ "Column": "CompiledOperationHash",     "Type": "String",       "Size": "200"     },
				{ "Column": "CompiledOperationConfigHash","Type": "String",      "Size": "200"     }
			],
			"DefaultObject":
			{
				"IDOperationConfig": 0,
				"GUIDOperationConfig": "0x0000000000000000",
				"CreateDate": null,
				"CreatingIDUser": 0,
				"UpdateDate": null,
				"UpdatingIDUser": 0,
				"Deleted": false,
				"DeleteDate": null,
				"DeletingIDUser": 0,
				"Hash": "",
				"Scope": "",
				"Name": "",
				"Description": "",
				"OperationType": "",
				"SourceBeaconName": "",
				"SourceConnectionHash": "",
				"SourceEntity": "",
				"TargetBeaconName": "",
				"TargetConnectionHash": "",
				"TargetTable": "",
				"OperationConfiguration": "{}",
				"DependsOn": "[]",
				"ResetMode": "Append",
				"Concurrency": 0,
				"CompiledOperationHash": "",
				"CompiledOperationConfigHash": ""
			},
			"Indexes":
			[
				{ "Name": "UX_OperationConfig_ScopeHash", "Columns": ["Scope", "Hash"], "Unique": true },
				{ "Name": "IX_OperationConfig_Type",      "Columns": ["OperationType"] }
			]
		}
	],

	"_notes":
	{
		"OperationType":            "One of: Extraction | Unnest | PassthroughClone | Aggregation | SQLAggregate | Histogram | Intersection | SQLJoin. The data-mapper bridge dispatches by this value at compile time.",
		"OperationConfiguration":   "Type-specific JSON blob. See PLAN-PHASE-2B-Operation-Types.md §3 for the per-type shape.",
		"TargetTable":              "Lake table name where the result lands. The data-mapper ensures this table on the target beacon (typically lake-databeacon) via DataBeaconSchema:EnsureSchema before the first run.",
		"DependsOn":                "JSON-encoded array of OperationConfig hashes this op reads from (e.g. [\"weather-reading-enriched\"]). POST /mapper/uv/run-chain/:id walks the DAG topologically, fails fast on cycles, halts on first error.",
		"ResetMode":                "'Append' (default) | 'Replace'. Replace soft-deletes rows in TargetTable whose GUID didn't appear in the new run before completion — keeps cached views from accumulating orphans when source data churns.",
		"Concurrency":              "Optional per-op override of the bulk-Upsert client-side parallelism. 0 / null = compiler default (5 for typed ops). Clamped to [1,5] in WriteRecords.",
		"CompiledOperationHash":    "The UV-assigned hash of the most recently compiled-and-registered Operation graph for this OperationConfig. Reused on subsequent runs as long as CompiledOperationConfigHash still matches the live OperationConfiguration JSON.",
		"CompiledOperationConfigHash": "SHA-1 of the canonical OperationConfiguration JSON used to produce CompiledOperationHash. Cache invalidator — when this no longer matches the live JSON, the bridge recompiles + re-registers.",
		"ScopeHashIndex":           "UNIQUE index UX_OperationConfig_ScopeHash matches the partial index in init-platform-configs.sql by name. EnsureSchema uses CREATE [UNIQUE] INDEX IF NOT EXISTS, so re-creating against an already-bootstrapped DB is a no-op."
	}
}
