Skip to content

Add NETCONF edit-config remediation rendering (#232)#280

Merged
jtdub merged 1 commit into
nextfrom
issue-232-netconf-ops
Jul 19, 2026
Merged

Add NETCONF edit-config remediation rendering (#232)#280
jtdub merged 1 commit into
nextfrom
issue-232-netconf-ops

Conversation

@jtdub

@jtdub jtdub commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Completes the final scope of #232: remediation output that matches the XML input format.

  • WorkflowRemediation.remediation_netconf_xml() (plus standalone formats.hconfig_to_netconf_xml()) renders the remediation between two HConfig.from_xml() trees as a NETCONF edit-config-style payload: negated nodes become nc:operation="delete" elements (namespaced via xmlns:nc), additions use NETCONF's default merge operation, and attribute-level changes raise a clear InvalidConfigError (they have no NETCONF operation encoding).
  • Keyed list-entry deletions delete by key leaf (<interface nc:operation="delete"><name>eth1</name></interface>), resolved against the running config; without running-config context the standalone function falls back to value-bearing leaf deletes, which is correct for leaves and leaf-lists.
  • Ingestion fix found via this work: the identity suffix was only applied when a tag repeated among siblings, so the same list entry got different node text in configs with different entry counts — producing spurious delete-and-re-add diffs (the exact scenario remediation exists for). Elements are now keyed whenever an identifying list_keys child exists; an identity is only mandatory when the tag actually repeats.

Test plan

  • New tests: end-to-end payload structure (delete + merge + namespace declaration), keyed-entry deletion by key leaf, plain-subtree additions, attribute-negation error, no-running-context fallback, and the surgical-diff regression for differing entry counts.
  • poetry run ./scripts/build.py lint-and-test — all linters pass, 698 tests, ≥95% coverage.

🤖 Generated with Claude Code

- WorkflowRemediation.remediation_netconf_xml() and
  formats.hconfig_to_netconf_xml() render a remediation between
  from_xml() trees as a NETCONF payload: negated nodes become
  nc:operation="delete" elements, additions use the default merge
  operation, and attribute-level changes raise InvalidConfigError.
  Keyed list-entry deletions are expressed by their key leaf, resolved
  against the running config when available; the standalone function
  falls back to value-bearing leaf deletes.
- Fix XML ingestion to key an element whenever an identifying list_keys
  child exists rather than only when its tag repeats among siblings.
  Previously the same entry got different node text depending on
  sibling count, producing spurious delete-and-re-add diffs between
  configs with different list-entry counts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jtdub
jtdub requested a review from aedwardstx as a code owner July 19, 2026 00:30
@jtdub
jtdub merged commit f25069c into next Jul 19, 2026
5 checks passed
@jtdub
jtdub deleted the issue-232-netconf-ops branch July 19, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant