{"record":{"id":"e8fb9ceb657e0cba","repo":"ruvnet/ruflo","slug":"sections-prev-id-and-curr-id-overlap","errorCode":null,"errorMessage":"Sections \"${prev.id}\" and \"${curr.id}\" overlap (${prev.offset}+${prev.size} > ${curr.offset})","messagePattern":"Sections \"(.+?)\" and \"(.+?)\" overlap \\((.+?)\\+(.+?) > (.+?)\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/cli/src/appliance/rvfa-format.ts","lineNumber":374,"sourceCode":"    for (const sec of header.sections) {\n      if (sec.offset < 0 || sec.size < 0) {\n        throw new Error(`Section \"${sec.id}\" has negative offset or size`);\n      }\n      if (sec.offset + sec.size > totalSize - SHA256_SIZE) {\n        throw new Error(\n          `Section \"${sec.id}\" extends beyond buffer ` +\n            `(offset=${sec.offset}, size=${sec.size}, bufLen=${totalSize})`,\n        );\n      }\n    }\n\n    // Check for overlapping sections\n    const sorted = [...header.sections].sort((a, b) => a.offset - b.offset);\n    for (let i = 1; i < sorted.length; i++) {\n      const prev = sorted[i - 1];\n      const curr = sorted[i];\n      if (prev.offset + prev.size > curr.offset) {\n        throw new Error(\n          `Sections \"${prev.id}\" and \"${curr.id}\" overlap ` +\n            `(${prev.offset}+${prev.size} > ${curr.offset})`,\n        );\n      }\n    }\n\n    return new RvfaReader(buf, header);\n  }\n\n  /** Read an RVFA image from a file path. */\n  static async fromFile(path: string): Promise<RvfaReader> {\n    if (path.includes('\\0')) {\n      throw new Error('Path contains null bytes');\n    }\n    const data = await readFile(path);\n    return RvfaReader.fromBuffer(data);\n  }\n","sourceCodeStart":356,"sourceCodeEnd":392,"githubUrl":"https://github.com/ruvnet/ruflo/blob/6b01dc5a687b26b3e218f796de45ec51f8fa9e8c/v3/@claude-flow/cli/src/appliance/rvfa-format.ts#L356-L392","documentation":"Thrown by RvfaReader.fromBuffer() during the overlap check: after sorting sections by offset, two adjacent sections' byte ranges intersect (prev.offset + prev.size > curr.offset). The format requires non-overlapping, contiguous-ish sections, so an overlap indicates corrupt offsets or a tampered header. The message names both sections and shows the arithmetic.","triggerScenarios":"Two sections in the header whose [offset, offset+size) ranges overlap. Caused by corrupted offset/size fields, a writer bug that double-assigned an offset, or a hand-edited header.","commonSituations":"A buggy custom writer that did not advance the cursor between sections; bit-rot that shifted an offset; a header spliced from two different appliances; adversarial input designed to confuse extraction.","solutions":["Regenerate the appliance with RvfaWriter.build() which computes non-overlapping offsets iteratively.","Inspect the section table to confirm offsets are strictly increasing and non-overlapping.","Discard hand-edited or third-party appliances whose offsets were not validated.","If debugging a writer, ensure each section's offset = previous offset + previous size."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import { validateHeader } from './rvfa-format.js';\nfunction sectionsDoNotOverlap(buf: Buffer): boolean {\n  const hLen = buf.readUInt32LE(8);\n  const parsed = JSON.parse(buf.subarray(12, 12 + hLen).toString('utf-8'));\n  if (!validateHeader(parsed)) return false;\n  const sorted = [...(parsed as any).sections].sort((a: any, b: any) => a.offset - b.offset);\n  for (let i = 1; i < sorted.length; i++) {\n    if (sorted[i - 1].offset + sorted[i - 1].size > sorted[i].offset) return false;\n  }\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  const reader = RvfaReader.fromBuffer(buf);\n} catch (e) {\n  if (/overlap/.test((e as Error).message)) {\n    throw new Error('Section offsets overlap; the header is corrupt or was produced by a buggy writer');\n  }\n  throw e;\n}","preventionTips":["Use RvfaWriter.build() which computes non-overlapping offsets iteratively.","In custom writers, advance cursor = prev.offset + prev.size for each section.","Never splice section tables from different appliances.","Validate offset monotonicity before serializing a header."],"tags":["rvfa","section","overlap","integrity"],"backgroundTag":null,"analyzedSha":"6b01dc5a687b26b3e218f796de45ec51f8fa9e8c","analyzedAt":"2026-08-12T13:20:50.148Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}