{"record":{"id":"4519e427d912f10d","repo":"affaan-m/ECC","slug":"canonical-session-snapshot-requires-workers-inde-4519e4","errorCode":null,"errorMessage":"Canonical session snapshot requires workers[${index}].artifacts to be an object","messagePattern":"Canonical session snapshot requires workers\\[(.+?)\\]\\.artifacts to be an object","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/session-adapters/canonical-session.js","lineNumber":231,"sourceCode":"    ensureBoolean(worker.runtime.dead, `workers[${index}].runtime.dead`);\n\n    if (!isObject(worker.intent)) {\n      throw new Error(`Canonical session snapshot requires workers[${index}].intent to be an object`);\n    }\n\n    ensureStringAllowEmpty(worker.intent.objective, `workers[${index}].intent.objective`);\n    ensureArrayOfStrings(worker.intent.seedPaths, `workers[${index}].intent.seedPaths`);\n\n    if (!isObject(worker.outputs)) {\n      throw new Error(`Canonical session snapshot requires workers[${index}].outputs to be an object`);\n    }\n\n    ensureArrayOfStrings(worker.outputs.summary, `workers[${index}].outputs.summary`);\n    ensureArrayOfStrings(worker.outputs.validation, `workers[${index}].outputs.validation`);\n    ensureArrayOfStrings(worker.outputs.remainingRisks, `workers[${index}].outputs.remainingRisks`);\n\n    if (!isObject(worker.artifacts)) {\n      throw new Error(`Canonical session snapshot requires workers[${index}].artifacts to be an object`);\n    }\n  });\n\n  if (!isObject(snapshot.aggregates)) {\n    throw new Error('Canonical session snapshot requires aggregates to be an object');\n  }\n\n  ensureInteger(snapshot.aggregates.workerCount, 'aggregates.workerCount');\n  if (snapshot.aggregates.workerCount !== snapshot.workers.length) {\n    throw new Error('Canonical session snapshot requires aggregates.workerCount to match workers.length');\n  }\n\n  if (!isObject(snapshot.aggregates.states)) {\n    throw new Error('Canonical session snapshot requires aggregates.states to be an object');\n  }\n\n  if (!isObject(snapshot.aggregates.healths)) {\n    throw new Error('Canonical session snapshot requires aggregates.healths to be an object');","sourceCodeStart":213,"sourceCodeEnd":249,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/session-adapters/canonical-session.js#L213-L249","documentation":"This error is thrown when a worker entry lacks an artifacts object. The canonical schema ends each worker validation with workers[i].artifacts being a plain object (contents otherwise unconstrained), used to record files or references produced by the worker. The validator refuses snapshots where artifacts is missing or not an object.","triggerScenarios":"Calling persistCanonicalSnapshot or any normalize*Session adapter with a worker whose artifacts field is absent, null, an array, or a primitive.","commonSituations":"Adapters predating the artifacts requirement; snapshots hand-assembled in scripts or tests; JSON round-trips where artifacts was dropped by a lossy transform.","solutions":["Set worker.artifacts = {} (or the actual artifact map) on the offending worker.","Update the producer so every worker is initialized with an empty artifacts object.","Regenerate the snapshot with current adapters.","Assert validateCanonicalSnapshot passes on all persisted fixtures in tests."],"exampleFix":"// before\nworker.artifacts = [];\n// after\nworker.artifacts = {};","handlingStrategy":"validation","validationCode":"const artifactsOk = snapshot.workers.every(w => w && typeof w.artifacts === 'object' && w.artifacts !== null && !Array.isArray(w.artifacts));\nif (!artifactsOk) throw new Error('every worker needs an artifacts object');","typeGuard":"function hasArtifacts(w) { return !!w && typeof w.artifacts === 'object' && w.artifacts !== null && !Array.isArray(w.artifacts); }","tryCatchPattern":"try { persistCanonicalSnapshot(snapshot); } catch (err) { if (String(err.message).includes('.artifacts to be an object')) { console.error('Worker missing artifacts block:', err.message); /* set artifacts = {} and retry */ } else { throw err; } }","preventionTips":["Always initialize worker.artifacts = {} at creation.","Use plain objects (not arrays or Maps) for artifacts.","Validate snapshots after any transform that rebuilds workers.","Prefer regenerate-over-patch for snapshots from older formats."],"tags":["schema-validation","session-snapshot"],"backgroundTag":"schema-validation-failed","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}