{"record":{"id":"ee50bd1862fc90ab","repo":"can1357/oh-my-pi","slug":"array-length-must-be-even-the-weave-action-splits","errorCode":null,"errorMessage":"Array length must be even (the weave action splits it in half), got ${length}","messagePattern":"Array length must be even \\(the weave action splits it in half\\), got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/if-bench/actions.ts","lineNumber":44,"sourceCode":"\t| { kind: \"odd-even\" }\n\t| { kind: \"reverse-blocks\"; size: number }\n\t| { kind: \"rotate-span\"; first: number; last: number; amount: number }\n\t| { kind: \"weave\" };\n\n/**\n * Opening state: `A..Z` truncated to `length` and shuffled by a fixed LCG.\n *\n * Scrambled on purpose — an alphabetical start lets a model reconstruct state\n * from memory instead of reading its own previous answer.\n *\n * @throws when `length` is odd or outside [{@link MIN_ARRAY_LENGTH}, {@link MAX_ARRAY_LENGTH}].\n */\nexport function initialArray(length: number): string {\n\tif (!Number.isInteger(length) || length < MIN_ARRAY_LENGTH || length > MAX_ARRAY_LENGTH) {\n\t\tthrow new Error(`Array length must be an integer in [${MIN_ARRAY_LENGTH}, ${MAX_ARRAY_LENGTH}], got ${length}`);\n\t}\n\tif (length % 2 !== 0)\n\t\tthrow new Error(`Array length must be even (the weave action splits it in half), got ${length}`);\n\tconst chars = ALPHABET.slice(0, length).split(\"\");\n\tlet seed = 0x9e3779b9;\n\tfor (let i = chars.length - 1; i > 0; i -= 1) {\n\t\tseed = (Math.imul(seed, 1103515245) + 12345) >>> 0;\n\t\tconst j = seed % (i + 1);\n\t\t[chars[i], chars[j]] = [chars[j]!, chars[i]!];\n\t}\n\treturn chars.join(\"\");\n}\n\n/**\n * The `count` actions starting at absolute index `start`.\n *\n * The kind cycles every 10 indices so each turn mixes local edits (swap, move)\n * with whole-array permutations (weave, odd-even) that invalidate every\n * remembered position.\n */\nexport function makeActions(length: number, start: number, count: number): Action[] {","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/if-bench/actions.ts#L26-L62","documentation":"initialArray() additionally requires an even length because the weave benchmark action splits the array in half; an odd length would break that split. It throws this Error for any valid-range but odd length.","triggerScenarios":"Calling `omp if-bench --length N` (or initialArray(N) directly) with an odd integer N within the allowed min/max range, e.g. 7, 15, 33.","commonSituations":"Users picking arbitrary sizes unaware of the even-length invariant; generated benchmark matrices iterating over every integer in the range.","solutions":["Use an even --length value","When scripting, round to the nearest even number: length - (length % 2)","Step by 2 in parameter sweep loops over array lengths"],"exampleFix":"// before\nomp if-bench opus --length 15\n// after\nomp if-bench opus --length 16","handlingStrategy":"validation","validationCode":"if (length % 2 !== 0) {\n  throw new Error(\"--length must be even\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runIfBenchCommand({ models, flags: { length } });\n} catch (err) {\n  if (err instanceof Error && err.message.includes(\"must be even\")) {\n    console.error(\"Round --length to the nearest even value\");\n    process.exitCode = 1;\n  } else throw err;\n}","preventionTips":["Always pick even array lengths (the weave action halves the array)","Iterate lengths in steps of 2 in sweep scripts","Normalize input with length - (length % 2) before passing"],"tags":["cli","validation","invariant"],"backgroundTag":"invalid-parameter-value","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}