ruvnet/RuView · error · Error

brain line ${index + 1}: exceeds 16 KiB

Error message

brain line ${index + 1}: exceeds 16 KiB

What it means

Every JSONL line in the brain corpus must stay under 16 KiB (16_384 bytes); the error names the 1-based line number. Because the per-record content cap is 8192 characters (not bytes), multibyte UTF-8 content or heavy JSON escaping is the usual way an apparently compliant record still exceeds the byte cap.

Source

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

    errors.push('source.path and positive source.line are required');
  } else if (isAbsolute(record.source.path) || record.source.path.split(/[\\/]/).includes('..') || /^[A-Za-z]:/.test(record.source.path)) {
    errors.push('source.path must be repository-relative without traversal');
  }
  if (!Array.isArray(record.tags) || record.tags.some((tag) => typeof tag !== 'string')) errors.push('tags must be strings');
  if ((record.content || '').length > 8192) errors.push('content exceeds 8192 characters');
  if ((record.title || '').length > 200) errors.push('title exceeds 200 characters');
  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) || []);
}

View on GitHub (pinned to 4685618388)

Solutions

  1. Open core.jsonl at the reported line number and split or trim the record
  2. Keep content concise and prefer ASCII where possible
  3. Find all oversized lines: awk 'length($0) > 16384 {print NR}' harness/ruview/brain/corpus/core.jsonl

Example fix

// before (line 214 of core.jsonl, one 17 KB line)
{"id":"big-lesson","content":"<8192 multibyte characters>", ...}

// after
{"id":"big-lesson","content":"<trimmed summary>","source":{"path":"docs/x.md","line":1}, ...}
Defensive patterns

Strategy: validation

Validate before calling

import { readFileSync } from 'node:fs';
function oversizedLines(path) {
  return readFileSync(path, 'utf8')
    .split('\n')
    .reduce((acc, line, i) => (Buffer.byteLength(line) > 16_384 ? [...acc, i + 1] : acc), []);
}

Try / catch

try {
  const brain = loadBrain(path);
} catch (error) {
  if (error.message.includes('exceeds 16 KiB')) {
    console.error(`oversized line: ${error.message} — trim or split the record`);
    process.exit(1);
  }
  throw error;
}

Prevention

When it happens

Trigger: A record whose content field has many multibyte characters (8192 chars x up to 4 bytes each), long tag arrays, strings full of escaped quotes, or two records accidentally concatenated onto one line.

Common situations: Non-English record content, pasted log excerpts with dense escaping, hand-merged lines.

Related errors


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