{"record":{"id":"f45e7ce5ace6340f","repo":"Hmbown/CodeWhale","slug":"unsupported-pet-expression-version-sim","errorCode":null,"errorMessage":"Unsupported pet expression version.","messagePattern":"Unsupported pet expression version\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/src/core/pet-sim.ts","lineNumber":286,"sourceCode":"// Fixed reduced-motion clock per channel, so ticks still point along the gait.\nconst STILL_T: Record<string, number> = {\n  reasoning: 1.15, memory: 0.42, tool: 0.30, code: 0.18, filesystem: 0.48,\n  network: 0.72, browser: 0.95, communication: 0.58, agent: 1.25,\n  orchestration: 0.85, error: 0.35, human: 0.05, other: 0.90,\n};\n\nexport class PetSim {\n  readonly p: Particle[];\n  private phase = 0;\n  private clock = 0;\n  private tear = 0;\n  private prev: number;\n  private col = [...REST_RGB];\n  private cur: number;\n  frame: Frame = { r: REST_RGB[0], g: REST_RGB[1], b: REST_RGB[2], alpha: 0.3, hollow: false, channel: 'reasoning', arch: 'gyre', work: 0 };\n\n  constructor(points: [number, number][], seed = 0xC0FFEE, readonly expressionVersion: 1 | 2 = 2) {\n    if (expressionVersion !== 1 && expressionVersion !== 2) throw new Error('Unsupported pet expression version.');\n    const rand = mulberry32(seed);\n    this.p = points.map(([hx, hy], i) => {\n      const q: Particle = {\n        x: hx, y: hy, vx: 0, vy: 0,\n        s: rand(), jx: rand() * 6.283, jy: rand() * 6.283, pod: i % 6,\n        hx, hy, ang: 0, rad: 0, tail: 0, tx: hx, ty: hy,\n      };\n      q.ang = Math.atan2(hy, hx);\n      q.rad = Math.hypot(hx, hy);\n      q.tail = clamp(((-hx - hy) * 0.5 + 0.22) / 0.62);\n      return q;\n    });\n    this.cur = this.prev = CHANNEL_INDEX['reasoning'];\n  }\n\n  checkpoint(): PetSimCheckpoint {\n    return { version: 1, expressionVersion: this.expressionVersion, body: this.p.map(p => [p.hx, p.hy, p.s]),\n      particles: this.p.map(p => [p.x, p.y, p.vx, p.vy, p.jx, p.jy, p.tx, p.ty]),","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/src/core/pet-sim.ts#L268-L304","documentation":"The Pet particle simulation constructor accepts only expression versions 1 and 2 (the default). This guard throws immediately when a caller passes any other expressionVersion, rejecting models the renderer cannot draw.","triggerScenarios":"Calling `new PetSim(points, seed, version)` with a version other than 1 or 2 — e.g. 0, 3, NaN, or a version read from a saved pet file that was produced by a newer build.","commonSituations":"Loading pets persisted by a newer app version that emits expression version 3; passing a user-controlled or config-supplied version number without clamping; typos like passing a string '2' that gets compared by !==.","solutions":["Pass 1 or 2 (or omit the argument to use the default 2) when constructing PetSim","If the version came from persisted state, migrate or clamp it to a supported value before constructing","Update the library if you need support for a newer expression version"],"exampleFix":"// before\nnew PetSim(points, seed, petFile.expressionVersion); // e.g. 3\n// after\nconst version = petFile.expressionVersion === 1 ? 1 : 2;\nnew PetSim(points, seed, version);","handlingStrategy":"validation","validationCode":"const SUPPORTED = [1, 2];\nif (!SUPPORTED.includes(petVersion)) throw new Error(`Pet expression version ${petVersion} not supported; use 1 or 2`);","typeGuard":"function isSupportedExpressionVersion(v: unknown): v is 1 | 2 {\n  return v === 1 || v === 2;\n}","tryCatchPattern":"try {\n  const pet = new PetSim(points, seed, version);\n} catch (e) {\n  if (e.message === 'Unsupported pet expression version.') {\n    pet = new PetSim(points, seed, 2); // fall back to default version\n  } else throw e;\n}","preventionTips":["Persist the expression version with each pet and migrate on load","Clamp or normalize any externally supplied version before constructing","Let the parameter default (2) apply unless you specifically need v1"],"tags":["validation","versioning","constructor"],"backgroundTag":"unsupported-enum-value","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-22T16:17:23.217Z"}