Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

2.3 KB
Raw Blame
import { expect, it } from 'vitest'
import { reviewUnitSelection } from './ci-unit-selection-review.mjs'

const plan = {
  sourceSha: 'sha',
  mode: 'shadow',
  selectionAvailable: true,
  files: ['a', 'b'],
  candidateFiles: ['a']
}

it('does not present full fallback runs as selection-validation evidence', () => {
  const records = [record(1, 'a', 'passed'), record(2, 'b', 'passed')].map((row) => ({
    ...row,
    plan: { ...plan, selectionAvailable: false }
  }))
  expect(reviewUnitSelection(records)[0]).toMatchObject({
    completeFullRun: true,
    selectionEvaluated: false
  })
})
const record = (index, file, state) => ({
  plan,
  timing: {
    sourceSha: 'sha',
    runId: '1',
    runAttempt: '1',
    nodeVersion: '24',
    status: state,
    unhandledErrors: 0,
    shard: { index, count: 2 },
    timings: { [file]: 100 },
    results: { [file]: state }
  }
})

it('finds omitted failures in a complete failing reference run', () => {
  expect(
    reviewUnitSelection([record(1, 'a', 'passed'), record(2, 'b', 'failed')])[0]
  ).toMatchObject({ completeFullRun: true, missedFailures: ['b'], potentiallyOmittedWorkerMs: 100 })
})

it('does not call incomplete, duplicate, interrupted or selected evidence a full reference', () => {
  const a = record(1, 'a', 'passed'),
    b = record(2, 'b', 'passed')
  for (const rows of [
    [a],
    [a, a],
    [a, { ...b, timing: { ...b.timing, unhandledErrors: 1 } }],
    [a, { ...b, timing: { ...b.timing, status: 'interrupted' } }],
    [a, b].map((row) => ({ ...row, plan: { ...plan, mode: 'selected' } }))
  ]) {
    expect(reviewUnitSelection(rows).map((row) => row.completeFullRun)).toEqual([false])
  }
})

it('requires all ten full assignments exactly once for complete evidence', () => {
  const files = Array.from({ length: 10 }, (_, index) => `retained-${index}.test.ts`)
  const tenPlan = { ...plan, files, candidateFiles: files }
  const records = files.map((file, index) => {
    const row = record(index + 1, file, 'passed')
    return {
      ...row,
      plan: tenPlan,
      timing: { ...row.timing, shard: { index: index + 1, count: 10 } }
    }
  })
  expect(reviewUnitSelection(records)[0].completeFullRun).toBe(true)
  expect(reviewUnitSelection(records.slice(0, -1))[0].completeFullRun).toBe(false)
  expect(reviewUnitSelection([...records.slice(0, -1), records[0]])[0].completeFullRun).toBe(false)
})