Skip to content
CAI
Software that uses CAICheck a score

gnieh/diffson

61.1

Adequate · 6 November 2026

2.8k

lines of production code

Scala

primary language

4

measurements over time

CAI band scale
CAI trend line
CAI lens gauges

What this system is

Diffson is a Scala library that computes diffs and applies JSON patches and merge patches according to RFC 6902 and RFC 7396. It provides a modular, type-class-based architecture that supports multiple JSON libraries, including Circe, Play-JSON, ujson, and spray-json. The system implements various diffing algorithms, such as Patience LCS and dynamic programming, to handle JSON structure comparisons efficiently.

How it got here

2013–2016 — Modernization and multi-library support

5 changes.

The project underwent a significant architectural overhaul by migrating to the Cats library and adopting a type-class-based API, which enabled support for multiple JSON libraries including Play-JSON, Circe, and ujson. Legacy Lift JSON implementations and their associated tests were removed to streamline the codebase, while the build infrastructure was updated to sbt 1.x to support modern Scala versions and cross-compilation targets like Scala.js and Scala Native.

2019–2023 — Core refactoring and multi-format integration

15 changes.

The library underwent a significant architectural overhaul, replacing its core logic with a modular, type-class-based design and rewriting the JSON Patch engine for better performance and stack safety. This period also focused on expanding ecosystem support by adding integration modules for spray-json, ujson, and Play JSON, alongside a new JSON Pointer implementation. Extensive testing and benchmarking were added to ensure conformance with RFC standards and validate the efficiency of the new diff algorithms.

Features

Add Play JSON integration for JSON Patch and Merge Patch

This change introduces a new Play JSON module that enables serialization and deserialization of JSON Patch and JSON Merge Patch operations using Play's JsValue. It provides the necessary implicit Formats for JsonPatch, JsonMergePatch, Pointer, and Operation types, along with a Jsony instance to bridge the library's core abstractions with Play's JSON API, allowing users to apply and serialize patches directly with Play JSON objects.

playJson/shared · high confidence

Add ujson integration for JSON Patch and Merge Patch

This change introduces a new integration module for the ujson library, enabling Diffson to work with ujson's \Value\ type. It provides the necessary serialization and deserialization logic (via upickle) for JSON Patch and JSON Merge Patch operations, allowing users to apply patches to ujson-backed JSON documents. The implementation includes the core bridge in \package.scala\ and a comprehensive suite of tests to verify functionality.

circe/shared/src/main, ujson/shared · high confidence

Added spray-json integration for JSON Patch and Merge Patch operations

Users can now apply JSON Patch and JSON Merge Patch operations using spray-json as the underlying JSON representation. This change introduces the \DiffsonProtocol\ trait and \sprayJsonJsony\ implicit object, which provide serialization and deserialization formats for JSON Pointer, JSON Patch operations (add, remove, replace, move, copy, test), and JSON Merge Patch structures, enabling seamless integration with the spray-json library.

sprayJson/src/main · high confidence

New JSON Merge Patch support and rewritten JSON Patch engine

The library now includes a new JSON Merge Patch implementation (JsonMergeDiff and JsonMergePatch) alongside a complete rewrite of the JSON Patch engine. The JSON Patch core has been refactored to use Cats Effect (Eval, Chain) for improved performance and to prevent stack overflows on wide objects, and it now supports an optional 'remember old values' mode for operations like Replace and Remove.

core/src/main/scala/diffson/jsonpatch · high confidence

New JSON Pointer implementation in diffson

The \core/src/main/scala/diffson/jsonpointer\ location now contains a new \package.scala\ file that introduces the core JSON Pointer data structures and logic for the diffson library. This includes the \Pointer\ case class, which represents a JSON Pointer as a chain of string keys or integer indices, and its \evaluate\ method, which resolves the pointer against a JSON document using a \MonadError\ context. The implementation handles JSON Pointer parsing (including escape sequences like \\~0\ and \\~1\), integer overflow protection via raw string handling, and specific error raising for invalid paths or out-of-bounds array access. It also provides companion objects (\Inner\, \Leaf\, \ArrayIndex\, \ObjectField\) for pattern matching on pointer segments.

core/src/main/scala/diffson/jsonpointer · high confidence

Removals

Removal of Lift JSON implementation and core diffing classes

The core implementation files for JSON diffing and patching using the Lift JSON library have been removed from the source tree. Specifically, \JsonDiff.scala\ (which provided the default patience algorithm for computing diffs), \JsonPatch.scala\ (handling RFC 6902 patch application and parsing), \JsonPointer.scala\ (RFC 6901 pointer evaluation), \Patience.scala\ (the LCS algorithm), and \package.scala\ (containing implicit conversions and default formats) are all deleted. This change eliminates the existing Lift-based JSON processing capabilities from the \gnieh.diffson\ package.

