Skip to main content

LoadedPriors

Struct LoadedPriors 

Source
pub struct LoadedPriors {
Show 19 fields pub industry: String, pub bundle_path: PathBuf, pub source_mix: SourceMixPrior, pub iet_sampler: ConditionalIETSampler, pub lines_per_je: LinesPerJePrior, pub active_window: SourceActiveWindow, pub multi_segment_window: Option<MultiSegmentActiveWindow>, pub fanout_samplers: HashMap<String, BipartiteFanoutSampler>, pub posting_lag: Option<PostingLagPrior>, pub cross_entity_motifs: Option<CrossEntityMotifSampler>, pub per_source_attribute: Option<PerSourceAttributePrior>, pub tp_motif_sampler: Option<CrossEntityMotifSampler>, pub reference_formats: Option<ReferenceFormatPrior>, pub coa_semantic: Option<CoaSemanticPrior>, pub user_personas: Option<UserPersonaPrior>, pub source_amount_conditionals: Option<PerSourceAmountPrior>, pub source_role_gl: Option<PerSourceRolePrior>, pub tb_anchor: Option<TbAnchorPrior>, pub text_taxonomy: Option<TextTaxonomyPrior>,
}
Expand description

Fully-built runtime priors consumed by je_generator and friends.

Fields§

§industry: String§bundle_path: PathBuf§source_mix: SourceMixPrior§iet_sampler: ConditionalIETSampler§lines_per_je: LinesPerJePrior§active_window: SourceActiveWindow§multi_segment_window: Option<MultiSegmentActiveWindow>

SP3.2 — when Some, supersedes active_window for is_active checks.

§fanout_samplers: HashMap<String, BipartiteFanoutSampler>§posting_lag: Option<PostingLagPrior>§cross_entity_motifs: Option<CrossEntityMotifSampler>

SP3.3 — cross-entity motif sampler. None when bundle has no entity_clusters.

§per_source_attribute: Option<PerSourceAttributePrior>

SP3.7 — per-source conditional attribute distributions. When Some, downstream attribute sampling (GL account, cost center, profit center) is constrained to the values characteristic of the just-drawn source code rather than the marginal distribution over all sources.

§tp_motif_sampler: Option<CrossEntityMotifSampler>

SP3.12 — TP motif sampler. Built from tp_entity_clusters; biases the TP draw toward cluster-mates of recently-emitted TPs on the same source to build triangle structure in the TP co-occurrence graph.

§reference_formats: Option<ReferenceFormatPrior>

SP4.7 — Per-source reference-string format templates. When Some, the JE generator calls sample_reference to produce a reference string that matches the corpus format pattern for the current source code.

§coa_semantic: Option<CoaSemanticPrior>

SP4.2 — CoA semantic content extracted from corpus CoA parquet files. When Some, the CoA generator overwrites generic account descriptions with corpus names and ISO 21378 hierarchy values.

§user_personas: Option<UserPersonaPrior>

SP4.5 — Per-user behavioral patterns (source mix, hourly density, weekday density, volume share). When Some and has_data() is true, je_generator biases created_by and created_at toward the characteristic patterns of each user.

None or empty: generator falls back to the internal user pool.

§source_amount_conditionals: Option<PerSourceAmountPrior>

SP4.3 — Per-(source, gl_prefix) log-normal amount parameters. When Some, je_generator draws JE total-amounts from the source-conditional distribution rather than the global AmountSampler marginal. Fraud entries bypass this path to preserve fraud-pattern semantics.

None means the bundle was built before SP4.3 or had too few rows.

§source_role_gl: Option<PerSourceRolePrior>

SP4.6 — Per-(source, line_role) GL account conditional.

When Some, callers use sample_gl_for_source_role(source, "DR"|"CR") to draw a GL account that respects the debit/credit line role for the given SAP document type. Falls back to sample_attribute_for_source → default when the pair is missing.

None means the bundle was built before SP4.6 or had too few rows.

§tb_anchor: Option<TbAnchorPrior>

SP4.1 — Trial-balance anchor prior.

When Some and has_data() is true, the RunningBalanceTracker can use these industry-median per-account targets to generate periodic drift-correction entries that keep the synthetic balance sheet shaped like a corpus balance sheet.

None means the bundle was built before SP4.1 (current committed bundles) or had no TB data — the balance tracker operates in its existing free-drift mode in that case.

§text_taxonomy: Option<TextTaxonomyPrior>

SP6 — corpus text taxonomy. When Some, provides (source, account-class) line pools, source header pools, and per-account CoA description templates.

Implementations§

Source§

impl LoadedPriors

Source

pub fn load_bundled<R: Rng>( industry: &str, rng: &mut R, period_days: i64, ) -> Result<Self, PriorsLoadError>

