Skip to content

fix(build): write the search index in path order - #807

Merged
LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/reproducible-static-build
Oct 28, 2026
Merged

LeMyst merged 1 commit into
cooklang:mainfrom
LeMyst:fix/reproducible-static-build

Conversation

@LeMyst

@LeMyst LeMyst commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Closes #806

build_search_index now sorts its entries by path, as the sitemap already does, so an unchanged collection always writes the same static/search-index.js.

The static search ranks results by score with a stable sort (static/js/search.js), so results with equal scores now also come out in path order instead of a random one. Nothing else about search changes.

Tests

  • New tests/build_reproducible_test.rs builds the seed twice with --sitemap and --feed on (with isolated config) and requires every written file to be byte-identical. It failed 3 runs out of 3 without the sort, naming static/search-index.js, and passes with it.
  • cargo clippy --all-targets is clean; cargo test --workspace: 1873 passed.
  • I couldn't run static-file-search.spec.ts locally (it needs a target/debug/cook that runs inside the Playwright container); CI runs it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MmrM91dHzvQoaerCcR9wra

`cook build web` listed the search index in the order of a walk over
the recipe tree, whose children are a `HashMap`: the order changed from
one run to the next, so an unchanged collection wrote a different
`static/search-index.js` every time, and a site published through git
or rsync always had a change to ship. It was the only file that
differed; the sitemap already sorts by path for this reason.

The index is now sorted by path. Search ranks by score with a stable
sort, so equal scores now also list in path order.

Introduced with the static-site generator in f6703df (cooklang#344).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmrM91dHzvQoaerCcR9wra
@LeMyst
LeMyst marked this pull request as ready for review October 28, 2026 20:35
@LeMyst
LeMyst merged commit 93b7385 into cooklang:main Oct 28, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cook build web: search-index.js changes on every build of an unchanged collection

1 participant