Record Class RetrievalRequest
- Record Components:
query- normalized retrieval queryconfig- canonical retrieval configurationscope- tenant/session isolation scopecancellationToken- cooperative cancellation signaldeadline- absolute deadline, if one is configuredmetadataFilters- immutable metadata filters; keys and values are non-blank, and an absent filter is an absent entry rather than an empty value
RetrievalEngine.
The engine owns its complete source set. The request selects and
configures those sources through the canonical RetrievalConfig,
while carrying per-invocation identity, cancellation, deadline, and
metadata filters.
The engine reads config for retrieval behaviour only. It does
not apply Search.contextWindow(), which
bounds assembled prompt text rather than evidence — rendering is the
caller's responsibility, so the window is enforced wherever evidence
becomes a prompt.
Cache keys
A retrieval cache key must cover the full scope() and the full
metadataFilters() in addition to the query and configuration.
Two properties of this record constrain how:
- Filter keys and values are arbitrary non-blank text and may contain
any separator a naive encoding would use, so
{"a": "b|c"}and{"a|b": "c"}both flatten toa|b|c. A key must therefore length-prefix each part rather than join on a delimiter. metadataFiltersis an unordered immutable map whose iteration order is unspecified and varies between JVM runs, so entries must be sorted before they are digested. Digesting in iteration order yields a different key for identical filters on the next run, silently defeating the cache.
- Since:
- 0.13.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder with safe defaults for unscoped, non-cancellable retrieval. -
Constructor Summary
ConstructorsConstructorDescriptionRetrievalRequest(String query, RetrievalConfig config, RetrievalScope scope, CancellationToken cancellationToken, Optional<Instant> deadline, Map<String, String> metadataFilters) Validates and defensively copies request state. -
Method Summary
Modifier and TypeMethodDescriptionstatic RetrievalRequest.Builderbuilder(String query, RetrievalConfig config) Creates a request builder.Returns the value of thecancellationTokenrecord component.config()Returns the value of theconfigrecord component.deadline()Returns the value of thedeadlinerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of themetadataFiltersrecord component.query()Returns the value of thequeryrecord component.scope()Returns the value of thescoperecord component.voidEvaluates cancellation and deadline against the UTC system clock.voidthrowIfAborted(Clock clock) Throws when cooperative cancellation or the absolute deadline says this request must stop.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RetrievalRequest
public RetrievalRequest(String query, RetrievalConfig config, RetrievalScope scope, CancellationToken cancellationToken, Optional<Instant> deadline, Map<String, String> metadataFilters) Validates and defensively copies request state.
-
-
Method Details
-
builder
Creates a request builder.- Parameters:
query- retrieval queryconfig- canonical retrieval configuration- Returns:
- new builder
-
throwIfAborted
Throws when cooperative cancellation or the absolute deadline says this request must stop.Engines call this at their deadline-enforcement boundary. Backends that own that boundary also call it before, between, and after blocking phases with the same clock, and configure backend-native I/O timeouts; an absolute deadline cannot interrupt an arbitrary blocking call by itself.
- Parameters:
clock- time source used to evaluate the deadline
-
throwIfAborted
public void throwIfAborted()Evaluates cancellation and deadline against the UTC system clock. -
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. -
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. -
equals
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 withObjects::equals(Object,Object). -
query
Returns the value of thequeryrecord component.- Returns:
- the value of the
queryrecord component
-
config
Returns the value of theconfigrecord component.- Returns:
- the value of the
configrecord component
-
scope
Returns the value of thescoperecord component.- Returns:
- the value of the
scoperecord component
-
cancellationToken
Returns the value of thecancellationTokenrecord component.- Returns:
- the value of the
cancellationTokenrecord component
-
deadline
Returns the value of thedeadlinerecord component.- Returns:
- the value of the
deadlinerecord component
-
metadataFilters
Returns the value of themetadataFiltersrecord component.- Returns:
- the value of the
metadataFiltersrecord component
-