Support mixins referencing other mixins via a reserved 'mixin' key - #69
Open
PiousCrossten wants to merge 6 commits into
Open
Support mixins referencing other mixins via a reserved 'mixin' key#69PiousCrossten wants to merge 6 commits into
PiousCrossten wants to merge 6 commits into
Conversation
When multiple mixins provided list arguments (e.g. cmake-args) they were concatenated in reverse of the order given on the command line: each mixin prepends its values, and applying the mixins in forward order stacked them backwards. Apply the mixins in reverse so the resulting list follows the order the mixins were given while keeping any explicit command line arguments last. As a side effect this also lets a later mixin override a scalar value set by an earlier one. The requested mixins are still validated in the given order so an error reports the first unavailable mixin. Add regression tests covering list ordering, scalar override and command line precedence.
Co-authored-by: Kimberly N. McGuire <kimberleymcguire@gmail.com>
Remove comment about command line arguments order.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #69 +/- ##
===========================================
+ Coverage 15.30% 39.03% +23.73%
===========================================
Files 11 12 +1
Lines 562 602 +40
Branches 94 102 +8
===========================================
+ Hits 86 235 +149
+ Misses 474 353 -121
- Partials 2 14 +12 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Add colcon_mixin/mixin/order.py, a standalone module that computes the application order for a mixin together with the other mixins it references through a 'mixin' key. It uses a depth-first, post-order traversal with re-application: referenced mixins are recorded before the mixin that references them, and a mixin reachable through multiple paths is applied once per path to preserve last-applied-wins semantics. Cycle detection uses the active recursion path only, so legitimate re-application is never mistaken for a cycle. Circular references, unknown references and malformed 'mixin' keys raise dedicated errors. Add unit tests covering the ordering algorithm, the canonical reference graph and error reporting. Assisted-by: Claude Opus (Antigravity) for test case generation and architecture-level testing
Expand each requested mixin into its full application order using colcon_mixin.mixin.order and apply the result in reverse, so the prepend-based overlay produces the computed order while explicit command line arguments keep precedence. A referencing mixin is applied conceptually last and can override values inherited from its references. Skip the reserved 'mixin' key during overlay since it is metadata, not an argument. Report circular, unknown and malformed references as clean CLI errors. Mixins without a 'mixin' key behave exactly as before. Add parser integration tests covering nested references, scalar overrides, command line precedence and error reporting. Assisted-by: Claude Opus (Antigravity) for test case generation and architecture-level testing
PiousCrossten
force-pushed
the
feature/mixins-referencing-mixins
branch
2 times, most recently
from
August 4, 2026 05:39
5c19fa3 to
df953e1
Compare
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.
Lets a mixin reference other mixins through a reserved
mixinkey holding a list of mixin names, so a bigger mixin can be built out of smaller ones. Addresses #39.About the diff: this branch sits on top of #59, which is approved but not merged yet, so the four commits from that PR show up here as well. The composition work is the last two commits. Happy to rebase once #59 goes in.
The new module
colcon_mixin/mixin/order.pyworks out the application order with a depth first post-order walk. A mixin reachable through more than one path is applied once per path so that last one wins still holds, cycle detection only looks at the active recursion path, and circular, unknown or malformed references each raise their own error.In
mixin_argument.pythe references are applied before the mixin itself, so a mixin can override what it inherits. The reservedmixinkey is skipped during the overlay since it is metadata and not an argument. Mixins that don't use the key behave exactly as before.test/test_order.pycovers the ordering algorithm and the error cases,test/test_mixin_argument.pycovers nested references, scalar overrides and command line precedence.Claude Opus (via Antigravity) was used for generating test cases and for architecture level testing. The design, implementation and final review are my own.