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
impl LoadedPriors
Sourcepub fn load_bundled<R: Rng>(
industry: &str,
rng: &mut R,
period_days: i64,
) -> Result<Self, PriorsLoadError>
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.
Sourcepub fn load_from_path<R: Rng>(
path: &Path,
rng: &mut R,
period_days: i64,
expected_industry: Option<&str>,
) -> Result<Self, PriorsLoadError>
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.
Sourcepub fn from_priors<R: Rng>(
bp: BehavioralPriors,
bundle_path: PathBuf,
rng: &mut R,
period_days: i64,
) -> Result<Self, PriorsLoadError>
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
impl LoadedPriors
Sourcepub fn sample_attribute_for_source<R: Rng>(
&self,
source: &str,
attribute: &str,
rng: &mut R,
) -> Option<String>
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.
Sourcepub fn sample_user_for_source<R: Rng>(
&self,
source: &str,
rng: &mut R,
) -> Option<String>
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_personasprior 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.
Sourcepub fn sample_timestamp_for_user<R: Rng>(
&self,
user_id: &str,
rng: &mut R,
) -> Option<(u32, u32)>
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).
Sourcepub fn sample_amount_for_source<R: Rng>(
&self,
source: &str,
gl_prefix: &str,
rng: &mut R,
) -> Option<f64>
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:
- Try
(source, gl_prefix)whengl_prefixis non-empty. - Fall back to the source-marginal.
- Return
Nonewhen 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.
Sourcepub fn sample_gl_for_source_role<R: Rng>(
&self,
source: &str,
role: &str,
rng: &mut R,
) -> Option<String>
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_glprior 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.
Sourcepub fn sample_reference<R: Rng>(
&self,
source: &str,
rng: &mut R,
) -> Option<String>
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).
Sourcepub fn sample_line_template<R: Rng>(
&self,
source: &str,
account_class: &str,
resolver: &mut dyn PlaceholderResolver,
rng: &mut R,
) -> Option<String>
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:
line_pools["SOURCE|CLASS"]line_pools["SOURCE|_unknown_"]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.
Sourcepub fn sample_header_template<R: Rng>(
&self,
source: &str,
resolver: &mut dyn PlaceholderResolver,
rng: &mut R,
) -> Option<String>
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.
Sourcepub fn sample_coa_description<R: Rng>(
&self,
account_no: &str,
resolver: &mut dyn PlaceholderResolver,
rng: &mut R,
) -> Option<String>
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
impl Clone for LoadedPriors
Source§fn clone(&self) -> LoadedPriors
fn clone(&self) -> LoadedPriors
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LoadedPriors
impl RefUnwindSafe for LoadedPriors
impl Send for LoadedPriors
impl Sync for LoadedPriors
impl Unpin for LoadedPriors
impl UnsafeUnpin for LoadedPriors
impl UnwindSafe for LoadedPriors
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.