Skip to main content

MergeQueue

Struct MergeQueue 

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

Single-shard speculative merge queue over one file.

Implementations§

Source§

impl MergeQueue

Source

pub fn set_max_window(&mut self, n: usize)

Sets the ceiling the speculation window may grow to, and brings the current window under it now rather than at the next resize.

The cost of a round is linear in this number and so is the number of CI jobs in flight at once, which is why it is a deliberate call and not a field a caller can drift upward.

§Panics

If n is zero, which would be a queue that speculates on nothing and drains forever.

Source

pub fn max_window(&self) -> usize

The ceiling MergeQueue::window may grow to.

Source

pub fn set_journal(&mut self, journal: Box<dyn Journal>)

Sends window changes to journal instead of discarding them.

Source

pub fn set_check_reporter(&mut self, reporter: CheckReporter)

Records every verdict CI returns as a choir_view::OpKind::RecordCheck op.

Every verdict, not only the faults. The map from executor::Verdict to choir_view::CheckStatus is total, so recording some and dropping the rest would put an arbitrary hole in the log: a reader finding no check could not tell “it passed” from “nobody was reporting”. The subject is the speculative tree the job actually ran against, which means one change tested at two train positions reports against two subjects – correct, because they are two different questions, and the second is the one that landed.

Source

pub fn new(base: &str) -> Self

Creates a queue over base content with the default window.

Source

pub fn with_pipeline(base: &str, pipeline: Pipeline) -> Self

Creates a queue with a caller-supplied strategy pipeline — the D4/D19 widening seam (structured or LLM slots appended by the caller). Every resolution is still safety-checked by speculate::TextSpeculator, which is what makes the non-deterministic slots admissible at all.

Source

pub fn with_speculator(base: &str, speculator: Box<dyn Speculator>) -> Self

Creates a queue over base whose merges, change identities and job subjects come from speculator (D5).

This is the constructor a caller holding a repository wants: base is then a commit id rather than a file body, and every state the queue moves around is one too. The queue’s policy is unchanged, which is the point — it was never about text.

Source

pub fn set_job_template(&mut self, template: JobTemplate)

Installs the job template (D18): what to run for each candidate state. Without one, every job is refused by the executor for having no command.

Source

pub fn set_landing(&mut self, landing: Box<dyn Landing>)

Installs how a landing is recorded (D68).

The default records a workspace head over whatever log the sequencer holds, which is right for a caller mirroring a canonical upstream. A caller whose own log decides – a node – installs one that moves the ref the change was proposed to, and signs it, because the daemon’s policy refuses an unsigned op.

Source

pub fn set_memory(&mut self, memory: ResolutionMemory)

Installs a resolution memory (item B): a conflict whose triple it remembers is replayed as a candidate instead of re-conflicting. The default is an empty memory, which changes nothing.

Source

pub fn mark_landed(&mut self, identity: String)

Seeds a landed change identity (item 4), for a queue picking up where an earlier instance left off. drain records identities of everything it lands through the same set.

Source

pub fn submit(&mut self, change: Change)

Enqueues a change.

Source

pub fn len(&self) -> usize

Number of changes waiting.

Source

pub fn is_empty(&self) -> bool

Whether the queue is empty.

Source

pub fn window(&self) -> usize

The current speculation window.

Exposed because QueueReport::window_trace cannot answer for it in every case: a drain that stops on a provider fault breaks out before writing the trace, so a test reading only the report asserts over an empty vector and passes whatever the window did. One did, until a mutation that halved the window on a fault was not caught.

Source

pub fn drain_in_memory(&mut self, ci: &mut dyn CiExecutor) -> QueueReport

Drains through a sequencer over an in-memory log.

For a caller whose repository is not the platform’s: the sequencer is not optional – every landing is recorded through it, which is what keeps the single-writer order true of a train as well as of a push – but a forge bridge mirrors an upstream that is canonical (D21), so the ordering of one round is not a claim anybody reads back. Keeping it in memory says that, instead of writing a log which would look like a second source of truth.

Source

pub fn drain( &mut self, ci: &mut dyn CiExecutor, sequencer: &Sequencer, ) -> QueueReport

Drains the queue: speculatively merges up to window changes, runs CI on each against its speculative state, merges the passing prefix, and halves the window + retests behind on any failure.

Every merged change is recorded through the single-writer sequencer (payload = the merged state), preserving the platform’s total order.

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