Fix future() negation edge cases; add prune_empty_branches (#269)#281
Merged
Conversation
compute_future now resolves negations in an explicit order: 1. Exact positive match - the negation removes the line and neither survives. Evaluated before the idempotency rules, which can match the negation line itself and previously kept it as a literal child while displacing the original (issue case 1). 2. Idempotency rules - interchangeable forms of one setting replace each other, deliberately including negated forms tracked by a rule (IOS `no logging console` persists in the render, which the remediation roundtrip depends on). 3. Shorthand prefix match - `no description` removes `description foo` as devices do (issue case 2). 4. Unmatched negations are kept, accounting for `no ...` lines native to running configs and preserving the did-not-apply-cleanly signal the issue asked to retain. HConfig.future() gains prune_empty_branches (issue case 3): sections emptied by the change are pruned as devices do on commit, cascading upward, while sections that were already empty (or newly added empty) are kept. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
jtdub
force-pushed
the
issue-269-future-negation
branch
from
July 19, 2026 00:44
404b5ad to
bb42051
Compare
jtdub
added a commit
that referenced
this pull request
Jul 19, 2026
* Fix future() negation edge cases; add prune_empty_branches (#269) Port of the next-branch fix (#281) to the 3.x line: - A negation whose positive form exists removes it and neither line survives; evaluated before the idempotency rules, which can match the negation line itself and previously kept it as a literal child while displacing the original. - Idempotency rules keep their replace semantics, deliberately covering rule-tracked negated forms (IOS `no logging console` persists, which the remediation roundtrip depends on). - Shorthand negations (`no description`) remove the valued lines they prefix-match, as devices do. - Unmatched negations are kept as a did-not-apply-cleanly signal. - HConfig.future() gains prune_empty_branches: sections emptied by the change are pruned as devices do on commit; already-empty sections are kept. Also adapts the tree to ruff 0.15 from the renovate lock bump (suppression-comment syntax and property-docstring rules), which had left master failing its own lint gate. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Update poetry.lock Brings ruff to 0.15.22 (matching the suppression syntax this branch uses and the next branch's toolchain), plus routine dependency bumps. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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
Closes #269 (next side; a master port follows as a separate PR).
compute_futurenow resolves negations in an explicit, documented order:neighbor \S+ descriptionrule matched the negation line itself, keeping it as a literal child while displacing the original.no logging consolestill replaceslogging console Xand persists in the render — real device behavior for display-default commands, and the existing remediation roundtrip depends on it. A stale-valued EOS negation likewise displaces the tracked line but stays visible, preserving the did-not-apply-cleanly signal the issue explicitly asked to retain.no descriptionremovesdescription foo(andno Xremoves allX ...lines), as devices do (case 2).no ...lines native to running configs and as the apply-signal.Case 3 ships as an opt-in:
HConfig.future(change, prune_empty_branches=True)prunes sections the change emptied out (cascading upward, e.g. XRrouter static / address-family), while sections that were already empty — or newly added empty — are kept, so legitimately-empty interfaces don't vanish.Test plan
logging consoleroundtrip that constrains the idempotency-replace semantics.poetry run ./scripts/build.py lint-and-test— all linters green.🤖 Generated with Claude Code