chenglou/pretext · error · Error

--samples is obsolete for corpus-sweep; use the default step

Error message

--samples is obsolete for corpus-sweep; use the default step-based sweep or sampled font-matrix/taxonomy runs instead

What it means

The sweep used to accept `--samples` for randomized width selection; that mode was removed in favor of the deterministic step-based sweep. Passing `--samples` now hard-fails to prevent silent misinterpretation of old invocations.

Source

Thrown at scripts/corpus-sweep.ts:130

  const browser = (value ?? process.env['CORPUS_CHECK_BROWSER'] ?? 'chrome').toLowerCase()
  if (browser !== 'chrome' && browser !== 'safari') {
    throw new Error(`Unsupported browser ${browser}; expected chrome or safari`)
  }
  return browser
}

async function loadSources(): Promise<CorpusMeta[]> {
  return await Bun.file('corpora/sources.json').json()
}

function parseOptions(): SweepOptions {
  const start = parseNumberFlag('start', 300)
  const end = parseNumberFlag('end', 900)
  const step = parseNumberFlag('step', 10)
  if (step <= 0) throw new Error('--step must be > 0')
  if (end < start) throw new Error('--end must be >= --start')
  if (parseStringFlag('samples') !== null) {
    throw new Error('--samples is obsolete for corpus-sweep; use the default step-based sweep or sampled font-matrix/taxonomy runs instead')
  }

  return {
    id: parseStringFlag('id'),
    all: hasFlag('all'),
    start,
    end,
    step,
    port: parseNumberFlag('port', Number.parseInt(process.env['CORPUS_CHECK_PORT'] ?? '0', 10)),
    browser: parseBrowser(parseStringFlag('browser')),
    output: parseStringFlag('output'),
    timeoutMs: parseNumberFlag('timeout', Number.parseInt(process.env['CORPUS_CHECK_TIMEOUT_MS'] ?? '180000', 10)),
    font: parseStringFlag('font'),
    lineHeight: parseOptionalNumberFlag('lineHeight'),
    diagnose: hasFlag('diagnose'),
    diagnoseLimit: parseNumberFlag('diagnose-limit', 6),
  }
}

View on GitHub (pinned to ac49b09b7d)

Solutions

  1. Drop `--samples`; rely on the default step sweep (`--start`/`--end`/`--step`).
  2. If you specifically need sampling, use `corpus-taxonomy.ts --samples=N` or `corpus-font-matrix.ts --samples=N`, which still accept it.

Example fix

// before
bun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito --samples=12
// after
bun run scripts/corpus-sweep.ts --id=ja-kumo-no-ito                 // step sweep
bun run scripts/corpus-taxonomy.ts --id=ja-kumo-no-ito --samples=12 // sampling kept here
Defensive patterns

Strategy: validation

Validate before calling

if (parseStringFlag('samples') !== null) {
  console.error('--samples is not accepted by corpus-sweep; use corpus-taxonomy or corpus-font-matrix for sampling')
  process.exit(2)
}

Prevention

When it happens

Trigger: Re-running an old command or CI line that still includes `--samples=N` against `corpus-sweep.ts`.

Common situations: Stale CI/shell history after upgrading; muscle memory from the old sampled sweep mode.

Related errors


AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12). Data as JSON: /api/errors/980f3baf3fe17f24. Report an issue: GitHub.