Fix future() negation edge cases; add prune_empty_branches (#269)#282
Merged
Conversation
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>
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>
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
Port of #281 (next) to the 3.x line — closes #269 together with #281.
_future()resolves negations in an explicit, documented order:neighbor \S+ descriptionrule).no logging consolestill replaceslogging console Xand persists — real device behavior and required by the existing remediation roundtrip test.no descriptionremovesdescription foo(issue case 2).no ...lines and the did-not-apply-cleanly signal the issue asked to preserve.Issue case 3 ships as opt-in
HConfig.future(change, prune_empty_branches=True): prunes sections the change emptied (cascading, e.g. XRrouter static / address-family), keeping already-empty and newly-added-empty sections.Also includes the mechanical ruff 0.15 adaptation (suppression syntax + property-docstring rules) — the renovate lock bump had left master unable to pass its own lint gate, so any PR here would have failed CI without it.
Test plan
get_hconfig/dump_simple): all three issue repros, the stale-value idempotency pin, the unmatched-signal pin, and prune on/off/originally-empty.logging consoleroundtrip.poetry run ./scripts/build.py lint-and-test— "No issues found".🤖 Generated with Claude Code