Forge module: semantic + hybrid (FTS∪vector RRF) evidence search over pgvector, consuming infrastructure-embeddings. Per-firm; privilege-safe (vectors stay in the firm DB).
| Tier | application |
| Role | unclassified (baselined) |
| Path | crates/application/legal-knowledge |
| Edition | 2024 |
| Targets | application_legal_knowledge |
| Public items | 8 across 0 modules |
| Tests | 4 |
What it is for
application-legal-knowledge — semantic + hybrid evidence search wired over infrastructure-embeddings: schema (migrations/, pgvector), persistence (repo), behavior (IndexService + HybridSearch), and HTTP (firm_router). Per-firm module — mount under the host firm plane WITH a SharedEmbedder layer.
Privilege-safe by construction (ADR 0016): chunks + vectors live in the firm's own data DB, embeddings are produced in-process, and nothing on the default path egresses to a third party. Retrieval fuses bilingual FTS with vector similarity (RRF k=60) so exact citations AND cross-lingual meaning both surface.
Capabilities
LegalKnowledgeModule
application-legal-knowledge — semantic + hybrid evidence search wired over
| Item |
|---|
pub struct LegalKnowledgeModule |
LegalKnowledgeModule :: fn new() -> Self |
LegalKnowledgeModule :: fn name(& self) -> & 'static str |
LegalKnowledgeModule :: fn version(& self) -> & 'static str |
LegalKnowledgeModule :: fn migrations(& self) -> Vec <MigrationSet> |
LegalKnowledgeModule :: async fn migrate_pending(& self, pool : & PgPool) -> std::result::Result <u32, MigrationError> |
LegalKnowledgeModule :: fn permission_codes(& self) -> Vec <String> |
SharedEmbedder
application-legal-knowledge — semantic + hybrid evidence search wired over
| Item |
|---|
pub type SharedEmbedder: Arc <dyn Embedder> |
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 |
|---|---|
pub type SharedEmbedder: Arc <dyn Embedder> | The embedder the host installs as an axum Extension for the handlers |
pub struct LegalKnowledgeModule | — |
LegalKnowledgeModule :: fn new() -> Self | — |
LegalKnowledgeModule :: fn name(& self) -> & 'static str | — |
LegalKnowledgeModule :: fn version(& self) -> & 'static str | — |
LegalKnowledgeModule :: fn migrations(& self) -> Vec <MigrationSet> | — |
LegalKnowledgeModule :: async fn migrate_pending(& self, pool : & PgPool) -> std::result::Result <u32, MigrationError> | — |
LegalKnowledgeModule :: fn permission_codes(& self) -> Vec <String> | — |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
ServiceError | error::ServiceError |
firm_router | api::firm_router |
{ChunkHit,to_pgvector} | repo::{ChunkHit,to_pgvector} |
{ChunkOptions,DeterministicEmbedder,Embedder,EmbeddingError,NormalizePolicy,TextChunk,chunk_text,} | infrastructure_embeddings::{ChunkOptions,DeterministicEmbedder,Embedder,EmbeddingError,NormalizePolicy,TextChunk,chunk_text,} |
{HybridSearch,IndexService,ScoredChunk,VECTOR_DIM} | service::{HybridSearch,IndexService,ScoredChunk,VECTOR_DIM} |
Boundary
Reaches into infrastructure.
Shares tier application with 120 other crates: application-agreements, application-ai, application-analytics, application-approvals, application-assessments, application-audit-log, application-auth, application-billing, … (120 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) | application |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/application/legal-knowledge |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_application["application"] --> n_infrastructure["infrastructure"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-core` | application | no | always |
| `infrastructure-embeddings` | infrastructure | no | always |
| `infrastructure-tenant-pool` | infrastructure | no | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
async-trait | ^0.1 | — | no | always |
axum | ^0.7 | multipart | no | always |
chrono | ^0.4 | serde, serde | no | always |
serde | ^1 | derive, derive | no | always |
serde_json | ^1 | — | no | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json, migrate | no | always |
thiserror | ^2 | — | no | always |
uuid | ^1 | v4, v7, serde, js, v4, serde | no | always |
Development, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `application-legal-evidence` | application | 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. Nothing in this workspace.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR SELF["application-legal-knowledge"] SELF -->|development| n_application_legal_evidence["application-legal-evidence"] SELF -->|runtime| n_application_core["application-core"] SELF -->|runtime| n_infrastructure_embeddings["infrastructure-embeddings"] SELF -->|runtime| n_infrastructure_tenant_pool["infrastructure-tenant-pool"] 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 | application_legal_knowledge | `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 | yes |
| network I/O | yes |
| 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 |
|---|---|
CARGO_PKG_VERSION | src/lib.rs |
LEGAL_TEST_DB | src/lib.rs |
Related capabilities
No workspace crate depends on this one.
Verification
| Kind | Count |
|---|---|
| Unit tests | 4 |
| 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 | 2 | 0 | 0 |
What the tests establish, by name:
hybrid_search_indexes_and_retrieves—src/lib.rsmodule_declares_perms_and_migration—src/lib.rsfuse_respects_limit_and_is_deterministic—src/service.rsrrf_rewards_agreement_across_arms—src/service.rs
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 1 | 8 |
Public modules with a //! block | 0 | 0 |
pie showData
title Public items with rustdoc
"Documented" : 1
"No rustdoc detected" : 7
Metrics
| Metric | Value |
|---|---|
| Rust source files | 5 |
| Source lines | 782 |
| Code lines | 610 |
| Public API items | 8 |
| Public modules | 0 |
| Tests | 4 |
| Examples | 0 |
| Cargo features | 0 |
| Direct runtime dependencies | 11 |
| Workspace reverse dependencies | 0 |
pie showData
title Public API by kind
"method" : 6
"struct" : 1
"type alias" : 1
pie showData
title Rust source composition
"Code" : 610
"Blank or comment" : 172
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.