Skip to content

compiler: stabilize generated module ordering - #326

Merged
wllenyj merged 1 commit into
masterfrom
fix-deterministic-codegen-mod
Sep 15, 2026
Merged

wllenyj merged 1 commit into
masterfrom
fix-deterministic-codegen-mod

Conversation

@Tim-Zhang

@Tim-Zhang Tim-Zhang commented Sep 14, 2026

Copy link
Copy Markdown
Member

When Customize.gen_mod is enabled, the compiler writes mod.rs by iterating a HashSet. Rebuilding the workspace can therefore reorder tracked example module files and leave a diff after every generation. The same implementation can also reorder comments and attributes or remove repeated attribute lines.

Preserve existing lines in their original order and append only missing module declarations, sorted by name. Refresh the two example mod.rs files to match the stable output. The regression test covers a missing file, existing comments and repeated attributes, duplicate inputs, and regeneration with reordered inputs.

Follow-up to #232.

Preserve existing mod.rs lines in order and append sorted, unique
module declarations. Do not reorder or deduplicate comments and
attributes while merging generated modules.

Regenerate the example module files and cover repeated generation,
duplicate inputs, and preservation of existing lines.

Signed-off-by: Tim Zhang <tim@hyper.sh>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No unresolved review issues were identified.

Pull request overview

Stabilizes generated mod.rs ordering while preserving existing content.

Changes:

  • Preserve existing lines and append missing modules in sorted order.
  • Add regression coverage for duplicates, comments, and attributes.
  • Refresh example module files.
File summaries
File Description
example/protocols/sync/mod.rs Updates synchronous module ordering.
example/protocols/asynchronous/mod.rs Updates asynchronous module ordering.
compiler/src/codegen.rs Implements stable module generation and tests it.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@teawater teawater left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wllenyj
wllenyj merged commit 9bd213c into master Sep 15, 2026
14 checks passed
@wllenyj
wllenyj deleted the fix-deterministic-codegen-mod branch September 15, 2026 03:39
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.

4 participants