Package com.tnsai.rag

Record Class RetrievalScope

java.lang.Object
java.lang.Record
com.tnsai.rag.RetrievalScope
Record Components:
tenantId - tenant identity, if configured
sessionId - conversation or execution-session identity, if configured

public record RetrievalScope(Optional<String> tenantId, Optional<String> sessionId) extends Record
Tenant and session identity carried by a retrieval request.

The complete value is a request isolation boundary. Retrieval engines must use this record, rather than only one of its fields, in request caches and mutable request-scoped stores. The engine's indexed source corpus has a separate engine-owned lifecycle boundary; this value does not partition or transfer ownership of that corpus. An unscoped request is supported for agents that do not configure tenant or session identity.

Each part has exactly one representation of absence. A part is either Optional.empty() or non-blank stripped text: a present-but-blank identity is rejected at construction rather than normalized to Optional.empty(). A cache key therefore cannot confuse "no tenant" with "the empty tenant", because the latter is unrepresentable — the two cases a digest must distinguish are absence and non-blank text, and nothing else can occur.

Since:
0.13.0
  • Constructor Details

    • RetrievalScope

      public RetrievalScope(Optional<String> tenantId, Optional<String> sessionId)
      Validates and normalizes the identity fields.
  • Method Details

    • of

      public static RetrievalScope of(String tenantId, String sessionId)
      Creates a scope from nullable identity values.
      Parameters:
      tenantId - tenant identity, or null when absent
      sessionId - session identity, or null when absent
      Returns:
      normalized retrieval scope
    • unscoped

      public static RetrievalScope unscoped()
      Returns the canonical scope for requests without identity.
      Returns:
      unscoped identity
    • 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.
    • tenantId

      public Optional<String> tenantId()
      Returns the value of the tenantId record component.
      Returns:
      the value of the tenantId record component
    • sessionId

      public Optional<String> sessionId()
      Returns the value of the sessionId record component.
      Returns:
      the value of the sessionId record component