{"record":{"id":"8d361ec6b7ae39e8","repo":"JuliusBrussee/caveman","slug":"cave-harness-upstream-version-mismatch-8d361e","errorCode":"cave_${harness}_upstream_version_mismatch","errorMessage":"cave_${harness}_upstream_version_mismatch","messagePattern":"cave_(.+?)_upstream_version_mismatch","errorType":"error_code","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/adapters.ts","lineNumber":592,"sourceCode":"\nfunction assertSupportedUpstream(\n  identity: HarnessAdapterIdentity,\n  expected: string,\n  harness: string,\n  pkg: string,\n): void {\n  // The pin is enforced against the INSTALLED version, and the caller's claimed\n  // upstreamVersion must match what is actually installed — a claim alone can no\n  // longer authorize execution.\n  const installed = installedPackageVersion(pkg);\n  if (installed === undefined) {\n    throw new Error(`cave_${harness}_upstream_version_unresolvable`);\n  }\n  if (installed !== expected) {\n    throw new Error(`cave_${harness}_upstream_version_unsupported`);\n  }\n  if (identity.upstreamVersion !== installed) {\n    throw new Error(`cave_${harness}_upstream_version_mismatch`);\n  }\n}\n\nfunction canonicalRecord(value: Readonly<Record<string, unknown>>): Readonly<Record<string, unknown>> {\n  let encoded: string;\n  try {\n    encoded = stableStringify(value);\n  } catch {\n    throw new Error(\"cave_harness_wire_contract_invalid\");\n  }\n  const decoded = JSON.parse(encoded) as unknown;\n  if (!isRecord(decoded)) throw new Error(\"cave_harness_wire_contract_invalid\");\n  return decoded;\n}\n\nfunction deepFreeze<T>(value: T): T {\n  if (value !== null && typeof value === \"object\") {\n    Object.freeze(value);","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/agent/src/adapters.ts#L574-L610","documentation":"The installed package matches the exact pin, but the upstreamVersion string in the HarnessAdapterIdentity you passed to the factory does not equal the installed version. The pin is enforced against what is actually installed and the caller's claim must match it — a claim alone can no longer authorize execution.","triggerScenarios":"Passing identity.upstreamVersion \"7.0.42\" (or a hand-typed/README-copied string) to createVercelAISDKAdapter while ai@7.0.43 is installed; reusing an identity object recorded from an older build; generating identity from a config value that drifted from package.json.","commonSituations":"Hardcoding the version in two places (identity and package.json) and updating only one; CI caching identity snapshots; a deploy template with a stale version string.","solutions":["Build identity.upstreamVersion from the exported constants (VERCEL_AI_SDK_VERSION, EVE_VERSION, MASTRA_VERSION) instead of typing it","Or read the installed version at startup from the package's own package.json and feed that into the identity","Keep a single source of truth for the pin and fail CI when package.json disagrees with it"],"exampleFix":"// before\nconst identity = { adapterVersion: \"1.0.0\", upstreamVersion: \"7.0.42\", ... };\nconst adapter = createVercelAISDKAdapter(identity, agent); // throws cave_vercel_upstream_version_mismatch\n\n// after\nimport { VERCEL_AI_SDK_VERSION } from \"@caveman-ai/agent\";\nconst identity = { adapterVersion: \"1.0.0\", upstreamVersion: VERCEL_AI_SDK_VERSION, ... };","handlingStrategy":"validation","validationCode":"// Derive the identity's claim from the same source as the pin.\nimport { VERCEL_AI_SDK_VERSION } from \"@caveman-ai/agent\";\nconst identity = {\n  adapterVersion: pkg.version,\n  upstreamVersion: VERCEL_AI_SDK_VERSION, // never hand-typed\n  /* ... */\n};","typeGuard":null,"tryCatchPattern":"try {\n  const adapter = createMastraAdapter(identity, agent, opts);\n} catch (error) {\n  if (error instanceof Error && error.message.endsWith(\"_upstream_version_mismatch\")) {\n    // identity.upstreamVersion disagrees with the installed pin;\n    // rebuild the identity from the exported version constant.\n  }\n  throw error;\n}","preventionTips":["Build HarnessAdapterIdentity.upstreamVersion from the exported constants at runtime","Never persist identity objects across dependency upgrades","Treat version strings as code: update them in the same commit as package.json"],"tags":["dependency","version-pin","adapter-identity","adapter"],"backgroundTag":"dependency-version-mismatch","analyzedSha":"766dce6b1394ebb56a3090748d5a0240a5aefb36","analyzedAt":"2026-08-18T03:14:35.516Z","contentChangedAt":"2026-08-18T03:14:35.516Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}