Skip to main content

ReviewState

Struct ReviewState 

Source
pub struct ReviewState {
    pub target: Option<ContentHash>,
    pub reviewers: Vec<String>,
    pub verdicts: BTreeMap<String, VerdictState>,
    pub slashes: BTreeMap<String, String>,
    pub target_ref: Option<String>,
    pub comments: Vec<CommentState>,
    pub viewed: BTreeMap<String, u64>,
    pub status: ReviewStatus,
}
Expand description

Materialized state of one review: what is under review, who was asked, who has answered what, and what was said about it.

Fields§

§target: Option<ContentHash>

The commit under review.

§reviewers: Vec<String>

Actors the review fanned out to.

§verdicts: BTreeMap<String, VerdictState>

reviewer → their answer; absent = not answered yet.

§slashes: BTreeMap<String, String>

reviewer → node-recorded reason for retroactively invalidating that approval. Kept separately from verdict bulk so archived rows remain compact while the append-only decision stays visible.

§target_ref: Option<String>

The ref the review proposes to land on (<repo>:<refname>), or None for a review that named no destination. Policy reads this to decide whether a review is privilege-bearing.

§comments: Vec<CommentState>

The discussion, in the order the sequencer admitted it (D38). Emptied by OpKind::ArchiveReview with the rest of the bulk.

§viewed: BTreeMap<String, u64>

viewer → fold position of that viewer’s first recorded read . Emptied by OpKind::ArchiveReview with the rest of the bulk.

§status: ReviewStatus

Live, or settled with its outcome retained. Defaults to ReviewStatus::Live, so replaying a log written before archiving existed yields exactly the previous behaviour.

Implementations§

Source§

impl ReviewState

Source

pub fn counted_approvers(&self) -> Vec<(&str, u64)>

The reviewer channels ReviewState::approval_weight actually counts: the first standing Approve from each distinct operator, in verdict order, slashes applied.

This exists so a OpKind::Submit can name the approvals its weight rested on rather than “everyone who clicked approve”. The weight is defined as this list’s length times MAX_APPROVAL_WEIGHT_PER_OPERATOR, so the number in an authorization record and the names beside it cannot drift.

Each entry pairs the channel with the fold position of the verdict being counted, because that position is what resolves the channel to a key (see View::bound_actor_at). Returning the channel alone would leave every caller to look the position up again, and the one that forgot would silently credit whatever key holds the channel today.

Meaningless on an archived review, whose verdicts are gone: the list is empty while ReviewState::approval_weight still answers from the stored total.

Source

pub fn approval_stands(&self, reviewer: &str) -> bool

Whether reviewer has an Approve verdict that no slash has invalidated — the individual half of ReviewState::counted_approvers, used where one named approval has to be checked rather than a set.

Source

pub fn standing_approval_at(&self, reviewer: &str) -> Option<u64>

The fold position of reviewer’s standing approval, or None if they have none — ReviewState::approval_stands plus the one fact a caller needs to resolve it to a key (View::bound_actor_at).

The predicate is defined as this returning Some, so the two can never disagree about what “standing” means.

Source

pub fn complete(&self) -> bool

Whether every listed reviewer has answered. An unassigned review (no reviewers yet) is never complete — vacuous truth must not turn “asked nobody” into a finished review.

Source

pub fn approved(&self) -> bool

Whether the review is complete with no RequestChanges.

Source

pub fn approval_weight(&self) -> usize

Approval weight after capping every operator at one unit.

Multiple agent channels under one operator/agent prefix never manufacture additional approval weight. Archived reviews return the compact weight captured before their reviewer detail was dropped.

Source

pub fn re_review_required(&self) -> bool

Whether a retroactive invalidation requires a fresh review before the same (ref, commit) can authorize another protected landing.

Trait Implementations§

Source§

impl Clone for ReviewState

Source§

fn clone(&self) -> ReviewState

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
Source§

impl Debug for ReviewState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ReviewState

Source§

fn default() -> ReviewState

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ReviewState

Source§

fn eq(&self, other: &ReviewState) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ReviewState

Source§

impl StructuralPartialEq for ReviewState

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