0.8.0-dev7: :AFFECTS edge resolution + target/subject consistency#8
Merged
Merged
Conversation
Second small polish to the dev5 pipeline. The dev5+dev6 deploys produced 31 :ReflexEvent nodes (real data) but none of them connected to their :Device nodes via :AFFECTS. Root cause: link_down handler preferred payload['device_id'] over payload['device'], producing targets like 'meraki:Q4CD-Y6FW-EKVS|Port 9' - a Neo4j node-id form that no Device node had as its name or platform_id. Two-sided fix: 1. link_down handler now prefers payload['device'] (human name) over payload['device_id'] so the target string matches the subject token built by the publisher. Falls back to device_id when device is absent (legacy publishers, traps). 2. Neo4jReflexEventSink AFFECTS-edge MATCH now resolves devices on three identifiers: d.name, d.platform_id, AND d.id - the latter catches node-id-form targets if a future publisher emits them. Tests: 2 new cases covering both ordering preferences. CHANGELOG includes a Cypher snippet to backfill the existing 31 nodes with :AFFECTS edges after deploy. Co-authored-by: Cursor <cursoragent@cursor.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
Second small polish to the dev5 pipeline, caught by deployment verification.
The dev5+dev6 deploys produced 31
:ReflexEventnodes (real data, including 28 from Meraki MS switches after the dev6 fix landed), but none of them connected to their:Devicenodes via:AFFECTS.Root cause: the
link_downhandler preferredpayload[\"device_id\"]overpayload[\"device\"], which produced targets like'meraki:Q4CD-Y6FW-EKVS|Port 9'— a Neo4j node-id form that no Device node had as itsnameorplatform_id.Fix (two-sided, low-risk)
link_downnow preferspayload[\"device\"](human name) overpayload[\"device_id\"]. Falls back todevice_idwhendeviceis absent (legacy publishers, traps).Neo4jReflexEventSinkAFFECTS-edge MATCH now resolves on three identifiers:d.name,d.platform_id, ANDd.id— the third catches node-id-form targets if a future publisher emits them.The handler fix makes the target consistent with the subject token; the sink fix makes the edge resolution forgiving of any remaining identifier-form drift.
Tests
Backfill plan
After deploy, run this Cypher once to retrofit the 31 already-captured events:
```cypher
MATCH (e:ReflexEvent) WHERE NOT (e)-[:AFFECTS]->(:Device)
WITH e, split(e.target, '|')[0] AS device_key
MATCH (d:Device)
WHERE d.name = device_key OR d.platform_id = device_key OR d.id = device_key
MERGE (e)-[:AFFECTS]->(d)
RETURN count(*) AS backfilled
```
Test plan
Made with Cursor