{"record":{"id":"2b8d969a1c76e5a3","repo":"pbakaus/impeccable","slug":"concept-seed-candidate-count-must-be-an-integer","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":null,"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/f88b2837a7d7c3182e46307bbbb091a1ed547571/skill/scripts/concept-seed.mjs#L315-L351","documentation":"Thrown by the concept-seed script when --candidate-count is not an integer between 5 and 7 inclusive. The value is read naively via args.indexOf('--candidate-count') followed by Number(args[i+1]), so a missing value yields Number(undefined) = NaN and the equals form --candidate-count=6 is not recognized at all. The 5-7 band is deliberate: fewer than 5 candidates starves the ranked roll, more than 7 bloats the model's consideration set. Default is 7 when the flag is omitted.","triggerScenarios":"Running `node skill/scripts/concept-seed.mjs --scope direction --candidate-count 4` (or 8, or 5.5, or 'six'); passing `--candidate-count` as the last argument (next token undefined -> NaN); using `--candidate-count=6` (the indexOf-based parser does not recognize the = form, so it reads the next token or undefined); passing a value like '6x' that Number() coerces to NaN.","commonSituations":"Agent or user tuning the seed hand size; copy-pasting a command template that used = syntax; truncating the command line so the value falls off; scripting the call and interpolating an empty variable (`--candidate-count $COUNT` with COUNT unset).","solutions":["Pass a plain space-separated integer in range: `--candidate-count 6`.","Omit the flag entirely to get the default of 7.","If you used `--candidate-count=6`, rewrite it as `--candidate-count 6` — the equals form is silently parsed as NaN.","When scripting, quote and default the variable: `--candidate-count \"${COUNT:-7}\"` after validating COUNT is 5, 6, or 7."],"exampleFix":"# before\nnode skill/scripts/concept-seed.mjs --scope direction --candidate-count=6   # NaN -> throws\nnode skill/scripts/concept-seed.mjs --scope direction --candidate-count    # value missing -> throws\n\n# after\nnode skill/scripts/concept-seed.mjs --scope direction --candidate-count 6\nnode skill/scripts/concept-seed.mjs --scope direction                      # default 7","handlingStrategy":"validation","validationCode":"const SEED_COUNT_RE = /^[5-7]$/;\nfunction validCandidateCount(raw) {\n  return raw == null || (typeof raw === 'string' && SEED_COUNT_RE.test(raw.trim()));\n}\n// before shelling out:\nif (!validCandidateCount(process.env.CANDIDATE_COUNT)) {\n  console.error('--candidate-count must be 5, 6, or 7 (space-separated)');\n  process.exit(2);\n}\nspawnSync('node', ['skill/scripts/concept-seed.mjs', '--scope', 'direction', '--candidate-count', COUNT]);","typeGuard":"function isValidSeedCount(v) {\n  return v == null || (typeof v === 'number' && Number.isInteger(v) && v >= 5 && v <= 7);\n}","tryCatchPattern":null,"preventionTips":["Always pass --candidate-count as a separate space-separated token; the parser does not understand --candidate-count=6.","Default unset shell variables with ${COUNT:-7} before using them as the flag value.","When wrapping the script, validate the count is one of 5/6/7 before spawning the child process."],"tags":["cli","argument-validation","concept-seed","range-check"],"backgroundTag":"cli-argument-out-of-range","analyzedSha":"f88b2837a7d7c3182e46307bbbb091a1ed547571","analyzedAt":"2026-08-18T04:58:36.608Z","contentChangedAt":"2026-08-18T04:58:36.608Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}