Class: Rigor::Effects::Discharge
- Inherits:
-
Object
- Object
- Rigor::Effects::Discharge
- Defined in:
- lib/rigor/effects/discharge.rb
Overview
effects.tolerated: at judgment time — the discharge policy, per origin (ADR-103 WD1 / WD14;
normative in docs/type-specification/effect-labels.md § Discharge by policy).
The rule the whole slice turns on: a bundle is discharged when ANY of its labels is tolerated.
An origin is one callee or one construct, and its labels are what that one thing does; tolerating
what the origin was for frees the transport it came with. Logger#info is io + telemetry, so
tolerated: [telemetry] discharges the whole bundle — the project has said "logging is fine", and
the io in that bundle is logging. A File.read in the same body is a different origin with a
different bundle, and its io.fs.read still counts. That is why summaries keep labels per origin at
all (Summary#bundles); a flat label set cannot tell the two ios apart.
Discharge is a judgment, never a record. The snapshot on disk holds undischarged sets, the
collector attributes undischarged labels, and only the two consumers below subtract:
EnvelopeCheck (through Propagator's second lane) and SnapshotDiff. --no-tolerated-effects is
the audit switch — the same judgment with NONE — and is what makes the policy inspectable
(Steins ADR-0084 invariant 3).
Class Method Summary collapse
-
.none ⇒ Object
The identity policy: nothing is tolerated, so nothing is discharged.
Instance Method Summary collapse
-
#discharges?(labels) ⇒ Boolean
Whether ONE origin's bundle is discharged: some member of it is tolerated (or subsumed by a tolerated label —
tolerated: [io]discharges anio.fs.readbundle). -
#inert? ⇒ Boolean
Whether the policy discharges nothing at all — the fast path every project that wrote no
tolerated:list takes, and the reason the second propagation lane costs zero when unconfigured. -
#initialize(tolerated) ⇒ Discharge
constructor
A new instance of Discharge.
-
#undischarged(bundles) ⇒ Object
The join of every bundle this policy does NOT discharge — what a judgment reads in place of Summary#proven.
Constructor Details
Class Method Details
.none ⇒ Object
The identity policy: nothing is tolerated, so nothing is discharged. What
--no-tolerated-effects judges with, and what a project that configured no tolerated: list
always has.
27 28 29 |
# File 'lib/rigor/effects/discharge.rb', line 27 def self.none @none ||= new([]) end |
Instance Method Details
#discharges?(labels) ⇒ Boolean
Whether ONE origin's bundle is discharged: some member of it is tolerated (or subsumed by a
tolerated label — tolerated: [io] discharges an io.fs.read bundle). An empty bundle is
discharged by nothing, and never carries anything to discharge.
45 46 47 48 49 |
# File 'lib/rigor/effects/discharge.rb', line 45 def discharges?(labels) return false if inert? labels.to_a.any? { |label| @tolerated.admits?(label) } end |
#inert? ⇒ Boolean
Whether the policy discharges nothing at all — the fast path every project that wrote no
tolerated: list takes, and the reason the second propagation lane costs zero when unconfigured.
38 39 40 |
# File 'lib/rigor/effects/discharge.rb', line 38 def inert? @tolerated.empty? end |
#undischarged(bundles) ⇒ Object
The join of every bundle this policy does NOT discharge — what a judgment reads in place of Summary#proven. A label that arrives through both a discharged and an undischarged origin survives, because the undischarged origin proves it on its own.
54 55 56 57 58 59 60 |
# File 'lib/rigor/effects/discharge.rb', line 54 def undischarged(bundles) return flatten(bundles) if inert? bundles.reduce(LabelSet::EMPTY) do |acc, (_origin, labels)| discharges?(labels) ? acc : acc.join(labels) end end |