class Rigor::ModuleGraph::Edge
A single dependency edge between two constants.
Carries the dependency itself (+from+, +to+, +kind+, +confidence+), the source position it was extracted from (+path+, +line+, +column+), and the raw source slice (+raw+) when the resolution went through a fallback path. Edge is a +Data+ subclass — every instance is immutable.
== Two serialisation shapes
+to_message_payload+:: What the plugin embeds in a diagnostic’s +message+ field. The collector reconstructs an Edge from this payload plus the diagnostic’s own +path+/+line+/+column+, so the payload omits position to keep the message compact. +to_h+:: What the JSONL writer dumps to disk. Full row, with +path+/+line+/+column+ included.
== Dedup key
+dedup_key+ ignores +path+ and +line+ so the same logical edge declared in two files (or surfaced by two re-runs of +rigor check+) collapses to one row. The +dedup_key+ member at the end is internal: it’s the cached +“\x00”+-joined key string the renderers’ dedup loops use for Hash lookups. Storing it on the value pays for itself once a few hundred edges flow through any rendering / IO path.
Constants
- CONFIDENCES
-
Same as
Rigor::ModuleGraph::EDGE_CONFIDENCES; exposed on the class so callers can write +Edge::CONFIDENCES+. - KINDS
-
class so callers can write +Edge::KINDS+.
Public Class Methods
Source
# File lib/rigor/module_graph/edge.rb, line 75 def self.build(from:, to:, kind:, path: nil, line: nil, column: nil, confidence: "syntax", raw: nil) from = from.to_s.freeze to = to.to_s.freeze kind = validate_kind!(kind) confidence = validate_confidence!(confidence) new( from: from, to: to, kind: kind, path: path, line: line, column: column, confidence: confidence, raw: raw, dedup_key: -"#{from}\x00#{to}\x00#{kind}\x00#{confidence}" ) end
Build an Edge, validating +kind+ and +confidence+ against the canonical lists and frozen-stringifying +from+ / +to+. Raises +ArgumentError+ on unknown values.
Public Instance Methods
Source
# File lib/rigor/module_graph/edge.rb, line 110 def to_h h = { "from" => from, "to" => to, "kind" => kind } h["path"] = path if path h["line"] = line if line h["column"] = column if column h["confidence"] = confidence h["raw"] = raw if raw h end
The on-disk JSONL row. Nil-valued positional fields are omitted so a stand-alone edge (e.g. constructed in a test without a path) does not leak +“path”:null+ noise.
Source
# File lib/rigor/module_graph/edge.rb, line 130 def to_json(*args) JSON.generate(to_h, *args) end
Source
# File lib/rigor/module_graph/edge.rb, line 124 def to_message_payload h = { "from" => from, "to" => to, "kind" => kind, "confidence" => confidence } h["raw"] = raw if raw h end
The payload embedded in a +:info+ diagnostic’s message. Position is intentionally absent — the diagnostic carries its own +path+/+line+/+column+, so duplicating them here would just bloat output.