Class DefaultRetrievalSpi

java.lang.Object
com.tnsai.intelligence.rag.binding.DefaultRetrievalSpi
All Implemented Interfaces:
com.tnsai.rag.RetrievalSpi

public final class DefaultRetrievalSpi extends Object implements com.tnsai.rag.RetrievalSpi
Action enforcement boundary backed by the unified retrieval engine.

The SPI owns action-specific configuration resolution, query selection, prompt-context assembly, and reserved context keys. Source loading, strategy composition, ranking, caching, failure policy, reranking, and deduplication are delegated to the same engine implementation used by chat retrieval.

Since:
0.5.4
  • Constructor Details

    • DefaultRetrievalSpi

      public DefaultRetrievalSpi()
      Creates the ServiceLoader-discovered production implementation.
  • Method Details

    • validateConfiguration

      public void validateConfiguration(Class<?> targetClass)
      Specified by:
      validateConfiguration in interface com.tnsai.rag.RetrievalSpi
    • validateConfiguration

      public void validateConfiguration(Class<?> targetClass, List<com.tnsai.rag.KnowledgeEntry> outer, com.tnsai.llm.LLMClient llm)
      Specified by:
      validateConfiguration in interface com.tnsai.rag.RetrievalSpi
    • validateConfiguration

      public void validateConfiguration(Class<?> targetClass, List<com.tnsai.rag.KnowledgeEntry> outer, com.tnsai.llm.LLMClient llm, boolean pathsPerRun)
      Specified by:
      validateConfiguration in interface com.tnsai.rag.RetrievalSpi
    • validateConfiguration

      public void validateConfiguration(Class<?> targetClass, List<com.tnsai.rag.KnowledgeEntry> outer, com.tnsai.llm.LLMClient llm, Map<String,List<String>> actionKnowledge)
      Specified by:
      validateConfiguration in interface com.tnsai.rag.RetrievalSpi
    • prepareChatKnowledge

      public com.tnsai.rag.ChatKnowledgeContext prepareChatKnowledge(Object agent, List<com.tnsai.rag.KnowledgeEntry> entries, com.tnsai.llm.LLMClient llm)

      DIRECT sources load and are measured here, at agent init, so an oversized source fails before the first turn; each turn reuses the loaded sources and checks the budget again for its filters. No DIRECT source loads lazily today; a lazy loader type, if ever added, would be skipped here and checked per turn only.

      A turn whose context carries ChatRetrievalContext.sourcePaths() reads each DIRECT source it names from that location, as an action's dispatch does: every name must be declared on the agent, chat scope or not, or the turn fails. A source it does not name reads its declared path, resolved against the base directory when one is set. The measurement at init reads the declared paths.

      Specified by:
      prepareChatKnowledge in interface com.tnsai.rag.RetrievalSpi
    • enforce

      public void enforce(com.tnsai.metadata.ActionMetadata action, com.tnsai.roles.Role role, Map<String,Object> params, Map<String,Object> context)
      Specified by:
      enforce in interface com.tnsai.rag.RetrievalSpi
    • enforce

      public void enforce(com.tnsai.metadata.ActionMetadata action, Object target, Map<String,Object> params, Map<String,Object> context)
      Specified by:
      enforce in interface com.tnsai.rag.RetrievalSpi
    • requireLoaded

      public Map<String,Integer> requireLoaded(Object target, Collection<String> names, Map<String,Object> context)
      Specified by:
      requireLoaded in interface com.tnsai.rag.RetrievalSpi
    • requireReady

      public Map<String,Integer> requireReady(Object target, Map<String,Object> context)
      KnowledgePreflight.requireReady(java.lang.Object, java.util.List<com.tnsai.rag.KnowledgeEntry>, java.util.Map<java.lang.String, java.nio.file.Path>, com.tnsai.rag.KnowledgeScope) over the reach a dispatch with this context has, the host's knowledge and the agent's, under the scope and with the locations read from the context exactly as enforce(com.tnsai.metadata.ActionMetadata, com.tnsai.roles.Role, java.util.Map<java.lang.String, java.lang.Object>, java.util.Map<java.lang.String, java.lang.Object>) reads them.
      Specified by:
      requireReady in interface com.tnsai.rag.RetrievalSpi