MCPcopy Create free account
hub / github.com/SethGammon/Citadel / validateLoopContract

Function validateLoopContract

core/loops/contract.js:102–119  ·  view source on GitHub ↗
(contract)

Source from the content-addressed store, hash-verified

100}
101
102function validateLoopContract(contract) {
103 const errors = [];
104 if (!contract || typeof contract !== 'object') errors.push('contract must be an object');
105 if (!contract?.id) errors.push('id is required');
106 if (!contract?.type) errors.push('type is required');
107 if (!contract?.trigger?.kind) errors.push('trigger.kind is required');
108 if (!contract?.budget || !Number.isFinite(Number(contract.budget.maxAttempts)) || Number(contract.budget.maxAttempts) < 1) {
109 errors.push('budget.maxAttempts must be >= 1');
110 }
111 if (!Array.isArray(contract?.stopConditions) || contract.stopConditions.length === 0) {
112 errors.push('stopConditions must be a non-empty array');
113 }
114 if (!contract?.statePath) errors.push('statePath is required');
115 return {
116 pass: errors.length === 0,
117 errors,
118 };
119}
120
121module.exports = Object.freeze({
122 CONTRACT_VERSION,

Callers 2

registerLoopFunction · 0.85
test-loops.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected