printer sid BUGFIX include nodes augmented into other modules - #2561
Merged
Conversation
The SID generator collected data-namespace items only from the processed module's own compiled tree (lysc_module_dfs_full(module, ...)). Nodes that the module contributes to other modules by augmentation live in the target modules' trees, so they were never collected and got no SID. For models that place feature data via augments (e.g. augmenting a common root module), the generated .sid file ended up with just the module item and no data items. Collect all nodes defined by the processed module wherever they are grafted: after walking the module's own tree, also walk every context module whose augmented_by references the processed module. collect_data_cb now attributes each node to its defining module (node->module), so a foreign module's own nodes are skipped while traversing its tree, and a module's .sid no longer wrongly includes nodes augmented into it by others. Add test_augment covering both directions (the augmenting module's .sid contains the augmented-in node; the base module's .sid does not). Co-authored-by: Cursor <cursoragent@cursor.com>
michalvasko
approved these changes
Aug 25, 2026
Member
|
Thanks, seems fine. The RFC does not mention explicitly how to process augments but this should be correct. |
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.
printer sid BUGFIX: include nodes augmented into other modules
Summary
The RFC 9595 SID generator does not assign SIDs to data nodes that a module
contributes to other modules via
augment. For any module that places itsdata by augmenting another module,
lys_sid_gen()/lys_sid_update()(andyanglint -g) produce a.sidfile containing only themoduleitem and nodata items. This PR makes the generator collect those augmented-in nodes.
Problem
sid_collect_items()gathered data-namespace items only from the processedmodule's own compiled tree:
Nodes that
moduleaugments into another module live in the target module'scompiled tree (their
node->modulestill points back to the augmentingmodule), solysc_module_dfs_full(module, ...)never visits them. As a resultthey receive no SID.
Minimal example — a module whose only data is an augment into another module:
Before this PR,
a1's generated.sidcontains a single item (module a1) and0 data items; the augmented-in
/b1:cont/a1:xis missing.Fix
Collect all nodes defined by the processed module, wherever they are grafted
in the compiled schema:
collect_data_cb()now attributes each node to its defining module and skipsnodes whose
node->modulediffers from the module being processed. This both(a) lets us safely traverse other modules' trees and pick only the
augmented-in nodes, and (b) fixes a latent mis-attribution where a module's own
.sidcould wrongly include nodes augmented into it by others.sid_collect_items()also walks everycontext module whose
augmented_byreferences the processed module (guarded on->compiled), using the same callback.libyang already implements augment target modules when the augmenting module is
implemented (
lys_precompile_augments_deviations()), so the target trees arepresent during generation. The existing choice/case handling and top-level
extension-data (
yang-data/structure) traversal are unchanged.Backward compatibility
Output is unchanged for modules that do not augment other modules. The only
behavioral change is correct attribution: augmented-in nodes now appear in the
augmenting module's
.sid, and are no longer (incorrectly) included in thetarget module's
.sid.Notes
deviated_by) are a separate RFC 9595 concern andare intentionally out of scope here.