snapkitty
agents
python
File size: 2,911 Bytes
662ceed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import type { MisconceptionResult } from '../types.js';

interface MisconceptionPattern {
  type: string;
  pattern: RegExp;
  severity: 'critical' | 'high' | 'medium' | 'low';
  reason: string;
}

const PATTERNS: MisconceptionPattern[] = [
  {
    type: 'correlation_causation',
    pattern: /both.*therefore|similar.*so|like.*hence|mirror.*thus/i,
    severity: 'high',
    reason: 'Correlation or similarity does not imply causation or equivalence'
  },
  {
    type: 'authority_evidence',
    pattern: /einstein|newton|hawking|feynman|bohr|heisenberg|schrodinger/i,
    severity: 'medium',
    reason: 'Scientific authority does not constitute evidence for theological claims'
  },
  {
    type: 'analogy_proof',
    pattern: /analogy|metaphor|like|similar to|mirrors|parallel/i,
    severity: 'high',
    reason: 'Analogy illustrates but does not prove'
  },
  {
    type: 'confidence_correctness',
    pattern: /clearly|obviously|undoubtedly|certainly|definitely|proves|demonstrates/i,
    severity: 'medium',
    reason: 'Confidence does not equal correctness'
  },
  {
    type: 'false_dilemma',
    pattern: /either.*or|only two|no other|must be/i,
    severity: 'medium',
    reason: 'Reality may have more options than presented'
  },
  {
    type: 'appeal_nature',
    pattern: /natural|innate|instinctive|human nature/i,
    severity: 'low',
    reason: 'Naturalness does not imply truth'
  },
  {
    type: 'cherry_picking',
    pattern: /ignoring|overlooking|dismissing|excluding/i,
    severity: 'high',
    reason: 'Selective evidence weakens the claim'
  },
  {
    type: 'popularity_truth',
    pattern: /most people|everyone|widely believed|common knowledge/i,
    severity: 'low',
    reason: 'Popularity does not equal truth'
  }
];

function checkPatterns(text: string): MisconceptionResult[] {
  const results: MisconceptionResult[] = [];
  for (const p of PATTERNS) {
    if (p.pattern.test(text)) {
      results.push({
        claim: text.slice(0, 100),
        classification: p.type,
        severity: p.severity,
        reason: p.reason
      });
    }
  }
  return results;
}

export async function generateMisconceptions(enkiClaim: string, enkiSynthesis: string): Promise<MisconceptionResult[]> {
  const text = enkiClaim + ' ' + enkiSynthesis;
  const results = checkPatterns(text);

  if (results.length === 0 && enkiSynthesis.length > 50) {
    const hasBoth = /both/i.test(enkiSynthesis);
    const hasGap = /but|however|unlike|differs|gap/i.test(enkiSynthesis);
    if (hasBoth && hasGap) {
      results.push({
        claim: enkiSynthesis.slice(0, 100),
        classification: 'analogy_proof',
        severity: 'medium',
        reason: 'Synthesis identifies both similarity and gap — verify analogy is structural, not superficial'
      });
    }
  }

  return results;
}