refactor: rename agent group→application across entire codebase
All checks were successful
CI / build (push) Successful in 1m22s
CI / cleanup-branch (push) Has been skipped
CI / docker (push) Successful in 52s
CI / deploy (push) Successful in 39s
CI / deploy-feature (push) Has been skipped

Complete the group→application terminology rename in the agent
registry subsystem:

- AgentInfo: field group → application, all wither methods updated
- AgentRegistryService: findByGroup → findByApplication
- AgentInstanceResponse: field group → application (API response)
- AgentRegistrationRequest: field group → application (API request)
- JwtServiceImpl: parameter names group → application (JWT claim
  string "group" preserved for token backward compatibility)
- All controllers, lifecycle monitor, command controller updated
- Integration tests: JSON request bodies "group" → "application"
- Frontend: schema.d.ts, openapi.json, agent queries, AgentHealth

RBAC group references (groups table, GroupAdminController, etc.)
are NOT affected — they are a separate domain concept.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-03-24 08:48:12 +01:00
parent 413839452c
commit ff76751629
28 changed files with 104 additions and 4618 deletions

View File

@@ -13,7 +13,7 @@ import java.util.Map;
*
* @param id agent-provided persistent identifier
* @param name human-readable agent name
* @param group logical grouping (e.g., "order-service-prod")
* @param application application name (e.g., "order-service-prod")
* @param version agent software version
* @param routeIds list of Camel route IDs managed by this agent
* @param capabilities agent-declared capabilities (free-form)
@@ -25,7 +25,7 @@ import java.util.Map;
public record AgentInfo(
String id,
String name,
String group,
String application,
String version,
List<String> routeIds,
Map<String, Object> capabilities,
@@ -36,28 +36,28 @@ public record AgentInfo(
) {
public AgentInfo withState(AgentState newState) {
return new AgentInfo(id, name, group, version, routeIds, capabilities,
return new AgentInfo(id, name, application, version, routeIds, capabilities,
newState, registeredAt, lastHeartbeat, staleTransitionTime);
}
public AgentInfo withLastHeartbeat(Instant newLastHeartbeat) {
return new AgentInfo(id, name, group, version, routeIds, capabilities,
return new AgentInfo(id, name, application, version, routeIds, capabilities,
state, registeredAt, newLastHeartbeat, staleTransitionTime);
}
public AgentInfo withRegisteredAt(Instant newRegisteredAt) {
return new AgentInfo(id, name, group, version, routeIds, capabilities,
return new AgentInfo(id, name, application, version, routeIds, capabilities,
state, newRegisteredAt, lastHeartbeat, staleTransitionTime);
}
public AgentInfo withStaleTransitionTime(Instant newStaleTransitionTime) {
return new AgentInfo(id, name, group, version, routeIds, capabilities,
return new AgentInfo(id, name, application, version, routeIds, capabilities,
state, registeredAt, lastHeartbeat, newStaleTransitionTime);
}
public AgentInfo withMetadata(String name, String group, String version,
public AgentInfo withMetadata(String name, String application, String version,
List<String> routeIds, Map<String, Object> capabilities) {
return new AgentInfo(id, name, group, version, routeIds, capabilities,
return new AgentInfo(id, name, application, version, routeIds, capabilities,
state, registeredAt, lastHeartbeat, staleTransitionTime);
}
}

View File

@@ -43,10 +43,10 @@ public class AgentRegistryService {
* Register a new agent or re-register an existing one.
* Re-registration updates metadata, transitions state to LIVE, and resets timestamps.
*/
public AgentInfo register(String id, String name, String group, String version,
public AgentInfo register(String id, String name, String application, String version,
List<String> routeIds, Map<String, Object> capabilities) {
Instant now = Instant.now();
AgentInfo newAgent = new AgentInfo(id, name, group, version,
AgentInfo newAgent = new AgentInfo(id, name, application, version,
List.copyOf(routeIds), Map.copyOf(capabilities),
AgentState.LIVE, now, now, null);
@@ -55,13 +55,13 @@ public class AgentRegistryService {
// Re-registration: update metadata, reset to LIVE
log.info("Agent {} re-registering (was {})", id, existing.state());
return existing
.withMetadata(name, group, version, List.copyOf(routeIds), Map.copyOf(capabilities))
.withMetadata(name, application, version, List.copyOf(routeIds), Map.copyOf(capabilities))
.withState(AgentState.LIVE)
.withLastHeartbeat(now)
.withRegisteredAt(now)
.withStaleTransitionTime(null);
}
log.info("Agent {} registered (name={}, group={})", id, name, group);
log.info("Agent {} registered (name={}, application={})", id, name, application);
return newAgent;
});
@@ -168,11 +168,11 @@ public class AgentRegistryService {
}
/**
* Return all agents belonging to the given application group.
* Return all agents belonging to the given application.
*/
public List<AgentInfo> findByGroup(String group) {
public List<AgentInfo> findByApplication(String application) {
return agents.values().stream()
.filter(a -> group.equals(a.group()))
.filter(a -> application.equals(a.application()))
.collect(Collectors.toList());
}

View File

@@ -14,21 +14,21 @@ public interface JwtService {
/**
* Validated JWT payload.
*
* @param subject the {@code sub} claim (agent ID or {@code user:<username>})
* @param group the {@code group} claim
* @param roles the {@code roles} claim (e.g. {@code ["AGENT"]}, {@code ["ADMIN"]})
* @param subject the {@code sub} claim (agent ID or {@code user:<username>})
* @param application the {@code group} claim (application name)
* @param roles the {@code roles} claim (e.g. {@code ["AGENT"]}, {@code ["ADMIN"]})
*/
record JwtValidationResult(String subject, String group, List<String> roles) {}
record JwtValidationResult(String subject, String application, List<String> roles) {}
/**
* Creates a signed access JWT with the given subject, group, and roles.
* Creates a signed access JWT with the given subject, application, and roles.
*/
String createAccessToken(String subject, String group, List<String> roles);
String createAccessToken(String subject, String application, List<String> roles);
/**
* Creates a signed refresh JWT with the given subject, group, and roles.
* Creates a signed refresh JWT with the given subject, application, and roles.
*/
String createRefreshToken(String subject, String group, List<String> roles);
String createRefreshToken(String subject, String application, List<String> roles);
/**
* Validates an access token and returns the full validation result.
@@ -46,12 +46,12 @@ public interface JwtService {
// --- Backward-compatible defaults (delegate to role-aware methods) ---
default String createAccessToken(String subject, String group) {
return createAccessToken(subject, group, List.of());
default String createAccessToken(String subject, String application) {
return createAccessToken(subject, application, List.of());
}
default String createRefreshToken(String subject, String group) {
return createRefreshToken(subject, group, List.of());
default String createRefreshToken(String subject, String application) {
return createRefreshToken(subject, application, List.of());
}
default String validateAndExtractAgentId(String token) {

View File

@@ -32,7 +32,7 @@ class AgentRegistryServiceTest {
assertThat(agent).isNotNull();
assertThat(agent.id()).isEqualTo("agent-1");
assertThat(agent.name()).isEqualTo("Order Agent");
assertThat(agent.group()).isEqualTo("order-svc");
assertThat(agent.application()).isEqualTo("order-svc");
assertThat(agent.version()).isEqualTo("1.0.0");
assertThat(agent.routeIds()).containsExactly("route1", "route2");
assertThat(agent.capabilities()).containsEntry("feature", "tracing");
@@ -52,7 +52,7 @@ class AgentRegistryServiceTest {
assertThat(updated.id()).isEqualTo("agent-1");
assertThat(updated.name()).isEqualTo("New Name");
assertThat(updated.group()).isEqualTo("new-group");
assertThat(updated.application()).isEqualTo("new-group");
assertThat(updated.version()).isEqualTo("2.0.0");
assertThat(updated.routeIds()).containsExactly("route1", "route2");
assertThat(updated.capabilities()).containsEntry("new", "cap");