Support mixins referencing other mixins - #70
Merged
cottsay merged 2 commits intoAug 21, 2026
Merged
Conversation
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
changed the base branch from
master
to
PiousCrossten/reverse-list-concatenation
August 11, 2026 07:08
knmcguire
approved these changes
Aug 11, 2026
knmcguire
left a comment
Contributor
There was a problem hiding this comment.
See my comments here on the same PR but in your forked repo but I approve it on my end!
cottsay
approved these changes
Aug 21, 2026
cottsay
pushed a commit
that referenced
this pull request
Aug 21, 2026
* Add mixin ordering module for composing mixins 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 * Apply referenced mixins in parse_args 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
pushed a commit
to PiousCrossten/gsoc-2026-colcon-mixin
that referenced
this pull request
Aug 27, 2026
Final report for "Add Support for Mixin Composition in colcon-mixin", Google Summer of Code 2026 with OSRF / Open Robotics. Covers the merged work (colcon/colcon-mixin#70, #71), the open follow-ups (#73 and colcon/colcon.readthedocs.org#113), the architecture and the ordering alternatives that were considered and rejected, testing, and the week-by-week project history. The two working documents are archived under docs/ rather than linked externally so they remain readable alongside the report. The project log is lightly redacted: a recurring video-call link and a tokenised proposal download URL were removed. No project content was altered.
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 one mixin be built out of others. A mixin can now list other mixins under a reserved
mixinkey, instead of copy-pasting the samecmake-argsinto every variant.Addresses #39.
So this becomes possible:
colcon build --mixin devappliesdebug, thenccache, thendev's own arguments - references first, so the mixin doing the referencing gets the last word and can override anything it inherits. Command line arguments still beat all of them.How it works
colcon_mixin/mixin/order.pyis a new standalone module that works out the application order with a depth-first post-order walk. Two details worth flagging for review:Circular references, unknown names, and a malformed
mixinkey each raise their own errthem into ordinary CLI errors rather than tracebacks.In
mixin_argument.pythe reservedmixinkey is skipped during the overlay, since it's metadata rather than an argument. Mixins that don't use the key behave exactly as before.Tests
test/test_order.pycovers the ordering algorithm and the error cases;test/test_mixin_argument.pyadds nested references, scalar overrides, command line precedence, and the error paths through the parser.Stacked on #71 - this PR targets that branch, so the diff here shows only the composition work. It'll retarget to
masterand be rebased once #71 lands.Claude Opus (via Antigravity) was used for generating test cases and for architecture level testing. The design, implementation and final review are my own.