src/main · high confidence

Behavioural changes

Core library refactored to use a type-class based architecture

The core diffing and patching logic has been rewritten to rely on Scala type-classes rather than the previous implementation. New abstractions including \Diff\, \Patch\, and \Jsony\ define the interfaces for comparing JSON structures and applying patches, while \package.scala\ provides convenient extension methods (such as \diff\ and \apply\) and extractors (\JsObject\, \JsArray\) to simplify usage. This change shifts the library's design towards a more modular, type-driven approach for handling JSON operations.

core/src/main/scala/diffson · high confidence

Migrate build infrastructure to sbt 1.13 and Typelevel plugins

The project has migrated its build system from the legacy sbt 0.13 \Build.scala\ style to the modern sbt 1.x structure, setting the build version to 1.13.0. This change replaces the \sbt-osgi\ plugin with \sbt-typelevel\ (0.8.7) and adds support for cross-compilation to Scala.js (1.22.0) and Scala Native (0.5.12), alongside the \sbt-jmh\ benchmarking plugin.

project · high confidence

Migration to Diffson 4.x with Cats-based API and Multi-library Support

The library has been upgraded to version 4.x, introducing a significant API change by adopting the Cats library for its type-class approach (using \MonadError\ for error handling) and renaming the \gnieh.diffson\ package to \diffson\. This update adds support for RFC-7396 (JSON Merge Patches) alongside existing RFC-6901/6902 features, and expands JSON library compatibility to include Play-JSON, Circe, and ujson/upickle in addition to the original spray-json. The build infrastructure has also been modernized to support Scala 2.12, 2.13, and 3, including Scala.js and Scala Native targets, with CI configured for Travis and coverage reporting.

(repo-wide) · high confidence

Refactored LCS algorithm implementations and interface

The Longest Common Subsequence (LCS) logic has been restructured to improve performance and code organization. The core interface, Lcs, now operates on List slices with explicit bounds rather than generic sequences, allowing implementations to avoid unnecessary data copying. New implementations include DynamicProgLcs, which uses a dynamic programming approach with optimized tail-recursive matrix filling, and Patience, which employs the patience sorting algorithm with an optional fallback to the dynamic programming method for cases where patience sorting cannot find the LCS. Additionally, HashedLcs provides a decorator that pre-computes hashes to speed up comparisons for objects with expensive hashCode calculations.

core/src/main/scala/diffson/lcs · high confidence

Test coverage

Added Circe conformance tests for JSON Patch; Added Circe-specific test suite for JSON diffing operations; Added Play JSON conformance tests for JSON Patch; Added Spray JSON conformance tests; Added benchmarks for the Patience LCS diff algorithm; Added comprehensive test suite for JSON Patch, Diff, and Merge Patch functionality; Added test suite for spray-json integration; Added tests for LCS algorithms; Removed legacy Lift-json based test suite.

Dependencies

Update core and module dependencies to latest versions

The build configuration updates several key dependencies: Scala versions are set to 2.12.21, 2.13.18, and 3.3.8; test libraries are upgraded to scalatest 3.2.20 and scalacheck 1.20.0; and core libraries are updated to scala-collection-compat 2.14.0 and cats-core 2.13.0. Module-specific dependencies are also refreshed, including play-json 3.1.0-M10, circe 0.14.16, and ujson/upickle 4.4.3.

(dependencies) · high confidence

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Score

  • CAI 62 → 61 (-1.4)
  • Rubric changed (rubric-2026.10.5 → rubric-2026.11.2) — scores are not directly comparable.

Lenses

  • Code Health 74 → 74 (+0.0)
  • Architecture 100 → 100 (+0.0)
  • Maturity 53 → 53 (+0.0)
  • Readiness 63 → 61 (-1.9)
  • Security 82 → 70 (-12.1)
  • Performance 74 → 74 (+0.0)

Resolved (2)

  • Off-boarding risk: anonymized user #1
  • Outdated: io.circe:circe-literal_2.13

New (2)

  • Dependency hygiene PARTLY measured — sbt declarations read, dependency currency not (Maven Central unreachable)
  • Off-boarding risk: anonymized user #1

Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

gnieh/diffson was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 6 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit ad3601588d8104bbfc9a160f0feeb9e13860ccc7 — the exact code this score is about.
  • Scored under rubric-2026.11.2 — the same rubric and the same method as every other entry in this index.
  • Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.3+preprod-60d1b390edf0.