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.
40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
"""Routing reason enums for the deterministic routing engine.
|
|
|
|
RoutingReason captures *why* a document was routed to adjudication or accepted
|
|
on the fast path. RouteDecision is the binary outcome.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import Enum
|
|
|
|
|
|
class RoutingReason(str, Enum):
|
|
"""Structured reason codes explaining a routing decision.
|
|
|
|
Any triggered reason (except FAST_PATH_ACCEPTED) forces adjudication.
|
|
These codes are stored in the database as TEXT[] and must remain stable
|
|
across versions for audit queries.
|
|
"""
|
|
|
|
UNRESOLVED_ALIAS = "UNRESOLVED_ALIAS"
|
|
MULTIPLE_PRIMARY_COMPANIES = "MULTIPLE_PRIMARY_COMPANIES"
|
|
CONTRADICTORY_NUMERIC_FACTS = "CONTRADICTORY_NUMERIC_FACTS"
|
|
CONFLICTING_SENTIMENT = "CONFLICTING_SENTIMENT"
|
|
IMPLIED_CAUSAL_IMPACT = "IMPLIED_CAUSAL_IMPACT"
|
|
GUIDANCE_VS_CONSENSUS_REQUIRES_REASONING = (
|
|
"GUIDANCE_VS_CONSENSUS_REQUIRES_REASONING"
|
|
)
|
|
MATERIAL_FIELD_MISSING = "MATERIAL_FIELD_MISSING"
|
|
EVIDENCE_COVERAGE_BELOW_THRESHOLD = "EVIDENCE_COVERAGE_BELOW_THRESHOLD"
|
|
CALIBRATED_CONFIDENCE_BELOW_THRESHOLD = "CALIBRATED_CONFIDENCE_BELOW_THRESHOLD"
|
|
LONG_DOCUMENT_CROSS_CHUNK_RELATION = "LONG_DOCUMENT_CROSS_CHUNK_RELATION"
|
|
FAST_PATH_ACCEPTED = "FAST_PATH_ACCEPTED"
|
|
|
|
|
|
class RouteDecision(str, Enum):
|
|
"""Binary routing outcome."""
|
|
|
|
FAST_PATH = "fast_path"
|
|
ADJUDICATION = "adjudication"
|