(contract)
| 71 | capabilities: Object.fromEntries( |
| 72 | Object.values(CAPABILITY_IDS).map((capabilityId) => [ |
| 73 | capabilityId, |
| 74 | { support: 'none', notes: '' }, |
| 75 | ]) |
| 76 | ), |
| 77 | }; |
| 78 | } |
| 79 | |
| 80 | function validateRuntimeContract(contract) { |
| 81 | const errors = []; |
| 82 | |
| 83 | if (!contract || typeof contract !== 'object') { |
| 84 | return ['Runtime contract must be an object']; |
| 85 | } |
| 86 | |
| 87 | if (!RUNTIME_IDS.includes(contract.id)) { |
| 88 | errors.push(`Unknown runtime id: ${contract.id}`); |
| 89 | } |
| 90 | |
| 91 | if (!contract.guidance || typeof contract.guidance !== 'object') { |
| 92 | errors.push('Runtime contract is missing guidance metadata'); |
| 93 | } |
| 94 | |
| 95 | if (!Array.isArray(contract.events)) { |
| 96 | errors.push('Runtime contract events must be an array'); |
| 97 | } |
| 98 | |
| 99 | if (!contract.capabilities || typeof contract.capabilities !== 'object') { |
| 100 | errors.push('Runtime contract capabilities must be an object'); |
| 101 | } |
| 102 | |
| 103 | if (Array.isArray(contract.events)) { |
| 104 | for (const eventEntry of contract.events) { |
| 105 | if (!eventEntry || typeof eventEntry !== 'object') { |
| 106 | errors.push('Runtime event entry must be an object'); |
| 107 | continue; |
| 108 | } |
| 109 | if (!eventEntry.event_id) { |
| 110 | errors.push('Runtime event entry missing event_id'); |
| 111 | } |
| 112 | if (!isSupportLevel(eventEntry.support)) { |
| 113 | errors.push(`Runtime event entry has invalid support level: ${eventEntry.support}`); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | if (contract.capabilities && typeof contract.capabilities === 'object') { |
| 119 | for (const capabilityId of Object.values(CAPABILITY_IDS)) { |
| 120 | const capability = contract.capabilities[capabilityId]; |
| 121 | if (!capability || typeof capability !== 'object') { |
| 122 | errors.push(`Runtime contract missing capability: ${capabilityId}`); |
| 123 | continue; |
| 124 | } |
| 125 | for (const field of REQUIRED_CAPABILITY_FIELDS) { |
| 126 | if (!(field in capability)) { |
| 127 | errors.push(`Capability ${capabilityId} missing field: ${field}`); |
| 128 | } |
| 129 | } |
| 130 | if (!isSupportLevel(capability.support)) { |
nothing calls this directly
no test coverage detected