Comp AI CRM is an open source, CRM designed for AI agents. Agentic-first CRM.
TypeScript
Derive the dedupe id with SHA-256 in a v8 uuid
Lewis Carharta2000621a852
diff --git a/docs/telemetry.md b/docs/telemetry.mdindex 8c70272d..e2602987 100644--- a/docs/telemetry.md+++ b/docs/telemetry.md@@ -63,7 +63,10 @@ already drained. A rollup that fails to send hands the day and the counters backrun is not suppressed by a send that never happened.**The event carries a deterministic `uuid`**, `stableUuid(install.uuid, "install_daily", day)` — a-v5-shaped digest — and PostHog ingests a repeat of one it has already seen only once. The lock+SHA-256 digest in a v8 UUID — and PostHog ingests a repeat of one it has already seen only once.+RFC 4122 defines v5 as SHA-1, and CodeQL rightly refuses to see a hash of the install identity+and a weak algorithm in the same expression. Nothing here needs v5, so it is v8, the slot RFC 9562+leaves for a derivation of one's own. The lockstops two processes racing; the id stops the *same* process sending twice, which the release pathcan otherwise cause. Counting installs survives a duplicate either way, because PostHog's uniquemath is per install per day, but `tool_calls_total` and the other summed properties would bediff --git a/packages/telemetry/src/install.ts b/packages/telemetry/src/install.tsindex decab68f..de2a5a59 100644--- a/packages/telemetry/src/install.ts+++ b/packages/telemetry/src/install.ts@@ -222,10 +222,10 @@ export function utcDay(at: Date): string {}export function stableUuid(...parts: string[]): string {- const digest = createHash("sha1").update(parts.join(":")).digest();+ const digest = createHash("sha256").update(parts.join(":")).digest();const bytes = Uint8Array.from(digest.subarray(0, 16));- bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x50;+ bytes[6] = ((bytes[6] ?? 0) & 0x0f) | 0x80;bytes[8] = ((bytes[8] ?? 0) & 0x3f) | 0x80;const hex = Buffer.from(bytes).toString("hex");diff --git a/packages/telemetry/test/stable-uuid.spec.ts b/packages/telemetry/test/stable-uuid.spec.tsindex 59c863b9..ce52a9c1 100644--- a/packages/telemetry/test/stable-uuid.spec.ts+++ b/packages/telemetry/test/stable-uuid.spec.ts@@ -6,7 +6,7 @@ const INSTALL = "cdf04e64-7722-4921-8b28-be936ce36353";const OTHER = "c4b8d582-ec43-44f1-9a73-7b331eec90c7";const UUID_SHAPE =- /^[0-9a-f]{8}-[0-9a-f]{4}-5[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;+ /^[0-9a-f]{8}-[0-9a-f]{4}-8[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;describe("utcDay", () => {it("is the same string across a whole utc day", () => {@@ -20,7 +20,7 @@ describe("utcDay", () => {});describe("stableUuid", () => {- it("is a well formed v5 uuid", () => {+ it("is a well formed v8 uuid", () => {expect(stableUuid(INSTALL, "install_daily", "2026-08-05")).toMatch(UUID_SHAPE,);