pub struct HypergraphBuilder { /* private fields */ }Expand description
Builder for constructing a multi-layer hypergraph.
Implementations§
Source§impl HypergraphBuilder
impl HypergraphBuilder
Sourcepub fn new(config: HypergraphConfig) -> Self
pub fn new(config: HypergraphConfig) -> Self
Create a new builder with the given configuration.
Sourcepub fn rebalance_budget(
&mut self,
l1_demand: usize,
l2_demand: usize,
l3_demand: usize,
)
pub fn rebalance_budget( &mut self, l1_demand: usize, l2_demand: usize, l3_demand: usize, )
Rebalance the per-layer budget based on actual demand. Unused slots from layers with fewer entities than their max are redistributed to L2 (Process), which is typically the largest consumer. Call this after adding all governance and accounting nodes, but before adding large L2 producers like OCPM events.
Sourcepub fn suggest_budget(&self, demand: &LayerDemand) -> NodeBudgetSuggestion
pub fn suggest_budget(&self, demand: &LayerDemand) -> NodeBudgetSuggestion
Compute a budget suggestion based on actual demand per layer.
Does not modify the builder’s budget — call [rebalance_with_demand]
to actually apply the suggestion.
Sourcepub fn rebalance_with_demand(&mut self, demand: &LayerDemand)
pub fn rebalance_with_demand(&mut self, demand: &LayerDemand)
Rebalance the budget and apply the suggested allocation.
Surplus from layers that need fewer entities than their default max is redistributed proportionally to layers with unsatisfied demand.
Sourcepub fn budget(&self) -> &NodeBudget
pub fn budget(&self) -> &NodeBudget
Return a snapshot of the current budget for inspection.
Sourcepub fn count_demand(input: &BuilderInput<'_>) -> LayerDemand
pub fn count_demand(input: &BuilderInput<'_>) -> LayerDemand
Count entities per layer from a BuilderInput to compute demand.
This is a convenience method that tallies the entities from each slice
according to which layer they belong to. The returned LayerDemand
can be passed to [suggest_budget] or [rebalance_with_demand].
Sourcepub fn add_all_ordered(&mut self, input: &BuilderInput<'_>)
pub fn add_all_ordered(&mut self, input: &BuilderInput<'_>)
Add all entities from a BuilderInput in the correct phase order.
Phase ordering guarantees that critical small-count entities (like audit documents) are inserted before large-volume producers (like banking transactions) so they are never silently dropped by budget exhaustion.
Phases:
- L1 Governance (COSO, controls, master data, compliance standards, ESG)
- L2 Critical (audit — small count, must not be dropped)
- L2 Volume (P2P, O2C, S2C, H2R, MFG, banking, temporal, IC, OCPM)
- L3 Accounting (chart of accounts, journal entries)
- L3 Domain extensions (tax, treasury, project accounting)
- Process family tagging
Sourcepub fn add_coso_framework(&mut self)
pub fn add_coso_framework(&mut self)
Add COSO framework as Layer 1 nodes (5 components + 17 principles).
Sourcepub fn add_controls(&mut self, controls: &[InternalControl])
pub fn add_controls(&mut self, controls: &[InternalControl])
Add internal controls as Layer 1 nodes with edges to COSO components.
Sourcepub fn add_vendors(&mut self, vendors: &[Vendor])
pub fn add_vendors(&mut self, vendors: &[Vendor])
Add vendor master data as Layer 1 nodes.
Sourcepub fn add_customers(&mut self, customers: &[Customer])
pub fn add_customers(&mut self, customers: &[Customer])
Add customer master data as Layer 1 nodes.
Sourcepub fn add_employees(&mut self, employees: &[Employee])
pub fn add_employees(&mut self, employees: &[Employee])
Add employee/organizational nodes as Layer 1 nodes.
Sourcepub fn add_materials(&mut self, materials: &[Material])
pub fn add_materials(&mut self, materials: &[Material])
Add material master data as Layer 3 nodes.
Sourcepub fn add_fixed_assets(&mut self, assets: &[FixedAsset])
pub fn add_fixed_assets(&mut self, assets: &[FixedAsset])
Add fixed asset master data as Layer 3 nodes.
Sourcepub fn add_accounts(&mut self, coa: &ChartOfAccounts)
pub fn add_accounts(&mut self, coa: &ChartOfAccounts)
Add GL accounts as Layer 3 nodes.
Sourcepub fn add_journal_entries_as_hyperedges(&mut self, entries: &[JournalEntry])
pub fn add_journal_entries_as_hyperedges(&mut self, entries: &[JournalEntry])
Add journal entries as Layer 3 hyperedges.
Each journal entry becomes a hyperedge connecting its debit and credit accounts.
Sourcepub fn add_journal_entry_nodes(&mut self, entries: &[JournalEntry])
pub fn add_journal_entry_nodes(&mut self, entries: &[JournalEntry])
Add journal entries as standalone Layer 3 nodes.
Creates a node per JE with amount, date, anomaly info, and line count.
Use alongside add_journal_entries_as_hyperedges so the dashboard can
count JE nodes while the accounting network still has proper hyperedges.
Sourcepub fn add_p2p_documents(
&mut self,
purchase_orders: &[PurchaseOrder],
goods_receipts: &[GoodsReceipt],
vendor_invoices: &[VendorInvoice],
payments: &[Payment],
)
pub fn add_p2p_documents( &mut self, purchase_orders: &[PurchaseOrder], goods_receipts: &[GoodsReceipt], vendor_invoices: &[VendorInvoice], payments: &[Payment], )
Add P2P document chains as Layer 2 nodes.
If a vendor has more documents than the threshold, they’re aggregated into pool nodes.
Sourcepub fn add_o2c_documents(
&mut self,
sales_orders: &[SalesOrder],
deliveries: &[Delivery],
customer_invoices: &[CustomerInvoice],
)
pub fn add_o2c_documents( &mut self, sales_orders: &[SalesOrder], deliveries: &[Delivery], customer_invoices: &[CustomerInvoice], )
Add O2C document chains as Layer 2 nodes.
Sourcepub fn add_s2c_documents(
&mut self,
projects: &[SourcingProject],
qualifications: &[SupplierQualification],
rfx_events: &[RfxEvent],
bids: &[SupplierBid],
evaluations: &[BidEvaluation],
contracts: &[ProcurementContract],
)
pub fn add_s2c_documents( &mut self, projects: &[SourcingProject], qualifications: &[SupplierQualification], rfx_events: &[RfxEvent], bids: &[SupplierBid], evaluations: &[BidEvaluation], contracts: &[ProcurementContract], )
Add S2C (Source-to-Contract) documents as Layer 2 nodes.
Sourcepub fn add_h2r_documents(
&mut self,
payroll_runs: &[PayrollRun],
time_entries: &[TimeEntry],
expense_reports: &[ExpenseReport],
)
pub fn add_h2r_documents( &mut self, payroll_runs: &[PayrollRun], time_entries: &[TimeEntry], expense_reports: &[ExpenseReport], )
Add H2R (Hire-to-Retire) documents as Layer 2 nodes.
Sourcepub fn add_mfg_documents(
&mut self,
production_orders: &[ProductionOrder],
quality_inspections: &[QualityInspection],
cycle_counts: &[CycleCount],
)
pub fn add_mfg_documents( &mut self, production_orders: &[ProductionOrder], quality_inspections: &[QualityInspection], cycle_counts: &[CycleCount], )
Add MFG (Manufacturing) documents as Layer 2 nodes.
Sourcepub fn add_bank_documents(
&mut self,
customers: &[BankingCustomer],
accounts: &[BankAccount],
transactions: &[BankTransaction],
)
pub fn add_bank_documents( &mut self, customers: &[BankingCustomer], accounts: &[BankAccount], transactions: &[BankTransaction], )
Add Banking documents as Layer 2 nodes.
Sourcepub fn add_audit_documents(
&mut self,
engagements: &[AuditEngagement],
workpapers: &[Workpaper],
findings: &[AuditFinding],
evidence: &[AuditEvidence],
risks: &[RiskAssessment],
judgments: &[ProfessionalJudgment],
)
pub fn add_audit_documents( &mut self, engagements: &[AuditEngagement], workpapers: &[Workpaper], findings: &[AuditFinding], evidence: &[AuditEvidence], risks: &[RiskAssessment], judgments: &[ProfessionalJudgment], )
Add Audit documents as Layer 2 nodes.
Sourcepub fn add_audit_procedure_entities(
&mut self,
confirmations: &[ExternalConfirmation],
responses: &[ConfirmationResponse],
steps: &[AuditProcedureStep],
samples: &[AuditSample],
analytical_results: &[AnalyticalProcedureResult],
ia_functions: &[InternalAuditFunction],
ia_reports: &[InternalAuditReport],
related_parties: &[RelatedParty],
rp_transactions: &[RelatedPartyTransaction],
)
pub fn add_audit_procedure_entities( &mut self, confirmations: &[ExternalConfirmation], responses: &[ConfirmationResponse], steps: &[AuditProcedureStep], samples: &[AuditSample], analytical_results: &[AnalyticalProcedureResult], ia_functions: &[InternalAuditFunction], ia_reports: &[InternalAuditReport], related_parties: &[RelatedParty], rp_transactions: &[RelatedPartyTransaction], )
Add audit procedure entities as Layer 1/2 nodes (ISA 505, 520, 530, 550, 610).
Covers 9 entity types:
- ExternalConfirmation, ConfirmationResponse (ISA 505)
- AuditProcedureStep, AuditSample (ISA 330/530)
- AnalyticalProcedureResult (ISA 520)
- InternalAuditFunction, InternalAuditReport (ISA 610)
- RelatedParty, RelatedPartyTransaction (ISA 550)
Sourcepub fn add_bank_recon_documents(
&mut self,
reconciliations: &[BankReconciliation],
)
pub fn add_bank_recon_documents( &mut self, reconciliations: &[BankReconciliation], )
Add Bank Reconciliation documents as Layer 2 nodes.
Sourcepub fn add_ocpm_events(&mut self, event_log: &OcpmEventLog)
pub fn add_ocpm_events(&mut self, event_log: &OcpmEventLog)
Add OCPM events as hyperedges connecting their participating objects.
Sourcepub fn add_compliance_regulations(
&mut self,
standards: &[ComplianceStandard],
findings: &[ComplianceFinding],
filings: &[RegulatoryFiling],
)
pub fn add_compliance_regulations( &mut self, standards: &[ComplianceStandard], findings: &[ComplianceFinding], filings: &[RegulatoryFiling], )
Adds compliance regulation nodes: standards (Layer 1), findings & filings (Layer 2).
Creates cross-layer edges:
- Standard → Account (GovernedByStandard) via
applicable_account_types - Standard → Control (StandardToControl) via domain/process mapping
- Finding → Control (FindingOnControl) if finding has
control_id
Sourcepub fn add_tax_documents(
&mut self,
jurisdictions: &[TaxJurisdiction],
codes: &[TaxCode],
tax_lines: &[TaxLine],
tax_returns: &[TaxReturn],
tax_provisions: &[TaxProvision],
withholding_records: &[WithholdingTaxRecord],
)
pub fn add_tax_documents( &mut self, jurisdictions: &[TaxJurisdiction], codes: &[TaxCode], tax_lines: &[TaxLine], tax_returns: &[TaxReturn], tax_provisions: &[TaxProvision], withholding_records: &[WithholdingTaxRecord], )
Add tax documents as Layer 3 (Accounting Network) nodes.
Creates nodes for jurisdictions, tax codes, tax lines, tax returns, tax provisions, and withholding tax records.
Sourcepub fn add_treasury_documents(
&mut self,
cash_positions: &[CashPosition],
cash_forecasts: &[CashForecast],
hedge_relationships: &[HedgeRelationship],
debt_instruments: &[DebtInstrument],
)
pub fn add_treasury_documents( &mut self, cash_positions: &[CashPosition], cash_forecasts: &[CashForecast], hedge_relationships: &[HedgeRelationship], debt_instruments: &[DebtInstrument], )
Add treasury documents as Layer 3 (Accounting Network) nodes.
Creates nodes for cash positions, cash forecasts, hedge relationships, and debt instruments.
Sourcepub fn add_esg_documents(
&mut self,
emissions: &[EmissionRecord],
disclosures: &[EsgDisclosure],
supplier_assessments: &[SupplierEsgAssessment],
climate_scenarios: &[ClimateScenario],
)
pub fn add_esg_documents( &mut self, emissions: &[EmissionRecord], disclosures: &[EsgDisclosure], supplier_assessments: &[SupplierEsgAssessment], climate_scenarios: &[ClimateScenario], )
Add ESG documents as Layer 1 (Governance & Controls) nodes.
Creates nodes for emissions, disclosures, supplier assessments, and climate scenarios.
Sourcepub fn add_project_documents(
&mut self,
projects: &[Project],
earned_value_metrics: &[EarnedValueMetric],
milestones: &[ProjectMilestone],
)
pub fn add_project_documents( &mut self, projects: &[Project], earned_value_metrics: &[EarnedValueMetric], milestones: &[ProjectMilestone], )
Add project accounting documents as Layer 3 (Accounting Network) nodes.
Creates nodes for projects, earned value metrics, and milestones.
Sourcepub fn add_intercompany_documents(
&mut self,
matched_pairs: &[ICMatchedPair],
elimination_entries: &[EliminationEntry],
)
pub fn add_intercompany_documents( &mut self, matched_pairs: &[ICMatchedPair], elimination_entries: &[EliminationEntry], )
Add intercompany documents as Layer 3 (Accounting Network) nodes.
Creates nodes for IC matched pairs and elimination entries.
Sourcepub fn add_temporal_events(
&mut self,
process_events: &[ProcessEvolutionEvent],
organizational_events: &[OrganizationalEvent],
disruption_events: &[DisruptionEvent],
)
pub fn add_temporal_events( &mut self, process_events: &[ProcessEvolutionEvent], organizational_events: &[OrganizationalEvent], disruption_events: &[DisruptionEvent], )
Add temporal events as Layer 2 (Process Events) nodes.
Creates nodes for process evolution events, organizational events, and disruption events.
Sourcepub fn add_aml_alerts(&mut self, transactions: &[BankTransaction])
pub fn add_aml_alerts(&mut self, transactions: &[BankTransaction])
Add AML alert nodes derived from suspicious banking transactions (Layer 2).
Creates an aml_alert node for each suspicious transaction. These are
separate from the bank_transaction nodes produced by add_bank_documents.
Sourcepub fn add_kyc_profiles(&mut self, customers: &[BankingCustomer])
pub fn add_kyc_profiles(&mut self, customers: &[BankingCustomer])
Add KYC profile nodes derived from banking customers (Layer 2).
Creates a kyc_profile node for each banking customer. These capture
the KYC/AML risk profile rather than the transactional behavior.
Sourcepub fn tag_process_family(&mut self)
pub fn tag_process_family(&mut self)
Tag all nodes with a process_family property based on their entity type.
This replaces AssureTwin’s entity_registry logic. Call after all nodes
have been added and before build().
Sourcepub fn build_cross_layer_edges(&mut self)
pub fn build_cross_layer_edges(&mut self)
Build cross-layer edges linking governance to accounting and process layers.
Sourcepub fn build(self) -> Hypergraph
pub fn build(self) -> Hypergraph
Finalize and build the Hypergraph.