Skip to content

feat: Neo4j entity graph (phase 9) — catalog sync, Dagster asset, S2 /graph endpoints - #31

Merged
oldhero5 merged 9 commits into
mainfrom
feat/entity-graph
Jul 17, 2026
Merged

feat: Neo4j entity graph (phase 9) — catalog sync, Dagster asset, S2 /graph endpoints#31
oldhero5 merged 9 commits into
mainfrom
feat/entity-graph

Conversation

@oldhero5

Copy link
Copy Markdown
Owner

Summary

Builds the reserved phase-9 Neo4j entity graph: the what/who/connected layer over the instrument catalog. Numbers stay in ArcticDB — the graph mirrors identity only (instruments, balancing authorities, ERCOT hubs/load zones, NOAA regions, commodities, observed fuel types) plus curated cross-domain edges, per the original unified-platform spec's locked decision #8.

  • energex.core.graph (pure): build_entity_graph() derives a GraphPlan from symbology + connector vocabularies + store-observed entities; compiles to batched idempotent UNWIND…MERGE Cypher with first_seen/last_seen provenance. The neo4j driver (6.2.0 as locked) is imported lazily in exactly one function; sync/queries duck-type the driver, so no test or graph-extra-less install ever imports it.
  • Orchestration: Neo4jResource (EnvVar-bound, redacted errors), entity_graph asset with store-driven discovery (BAs from power.demand symbols, fuel types from power.generation_by_fuel tails — no hardcoded lists), entity_graph_instruments_resolve asset check, daily 06:10 ET schedule that probes reachability and skips (not fails) when the optional neo4j is absent.
  • S2 read API: GET /graph/entities + GET /graph/related (semantic-rel traversal only), lazy connect with 15s backoff, 503 degradation, additive graph flag on /healthz; gated by the optional API key like every other data endpoint.
  • Wiring/docs: api image gains the graph extra + NEO4J env; CI graph-gate job; .env.example NEO4J_AUTH/NEO4J_PASSWORD sync warning; new website/docs/entity-graph.md + contract-table additions.

Verification

  • 296 tests green (41 graph tests, all offline via duck-typed fake drivers — no Neo4j in CI); ruff clean; docs site builds.
  • Live-verified against neo4j:5.26.0-community: driver-6.x compatibility, idempotent re-sync (identical counts, stable first_seen), /graph/* end-to-end through uvicorn.
  • Synced against the production store: 539 nodes / 1,332 edges from 73 discovered balancing authorities.
  • A 20-agent adversarial review produced 10 confirmed findings, all fixed in fix(graph).

Notes for review

Test plan

  • CI: all gates including the new graph-gate
  • docker compose --profile full up -d --build, materialize entity_graph in Dagster, browse http://localhost:7474
  • curl localhost:8000/graph/related?instrument_id=ERCOT.SPP.HB_NORTH

🤖 Generated with Claude Code

oldhero5 and others added 9 commits July 17, 2026 05:50
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ies)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
… schedule

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nal, 503-degrading)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…-sync note

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- fuel-only BAs become full plan nodes (never bare edge-MERGE nodes)
- schedule probes neo4j reachability and skips instead of failing daily
  in profiles without the optional server
- readapi backs off 15s between failed graph connects so an unreachable
  neo4j cannot stall the threadpool
- _redact_uri strips userinfo from scheme-less URIs too
- tests: neo4j temporal-type cleaning, query-time 503s, Cypher shape for
  label=None, connect backoff, schedule skip/fire
- docs: note that GENERATES fuel mix is under-reported pending the
  generation-by-fuel storage dedup fix (flagged separately)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oldhero5
oldhero5 merged commit 1f33b43 into main Jul 17, 2026
11 checks passed
@oldhero5
oldhero5 deleted the feat/entity-graph branch July 17, 2026 09:58
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