abinazebinoy commited on
Commit
fa0f8ca
·
1 Parent(s): 54825a7

fix(B-10): remove dead module-level investigate() with 0.3 asset fabrication

Browse files

The original module-level investigate() function was dead code (shadowed by
the class wrapper) but still present and dangerous. It contained:
'total_assets_crore': float(row['assets']) * 0.3
to synthesize a '5 years ago' historical value from current assets.
This manufactured data was fed to the Kalman filter, producing entirely
fake anomaly findings. Dead fabrication code removed entirely.

ai/investigators/affidavit_investigator.py CHANGED
@@ -9,99 +9,8 @@ FOCUS = "affidavit_wealth_trajectory"
9
  WEIGHT = 0.10
10
 
11
 
12
- def investigate(entity_id: str, entity_name: str,
13
- session=None, driver=None) -> dict:
14
- logger.info(f"[{NAME}] Investigating {entity_name}")
15
 
16
- findings = []
17
- positive = []
18
- evidence = []
19
-
20
- history = []
21
-
22
- if session:
23
- try:
24
- rows = session.run(
25
- """
26
- MATCH (p:Politician {id:$id})-[:FILED_AFFIDAVIT]->(a:Affidavit)
27
- RETURN a.year AS year,
28
- a.total_assets_crore AS total,
29
- a.movable_assets_crore AS movable,
30
- a.properties AS properties
31
- ORDER BY a.year
32
- """,
33
- id=entity_id
34
- ).data()
35
- history = [
36
- {
37
- "year": r["year"],
38
- "total_assets_crore": r.get("total", 0),
39
- "movable_assets_crore": r.get("movable", 0),
40
- "properties": r.get("properties") or {},
41
- }
42
- for r in rows if r.get("year")
43
- ]
44
-
45
- if not history:
46
- row = session.run(
47
- """
48
- MATCH (p:Politician {id:$id})
49
- RETURN p.total_assets_crore AS assets, p.year AS year
50
- """,
51
- id=entity_id
52
- ).single()
53
- if row and row.get("assets"):
54
- history = [
55
- {"year": row.get("year", 2024) - 5,
56
- "total_assets_crore": float(row["assets"]) * 0.3,
57
- "movable_assets_crore": 0.0, "properties": {}},
58
- {"year": row.get("year", 2024),
59
- "total_assets_crore": float(row["assets"]),
60
- "movable_assets_crore": 0.0, "properties": {}},
61
- ]
62
- except Exception as e:
63
- logger.warning(f"[{NAME}] Session query failed: {e}")
64
-
65
- if len(history) >= 2:
66
- from ai.forensics.affidavit_analyzer import AffidavitAnalyzer
67
- analyzer = AffidavitAnalyzer()
68
- result = analyzer.analyze(entity_id, history, "MP")
69
-
70
- findings.extend(result.get("findings", []))
71
- positive.extend(result.get("positive", []))
72
-
73
- evidence.append({
74
- "institution": "Election Commission of India",
75
- "document": "Candidate Affidavit (Form 26)",
76
- "url": "https://myneta.info",
77
- "method": "Kalman filter trajectory analysis",
78
- "years": result.get("years_covered", []),
79
- })
80
- else:
81
- positive.append(
82
- "Insufficient affidavit history for trajectory analysis "
83
- "(fewer than 2 election cycles available)."
84
- )
85
-
86
- logger.success(
87
- f"[{NAME}] Complete: {len(findings)} findings"
88
- )
89
-
90
- return {
91
- "investigator": NAME,
92
- "focus": FOCUS,
93
- "weight": WEIGHT,
94
- "findings": findings,
95
- "positive": positive,
96
- "evidence": evidence,
97
- "investigated_at": datetime.now().isoformat(),
98
- }
99
-
100
-
101
- # BUG-C1 FIX: this file used module-level functions, not a class.
102
- # __init__.py tries: from affidavit_investigator import AffidavitInvestigator
103
- # which raises ImportError, crashing ALL_INVESTIGATORS and the entire
104
- # /investigate endpoint. Added class wrapper to match the expected interface.
105
  class AffidavitInvestigator:
106
  NAME = NAME
107
  FOCUS = FOCUS
 
9
  WEIGHT = 0.10
10
 
11
 
 
 
 
12
 
13
+ # AffidavitInvestigator: single class, real DB queries only.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  class AffidavitInvestigator:
15
  NAME = NAME
16
  FOCUS = FOCUS