Class: Glossarist::Validation::Rules::HyperedgeCoherenceRule

Inherits:
Base
  • Object
show all
Defined in:
lib/glossarist/validation/rules/hyperedge_coherence_rule.rb

Overview

Validates semantic invariants of n-ary relation entries (PartitiveHyperedge, GenericHyperedge) that the model constructor does NOT enforce. The relations are passed in via the ConceptContext (per-file storage — see Glossarist::V3::RelationLoader).

Checks:

- error when a relation has fewer than 2 members
(ISO 704: "two or more"; single binary should use a
has_part edge instead)
- error when two relations share the same comprehensive
AND the same non-empty criterion (duplicate decomposition;
ISO 12620 coordinate-concept coherence)
- warning when a relation has no criterion (cannot
distinguish from siblings sharing the comprehensive)
- warning when a member's presence or count deviates from
the defaults (required / exactly_one) — encourages an
explicit choice rather than an accidental non-default
- error when ExternalConcept (status: external) lacks
at least one designation

The model constructor already rejects empty comprehensive, empty members list, self-loops, invalid enum values, and the optional + at_least_one combination.

Constant Summary collapse

DEFAULT_PRESENCE =
"required"
DEFAULT_COUNT =
"exactly_one"

Instance Method Summary collapse

Methods inherited from Base

inherited

Instance Method Details

#applicable?(context) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
45
46
47
# File 'lib/glossarist/validation/rules/hyperedge_coherence_rule.rb', line 42

def applicable?(context)
  concept = context.concept
  return false unless concept.is_a?(V3::ManagedConcept)

  context.relations&.any? || external?(concept)
end

#categoryObject



38
# File 'lib/glossarist/validation/rules/hyperedge_coherence_rule.rb', line 38

def category = :schema

#check(context) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/glossarist/validation/rules/hyperedge_coherence_rule.rb', line 49

def check(context)
  concept = context.concept
  fname = context.file_name
  relations = context.relations
  issues = []

  return issues unless concept.is_a?(V3::ManagedConcept)

  relations.each_with_index do |rel, idx|
    check_cardinality(rel, idx, fname, issues)
    check_criterion_present(rel, idx, fname, issues)
    check_member_dimensions(rel, idx, fname, issues)
  end

  check_duplicate_decomposition(relations, fname, issues)
  check_external_concept(concept, fname, issues)

  issues
end

#codeObject

Stable identifier for downstream issue trackers / config. Originally assigned when the rule was partitive-only; kept after the rename to GenericHyperedge + n-ary generalization so existing suppression configs continue to work.



37
# File 'lib/glossarist/validation/rules/hyperedge_coherence_rule.rb', line 37

def code = "GLS-221"

#scopeObject



40
# File 'lib/glossarist/validation/rules/hyperedge_coherence_rule.rb', line 40

def scope = :concept

#severityObject



39
# File 'lib/glossarist/validation/rules/hyperedge_coherence_rule.rb', line 39

def severity = "error"