mcp_fact_graph library
MCP Fact Graph - Knowledge representation with 4-layer architecture.
Layers:
- L0: Evidence Layer (ingestion, extraction)
- L1: FactGraph Layer (candidates, entities, events, views)
- L2: ContextOps Layer (context bundles, summaries, claims)
- L3: SkillOps Layer (patterns, skills, rubrics, evaluation)
Classes
- AggregateResult
- Aggregation result.
- Artifact
- Artifact represents a generated output from report/view operations.
- ArtifactFormat
- Common artifact formats.
- AssetPortAdapter
-
Implements
bundle.AssetPorton top ofArtifactStoragePort. - AuditEntry
- Audit entry for tracking candidate changes. Reference: Design Section 2.3 - AuditEntry
- Automation
- Automation defines scheduled or triggered actions.
- BundleBudget
- BundleBudget defines constraints for context generation.
- CachedGraphStorage
- Cached graph storage wrapper.
- Candidate
- Candidate represents an assembled fact/event pending confirmation.
- CandidateDeduplicator
- Content-hash deduplicator for candidate records.
- CandidateField
- A field in a candidate with value and confidence.
- CandidatesPortAdapter
-
Implements
bundle.CandidatesPorton top ofFactGraphServiceandCandidateStoragePort. - ClaimFeatures
- Features extracted from a claim for pattern mining. Reference: Design Section 2.15.3.2 - ClaimFeatures.
- ClaimSignal
- ClaimSignal represents a signal from claim validation for pattern mining.
- ClaimsPortAdapter
-
Implements
bundle.ClaimsPorton top ofContextServiceandContextStoragePort. - Classification
- Classification represents operational categorization applied to targets.
- ClassifierMemory
- ClassifierMemory stores successful classification decisions for pattern matching.
- ComputationMeta
- Computation metadata.
- ConfirmationResult
- Result of confirming a candidate.
- ConflictReport
- Report describing the detected conflict.
- ConsistencyChecker
- Detects duplicate factId and triple conflicts before a write.
- ContextBundlePortAdapter
-
Implements
bundle.ContextBundlePorton top ofContextService. - ContextHasher
- Helper for generating context hash.
- ContextService
- Service for L2 ContextOps Layer operations.
- DisambiguationDecision
- DisambiguationDecision stores explicit user decisions for future automatic resolution.
- EntitiesPortAdapter
-
Implements
bundle.EntitiesPorton top ofFactGraphService+EntityStoragePort+RelationStoragePort. - Entity
- Entity represents a resolved real-world object in the fact graph.
- EntityLink
- Entity link for candidate. Reference: Design Section 2.3 - EntityLink
- EvaluationInput
- Typed evaluation input snapshot. Reference: Design Section 2.16.5 - EvaluationInput.
- EvaluationOutput
- Typed evaluation output snapshot. Reference: Design Section 2.16.5 - EvaluationOutput.
- EvaluationRun
- EvaluationRun represents a deterministic evaluation execution.
- Evidence
- Evidence represents the original, immutable input data.
- EvidencePortAdapter
-
Implements
bundle.EvidencePortwith heuristic fallbacks. - EvidenceReference
- Reference to evidence used in verification.
- EvidenceService
- Service for L0 Evidence Layer operations.
- ExtractionRule
- ExtractionRule stores patterns for extracting fields from evidence without LLM.
- ExtractionValidator
- ExtractionValidator defines validation rules for extracted facts.
- Fact
- Fact represents a confirmed fact in the fact graph.
- FactCluster
- FactCluster groups multiple Facts that represent the same real-world occurrence.
- FactClusterAuditEntry
- Audit entry for cluster operations.
- FactEdge
- An edge connecting two nodes in the fact graph.
- FactGraph
- A graph structure for storing and querying facts.
- FactGraphRuntime
-
Phase 2 composition root for
mcp_fact_graph. - FactGraphService
- Service for L1 FactGraph Layer operations.
- FactNode
- A node in the fact graph representing a piece of knowledge.
- FactPolicy
- FactPolicy defines rules for classification, evaluation, and settlement.
- FactSource
- Source information for a fact.
- FactsPortAdapter
-
Implements the capability port
bundle.FactsPorton top ofFactGraphServiceandFactStoragePort. - FeatureVector
- Feature vector for classification matching.
- Finding
- Detailed finding from evaluation. Reference: Design Section 2.16.5 - Finding.
- Fragment
- Fragment represents an extracted piece of data from evidence.
- GateCheck
- Record of a quality gate check.
- GenerationContext
- Context for artifact generation (for reproducibility).
- GraphQuery
- A fluent query builder for fact graphs.
- GraphStorage
- Abstract interface for graph storage.
- IdempotencyKeyStrategy
- Idempotency key generation strategies.
- IdempotencyRecord
- IdempotencyRecord prevents duplicate execution of operations.
- IndexPortAdapter
-
Implements
bundle.IndexPortwith an in-memory registry. - InternalContextBundle
- InternalContextBundle represents an internal context bundle for LLM operations.
- LLMCallLog
- LLMCallLog tracks LLM API calls for optimization and cost analysis.
- LLMCallPurpose
- LLM call purposes.
- LLMCostAnalytics
- LLM cost analytics helper.
- LogEntry
- Log entry for a run.
- MemoryGraphStorage
- In-memory graph storage.
- OpenQuestion
- OpenQuestion represents an unresolved item requiring attention.
- PathResult
- Path result for graph traversal.
- Pattern
- Pattern represents a discovered recurring pattern.
- PatternMatch
- Pattern match result.
- PatternMiner
- L0 pattern miner for the FactGraph layer.
- PatternsPortAdapter
-
Implements
bundle.PatternsPorton top ofSkillOpsStoragePort. - Period
- Simple period for evaluation time range. Reference: Design Section 2.16.5 - Period.
- PolicyRule
- Rule within a policy.
- QualityGate
- QualityGate defines a verification checkpoint for skill execution.
- QueryFilter
- Query filter types.
-
QueryResult<
T> - Result of a graph query with pagination info.
- QuerySort
- Sort specification.
- Relation
- Relation represents connections between entities.
- RelationTypes
- Common relation types.
- ResponseValidation
- ResponseValidation represents the result of validating an LLM response.
- RetrievalPortAdapter
-
Implements
bundle.RetrievalPorton top ofFactGraphService. - RetryPolicy
- Retry policy configuration.
- Rubric
- Rubric represents evaluation criteria for skills.
- RubricDimension
- Evaluation dimension within a rubric. Reference: Design Section 2.16.4 - RubricDimension with measurementMethod.
- Run
- Run represents an execution log of automation with full reproducibility.
- RunInput
- Complete input snapshot for reproducibility.
- RunOutput
- Complete output snapshot for audit.
- RunsPortAdapter
-
Implements
bundle.RunsPorton top ofRunStoragePort. - ScheduleMeta
- Schedule metadata for scheduled triggers.
- ScoreLevel
- Score level definition. Reference: Design Section 2.16.4 - score range with min/max.
- Skill
- Skill represents an executable capability with proceduralized steps.
- SkillExecutionResult
- Skill execution result.
- SkillOpsService
- Service for L3 SkillOps Layer operations.
- SkillRun
- SkillRun represents a single execution of a skill.
- SkillStep
- SkillStep defines a single step in a skill procedure.
- SourceInfo
- Describes where a piece of evidence came from.
- StepExecution
- Record of a single step execution.
- SummariesPortAdapter
-
Implements
bundle.SummariesPorton top ofContextStoragePort. - SummaryNode
- SummaryNode represents a cumulative summary stored as a graph node.
- SummaryPeriod
- Simple period for summary time range.
- SummaryScheduler
- Periodic driver for stale-summary refresh.
- SummaryScope
- Structured summary scope. Reference: Design Section 2.15.1 - SummaryScope
- UnresolvedIssue
- An unresolved issue preventing candidate confirmation.
- ValidationContext
- Context in which a claim was validated. Reference: Design Section 2.15.3.1 - ValidationContext.
- ValidationIssue
- A single validation issue found during response validation.
- ValidationOutcome
- Outcome details from claim validation. Reference: Design Section 2.15.3.1 - ValidationOutcome (class, not enum).
- VerifiableClaim
- VerifiableClaim represents an assertion to be verified against the fact graph.
- VerificationResult
- Verification result.
- VersionedGraphStorage
- Graph storage with versioning support.
- View
- View represents an aggregated computation over events/facts.
- ViewPeriod
- View period (simplified, aligned with Period from mcp_bundle).
Enums
- ArtifactType
- Type of artifact.
- AutomationTriggerType
- Type of automation trigger.
- CandidateStatus
- Candidate status. Reference: Design Section 2.3 - open | qualifying | ready | confirmed | rejected | promoted | orphaned | merged
- ClaimSignalType
- Type of claim signal.
- ClaimStatus
- Claim status (aligned with ClaimStatus from mcp_bundle). Reference: Design Section 2.15.3
- ClaimType
- Claim type (aligned with ClaimType from mcp_bundle). Reference: Design Section 2.15.3
- ClassificationStatus
- Status of a classification.
- ConflictKind
- Conflict classification returned by ConsistencyChecker.check.
- DecisionType
- Type of disambiguation decision.
- EdgeType
- Types of edges in the fact graph. Reference: 03-data-model-specification.md Section 2.17
- EntityStatus
- Entity status.
- EvaluationStatus
- Evaluation status. Reference: Design Section 2.16.5 - running | completed | failed
- EvidenceRelation
- Evidence relation to claim.
- EvidenceSourceType
- Types of evidence sources. Reference: Design Section 2.2 - text | image | file | message | api
- EvidenceStatus
- Evidence processing status.
- ExtractorType
- Extractor types for fragment extraction. Reference: Design Section 2.2 - ExtractorType: rule | ocr | llm | manual
- FactClusterStatus
- Status of a fact cluster.
- FactStatus
- Fact status.
- FindingType
- Finding types. Reference: Design Section 2.16.5.
- FragmentStatus
- Fragment status. Reference: Design Section 2.5 - proposed | confirmed | rejected
- GateAction
- Actions for quality gate failures.
- IdempotencyStatus
- Status of an idempotency record.
- IssueSeverity
- Severity of validation issues.
- IssueType
- Types of unresolved issues.
- LinkStatus
- Link status.
- MeasurementType
- Measurement types for dimensions. Reference: Design Section 2.16.4
- MemorySource
- Source of the classification memory.
- NodeType
- Types of nodes in the fact graph.
- PatternScope
- Pattern scope levels. Reference: Design Section 2.16.1 - person | team | project | global
- PatternStatus
- Pattern status. Reference: Design Section 2.16.1 - observed | proposed | confirmed | rejected | merged | codified | deprecated | archived
- PolicyType
- Type of policy.
- RelationStatus
- Status of a relation.
- ResolutionState
- Resolution state for candidates. Reference: Design Section 2.3 - Status vs ResolutionState Matrix
- RubricStatus
- Rubric status. Reference: Design Section 2.16.4 - draft | active | deprecated
- RuleStatus
- Status of an extraction rule.
- RuleType
- Type of extraction rule.
- RunStatus
- Status of a run.
- SkillRunStatus
- Status of a skill run.
- SkillStatus
- Skill status. Reference: Design Section 2.16.2 - draft | testing | testFail | active | published | suspended | deprecated
- SourceType
- Types of fact sources.
- StepStatus
- Status of an individual step.
- SummaryStatus
- Summary status. Reference: Design Section 2.15.1 - created | active | stale | refreshFail | archived
- ValidationIssueType
- Types of validation issues.
- ValidationResult
- Result of response validation.
- ValidatorSeverity
- Severity levels for validation failures.
- VerificationVerdict
- Verification verdict.
- ViewStatus
- View status.
Extensions
- QueryableGraph on FactGraph
- Extension to add query method to FactGraph.
Constants
- metadataSourceCandidateKey → const String
-
Metadata key used to stamp candidateId on fact records when the
bundle-level
FactRecorddoes not carry an explicitsourceCandidateIdsfield. Allows hosts to propagate provenance without a breaking change to the public bundle contract. - metadataSourceCandidateListKey → const String
- Metadata key used when writing back a candidate hint in the reverse direction.
Typedefs
-
ArtifactBytesResolver
= Future<
List< Function(Artifact artifact)int> > -
Resolves an
Artifact.contentRefinto a byte list. Downstream adapter packages (filesystem, S3, Firestore) provide real implementations. - CanonicalEvent = FactCluster
- Backward compatibility alias.
- CanonicalStatus = FactClusterStatus
- Backward compatibility alias.
- ClusterAuditEntry = FactClusterAuditEntry
- Backward compatibility alias.
- ContextBundle = InternalContextBundle
- Backward compatibility alias.
- Event = Fact
- Backward compatibility alias.
- EventStatus = FactStatus
- Backward compatibility alias.
- ExtractionMethod = ExtractorType
- Backward compatibility alias.
- SourceMetadata = SourceInfo
- Backward compatibility alias for SourceInfo.
- VerifiableClaimType = ClaimType
- Backward compatibility aliases.
- VerificationStatus = ClaimStatus
- Backward compatibility alias.
Exceptions / Errors
- FactConflictException
- Exception raised when a candidate fact violates consistency rules.