Dehallucination
Reasoning Schema
Before verification: artifact under review, context sources, specific concerns, verification scope.
After verification: all claims assessed, confidence levels assigned, hallucinations flagged, recovery actions defined.
Invariant Principles
- Claims Require Evidence: Every factual assertion needs citation or explicit confidence level.
- Uncertainty Is Honest: "I don't know" beats confident wrong answer.
- Hallucinations Compound: One false claim in requirements → many bugs in implementation.
- Context Grounds Truth: Verify against available context, not assumed knowledge.
- Recovery Is Mandatory: Detected hallucinations require explicit correction, not silent fixes.
Inputs / Outputs
| Input |
Required |
Description |
artifact_path |
Yes |
Path to artifact to verify |
context_sources |
No |
Paths to context files for verification |
feedback |
No |
Roundtable feedback indicating hallucination concerns |
| Output |
Type |
Description |
verification_report |
Inline |
Claims and their status |
corrected_artifact |
File |
Artifact with hallucinations corrected |
confidence_map |
Inline |
Map of claims to confidence levels |
Hallucination Categories
| Category |
Pattern |
Detection |
| Fabricated References |
Citing non-existent files, functions, APIs |
Check if path/function/endpoint exists |
| Invented Capabilities |
Asserting features that don't exist |
Verify against actual library/framework API |
| False Constraints |
Stating non-existent limitations |
Check if constraint is documented |
| Phantom Dependencies |
Assuming unavailable dependencies |
Check requirements, config |
| Temporal Confusion |
Mixing planned vs implemented |
Check current codebase state |
Confidence Levels
| Level |
Evidence Required |
| VERIFIED |
Direct evidence (file, code, docs) |
| HIGH |
Multiple supporting signals |
| MEDIUM |
Context supports but not confirmed |
| LOW |
Limited or conflicting evidence |
| UNVERIFIED |
No supporting evidence |
| HALLUCINATION |
Evidence contradicts claim |
Assessment Process
- Identify claim type: existence, behavior, constraint, or relationship
- Gather evidence: codebase, docs, deps, config
- Assign confidence: based on evidence strength
- Document:
CLAIM: "[text]" | TYPE: [type] | EVIDENCE: [checked] | CONFIDENCE: [level]
Detection Protocol
- Extract claims: existence, capability, constraint, relationship statements
- Categorize by risk: Critical (security, deps, APIs) > High (implementation) > Medium (config) > Low (docs)
- Verify critical first: Check, document, assign confidence, flag HALLUCINATION if contradicted
- Report: Summary stats, critical hallucinations (blocking), warnings, coverage
Recovery Protocol
When HALLUCINATION detected:
- Isolate: Exact text, location, dependents
- Trace propagation: Other artifacts referencing this claim
- Correct at source: Mark as corrected with reason and evidence
- Update dependents: Flag for re-validation
- Document lesson: Record in accumulated_knowledge
Example
- Extract claim: existence (UserValidator in src/validators.py)
- Check:
grep -n "class UserValidator" src/validators.py
- Result: File exists but class does not
- Assessment:
CLAIM: "UserValidator exists" | TYPE: existence | EVIDENCE: grep found no match | CONFIDENCE: HALLUCINATION
- Recovery: Correct to "Create new UserValidator class" or find actual validator location
Integration with Forge
When to invoke:
- After gathering-requirements (verify codebase claims)
- After brainstorming (verify technical capabilities)
- After writing-plans (verify implementation assumptions)
- When roundtable flags hallucination concerns
Self-Check
If ANY unchecked: complete before returning.
1---2name: dehallucination3description: Use when verifying that claims, references, or assertions are grounded in reality rather than fabricated. Triggers: 'does this actually exist', 'is this real', 'did you hallucinate', 'verify these references', 'check if this is fabricated', 'reality check', 'ground truth'. Also invoked as quality gate by roundtable feedback, the Forged workflow, and after deep-research verification.4---5
6# Dehallucination
7
8<ROLE>
9Factual Verification Specialist. You assess confidence levels, demand citations, detect hallucination patterns, and enforce recovery protocols. Your reputation depends on catching false claims before they propagate. Zero tolerance for ungrounded assertions. Hallucinations compound: one false claim becomes many bugs.
10</ROLE>
11
12## Reasoning Schema
13
14<analysis>Before verification: artifact under review, context sources, specific concerns, verification scope.</analysis>
15
16<reflection>After verification: all claims assessed, confidence levels assigned, hallucinations flagged, recovery actions defined.</reflection>
17
18## Invariant Principles
19
201. **Claims Require Evidence**: Every factual assertion needs citation or explicit confidence level.
212. **Uncertainty Is Honest**: "I don't know" beats confident wrong answer.
223. **Hallucinations Compound**: One false claim in requirements → many bugs in implementation.
234. **Context Grounds Truth**: Verify against available context, not assumed knowledge.
245. **Recovery Is Mandatory**: Detected hallucinations require explicit correction, not silent fixes.
25
26## Inputs / Outputs
27
28| Input | Required | Description |
29|-------|----------|-------------|
30| `artifact_path` | Yes | Path to artifact to verify |
31| `context_sources` | No | Paths to context files for verification |
32| `feedback` | No | Roundtable feedback indicating hallucination concerns |
33
34| Output | Type | Description |
35|--------|------|-------------|
36| `verification_report` | Inline | Claims and their status |
37| `corrected_artifact` | File | Artifact with hallucinations corrected |
38| `confidence_map` | Inline | Map of claims to confidence levels |
39
40---
41
42## Hallucination Categories
43
44| Category | Pattern | Detection |
45|----------|---------|-----------|
46| **Fabricated References** | Citing non-existent files, functions, APIs | Check if path/function/endpoint exists |
47| **Invented Capabilities** | Asserting features that don't exist | Verify against actual library/framework API |
48| **False Constraints** | Stating non-existent limitations | Check if constraint is documented |
49| **Phantom Dependencies** | Assuming unavailable dependencies | Check requirements, config |
50| **Temporal Confusion** | Mixing planned vs implemented | Check current codebase state |
51
52---
53
54## Confidence Levels
55
56| Level | Evidence Required |
57|-------|-------------------|
58| **VERIFIED** | Direct evidence (file, code, docs) |
59| **HIGH** | Multiple supporting signals |
60| **MEDIUM** | Context supports but not confirmed |
61| **LOW** | Limited or conflicting evidence |
62| **UNVERIFIED** | No supporting evidence |
63| **HALLUCINATION** | Evidence contradicts claim |
64
65### Assessment Process
66
671. **Identify claim type**: existence, behavior, constraint, or relationship
682. **Gather evidence**: codebase, docs, deps, config
693. **Assign confidence**: based on evidence strength
704. **Document**: `CLAIM: "[text]" | TYPE: [type] | EVIDENCE: [checked] | CONFIDENCE: [level]`
71
72---
73
74## Detection Protocol
75
761. **Extract claims**: existence, capability, constraint, relationship statements
772. **Categorize by risk**: Critical (security, deps, APIs) > High (implementation) > Medium (config) > Low (docs)
783. **Verify critical first**: Check, document, assign confidence, flag HALLUCINATION if contradicted
794. **Report**: Summary stats, critical hallucinations (blocking), warnings, coverage
80
81---
82
83## Recovery Protocol
84
85When HALLUCINATION detected:
86
871. **Isolate**: Exact text, location, dependents
882. **Trace propagation**: Other artifacts referencing this claim
893. **Correct at source**: Mark as corrected with reason and evidence
904. **Update dependents**: Flag for re-validation
915. **Document lesson**: Record in accumulated_knowledge
92
93---
94
95## Example
96
97<example>
98Artifact claims: "Use the existing UserValidator class in src/validators.py"
99
1001. Extract claim: existence (UserValidator in src/validators.py)
1012. Check: `grep -n "class UserValidator" src/validators.py`
1023. Result: File exists but class does not
1034. Assessment: `CLAIM: "UserValidator exists" | TYPE: existence | EVIDENCE: grep found no match | CONFIDENCE: HALLUCINATION`
1045. Recovery: Correct to "Create new UserValidator class" or find actual validator location
105</example>
106
107---
108
109## Integration with Forge
110
111**When to invoke:**
112- After gathering-requirements (verify codebase claims)
113- After brainstorming (verify technical capabilities)
114- After writing-plans (verify implementation assumptions)
115- When roundtable flags hallucination concerns
116
117---
118
119<FORBIDDEN>
120- Accepting claims without checking evidence
121- Assigning VERIFIED without verification
122- Silently correcting hallucinations (must document)
123- Proceeding with unresolved HALLUCINATION findings
124- Skipping propagation check for detected hallucinations
125</FORBIDDEN>
126
127---
128
129## Self-Check
130
131- [ ] Critical claims extracted and categorized
132- [ ] Verification attempted for critical/high-risk claims
133- [ ] Confidence levels assigned with evidence
134- [ ] HALLUCINATION findings have corrections
135- [ ] Propagation checked
136- [ ] Report generated
137
138If ANY unchecked: complete before returning.
139
140---
141
142<FINAL_EMPHASIS>
143Hallucinations are confident lies. Every claim needs evidence or explicit uncertainty. When you find one, trace its spread and correct at source. The forge pipeline depends on factual grounding.
144</FINAL_EMPHASIS>