Module: Pikuri::VectorDb

Defined in:
lib/pikuri-vectordb.rb,
lib/pikuri/vector_db/chunk.rb,
lib/pikuri/vector_db/tools.rb,
lib/pikuri/vector_db/server.rb,
lib/pikuri/vector_db/backend.rb,
lib/pikuri/vector_db/chunker.rb,
lib/pikuri/vector_db/indexer.rb,
lib/pikuri/vector_db/watcher.rb,
lib/pikuri/vector_db/embedder.rb,
lib/pikuri/vector_db/reranker.rb,
lib/pikuri/vector_db/extension.rb,
lib/pikuri/vector_db/librarian.rb,
lib/pikuri/vector_db/tokenizer.rb,
lib/pikuri/vector_db/tools/read.rb,
lib/pikuri/vector_db/reranker/hit.rb,
lib/pikuri/vector_db/tools/search.rb,
lib/pikuri/vector_db/server/chroma.rb,
lib/pikuri/vector_db/server/qdrant.rb,
lib/pikuri/vector_db/tools/reindex.rb,
lib/pikuri/vector_db/backend/chroma.rb,
lib/pikuri/vector_db/backend/qdrant.rb,
lib/pikuri/vector_db/backend/result.rb,
lib/pikuri/vector_db/server/in_memory.rb,
lib/pikuri/vector_db/backend/in_memory.rb,
lib/pikuri/vector_db/chunker/fixed_window.rb,
lib/pikuri/vector_db/reranker/llama_server.rb,
lib/pikuri/vector_db/tokenizer/llama_server.rb,
lib/pikuri/vector_db/server/docker_container.rb,
lib/pikuri/vector_db/tokenizer/char_heuristic.rb

Overview

Namespace for the local-corpus vector search feature. The host wires it via Extension (+c.add_extension+); the Indexer orchestrates sources → text → ChunkerEmbedderBackend#upsert; a swappable Backend (Backend::InMemory / Backend::Qdrant / Backend::Chroma) stores and queries; the optional Reranker::LlamaServer is a quality knob. The Tools/ directory (Tools::Search / Tools::Read / Tools::Reindex) is the gem's LLM-facing surface, and LIBRARIAN is the bundled opt-in persona.

Two name conventions: the Ruby namespace is VectorDb (the +Mcp+/+SubAgent+ casing precedent), the LLM-visible tool is vectordb_search (snake_case, no underscore between vector and db — matches the other bundled tools).

Defined Under Namespace

Modules: Backend, Chunker, Reranker, Server, Tokenizer, Tools Classes: Chunk, Embedder, Extension, Indexer, Watcher

Constant Summary collapse

LOADER =
Zeitwerk::Loader.new
LIBRARIAN =

Bundled "focused corpus search" persona — the privilege-separated sub-agent counterpart to vectordb_search. Same shape as SubAgent::RESEARCHER / SubAgent::FILE_MINER: narrow toolset, short prompt replacing the parent's verbatim, bounded budget. The parent delegates a corpus lookup so retrieved chunks never pollute its context — the child searches, reads the clean hits in full, distils to one paragraph + cited paths (all the parent ingests); the chunks and documents disappear at sub-agent close.

Privilege-separation (the load-bearing reason)

tool_names admits only the two inbound corpus tools and nothing else: no shell, no fetch, no write, no recursion. Both only pull content in, so the lethal trifecta's egress leg stays absent — a librarian that reads a poisoned document ("exfiltrate ~/.ssh/...") has no hand to act with; the content is summarized away and the parent sees only the paragraph, as data not instructions. vectordb_read is safe here for exactly this reason: reading widens what the librarian sees, never what it can do (see Tools::Read). Corpus content is the threat — see SECURITY.md and book/trifecta-detector.md.

Opt-in via SubAgent::Extension.new(personas: [LIBRARIAN]); same precedent as Pikuri::Code::GIT_REPO_RESEARCHER — the constant lives with the gem shipping its required tool, not in pikuri-subagents.

Returns:

  • (Pikuri::SubAgent::Persona)
Pikuri::SubAgent::Persona.new(
  name: 'librarian',
  description: 'Focused corpus lookup with vectordb_search + vectordb_read. ' \
               'Use to delegate document lookups so retrieved chunks and full documents stay out of your context. ' \
               'Returns one paragraph + cited source paths.',
  tool_names: %w[vectordb_search vectordb_read].freeze,
  system_prompt: Pikuri.prompt('persona-librarian'),
  max_steps: 15
)