Path: redb/redb.Core/Utils/LoadedGraphInspector.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Core/Utils/LoadedGraphInspector.cs
----
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using redb.Core.Models.Contracts;
using redb.Core.Models.Entities;
namespace redb.Core.Utils;
///
/// V4 (review, owner decision 2026-09-01): the props-cache dirty guard, one level deeper.
///
///
/// The parent's own hash is composed of id:hash of its references (L.2), so an unsaved
/// in-memory edit INSIDE a loaded nested object does not move it: the root check of the cache sees
/// a clean object and would serve the graph with the phantom edit - the SetStatus-before-Save
/// incident, one level down. This walk visits the LOADED part of a cached graph (raw Props only,
/// stubs are neither touched nor woken) and asks each nested object whether its live content hash
/// still equals its own persisted hash; after the V4 hash fixes the two are equal by construction
/// for an unmodified object, so any drift means an unsaved edit somewhere in the graph.
///
///
public static class LoadedGraphInspector
{
///
/// True when a LOADED object under carries a live content hash that
/// differs from its own persisted hash - an unsaved in-memory edit. Stubs and objects
/// that were never persisted (no hash) are skipped.
///
public static bool HasDirtyLoadedReference(object? props)
{
if (props == null) return false;
var visited = new HashSet