Skip to content

Release 1.28.0

Latest

Choose a tag to compare

@reid-spencer reid-spencer released this 03 Jul 21:17

What's New

Features

  • compareRoots — Root-AST structural similarity API — A new
    deterministic, model-free API for comparing two RIDDL Root ASTs and
    getting back a similarity score with a full breakdown. Surfaced on the
    cross-platform RiddlLib facade (JVM, JS, and Native):

    def compareRoots(a: Root, b: Root)(using PlatformContext): RootSimilarity
    def similarityMarkdown(a: Root, b: Root)(using PlatformContext): String

    RootSimilarity carries per-kind counts (Map[String, (Int, Int)]),
    fuzzy-matched and unmatched name pairs per definition kind, structural
    metrics (max depth and top-level breadth), and an overall weighted score
    in [0.0, 1.0] — exactly 1.0 for identical models, low for disjoint
    ones. similarityMarkdown renders the same data as a human/AI-readable
    report.

    Matching is on definition kind + fuzzy name (lowercase-alphanumeric
    normalization with greedy best Levenshtein-ratio pairing), making it
    location- and case-independent — a renamed-but-structurally-equal
    model still scores high on structure, and identically named definitions
    at different source locations still match. It never uses
    Definition.equals/hashCode (which include source location). Scoring
    weights DDD-structural kinds (contexts, entities, message types) above
    incidental ones, and blends a count-vector cosine term so that structure
    is rewarded independently of naming.

    This was built for consumers that generate RIDDL models and need a
    regression guard on how closely a generated model matches a
    hand-authored reference — but it is a general-purpose AST diff/compare
    utility usable by any tool.

Notes

  • Additive only — new methods on the RiddlLib trait and object; no
    existing signatures changed. Fully backward compatible with the 1.x line.
  • The comparison core (RootComparison, RootSimilarity,
    KindComparison) lives in com.ossuminc.riddl.passes.analysis and is
    Native-safe (no regex or platform formatting).
  • Verified across JVM, JS, and Native builds.