Anahata Core
An Enterprise ready, Domain-Driven abstraction of the Context Window. Engineered for stability, modularity, portability, observability, security and traceability.
Mission Statement
Core provides the atomic units of context (Messages, Parts, Tools) and the context augmentation and metabolic management systems (CwGC) required to sustain live, long-running, multi-modal, cross platform, super intelligent agentic sessions without provider lock-in.
The AGI Container
The Agi class is the central orchestrator. It manages the session lifecycle, state persistence, and model communication.
- Transactional States: Automatically triggers
autoSave()on turn completion or terminal tool states (EXECUTED/FAILED) to ensure persistence. - Non-Blocking Inputs: Implements a
stagedUserMessagequeue, allowing users to submit input while the ASI is currently processing a turn. - Metabolic Policy: The
AgiConfigdefines default Turns to Keep (Max Depth) for different data types: Text (108), Thoughts (12), Tools (12), and Blobs (4).
Messages & Parts
Anahata treats context as a rich graph. A conversation is a sequence of AbstractMessage turns, each containing a collection of AbstractPart objects tracking their own metadata and metabolic state.
In-Band Metadata Injection
Self-awareness is achieved by interleaving invisible metadata headers before every component. Even when a part is effectively pruned to save tokens, the Pruned Hint ensures the ASI maintains a "Semantic Ghost" of the action.
Metabolic Part Lifecycle
[x-anahata-part-id: 19 | Type: JavaMethodToolCall | Status: EXECUTED | Remaining Depth: 0 | Hint: Tool: NbFiles.updateTextFile | Result: Success]
Garbage Collection (CwGC)
Context Providers
Context Providers are the sensors of the ASI. They contribute high-salience information to the RAG Message via a hierarchical tree structure.
Reactive Events
The JASI platform follows a Data-First Reactive UI pattern. Core components implement the PropertyChangeSource interface, allowing the Swing UI to remain perfectly synchronized with the domain state.
public class ResourceManager extends BasicPropertyChangeSource {
public void register(Resource resource) {
resources.put(resource.getId(), resource);
// Fires event to trigger UI tree refresh
propertyChangeSupport.firePropertyChange("resources", null, getResourcesList());
}
}
agi.addPropertyChangeListener("status", evt -> {
statusIndicator.update((AgiStatus) evt.getNewValue());
});
Universal Resource Pipeline (V2)
The V2 architecture introduces a URI-centric, capability-based resource model that decouples the source of data from its interpretation. Resources are "Self-Aware" and automatically bind the appropriate view based on detected MIME types.
The Source Nexus: Universal Connectivity
Resource Component Hierarchy
Toolkits & Tools
Session
Metadata & depth governor.
Files
Atomic cross-platform I/O.
Java
Singularity hot-reload engine.
Shell
Direct host interaction.
Advanced State Management
Toolkits manage three scopes of memory: Session (AGI turn), Container (all sessions), and Application (JVM-wide). Deserialization is handled via rebind().
@AiToolkit(value = "Task Orchestration", maxDepth = 12)
public class TaskToolkit extends AnahataToolkit {
private List<String> persistentTasks = new ArrayList<>(); // Serialized by Kryo
private transient Map<String, Long> runtimeMetrics; // Cleared on save
@Override
public void rebind() {
this.runtimeMetrics = new ConcurrentHashMap<>(); // Restored upon deserialization
}
@AiTool("Shares a task across the ASI Container.")
public String createGlobalTask(String task) {
getSessionMap().put("last", task); // Local turn memory
getContainerMap().put("latest", task); // Shared across all app AGIs
getApplicationMap().put("sys", "UP"); // Shared across entire JVM
return "Broadcasting task...";
}
}
Java: On-the-Fly Tool Creation
The Java toolkit enables the Singularity Loop: scouting a new capability and integrating it into the starting XI in just two turns.
The Singularity Loop: 2-Turn Self-Evolution
Java ↔ JSON Schema (J2S)
@Schema(description = "Recursive dependency analysis.")
public class IssueNode {
private String id;
private List<IssueNode> children;
}
{
"title": "uno.anahata.asi.model.IssueNode",
"properties": {
"children": {
"type": "array",
"items": { "description": "Recursive reference to IssueNode" }
}
}
}
Flight Recorder & Persistence
The Agi Container is designed from the ground up for ultra-fast passivation / serialization of the entire container. This includes the state of: container settings and state, history, context providers, resources, and toolkits.
public class NbHandle extends AbstractResourceHandle implements Rebindable {
private transient FileObject fileObject; // Lost during serialization
private String path;
@Override
public void rebind() {
// Restore the live FileObject pointer from the persisted path string
this.fileObject = FileUtil.toFileObject(new File(path));
if (this.fileObject != null) {
setupListeners(); // Re-attach IDE hooks
}
}
}
Recording Modes
- Auto Save (Default): The Agi container is serialized on every turn and every tool execution to the same backup file. This allows for transactional-grade crash recovery.
- Flight Recorder (Storage Intensive): The Agi container is serialized to a different backup file on every turn and every tool execution. This allows for fully auditable/replayable sessions.