refactor(domain): consolidate canonical ordering and digest helpers (#624)

* refactor(domain): consolidate canonical ordering and digest helpers

Single owner for code-point ordering (domain/canonicalOrdering.ts)
and canonical JSON digests (domain/comparisonSemantics.ts). Delete
all local compareCodePoints/compareText/digestCanonical duplicates
and migrate every importer. No re-export shims.

* fix(ci): allow slower real browser startup
This commit is contained in:
morluto
2026-10-06 04:55:26 +08:00
committed by GitHub
parent 38b293329c
commit ba3869c597
74 changed files with 438 additions and 530 deletions
+3 -7
View File
@@ -1,5 +1,6 @@
import { z } from "zod";
import { uniqueSorted } from "../domain/canonicalOrdering.js";
import type { AnalysisOperationPort } from "../application/AnalysisProvider.js";
import type { BinarySessionPort } from "../application/BinarySession.js";
import type { PromptCompletionKind } from "../contracts/promptContracts.js";
@@ -41,7 +42,8 @@ export const createPromptCompletionSource = (
context,
);
const prefix = normalize(value);
return uniqueSorted(candidates).filter((candidate) =>
const nonEmpty = candidates.filter((candidate) => candidate.length > 0);
return uniqueSorted(nonEmpty).filter((candidate) =>
normalize(candidate).startsWith(prefix),
);
},
@@ -182,11 +184,5 @@ const unknownCandidates = (
.filter(({ status }) => status !== "resolved")
.map(({ unknown_id: id }) => id);
const uniqueSorted = (values: readonly string[]): string[] =>
[...new Set(values.filter((value) => value.length > 0))].sort(compareText);
const compareText = (left: string, right: string): number =>
left < right ? -1 : left > right ? 1 : 0;
const normalize = (value: string): string =>
value.normalize("NFKC").toLowerCase();