cargo mutants: missed mutants in vortex-scan

Open
#12,632 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
rust

Research direction

Start by reviewing the listed mutant diffs in vortex-scan/src/execution/retain.rs and vortex-scan/src/execution/filter.rs, then inspect the nightly run artifacts for the remaining mutants. Run the focused cargo mutants commands shown in the issue to reproduce survivors and identify missing behavioral coverage. Done when tests in vortex-scan fail for the reported mutations and pass with the original code.

Written by the indexing model from the issue text.

Description

The nightly run at fdb9507c04e2939724aa39c298653a8ea3fd3b49 found 19 mutants in vortex-scan that survive the tests. They are in code that changed during the last day.

Artifacts:

vortex-scan/src/execution/retain.rs:134:28

replace * with + in RetainedSegments::evict

--- vortex-scan/src/execution/retain.rs
+++ replace * with + in RetainedSegments::evict
@@ -126,17 +126,17 @@
             self.evict(&mut shard.write(), id);
         }
     }
 
     /// Evicts segments of `state` until the retained bytes fit the budget, keeping `keep`.
     fn evict(&self, state: &mut State, keep: SegmentId) {
         // Two passes over the shard's queue clear every mark once, so the loop ends even when
         // the shard holds only the kept segment.
-        let mut visits = 2 * state.queue.len();
+        let mut visits = 2 + /* ~ changed by cargo-mutants ~ */ state.queue.len();
         while visits > 0 && self.bytes.load(Ordering::Relaxed) > self.budget {
             visits -= 1;
             let Some(oldest) = state.queue.pop_front() else {
                 break;
             };
             let Some(retained) = state.segments.get(&oldest) else {
                 continue;
             };
cargo mutants -f vortex-scan/src/execution/retain.rs -F ':134:28:'
vortex-scan/src/execution/retain.rs:136:20

replace -= with += in RetainedSegments::evict

--- vortex-scan/src/execution/retain.rs
+++ replace -= with += in RetainedSegments::evict
@@ -128,17 +128,17 @@
     }
 
     /// Evicts segments of `state` until the retained bytes fit the budget, keeping `keep`.
     fn evict(&self, state: &mut State, keep: SegmentId) {
         // Two passes over the shard's queue clear every mark once, so the loop ends even when
         // the shard holds only the kept segment.
         let mut visits = 2 * state.queue.len();
         while visits > 0 && self.bytes.load(Ordering::Relaxed) > self.budget {
-            visits -= 1;
+            visits += /* ~ changed by cargo-mutants ~ */ 1;
             let Some(oldest) = state.queue.pop_front() else {
                 break;
             };
             let Some(retained) = state.segments.get(&oldest) else {
                 continue;
             };
             // The segment being inserted is about to be used, and a segment used since it was
             // queued goes to the back once, unmarked.
cargo mutants -f vortex-scan/src/execution/retain.rs -F ':136:20:'
vortex-scan/src/execution/retain.rs:136:20

replace -= with /= in RetainedSegments::evict

--- vortex-scan/src/execution/retain.rs
+++ replace -= with /= in RetainedSegments::evict
@@ -128,17 +128,17 @@
     }
 
     /// Evicts segments of `state` until the retained bytes fit the budget, keeping `keep`.
     fn evict(&self, state: &mut State, keep: SegmentId) {
         // Two passes over the shard's queue clear every mark once, so the loop ends even when
         // the shard holds only the kept segment.
         let mut visits = 2 * state.queue.len();
         while visits > 0 && self.bytes.load(Ordering::Relaxed) > self.budget {
-            visits -= 1;
+            visits /= /* ~ changed by cargo-mutants ~ */ 1;
             let Some(oldest) = state.queue.pop_front() else {
                 break;
             };
             let Some(retained) = state.segments.get(&oldest) else {
                 continue;
             };
             // The segment being inserted is about to be used, and a segment used since it was
             // queued goes to the back once, unmarked.
cargo mutants -f vortex-scan/src/execution/retain.rs -F ':136:20:'
vortex-scan/src/execution/filter.rs:172:9

replace FilterPlans::dynamic_versions -> Vec<Option<u64>> with vec![Some(0)]

--- vortex-scan/src/execution/filter.rs
+++ replace FilterPlans::dynamic_versions -> Vec<Option<u64>> with vec![Some(0)]
@@ -164,19 +164,17 @@
     fn dynamic_version(&self, conjunct_idx: usize) -> Option<u64> {
         self.expression
             .dynamic_updates(conjunct_idx)
             .map(DynamicExprUpdates::version)
     }
 
     /// The current version of each conjunct's dynamic values, `None` for a static conjunct.
     pub(crate) fn dynamic_versions(&self) -> Vec<Option<u64>> {
-        (0..self.conjuncts.len())
-            .map(|idx| self.dynamic_version(idx))
-            .collect()
+        vec![Some(0)] /* ~ changed by cargo-mutants ~ */
     }
 
     /// Whether the conjunct is dynamic and, at its current values, kept almost every row on its
     /// last evaluations, so a scan that may skip unselective dynamic conjuncts skips it.
     pub(crate) fn is_unselective(&self, conjunct_idx: usize) -> bool {
         self.conjuncts[conjunct_idx]
             .dynamic
             .as_ref()
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':172:9:'
vortex-scan/src/execution/filter.rs:213:60

replace && with || in FilterPlans::scan_pruning

--- vortex-scan/src/execution/filter.rs
+++ replace && with || in FilterPlans::scan_pruning
@@ -205,17 +205,17 @@
         skip_unselective_dynamic: bool,
     ) -> impl Iterator<Item = &PlanRef> {
         let small = rows <= FILTERED_ROWS_PER_CHUNK as u64;
         self.conjuncts
             .iter()
             .enumerate()
             .filter(move |(idx, conjunct)| {
                 conjunct.dynamic.is_none()
-                    || !(small || skip_unselective_dynamic && self.is_unselective(*idx))
+                    || !(small || skip_unselective_dynamic || /* ~ changed by cargo-mutants ~ */ self.is_unselective(*idx))
             })
             .flat_map(|(_, conjunct)| &conjunct.pruning)
     }
 
     /// The pruning plans of the dynamic conjuncts whose values changed since `versions`, from
     /// [`dynamic_versions`](Self::dynamic_versions): a chunk prunes with them again before its
     /// conjuncts run, as their new values may exclude zones the scan's pruning kept.
     pub(crate) fn moved_dynamic_pruning(
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':213:60:'
vortex-scan/src/execution/filter.rs:232:51

replace && with || in FilterPlans::moved_dynamic_pruning

--- vortex-scan/src/execution/filter.rs
+++ replace && with || in FilterPlans::moved_dynamic_pruning
@@ -224,17 +224,17 @@
         skip_unselective_dynamic: bool,
     ) -> Vec<PlanRef> {
         self.conjuncts
             .iter()
             .enumerate()
             .filter(|(idx, conjunct)| {
                 conjunct.dynamic.is_some()
                     && self.dynamic_version(*idx) != versions[*idx]
-                    && !(skip_unselective_dynamic && self.is_unselective(*idx))
+                    && !(skip_unselective_dynamic || /* ~ changed by cargo-mutants ~ */ self.is_unselective(*idx))
             })
             .flat_map(|(_, conjunct)| conjunct.pruning.iter().cloned())
             .collect()
     }
 
     /// Whether any dynamic conjunct has a pruning plan, so its chunks may prune again.
     pub(crate) fn has_dynamic_pruning(&self) -> bool {
         self.conjuncts
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':232:51:'
vortex-scan/src/execution/filter.rs:240:9

replace FilterPlans::has_dynamic_pruning -> bool with true

--- vortex-scan/src/execution/filter.rs
+++ replace FilterPlans::has_dynamic_pruning -> bool with true
@@ -232,19 +232,17 @@
                     && !(skip_unselective_dynamic && self.is_unselective(*idx))
             })
             .flat_map(|(_, conjunct)| conjunct.pruning.iter().cloned())
             .collect()
     }
 
     /// Whether any dynamic conjunct has a pruning plan, so its chunks may prune again.
     pub(crate) fn has_dynamic_pruning(&self) -> bool {
-        self.conjuncts
-            .iter()
-            .any(|conjunct| conjunct.dynamic.is_some() && !conjunct.pruning.is_empty())
+        true /* ~ changed by cargo-mutants ~ */
     }
 }
 
 /// A pruning plan must not fetch data, materialize row indices, or execute unresolved statistics
 /// when its requested statistics are unavailable.
 fn metadata_only(plan: &PlanRef) -> VortexResult<bool> {
     if plan
         .as_opt::<Zoned>()
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':240:9:'
vortex-scan/src/execution/filter.rs:242:56

replace && with || in FilterPlans::has_dynamic_pruning

--- vortex-scan/src/execution/filter.rs
+++ replace && with || in FilterPlans::has_dynamic_pruning
@@ -234,17 +234,17 @@
             .flat_map(|(_, conjunct)| conjunct.pruning.iter().cloned())
             .collect()
     }
 
     /// Whether any dynamic conjunct has a pruning plan, so its chunks may prune again.
     pub(crate) fn has_dynamic_pruning(&self) -> bool {
         self.conjuncts
             .iter()
-            .any(|conjunct| conjunct.dynamic.is_some() && !conjunct.pruning.is_empty())
+            .any(|conjunct| conjunct.dynamic.is_some() || /* ~ changed by cargo-mutants ~ */ !conjunct.pruning.is_empty())
     }
 }
 
 /// A pruning plan must not fetch data, materialize row indices, or execute unresolved statistics
 /// when its requested statistics are unavailable.
 fn metadata_only(plan: &PlanRef) -> VortexResult<bool> {
     if plan
         .as_opt::<Zoned>()
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':242:56:'
vortex-scan/src/execution/filter.rs:363:17

replace && with || in FilterPlanner::start_next

--- vortex-scan/src/execution/filter.rs
+++ replace && with || in FilterPlanner::start_next
@@ -355,17 +355,17 @@
                     );
                     continue;
                 }
                 Some(_) => self.filter.dynamic_version(conjunct),
             };
             let predicate = self.filter.conjuncts[conjunct].predicate.clone();
             // For dense selections, evaluate the vectorized predicate before gathering rows.
             let predicate = if !selected.mask.all_true()
