Assure Consistent Workflow and Codify Docs — Fact-Check Pipeline & Source Catalog
Introduces a three-step LLM-powered fact-check pipeline (extract → verify → correct) and a per-section comprehensive source catalog. The mechanical-only fact-checker is upgraded to use Perplexity Sonar Pro for independent claim verification and Claude for surgical corrections.
Changelog - 2026-03-23_02
Assure Consistent Workflow and Codify Docs — Fact-Check Pipeline & Source Catalog
Introduces a three-step LLM-powered fact-check pipeline (extract → verify → correct) and a per-section comprehensive source catalog. The mechanical-only fact-checker is upgraded to use Perplexity Sonar Pro for independent claim verification and Claude for surgical corrections.
Why
The existing fact_checker.py used regex to find claims and string matching to check if they appeared in research data. It could detect "this sentence mentions $50M" but couldn't assess whether the source actually said $50M, whether the number was about the right company, or whether a better source exists. Claims were flagged but never acted on — the 4-fact-check.json artifact was a dead end.
Investment analysts need:
Verified claims — not just "has a citation" but "citation supports the claim"
Corrections with traceability — old value → finding → new value → new source
Complete source lists — every source the pipeline found, including excluded ones
What Changed
New Agent: fact_verifier.py (LLM-powered verification)
Reads 4-fact-check.json, filters to suspicious/critical claims, sends batches to Perplexity Sonar Pro for independent verification.
Pipeline: fact_check → fact_verify → fact_correct
↑
Perplexity Sonar Pro
"Is this claim accurate?"Each claim gets tagged:
| Result | Meaning |
confirmed | Claim matches independent sources |
contradicted | Sources say something materially different |
corrected | Partially right, needs adjustment |
unverifiable | Cannot find reliable sources to confirm or deny |
Output: 4-fact-check-verified.json + 4-fact-check-verified.md
New Agent: fact_corrector.py (surgical section updates)
Reads verified results, groups corrections by section, uses Claude to update specific sentences. Does NOT rewrite sections wholesale.
# Safety guard: reject if corrected content is wildly different length
len_ratio = len(corrected_content) / len(original_content)
if len_ratio < 0.5 or len_ratio > 2.0:
print("Correction produced suspicious length change, skipping")Output: 4-corrections-log.json + 4-corrections-log.md
Traceability chain:
claim found → checked for accuracy → found better source →
updated claim with citation → logged change with before/afterNew Agent: source_cataloger.py (per-section source lists)
Compiles comprehensive source lists in 3-source-catalog/ by reading all pipeline artifacts:
1-research/*.md → "found in research"
2-sections/*.md → "included in final draft"
source-validation-log-* → "excluded-invalid", "hallucinated"
4-fact-check-verified.* → "verified by LLM"
4-corrections-log.* → "added by correction"Each source is tagged with a status:
| Status | Description |
| Included | In the final memo with inline citation |
| Added by Correction | Found by LLM to fix an inaccurate claim |
| Valid but Not Cited | Passed URL validation but wasn't used |
| Found in Research | Discovered during research phase |
| Excluded — Uncertain | 403/401/timeout (may be behind paywall) |
| Excluded — Invalid | URL returned 404 |
| Hallucinated | Fabricated URL detected |
Output: 3-source-catalog/{section}-Complete-Source-List.md + README.md
Modified: remove_invalid_sources.py (validation logging)
The cleanup gate now persists full URL validation results as source-validation-log-cleanup_sections.json. Previously, validation details were only printed to console and lost.
Updated Pipeline Sequence
... → validate_citations →
fact_check (regex extraction) →
fact_verify (Perplexity Sonar Pro) →
fact_correct (Claude surgical fixes) →
source_catalog (compile source lists) →
validate → scorecard → ...Canonical Orchestration Document
Created context-v/reminders/Ideal-Orchestration-Agent-Workflow.md as the single source of truth for agent execution order. Documents all 31 nodes across 9 phases, known bug patterns, and the golden rules for edge ordering.
Verification (Metabologic v0.2.3 → v0.2.4)
| Metric | v0.2.3 (before) | v0.2.4 (after) |
| Fact-check score | 0% (entity mismatch) | 66% (25/38 verified) |
| Claims sent to Perplexity | N/A | 12 |
| Confirmed by LLM | N/A | 2 |
| Contradicted by LLM | N/A | 2 |
| Corrections applied | N/A | 2 sections modified |
| Source catalog | N/A | 37 sources / 7 sections |
| Artifact files produced | 2 (json + md) | 8 (fact-check, verified, corrections, source catalog) |
Files Changed
| File | Change |
src/agents/fact_verifier.py | Created — LLM-powered claim verification via Perplexity |
src/agents/fact_corrector.py | Created — surgical section correction with traceability |
src/agents/source_cataloger.py | Created — per-section comprehensive source lists |
src/agents/remove_invalid_sources.py | Added extract_citation_details(), save_source_validation_log() |
src/workflow.py | Added 4 new nodes + edges in pipeline sequence |
context-v/reminders/Ideal-Orchestration-Agent-Workflow.md | Created — canonical workflow reference |
context-v/issue-resolution/Preventing-Hallucinations-in-Memo-Generation.md | Updated status: Tier 2+3 implemented |