feat(diagrams): add findLatestContentHashForAppRoute with app-route cache

Agent-scoped lookups miss diagrams from routes whose publishing agents
have been redeployed or removed. The new method resolves by
(applicationId, environment, routeId) + created_at DESC, independent of
the agent registry. An in-memory cache mirrors the existing hashCache
pattern, warm-loaded at startup via argMax.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-23 18:58:49 +02:00
parent e5c8fff0f9
commit d3ce5e861b
3 changed files with 75 additions and 0 deletions

View File

@@ -17,5 +17,19 @@ public interface DiagramStore {
Optional<String> findContentHashForRouteByAgents(String routeId, List<String> instanceIds);
/**
* Return the most recently stored {@code content_hash} for the given
* {@code (applicationId, environment, routeId)} triple, regardless of the
* agent instance that produced it.
*
* <p>Unlike {@link #findContentHashForRoute(String, String)} and
* {@link #findContentHashForRouteByAgents(String, List)}, this lookup is
* independent of the agent registry — so it keeps working for routes
* whose publishing agents have since been redeployed or removed.
*/
Optional<String> findLatestContentHashForAppRoute(String applicationId,
String routeId,
String environment);
Map<String, String> findProcessorRouteMapping(String applicationId, String environment);
}

View File

@@ -23,6 +23,7 @@ class ChunkAccumulatorTest {
public Optional<com.cameleer.common.graph.RouteGraph> findByContentHash(String h) { return Optional.empty(); }
public Optional<String> findContentHashForRoute(String r, String a) { return Optional.empty(); }
public Optional<String> findContentHashForRouteByAgents(String r, List<String> a) { return Optional.empty(); }
public Optional<String> findLatestContentHashForAppRoute(String app, String r, String env) { return Optional.empty(); }
public Map<String, String> findProcessorRouteMapping(String app, String env) { return Map.of(); }
};