feat: Intelligence Pipeline v3 — full implementation

Multi-stage evidence-grounded inference architecture replacing the
monolithic 9B model extraction pipeline. CPU-first specialist services
handle routine extraction while the 9B vLLM model is preserved for
semantic adjudication of ambiguous cases.

Key components:
- Capability-aware inference gateway (OpenAI-compatible + Ollama)
- Endpoint registry with DB migrations and REST API
- Sentence-aware document segmenter (property tests)
- Deterministic financial parsing with offset integrity
- Symbol resolution with ambiguity detection
- Specialist service (GLiNER2, dynamic batching, K8s deployment)
- Company-specific sentiment (FinBERT, calibration)
- Retrieval-based novelty and duplicate detection
- Confidence calibration pipeline
- Deterministic routing engine (property tests)
- 9B adjudication layer with VRAM gating
- Stock-specific impact model (features, labels, baseline, trained)
- Pipeline orchestrator (state machine, queues, leases, feature flags)
- Bounded parallelism (async workers, semaphore, load shedding)
- Observability (tracing, metrics, alerts)
- Compatibility adapter (v3→v2 golden mapping tests)
- Shadow/canary promotion framework
- Active learning and fine-tuning pipeline

Test results: 1,161 tests pass, ruff lint clean.
All 282 spec tasks completed.
This commit is contained in:
Celes Renata
2026-07-13 02:14:59 +00:00
parent 84634a365e
commit a72f336ad1
227 changed files with 50403 additions and 0 deletions
@@ -0,0 +1,37 @@
"""Retrieval-based novelty and duplicate detection.
Replaces model-generated novelty with deterministic fingerprinting,
semantic embeddings, and similarity-based scoring against a recent
history window.
"""
from services.intelligence_pipeline_v3.novelty.embeddings import (
EmbeddingBackend,
MockEmbeddingBackend,
SentenceTransformerBackend,
cosine_similarity,
)
from services.intelligence_pipeline_v3.novelty.fingerprints import (
compute_exact_fingerprint,
compute_simhash,
hamming_distance,
is_near_duplicate,
)
from services.intelligence_pipeline_v3.novelty.index import Match, NoveltyIndex
from services.intelligence_pipeline_v3.novelty.models import NoveltyResult
from services.intelligence_pipeline_v3.novelty.scorer import NoveltyScorer
__all__ = [
"EmbeddingBackend",
"Match",
"MockEmbeddingBackend",
"NoveltyIndex",
"NoveltyResult",
"NoveltyScorer",
"SentenceTransformerBackend",
"compute_exact_fingerprint",
"compute_simhash",
"cosine_similarity",
"hamming_distance",
"is_near_duplicate",
]