Use nominal NodeID and EdgeID types across graph contracts
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- backend-api-design
Research direction
Start by locating GraphProtocol, EdgeProtocol, and the engine, runtime, event, and snapshot contracts that carry node and edge identifiers; the issue names no file paths, so trace these definitions and their construction or deserialization boundaries first. Review the tests for graph construction, protocols, traversal, streaming, and pause/resume snapshots, then run them with the repository's type checks. Done means distinct shared NodeID and EdgeID types flow through the contracts, strings retain their existing boundary behavior, and static checks catch mixed IDs.
Written by the indexing model from the issue text.
Description
AI disclosure: This issue was drafted with Codex using gpt-6.1-sol. Final review and responsibility remain with the human author.
Problem
Graph node and edge identifiers currently share the type str. For example, GraphProtocol.nodes and GraphProtocol.edges both expose string keys, while EdgeProtocol.id, tail, and head are also strings. The type checker cannot distinguish an edge ID from a node ID.
Introducing nominal types only inside a consumer leaves these graph contracts unchanged. Consumers then need conversions such as map(EdgeID, graph.edges.keys()) solely to bridge str to EdgeID, even though the keys already represent edge IDs. This spreads typing adapters through otherwise straightforward graph operations.
Proposed change
- Define canonical shared
NodeIDandEdgeIDnominal types, for example withtyping.NewType, in a low-level module accessible to graph, runtime, and event contracts. - Use them consistently for node identities, edge identities/endpoints, graph dictionary keys and adjacency lists, and the corresponding engine/runtime/event/snapshot fields.
- Convert external strings at construction and deserialization boundaries. Internal consumers should receive correctly typed identifiers without repeated conversions.
- Keep graph identifiers distinct from execution, frame, and invocation identifiers.
In particular, GraphProtocol.edges should expose Mapping[EdgeID, EdgeProtocol], GraphProtocol.nodes should expose Mapping[NodeID, NodeProtocol], and edge endpoints should be NodeID.
Compatibility and validation
- Preserve identifier values, string JSON representation, existing DSL/selector semantics, and historical snapshot compatibility. This is a typing refactor, not new ID validation or a runtime behavior change.
- Document any impact on public typing contracts and supported string-input boundaries.
- Verify that static checks reject node/edge ID mix-ups and accept direct iteration over typed graph keys without consumer-local conversions.
- Run the relevant graph construction, protocol, traversal, streaming, and pause/resume/snapshot tests alongside the normal type and repository checks.
Related motivation: #400, which currently needs response-filter-local ID types and boundary conversions. This issue concerns the shared graph contracts and can be implemented independently of the reachability algorithm change.
- Dominant language
- Python
- Stars
- 90
- Forks
- 47
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 19
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from langgenius/graphon
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
langgenius/graphon#443 ·
Maintainers usually reply within 2 days
-
Complete LLM results disappear from streamed answersPossibly taken @WH-2099 claimed this 13 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
langgenius/graphon#389 · 1 comment · 1 assignee ·
Maintainers usually reply within 2 days
-
bug(utils): parse_json_markdown drops a valid payload when the text contains a backtickPossibly taken @WH-2099 claimed this 9 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
langgenius/graphon#380 · 1 assignee ·
Maintainers usually reply within 2 days
-
project#graphon
Difficulty 4/5 3-5 days Newbie friendliness 40/100
langgenius/graphon#442 ·
Maintainers usually reply within 2 days
-
project#graphon
Difficulty 3/5 1-2 days Newbie friendliness 50/100
langgenius/graphon#438 · 1 comment ·
Maintainers usually reply within 2 days
All issues in langgenius/graphon
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
micronaut-projects/micronaut-core#14585 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
[BUG]: Management endpoints /v1/memory/stats and /v1/memory/counts bypass API key authenticationOpen
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
docling-project/docling-serve#788 ·
Maintainers usually reply within 1 day
-
Mend: dependency security vulnerability untriaged
Difficulty 1/5 Under an hour Newbie friendliness 78/100
opensearch-project/cross-cluster-replication#1805 ·
Maintainers usually reply within 1 day
-
load_advbench() re-raises HTTPError as the bare class, so a failed download ends in a TypeErrorOpenneeds-triage
Difficulty 1/5 Under an hour Newbie friendliness 82/100
Maintainers usually reply within 2 days