{"record":{"id":"8d13f0a593f5b516","repo":"Hmbown/CodeWhale","slug":"runtime-event-seq-rec-seq-is-missing-a-usable-timestamp","errorCode":null,"errorMessage":"Runtime event seq ${rec.seq} is missing a usable timestamp.","messagePattern":"Runtime event seq (.+?) is missing a usable timestamp\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tui/pet_watch/pet-native.js","lineNumber":2303,"sourceCode":"                this.sizes.delete(event);\n                if (this.open.get(event.id) === event)\n                    this.open.delete(event.id);\n            }\n        }\n        this.events.length = keep;\n    }\n    append(records) {\n        if (!records.length)\n            return;\n        const { events, open, requests } = this;\n        const threadId = this.threadId ?? str(obj(records[0]).thread_id) ?? this.filename;\n        this.threadId = threadId;\n        let { origin, model, skippedDeltas } = this;\n        let threadName = this.threadName ?? threadId;\n        const stamp = (rec) => {\n            const t = parseTime(rec.timestamp);\n            if (t === undefined)\n                throw new Error(`Runtime event seq ${rec.seq} is missing a usable timestamp.`);\n            if (origin === undefined)\n                origin = t;\n            return t - origin;\n        };\n        for (const raw of records) {\n            if (!isCodewhaleRuntimeRecord(raw))\n                throw new Error('Runtime import cancelled: a line is not a Codewhale runtime event record. No rows were skipped.');\n            this.recordCount++;\n            const rec = obj(raw);\n            if (rec.thread_id !== threadId)\n                throw new Error('Runtime import contains multiple threads. Export one thread before importing.');\n            const eventName = rec.event;\n            if (eventName === 'item.delta') {\n                skippedDeltas++;\n                continue;\n            }\n            const payload = obj(rec.payload);\n            const item = obj(payload.item);","sourceCodeStart":2285,"sourceCodeEnd":2321,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tui/pet_watch/pet-native.js#L2285-L2321","documentation":"Each runtime record must carry a parseable timestamp; stamp() converts rec.timestamp into a relative event time using the first record as origin. If parseTime cannot interpret the timestamp, the import aborts with the offending record's seq so the bad row can be located. Without a timestamp the event cannot be placed on the timeline.","triggerScenarios":"Importing a runtime export containing a record whose timestamp field is missing, null, empty, or in a format parseTime does not recognize (e.g. non-ISO string, integer seconds vs ms mismatch handled elsewhere).","commonSituations":"Hand-edited exports; exports from a different Codewhale version with a changed timestamp format; clock skew/corruption writing 'undefined' or partial timestamps; truncated JSON lines.","solutions":["Locate the record with the reported seq in the runtime export and fix or remove its timestamp.","Re-export the runtime stream with a compatible Codewhale version.","Validate all timestamps parse before import (see validation code).","If hand-editing, use ISO 8601 (e.g. 2026-09-21T12:00:00.000Z)."],"exampleFix":"// before (record in export)\n{ \"seq\": 7, \"event\": \"item.completed\", \"timestamp\": \"yesterday\" }\n// after\n{ \"seq\": 7, \"event\": \"item.completed\", \"timestamp\": \"2026-09-21T12:00:00.000Z\" }","handlingStrategy":"validation","validationCode":"const badSeq = records.find(r => !Number.isFinite(Date.parse(r?.timestamp)));\nif (badSeq) throw new Error(`Record seq ${badSeq.seq} has an unusable timestamp`);","typeGuard":"const hasTimestamp = (r) => typeof r?.timestamp === 'string' && !Number.isNaN(Date.parse(r.timestamp));","tryCatchPattern":"try { importRuntime(records); } catch (e) { if (e.message.includes('missing a usable timestamp')) quarantineRecordBySeq(e); else throw e; }","preventionTips":["Validate all timestamps parse before import.","Use ISO 8601 timestamps in exports.","Don't hand-edit timestamp fields.","Re-export after version upgrades rather than patching files."],"tags":["timestamp","validation","import"],"backgroundTag":"invalid-date-format","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-22T11:17:16.035Z"}