ores.diff

Table of Contents

1. Diagram

ores.diff component diagram

Figure 1: ores.diff

2. Summary

ores.diff is a dependency-light leaf component owning the vocabulary of "what changed" between two versions of an entity. It defines the diff model — field_value (field name plus rendered value), diff_entry (field, old value, new value) and diff_result (ordered entries) — and a compare engine that produces a diff_result from two ordered field lists. Domain services use it to compute history diffs server-side; frontends (UI, shell) render its results without any comparison logic of their own. The types are codec-serialisable so protocol messages can embed them directly.

3. Inputs

  • Ordered field_value lists for the previous and current versions of an entity, produced by per-entity field mappers in domain services.

The model is deliberately flat: one ordered list of (name, rendered value) pairs per version. Nested entities flatten in the mapper, with topology encoded in path-style display names (e.g. Legs[1] / Notional). When a consumer needs real topology — grouping, collapse, list-identity-aware diffs — the model grows an optional path alongside the display name rather than becoming a tree; flat consumers are unaffected.

4. Outputs

  • diff_result values: ordered field-level diff entries, embeddable in NATS protocol messages via the generated codec.

5. Entry points

  • include/ores.diff/domain/field_value.hpp — field name plus rendered value.
  • include/ores.diff/domain/diff_entry.hpp — one changed field: name, old value, new value.
  • include/ores.diff/domain/diff_result.hpp — ordered list of entries.
  • include/ores.diff/engine/compare.hpp — the compare engine: compute(previous, current) → diff_result.

6. Dependencies

  • None beyond std — the component is deliberately a leaf so every domain service and frontend can depend on it without cycles.

7. See also

  • ores.assets.api — a sibling leaf contract component with the same dependency discipline.

ores.utility is a public dependency because the generated codec headers of the four diff types include its codec headers: a component that encodes a diff result reads them too.

target_link_libraries(${lib_target_name}
    PUBLIC
        ores.logging.lib
        ores.platform.lib
        ores.utility.lib)

target_link_libraries(${lib_target_name} PRIVATE ores.codec.pch)
target_link_libraries(${tests_target_name}
    PRIVATE
        ${lib_target_name}
        ores.testing.lib
        ores.logging.lib
        Catch2::Catch2
        faker-cxx::faker-cxx
        ores.openssl_cleanup
        Threads::Threads)

Emacs 29.3 (Org mode 9.6.15)