{"record":{"id":"2b8d969a1c76e5a3","repo":"pbakaus/impeccable","slug":"concept-seed-candidate-count-must-be-an-integer-2b8d96","errorCode":null,"errorMessage":"concept-seed: --candidate-count must be an integer from 5 to 7","messagePattern":"concept-seed: --candidate-count must be an integer from 5 to 7","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"skill/scripts/concept-seed.mjs","lineNumber":333,"sourceCode":"  if (register !== null && reroll < 1) {\n    throw new Error('concept-seed: --register steers a re-roll round; pass --reroll <n> with it');\n  }\n  if (register !== null && scope !== 'direction') {\n    throw new Error('concept-seed: --register applies to direction rounds only');\n  }\n  if (mode !== null && !SEED_MODES.has(mode)) {\n    throw new Error('concept-seed: --mode must be persuade, operate, read, or experience');\n  }\n  // Grain needs no mode: how much of the product is in play is independent of\n  // which register of work it is.\n  if (grain !== null && !COMPOSITION_GRAINS.includes(grain)) {\n    throw new Error(`concept-seed: --grain must be one of ${COMPOSITION_GRAINS.join(', ')}`);\n  }\n  if (platform !== null && !COMPOSITION_PLATFORMS.includes(platform)) {\n    throw new Error(`concept-seed: --platform must be one of ${COMPOSITION_PLATFORMS.join(', ')}`);\n  }\n  if (!Number.isInteger(candidateCount) || candidateCount < 5 || candidateCount > 7) {\n    throw new Error('concept-seed: --candidate-count must be an integer from 5 to 7');\n  }\n  const unit = (salt) => {\n    const h = crypto.createHash('sha256').update(`${scope}:${salt}:${key}`).digest();\n    return h.readUInt32BE(0) / 0xffffffff;\n  };\n  const indexSalt = reroll === 0 ? 'index' : `index:reroll-${reroll}`;\n  const buildIndex = 3 + Math.floor(unit(indexSalt) * (candidateCount - 2)); // 3..candidateCount\n  // Surface scope deals a hand of three grounded structures: one card is not\n  // a choice, and the full ranked list would hand selection back to the\n  // model's taste. The dice pick all three; the primary index leads. The\n  // no-lineup rule stays direction-only, where it was written for worlds.\n  const dealtIndices = [buildIndex];\n  for (let draw = 0; scope === 'surface' && dealtIndices.length < Math.min(3, candidateCount); draw += 1) {\n    const idx = 1 + Math.floor(unit(`${indexSalt}:deal-${draw}`) * candidateCount);\n    if (!dealtIndices.includes(idx)) dealtIndices.push(idx);\n    if (draw > 64) { // hash repeats cannot stall the deal\n      for (let fill = 1; dealtIndices.length < Math.min(3, candidateCount); fill += 1) {\n        if (!dealtIndices.includes(fill)) dealtIndices.push(fill);","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/pbakaus/impeccable/blob/d14711ae3d1a1dd62dee61a358d27f107c51ccd0/skill/scripts/concept-seed.mjs#L315-L351","documentation":"Thrown when `candidateCount` is not an integer in the closed range [5,7] (default 7). The count controls how many candidates the deterministic dice rank; the range is narrow by design so rolls stay comparable. Non-integers and values outside 5-7 are both rejected.","triggerScenarios":"Passing 3, 4, 8, or 10; passing a float like 6.5; passing candidateCount as a string from argv; computing the count dynamically and overshooting the range.","commonSituations":"A caller assuming any positive integer is fine; CLI forwarding an uncoerced string; a UI slider with a wider range than the function accepts.","solutions":["Pass exactly 5, 6, or 7.","Coerce and clamp at the CLI boundary: Math.min(7, Math.max(5, Math.round(n))).","If you genuinely need more candidates, that is a design change to the function, not a runtime tweak."],"exampleFix":"// before\nawait seedConcepts({ scope: 'surface', candidateCount: 10 });\n// before (string from CLI)\nawait seedConcepts({ scope: 'surface', candidateCount: argv['--candidate-count'] });\n\n// after\nawait seedConcepts({ scope: 'surface', candidateCount: 7 }); // 5|6|7 only","handlingStrategy":"validation","validationCode":"// Coerce and clamp candidateCount at the boundary.\nfunction parseCandidateCount(raw) {\n  const n = Math.round(Number(raw ?? 7));\n  if (!Number.isInteger(n) || n < 5 || n > 7) {\n    throw new Error('--candidate-count must be an integer from 5 to 7');\n  }\n  return n;\n}","typeGuard":"function isValidCandidateCount(v) {\n  return v == null || (Number.isInteger(v) && v >= 5 && v <= 7);\n}","tryCatchPattern":null,"preventionTips":["Pass only 5, 6, or 7 (default 7).","Coerce argv with Number() and Math.round, then range-check.","Needing >7 is a design change, not a runtime option."],"tags":["validation","concept-seed","cli","numeric","range"],"backgroundTag":null,"analyzedSha":"d14711ae3d1a1dd62dee61a358d27f107c51ccd0","analyzedAt":"2026-08-13T00:52:25.771Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}