Local-only embedding-based text clustering: groups texts by vector similarity into opaque, zero-based cluster labels. The embedding vector never leaves this call -- only the cluster label crosses any further disclosure boundary, since a raw vector for a short/constrained phrase can often be inverted back toward the source text (unlike a one-way opaque ID). Generic over infrastructure_embeddings::Embedder -- works with the dependency-free DeterministicEmbedder (lexical-overlap only, not semantic -- the honest default, no model download required) or the real ONNX BGE-m3 embedder behind that crate's `ort` feature (genuinely semantic, opt-in, needs the model present).
| Tier | foundation |
| Role | unclassified (baselined) |
| Path | crates/foundation/text-clustering |
| Edition | 2021 |
| Targets | foundation_text_clustering |
| Public items | 1 across 0 modules |
| Tests | 5 |
What it is for
Local-only embedding-based text clustering: group texts by vector similarity into opaque, zero-based cluster labels via a simple greedy nearest-centroid pass (deterministic given a deterministic embedder and threshold -- no randomized initialization, no iteration count to tune).
The embedding vector never leaves this call. Only the cluster label crosses any further disclosure boundary. This matters: a raw embedding vector for a short, constrained phrase (a citation, a named entity) can often be inverted or nearest-neighbor-matched back toward the source text -- a real, published attack class. A one-way, non-invertible cluster label carries no such geometry to exploit, the same reason table-shard/transcript-shard/prose-shard disclose opaque P1/D1-style IDs and never a raw identifier.
Generic over infrastructure_embeddings::Embedder, so it works unchanged with either implementation already in this repo: the dependency-free DeterministicEmbedder (lexical/word-overlap similarity only -- NOT semantic, and this crate makes no claim otherwise; see that crate's own doc comment) with zero model download required, or the real ONNX BGE-m3 embedder behind infrastructure-embeddings's ort feature (genuinely semantic, opt-in, requires the model to actually be present).
Capabilities
crate root
Local-only embedding-based text clustering: group texts by vector
| Item |
|---|
async fn cluster_texts(embedder : & dyn Embedder, texts : & & str, similarity_threshold : f32,) -> Result <Vec <usize>, EmbeddingError> |
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
No public modules: the crate root is its whole surface.
Public surface
`crate root`
| Item | What it is |
|---|---|
async fn cluster_texts(embedder : & dyn Embedder, texts : & & str, similarity_threshold : f32,) -> Result <Vec <usize>, EmbeddingError> | Cluster texts by embedding similarity |
No pub use re-exports: every item above is declared in this crate.
Boundary
Reaches into infrastructure.
Shares tier foundation with 27 other crates: foundation-audit-log, foundation-basemodels, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, … (27 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) | foundation |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/foundation/text-clustering |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_foundation["foundation"] --> n_infrastructure["infrastructure"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `infrastructure-embeddings` | infrastructure | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio | ^1 | full, macros, rt | no | always |
Build. None.
Depended on by. 1 workspace crate.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_domain_prose_shard["domain-prose-shard"] -->|uses| SELF SELF["foundation-text-clustering"] SELF -->|runtime| n_infrastructure_embeddings["infrastructure-embeddings"] 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 | foundation_text_clustering | `src/lib.rs` |
Error model
No public error type was detected: no public item declares a type named *Error, and no public signature returns one.
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | none detected |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.
Related capabilities
1 workspace crate depends on this one: domain-prose-shard.
Verification
| Kind | Count |
|---|---|
| Unit tests | 5 |
| 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 | 1 | 0 | 1 |
What the tests establish, by name:
a_maximal_threshold_never_merges_non_identical_text—src/lib.rsa_single_text_gets_cluster_zero—src/lib.rsempty_input_returns_empty_labels—src/lib.rsheavily_overlapping_text_clusters_with_completely_different_text_separately—src/lib.rsidentical_texts_always_cluster_together—src/lib.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 1 | 1 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 1
"No rustdoc detected" : 0
Metrics
| Metric | Value |
|---|---|
| Rust source files | 1 |
| Source lines | 159 |
| Code lines | 103 |
| Public API items | 1 |
| Public modules | 0 |
| Tests | 5 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 1 |
| Workspace reverse dependencies | 1 |
pie showData
title Public API by kind
"function" : 1
pie showData
title Rust source composition
"Code" : 103
"Blank or comment" : 56
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.