How rkjegan/razorpay_track_03_ghost_ledger works
Ghost Ledger is a bounded revenue-recovery agent: it generates and diagnoses failed-transaction data, gates recovery attempts with deterministic policy, selects payment-link or mandate retries, records decisions, and reports results. The main run also supports model training and held-out evaluation; autopsy prose is a separate, non-decision capability. The README documents the overall workflow and key guarantees; source excerpts and the SOURCE INDEX support the specific implementation relationships shown.
Main entry points: main.py Pipeline runner · recovery_base.py Recovery sequence · metrics.py Recovery metrics · db_client.py SQLite store
Components 20
Data and diagnosis
- Synthetic data
data/synthetic_generator.py - Transaction seeding
database/seed_db.py - Root-cause classifier
diagnoser/root_cause_classifier.py - Model training
diagnoser/train.py - Holdout evaluation
diagnoser/eval_holdout.py
Recovery workflow
- Pipeline runner
main.py - Policy engine
agents/policy_engine.py - Recovery sequence
agents/recovery_base.py - Payment-link retry
agents/payment_failure_agent.py - Mandate retry
agents/subscription_agent.py - Razorpay client
api/razorpay_client.py
Records and reporting
- Audit trail
database/audit_trail.py - SQLite store
database/db_client.py - Recovery metrics
metrics.py - Recovery dashboard
dashboard/app.py - Precision-recall panel
dashboard/components/precision_recall_panel.py - Weekly recovery report
weekly_report.py
Autopsy reporting
- Autopsy reporter
agents/autopsy_reporter.py - LLM service
Other components
- Pipeline operator
Connections 25
- Pipeline operator → Pipeline runner: runs
README.md - Pipeline runner → Synthetic data: generates data
main.py - Synthetic data → Transaction seeding: seeds transactions
data/synthetic_generator.py - Pipeline runner → Root-cause classifier: diagnoses failures
README.md - Model training → Root-cause classifier: trains model
diagnoser/train.py - Holdout evaluation → Root-cause classifier: evaluates predictions
diagnoser/eval_holdout.py - Pipeline runner → Policy engine: checks actions
README.md - Pipeline runner → Payment-link retry: dispatches payment retry
main.py - Pipeline runner → Mandate retry: dispatches mandate retry
main.py - Payment-link retry → Recovery sequence: delegates recovery
agents/payment_failure_agent.py - Mandate retry → Recovery sequence: delegates recovery
agents/subscription_agent.py - Recovery sequence → Policy engine: evaluates attempt
agents/recovery_base.py - Recovery sequence → Razorpay client: executes retry
README.md - Recovery sequence → Audit trail: logs decisions
agents/recovery_base.py - Pipeline runner → Audit trail: records decisions
README.md - Audit trail → SQLite store: writes records
database/audit_trail.py - Razorpay client → SQLite store: records outcomes
- Pipeline runner → Autopsy reporter: generates explanations
main.py - Autopsy reporter → LLM service: requests prose
agents/autopsy_reporter.py - Autopsy reporter → SQLite store: stores reports
agents/autopsy_reporter.py - Pipeline runner → Recovery metrics: computes results
main.py - Recovery metrics → SQLite store: queries records
metrics.py - Recovery dashboard → Recovery metrics: reads metrics
dashboard/app.py - Recovery dashboard → Precision-recall panel: renders evaluation
dashboard/app.py - Weekly recovery report → Recovery metrics: reads recovery figures
weekly_report.py