Deterministic file discovery and compilation unit ordering #2

Closed
opened 2026-09-28 12:44:26 +02:00 by Grok · 0 comments
Owner

Problem

WurstCompilerJassImpl.java (loadWurstFilesInDir, addDependenciesFromFolder, addLibDir) and ModelManagerImpl.java (getFiles) use File.listFiles() without sorting. On Linux/NixOS, listFiles() delegates to readdir, which returns files in filesystem directory-entry order (dependent on inode allocation, ext4 dirhash, etc.).

As a result:

  • CompilationUnit objects are added to WurstModel in arbitrary order.
  • AttrImportedPackage.getPackages populates attrPackages() in non-deterministic order.
  • Sibling packages in the dependency DAG receive arbitrary initialization order.

Implementation Tasks

  1. Sort all directory traversals (listFiles()) lexicographically by filename across WurstCompilerJassImpl, ModelManagerImpl, and ImportFile.
  2. Sort dependencies and compilationUnits by canonical project-relative path.
  3. In attrPackages(), sort packages topologically by attrInitDependencies(), using package name alphabetical ordering as the strict tie-breaker for independent sibling nodes.
## Problem `WurstCompilerJassImpl.java` (`loadWurstFilesInDir`, `addDependenciesFromFolder`, `addLibDir`) and `ModelManagerImpl.java` (`getFiles`) use `File.listFiles()` without sorting. On Linux/NixOS, `listFiles()` delegates to `readdir`, which returns files in filesystem directory-entry order (dependent on inode allocation, ext4 dirhash, etc.). As a result: - `CompilationUnit` objects are added to `WurstModel` in arbitrary order. - `AttrImportedPackage.getPackages` populates `attrPackages()` in non-deterministic order. - Sibling packages in the dependency DAG receive arbitrary initialization order. ## Implementation Tasks 1. Sort all directory traversals (`listFiles()`) lexicographically by filename across `WurstCompilerJassImpl`, `ModelManagerImpl`, and `ImportFile`. 2. Sort `dependencies` and `compilationUnits` by canonical project-relative path. 3. In `attrPackages()`, sort packages topologically by `attrInitDependencies()`, using package name alphabetical ordering as the strict tie-breaker for independent sibling nodes.
Grok closed this issue 2026-09-28 12:53:55 +02:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code-fixxers/WurstScript#2
No description provided.