rust-kgdb 0.5.4 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/README.md +643 -0
- package/examples/fraud-detection-agent.js +134 -0
- package/examples/hypermind-complete-demo.js +926 -0
- package/examples/underwriting-agent.js +127 -0
- package/package.json +1 -1
|
@@ -628,6 +628,140 @@ async function main() {
|
|
|
628
628
|
console.log(` Duration: ${witness.duration_ms}ms`)
|
|
629
629
|
console.log(` Tools: ${witness.tools_executed.length} executed`)
|
|
630
630
|
console.log()
|
|
631
|
+
|
|
632
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
633
|
+
// PHASE 6: CONVERSATIONAL AGENT DEMONSTRATION
|
|
634
|
+
// This shows how a user would naturally interact with the HyperMind agent
|
|
635
|
+
// ───────────────────────────────────────────────────────────────────────────
|
|
636
|
+
|
|
637
|
+
console.log('═'.repeat(80))
|
|
638
|
+
console.log(' CONVERSATIONAL AGENT DEMONSTRATION')
|
|
639
|
+
console.log(' Natural Language Interaction with HyperMind')
|
|
640
|
+
console.log('═'.repeat(80))
|
|
641
|
+
console.log()
|
|
642
|
+
|
|
643
|
+
// Simulated conversation showing what the agent interaction looks like
|
|
644
|
+
console.log(' ┌────────────────────────────────────────────────────────────────────────┐')
|
|
645
|
+
console.log(' │ USER: "Which claims should I investigate for fraud?" │')
|
|
646
|
+
console.log(' └────────────────────────────────────────────────────────────────────────┘')
|
|
647
|
+
console.log()
|
|
648
|
+
|
|
649
|
+
// Agent reasoning display
|
|
650
|
+
console.log(' Agent Reasoning:')
|
|
651
|
+
console.log(' ─────────────────')
|
|
652
|
+
console.log(' 1. Parsing intent: fraud investigation request')
|
|
653
|
+
console.log(' 2. Required data: high-risk claimants, network patterns, rule violations')
|
|
654
|
+
console.log(' 3. Tool selection: kg.sparql.query, kg.graphframe.triangles, kg.datalog.infer')
|
|
655
|
+
console.log(' 4. Type checking: all tools compatible (Graph -> Analysis -> Inference)')
|
|
656
|
+
console.log()
|
|
657
|
+
|
|
658
|
+
// Synthesized response
|
|
659
|
+
console.log(' ┌────────────────────────────────────────────────────────────────────────┐')
|
|
660
|
+
console.log(' │ AGENT RESPONSE: │')
|
|
661
|
+
console.log(' └────────────────────────────────────────────────────────────────────────┘')
|
|
662
|
+
console.log()
|
|
663
|
+
console.log(` Based on my analysis of ${tripleCount} triples in the fraud knowledge graph,`)
|
|
664
|
+
console.log(' I identified the following priority investigations:')
|
|
665
|
+
console.log()
|
|
666
|
+
|
|
667
|
+
if (riskLevel === 'CRITICAL' || riskLevel === 'HIGH') {
|
|
668
|
+
console.log(' [CRITICAL] PRIORITY 1: POTENTIAL FRAUD RING')
|
|
669
|
+
console.log(' ──────────────────────────────────────────────')
|
|
670
|
+
console.log(' Subjects: John Smith (P001) + Jane Doe (P002)')
|
|
671
|
+
console.log(' Provider: Quick Care Clinic (PROV001)')
|
|
672
|
+
console.log(' Pattern: Triangle network structure detected')
|
|
673
|
+
console.log()
|
|
674
|
+
console.log(' Evidence Chain:')
|
|
675
|
+
console.log(' 1. GraphFrame Analysis: Detected triangle (P001 ↔ P002 ↔ PROV001)')
|
|
676
|
+
console.log(' 2. SPARQL Query: Both claimants have risk scores > 0.7')
|
|
677
|
+
console.log(' 3. Datalog Rule: potential_collusion(?X, ?Y, ?P) matched')
|
|
678
|
+
console.log()
|
|
679
|
+
console.log(' Rule Derivation:')
|
|
680
|
+
console.log(' potential_collusion(P001, P002, PROV001) derived because:')
|
|
681
|
+
console.log(' - claimant(P001) ✓')
|
|
682
|
+
console.log(' - claimant(P002) ✓')
|
|
683
|
+
console.log(' - provider(PROV001) ✓')
|
|
684
|
+
console.log(' - claims_with(P001, PROV001) ✓')
|
|
685
|
+
console.log(' - claims_with(P002, PROV001) ✓')
|
|
686
|
+
console.log(' - knows(P001, P002) ✓')
|
|
687
|
+
console.log()
|
|
688
|
+
console.log(' Confidence: 95% (all rule conditions satisfied)')
|
|
689
|
+
console.log(' Recommendation: Escalate to SIU immediately')
|
|
690
|
+
console.log()
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
if (findings.addressFraud && findings.addressFraud.length > 0) {
|
|
694
|
+
console.log(' [WARNING] PRIORITY 2: ADDRESS FRAUD INDICATOR')
|
|
695
|
+
console.log(' ────────────────────────────────────────────────')
|
|
696
|
+
console.log(' Subjects: P001 and P002 share address ADDR001')
|
|
697
|
+
console.log(' Risk Factor: Both claimants are high-risk (>0.7)')
|
|
698
|
+
console.log(' Pattern: Same address + same provider + know each other')
|
|
699
|
+
console.log()
|
|
700
|
+
console.log(' NICB Guideline: "Shared address among unrelated high-risk')
|
|
701
|
+
console.log(' claimants is a primary fraud indicator"')
|
|
702
|
+
console.log()
|
|
703
|
+
console.log(' Recommendation: Verify address authenticity, check for mail drops')
|
|
704
|
+
console.log()
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// Follow-up demonstration
|
|
708
|
+
console.log(' ┌────────────────────────────────────────────────────────────────────────┐')
|
|
709
|
+
console.log(' │ USER: "Show me the evidence for the collusion detection" │')
|
|
710
|
+
console.log(' └────────────────────────────────────────────────────────────────────────┘')
|
|
711
|
+
console.log()
|
|
712
|
+
console.log(' ┌────────────────────────────────────────────────────────────────────────┐')
|
|
713
|
+
console.log(' │ AGENT RESPONSE: │')
|
|
714
|
+
console.log(' └────────────────────────────────────────────────────────────────────────┘')
|
|
715
|
+
console.log()
|
|
716
|
+
console.log(' Here is the complete evidence chain for the collusion detection:')
|
|
717
|
+
console.log()
|
|
718
|
+
console.log(' DATALOG RULE (from NICB Guidelines):')
|
|
719
|
+
console.log(' ┌────────────────────────────────────────────────────────────────────┐')
|
|
720
|
+
console.log(' │ potential_collusion(?X, ?Y, ?P) :- │')
|
|
721
|
+
console.log(' │ claimant(?X), │')
|
|
722
|
+
console.log(' │ claimant(?Y), │')
|
|
723
|
+
console.log(' │ provider(?P), │')
|
|
724
|
+
console.log(' │ claims_with(?X, ?P), │')
|
|
725
|
+
console.log(' │ claims_with(?Y, ?P), │')
|
|
726
|
+
console.log(' │ knows(?X, ?Y). │')
|
|
727
|
+
console.log(' └────────────────────────────────────────────────────────────────────┘')
|
|
728
|
+
console.log()
|
|
729
|
+
console.log(' MATCHING FACTS FROM KNOWLEDGE GRAPH:')
|
|
730
|
+
console.log(' ins:P001 rdf:type ins:Claimant . ✓ claimant(P001)')
|
|
731
|
+
console.log(' ins:P002 rdf:type ins:Claimant . ✓ claimant(P002)')
|
|
732
|
+
console.log(' ins:PROV001 rdf:type ins:Provider . ✓ provider(PROV001)')
|
|
733
|
+
console.log(' ins:CLM001 ins:provider ins:PROV001 . ✓ claims_with(P001, PROV001)')
|
|
734
|
+
console.log(' ins:CLM002 ins:provider ins:PROV001 . ✓ claims_with(P002, PROV001)')
|
|
735
|
+
console.log(' ins:P001 ins:knows ins:P002 . ✓ knows(P001, P002)')
|
|
736
|
+
console.log()
|
|
737
|
+
console.log(' DERIVED FACT:')
|
|
738
|
+
console.log(' potential_collusion(P001, P002, PROV001)')
|
|
739
|
+
console.log()
|
|
740
|
+
console.log(' AUDIT SIGNATURE:')
|
|
741
|
+
console.log(` Proof Hash: ${witness.proof_hash}`)
|
|
742
|
+
console.log(` Timestamp: ${witness.timestamp}`)
|
|
743
|
+
console.log()
|
|
744
|
+
console.log(' This derivation is 100% deterministic and auditable.')
|
|
745
|
+
console.log(' A regulator can verify this finding by checking the rule')
|
|
746
|
+
console.log(' against the facts in the knowledge graph.')
|
|
747
|
+
console.log()
|
|
748
|
+
|
|
749
|
+
// Key value proposition
|
|
750
|
+
console.log(' ═══════════════════════════════════════════════════════════════════════')
|
|
751
|
+
console.log(' WHY THIS MATTERS:')
|
|
752
|
+
console.log(' ─────────────────')
|
|
753
|
+
console.log(' Unlike ChatGPT or DSPy, this response is NOT a guess.')
|
|
754
|
+
console.log(' Every claim is backed by:')
|
|
755
|
+
console.log(' - Real data from your knowledge graph')
|
|
756
|
+
console.log(' - Deterministic Datalog rules (NICB guidelines)')
|
|
757
|
+
console.log(' - Cryptographic proof hash for audit')
|
|
758
|
+
console.log()
|
|
759
|
+
console.log(' Ask a regulator: "Would you accept this as evidence?"')
|
|
760
|
+
console.log(' HyperMind: YES (full derivation chain)')
|
|
761
|
+
console.log(' ChatGPT: NO (probabilistic hallucination)')
|
|
762
|
+
console.log(' ═══════════════════════════════════════════════════════════════════════')
|
|
763
|
+
console.log()
|
|
764
|
+
|
|
631
765
|
console.log('═'.repeat(80))
|
|
632
766
|
console.log()
|
|
633
767
|
console.log('HyperMind Agent completed successfully.')
|