Skip to content

fix: endpoint import on tag-scoped syncs + tag merge name collision (2.4.4)#45

Merged
captainpacket merged 2 commits into
mainfrom
fix/endpoint-scope-and-tag-merge
Jul 9, 2026
Merged

fix: endpoint import on tag-scoped syncs + tag merge name collision (2.4.4)#45
captainpacket merged 2 commits into
mainfrom
fix/endpoint-scope-and-tag-merge

Conversation

@captainpacket

Copy link
Copy Markdown
Collaborator

Problem

A design partner on 2.4.2/2.4.3 with a device-tag include scope still saw zero SNMP endpoints (Avocents), plus 5 merge-phase Tag with this Name already exists ingestion issues. Multi-agent trace found two independent scope defects that made endpoint import impossible on any tag-scoped sync (publish/refresh could never fix it):

  1. Query-side: the endpoint branch required endpoints to carry the device include tags — endpoints rarely share device scoping tags, so Forward filtered every endpoint.
  2. Plugin-side: scoped_device_names was built from network.devices only, so _apply_device_tag_scope dropped every endpoint row unconditionally — and with prune-out-of-scope on, dropped rows become deletes.

Changes

  • Endpoint branches (forward_devices.nqe, forward_devices_with_netbox_aliases.nqe): exclude tags only — include scope narrows modeled devices, not endpoints.
  • _resolve_scoped_tag_scope + new _resolve_scoped_endpoint_names: with sync_endpoints on, endpoint names (exclude-honoring probe) union into the scoped set so the local filter and prune keep them. Probe failure disables endpoint emission for the run (never proceeds with an endpoint-less scope → no risk of pruning imported endpoints) and skips the context-artifact save; memo key + artifact (v3) include the toggle.
  • bulk_merge._flush: same-named/same-slug main-side extras.tag treated as already merged (skip counted as applied) — kills the mid-merge name-collision ValidationErrors. Differing non-unique attrs converge next sync.

Validation

  • Live on ADP reproducing the partner scenario (include tags endpoints don't carry + sync_endpoints on): both device queries emit 355 Avocent/console endpoints; scope union adds 688 endpoint names; local filter keeps endpoint rows, drops out-of-scope devices.
  • Adversarial (codex) review: found the probe-failure/prune-delete hazard → fixed + test-locked; tag-metadata convergence documented.
  • New tests: scope union, exclude-tag probe, probe-failure flag, NQE include-scope removal, real branch-merge tag collision. Full suite 994 OK + lint + harness green.

…2.4.4)

SNMP-endpoint import (sync_endpoints) never worked on tag-scoped syncs. Two
independent defects: the endpoint query branch required endpoints to carry the
device include tags (endpoints rarely share device scoping tags, so Forward
filtered them all), and the local scope filter's device set was built from
network.devices only, so every endpoint row was dropped — with
prune-out-of-scope enabled they would even be emitted as deletes.

The endpoint branch now applies exclude tags only, and with sync_endpoints on a
dedicated endpoint probe (exclude tags honored) unions endpoint names into
scoped_device_names so the local filter and prune keep them. A probe failure
disables endpoint emission for the run (and skips the context-artifact save)
instead of risking deletes. The context memo key and shared context artifact
(v3) include the toggle so an endpoint-less scope is never reused.

Also fixes the merge-phase "Tag with this Name already exists" issues: device
updates (ordered before creates) set tags by name, creating the tag on main
with a new pk; the branch's tag create then collided on the unique name.
bulk_merge now treats a same-named/same-slug main-side tag as already merged;
differing non-unique attrs converge on the next sync.

Validated live reproducing the reported scenario (include tags endpoints don't
carry + endpoint import on): 355 Avocent/console endpoints import under a
tag-scoped sync. Full suite (994) + lint + harness green.
@captainpacket captainpacket merged commit 56d68c5 into main Jul 9, 2026
2 checks passed
@captainpacket captainpacket deleted the fix/endpoint-scope-and-tag-merge branch July 9, 2026 04:01
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