Module: Rigor::Effects::PathFinder
- Defined in:
- lib/rigor/effects/path_finder.rb
Overview
"Why does this entry point reach io.net.http?" — the shortest edge path from a method to the
origin that introduced a label (ADR-103 WD7; design note § 9.4, "the review feature that pays for
the fixpoint").
OrdersController#create → OrderService#place → PaymentGateway#charge → Net::HTTP.get [io.net.http]
A breadth-first walk over the EffectTable's resolved edges, so the answer is a shortest path rather than whichever one a depth-first walk stumbled into first — a reviewer wants the tightest explanation available. Ties break on sorted key order, so two runs explain a change identically.
The path ends at the origin, not at the last method: the catalogue row or language construct that actually coloured the label is what the reviewer is looking for, and the method that owns it is the hop before.
Defined Under Namespace
Classes: Path
Class Method Summary collapse
-
.explain_all(table, symbol:) ⇒ Object
Every label of
symbol's transitive summary, explained. -
.shortest(table, symbol:, label:) ⇒ Object
The shortest path from
symbolto a direct origin oflabel, or nil when the table proves the label nowhere reachable from it.
Class Method Details
.explain_all(table, symbol:) ⇒ Object
Every label of symbol's transitive summary, explained. Sorted by label, so the output is stable.
49 50 51 52 53 54 |
# File 'lib/rigor/effects/path_finder.rb', line 49 def explain_all(table, symbol:) entry = table[symbol] return [] if entry.nil? entry.proven.to_a.filter_map { |label| shortest(table, symbol: symbol, label: label) } end |
.shortest(table, symbol:, label:) ⇒ Object
The shortest path from symbol to a direct origin of label, or nil when the table proves the
label nowhere reachable from it.
41 42 43 44 45 46 |
# File 'lib/rigor/effects/path_finder.rb', line 41 def shortest(table, symbol:, label:) entry = table[symbol] return nil if entry.nil? walk(table, symbol, label) end |