Ancora.ModalClass (ancora v1.0.0)

Copy Markdown View Source

Pure classifier for the normative strength of a requirement statement.

Classifies a statement as one of :must, :shall, :must_not, :shall_not, :should, :may, or :none. Consumed by the append/must_downgraded guard at diff time. The classifier is pure and runs only when asked.

Summary

Functions

Classifies a statement string into a modal atom.

Returns true when moving from prior to current is a modal-class downgrade.

Lists every modal atom in a stable order.

Types

modal()

@type modal() :: :must | :shall | :must_not | :shall_not | :should | :may | :none

Functions

classify(statement)

@spec classify(binary()) :: modal()

Classifies a statement string into a modal atom.

Case and punctuation insensitive. Returns :none for any binary input that does not carry a recognized modal verb. Negative forms take precedence over positive forms.

downgrade?(prior, current)

@spec downgrade?(modal(), modal()) :: boolean()

Returns true when moving from prior to current is a modal-class downgrade.

Total over the 7 × 7 Cartesian product of modals. Behaviour:

  • Identity pairs return false.
  • Transitions starting from :none return false — there is no normative force to lose.
  • Transitions ending at :none return true:none is strictly weaker than any recognized modal.
  • Within a polarity family (positive {:must, :shall, :should, :may}, negative {:must_not, :shall_not}), rank-decreasing transitions return true; rank-increasing transitions return false.
  • Positive → negative cross-polarity returns true.
  • Negative → positive cross-polarity returns false — polarity loss is a separate append-only concern, not a modal-class downgrade.

modals()

@spec modals() :: [modal()]

Lists every modal atom in a stable order.