{"record":{"id":"46d59a0cb97ab4ec","repo":"earendil-works/pi","slug":"protocol-timestamps-must-be-non-negative-integers","errorCode":null,"errorMessage":"Protocol timestamps must be non-negative integers","messagePattern":"Protocol timestamps must be non-negative integers","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/server/src/protocol.ts","lineNumber":137,"sourceCode":"}\n\nfunction nonNegativeInteger(value: number | undefined): number | undefined {\n\tif (value === undefined || !Number.isFinite(value)) return undefined;\n\treturn Math.max(0, Math.floor(value));\n}\n\nfunction nonNegativeNumber(value: number): number {\n\treturn Number.isFinite(value) ? Math.max(0, value) : 0;\n}\n\nfunction identifier(value: string, label: string): string {\n\tif (typeof value !== \"string\" || value.length === 0) throw new TypeError(`${label} must be a non-empty string`);\n\treturn value;\n}\n\nfunction timestamp(value: number): number {\n\tif (!Number.isSafeInteger(value) || value < 0)\n\t\tthrow new TypeError(\"Protocol timestamps must be non-negative integers\");\n\treturn value;\n}\n\n/** Validate and copy a value from an execution boundary into the protocol's JSON-compatible subset. */\nexport function toProtocolJsonValue(value: unknown, seen = new Set<object>()): JsonValue {\n\tif (value === null || typeof value === \"string\" || typeof value === \"boolean\") return value;\n\tif (typeof value === \"number\") {\n\t\tif (!Number.isFinite(value)) throw new TypeError(\"Protocol JSON numbers must be finite\");\n\t\treturn value;\n\t}\n\tif (typeof value !== \"object\") throw new TypeError(`Unsupported protocol JSON value: ${typeof value}`);\n\tif (seen.has(value)) throw new TypeError(\"Protocol JSON values must not contain circular references\");\n\tconst prototype = Object.getPrototypeOf(value);\n\tif (!Array.isArray(value) && prototype !== Object.prototype && prototype !== null) {\n\t\tthrow new TypeError(\"Protocol JSON objects must be plain objects\");\n\t}\n\tseen.add(value);\n\ttry {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/earendil-works/pi/blob/4af9d21d3b4d664e4a29fcabfec85171077248e3/packages/server/src/protocol.ts#L119-L155","documentation":"Error \"Protocol timestamps must be non-negative integers\" thrown in earendil-works/pi.","triggerScenarios":"Thrown at packages/server/src/protocol.ts:137 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use non-negative integer timestamps (for example Date.now())."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4af9d21d3b4d664e4a29fcabfec85171077248e3","analyzedAt":"2026-08-24T13:07:14.692Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}