Imported from kathir-iTech/ScamShield (
docs/archive/AGENTS.md). Install upstream withnpx skills add kathir-iTech/ScamShield --skill archive. Copyright stays with the author.
ScamShield — Agent State
Active Summary
Phase 1.5 (FPR Regression Fix) COMPLETE (2026-08-30). FPR reduced from 48% to 14%. Recall 77%. Both targets met.
Current Best Model
- Backend model: TF-IDF + LogisticRegression, trained on v2 gamma dataset (2,531 samples)
- Performance: Test Acc=0.9513, F1=0.9622, ROC-AUC=0.9898, FPR=1.92%
- Top scam indicators: http, xyz, verify, update, pay, tk, pan, fee, kyc
- Top safe indicators: valid, aug, credited, order, ref, delivered
Full Pipeline Gold Eval (refined_prediction, 308 samples)
- Acc=0.8084, Prec=0.8854, Rec=0.7722, F1=0.8249
- FPR=0.1406, FNR=0.2278 (targets: FPR<=15%, Recall>=75%)
- TP=139, FP=18, FN=41, TN=110
- Gold labels fixed: 24 LEGITIMATE_* entries corrected
Dataset
- v2 gamma (2531 samples: 1734 scam, 797 safe, 25 categories)
- Model registry:
backend/models/registry.json - Training log:
backend/models/training_log.json - Production artifacts:
backend/models/model.joblib,vectorizer.joblib
Production Readiness — Phase 2-8 Complete
Phase 2: Observability ✓
- Prometheus metrics endpoint (17 metric instruments, OpenMetrics format)
- Request tracing with contextvars
- Structured logging with trace/span IDs,
log_durationcontext manager - Grafana dashboard (
monitoring/grafana/dashboard.json) - Alertmanager rules (9 alert rules)
- Prometheus + Grafana Docker Compose overlay
- Health diagnostics improvements
Phase 3: Scalability ✓
- Thread-safe
SlidingWindowRateLimiter(threading.Lock) - Redis-backed distributed rate limiter with graceful in-memory fallback
create_rate_limiter()factory auto-selects Redis or in-memory- FastAPI lifespan pattern (replaced deprecated
@app.on_event) - OCR thread pool cleanup on shutdown (configurable
max_workers) - Shared connector thread pool (lazy-init, reused across calls)
- Rate limit headers on auth endpoints
Phase 4: ML Operations ✓
ModelRegistrywith JSON persistence (models/registry.json)PredictionLoggerwith daily JSONL files (logs/predictions/)DriftDetector(accuracy, confidence, data, latency checks)EvalSchedulerfor automated evaluation runs- Model rollback support in registry
- Model info endpoint (
GET /model/info) - Prediction logging integrated into
/analyze/textand/analyze/image
Phase 5: Quality ✓
- Proper
__init__.pyexports for all packages (core, domains, services, routers, etc.) - Removed unused
import refromconnectors/utils.py - Added type hints (
core/metrics.py,scripts/quality_gate.py) - Created
pyproject.tomlwith ruff/mypy/pytest config - Quality and core-init test suites added
Phase 6: Performance ✓
- Cold start eliminated: Model + pipeline warmup in FastAPI lifespan
- Model load: 11,551ms (cold) → 0ms (warmup)
- Knowledge service: 463ms (cold) → 0ms (warmup)
- Connector step: 146ms (cold) → 0ms (warmup)
- API text P50: 42.88ms (min 32ms, max 202ms)
- Pipeline P50: 66.29ms / P95: 98ms
- Inference (1000 chars): P50 2.86ms, P95 12.15ms, P99 24.14ms
- Performance baseline at
backend/performance_baseline.json
Phase 7: DevOps ✓
.dockerignore(root + backend)- K8s manifests validated: probes (
/live//ready), configmap (SCAMSHIELD_*), ingress (SPA routing), secrets template, HPA - Rollback script (
scripts/rollback.sh) - Backup/DR documentation (
docs/BACKUP.md) - GitLeaks secret scanning in CI
- Docker security scan (Trivy) in CI backend workflow
- Coverage gate rewritten in pure Python
Phase 8: Final Validation ✓
- 820 tests passed, 0 failed, 3 skipped (pre-existing)
- All K8s YAML files valid
- Docker Compose valid
- Full validation report at
backend/VALIDATION_REPORT.md
Known Issues
- Transformer model (DistilBERT) won't train:
module 'datasets' has no attribute 'Dataset'— library compat - Embedding evaluation is slow (per-sample SentenceTransformer inference on CPU)
- A few categories still below 60 samples (legitimate categories mostly)
- No non-English samples yet (Tamil/Hindi/Telugu)
- Benchmark/gamma still uses beta DATA_PATH in run_beta_benchmark.py — need separate gamma benchmark
- Frontend bundle build fails due to
@sentry/coredependency resolution — pre-existing - OCR profiling not possible without Tesseract installed on dev machine
Next Priorities
- Fix frontend Sentry dependency issue for production builds
- Add real-world data collection to fix remaining 13 FNs
- Add REST API endpoint for model retraining
- Implement Helm charts for Kubernetes deployment
- Add Terraform infrastructure-as-code for cloud deployment