Skip to main content

HypergraphBuilder

Struct HypergraphBuilder 

Source
pub struct HypergraphBuilder { /* private fields */ }
Expand description

Builder for constructing a multi-layer hypergraph.

Implementations§

Source§

impl HypergraphBuilder

Source

pub fn new(config: HypergraphConfig) -> Self

Create a new builder with the given configuration.

Source

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.

Source

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.

Source

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.

Source

pub fn budget(&self) -> &NodeBudget

Return a snapshot of the current budget for inspection.

Source

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].

Source

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:

  1. L1 Governance (COSO, controls, master data, compliance standards, ESG)
  2. L2 Critical (audit — small count, must not be dropped)
  3. L2 Volume (P2P, O2C, S2C, H2R, MFG, banking, temporal, IC, OCPM)
  4. L3 Accounting (chart of accounts, journal entries)
  5. L3 Domain extensions (tax, treasury, project accounting)
  6. Process family tagging
Source

pub fn add_coso_framework(&mut self)

Add COSO framework as Layer 1 nodes (5 components + 17 principles).

Source

pub fn add_controls(&mut self, controls: &[InternalControl])

Add internal controls as Layer 1 nodes with edges to COSO components.

Source

pub fn add_vendors(&mut self, vendors: &[Vendor])

Add vendor master data as Layer 1 nodes.

Source

pub fn add_customers(&mut self, customers: &[Customer])

Add customer master data as Layer 1 nodes.

Source

pub fn add_employees(&mut self, employees: &[Employee])

Add employee/organizational nodes as Layer 1 nodes.

Source

pub fn add_materials(&mut self, materials: &[Material])

Add material master data as Layer 3 nodes.

Source

pub fn add_fixed_assets(&mut self, assets: &[FixedAsset])

Add fixed asset master data as Layer 3 nodes.

Source

pub fn add_accounts(&mut self, coa: &ChartOfAccounts)

Add GL accounts as Layer 3 nodes.

Source

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.

Source

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.

Source

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.

Source

pub fn add_o2c_documents( &mut self, sales_orders: &[SalesOrder], deliveries: &[Delivery], customer_invoices: &[CustomerInvoice], )

Add O2C document chains as Layer 2 nodes.

Source

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.

Source

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.

Source

pub fn add_mfg_documents( &mut self, production_orders: &[ProductionOrder], quality_inspections: &[QualityInspection], cycle_counts: &[CycleCount], )

Add MFG (Manufacturing) documents as Layer 2 nodes.

Source

pub fn add_bank_documents( &mut self, customers: &[BankingCustomer], accounts: &[BankAccount], transactions: &[BankTransaction], )

Add Banking documents as Layer 2 nodes.

Source

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.

Source

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)
Source

pub fn add_bank_recon_documents( &mut self, reconciliations: &[BankReconciliation], )

Add Bank Reconciliation documents as Layer 2 nodes.

Source

pub fn add_ocpm_events(&mut self, event_log: &OcpmEventLog)

Add OCPM events as hyperedges connecting their participating objects.

Source

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
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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().

Source

pub fn build_cross_layer_edges(&mut self)

Build cross-layer edges linking governance to accounting and process layers.

Source

pub fn build(self) -> Hypergraph

Finalize and build the Hypergraph.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more