Deus - Discovery, Extraction, Embedding, and Index Construction
The discovery pipeline that turns a query into ranked service results: constraint extraction, semantic embedding, vector + lexical candidate retrieval, and blended scoring.
Overview
The discovery pipeline turns a free-text query into ranked service results. It extracts structured constraints from the query, generates optional semantic embeddings, merges vector and lexical candidates, filters by price and uptime, and blends a final score.
Discovery Service
Source: deus/internal/discovery/discovery.go
The Service owns query execution, candidate merging, and ranking. It is constructed with a store, an embedder, and ranking weights.
Search flow
- Clamp
Limitto 10 (default) when<= 0or> 100 - Call
ExtractConstraintswith query text and explicit filters - Resolve
kind,max_price_wei,min_uptime_bpsfrom extracted filters - Merge candidate rows by ID from semantic and lexical searches
- Fall back to
ListDiscoverCandidatesonly when both search paths produce nothing - Filter by uptime, then by price
- Score with
BlendScoreWithPrice, sort descending, truncate to limit
Result fields
Each DiscoverResult carries: ID, Slug, DisplayName, Summary, Kind, QualityScore, UptimeBPS, Score, and Operations (from the manifest pricing array).
Ranking weights
Configurable via WithRankingWeights. Default values:
| Signal | Weight |
|---|---|
| semantic | 0.40 |
| quality | 0.30 |
| uptime | 0.15 |
| price | 0.10 |
| freshness | 0.05 |
Degradation model
The search pipeline degrades gracefully:
- Embedding failures do not stop lexical search
- Vector search failures do not stop lexical search
- Lexical failures do not stop browse fallback
- The only hard failure is when no candidates exist at all
Constraint Extraction
Source: deus/internal/discovery/extract.go
ExtractConstraints turns plain-language queries into structured filters:
| Pattern | Extracted filter |
|---|---|
under <N> PAX | max_price_wei (via paxToWei, multiply by 1e18) |
under <N> wei | max_price_wei |
> <N>% uptime or at least <N>% uptime | min_uptime_bps (N * 100) |
agent service | kind = "agent" |
data service | kind = "data" |
Explicit filters win over text extraction. The semantic query is the remaining text after recognized phrases are stripped and normalized.
Embedding Implementations
Source: deus/internal/discovery/embed.go
HashEmbedder (default)
- Deterministic, non-semantic (768-dimensional)
Semantic()returnsfalse-- disables vector search- Generates normalized vectors from SHA-256 seeds
- Used as development/test fallback
HTTPEmbedder
- Calls a remote embedding service (JSON POST)
Semantic()returnstrue-- enables vector search- 15-second HTTP timeout
- Default dimension: 768
- Response shape:
data[0].embedding
Backend selection
NewEmbedderFromConfig returns HTTPEmbedder when the endpoint string is non-blank, otherwise HashEmbedder.
Search Document Construction
Source: deus/internal/discovery/index.go
BuildSearchDocument concatenates: DisplayName, Summary, Description, each Tags entry, and each Operations[].Name into a single trimmed string.
IndexService validates the manifest, writes the search document to the store (for lexical/tsvector search), embeds the document, and upserts the embedding vector (for pgvector HNSW search). A nil embedder short-circuits after the search document is stored, so lexical search works even without a semantic backend.
Catalog Endpoint
Source: deus/internal/server/handlers_discovery.go
GET /v1/catalog serves the public paginated catalog. It enriches each CatalogItem with headline pricing (first pricing[].price_wei + unit) and tags extracted from the stored manifest JSON. Response:
{
"services": [...],
"total": 42,
"limit": 20,
"offset": 0
}