Contract Risk Analyzer (CRA) — Migration Plan
This plan details the step-by-step steps for migrating historical datasets and resolving remaining functionality gaps in the Contract Risk Analyzer (CRA).
Migration Roadmap
chronology
title Gap Resolution Timeline
2026-07-15 : Retrain MLP Classifier
2026-07-16 : Cache Qwen LLM Weights
2026-07-17 : Remove Deprecated Datasets
2026-07-18 : Prepare PostgreSQL Migration
1. Action Items
Step 1: Retrain the MLP Clause Classifier (risk_scorer.pkl / legal_mlp.pkl)
- Rationale: The MLP classifier file is currently missing, causing
sydeco_engine.pyto fall back to rule-based classification. Retraining on current master CSVs will restore AI clause tag matching. - Execution:
Run these commands inside the
appcontainer:# Step A: Compile training data from datasets directory python3 scripts/import_datasets.py # Step B: Retrain classifier and generate risk_scorer.pkl python3 scripts/train_mlp.py
Step 2: Cache Qwen LLM weights for Layer 4 Explanations
- Rationale: The prompt runner is ready, but tests are currently PENDING because the
Qwen3-1.7Bweights are not cached locally. - Execution:
- Temporarily enable downloading by setting
LDV_DOWNLOAD_MODELS=1indocker-compose.yml. - Restart the container to download and cache the model:
docker compose up --build -d app - Once downloaded, revert
LDV_DOWNLOAD_MODELSto0to enforce strict offline execution.
- Temporarily enable downloading by setting
Step 3: Remove Deprecated Datasets
- Rationale: Deleting historical files prevents configuration conflicts and reduces confusion.
- Execution:
Safely delete the following files from
/datasets:dangerous_clauses.csvdangerous_clauses_ADDITIONS.csvdangerous_clauses_MASTER.csvrequired_clauses.csvrequired_clauses_final_OPTIMAL_with_Legal_Reference.csv
Step 4: Prepare PostgreSQL Schema Migration
- Rationale: Upgrading from SQLite to PostgreSQL avoids database write-locking issues in multi-worker production environments.
- Execution:
Configure target database endpoints by injecting
LDV_DB_PATH=postgresql://user:pass@host:port/dbnameinto Gunicorn environment variables.