Load the bundled .dsf for industry from the crate’s resources/priors/ directory.

Source

pub fn load_from_path<R: Rng>( path: &Path, rng: &mut R, period_days: i64, expected_industry: Option<&str>, ) -> Result<Self, PriorsLoadError>

Load a .dsf bundle from an arbitrary path.

Source

pub fn from_priors<R: Rng>( bp: BehavioralPriors, bundle_path: PathBuf, rng: &mut R, period_days: i64, ) -> Result<Self, PriorsLoadError>

Build LoadedPriors from an already-deserialised BehavioralPriors.

Use this when you already have a BehavioralPriors from the datasynth-fingerprint SDK and don’t need file I/O here.

Source§

impl LoadedPriors

Source

pub fn sample_attribute_for_source<R: Rng>( &self, source: &str, attribute: &str, rng: &mut R, ) -> Option<String>

SP3.7 — Try to sample attribute value conditional on the given source code. Returns None when either the prior is absent, the source isn’t represented in the prior, the attribute isn’t present for that source, or the conditional distribution is empty.

Caller falls back to the marginal sampler in that case.

Source

pub fn sample_user_for_source<R: Rng>( &self, source: &str, rng: &mut R, ) -> Option<String>

SP4.5 — Sample a user ID likely to post the given source code from the user-persona prior.

Returns None when:

  • No user_personas prior was loaded, OR
  • The prior is empty (no user-column data; typical for current corpus), OR
  • No user has a non-zero weight for source.

Callers fall back to the internal user pool (select_user) in all of these cases — the prior is purely additive.

Source

pub fn sample_timestamp_for_user<R: Rng>( &self, user_id: &str, rng: &mut R, ) -> Option<(u32, u32)>

SP4.5 — Given a user_id from the prior, sample an (hour, weekday) pair from the user’s characteristic density.

Returns None when the prior is absent, empty, or the user ID is unknown. hour ∈ 0..24, weekday ∈ 0..7 (Monday = 0).

Source

pub fn sample_amount_for_source<R: Rng>( &self, source: &str, gl_prefix: &str, rng: &mut R, ) -> Option<f64>

SP4.3 — Sample a JE total-amount magnitude for source (and optionally gl_prefix) from the per-(source, gl_prefix) log-normal prior.

Lookup strategy:

  1. Try (source, gl_prefix) when gl_prefix is non-empty.
  2. Fall back to the source-marginal.
  3. Return None when the prior is absent or the source isn’t represented.

Callers fall back to the existing AmountSampler when None is returned. Fraud entries should bypass this helper entirely — the caller is responsible for that guard.

Source

pub fn sample_gl_for_source_role<R: Rng>( &self, source: &str, role: &str, rng: &mut R, ) -> Option<String>

SP4.6 — Sample a GL account conditioned on (source, role) where role is "DR" or "CR".

Returns None when:

  • No source_role_gl prior was loaded (old bundle), OR
  • The (source, role) pair isn’t represented (sparse corpus), OR
  • The distribution is empty.

Callers must fall back to sample_attribute_for_source(source, "gl_account", ...) and ultimately to a hard-coded default GL when None is returned.

Source

pub fn sample_reference<R: Rng>( &self, source: &str, rng: &mut R, ) -> Option<String>

SP4.7 — Sample a reference string for source from the reference-format prior. Returns None when the prior is absent or the source has no templates (caller falls back to the existing format!(...) template).

Source

pub fn sample_line_template<R: Rng>( &self, source: &str, account_class: &str, resolver: &mut dyn PlaceholderResolver, rng: &mut R, ) -> Option<String>

SP6 — Sample a line-text string for (source, account_class) from the text-taxonomy prior, filling placeholders via resolver.

Lookup cascade:

  1. line_pools["SOURCE|CLASS"]
  2. line_pools["SOURCE|_unknown_"]
  3. header_pools["SOURCE"] (last resort — source-level vocabulary)

Returns None only when the prior is absent or the source has no pools at any cascade tier — the caller then falls back to the DescriptionGenerator.

Source

pub fn sample_header_template<R: Rng>( &self, source: &str, resolver: &mut dyn PlaceholderResolver, rng: &mut R, ) -> Option<String>

SP6 — Sample a header-text string for source from the text-taxonomy prior. Returns None when absent / no pool for the source.

Source

pub fn sample_coa_description<R: Rng>( &self, account_no: &str, resolver: &mut dyn PlaceholderResolver, rng: &mut R, ) -> Option<String>

SP6 — Fill the CoA description template for account_no. Returns None when the prior is absent or the account has no template.

Trait Implementations§

Source§

impl Clone for LoadedPriors

Source§

fn clone(&self) -> LoadedPriors

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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