feat(spec): preserve referenced macros during removal - #334
Open
Thien Trung Vuong (trungams) wants to merge 1 commit into
Conversation
Thien Trung Vuong (trungams)
force-pushed
the
tvuong/structural-spec-editor-macro-preservation
branch
from
September 2, 2026 23:50
4a298a0 to
740f791
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.
Summary
Removing a section or subpackage can also remove
%defineor%globaldeclarations that happen to live inside it. When surviving content still references one of those macros, the rendered spec is left with a dangling reference and often fails much later during the build.This PR teaches the structural editor to preserve the complete declarations that surviving content still needs. It follows transitive dependencies and keeps declaration ordering intact. When a relocation is ambiguous or clearly unsafe, the removal fails without modifying the spec.
Motivation
Issue #203 documents this with QEMU:
%define testsdirlives in the tests subpackage, but%installcontinues to use it after that subpackage is removed. The macro declaration must survive even though the package sections do not.Changes
ErrUnsafeMacroHoistwithout modifying the spec, including:%globaldependencies or redefinitions;%globaldeclarations;spec-remove-subpackagedrops%definemacros inside the removed subpackage that are referenced elsewhere #203 coverage and focused rejection tests.Validation
mage buildmage unitThe completed structural editor also rendered the full Azure Linux evaluation corpus without parser or overlay errors, including automatic preservation of QEMU's
testsdirmacro.Known limitations
This is conservative structural and lexical analysis, not RPM macro evaluation. If azldev cannot establish a safe binding, it rejects the removal instead of guessing. Conditional same-name bindings that would require evaluating the condition remain best-effort.