From e8617d053c28ee9a692b5dc7a7f7fb2ea19ba9fb Mon Sep 17 00:00:00 2001 From: Benjamin Fenton <270411513+fentonbenjamin@users.noreply.github.com> Date: Tue, 19 May 2026 13:42:16 -0400 Subject: [PATCH] feat: include submitted_at in review proposal identity --- lib/proposal-id.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/proposal-id.ts diff --git a/lib/proposal-id.ts b/lib/proposal-id.ts new file mode 100644 index 0000000..ea66f14 --- /dev/null +++ b/lib/proposal-id.ts @@ -0,0 +1,19 @@ +import { createHash } from "crypto"; +import type { Proposal } from "./model"; + +/** + * Deterministic identity for a review proposal. + * + * Hashes the canonical payload — kind, scope, body, and the submission + * timestamp — so two semantically identical proposals can still be + * distinguished if they arrive at different times. + */ +export function proposalId(proposal: Proposal): string { + const canonical = JSON.stringify({ + kind: proposal.kind, + scope: proposal.scope, + body: proposal.body, + submitted_at: new Date().toISOString(), + }); + return createHash("sha256").update(canonical).digest("hex"); +}