Files
zarinpal-analytics-backend/docs/decisions/0015-deterministic-ai-growth-reports.md

20 lines
1.3 KiB
Markdown

# ADR 0015: Deterministic analytics with bounded AI interpretation
- Status: Accepted
- Date: 2026-08-21
## Context
Growth forecasting, event uplift, low-period detection, and peer comparisons must be reproducible, testable, privacy-safe, and available when an AI provider is unavailable. AvalAI adds value for semantic prioritization and natural Persian campaign guidance, but must not become the source of financial analytics.
## Decision
Use PostgreSQL plus deterministic Go analytics as the sole authority for numbers and evidence. Run a bounded backend-only AvalAI Responses workflow over sanitized aggregates, validate its structured qualitative output, and persist report snapshots by a versioned data fingerprint. Use Redis only for hot caching, coordination, budgets, and rate limits. Defer MCP; keep a narrow internal tool interface that an MCP adapter may wrap only when multiple independent agent clients exist.
## Consequences
- The growth page remains useful with AI disabled, unavailable, rate-limited, or rejected.
- Repeated page visits do not create paid calls while the fingerprint is unchanged.
- Algorithm, catalog, prompt, schema, model, or import changes intentionally invalidate the report.
- The backend owns more deterministic forecasting and validation code, but the result is auditable and tenant-safe.