Module: Rigor::Effects::LabelIntent
- Defined in:
- lib/rigor/effects/label_intent.rb
Overview
Whether an unrecognised effect label is evidence of a typo rather than of a word that was
never meant to be a label at all (ADR-103 WD1; normative in
docs/type-specification/effect-labels.md § Unknown labels).
The degradation an unknown label causes is silent by construction — the tag reads ⊤ and stops
bounding anything — so a paired diagnostic is the only thing that keeps the fail-open rule
honest. But the diagnostic cannot fire on every unrecognised spelling: a vocabulary is open by
design (effects.labels:, a plugin's own root), so an unknown word is as likely to be a label
this project has not registered yet as it is to be a misspelling. Reporting both would put a
finding on correct-by-intent code, which is the direction the false-positive budget is not
allowed to run (ADR-5).
Intent is therefore read off four signals, any one of which is enough:
- A near miss — the spelling is within Registry::SUGGESTION_DISTANCE_CAP edits of a
label the registry knows (
io.bdagainstio.db). - A known sibling — another member of the same comma-separated list is recognised, so the list as a whole is demonstrably written in this vocabulary.
- A dotted path — the token carries two or more segments (
io.netw). Nothing but a label is spelled that way; a project opening its own root writes a bare word first. - A retired spelling — the registry's
retired:table names it, so the author wrote a label that WAS correct and a vocabulary bump moved it.
A lone far-off word (%a{rigor:v1:effect database}) matches none of them and stays silent
everywhere. It still degrades the tag to ⊤ — the reading never depends on this module.
Constant Summary collapse
- MULTI_SEGMENT_ARITY =
How many dot-separated segments make a token unmistakably label-shaped (signal 3).
2
Class Method Summary collapse
-
.evident?(token, registry, siblings: []) ⇒ Boolean
Whether reporting
tokenas an unknown label is justified.
Class Method Details
.evident?(token, registry, siblings: []) ⇒ Boolean
Whether reporting token as an unknown label is justified.
45 46 47 48 49 50 51 52 |
# File 'lib/rigor/effects/label_intent.rb', line 45 def evident?(token, registry, siblings: []) return false if registry.nil? return false unless Label.valid?(token) return false if registry.known?(token) retired?(token, registry) || near_miss?(token, registry) || multi_segment?(token) || known_sibling?(token, registry, siblings) end |