Skip to content

Commit deb35a0

Browse files
v0.17.3 - fix flaky link path filter
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 85eb9d9 commit deb35a0

5 files changed

Lines changed: 34 additions & 8 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.17.3] - 2026-02-02
9+
10+
### Fixed
11+
12+
- Link path filter now uses deterministic `{source}|{target}` instead of full link ID
13+
814
## [0.17.2] - 2026-02-02
915

1016
### Changed

ngraph/model/failure/generate.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,18 @@ def generate_risk_groups(network: "Network", spec: GenerateSpec) -> List[RiskGro
7777

7878
# Apply path filter if specified
7979
if path_pattern:
80-
entities = [
81-
(eid, entity, attrs)
82-
for eid, entity, attrs in entities
83-
if path_pattern.match(eid)
84-
]
80+
if spec.scope == "node":
81+
entities = [
82+
(eid, entity, attrs)
83+
for eid, entity, attrs in entities
84+
if path_pattern.match(eid)
85+
]
86+
else:
87+
entities = [
88+
(eid, entity, attrs)
89+
for eid, entity, attrs in entities
90+
if path_pattern.match(f"{attrs['source']}|{attrs['target']}")
91+
]
8592

8693
# Group by attribute value
8794
groups: Dict[Any, List] = defaultdict(list)

ngraph/model/failure/membership.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,11 @@ def _select_entities(
186186
}
187187
# Start with all or path-filtered IDs
188188
if path_pattern:
189-
candidate_ids = {eid for eid in entity_attrs if path_pattern.match(eid)}
189+
candidate_ids = {
190+
eid
191+
for eid, attrs in entity_attrs.items()
192+
if path_pattern.match(f"{attrs['source']}|{attrs['target']}")
193+
}
190194
else:
191195
candidate_ids = set(entity_attrs.keys())
192196

ngraph/model/failure/policy.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,16 @@ def _match_scope(
255255
# Apply path filter if specified
256256
if rule.path:
257257
pattern = re.compile(rule.path)
258-
candidates = {eid for eid in candidates if pattern.match(eid)}
258+
if rule.scope == "link":
259+
candidates = {
260+
eid
261+
for eid in candidates
262+
if pattern.match(
263+
f"{network_links[eid]['source']}|{network_links[eid]['target']}"
264+
)
265+
}
266+
else:
267+
candidates = {eid for eid in candidates if pattern.match(eid)}
259268

260269
return candidates
261270

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
55
# ---------------------------------------------------------------------
66
[project]
77
name = "ngraph"
8-
version = "0.17.2"
8+
version = "0.17.3"
99
description = "A tool and a library for network modeling and analysis."
1010
readme = "README.md"
1111
authors = [{ name = "Andrey Golovanov" }]

0 commit comments

Comments
 (0)