feat(agentic): Phase 1 — API Foundation#290
Conversation
Add four new types to main/api: - @AgenticAggregateInfo annotation (stateClass, description, maxMemories) - AgenticAggregateMemory record (6-field immutable memory entry) - MemoryAwareState interface (getMemories() contract) - AgenticAggregate<S> interface (extends Aggregate, default getMemories) No new dependencies. All existing main/api tests pass. Agent-Logs-Url: https://github.com/elasticsoftwarefoundation/akces-framework/sessions/baa69a64-4f5a-4df9-a3c5-98de3a0824a5 Co-authored-by: jwijgerd <914840+jwijgerd@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds initial “agentic aggregate” API primitives to main/api to support later agentic aggregate phases without introducing new dependencies.
Changes:
- Introduces
@AgenticAggregateInfoannotation mirroring existing@AggregateInfoSpring composition patterns, with agentic-specific attributes (stateClass,description,maxMemories). - Adds agentic memory model types:
AgenticAggregateMemoryandMemoryAwareState. - Adds
AgenticAggregate<S>interface extendingAggregate<S>with a conveniencegetMemories(S)default method.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
main/api/src/main/java/org/elasticsoftware/akces/annotations/AgenticAggregateInfo.java |
New Spring-composable annotation for registering agentic aggregates with memory configuration metadata. |
main/api/src/main/java/org/elasticsoftware/akces/aggregate/MemoryAwareState.java |
New opt-in state interface exposing a list of agentic memories. |
main/api/src/main/java/org/elasticsoftware/akces/aggregate/AgenticAggregateMemory.java |
New immutable record representing a single “memory” entry (fact + metadata). |
main/api/src/main/java/org/elasticsoftware/akces/aggregate/AgenticAggregate.java |
New aggregate interface with default getMemories delegation to MemoryAwareState. |
| */ | ||
| default List<AgenticAggregateMemory> getMemories(S state) { | ||
| if (state instanceof MemoryAwareState memoryState) { | ||
| return memoryState.getMemories(); |
There was a problem hiding this comment.
getMemories can return null if a MemoryAwareState implementation returns null from getMemories(), which contradicts the method’s contract of returning a list (or empty list). Consider defensively normalizing to an empty list (and/or returning an unmodifiable copy) to guarantee a non-null result.
| return memoryState.getMemories(); | |
| List<AgenticAggregateMemory> memories = memoryState.getMemories(); | |
| return memories == null ? List.of() : List.copyOf(memories); |
|
|
||
| public interface MemoryAwareState { |
There was a problem hiding this comment.
MemoryAwareState#getMemories() doesn’t specify whether it may return null. Since AgenticAggregate#getMemories is documented to return a list (or empty list), it would be safer to define a non-null contract here as well (e.g., annotate the return with @Nonnull and document that implementations must return an empty list instead of null).
| public interface MemoryAwareState { | |
| import jakarta.annotation.Nonnull; | |
| public interface MemoryAwareState { | |
| /** | |
| * Returns the memories associated with this state. | |
| * <p> | |
| * Implementations must never return {@code null}. If no memories are available, | |
| * an empty list must be returned instead. | |
| * | |
| * @return a non-null list of memories, or an empty list if none exist | |
| */ | |
| @Nonnull |
Introduces the
main/apiprimitives required by all subsequent agentic aggregate phases. Pure Java — no new dependencies.New Types
@AgenticAggregateInfo—@Component-composable annotation for singleton agentic aggregates. ExposesstateClass,description, andmaxMemories(sliding-window eviction limit, default 100). Deliberately omitsgenerateGDPRKeyOnCreate,indexed/indexName, and partition count (always 1).AgenticAggregateMemory— immutable record capturing a single memory entry:MemoryAwareState— opt-in interface for aggregate state classes that expose memories:AgenticAggregate<S>— extendsAggregate<S>, adds a defaultgetMemories(S state)that uses pattern matching to delegate toMemoryAwareStateor fall back toList.of():