-                && selected.mask.true_count().saturating_mul(2) >= selected.mask.len()
+                || /* ~ changed by cargo-mutants ~ */ selected.mask.true_count().saturating_mul(2) >= selected.mask.len()
             {
                 FilterPlan::new(predicate).into_plan()
             } else {
                 predicate
             };
             let scan = Scan::try_new(
                 self.scan.session.clone(),
                 predicate,
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':363:17:'
vortex-scan/src/execution/filter.rs:362:32

delete ! in FilterPlanner::start_next

--- vortex-scan/src/execution/filter.rs
+++ delete ! in FilterPlanner::start_next
@@ -354,17 +354,17 @@
                         "v2 filter conjunct switched off"
                     );
                     continue;
                 }
                 Some(_) => self.filter.dynamic_version(conjunct),
             };
             let predicate = self.filter.conjuncts[conjunct].predicate.clone();
             // For dense selections, evaluate the vectorized predicate before gathering rows.
-            let predicate = if !selected.mask.all_true()
+            let predicate = if  /* ~ changed by cargo-mutants ~ */selected.mask.all_true()
                 && selected.mask.true_count().saturating_mul(2) >= selected.mask.len()
             {
                 FilterPlan::new(predicate).into_plan()
             } else {
                 predicate
             };
             let scan = Scan::try_new(
                 self.scan.session.clone(),
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':362:32:'
vortex-scan/src/execution/filter.rs:363:65

replace >= with < in FilterPlanner::start_next

--- vortex-scan/src/execution/filter.rs
+++ replace >= with < in FilterPlanner::start_next
@@ -355,17 +355,17 @@
                     );
                     continue;
                 }
                 Some(_) => self.filter.dynamic_version(conjunct),
             };
             let predicate = self.filter.conjuncts[conjunct].predicate.clone();
             // For dense selections, evaluate the vectorized predicate before gathering rows.
             let predicate = if !selected.mask.all_true()
