feat: competitive intelligence & historical pattern matching layer

This commit is contained in:
Celes Renata
2026-04-14 19:42:48 +00:00
parent b478022ba3
commit f7a11d14ea
203 changed files with 20155 additions and 97 deletions
+14 -2
View File
@@ -35,7 +35,7 @@ from services.shared.metrics import (
PARSE_LOW_QUALITY_TOTAL,
PARSE_QUALITY_SCORE,
)
from services.shared.redis_keys import QUEUE_EXTRACTION, QUEUE_PARSING, queue_key
from services.shared.redis_keys import QUEUE_EXTRACTION, QUEUE_MACRO_CLASSIFICATION, QUEUE_PARSING, queue_key
from services.shared.storage import upload_normalized_text, upload_parser_output
logger = logging.getLogger("parser_worker")
@@ -210,7 +210,19 @@ async def process_job(
# Only enqueue for extraction if quality is acceptable
if parsed.confidence != "low":
await rds.rpush(queue_key(QUEUE_EXTRACTION), json.dumps(inject_trace_context({
# Route macro_event documents to the macro classification queue
# instead of the standard extraction queue (Requirement 2.1)
doc_type_row = await pool.fetchrow(
"SELECT document_type FROM documents WHERE id = $1::uuid", doc_id,
)
doc_type = doc_type_row["document_type"] if doc_type_row else None
if doc_type == "macro_event":
target_queue = queue_key(QUEUE_MACRO_CLASSIFICATION)
else:
target_queue = queue_key(QUEUE_EXTRACTION)
await rds.rpush(target_queue, json.dumps(inject_trace_context({
"document_id": doc_id,
"ticker": ticker,
"normalized_text": text[:32000],