ReviewOS

stacks/bunpress

fix(search): make index record order deterministic across filesystems

#85
Closed chris opened this 2 months ago ·
2 months ago

Parent consumer issue: zig-utils/zig-js#631

BunPress 0.2.6 builds every page deterministically, but buildSearchIndex appends records directly in Bun.Glob.scan() enumeration order. That order differs between macOS and Linux filesystems.

Observed in zig-js CI: the complete output manifest matched except for search-index.json; both files were exactly 254,740 bytes, while macOS produced SHA-256 0aee1a5d9372b0661aa78ed1bdfaaf4f0de6871d418f780de8e619ac91ec9dbc and Linux produced 2e6f9162eb9d1f50da4a4b2574ad22a53e79d1d8d6b5475a7a728a002ffd204c.

Acceptance:

  • collect the complete unique included path inventory before reading documents;
  • sort normalized relative paths with a locale-independent ordering;
  • preserve section order within each document and configured locale fallback behavior;
  • add a regression test for stable page ordering;
  • reproduce the same manifest hash from clean macOS and Linux builds.
10 days ago

Landed in d248efd3.

Verification on Bun 1.3.14:

  • focused search-index suite: 22/22
  • full suite: 562/562
  • TypeScript typecheck: pass
  • diff/whitespace audit: pass

The index now deduplicates and filters the complete normalized path inventory before locale-independent default string sorting, then preserves record order within each document and the existing locale-fallback pass.

Sign in to comment on this issue.