{"record":{"id":"34db8fa45ef6ad61","repo":"JuliusBrussee/caveman","slug":"cave-stale-lock-registration","errorCode":null,"errorMessage":"cave_stale_lock:registration","messagePattern":"cave_stale_lock:registration","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/agent/src/cli.ts","lineNumber":475,"sourceCode":"      available: Boolean(process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY),\n    };\n  }\n  return { name: `credential for ${provider || \"unknown provider\"}`, available: false };\n}\n\nasync function register(_args: string[]): Promise<void> {\n  const root = process.cwd();\n  const controlURL = process.env.CAVE_CONTROL_URL?.replace(/\\/+$/, \"\");\n  const token = process.env.CAVE_TOKEN ?? process.env.CAVE_API_TOKEN;\n  const projectID = process.env.CAVE_PROJECT_ID;\n  if (!controlURL || !token || !projectID) {\n    throw new Error(\"register requires CAVE_CONTROL_URL, CAVE_TOKEN, and CAVE_PROJECT_ID\");\n  }\n  const lock = await readLock(root);\n  const loaded = await loadBuildInputs(root, \"caveman.config.ts\");\n  const checked = await validLockIdentity(root, loaded.config.entry);\n  if (!checked || checked.build_sha256 !== lock.build_sha256) {\n    throw new Error(\"cave_stale_lock:registration\");\n  }\n  const response = await fetch(`${controlURL}/api/v1/projects/${encodeURIComponent(projectID)}/agent-builds`, {\n    method: \"POST\",\n    headers: {\n      authorization: `Bearer ${token}`,\n      \"content-type\": \"application/json\",\n    },\n    body: JSON.stringify({\n      agent_slug: lock.agent_id,\n      build_sha256: lock.build_sha256,\n      plan_sha256: lock.plan_sha256,\n      source_sha256: lock.source_sha256,\n      eval_suite_sha256: lock.eval_suite_sha256,\n      catalog_sha256: lock.catalog_sha256,\n      transform_registry_sha256: lock.runtime.transform_registry_sha256,\n      harness: lock.harness.id,\n      adapter_version: lock.harness.adapter_version,\n      upstream_version: lock.harness.upstream_version,","sourceCodeStart":457,"sourceCodeEnd":493,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/766dce6b1394ebb56a3090748d5a0240a5aefb36/packages/agent/src/cli.ts#L457-L493","documentation":"Staleness guard in register: the local .caveman lock (agent.lock.json) was built by a different caveman version/state than the current one, so registering it would sign unverified hashes. The 'registration' scope tag names the operation.","triggerScenarios":"Thrown at packages/agent/src/cli.ts:475 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-run npm run build (or caveman-agent build) to regenerate the lock with the current toolchain","Upgrade/downgrade so the building and registering versions match","Delete the stale .caveman/agent.lock.json and rebuild from scratch"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}