Skip to content

Apply recipe patches in deterministic order - #53

Open
val-ms wants to merge 1 commit into
mainfrom
fix/deterministic-patch-order
Open

Apply recipe patches in deterministic order#53
val-ms wants to merge 1 commit into
mainfrom
fix/deterministic-patch-order

Conversation

@val-ms

@val-ms val-ms commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

  • process recipe patch-directory entries in deterministic filename order
  • preserve existing handling for .patch, .diff, and auxiliary files
  • add regression coverage for reverse filesystem enumeration order

Root cause

Mussels consumed patch directories directly through os.listdir(). The API
does not guarantee an ordering, so sequential patch sets could be applied in a
different order on different filesystems. This was observed when a dependent
json-c patch series applied numerically on Linux and Windows but started with
the final patch on macOS.

Fix

Sort patch-directory entries by filename before processing them. Existing
numeric patch naming conventions now reliably determine application order on
every platform. Non-patch files copied from the same directory are also
processed deterministically.

The regression test forces os.listdir() to return 0002 before 0001
and verifies that Mussels still applies 0001 first.

Validation

  • pytest -q: 36 passed
  • strict flake8 syntax/undefined-name check: 0 findings
  • advisory flake8 check completed with only pre-existing findings

Recipe patch directories were consumed using os.listdir(), whose ordering is
filesystem-dependent. Sequential patch sets could therefore work on one
platform and fail on another when a dependent patch was returned first.

Sort patch directory entries by filename before applying patches or copying
auxiliary files. Add regression coverage that presents patches in reverse
filesystem order and verifies they are still applied by filename.
@val-ms
val-ms marked this pull request as ready for review August 13, 2026 19:00
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.

1 participant