{"record":{"id":"09ca0b92a551ccae","repo":"ruvnet/RuView","slug":"brain-line-index-1-exceeds-16-kib-09ca0b","errorCode":null,"errorMessage":"brain line ${index + 1}: exceeds 16 KiB","messagePattern":"brain line (.+?): exceeds 16 KiB","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"harness/ruview/src/brain.js","lineNumber":47,"sourceCode":"    errors.push('source.path and positive source.line are required');\n  } else if (isAbsolute(record.source.path) || record.source.path.split(/[\\\\/]/).includes('..') || /^[A-Za-z]:/.test(record.source.path)) {\n    errors.push('source.path must be repository-relative without traversal');\n  }\n  if (!Array.isArray(record.tags) || record.tags.some((tag) => typeof tag !== 'string')) errors.push('tags must be strings');\n  if ((record.content || '').length > 8192) errors.push('content exceeds 8192 characters');\n  if ((record.title || '').length > 200) errors.push('title exceeds 200 characters');\n  if (canonical && record.reviewed !== true) errors.push('canonical records must be reviewed');\n  const combined = `${record.title || ''}\\n${record.content || ''}`;\n  if (SECRET.test(combined)) errors.push('record appears to contain a secret');\n  if (INJECTION.test(combined)) errors.push('record contains instruction-like prompt injection');\n  return errors;\n}\n\nexport function loadBrain(path = CORPUS_PATH) {\n  const raw = readFileSync(path, 'utf8').replace(/\\r\\n/g, '\\n');\n  if (Buffer.byteLength(raw) > 1_048_576) throw new Error('brain corpus exceeds 1 MiB');\n  const records = raw.split('\\n').filter(Boolean).map((line, index) => {\n    if (Buffer.byteLength(line) > 16_384) throw new Error(`brain line ${index + 1}: exceeds 16 KiB`);\n    let record;\n    try { record = JSON.parse(line); } catch (error) { throw new Error(`brain line ${index + 1}: ${error.message}`); }\n    const errors = validateBrainRecord(record, { canonical: true });\n    if (errors.length) throw new Error(`brain line ${index + 1}: ${errors.join('; ')}`);\n    return Object.freeze(record);\n  });\n  if (records.length > 1000) throw new Error('brain corpus exceeds 1000 records');\n  const ids = new Set();\n  for (const record of records) {\n    if (ids.has(record.id)) throw new Error(`duplicate brain id: ${record.id}`);\n    ids.add(record.id);\n  }\n  return { records, digest: sha256(raw), bytes: Buffer.byteLength(raw) };\n}\n\nfunction terms(value) {\n  return new Set(String(value).toLowerCase().match(/[a-z0-9][a-z0-9_-]{1,}/g) || []);\n}","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/ruvnet/RuView/blob/4685618388a5e49fad5b3005806f3bdd6a7c25c3/harness/ruview/src/brain.js#L29-L65","documentation":"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.","triggerScenarios":"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.","commonSituations":"Non-English record content, pasted log excerpts with dense escaping, hand-merged lines.","solutions":["Open core.jsonl at the reported line number and split or trim the record","Keep content concise and prefer ASCII where possible","Find all oversized lines: awk 'length($0) > 16384 {print NR}' harness/ruview/brain/corpus/core.jsonl"],"exampleFix":"// before (line 214 of core.jsonl, one 17 KB line)\n{\"id\":\"big-lesson\",\"content\":\"<8192 multibyte characters>\", ...}\n\n// after\n{\"id\":\"big-lesson\",\"content\":\"<trimmed summary>\",\"source\":{\"path\":\"docs/x.md\",\"line\":1}, ...}","handlingStrategy":"validation","validationCode":"import { readFileSync } from 'node:fs';\nfunction oversizedLines(path) {\n  return readFileSync(path, 'utf8')\n    .split('\\n')\n    .reduce((acc, line, i) => (Buffer.byteLength(line) > 16_384 ? [...acc, i + 1] : acc), []);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const brain = loadBrain(path);\n} catch (error) {\n  if (error.message.includes('exceeds 16 KiB')) {\n    console.error(`oversized line: ${error.message} — trim or split the record`);\n    process.exit(1);\n  }\n  throw error;\n}","preventionTips":["Remember content is capped in characters (8192) but lines are capped in bytes — multibyte text can quadruple byte size","Run a line-length check on core.jsonl before committing","Avoid pasting escape-heavy log dumps into record content"],"tags":["validation","data-limits","jsonl","brain","ruview"],"backgroundTag":null,"analyzedSha":"4685618388a5e49fad5b3005806f3bdd6a7c25c3","analyzedAt":"2026-08-16T06:09:40.886Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}