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

Function validateBlock

core/memory/blocks.js:215–224  ·  view source on GitHub ↗
(blockRecord)

Source from the content-addressed store, hash-verified

213}
214
215function validateBlock(blockRecord) {
216 const issues = [];
217 for (const key of ['id', 'type', 'scope', 'owner', 'confidence', 'last_verified', 'sources', 'body']) {
218 if (blockRecord[key] === undefined || blockRecord[key] === null || blockRecord[key] === '') issues.push(`missing ${key}`);
219 }
220 if (!BLOCK_TYPES.includes(blockRecord.type)) issues.push(`unknown type ${blockRecord.type}`);
221 if (!Array.isArray(blockRecord.scope) || blockRecord.scope.length === 0) issues.push('scope must be a non-empty array');
222 if (!Array.isArray(blockRecord.sources) || blockRecord.sources.length === 0) issues.push('sources must be a non-empty array');
223 return issues;
224}
225
226function writeBlock(projectRoot, blockRecord) {
227 fs.mkdirSync(blocksDir(projectRoot), { recursive: true });

Callers 1

lintMemoryBlocksFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected