Skip to main content

Module policy_convergence

Module policy_convergence 

Source
Expand description

The bounded loop that repeats a pass after corrections changed candidate content. What: The bounded loop that repeats a whole policy pass after corrections changed the candidate content, until the content is stable or the loop gives up. Why: A correction by one policy can create a finding for another, so every changed state restarts the complete order. The loop must end: at most eight passes may change the content, and returning to an earlier state is a cycle. This module owns only that control flow; running policies, applying corrections and storing exact states stay behind a small interface, so the loop is testable without Git.

In TS you’d write (pseudocode):

// const convergence = await convergeCommitPolicies({ firstPass, firstSnapshot, ... });

Enums§

Convergence
What: How the loop ended. Settled carries the number of passes that changed content. Why: The caller reports the stable pass, or one engine failure for each other ending.
PassResult
What: What one whole policy pass over the current state ended in. An enum is a closed set of named alternatives. #[derive(...)] asks the compiler to generate copying, debug printing and ==. Why: Only a pass that proposes corrections continues the loop.

Constants§

FIX_CYCLE_MESSAGE
The engine-failure message of corrections that returned to an earlier state.
FIX_PASS_LIMIT_MESSAGE
The engine-failure message of a pass that still proposes corrections after the limit.
MAXIMUM_CHANGED_PASSES
What: The most passes that may change candidate content. usize is the unsigned integer of list positions and counts (siblings u32, u64). Why: The incumbent stops after eight changed passes; usize is the type the snapshot numbers below are counted in.

Traits§

FixPasses
What: The work the loop drives. A trait is a named set of methods a type promises to provide, like a TS interface; &mut self lends the implementer for writing. Why: Exact candidate states can be large, so the implementer stores them (the incumbent used private files) and answers equality by snapshot number; the loop never holds content. Gotcha: Snapshot 0 is the state before the first pass and must exist before the loop starts.

Functions§

converge
What: Drive passes until the state is stable or the loop must give up. Why: The bound is structural: the for loop runs at most eight times, each round ending or storing exactly one new state, and one last pass may only confirm stability.