feat(platform): add new services, tools, tests and crews modules

New router intelligence modules (26 files): alert_ingest/store, audit_store,
architecture_pressure, backlog_generator/store, cost_analyzer, data_governance,
dependency_scanner, drift_analyzer, incident_* (5 files), llm_enrichment,
platform_priority_digest, provider_budget, release_check_runner, risk_* (6 files),
signature_state_store, sofiia_auto_router, tool_governance

New services:
- sofiia-console: Dockerfile, adapters/, monitor/nodes/ops/voice modules, launchd, react static
- memory-service: integration_endpoints, integrations, voice_endpoints, static UI
- aurora-service: full app suite (analysis, job_store, orchestrator, reporting, schemas, subagents)
- sofiia-supervisor: new supervisor service
- aistalk-bridge-lite: Telegram bridge lite
- calendar-service: CalDAV calendar service with reminders
- mlx-stt-service / mlx-tts-service: Apple Silicon speech services
- binance-bot-monitor: market monitor service
- node-worker: STT/TTS memory providers

New tools (9): agent_email, browser_tool, contract_tool, observability_tool,
oncall_tool, pr_reviewer_tool, repo_tool, safe_code_executor, secure_vault

New crews: agromatrix_crew (10 modules: depth_classifier, doc_facts, doc_focus,
farm_state, light_reply, llm_factory, memory_manager, proactivity, reflection_engine,
session_context, style_adapter, telemetry)

Tests: 85+ test files for all new modules
Made-with: Cursor
This commit is contained in:
Apple
2026-03-03 07:14:14 -08:00
parent e9dedffa48
commit 129e4ea1fc
241 changed files with 69349 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
"""Tests for compute_scenario — fertilizer ×2 impact on profit."""
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
from crews.agromatrix_crew.doc_facts import compute_scenario, merge_doc_facts, extract_doc_facts
FACTS = {
"profit_uah": 5_972_016.0,
"fertilizer_uah": 1_521_084.0,
"area_ha": 497.0,
}
def test_fertilizer_double_profit():
question = "якщо збільшити витрати на добрива вдвічі, яким буде прибуток?"
ok, text = compute_scenario(question, FACTS)
assert ok is True, f"Expected ok=True, got text={text}"
# 5 972 016 - 1 521 084 = 4 450 932
assert "4 450 932" in text or "4450932" in text, f"Expected 4450932 in: {text}"
def test_fertilizer_double_contains_delta():
question = "якщо добрива збільшити вдвічі?"
ok, text = compute_scenario(question, FACTS)
assert ok is True
# Повинна бути згадка суми добрив як delta
assert "1 521 084" in text or "1521084" in text, f"Delta missing: {text}"
def test_fertilizer_double_no_profit_fact():
facts_no_profit = {"fertilizer_uah": 1_521_084.0}
ok, text = compute_scenario("добрива вдвічі яким буде прибуток?", facts_no_profit)
assert ok is False
def test_fertilizer_double_no_fertilizer_fact():
facts_no_fert = {"profit_uah": 5_972_016.0}
ok, text = compute_scenario("добрива вдвічі?", facts_no_fert)
assert ok is False
def test_merge_doc_facts_basic():
old = {"profit_uah": 5_972_016.0}
new = {"fertilizer_uah": 1_521_084.0, "area_ha": 497.0}
merged = merge_doc_facts(old, new)
assert merged["profit_uah"] == 5_972_016.0
assert merged["fertilizer_uah"] == 1_521_084.0
assert merged["area_ha"] == 497.0
def test_merge_conflict_detection():
old = {"profit_uah": 5_972_016.0}
# Значення відрізняється > 1%
new = {"profit_uah": 3_000_000.0}
merged = merge_doc_facts(old, new)
assert "conflicts" in merged
assert "profit_uah" in merged["conflicts"]
assert merged.get("needs_recheck") is True
# Старе значення збережено
assert merged["profit_uah"] == 5_972_016.0
def test_extract_then_compute():
"""E2E: extract → compute scenario."""
text = (
"Загальна площа — 497 га. Прибуток — 5 972 016 грн. "
"Витрати на добрива — 1 521 084 грн."
)
facts = extract_doc_facts(text)
assert facts.get("profit_uah")
assert facts.get("fertilizer_uah")
ok, result = compute_scenario("якщо добрива вдвічі — прибуток?", facts)
assert ok is True
assert "4 450 932" in result or "4450932" in result