From d8ea58104c38b8c073232211f6290e735faa0f2a Mon Sep 17 00:00:00 2001 From: Celes Renata Date: Tue, 14 Apr 2026 19:48:19 +0000 Subject: [PATCH] fix: lint errors (import sorting, unused vars) --- .hypothesis/constants/0fd19af6d8bbe8d3 | 4 ++++ .hypothesis/constants/2eeccf7f02200f3b | 4 ++++ .hypothesis/constants/30e3cd0337dfd77a | 4 ++++ .hypothesis/constants/4d73aab997a061aa | 4 ++++ .hypothesis/constants/639343d6f6e87901 | 4 ++++ .hypothesis/constants/83acce76c2cc9437 | 4 ++++ .hypothesis/constants/9677a3e756ff8959 | 4 ++++ .hypothesis/constants/c09a3975d58812bd | 4 ++++ .hypothesis/constants/fcd3f6823e196246 | 4 ++++ .../unicode_data/15.0.0/codec-utf-8.json.gz | Bin 60 -> 60 bytes services/aggregation/interpolation.py | 1 - services/aggregation/projection.py | 4 +--- services/aggregation/worker.py | 21 +++++++++--------- services/api/app.py | 14 +++++------- services/extractor/event_classifier.py | 3 +-- services/lake_publisher/iceberg.py | 2 +- services/lake_publisher/jobs.py | 4 ++-- services/recommendation/worker.py | 2 +- services/symbol_registry/app.py | 4 ++-- 19 files changed, 60 insertions(+), 31 deletions(-) create mode 100644 .hypothesis/constants/0fd19af6d8bbe8d3 create mode 100644 .hypothesis/constants/2eeccf7f02200f3b create mode 100644 .hypothesis/constants/30e3cd0337dfd77a create mode 100644 .hypothesis/constants/4d73aab997a061aa create mode 100644 .hypothesis/constants/639343d6f6e87901 create mode 100644 .hypothesis/constants/83acce76c2cc9437 create mode 100644 .hypothesis/constants/9677a3e756ff8959 create mode 100644 .hypothesis/constants/c09a3975d58812bd create mode 100644 .hypothesis/constants/fcd3f6823e196246 diff --git a/.hypothesis/constants/0fd19af6d8bbe8d3 b/.hypothesis/constants/0fd19af6d8bbe8d3 new file mode 100644 index 0000000..5caca4a --- /dev/null +++ b/.hypothesis/constants/0fd19af6d8bbe8d3 @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/api/app.py +# hypothesis_version: 6.151.14 + +[0.0, 1.0, 30.0, 60.0, 100, 168, 200, 201, 400, 404, 502, 503, 504, 1000, 10000, ' AND ', '/api/analytics/query', '/api/companies', '/api/documents', '/api/macro/events', '/api/orders', '/api/positions', '/api/recommendations', '/api/trends', '/health', '/metrics', '1 day', '1 hour', '15 minutes', '15m', '1d', '1h', '6 hours', '6h', 'Company not found', 'DELETE 0', 'Database unavailable', 'Document not found', 'Order not found', 'Query not found', 'SELECT 1', 'Source not found', 'Trend not found', 'WHERE ', 'X-Trino-Catalog', 'X-Trino-Schema', 'X-Trino-User', '^(15m|1h|6h|1d)$', '__str__', 'active_source_count', 'affected_companies', 'aggregation', 'aliases', 'approved', 'audit_trail', 'by_source_type', 'c.active = $1', 'catalog', 'catalyst_type', 'columns', 'company', 'company_impacts', 'company_mentions', 'competitive_enabled', 'competitive_signals', 'competitor_ticker', 'config', 'contributing_factors', 'count', 'data', 'decision_trace', 'decisions', 'default', 'deleted', 'document_id', 'document_stages', 'dominant_catalysts', 'driving_factors', 'elapsed_ms', 'entity_type = $1', 'events', 'evidence', 'evidence_spans', 'extraction', 'extraction_warnings', 'generated_at', 'hours', 'id', 'intelligence', 'intelligence_id', 'key_facts', 'limit', 'macro.layer_toggled', 'macro_enabled', 'macro_themes', 'market_context', 'material_risks', 'message', 'mir.ticker = $1', 'missing_source_types', 'name', 'new_enabled', 'nextUri', 'ok', 'operator', 'order_job', 'paper', 'parsing', 'pattern_statistics', 'patterns', 'previous_enabled', 'projection', 'query_api', 'recommendation', 'recommendation_id', 'rejected', 'rejection_reasons', 'risk_checks', 'risk_config', 'risk_configs', 'risk_evaluation', 'risks', 'row_count', 'rows', 'schema', 'source', 'sql', 'sql is required', 'stale_sources', 'status', 'stonks-dashboard', 'tables', 'ticker', 'toggled_by', 'trading_mode', 'trend', 'trend_window', 'trend_window_id', 'true', 'type', 'unknown', 'validation_errors', 'x-trace-id'] \ No newline at end of file diff --git a/.hypothesis/constants/2eeccf7f02200f3b b/.hypothesis/constants/2eeccf7f02200f3b new file mode 100644 index 0000000..f64d65e --- /dev/null +++ b/.hypothesis/constants/2eeccf7f02200f3b @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/lake_publisher/jobs.py +# hypothesis_version: 6.151.14 + +[0.0, 2.0, ', ', '1d', '7d', 'Order %s not found', '__main__', 'active', 'affected_commodities', 'affected_regions', 'affected_sectors', 'ap', 'as', 'ask_price', 'ask_size', 'avg_entry_price', 'bar', 'bars', 'bid_price', 'bid_size', 'bidirectional', 'bp', 'broker_account', 'broker_timestamp', 'bs', 'bulk_documents', 'bulk_extractions', 'c', 'canonical_url', 'captured_at', 'catalyst_type', 'close', 'close_price', 'commission', 'company_a_id', 'company_b_id', 'company_event', 'company_id', 'company_name', 'competitive_signal', 'computed_at', 'confidence', 'content_hash', 'contributing_factors', 'created_at', 'current_price', 'data', 'document', 'document_extraction', 'document_id', 'document_type', 'driving_factors', 'en', 'entity_id', 'error', 'estimated_duration', 'event_id', 'event_types', 'execution_mode', 'extraction_at', 'fill_id', 'fill_price', 'fill_quantity', 'global_event', 'h', 'high', 'id', 'impact_direction', 'impact_horizon', 'impact_score', 'interval', 'job_type', 'key_facts', 'l', 'lake_publisher', 'language', 'last_price', 'last_size', 'limit_price', 'low', 'lp', 'ls', 'macro_impact', 'macro_impact_score', 'macro_themes', 'market_snapshot', 'model_name', 'model_version', 'n', 'neutral', 'novelty_score', 'o', 'open', 'order_id', 'order_type', 'other', 'parse_quality_score', 'pattern_confidence', 'pnl_snapshot', 'positions_snapshot', 'price', 'projected_confidence', 'projected_direction', 'projected_strength', 'projection_horizon', 'prompt_version', 'published_at', 'publisher', 'qty', 'quantity', 'quote', 'quotes', 'realized_pnl', 'recommendation_id', 'refs', 'relationship_type', 'relevance', 'retrieved_at', 'risks', 'schema_version', 'sentiment', 'severity', 'short_term', 'side', 'signal_direction', 'signal_strength', 'since', 'snapshot_type', 'source', 'source_credibility', 'source_document_id', 'source_provider', 'source_ticker', 'source_type', 'status', 'strength', 'submitted_at', 'summary', 'target_ticker', 'ticker', 'title', 'trade_count', 'trade_fill', 'trade_order', 'trend_projection', 'trend_window_id', 'unrealized_pnl', 'url', 'v', 'volume', 'vw', 'vwap', '{}'] \ No newline at end of file diff --git a/.hypothesis/constants/30e3cd0337dfd77a b/.hypothesis/constants/30e3cd0337dfd77a new file mode 100644 index 0000000..34b3a62 --- /dev/null +++ b/.hypothesis/constants/30e3cd0337dfd77a @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/recommendation/worker.py +# hypothesis_version: 6.151.14 + +[0.0, 0.1, 0.15, 0.3, 0.5, 1.0, 1.5, 2.0, 3.0, ', ', '1.0.0', '; ', 'DIVERGENCE:', '[risk:', ']', '_', 'computed_at', 'confidence', 'contradiction_score', 'deterministic', 'document_id', 'dominant_catalysts', 'driving_factors', 'eligibility-v1', 'entity_id', 'entity_type', 'evidence', 'evidence_type', 'failed_documents', 'generated_at', 'high', 'id', 'low', 'material_risks', 'max_loss_pct', 'moderate', 'newest_evidence_at', 'none', 'ollama', 'opposing', 'portfolio_pct', 'position_sizing', 'projected_confidence', 'projected_direction', 'projected_strength', 'projection_horizon', 'risk_classification', 'source_types', 'supporting', 'thesis-rewrite', 'time_horizon', 'total_documents', 'trend_direction', 'trend_strength', 'valid_documents', 'very_high', 'weight', 'window'] \ No newline at end of file diff --git a/.hypothesis/constants/4d73aab997a061aa b/.hypothesis/constants/4d73aab997a061aa new file mode 100644 index 0000000..320e0b3 --- /dev/null +++ b/.hypothesis/constants/4d73aab997a061aa @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/aggregation/projection.py +# hypothesis_version: 6.151.14 + +[-1.0, -0.1, 0.0, 0.02, 0.05, 0.1, 0.15, 0.25, 0.3, 0.4, 0.5, 0.75, 0.8, 0.85, 1.0, 1.2, 2.0, 7.0, 24.0, 30.0, '1d', '30d', '7d', '90d', 'bearish', 'bullish', 'critical', 'high', 'intraday', 'long_term', 'low', 'medium_term', 'mixed', 'moderate', 'negative', 'neutral', 'positive', 'projection', 'short_term'] \ No newline at end of file diff --git a/.hypothesis/constants/639343d6f6e87901 b/.hypothesis/constants/639343d6f6e87901 new file mode 100644 index 0000000..aad32fe --- /dev/null +++ b/.hypothesis/constants/639343d6f6e87901 @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/extractor/event_classifier.py +# hypothesis_version: 6.151.14 + +[0.0, 0.5, 1.0, '1.0.0', 'additionalProperties', 'affected_commodities', 'affected_regions', 'affected_sectors', 'application/json', 'array', 'confidence', 'description', 'document_id', 'empty_response', 'enum', 'error', 'estimated_duration', 'event_classifier', 'event_id', 'event_types', 'geopolitical_risk', 'items', 'json_schema', 'key_facts', 'low', 'maximum', 'minimum', 'model', 'number', 'object', 'ollama', 'parsed_event', 'prompt_version', 'properties', 'raw_output', 'required', 'schema_version', 'severity', 'short_term', 'stonks-llm-prompts', 'stonks-llm-results', 'string', 'success', 'summary', 'system', 'system_prompt', 'type', 'user', 'user_prompt'] \ No newline at end of file diff --git a/.hypothesis/constants/83acce76c2cc9437 b/.hypothesis/constants/83acce76c2cc9437 new file mode 100644 index 0000000..57da71b --- /dev/null +++ b/.hypothesis/constants/83acce76c2cc9437 @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/lake_publisher/iceberg.py +# hypothesis_version: 6.151.14 + +[8080, ',\n', ',\n ', ', ', 'BIGINT', 'BOOLEAN', 'DATE', 'DOUBLE', 'INTEGER', 'REAL', 'SMALLINT', 'TIMESTAMP(6)', 'TINYINT', 'VARCHAR', 'bool', 'column_name', 'company_events', 'competitive_signals', 'data_type', 'date32', 'date32[day]', 'date64', 'document_extractions', 'documents', 'double', 'float', 'float32', 'float64', "format = 'PARQUET'", 'global_events', 'iceberg', 'int16', 'int32', 'int64', 'int8', 'is_nullable', 'large_string', 'large_utf8', 'localhost', 'macro_impacts', 'manifest_list', 'market_bars', 'market_quotes', 'model_performance', 'operation', 'parent_id', 'pnl_daily', 'positions_daily', 'row', 'snapshot_id', 'stonks', 'string', 'summary', 'timestamp', 'trade_fills', 'trade_orders', 'trade_signals', 'trend_projections', 'tz=', 'utf8'] \ No newline at end of file diff --git a/.hypothesis/constants/9677a3e756ff8959 b/.hypothesis/constants/9677a3e756ff8959 new file mode 100644 index 0000000..2744379 --- /dev/null +++ b/.hypothesis/constants/9677a3e756ff8959 @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/aggregation/worker.py +# hypothesis_version: 6.151.14 + +[-1.0, -0.15, 0.0, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 1.0, 20.0, 3600.0, 'catalyst_type', 'company', 'company_id', 'competitive_enabled', 'computed_at', 'confidence', 'contributing_factors', 'document_id', 'estimated_duration', 'event_id', 'event_published_at', 'id', 'impact_direction', 'impact_score', 'key_facts', 'low', 'macro_enabled', 'macro_impact_score', 'mixed', 'negative', 'neutral', 'novelty_score', 'opposing', 'other', 'pattern_confidence', 'positive', 'published_at', 'risks', 'sentiment', 'severity', 'short_term', 'signal_direction', 'signal_strength', 'source_credibility', 'source_document_id', 'source_ticker', 'supporting', 'target_ticker', 'ticker', 'true'] \ No newline at end of file diff --git a/.hypothesis/constants/c09a3975d58812bd b/.hypothesis/constants/c09a3975d58812bd new file mode 100644 index 0000000..139212d --- /dev/null +++ b/.hypothesis/constants/c09a3975d58812bd @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/symbol_registry/app.py +# hypothesis_version: 6.151.14 + +[0.5, 201, 365, 404, 409, 503, '/companies', '/health', '/watchlists', 'Already a member', 'Company not found', 'Database unavailable', 'SELECT 1', '^[A-Z]{1,10}$', 'access_policy', 'added', 'base_url', 'brand', 'broker', 'config', 'endpoint', 'filings_api', 'http', 'https', 'internal', 'market_api', 'news_api', 'ok', 'public', 'restricted', 'source_type', 'status', 'symbol_registry', 'ticker', 'url', 'web_scrape'] \ No newline at end of file diff --git a/.hypothesis/constants/fcd3f6823e196246 b/.hypothesis/constants/fcd3f6823e196246 new file mode 100644 index 0000000..76d0434 --- /dev/null +++ b/.hypothesis/constants/fcd3f6823e196246 @@ -0,0 +1,4 @@ +# file: /home/celes/sources/celesrenata/stonks-oracle/services/aggregation/interpolation.py +# hypothesis_version: 6.151.14 + +[-0.693, 0.0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.7, 0.75, 0.85, 1.0, 1.2, 168.0, 'AE', 'AU', 'BR', 'CA', 'CN', 'Consumer Staples', 'DE', 'EU', 'Energy', 'Financials', 'GB', 'Health Care', 'IN', 'Industrials', 'JP', 'KR', 'Materials', 'RU', 'Real Estate', 'SA', 'US', 'Utilities', 'commodity_shock', 'copper', 'corn', 'cost_increase', 'crude_oil', 'currency_impact', 'demand_shift', 'geopolitical_risk', 'inferred', 'interpolation', 'large_cap', 'lithium', 'micro_cap', 'mid_cap', 'mixed', 'natural_gas', 'negative', 'neutral', 'positive', 'regulatory_pressure', 'semiconductors', 'short_term', 'small_cap', 'steel', 'supply_disruption', 'trade_barrier', 'wheat'] \ No newline at end of file diff --git a/.hypothesis/unicode_data/15.0.0/codec-utf-8.json.gz b/.hypothesis/unicode_data/15.0.0/codec-utf-8.json.gz index 1fa1da83370f322891a92376f2c4ace44d0c446b..c017f29eb3b82e3d65421daa05f03b1f9e90aae5 100644 GIT binary patch delta 27 icmcDq5tZ-e;9z86U|{-Rl3QS6VwRFq7@s#$R2=|R5(g9j delta 27 icmcDq5tZ-e;9z86U|{-Rl3P#_Uyx@}7H>IGR2=|V 0: - current_factor = math.pow(2.0, -current_age_days / half_life) future_factor = math.pow(2.0, -future_age_days / half_life) else: - current_factor = 0.0 future_factor = 0.0 severity_w = _SEVERITY_WEIGHT.get(ev.severity, 0.25) diff --git a/services/aggregation/worker.py b/services/aggregation/worker.py index 05c9b66..80cd736 100644 --- a/services/aggregation/worker.py +++ b/services/aggregation/worker.py @@ -27,6 +27,12 @@ from services.aggregation.evidence import ( rank_evidence as _rank_evidence_composite, ) from services.aggregation.market_context import fetch_market_context +from services.aggregation.pattern_matcher import find_self_patterns +from services.aggregation.projection import ( + MacroEventInfo, + compute_projection, + persist_trend_projection, +) from services.aggregation.scoring import ( ScoringConfig, WeightedSignal, @@ -34,23 +40,16 @@ from services.aggregation.scoring import ( sentiment_to_numeric, weighted_sentiment_average, ) +from services.aggregation.signal_propagation import ( + CompetitiveSignalRecord, + build_pattern_weighted_signals, +) from services.shared.metrics import ( AGGREGATION_CONTRADICTION_SCORE, AGGREGATION_DURATION, AGGREGATION_SIGNALS_PROCESSED, AGGREGATION_WINDOWS_COMPUTED, ) -from services.aggregation.pattern_matcher import find_self_patterns -from services.aggregation.projection import ( - MacroEventInfo, - TrendProjection, - compute_projection, - persist_trend_projection, -) -from services.aggregation.signal_propagation import ( - CompetitiveSignalRecord, - build_pattern_weighted_signals, -) from services.shared.schemas import TrendDirection, TrendSummary, TrendWindow logger = logging.getLogger(__name__) diff --git a/services/api/app.py b/services/api/app.py index 0bf293b..22062be 100644 --- a/services/api/app.py +++ b/services/api/app.py @@ -16,6 +16,7 @@ import json import logging import time as _time from contextlib import asynccontextmanager +from dataclasses import asdict from datetime import datetime, timezone from typing import Any, Optional @@ -27,11 +28,16 @@ from pydantic import BaseModel from starlette.middleware.base import BaseHTTPMiddleware from starlette.responses import Response +from services.aggregation.pattern_matcher import ( + find_cross_company_patterns, + find_self_patterns, +) from services.extractor.metrics import get_model_performance_summary from services.shared.audit import get_entity_audit_trail, get_order_audit_trail, record_audit_event from services.shared.config import load_config from services.shared.db import get_pg_pool from services.shared.logging import new_trace_id, set_trace_context, setup_logging +from services.shared.schemas import MAJOR_DECISION_CATALYSTS logger = logging.getLogger("query_api") @@ -2092,14 +2098,6 @@ async def toggle_competitive_layer(body: CompetitiveToggleBody): # (Requirements 10.1, 10.2, 10.3, 10.4, 11.4, 11.6) # --------------------------------------------------------------------------- -from dataclasses import asdict - -from services.aggregation.pattern_matcher import ( - find_cross_company_patterns, - find_self_patterns, -) -from services.shared.schemas import MAJOR_DECISION_CATALYSTS - def _pattern_to_dict(p) -> dict[str, Any]: """Convert a HistoricalPattern dataclass to a JSON-safe dict.""" diff --git a/services/extractor/event_classifier.py b/services/extractor/event_classifier.py index fe5f92c..b0db953 100644 --- a/services/extractor/event_classifier.py +++ b/services/extractor/event_classifier.py @@ -461,10 +461,9 @@ async def classify_global_event( model_name = ollama_client._config.model # Persist prompt to MinIO - prompt_ref = None if minio_client: try: - prompt_ref = _upload_classification_prompt( + _upload_classification_prompt( minio_client, document_id, prompts, model_name, timestamp=ts, ) except Exception: diff --git a/services/lake_publisher/iceberg.py b/services/lake_publisher/iceberg.py index 0b673a4..970d7a4 100644 --- a/services/lake_publisher/iceberg.py +++ b/services/lake_publisher/iceberg.py @@ -128,8 +128,8 @@ TABLE_SCHEMAS: dict[str, pa.Schema] = { # These are added after the initial dict definition. def _register_worker_schemas() -> None: from services.lake_publisher.worker import ( - COMPETITOR_RELATIONSHIPS_SCHEMA, COMPETITIVE_SIGNALS_SCHEMA, + COMPETITOR_RELATIONSHIPS_SCHEMA, GLOBAL_EVENTS_SCHEMA, MACRO_IMPACTS_SCHEMA, TREND_PROJECTIONS_SCHEMA, diff --git a/services/lake_publisher/jobs.py b/services/lake_publisher/jobs.py index a107114..e74583a 100644 --- a/services/lake_publisher/jobs.py +++ b/services/lake_publisher/jobs.py @@ -35,6 +35,8 @@ from minio import Minio from services.lake_publisher.partitions import partition_values from services.lake_publisher.worker import ( + publish_competitive_signal_fact, + publish_competitor_relationship_fact, publish_document_extraction, publish_document_extractions_batch, publish_document_fact, @@ -48,8 +50,6 @@ from services.lake_publisher.worker import ( publish_trade_fill, publish_trade_order, publish_trend_projection_fact, - publish_competitor_relationship_fact, - publish_competitive_signal_fact, ) from services.shared.config import load_config from services.shared.db import get_minio, get_pg_pool, get_redis diff --git a/services/recommendation/worker.py b/services/recommendation/worker.py index 5c7979f..0a38df8 100644 --- a/services/recommendation/worker.py +++ b/services/recommendation/worker.py @@ -15,6 +15,7 @@ from datetime import datetime, timezone import asyncpg from minio import Minio +from services.aggregation.projection import TrendProjection from services.lake_publisher.worker import publish_recommendation_facts from services.recommendation.eligibility import ( EligibilityConfig, @@ -31,7 +32,6 @@ from services.recommendation.thesis_llm import ( THESIS_PROMPT_VERSION, rewrite_thesis_with_llm, ) -from services.aggregation.projection import TrendProjection from services.shared.config import OllamaConfig from services.shared.metrics import ( RECOMMENDATION_CONFIDENCE, diff --git a/services/symbol_registry/app.py b/services/symbol_registry/app.py index 02dcdc2..8afd599 100644 --- a/services/symbol_registry/app.py +++ b/services/symbol_registry/app.py @@ -12,9 +12,9 @@ from pydantic import BaseModel, field_validator from services.shared.config import load_config from services.shared.db import get_pg_pool from services.shared.logging import setup_logging -from services.symbol_registry.exposure import router as exposure_router -from services.symbol_registry.competitors import router as competitors_router from services.symbol_registry.competitor_inference import router as inference_router +from services.symbol_registry.competitors import router as competitors_router +from services.symbol_registry.exposure import router as exposure_router config = load_config() pool: Optional[asyncpg.Pool] = None