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
+70
View File
@@ -0,0 +1,70 @@
"""Migration helpers for deprecated provider records.
Scans agent configuration records for deprecated provider values (e.g. "vllm")
and produces structured deprecation warnings to guide operators toward the
canonical protocol names.
Requirements: 2.2, 3.8
"""
from __future__ import annotations
from dataclasses import dataclass
from services.shared.inference.factory import PROTOCOL_ALIASES
@dataclass(frozen=True)
class ProviderDeprecationWarning:
"""Structured deprecation warning for an agent record using a deprecated provider.
Attributes:
agent_id: The ID of the agent with the deprecated provider.
current_value: The current deprecated provider string (e.g. "vllm").
recommended_value: The canonical protocol to migrate to.
message: Human-readable migration guidance.
"""
agent_id: str
current_value: str
recommended_value: str
message: str
def check_deprecated_providers(
agent_records: list[dict],
) -> list[ProviderDeprecationWarning]:
"""Scan agent records for deprecated provider values.
Checks the ``model_provider`` field of each agent record against
PROTOCOL_ALIASES. Records using deprecated aliases get a warning
with migration guidance.
Args:
agent_records: List of dicts, each having at least ``agent_id``
(or ``id``) and ``model_provider`` fields.
Returns:
List of ProviderDeprecationWarning for records using deprecated providers.
"""
warnings_list: list[ProviderDeprecationWarning] = []
for record in agent_records:
agent_id = str(record.get("agent_id") or record.get("id", "unknown"))
provider = (record.get("model_provider") or "").strip().lower()
if provider in PROTOCOL_ALIASES:
recommended = PROTOCOL_ALIASES[provider]
warnings_list.append(
ProviderDeprecationWarning(
agent_id=agent_id,
current_value=provider,
recommended_value=recommended,
message=(
f"Agent {agent_id} uses deprecated provider '{provider}'. "
f"Migrate to protocol '{recommended}'. "
f"The '{provider}' alias will be removed in a future version."
),
)
)
return warnings_list