fix(core): sort catalog snapshot by code units for stable hashing

This commit is contained in:
Aiden Cline
2026-07-21 15:24:29 -05:00
parent cbd35e7401
commit 12c5984aa1
+5 -2
View File
@@ -21,8 +21,11 @@ const layer = Layer.effect(
return Service.of({
load: Effect.fn("CodeModeInstructions.load")(function* (selection) {
const catalog = selection.info ? ((yield* codeMode.materialize(selection.info.permissions)).catalog ?? []) : []
// Sorted entries keep the stored snapshot canonical so identical catalogs hash identically.
const entries = catalog.toSorted((left, right) => left.path.localeCompare(right.path))
// Code-unit sorting keeps the stored snapshot canonical so identical catalogs hash
// identically; localeCompare would let host ICU locale and version reorder the array.
const entries = catalog.toSorted((left, right) =>
left.path < right.path ? -1 : left.path > right.path ? 1 : 0,
)
return Instructions.make<ReadonlyArray<CodeModeCatalog.Entry>>({
key: Instructions.Key.make("core/codemode"),
codec: Schema.toCodecJson(Schema.Array(CodeModeCatalog.Entry)),