Fix deterministic ordering for implode.py cursor and github modes#3
Merged
iloveitaly merged 5 commits intoAug 11, 2025
Merged
Conversation
Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com>
Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com>
Copilot
AI
changed the title
[WIP]
Fix deterministic ordering for implode.py cursor and github modes
Aug 2, 2025
py impode.py cursor and py implode.py github does not order the resulting instructions.md in the same way. Can you fix this so the instruction ordering is deterministic?
Owner
Taking another look at this change, is there anything you would update? |
Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com>
Contributor
Author
Done! Changes made in commit 4fbf031:
Only implode.py contains the actual fix now. The get_ordered_files_github() function properly handles the .instructions suffix stripping to ensure deterministic ordering between cursor and github modes. |
Owner
|
@copilot That |
Co-authored-by: iloveitaly <150855+iloveitaly@users.noreply.github.com>
Contributor
Author
Done! Simplified the .gitignore to include only minimal Python cache files (pycache, *.pyc, *.pyo, *.py[cod]) in commit bb0c3ed. Much cleaner and focused on just what's needed for this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
py implode.py cursorandpy implode.py githubcommands were producing different section orderings in their outputinstructions.mdfiles, making the results non-deterministic depending on which mode was used.For example, running both commands on the same repository would produce different section orders:
Cursor mode output:
GitHub mode output (before fix):
Root Cause
The issue was in how file stems were handled between the two modes:
python.mdchave stems likepythonwhich correctly match theSECTION_GLOBSkey conversionspython.instructions.mdhave stems likepython.instructionswhich don't match theSECTION_GLOBSconversions because the.instructionssuffix was includedWhen files couldn't be matched to
SECTION_GLOBSkeys, they were treated as "remaining files" and sorted alphabetically instead of following the intended deterministic order.Solution
Created a new
get_ordered_files_github()function that strips the.instructionssuffix from file stems before matching againstSECTION_GLOBSkeys. This ensures both modes use the same ordering logic based on the predefined section order inconstants.py.Additional Changes
.gitignorefile to exclude Python cache files and other artifactsVerification
Both modes now produce sections in the same deterministic order for common files:
(plus any additional sections specific to each mode, in alphabetical order)
The fix maintains backward compatibility and doesn't change the behavior for cursor mode, only corrects the ordering issue in github mode.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.