0.8.0-dev5: first sensory publisher — SNMP link-state → NATS → :ReflexEvent#6
Merged
Merged
Conversation
…xEvent Closes the dev1–dev4 foundation by wiring the first end-to-end pipeline through the agentic architecture: SNMP poll → NATS subject → link_down reflex handler → Neo4j :ReflexEvent node. Until now the bus has been live but idle. After this lands, an interface flap on a real device produces a :ReflexEvent in Neo4j within seconds that operators can query with Cypher. New abstractions (all swappable via Protocol): - ReflexEventSink Protocol — persistence target for reflex outcomes - Neo4jReflexEventSink + InMemoryReflexEventSink in new netcortex.episodic package (the brain metaphor's episodic-memory layer) - SensoryPublisher facade over EventBus — validates source against SENSORY_SOURCES at construction, builds validated sensory_subject() per publish, swallows bus failures so the poll loop never crashes Wiring: - ReflexContext gains event_sink field; runner persists every outcome with sink-failure isolation - SnmpAdapter._poll_device computes ifOperStatus deltas vs prior Neo4j state and publishes one event per transition (first-observation only emits for currently-down to avoid 96-port-switch event storms) - Worker startup constructs the NATS bus, runner, and publisher; clean drain on shutdown; graceful no-op when NATS_URL is unset Tests: - Contract suite for ReflexEventSink (7 cases) - SensoryPublisher unit tests (5 cases) - SNMP link-state publisher unit tests (8 cases incl. all 4 transitions, first-observation, Neo4j-read failure, unknown oper_status) - Runner persistence + sink-failure-isolation tests Smoke-verified locally; full CI suite pending. 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
Closes the loop on the dev1–dev4 foundation by wiring the first end-to-end pipeline through the agentic architecture:
Until now the NATS bus has been live (since dev4 deploy) but idle: no publishers, no consumers acting. After this lands, an interface flap on a real device produces a
:ReflexEventin Neo4j within seconds.What changed
New abstractions (all swappable via Protocol)
ReflexEventSinkProtocol — persistence target for reflex outcomes (idempotentrecord,close).netcortex.episodicpackage — new "episodic memory" layer in the brain metaphor.InMemoryReflexEventSink— test impl, dedup via stable sha256 of(handler, subject, target, occurred_at).Neo4jReflexEventSink— production impl, writes:ReflexEventnodes via shared driver with optional:AFFECTSedge to matched:Device. MERGE on stable id → at-least-once safe.netcortex.thalamus.SensoryPublisher— thin facade overEventBus. ValidatessourceagainstSENSORY_SOURCESat construction, builds validatedsensory_subject()per publish, injectssource/recorded_atdefaults, swallows bus failures so the poll loop never crashes.Wiring
ReflexContextgainsevent_sinkfield; runner persists every outcome with sink-failure isolation (a flaky sink can't kill dispatch).SnmpAdapter._poll_devicecomputesifOperStatusdeltas vs prior Neo4j state and publishes one event per transition. First-observation of an interface only emits for currently-down(prevents 96-port switch event storms on first poll)._start_reflex_pipeline; clean drain on shutdown; graceful no-op whenNATS_URLis unset.Tests
ReflexEventSink(7 cases): well-formed record, idempotency on identity fields, payload-only-difference collapses, differentoccurred_atseparates, idempotent close, record-after-close raises, concurrent record from many tasks.SensoryPublisherunit tests (5 cases): source validation, default injection, bus-failure swallowing, caller override of source/recorded_at.Test plan
localhost:32000/netcortex:0.8.0-dev5helm upgradeoncpn-ful-netcortex1worker.reflex_pipeline_startedwith all 3 handlerssnmp.link_state.transitions_publishedin worker logs (will be zero if no flaps in the window — that's expected):ReflexEventnode appears in Neo4j:Why this matters
DedupStorefrom dev3 will get its first real workout collapsing duplicate observations.Made with Cursor