Changes for page FactHarbor POC1 Architecture Analysis 1.Jan.26
Last modified by Robert Schaub on 2026/02/08 08:12
From version 5.1
edited by Robert Schaub
on 2026/01/02 10:04
on 2026/01/02 10:04
Change comment:
Rollback to version 3.1
To version 1.1
edited by Robert Schaub
on 2026/01/02 09:59
on 2026/01/02 09:59
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,13 +2,14 @@ 1 -= FactHarbor POC1 Architecture Analysis = 2 2 2 += FactHarbor POC1 Architecture Analysis= 3 3 4 + 4 4 **Version:** 2.6.17 5 5 **Analysis Date:** January 2026 6 6 **Document Purpose:** Technical diagrams, gap analysis, and optimization recommendations 7 7 8 ---- -9 +--- 9 9 10 -== 1. AKEL Flow Diagram (with LLM and WebSearch Interactions) ==11 +== 1. AKEL Flow Diagram (with LLM and WebSearch Interactions)== 11 11 12 12 13 13 {{mermaid}} ... ... @@ -91,10 +91,10 @@ 91 91 class UNDERSTAND,DECIDE,FETCHSRC,EXTRACT,VERDICT,REPORT step 92 92 {{/mermaid}} 93 93 94 ---- -95 +--- 95 95 96 96 97 -== 2. ERD Data Model (Current POC1 Implementation) ==98 +== 2. ERD Data Model (Current POC1 Implementation)== 98 98 99 99 100 100 {{mermaid}} ... ... @@ -186,10 +186,10 @@ 186 186 } 187 187 {{/mermaid}} 188 188 189 ---- -190 +--- 190 190 191 191 192 -== 3. Overall Architecture with Interactions ==193 +== 3. Overall Architecture with Interactions== 193 193 194 194 195 195 {{mermaid}} ... ... @@ -285,74 +285,77 @@ 285 285 class ANALYZE_API,JOBS_API,JOB_API,EVENTS_API,RUN_JOB api 286 286 {{/mermaid}} 287 287 288 ---- -289 +--- 289 289 290 290 291 -== 4. Specification vs Implementation Gap Analysis ==292 +== 4. Specification vs Implementation Gap Analysis== 292 292 293 293 294 294 295 -=== 4.1 Data Model Gaps ===296 +=== 4.1 Data Model Gaps=== 296 296 297 297 298 -| Specification Entity | POC1 Status | Gap Description | 299 -|-|-|-| 300 -| **Claim** | ⚠️ Partial | No persistent storage; claims exist only in JSON result. Missing: `status`, `confidence_score`, `risk_score`, `completeness_score`, `version`, `views`, `edit_count` | 301 -| **Evidence** | ⚠️ Partial | Implemented as `ExtractedFact` but lacks: `supports` enum, proper `relevance_score` | 302 -| **Source** | ⚠️ Partial | `FetchedSource` exists but missing: `type` enum, `accuracy_history`, `correction_frequency`, weekly update scheduler | 303 -| **Scenario** | ❌ Missing | Not implemented. Claims are evaluated directly without scenario contexts | 304 -| **Verdict** | ⚠️ Partial | `ClaimVerdict` exists but missing: `likelihood_range`, `uncertainty_factors` array, proper `explanation_summary` | 305 -| **User** | ❌ Missing | No user authentication or role system | 306 -| **Edit** | ❌ Missing | No audit trail for changes | 299 +| Specification Entity | POC1 Status | Gap Description | 300 +|---------------------|-------------|-----------------| 301 +| **Claim** | ⚠️ Partial | No persistent storage; claims exist only in JSON result. Missing: `status`, `confidence_score`, `risk_score`, `completeness_score`, `version`, `views`, `edit_count` | 302 +| **Evidence** | ⚠️ Partial | Implemented as `ExtractedFact` but lacks: `supports` enum, proper `relevance_score` | 303 +| **Source** | ⚠️ Partial | `FetchedSource` exists but missing: `type` enum, `accuracy_history`, `correction_frequency`, weekly update scheduler | 304 +| **Scenario** | ❌ Missing | Not implemented. Claims are evaluated directly without scenario contexts | 305 +| **Verdict** | ⚠️ Partial | `ClaimVerdict` exists but missing: `likelihood_range`, `uncertainty_factors` array, proper `explanation_summary` | 306 +| **User** | ❌ Missing | No user authentication or role system | 307 +| **Edit** | ❌ Missing | No audit trail for changes | 307 307 309 + 308 308 === 4.2 AKEL Component Gaps === 309 309 310 -| Spec Component | POC1 Status | Gap Description | 311 -| |-|-|312 -| **AKEL Orchestrator** | ✅ Implemented | `runAnalysis()` function serves this role | 313 -| **Claim Extractor** | ✅ Implemented | `understandClaim()` with claim role/dependency tracking | 314 -| **Claim Classifier** | ⚠️ Partial | Risk tier (A/B/C) assigned, but no domain classification | 315 -| **Scenario Generator** | ❌ Missing | Claims evaluated without scenario extraction | 316 -| **Evidence Summarizer** | ✅ Implemented | `extractFacts()` function | 317 -| **Contradiction Detector** | ⚠️ Partial | `isContestedClaim` flag exists but no active contradiction search | 318 -| **Quality Gate Validator** | ❌ Missing | No source quality gates, no mandatory checks | 319 -| **Audit Sampling Scheduler** | ❌ Missing | No audit system | 320 -| **Embedding Handler** | ❌ Missing | Not needed for POC | 321 -| **Federation Sync** | ❌ Missing | Not needed for POC | 312 +| Spec Component | POC1 Status | Gap Description | 313 +|----------------|-------------|-----------------| 314 +| **AKEL Orchestrator** | ✅ Implemented | `runAnalysis()` function serves this role | 315 +| **Claim Extractor** | ✅ Implemented | `understandClaim()` with claim role/dependency tracking | 316 +| **Claim Classifier** | ⚠️ Partial | Risk tier (A/B/C) assigned, but no domain classification | 317 +| **Scenario Generator** | ❌ Missing | Claims evaluated without scenario extraction | 318 +| **Evidence Summarizer** | ✅ Implemented | `extractFacts()` function | 319 +| **Contradiction Detector** | ⚠️ Partial | `isContestedClaim` flag exists but no active contradiction search | 320 +| **Quality Gate Validator** | ❌ Missing | No source quality gates, no mandatory checks | 321 +| **Audit Sampling Scheduler** | ❌ Missing | No audit system | 322 +| **Embedding Handler** | ❌ Missing | Not needed for POC | 323 +| **Federation Sync** | ❌ Missing | Not needed for POC | 322 322 323 -=== 4.3 Architecture Gaps === 324 324 326 +=== 4.3 Architecture Gaps=== 325 325 326 -| Spec Requirement | POC1 Status | Gap Description | 327 -| |-|-| 328 -| **Three-Layer Architecture** | ✅ Implemented | Interface (Next.js) → Processing (AKEL) → Data (SQLite) | 329 -| **LLM Abstraction Layer** | ✅ Implemented | AI SDK supports multiple providers with failover | 330 -| **PostgreSQL Primary DB** | ⚠️ Different | Using SQLite for simplicity (acceptable for POC) | 331 -| **Redis Caching** | ❌ Missing | No caching layer | 332 -| **S3 Archival** | ❌ Missing | No long-term storage | 333 -| **Background Jobs** | ❌ Missing | No scheduler for source updates, cache warming | 334 -| **Quality Monitoring** | ⚠️ Partial | LLM call counting exists, but no anomaly detection | 335 335 336 -=== 4.4 Publication & Review Gaps === 329 +| Spec Requirement | POC1 Status | Gap Description | 330 +|------------------|-------------|-----------------| 331 +| **Three-Layer Architecture** | ✅ Implemented | Interface (Next.js) → Processing (AKEL) → Data (SQLite) | 332 +| **LLM Abstraction Layer** | ✅ Implemented | AI SDK supports multiple providers with failover | 333 +| **PostgreSQL Primary DB** | ⚠️ Different | Using SQLite for simplicity (acceptable for POC) | 334 +| **Redis Caching** | ❌ Missing | No caching layer | 335 +| **S3 Archival** | ❌ Missing | No long-term storage | 336 +| **Background Jobs** | ❌ Missing | No scheduler for source updates, cache warming | 337 +| **Quality Monitoring** | ⚠️ Partial | LLM call counting exists, but no anomaly detection | 337 337 338 338 339 -| Spec Feature | POC1 Status | Gap Description | 340 -| |-|-| 341 -| **Risk Tier Publication Rules** | ❌ Missing | All results published immediately regardless of tier | 342 -| **Human Review Queue** | ❌ Missing | No review workflow | 343 -| **AI-Generated Labeling** | ⚠️ Partial | Results show "AI analysis" but no formal labeling system | 344 -| **Audit Rate Sampling** | ❌ Missing | No sampling audits | 340 +=== 4.4 Publication & Review Gaps=== 345 345 346 ----- 347 347 343 +| Spec Feature | POC1 Status | Gap Description | 344 +|--------------|-------------|-----------------| 345 +| **Risk Tier Publication Rules** | ❌ Missing | All results published immediately regardless of tier | 346 +| **Human Review Queue** | ❌ Missing | No review workflow | 347 +| **AI-Generated Labeling** | ⚠️ Partial | Results show "AI analysis" but no formal labeling system | 348 +| **Audit Rate Sampling** | ❌ Missing | No sampling audits | 348 348 349 - == 5. Optimization Recommendations ==350 +--- 350 350 351 351 353 +== 5. Optimization Recommendations== 352 352 353 -=== 5.1 Cost Optimizations === 354 354 355 355 357 +=== 5.1 Cost Optimizations=== 358 + 359 + 356 356 {{mermaid}} 357 357 pie title Current LLM Cost Distribution (Estimated per Analysis) 358 358 "Step 1: Understand" : 15 ... ... @@ -360,17 +360,18 @@ 360 360 "Step 3: Verdicts" : 25 361 361 {{/mermaid}} 362 362 363 -| Optimization | Estimated Savings | Implementation Effort | 364 -| |-||365 -| **Cache claim understanding** | 30-50% on repeated claims | Medium | 366 -| **Use Haiku for fact extraction** | 40% on Step 2 costs | Low (config change) | 367 -| **Batch fact extraction** | 20% fewer API calls | Medium | 368 -| **Skip search for known claims** | 50%+ for cached claims | High (needs claim DB) | 369 -| **Reduce max iterations** | Linear reduction | Low (config change) | 367 +| Optimization | Estimated Savings | Implementation Effort | 368 +|--------------|-------------------|----------------------| 369 +| **Cache claim understanding** | 30-50% on repeated claims | Medium | 370 +| **Use Haiku for fact extraction** | 40% on Step 2 costs | Low (config change) | 371 +| **Batch fact extraction** | 20% fewer API calls | Medium | 372 +| **Skip search for known claims** | 50%+ for cached claims | High (needs claim DB) | 373 +| **Reduce max iterations** | Linear reduction | Low (config change) | 370 370 371 -=== 5.2 Timing Optimizations === 372 372 376 +=== 5.2 Timing Optimizations=== 373 373 378 + 374 374 {{mermaid}} 375 375 gantt 376 376 title Current Analysis Timeline (Typical) ... ... @@ -396,17 +396,18 @@ 396 396 Generate Verdicts :b5, after b4, 10s 397 397 {{/mermaid}} 398 398 399 -| Optimization | Time Savings | Notes | 400 -| ||-|401 -| **Parallel source fetching** | Already implemented | Currently fetches 3 sources in parallel | 402 -| **Streaming LLM responses** | 20-30% perceived | User sees progress faster | 403 -| **Search query batching** | 10-15% | Send multiple queries to search API | 404 -| **Reduce prompt size** | 5-10% per call | Optimize system prompts | 405 -| **Use faster models for extraction** | 30-40% on Step 2 | Claude Haiku vs Sonnet | 404 +| Optimization | Time Savings | Notes | 405 +|--------------|--------------|-------| 406 +| **Parallel source fetching** | Already implemented | Currently fetches 3 sources in parallel | 407 +| **Streaming LLM responses** | 20-30% perceived | User sees progress faster | 408 +| **Search query batching** | 10-15% | Send multiple queries to search API | 409 +| **Reduce prompt size** | 5-10% per call | Optimize system prompts | 410 +| **Use faster models for extraction** | 30-40% on Step 2 | Claude Haiku vs Sonnet | 406 406 407 -=== 5.3 Priority Recommendations === 408 408 413 +=== 5.3 Priority Recommendations=== 409 409 415 + 410 410 1. **HIGH PRIORITY - Implement Claim Caching** 411 411 - Cache claim verdicts by content hash 412 412 - Reduces costs for repeated/similar claims ... ... @@ -422,14 +422,14 @@ 422 422 - Cache search results (1h TTL) 423 423 - Reduces external API calls 424 424 425 ---- -431 +--- 426 426 427 427 428 -== 6. Separated Verdict Architecture Proposal ==434 +== 6. Separated Verdict Architecture Proposal== 429 429 430 430 431 431 432 -=== 6.1 Current Architecture ===438 +=== 6.1 Current Architecture=== 433 433 434 434 435 435 {{mermaid}} ... ... @@ -448,7 +448,7 @@ 448 448 - Article verdict tightly coupled to claim extraction 449 449 450 450 451 -=== 6.2 Proposed Separated Architecture ===457 +=== 6.2 Proposed Separated Architecture=== 452 452 453 453 454 454 {{mermaid}} ... ... @@ -504,26 +504,29 @@ 504 504 {{/mermaid}} 505 505 506 506 507 -=== 6.3 Benefits Analysis ===513 +=== 6.3 Benefits Analysis=== 508 508 509 509 510 -| Benefit | Impact | Rationale | 511 -|-| |-|512 -| **Cost Reduction** | 40-70% for repeated claims | Many articles share common claims (e.g., "COVID vaccines are safe") | 513 -| **Faster Analysis** | 50%+ for cached claims | Skip research + LLM calls for known claims | 514 -| **Consistency** | High | Same claim always gets same verdict (until cache expires) | 515 -| **Freshness Control** | Configurable TTL | Balance consistency vs. new evidence | 516 -| **Scalability** | Linear improvement | More users = higher cache hit rate | 516 +| Benefit | Impact | Rationale | 517 +|---------|--------|-----------| 518 +| **Cost Reduction** | 40-70% for repeated claims | Many articles share common claims (e.g., "COVID vaccines are safe") | 519 +| **Faster Analysis** | 50%+ for cached claims | Skip research + LLM calls for known claims | 520 +| **Consistency** | High | Same claim always gets same verdict (until cache expires) | 521 +| **Freshness Control** | Configurable TTL | Balance consistency vs. new evidence | 522 +| **Scalability** | Linear improvement | More users = higher cache hit rate | 517 517 524 + 518 518 === 6.4 Implementation Considerations === 519 519 520 520 **Claim Hashing Strategy:** 521 -{{code language="typescript"}}function getClaimHash(claim: string): string { 528 +{{code language="typescript"}} 529 +function getClaimHash(claim: string): string { 522 522 // Normalize: lowercase, remove punctuation, stem words 523 523 const normalized = normalize(claim); 524 524 // Hash for cache key 525 525 return crypto.createHash('sha256').update(normalized).digest('hex').slice(0, 16); 526 -}{{/code}} 534 +} 535 +{{/code}} 527 527 528 528 **Cache Invalidation Triggers:** 529 529 - TTL expiration (default 7 days) ... ... @@ -536,7 +536,7 @@ 536 536 - Same claims in different article contexts may yield different article verdicts 537 537 - Example: "Vaccines are safe" + "Vaccines cause autism" → article may be misleading even if first claim is true 538 538 539 -### 6.5 Recommendation ##548 +### 6.5 Recommendation 540 540 541 541 **YES, separating is beneficial** with the following caveats: 542 542 ... ... @@ -552,14 +552,14 @@ 552 552 - Phase 2: Semantic similarity caching (embedding-based) 553 553 - Phase 3: Federated claim sharing across instances 554 554 555 ---- -564 +--- 556 556 557 557 558 -== 7. Summary ==567 +== 7. Summary== 559 559 560 560 561 561 562 -=== Current State ===571 +=== Current State=== 563 563 564 564 - POC1 implements core AKEL pipeline successfully 565 565 - Claim dependency tracking is implemented ... ... @@ -567,7 +567,7 @@ 567 567 - No persistent claim storage or caching 568 568 569 569 570 -=== Key Gaps from Specification ===579 +=== Key Gaps from Specification=== 571 571 572 572 - No scenario extraction 573 573 - No user/role system ... ... @@ -576,7 +576,7 @@ 576 576 - No review queue 577 577 578 578 579 -=== Recommended Next Steps ===588 +=== Recommended Next Steps=== 580 580 581 581 1. Implement claim caching layer 582 582 2. Separate claim vs article verdict generation ... ... @@ -583,3 +583,5 @@ 583 583 3. Add Redis for source/search caching 584 584 4. Implement tiered model selection 585 585 5. Add basic audit logging 595 + 596 +