From c7e5c7fa2d580681f8d754fae377d42ac8fc8abe Mon Sep 17 00:00:00 2001 From: hsiegeln <37154749+hsiegeln@users.noreply.github.com> Date: Thu, 23 Apr 2026 19:02:47 +0200 Subject: [PATCH] refactor(diagrams): retire findContentHashForRouteByAgents All production callers migrated to findLatestContentHashForAppRoute in the preceding commits. The agent-scoped lookup adds no coverage beyond the latest-per-(app,env,route) resolver, so the dead API is removed along with its test coverage and unused imports. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../app/storage/ClickHouseDiagramStore.java | 32 ------------------- .../app/storage/ClickHouseDiagramStoreIT.java | 18 ----------- .../server/core/storage/DiagramStore.java | 8 ++--- .../core/ingestion/ChunkAccumulatorTest.java | 1 - 4 files changed, 2 insertions(+), 57 deletions(-) diff --git a/cameleer-server-app/src/main/java/com/cameleer/server/app/storage/ClickHouseDiagramStore.java b/cameleer-server-app/src/main/java/com/cameleer/server/app/storage/ClickHouseDiagramStore.java index dc2b879f..c1c27252 100644 --- a/cameleer-server-app/src/main/java/com/cameleer/server/app/storage/ClickHouseDiagramStore.java +++ b/cameleer-server-app/src/main/java/com/cameleer/server/app/storage/ClickHouseDiagramStore.java @@ -16,8 +16,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.sql.Timestamp; import java.time.Instant; -import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.HexFormat; import java.util.List; @@ -203,36 +201,6 @@ public class ClickHouseDiagramStore implements DiagramStore { return Optional.of(hash); } - @Override - public Optional findContentHashForRouteByAgents(String routeId, List agentIds) { - if (agentIds == null || agentIds.isEmpty()) { - return Optional.empty(); - } - - // Try cache first — return first hit - for (String agentId : agentIds) { - String cached = hashCache.get(cacheKey(routeId, agentId)); - if (cached != null) { - return Optional.of(cached); - } - } - - // Fall back to ClickHouse - String placeholders = String.join(", ", Collections.nCopies(agentIds.size(), "?")); - String sql = "SELECT content_hash FROM route_diagrams " + - "WHERE tenant_id = ? AND route_id = ? AND instance_id IN (" + placeholders + ") " + - "ORDER BY created_at DESC LIMIT 1"; - var params = new ArrayList(); - params.add(tenantId); - params.add(routeId); - params.addAll(agentIds); - List> rows = jdbc.queryForList(sql, params.toArray()); - if (rows.isEmpty()) { - return Optional.empty(); - } - return Optional.of((String) rows.get(0).get("content_hash")); - } - @Override public Optional findLatestContentHashForAppRoute(String applicationId, String routeId, diff --git a/cameleer-server-app/src/test/java/com/cameleer/server/app/storage/ClickHouseDiagramStoreIT.java b/cameleer-server-app/src/test/java/com/cameleer/server/app/storage/ClickHouseDiagramStoreIT.java index d986a851..7effec1d 100644 --- a/cameleer-server-app/src/test/java/com/cameleer/server/app/storage/ClickHouseDiagramStoreIT.java +++ b/cameleer-server-app/src/test/java/com/cameleer/server/app/storage/ClickHouseDiagramStoreIT.java @@ -154,24 +154,6 @@ class ClickHouseDiagramStoreIT { assertThat(retrieved.getDescription()).isEqualTo("v2"); } - @Test - void findContentHashForRouteByAgents_returnsHash() { - RouteGraph graph = buildGraph("route-4", "node-z"); - store.store(tagged("agent-10", "app-b", graph)); - store.store(tagged("agent-20", "app-b", graph)); - - Optional result = store.findContentHashForRouteByAgents( - "route-4", java.util.List.of("agent-10", "agent-20")); - - assertThat(result).isPresent(); - } - - @Test - void findContentHashForRouteByAgents_emptyListReturnsEmpty() { - Optional result = store.findContentHashForRouteByAgents("route-x", java.util.List.of()); - assertThat(result).isEmpty(); - } - @Test void findProcessorRouteMapping_extractsMapping() { // Build a graph with 3 nodes: root + 2 children diff --git a/cameleer-server-core/src/main/java/com/cameleer/server/core/storage/DiagramStore.java b/cameleer-server-core/src/main/java/com/cameleer/server/core/storage/DiagramStore.java index 5b2a007a..09b809ae 100644 --- a/cameleer-server-core/src/main/java/com/cameleer/server/core/storage/DiagramStore.java +++ b/cameleer-server-core/src/main/java/com/cameleer/server/core/storage/DiagramStore.java @@ -3,7 +3,6 @@ package com.cameleer.server.core.storage; import com.cameleer.common.graph.RouteGraph; import com.cameleer.server.core.ingestion.TaggedDiagram; -import java.util.List; import java.util.Map; import java.util.Optional; @@ -15,16 +14,13 @@ public interface DiagramStore { Optional findContentHashForRoute(String routeId, String instanceId); - Optional findContentHashForRouteByAgents(String routeId, List 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. * - *

Unlike {@link #findContentHashForRoute(String, String)} and - * {@link #findContentHashForRouteByAgents(String, List)}, this lookup is - * independent of the agent registry — so it keeps working for routes + *

Unlike {@link #findContentHashForRoute(String, String)}, this lookup + * is independent of the agent registry — so it keeps working for routes * whose publishing agents have since been redeployed or removed. */ Optional findLatestContentHashForAppRoute(String applicationId, diff --git a/cameleer-server-core/src/test/java/com/cameleer/server/core/ingestion/ChunkAccumulatorTest.java b/cameleer-server-core/src/test/java/com/cameleer/server/core/ingestion/ChunkAccumulatorTest.java index ecbea1f1..83b3d92c 100644 --- a/cameleer-server-core/src/test/java/com/cameleer/server/core/ingestion/ChunkAccumulatorTest.java +++ b/cameleer-server-core/src/test/java/com/cameleer/server/core/ingestion/ChunkAccumulatorTest.java @@ -22,7 +22,6 @@ class ChunkAccumulatorTest { public void store(com.cameleer.server.core.ingestion.TaggedDiagram d) {} public Optional findByContentHash(String h) { return Optional.empty(); } public Optional findContentHashForRoute(String r, String a) { return Optional.empty(); } - public Optional findContentHashForRouteByAgents(String r, List a) { return Optional.empty(); } public Optional findLatestContentHashForAppRoute(String app, String r, String env) { return Optional.empty(); } public Map findProcessorRouteMapping(String app, String env) { return Map.of(); } };