-                && selected.mask.true_count().saturating_mul(2) >= selected.mask.len()
+                && selected.mask.true_count().saturating_mul(2) < /* ~ changed by cargo-mutants ~ */ selected.mask.len()
             {
                 FilterPlan::new(predicate).into_plan()
             } else {
                 predicate
             };
             let scan = Scan::try_new(
                 self.scan.session.clone(),
                 predicate,
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':363:65:'
vortex-scan/src/execution/filter.rs:445:33

replace match guard evaluation.adaptor.state() != State::Done with false in <impl Planner for FilterPlanner>::state

--- vortex-scan/src/execution/filter.rs
+++ replace match guard evaluation.adaptor.state() != State::Done with false in <impl Planner for FilterPlanner>::state
@@ -437,17 +437,17 @@
 }
 
 impl Planner for FilterPlanner {
     fn state(&self) -> State {
         if self.selected.is_none() {
             return State::Done;
         }
         match &self.active {
-            Some(evaluation) if evaluation.adaptor.state() != State::Done => {
+            Some(evaluation) if false /* ~ changed by cargo-mutants ~ */ => {
                 evaluation.adaptor.state()
             }
             _ => State::NeedsCompute,
         }
     }
 
     fn compute(&mut self) -> VortexResult<PlannerOutput> {
         let Some(selected) = &self.selected else {
cargo mutants -f vortex-scan/src/execution/filter.rs -F ':445:33:'
vortex-scan/src/execution/selection.rs:26:60

replace - with + in select_chunk

--- vortex-scan/src/execution/selection.rs
+++ replace - with + in select_chunk
@@ -18,17 +18,17 @@
     scope: WorkScope,
     selection: &Selection,
     kept: Option<(&Mask, u64)>,
 ) -> Option<SelectedRows> {
     let selected = select_rows(scope, selection)?;
     let Some((kept, first_row)) = kept else {
         return Some(selected);
     };
-    let offset = usize::try_from(selected.scope.rows.start - first_row)
+    let offset = usize::try_from(selected.scope.rows.start + /* ~ changed by cargo-mutants ~ */ first_row)
         .vortex_expect("a work chunk fits usize");
     let kept = kept.slice(offset..offset + selected.mask.len());
     SelectedRows::narrowed(selected.scope, &selected.mask & &kept)
 }
 
 impl SelectedRows {
     /// The rows of `scope` that `mask`, over all of them, selects, bounded to their span, or
     /// `None` when it selects none.
cargo mutants -f vortex-scan/src/execution/selection.rs -F ':26:60:'
vortex-scan/src/execution/planning/driver/mod.rs:173:34

replace || with && in Work::narrow

--- vortex-scan/src/execution/planning/driver/mod.rs
+++ replace || with && in Work::narrow
@@ -165,17 +165,17 @@
         };
         let Some(rows) = remaining else {
             return Ok(());
         };
         let claimed = claim.rows();
         if rows == *claimed {
             return Ok(());
         }
-        if rows.start > rows.end || rows.start < claimed.start || rows.end > claimed.end {
+        if rows.start > rows.end && /* ~ changed by cargo-mutants ~ */ rows.start < claimed.start || rows.end > claimed.end {
             vortex_bail!(
                 "work for scope {:?} reported remaining rows {rows:?} outside its claim {claimed:?}",
                 self.scope
             );
         }
         claim.restrict_to(rows);
         Ok(())
     }
cargo mutants -f vortex-scan/src/execution/planning/driver/mod.rs -F ':173:34:'
vortex-scan/src/execution/planning/driver/mod.rs:173:48

replace < with == in Work::narrow

--- vortex-scan/src/execution/planning/driver/mod.rs
+++ replace < with == in Work::narrow
@@ -165,17 +165,17 @@
         };
         let Some(rows) = remaining else {
             return Ok(());
         };
         let claimed = claim.rows();
         if rows == *claimed {
             return Ok(());
         }
-        if rows.start > rows.end || rows.start < claimed.start || rows.end > claimed.end {
+        if rows.start > rows.end || rows.start == /* ~ changed by cargo-mutants ~ */ claimed.start || rows.end > claimed.end {
             vortex_bail!(
                 "work for scope {:?} reported remaining rows {rows:?} outside its claim {claimed:?}",
                 self.scope
             );
         }
         claim.restrict_to(rows);
         Ok(())
     }
cargo mutants -f vortex-scan/src/execution/planning/driver/mod.rs -F ':173:48:'
vortex-scan/src/execution/planning/driver/mod.rs:173:48

replace < with <= in Work::narrow

--- vortex-scan/src/execution/planning/driver/mod.rs
+++ replace < with <= in Work::narrow
@@ -165,17 +165,17 @@
         };
         let Some(rows) = remaining else {
             return Ok(());
         };
         let claimed = claim.rows();
         if rows == *claimed {
             return Ok(());
         }
-        if rows.start > rows.end || rows.start < claimed.start || rows.end > claimed.end {
+        if rows.start > rows.end || rows.start <= /* ~ changed by cargo-mutants ~ */ claimed.start || rows.end > claimed.end {
             vortex_bail!(
                 "work for scope {:?} reported remaining rows {rows:?} outside its claim {claimed:?}",
                 self.scope
             );
         }
         claim.restrict_to(rows);
         Ok(())
     }
cargo mutants -f vortex-scan/src/execution/planning/driver/mod.rs -F ':173:48:'
vortex-scan/src/execution/planning/driver/liveness/mod.rs:129:9

replace Liveness::pinned -> usize with 0

--- vortex-scan/src/execution/planning/driver/liveness/mod.rs
+++ replace Liveness::pinned -> usize with 0
@@ -121,17 +121,17 @@
                 _value: Box::new(value),
             },
         );
         true
     }
 
     /// The number of values currently pinned.
     pub fn pinned(&self) -> usize {
-        self.state.lock().pins.len()
+        0 /* ~ changed by cargo-mutants ~ */
     }
 
     fn add(&self, rows: &Range<u64>) {
         self.state.lock().coverage.add(rows);
     }
 
     /// Releases one claim on `rows`. Evicted values are dropped after the lock is released, so
     /// a value's destructor may use this liveness.
