{"record":{"id":"334edd1680602eae","repo":"moeru-ai/airi","slug":"prerelease-sequence-overflow-for-stage-seque","errorCode":null,"errorMessage":"Prerelease sequence overflow for ${stage}: ${sequence} exceeds limit ${maxSequence}","messagePattern":"Prerelease sequence overflow for (.+?): (.+?) exceeds limit (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"integrations/vscode/vscode-airi/scripts/shared.ts","lineNumber":68,"sourceCode":"    throw new Error(`Invalid semver: ${version}`)\n\n  const major = Number.parseInt(match.groups.major, 10)\n  const minor = Number.parseInt(match.groups.minor, 10)\n  const patch = Number.parseInt(match.groups.patch, 10)\n  const prerelease = match.groups.pre\n\n  const multiplier = 10_000\n  const stageBuckets = {\n    alpha: 1_000,\n    beta: 2_000,\n    rc: 3_000,\n    stable: 9_000,\n  } as const\n\n  const { stage, sequence } = parsePrerelease(prerelease)\n  const maxSequence = (multiplier - 1) - stageBuckets[stage]\n  if (sequence > maxSequence) {\n    throw new Error(`Prerelease sequence overflow for ${stage}: ${sequence} exceeds limit ${maxSequence}`)\n  }\n  if (sequence < 0) {\n    throw new Error(`Prerelease sequence must be non-negative: ${sequence}`)\n  }\n\n  const encodedPatch = (patch * multiplier) + (stageBuckets[stage] ?? stageBuckets.alpha) + sequence\n  const encoded = `${major}.${minor}.${encodedPatch}`\n\n  return {\n    version: encoded,\n    preview: stage !== 'stable',\n  }\n}\n\nfunction parsePrerelease(prerelease?: string) {\n  if (!prerelease) {\n    return { stage: 'stable' as const, sequence: 0 }\n  }","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/moeru-ai/airi/blob/27111382b4a79a7e983289d6e983a06af185ed0f/integrations/vscode/vscode-airi/scripts/shared.ts#L50-L86","documentation":"After parsing the prerelease tag, encodeNumericVersion computes maxSequence = (multiplier-1) - stageBuckets[stage] (multiplier is 10_000). If the sequence number exceeds that cap, the encoded patch would collide with the next stage bucket, so the encoder refuses to produce an ambiguous version. For alpha (bucket 1000) the limit is 8998.","triggerScenarios":"Passing '1.2.3-alpha.9000' or higher; a long-running prerelease cycle (e.g. alpha build 9500); prerelease identifiers generated from a CI counter that grows unbounded within a single minor.","commonSituations":"CI build counters reset only on minor bumps; an alpha cycle runs far longer than expected; tooling appends a timestamp-derived large number as the sequence.","solutions":["Bump the minor or major version to reset the prerelease sequence headroom.","If the sequence is a build counter, reset it when moving past a stage or releasing.","Switch the stage forward (alpha -> beta -> rc) which is the intended progression and frees the lower bucket reuse safely.","Cap the CI counter fed into the prerelease identifier below the computed maxSequence."],"exampleFix":"// before\n// 0.8.0-alpha.9500 -> throws Prerelease sequence overflow\n\n// after\n// bump minor to reset headroom\n// 0.9.0-alpha.1 -> encodes cleanly\n// OR advance the stage\n// 0.8.0-beta.1 -> encodes cleanly","handlingStrategy":"validation","validationCode":"function maxSeqForStage(stage: 'alpha'|'beta'|'rc'|'stable') {\n  const buckets = { alpha: 1000, beta: 2000, rc: 3000, stable: 9000 }\n  return 9999 - buckets[stage]\n}\nif (sequence > maxSeqForStage(stage)) {\n  throw new Error(`Bump the minor version; ${stage}.${sequence} exceeds the encoder budget`)\n}","typeGuard":null,"tryCatchPattern":"try {\n  return encodeNumericVersion(version)\n}\ncatch (err) {\n  if (/overflow/i.test((err as Error).message)) {\n    // bump minor and retry with a reset sequence\n    return encodeNumericVersion(bumpMinor(version))\n  }\n  throw err\n}","preventionTips":["Reset CI build counters when bumping minor/major or advancing the prerelease stage.","Advance alpha -> beta -> rc -> stable rather than growing alpha indefinitely.","Cap the counter fed into the prerelease identifier below the stage budget."],"tags":["semver","overflow","vscode","build","versioning"],"backgroundTag":null,"analyzedSha":"27111382b4a79a7e983289d6e983a06af185ed0f","analyzedAt":"2026-08-12T18:33:34.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}