Federated org knowledge index: corpus-agnostic hybrid retrieval (FTS ∪ pgvector RRF k=60) over provenance-stamped docs/chunks, fail-closed transactional indexing, rename aliases. Embedder trait at the crate boundary — no infrastructure-embeddings dependency.
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/knowledge-index |
| Edition | 2021 |
| Targets | infrastructure_knowledge_index |
| Public items | 52 across 7 modules |
| Tests | 29 |
What it is for
infrastructure-knowledge-index — federated org knowledge index (Sprint 3.4).
Corpus-agnostic hybrid retrieval (FTS ∪ pgvector fused by RRF k=60) over provenance-stamped documents and chunks: (corpus, source_kind, source_ref, repo, commit_sha) from day one, rename-stable doc identity (uuid + alias table), fail-closed transactional indexing (embed batch FIRST, then advisory-lock + staleness re-check + delete/reinsert in one tx), tombstones for removals, refuse-mixed-model fusion.
The embedder contract (KnowledgeEmbedder) is defined at THIS crate's boundary — this crate does NOT depend on infrastructure-embeddings; the tools-org-knowledge CLI wires the real embedder in via an adapter (Gate 1.5 Q4). Chunking also lives with the caller: IndexService receives pre-chunked content with file-absolute offsets.
Capabilities
crate root
infrastructure-knowledge-index — federated org knowledge index (Sprint 3.4).
| Item |
|---|
pub const VECTOR_DIM: usize |
pub const MIGRATIONS: & (& str, & str) |
async fn ensure_schema(pool : & sqlx::PgPool) -> Result <(), KnowledgeError> |
EmbedError
The embedder trait at THIS crate's boundary (Gate 1.5 Q4: no layer exception,
| Item |
|---|
pub enum EmbedError |
KnowledgeEmbedder
The embedder trait at THIS crate's boundary (Gate 1.5 Q4: no layer exception,
| Item |
|---|
pub trait KnowledgeEmbedder |
KnowledgeError
Error type for the knowledge index (indexing + retrieval).
| Item |
|---|
pub enum KnowledgeError |
models (other)
Data shapes crossing the crate boundary: what callers hand the index
| Item |
|---|
fn content_hash_hex(bytes : & u8) -> String |
ChunkHit
Data shapes crossing the crate boundary: what callers hand the index
| Item |
|---|
pub struct ChunkHit |
ChunkInput
Data shapes crossing the crate boundary: what callers hand the index
| Item |
|---|
pub struct ChunkInput |
DocSource
Data shapes crossing the crate boundary: what callers hand the index
| Item |
|---|
pub struct DocSource |
IndexOutcome
Data shapes crossing the crate boundary: what callers hand the index
| Item |
|---|
pub enum IndexOutcome |
ScoredHit
Data shapes crossing the crate boundary: what callers hand the index
| Item |
|---|
pub struct ScoredHit |
SearchRequest
Data shapes crossing the crate boundary: what callers hand the index
| Item |
|---|
pub struct SearchRequest |
rename (other)
Rename detection planning (pure logic; the ingest walker feeds it).
| Item |
|---|
fn plan_renames(disappeared : & DocKey, appeared : & DocKey) -> RenameOutcome |
DocKey
Rename detection planning (pure logic; the ingest walker feeds it).
| Item |
|---|
pub struct DocKey |
RenameOutcome
Rename detection planning (pure logic; the ingest walker feeds it).
| Item |
|---|
pub struct RenameOutcome |
RenamePlan
Rename detection planning (pure logic; the ingest walker feeds it).
| Item |
|---|
pub struct RenamePlan |
verb:advisory
sqlx persistence for the knowledge index.
| Item |
|---|
fn advisory_lock_keys(tenant_id : Uuid, corpus : & str, source_ref : & str) ->(i32, i32) |
async fn advisory_xact_lock <'e, E : PgExecutor <'e>>(ex : E, key1 : i32, key2 : i32,) -> Result <(), sqlx::Error> |
verb:chunk
sqlx persistence for the knowledge index.
| Item |
|---|
async fn chunk_hashes_for_doc <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid,) -> Result <Vec <(i32, String)>, sqlx::Error> |
verb:corpus
sqlx persistence for the knowledge index.
| Item |
|---|
async fn corpus_model_ids <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str,) -> Result <Vec <String>, sqlx::Error> |
verb:delete
sqlx persistence for the knowledge index.
| Item |
|---|
async fn delete_chunks_for_doc <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid,) -> Result <u64, sqlx::Error> |
async fn delete_chunks_by_index <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, indexes : & i32,) -> Result <u64, sqlx::Error> |
verb:insert
sqlx persistence for the knowledge index.
| Item |
|---|
async fn insert_chunk <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, tenant_id : Uuid, corpus : & str, chunk : & ChunkInput, content_hash : & str, model_id : & str, embedding : & str,) -> Result <Uuid, sqlx::Error> |
async fn insert_alias <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, old_ref : & str, valid_from_commit : Option <& str>, valid_to_commit : Option <& str>,) -> Result <(), sqlx::Error> |
verb:mark
sqlx persistence for the knowledge index.
| Item |
|---|
async fn mark_removed <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <Option <Uuid>, sqlx::Error> |
verb:model
sqlx persistence for the knowledge index.
| Item |
|---|
async fn model_ids_for_corpora <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpora : & String,) -> Result <Vec <String>, sqlx::Error> |
verb:ordered
sqlx persistence for the knowledge index.
| Item |
|---|
fn ordered_lock_pairs(a :(i32, i32), b :(i32, i32)) -> Vec <(i32, i32)> |
verb:resolve
sqlx persistence for the knowledge index.
| Item |
|---|
async fn resolve_ref <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <Option <Uuid>, sqlx::Error> |
verb:to
sqlx persistence for the knowledge index.
| Item |
|---|
fn to_pgvector(v : & f32) -> String |
verb:update
sqlx persistence for the knowledge index.
| Item |
|---|
async fn update_source_ref <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, new_ref : & str,) -> Result <(), sqlx::Error> |
verb:upsert
sqlx persistence for the knowledge index.
| Item |
|---|
async fn upsert_doc <'e, E : PgExecutor <'e>>(ex : E, doc : & DocSource,) -> Result <Uuid, sqlx::Error> |
async fn upsert_chunk <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, tenant_id : Uuid, corpus : & str, chunk : & ChunkInput, content_hash : & str, model_id : & str, embedding : & str,) -> Result <Uuid, sqlx::Error> |
CandidateFilter
sqlx persistence for the knowledge index.
| Item |
|---|
pub struct CandidateFilter |
async fn fts_candidates <'e, E : PgExecutor <'e>>(ex : E, filter : & CandidateFilter, query : & str, limit : i64,) -> Result <Vec <ChunkHit>, sqlx::Error> |
async fn vector_candidates <'e, E : PgExecutor <'e>>(ex : E, filter : & CandidateFilter, query_embedding : & str, limit : i64,) -> Result <Vec <ChunkHit>, sqlx::Error> |
DocState
sqlx persistence for the knowledge index.
| Item |
|---|
pub struct DocState |
async fn doc_state <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <Option <DocState>, sqlx::Error> |
search (other)
Hybrid retrieval: FTS ∪ vector fused by Reciprocal Rank Fusion (RRF, k=60 —
| Item |
|---|
fn fuse(lists : & Vec <ChunkHit>) -> Vec <ScoredHit> |
fn group_by_doc(hits : Vec <ScoredHit>, max_per_doc : usize) -> Vec <ScoredHit> |
KnowledgeSearch
Hybrid retrieval: FTS ∪ vector fused by Reciprocal Rank Fusion (RRF, k=60 —
| Item |
|---|
pub struct KnowledgeSearch |
KnowledgeSearch :: async fn search <E : KnowledgeEmbedder + ? Sized>(pool : & PgPool, embedder : & E, tenant_id : Uuid, req : & SearchRequest,) -> Result <Vec <ScoredHit>, KnowledgeError> |
service (other)
Indexing behavior: fail-closed (embed the whole batch FIRST — any embed
| Item |
|---|
fn check_model_ids(existing : & String, active : & str) -> Result <(), KnowledgeError> |
fn content_is_stale(embedded_hash : & str, current_hash : Option <& str>) -> bool |
ContentRecheck
Indexing behavior: fail-closed (embed the whole batch FIRST — any embed
| Item |
|---|
pub type ContentRecheck<'a>: & 'a(dyn Fn() -> Option <String> + Sync) |
IncrementalPlan
Indexing behavior: fail-closed (embed the whole batch FIRST — any embed
| Item |
|---|
pub struct IncrementalPlan |
fn plan_incremental(existing : & (i32, String), chunks : & ChunkInput) -> IncrementalPlan |
IndexService
Indexing behavior: fail-closed (embed the whole batch FIRST — any embed
| Item |
|---|
pub struct IndexService |
IndexService :: async fn index_doc <'c, A, E>(pool : A, embedder : & E, doc : & DocSource, chunks : & ChunkInput, force : bool, recheck : Option <ContentRecheck <'_>>,) -> Result <IndexOutcome, KnowledgeError> where A : sqlx::Acquire <'c, Database = sqlx::Postgres> + Send, E : KnowledgeEmbedder + ? Sized, |
IndexService :: async fn index_doc_incremental <E : KnowledgeEmbedder + ? Sized>(pool : & PgPool, embedder : & E, doc : & DocSource, chunks : & ChunkInput, force : bool, recheck : Option <ContentRecheck <'_>>,) -> Result <IndexOutcome, KnowledgeError> |
IndexService :: async fn remove_doc(pool : & PgPool, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <bool, KnowledgeError> |
IndexService :: async fn rename_doc(pool : & PgPool, tenant_id : Uuid, corpus : & str, old_ref : & str, new_ref : & str, valid_to_commit : Option <& str>,) -> Result <Uuid, KnowledgeError> |
How to use it
No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.
Module structure
infrastructure_knowledge_index
embeddererrormodelsrenamereposearchservice
flowchart TD n_infrastructure_knowledge_index["infrastructure_knowledge_index"] n_infrastructure_knowledge_index --> n_embedder["embedder"] n_infrastructure_knowledge_index --> n_error["error"] n_infrastructure_knowledge_index --> n_models["models"] n_infrastructure_knowledge_index --> n_rename["rename"] n_infrastructure_knowledge_index --> n_repo["repo"] n_infrastructure_knowledge_index --> n_search["search"] n_infrastructure_knowledge_index --> n_service["service"]
Public surface
`crate root`
| Item | What it is |
|---|---|
pub const VECTOR_DIM: usize | The vector(1024) column width (BGE-m3) |
pub const MIGRATIONS: & (& str, & str) | The crate's schema files in apply order: (file name, SQL) |
async fn ensure_schema(pool : & sqlx::PgPool) -> Result <(), KnowledgeError> | Apply the crate's schema (idempotent migrations, MIGRATIONS in order) to pool |
`embedder`
| Item | What it is |
|---|---|
pub enum EmbedError | Failure modes for vectorization |
pub trait KnowledgeEmbedder | Minimal batch embedder contract: batch embed, model identity, dimensions, structured errors |
`error`
| Item | What it is |
|---|---|
pub enum KnowledgeError | Failures from indexing or searching the knowledge index. |
`models`
| Item | What it is |
|---|---|
pub struct DocSource | Metadata + identity for one document being (re-)indexed |
pub struct ChunkInput | One pre-chunked passage with file-absolute provenance offsets. |
pub enum IndexOutcome | What an index pass did for one doc. |
pub struct ChunkHit | A retrieval hit (one chunk) with full citation provenance — the unit both retrieval arms return and RRF fuses by rank position. |
pub struct ScoredHit | A fused retrieval hit: the chunk + its RRF score. |
pub struct SearchRequest | A search request |
fn content_hash_hex(bytes : & u8) -> String | sha256 of exact bytes, lowercase hex — the doc invalidation key. |
`rename`
| Item | What it is |
|---|---|
pub struct DocKey | A (source_ref, content_hash) pair from a walk diff. |
pub struct RenamePlan | One safe rename to apply: update source_ref, alias the old path. |
pub struct RenameOutcome | The planning result: safe renames plus the ambiguous old paths the operator must resolve via explicit mv (they will otherwise be tombstoned). |
fn plan_renames(disappeared : & DocKey, appeared : & DocKey) -> RenameOutcome | Plan renames from a walk diff: disappeared are indexed docs whose path no longer exists; appeared are new paths not yet indexed |
`repo`
| Item | What it is |
|---|---|
fn to_pgvector(v : & f32) -> String | Format an embedding as a pgvector text literal (0.1,0.2,...). |
fn advisory_lock_keys(tenant_id : Uuid, corpus : & str, source_ref : & str) ->(i32, i32) | Derive the two-key pg_advisory_xact_lock(int4, int4) keyspace for one doc: key1 from the tenant id, key2 from (corpus, source_ref) |
fn ordered_lock_pairs(a :(i32, i32), b :(i32, i32)) -> Vec <(i32, i32)> | Order (and dedupe) two advisory lock key pairs so every caller acquires them in the same sequence — deterministic acquisition order prevents deadlock when two transactions each need both keyspaces (e.g |
async fn advisory_xact_lock <'e, E : PgExecutor <'e>>(ex : E, key1 : i32, key2 : i32,) -> Result <(), sqlx::Error> | Take the per-doc advisory lock for the current transaction (released at commit/rollback — no manual unlock path to forget). |
pub struct DocState | Current index state of a doc, if present. |
async fn doc_state <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <Option <DocState>, sqlx::Error> | Load a doc's (id, content_hash, status) by its current source_ref. |
async fn corpus_model_ids <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str,) -> Result <Vec <String>, sqlx::Error> | Distinct model_ids already present in a corpus (mixed-model refusal input). |
async fn model_ids_for_corpora <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpora : & String,) -> Result <Vec <String>, sqlx::Error> | Distinct model_ids present across the searched corpora (empty list = all of the tenant's corpora) — input to the query-time mixed-model guard. |
async fn upsert_doc <'e, E : PgExecutor <'e>>(ex : E, doc : & DocSource,) -> Result <Uuid, sqlx::Error> | Insert-or-update the doc row keyed by (tenant, corpus, source_ref); the uuid identity is preserved across re-indexes |
async fn delete_chunks_for_doc <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid,) -> Result <u64, sqlx::Error> | Delete a doc's existing chunks (re-index replaces atomically) |
async fn insert_chunk <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, tenant_id : Uuid, corpus : & str, chunk : & ChunkInput, content_hash : & str, model_id : & str, embedding : & str,) -> Result <Uuid, sqlx::Error> | Insert one chunk row; embedding is a pgvector text literal (see to_pgvector). |
async fn upsert_chunk <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, tenant_id : Uuid, corpus : & str, chunk : & ChunkInput, content_hash : & str, model_id : & str, embedding : & str,) -> Result <Uuid, sqlx::Error> | Upsert one chunk row on (doc_id, chunk_index) — the incremental path's write library crate: changed turns overwrite in place, unchanged rows are never touched |
async fn chunk_hashes_for_doc <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid,) -> Result <Vec <(i32, String)>, sqlx::Error> | Stored (chunk_index, content_hash) pairs for a doc — the incremental diff's left-hand side. |
async fn delete_chunks_by_index <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, indexes : & i32,) -> Result <u64, sqlx::Error> | Delete specific chunk rows by index (stale entries the incremental diff found missing from the incoming set). |
async fn mark_removed <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <Option <Uuid>, sqlx::Error> | Tombstone a doc (status='removed', row kept so citations distinguish removed from never-indexed) |
async fn insert_alias <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, old_ref : & str, valid_from_commit : Option <& str>, valid_to_commit : Option <& str>,) -> Result <(), sqlx::Error> | Record an old source_ref for a doc (idempotent on re-run). |
async fn update_source_ref <'e, E : PgExecutor <'e>>(ex : E, doc_id : Uuid, new_ref : & str,) -> Result <(), sqlx::Error> | Point a doc at its new source_ref (the rename mutation). |
async fn resolve_ref <'e, E : PgExecutor <'e>>(ex : E, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <Option <Uuid>, sqlx::Error> | Resolve a source_ref to its doc id: current refs first, then the alias table — so citations written before a rename still land on the doc. |
pub struct CandidateFilter | Scope filters both retrieval arms share |
async fn fts_candidates <'e, E : PgExecutor <'e>>(ex : E, filter : & CandidateFilter, query : & str, limit : i64,) -> Result <Vec <ChunkHit>, sqlx::Error> | FTS candidates, best-ranked first (the exact-term retrieval arm). |
async fn vector_candidates <'e, E : PgExecutor <'e>>(ex : E, filter : & CandidateFilter, query_embedding : & str, limit : i64,) -> Result <Vec <ChunkHit>, sqlx::Error> | Vector-similarity candidates, nearest first (the semantic retrieval arm) |
`search`
| Item | What it is |
|---|---|
pub struct KnowledgeSearch | Hybrid retrieval over the knowledge index. |
KnowledgeSearch :: async fn search <E : KnowledgeEmbedder + ? Sized>(pool : & PgPool, embedder : & E, tenant_id : Uuid, req : & SearchRequest,) -> Result <Vec <ScoredHit>, KnowledgeError> | Search a tenant's indexed knowledge |
fn fuse(lists : & Vec <ChunkHit>) -> Vec <ScoredHit> | Reciprocal Rank Fusion over one or more ranked lists |
fn group_by_doc(hits : Vec <ScoredHit>, max_per_doc : usize) -> Vec <ScoredHit> | Keep at most max_per_doc chunks per doc, preserving fused order — overlapping chunks of one doc must not crowd out other docs. |
`service`
| Item | What it is |
|---|---|
pub type ContentRecheck<'a>: & 'a(dyn Fn() -> Option <String> + Sync) | Re-reads the source and returns its CURRENT content hash (None = source vanished) |
fn check_model_ids(existing : & String, active : & str) -> Result <(), KnowledgeError> | Refuse to mix embedding models within one corpus: any already-present model_id different from active aborts (mixed vectors corrupt ANN ranking) |
fn content_is_stale(embedded_hash : & str, current_hash : Option <& str>) -> bool | Staleness decision for the in-tx re-check: stale when the current hash is missing (source vanished) or differs from what was embedded. |
pub struct IncrementalPlan | The diff an incremental pass will apply: which positions in the incoming chunk slice need embedding, which stored chunk_index values are stale, and how many incoming chunks were kept untouched. |
fn plan_incremental(existing : & (i32, String), chunks : & ChunkInput) -> IncrementalPlan | Pure diff for the incremental path: compare stored (chunk_index, hash) pairs against incoming chunks (each MUST carry chunk_hash) |
pub struct IndexService | Indexing: embed → publish a doc's pre-chunked content. |
IndexService :: async fn index_doc <'c, A, E>(pool : A, embedder : & E, doc : & DocSource, chunks : & ChunkInput, force : bool, recheck : Option <ContentRecheck <'_>>,) -> Result <IndexOutcome, KnowledgeError> where A : sqlx::Acquire <'c, Database = sqlx::Postgres> + Send, E : KnowledgeEmbedder + ? Sized, | (Re-)index one document |
IndexService :: async fn index_doc_incremental <E : KnowledgeEmbedder + ? Sized>(pool : & PgPool, embedder : & E, doc : & DocSource, chunks : & ChunkInput, force : bool, recheck : Option <ContentRecheck <'_>>,) -> Result <IndexOutcome, KnowledgeError> | Incrementally (re-)index one APPEND-MOSTLY document whose chunks carry per-chunk hashes (sprint 3.15: transcript sessions — a session grown by N turns embeds exactly those N turns) |
IndexService :: async fn remove_doc(pool : & PgPool, tenant_id : Uuid, corpus : & str, source_ref : & str,) -> Result <bool, KnowledgeError> | Tombstone a removed source: the doc row is kept with status='removed' (citations distinguish removed from never-indexed); its chunks are deleted so it can no longer be retrieved |
IndexService :: async fn rename_doc(pool : & PgPool, tenant_id : Uuid, corpus : & str, old_ref : & str, new_ref : & str, valid_to_commit : Option <& str>,) -> Result <Uuid, KnowledgeError> | Apply a rename: point the doc at new_ref and alias old_ref so existing citations still resolve |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
KnowledgeError | error::KnowledgeError |
KnowledgeSearch | search::KnowledgeSearch |
to_pgvector | repo::to_pgvector |
{EmbedError,KnowledgeEmbedder} | embedder::{EmbedError,KnowledgeEmbedder} |
{check_model_ids,content_is_stale,IndexService} | service::{check_model_ids,content_is_stale,IndexService} |
{content_hash_hex,ChunkHit,ChunkInput,DocSource,IndexOutcome,ScoredHit,SearchRequest,} | models::{content_hash_hex,ChunkHit,ChunkInput,DocSource,IndexOutcome,ScoredHit,SearchRequest,} |
{plan_renames,DocKey,RenameOutcome,RenamePlan} | rename::{plan_renames,DocKey,RenameOutcome,RenamePlan} |
Boundary
Depends on no other workspace tier.
Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | infrastructure |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/infrastructure/knowledge-index |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
serde | ^1 | derive, derive | no | always |
serde_json | ^1 | — | no | always |
sha2 | ^0.10 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js, v4, serde | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full, macros, rt-multi-thread | no | always |
Build. None.
Depended on by. 5 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_wiki["application-wiki"] -->|uses| SELF n_infrastructure_doc_ingest["infrastructure-doc-ingest"] -->|uses| SELF n_infrastructure_web_ingest["infrastructure-web-ingest"] -->|uses| SELF n_tools_corpus["tools-corpus"] -->|uses| SELF n_tools_retrieval_eval["tools-retrieval-eval"] -->|uses| SELF SELF["infrastructure-knowledge-index"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.
Targets
| Kind | Name | Source |
|---|---|---|
| lib | infrastructure_knowledge_index | `src/lib.rs` |
Error model
| Error type | Named by |
|---|---|
EmbedError | declared, no public signature returns it |
KnowledgeError | check_model_ids, ensure_schema |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | yes |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
KNOWLEDGE_TEST_DB | src/lib.rs |
Related capabilities
5 workspace crates depend on this one: application-wiki, infrastructure-doc-ingest, infrastructure-web-ingest, tools-corpus, tools-retrieval-eval.
Verification
| Kind | Count |
|---|---|
| Unit tests | 29 |
| Integration tests | 0 |
| Examples | 0 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
crate root | 3 | 0 | 4 |
embedder | 2 | 0 | 6 |
error | 1 | 0 | 3 |
models | 7 | 0 | 17 |
rename | 4 | 0 | 4 |
repo | 21 | 0 | 0 |
search | 3 | 0 | 3 |
service | 6 | 0 | 3 |
What the tests establish, by name:
ensure_schema_provisions_a_fresh_database—src/lib.rsincremental_guards_refuse_bad_batches_and_shrink_deletes—src/lib.rsincremental_index_embeds_only_new_turns_and_meta_round_trips—src/lib.rsindex_search_reindex_isolation_and_filters—src/lib.rsmigration_0003_backfills_then_refuses_nameless_rows—src/lib.rsmigration_list_is_complete_and_ordered—src/lib.rssearch_refuses_mixed_model_corpus—src/lib.rscontent_hash_is_sha256_hex_of_exact_bytes—src/models.rsduplicate_content_is_ambiguous_not_guessed—src/rename.rsindependent_pairs_each_rename—src/rename.rsno_hash_match_is_plain_delete_and_create—src/rename.rsone_disappeared_two_appeared_same_hash_is_ambiguous—src/rename.rsone_to_one_hash_match_is_a_rename—src/rename.rsadvisory_keys_are_deterministic_and_tenant_scoped—src/repo.rsordered_lock_pairs_sorts_and_dedupes—src/repo.rsto_pgvector_formats_a_text_literal—src/repo.rsfuse_is_deterministic_across_runs—src/search.rsgrouping_caps_chunks_per_doc_preserving_order—src/search.rsgrouping_is_a_noop_under_the_cap—src/search.rsrrf_rewards_agreement_across_arms—src/search.rsempty_corpus_accepts_any_model—src/service.rsincremental_plan_changed_hash_reembeds_and_missing_index_deletes—src/service.rsincremental_plan_first_run_embeds_everything—src/service.rsincremental_plan_grown_doc_embeds_only_new_turns—src/service.rsincremental_plan_unchanged_run_embeds_nothing—src/service.rsindex_doc_composes_under_an_outer_transaction_savepoint—src/service.rsmixed_model_is_refused_with_both_ids_named—src/service.rssame_model_is_accepted—src/service.rsstaleness_re_check_semantics—src/service.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 52 | 52 |
Public modules with a //! block | 7 | 7 |
pie showData
title Public items with rustdoc
"Documented" : 52
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 8 |
| Source lines | 2610 |
| Code lines | 2008 |
| Public API items | 52 |
| Public modules | 7 |
| Tests | 29 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 7 |
| Workspace reverse dependencies | 5 |
pie showData
title Public API by kind
"constant" : 2
"enum" : 3
"function" : 27
"method" : 5
"struct" : 13
"trait" : 1
"type alias" : 1
pie showData
title Rust source composition
"Code" : 2008
"Blank or comment" : 602
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.