cargo mutants -f vortex-scan/src/execution/planning/driver/liveness/mod.rs -F ':129:9:'
vortex-scan/src/execution/planning/driver/liveness/coverage.rs:46:9

replace Coverage::join_at with ()

--- vortex-scan/src/execution/planning/driver/liveness/coverage.rs
+++ replace Coverage::join_at with ()
@@ -38,24 +38,17 @@
             && row < span.end
         {
             self.0.get_mut(&start).vortex_expect("span exists").end = row;
             self.0.insert(row, span);
         }
     }
 
     fn join_at(&mut self, row: u64) {
-        if let Some((&start, &left)) = self.0.range(..row).next_back()
-            && let Some(&right) = self.0.get(&row)
-            && left.end == row
-            && left.owners == right.owners
-        {
-            self.0.get_mut(&start).vortex_expect("span exists").end = right.end;
-            self.0.remove(&row);
-        }
+        () /* ~ changed by cargo-mutants ~ */
     }
 
     pub(super) fn add(&mut self, rows: &Range<u64>) {
         if rows.is_empty() {
             return;
         }
         self.split_at(rows.start);
         self.split_at(rows.end);
cargo mutants -f vortex-scan/src/execution/planning/driver/liveness/coverage.rs -F ':46:9:'
vortex-scan/src/execution/planning/driver/liveness/coverage.rs:69:23

replace < with > in Coverage::add

--- vortex-scan/src/execution/planning/driver/liveness/coverage.rs
+++ replace < with > in Coverage::add
@@ -61,17 +61,17 @@
         self.split_at(rows.end);
         let starts: Vec<_> = self
             .0
             .range(rows.clone())
             .map(|(&start, _)| start)
             .collect();
         let mut cursor = rows.start;
         for start in starts {
-            if cursor < start {
+            if cursor > /* ~ changed by cargo-mutants ~ */ start {
                 self.0.insert(
                     cursor,
                     Span {
                         end: start,
                         owners: 1,
                     },
                 );
             }
cargo mutants -f vortex-scan/src/execution/planning/driver/liveness/coverage.rs -F ':69:23:'
Dominant language
Rust
Stars
3.2k
Forks
239
Avg merge
1d 4h
Merged PRs (30d)
684

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vortex-data/vortex

All issues in vortex-data/vortex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.