Record Class MemoryNamespace

java.lang.Object
java.lang.Record
com.tnsai.memory.MemoryNamespace
Record Components:
workspace - the workspace-level scope (e.g. project name, team ID)
session - the session-level scope (e.g. conversation ID, turn ID)

public record MemoryNamespace(String workspace, String session) extends Record
Defines a hierarchical memory namespace as workspace:session.

Namespace hierarchy supports scoped retrieval patterns:

  • GLOBAL — cross-workspace persistent memory
  • Workspace — project/team-level scope
  • Session — single conversation/interaction scope

Namespaces compose into a colon-delimited key (workspace:session) used by NamespacedMemoryStore for scoped storage and retrieval.

Since:
0.1.0
  • Field Details

    • GLOBAL

      public static final MemoryNamespace GLOBAL
      Global namespace shared across all workspaces and sessions.
  • Constructor Details

    • MemoryNamespace

      public MemoryNamespace(String workspace, String session)
      Canonical constructor with null/blank validation.
  • Method Details

    • toKey

      public String toKey()
      Returns the colon-delimited key for this namespace.
      Returns:
      workspace:session
    • of

      public static MemoryNamespace of(String workspace, String session)
      Creates a namespace with the given workspace and session.
      Parameters:
      workspace - the workspace scope
      session - the session scope
      Returns:
      a new MemoryNamespace
    • session

      public static MemoryNamespace session(String sessionId)
      Creates a namespace in the default workspace with the given session ID.
      Parameters:
      sessionId - the session scope
      Returns:
      a new MemoryNamespace with workspace "default"
    • fromKey

      public static MemoryNamespace fromKey(String key)
      Parses a colon-delimited key back into a MemoryNamespace.
      Parameters:
      key - the key in workspace:session format
      Returns:
      the parsed MemoryNamespace
      Throws:
      IllegalArgumentException - if the key format is invalid
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • workspace

      public String workspace()
      Returns the value of the workspace record component.
      Returns:
      the value of the workspace record component
    • session

      public String session()
      Returns the value of the session record component.
      Returns:
      the value of the session record component