Files
proxmox/scripts/validation/validate-dbis-institutional-schemas.sh
defiQUG 7ac74f432b chore: sync docs, config schemas, scripts, and meta task alignment
- Institutional / JVMTM / reserve-provenance / GRU transport + standards JSON
- Validation and verify scripts (Blockscout labels, x402, GRU preflight, P1 local path)
- Wormhole wiring in AGENTS, MCP_SETUP, MASTER_INDEX, 04-configuration README
- Meta docs, integration gaps, live verification log, architecture updates
- CI validate-config workflow updates

Operator/LAN items, submodule working trees, and public token-aggregation edge
routes remain follow-up (see TODOS_CONSOLIDATED P1).

Made-with: Cursor
2026-03-31 22:31:39 -07:00

65 lines
2.8 KiB
Bash
Executable File

#!/usr/bin/env bash
# Validate dbis-institutional examples against JSON Schemas (draft 2020-12).
# Uses `check-jsonschema` when available (pip install check-jsonschema).
# In CI, install first: pip install check-jsonschema
#
# Env:
# SCHEMA_STRICT=1 exit 1 if check-jsonschema is missing (default: skip with 0)
#
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
SCHEMA_DIR="$ROOT/config/dbis-institutional/schemas"
EX_DIR="$ROOT/config/dbis-institutional/examples"
# validate_json_array EX_FILE SCHEMA_FILE LABEL
validate_json_array() {
local ex_file="$1" schema_file="$2" label="$3"
if [[ ! -f "$ex_file" ]]; then
return 0
fi
if ! command -v jq &>/dev/null; then
echo "error: jq is required for $label validation" >&2
exit 1
fi
local n
n=$(jq 'length' "$ex_file")
if [[ "${n:-0}" -lt 1 ]]; then
echo "error: $ex_file must be a non-empty array" >&2
exit 1
fi
local batch_tmp idx
batch_tmp="$(mktemp)"
trap 'rm -f "$batch_tmp"' RETURN
idx=0
while IFS= read -r line; do
echo "$line" >"$batch_tmp"
check-jsonschema --schemafile "$schema_file" "$batch_tmp"
idx=$((idx + 1))
done < <(jq -c '.[]' "$ex_file")
echo "OK $label ($idx items)"
rm -f "$batch_tmp"
trap - RETURN
}
if ! command -v check-jsonschema &>/dev/null; then
if [[ "${SCHEMA_STRICT:-0}" == "1" ]]; then
echo "error: check-jsonschema not found; pip install check-jsonschema" >&2
exit 1
fi
echo "skip: check-jsonschema not installed (pip install check-jsonschema); JSON parse still covered by validate-dbis-institutional-json.sh"
exit 0
fi
check-jsonschema --schemafile "$SCHEMA_DIR/settlement-event.schema.json" "$EX_DIR/settlement-event.example.json"
check-jsonschema --schemafile "$SCHEMA_DIR/settlement-event.schema.json" "$EX_DIR/settlement-event.chain138-primary.example.json"
check-jsonschema --schemafile "$SCHEMA_DIR/settlement-event.schema.json" "$EX_DIR/settlement-event.min.json"
validate_json_array "$EX_DIR/settlement-events-batch.example.json" "$SCHEMA_DIR/settlement-event.schema.json" "settlement-events-batch"
check-jsonschema --schemafile "$SCHEMA_DIR/address-registry-entry.schema.json" "$EX_DIR/address-registry-entry.example.json"
validate_json_array "$EX_DIR/address-registry-entries-batch.example.json" "$SCHEMA_DIR/address-registry-entry.schema.json" "address-registry-entries-batch"
check-jsonschema --schemafile "$SCHEMA_DIR/trust.schema.json" "$EX_DIR/trust.json"
check-jsonschema --schemafile "$SCHEMA_DIR/governance.schema.json" "$EX_DIR/governance.json"
check-jsonschema --schemafile "$SCHEMA_DIR/policy-manifest.schema.json" "$EX_DIR/policy.json"
echo "OK dbis-institutional schema validation (settlement-event, settlement-event.chain138-primary, settlement-events-batch, address-registry-entry, address-registry-entries-batch, trust, governance, policy-manifest)"