affaan-m/ECC · error · Error
Invalid provenance metadata
Error message
Invalid provenance metadata: ${validation.errors.join('; ')} What it means
assertValidProvenance runs a provenance record through validateProvenance and, if the record fails schema validation, throws with all validation errors joined by semicolons. It is the write/read path's integrity gate: provenance metadata must be complete and internally consistent before it is persisted or consumed.
Solutions
- Read the joined error list in the message and add/fix the named fields in the record.
- Before writing, run validateProvenance(record) in the caller and repair fields programmatically.
- Regenerate provenance for the skill with the library's own tooling instead of hand-editing the JSON.
- If an old file fails new validation, migrate it: read the record, backfill missing fields per the current schema, then write it back.
Example fix
// before
writeProvenance(dir, { name: 'my-skill' }); // missing version/source
// after
const record = { name: 'my-skill', version: '1.0.0', source: 'ECC', ...rest };
const v = validateProvenance(record);
if (v.valid) writeProvenance(dir, record); Defensive patterns
Strategy: validation
Validate before calling
const v = validateProvenance(record);
if (!v.valid) {
console.error('Provenance issues:', v.errors.join('; '));
return null; // fix before writing
} Type guard
const isWellFormedProvenance = (r) => r !== null && typeof r === 'object' && typeof r.name === 'string' && r.name.length > 0;
Try / catch
try {
writeProvenance(dir, record);
} catch (err) {
if (err.message.startsWith('Invalid provenance metadata')) {
console.error(err.message); // semicolon-joined field errors
// repair record fields named in the message, then retry once
} else throw err;
} Prevention
- Always run validateProvenance before writeProvenance in your own scripts.
- Never hand-edit provenance JSON; use the library's generation/update tooling.
- After library upgrades, re-validate all on-disk provenance files and migrate them to the current schema.
When it happens
Trigger: writeProvenance(record) with a record missing required fields (e.g. no name/version/source) or wrong field types; readProvenance encountering an on-disk PROVENANCE/JSON file whose contents fail validateProvenance; hand-edited provenance files with missing keys; records produced by an older library version that no longer satisfy the current schema.
Common situations: Manually editing provenance JSON and dropping a required field; merging skill directories without updating provenance; upgrading the plugin where validation rules tightened; partial writes/corruption leaving truncated JSON that parses but fails validation.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- lacks probe evidence
- provenance must contain derived rules
- -32602
- a generated candidate cannot claim original-source identity
- anchor evidence source duration is not bound to its receipt…
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/a24f82141b9b5931.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/skill-evolution/provenance.js:136
errors.push('confidence must be a number');
} else if (record.confidence < 0 || record.confidence > 1) {
errors.push('confidence must be between 0 and 1');
}
if (typeof record.author !== 'string' || record.author.trim().length === 0) {
errors.push('author is required');
}
return {
valid: errors.length === 0,
errors,
};
}
function assertValidProvenance(record) {
const validation = validateProvenance(record);
if (!validation.valid) {
throw new Error(`Invalid provenance metadata: ${validation.errors.join('; ')}`);
}
}
function readProvenance(skillPath, options = {}) {
const skillDir = normalizeSkillDir(skillPath);
const provenancePath = getProvenancePath(skillDir);
const provenanceRequired = options.required === true || requiresProvenance(skillDir, options);
if (!fs.existsSync(provenancePath)) {
if (provenanceRequired) {
throw new Error(`Missing provenance metadata for ${skillDir}`);
}
return null;
}
const record = JSON.parse(fs.readFileSync(provenancePath, 'utf8'));
assertValidProvenance(record);View on GitHub (pinned to 8321021c54)