{"record":{"id":"0aa5e8c4f590c350","repo":"affaan-m/ECC","slug":"recorded-at-must-be-an-iso-timestamp","errorCode":null,"errorMessage":"recorded_at must be an ISO timestamp","messagePattern":"recorded_at must be an ISO timestamp","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/skill-evolution/tracker.js","lineNumber":78,"sourceCode":"\n  if (typeof skillVersion !== 'string' || skillVersion.trim().length === 0) {\n    throw new Error('skill_version is required');\n  }\n\n  if (typeof taskDescription !== 'string' || taskDescription.trim().length === 0) {\n    throw new Error('task_description is required');\n  }\n\n  if (!VALID_OUTCOMES.has(outcome)) {\n    throw new Error('outcome must be one of success, failure, or partial');\n  }\n\n  if (userFeedback !== null && !VALID_FEEDBACK.has(userFeedback)) {\n    throw new Error('user_feedback must be accepted, corrected, rejected, or null');\n  }\n\n  if (Number.isNaN(Date.parse(recordedAt))) {\n    throw new Error('recorded_at must be an ISO timestamp');\n  }\n\n  return {\n    skill_id: skillId,\n    skill_version: skillVersion,\n    task_description: taskDescription,\n    outcome,\n    failure_reason: input.failure_reason || input.failureReason || null,\n    tokens_used: toNullableNumber(input.tokens_used ?? input.tokensUsed, 'tokens_used'),\n    duration_ms: toNullableNumber(input.duration_ms ?? input.durationMs, 'duration_ms'),\n    user_feedback: userFeedback,\n    recorded_at: recordedAt,\n  };\n}\n\nfunction readJsonl(filePath) {\n  if (!fs.existsSync(filePath)) {\n    return [];","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/lib/skill-evolution/tracker.js#L60-L96","documentation":"normalizeExecutionRecord parses recordedAt with Date.parse and throws 'recorded_at must be an ISO timestamp' when the result is NaN. The library requires an ISO 8601 timestamp so records can be sorted and analyzed chronologically.","triggerScenarios":"Passing recordedAt as a non-date string (e.g. 'yesterday', '16/09/2026'), a Date object instead of a string, an empty string, or a locale-formatted date that Date.parse cannot interpret in the runtime environment.","commonSituations":"Shell scripts inserting $(date) output in a non-ISO locale format; hand-written timestamps like '2026-09-16 10:00' without seconds/timezone on strict engines; forgetting to call toISOString() on a Date object and passing the object itself; locale-dependent date formatting differing between CI and local machines.","solutions":["Generate the timestamp with new Date().toISOString() (e.g. '2026-09-16T10:00:00.000Z') instead of manual formatting.","If you have a Date object, convert it: date.toISOString().","If input is a raw string, normalize it first: new Date(raw).toISOString(), guarding against Invalid Date."],"exampleFix":"// before\ntracker.record({ skillId, skillVersion, taskDescription, outcome, recordedAt: '16/09/2026 10:00' });\n\n// after\ntracker.record({ skillId, skillVersion, taskDescription, outcome, recordedAt: new Date().toISOString() });","handlingStrategy":"validation","validationCode":"function assertIsoTimestamp(recordedAt) {\n  if (typeof recordedAt !== 'string' || Number.isNaN(Date.parse(recordedAt))) {\n    throw new Error('recorded_at must be an ISO 8601 timestamp string, e.g. new Date().toISOString()');\n  }\n}","typeGuard":"function isIsoTimestamp(v) {\n  return typeof v === 'string' && !Number.isNaN(Date.parse(v));\n}","tryCatchPattern":"try {\n  tracker.record(record);\n} catch (err) {\n  if (err.message === 'recorded_at must be an ISO timestamp') {\n    console.error(`Bad recorded_at \"${record.recordedAt}\"; regenerate with new Date().toISOString().`);\n    process.exitCode = 1;\n    return;\n  }\n  throw err;\n}","preventionTips":["Always generate timestamps with new Date().toISOString(); never hand-format dates.","Never pass Date objects where strings are expected; convert with toISOString().","Avoid locale-dependent date commands in shell scripts; use date -u +%Y-%m-%dT%H:%M:%SZ for UTC ISO output."],"tags":["validation","timestamp","date-format","skill-evolution"],"backgroundTag":"invalid-date-format","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"}