Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions lib/proposal-id.ts
Original file line number Diff line number Diff line change
@@ -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");
}