Skip to main content

Module concentration

Module concentration 

Source
Expand description

Central concentration abstraction (#143, Phase 1).

Post-generation passes that reshape the JE batch’s distributional structure toward a corpus-derived target. Single integration point in the orchestrator sidesteps the multi-generator coverage problem that blocked SOTA-8 (#141) and SOTA-11 (#142) during the SOTA-N round.

Design reference: docs/superpowers/specs/2026-05-23-concentration-pass-INDEX.md

Invariants every implementor MUST preserve:

  1. Per-JE balance: sum(debits) == sum(credits)
  2. Subledger-bridge accounts unchanged (see STRUCTURAL_BRIDGE_ACCOUNTS)
  3. Document-chain refs (DocumentReference is keyed by document_id, not by gl_account — substituting non-bridge accounts is safe)
  4. Determinism: same RNG seed + same input batch ⇒ same output

§Phase 1 (this commit)

§Phase 2 (next commit)

  • AccountPairSubstitutionPass — corpus-PMF-driven account rewriting respecting the bridge allowlist + AccountType invariant

Re-exports§

pub use account_pair_substitution::AccountPairSubstitutionError;
pub use account_pair_substitution::AccountPairSubstitutionPass;
pub use consolidation_outlier::ConsolidationOutlierPass;
pub use source_blanking::SourceBlankingPass;
pub use source_conditional_rarity_pass::SourceConditionalRarityPass;
pub use trading_partner_pool::TradingPartnerPoolPass;

Modules§

account_pair_substitution
AccountPairSubstitutionPass — Phase 2 of the central concentration abstraction (#143). Reshapes the per-JE (debit_account, credit_account) edge distribution toward a corpus-empirical PMF.
consolidation_outlier
ConsolidationOutlierPass — v5.30 B2 (#154) heavy-tail outlier emission.
source_blanking
SourceBlankingPass — Phase 1.5 of the central concentration abstraction (#143). Closes SOTA-7 (#132) by nulling sap_source_code on a configurable fraction of JEs to match the corpus’s ~21% blank-source rate.
source_conditional_rarity_pass
SourceConditionalRarityPass — Phase 1 trait wrapper around the already- shipped SOTA-12 tagger (crate::anomaly::source_conditional_rarity).
trading_partner_pool
TradingPartnerPoolPass — closes the SOTA-11.1 / #142 coverage gap by rewriting JE-line trading_partner strings to a target pool size.

Structs§

ConcentrationPipeline
Ordered, deterministic execution of zero or more ConcentrationPass instances. Each pass receives a dedicated ChaCha8 substream so adding or removing a pass does not perturb the RNG state of any other pass.
ConcentrationStats
Per-pass aggregate counters. Serialised into the orchestrator’s run report.

Enums§

ConcentrationPipelineError
Errors from constructing a ConcentrationPipeline. Currently only one fallible source (Phase-2 AccountPairSubstitutionPass loads its PMF file); the enum is open for future pass-construction errors.

Constants§

STRUCTURAL_BRIDGE_ACCOUNTS
The 7 subledger-bridge accounts whose balances must be preserved across any post-process substitution. Aggregating to subledger totals (AR/AP aging) or netting across matching pairs (GR/IR, IC, wire, fixed-asset acquisition), substituting them silently breaks reconciliation reports.

Traits§

ConcentrationPass
A post-generation transformation reshaping the JE batch’s concentration / distributional structure toward a target. See module-level docs for the invariants every implementor must preserve.

Functions§

is_structural_bridge
True iff the account code is a subledger-bridge account that must be preserved across post-process substitution. Phase-1 passes don’t substitute accounts at all so this is currently informational; Phase-2’s account-pair substitution pass will gate substitution on this.