""" main.py Unified Command-Line Interface (CLI) for the HIFFI Multi-Platform Intelligence Pipeline. Orchestrates batch ingestion, provenance audit, anomaly detection, QA tests, review queue, and reporting. """ import argparse import sys from pathlib import Path PROJECT_ROOT = Path(__file__).resolve().parent if str(PROJECT_ROOT) not in sys.path: sys.path.insert(0, str(PROJECT_ROOT)) import pytest from core.health_detector import main as run_health_audit from pipeline.batch_500_runner import main as run_batch_pipeline from reports.provenance_summary import main as run_provenance_summary def run_pipeline(): print("\n[HIFFI CLI] Executing Batch Multi-Platform Signal Ingestion & Scoring...") run_batch_pipeline() def run_audit(): print("\n[HIFFI CLI] Executing Automated Pipeline Health & Anomaly Detector...") run_health_audit() def run_tests(): print("\n[HIFFI CLI] Running QA Governance Test Suite via Pytest...") test_file = PROJECT_ROOT / "test_multiplatform_ranking.py" retcode = pytest.main(["-v", str(test_file)]) if retcode != 0: print("\n[HIFFI CLI] QA Governance Test Suite FAILED.") sys.exit(retcode) def run_report(): print("\n[HIFFI CLI] Generating Executive Provenance Report...") run_provenance_summary() def run_review(apply_mode: bool = False, include_unmatched: bool = False): print("\n[HIFFI CLI] Managing Instagram Candidate Review Queue...") from pipeline.export_review_queue import apply_decisions, export_queue if apply_mode: apply_decisions() else: export_queue(include_unmatched=include_unmatched) def run_all(): print("=" * 80) print("HIFFI PIPELINE: EXECUTING FULL END-TO-END VALIDATION & REPORTING") print("=" * 80) run_pipeline() run_audit() run_tests() run_report() def main(): parser = argparse.ArgumentParser( description="HIFFI 500-Artist Multi-Platform Pipeline CLI Engine" ) parser.add_argument( "action", choices=["run", "audit", "test", "report", "review", "all"], help="Pipeline command to execute: 'run', 'audit', 'test', 'report', 'review', or 'all'." ) parser.add_argument( "--apply", action="store_true", help="Apply review queue decisions to handle_overrides.json (used with 'review')" ) parser.add_argument( "--include-unmatched", action="store_true", help="Include records with missing candidate handles in review export" ) args = parser.parse_args() if args.action == "run": run_pipeline() elif args.action == "audit": run_audit() elif args.action == "test": run_tests() elif args.action == "report": run_report() elif args.action == "review": run_review(apply_mode=args.apply, include_unmatched=args.include_unmatched) elif args.action == "all": run_all() if __name__ == "__main__": main()