ruvnet/RuView · error · Error

brain corpus exceeds 1000 records

Error message

brain corpus exceeds 1000 records

What it means

The canonical brain corpus is limited to 1000 records so the reviewed knowledge base stays reviewable. loadBrain counts parsed records and throws when the count exceeds 1000. Short records can hit this limit even when the 1 MiB byte cap has not been reached yet.

Source

Thrown at harness/ruview/src/brain.js:54

  if (canonical && record.reviewed !== true) errors.push('canonical records must be reviewed');
  const combined = `${record.title || ''}\n${record.content || ''}`;
  if (SECRET.test(combined)) errors.push('record appears to contain a secret');
  if (INJECTION.test(combined)) errors.push('record contains instruction-like prompt injection');
  return errors;
}

export function loadBrain(path = CORPUS_PATH) {
  const raw = readFileSync(path, 'utf8').replace(/\r\n/g, '\n');
  if (Buffer.byteLength(raw) > 1_048_576) throw new Error('brain corpus exceeds 1 MiB');
  const records = raw.split('\n').filter(Boolean).map((line, index) => {
    if (Buffer.byteLength(line) > 16_384) throw new Error(`brain line ${index + 1}: exceeds 16 KiB`);
    let record;
    try { record = JSON.parse(line); } catch (error) { throw new Error(`brain line ${index + 1}: ${error.message}`); }
    const errors = validateBrainRecord(record, { canonical: true });
    if (errors.length) throw new Error(`brain line ${index + 1}: ${errors.join('; ')}`);
    return Object.freeze(record);
  });
  if (records.length > 1000) throw new Error('brain corpus exceeds 1000 records');
  const ids = new Set();
  for (const record of records) {
    if (ids.has(record.id)) throw new Error(`duplicate brain id: ${record.id}`);
    ids.add(record.id);
  }
  return { records, digest: sha256(raw), bytes: Buffer.byteLength(raw) };
}

function terms(value) {
  return new Set(String(value).toLowerCase().match(/[a-z0-9][a-z0-9_-]{1,}/g) || []);
}

export function searchBrain(query, { limit = 8, path = CORPUS_PATH } = {}) {
  const wanted = terms(query);
  if (!wanted.size) return [];
  const { records, digest } = loadBrain(path);
  return records.map((record) => {
    const title = terms(record.title);

View on GitHub (pinned to 4685618388)

Solutions

  1. Retire or consolidate stale records to stay under 1000
  2. Merge near-duplicate lessons into single records with shared tags
  3. Monitor the count: wc -l harness/ruview/brain/corpus/core.jsonl

Example fix

# before: 1043 records, loadBrain() throws

# after: consolidate duplicates and retire stale records
$ wc -l harness/ruview/brain/corpus/core.jsonl
998 harness/ruview/brain/corpus/core.jsonl
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'node:fs';
function recordCount(path) {
  return readFileSync(path, 'utf8').split('\n').filter((l) => l.trim()).length;
}
// use: if (recordCount(path) > 1000) failFast('prune the corpus before loading');

Try / catch

try {
  const brain = loadBrain(path);
} catch (error) {
  if (error.message.includes('exceeds 1000 records')) {
    console.error('corpus record cap reached — retire or consolidate records');
    process.exit(1);
  }
  throw error;
}

Prevention

When it happens

Trigger: core.jsonl accumulating more than 1000 valid JSONL records, e.g. bulk imports or long-term automated harvesting of lessons.

Common situations: Record-per-lesson automation, importing issue digests, long-lived repositories with many contributors.

Related errors


AI-assisted analysis of ruvnet/RuView@4685618388 (2026-08-16). Data as JSON: /api/errors/5d71dcedbf91a27b. Report an issue: GitHub.