JuliusBrussee/caveman · error

cave_invalid_lock:shape

cave_invalid_lock:shape

Error message

cave_invalid_lock:shape

What it means

Raised by parseCaveBuildLock (with reason 'shape') when the caveman build lock file parses as JSON but its structure is wrong: wrong schema_version, missing context_ir_schema, or harness/runtime/evidence sub-objects with missing keys, extra keys, or disallowed harness ids. A guard against proceeding on a malformed lock.

Solutions

  1. Regenerate the lock with a fresh caveman build instead of hand-editing it
  2. Upgrade caveman so its writer and reader agree on the lock schema
  3. Delete the stale lock file and rebuild from the current agent definition
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/agent/src/build.ts:507 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/5e5ce860f5b7f40b. Report an issue: GitHub.

Appendix: source

Thrown at packages/agent/src/build.ts:507

  if (lock.context_ir_sha256 !== current.contextIRSha256) stale.push("context_ir");
  if (lock.eval_suite_sha256 !== current.evalSuiteSha256) stale.push("eval_suite");
  if (lock.runtime.caveman_version !== current.runtimeVersion) stale.push("runtime");
  if (lock.harness.adapter_version !== current.adapterVersion) stale.push("adapter");
  if (lock.harness.upstream_version !== current.upstreamVersion) stale.push("upstream");
  if (lock.runtime.transform_registry_sha256 !== current.transformRegistrySha256) stale.push("transform_registry");
  if (lock.runtime.external_provenance_sha256 !== (current.externalProvenanceSha256 ?? "")) stale.push("external_provenance");
  if (lock.catalog_sha256 !== current.catalogSha256) stale.push("catalog");
  return { valid: stale.length === 0, stale };
}

export function parseCaveBuildLock(value: unknown): CaveBuildLock {
  if (!isRecord(value) || !exactKeys(value, [
    "schema_version", "agent_id", "build_sha256", "plan_sha256", "source_sha256",
    "agent_definition_sha256", "context_ir_sha256", "eval_suite_sha256",
    "context_ir_schema", "harness", "runtime", "catalog_sha256",
    "baseline_plan_id", "selected_plan_id", "selected_plan", "evidence",
  ])) {
    throw new Error("cave_invalid_lock:shape");
  }
  const lock = value as unknown as CaveBuildLock;
  if (lock.schema_version !== 2 || lock.context_ir_schema !== "1" ||
      !isRecord(lock.harness) || !exactKeys(lock.harness, ["id", "adapter_version", "upstream_version"]) ||
      !["pi", "claude", "vercel-ai-sdk", "eve", "mastra"].includes(lock.harness.id) ||
      !isRecord(lock.runtime) || !exactKeys(lock.runtime, ["caveman_version", "transform_registry_sha256", "external_provenance_sha256"]) ||
      !isRecord(lock.evidence) || !exactKeys(lock.evidence, [
        "status", "basis", "quality_retention_lcb95", "error_rate", "p95_latency_ms",
        "catalog_cost_usd_per_task", "completed_runs",
      ]) ||
      lock.evidence.status !== "locked" || lock.evidence.basis !== "inferred" ||
      !isRecord(lock.selected_plan) || !exactKeys(lock.selected_plan, [
        "schema_version", "plan_id", "model", "reasoning", "segment_routes",
        "budgets", "recovery", "fallbacks",
      ]) || !validPlanShape(lock.selected_plan)) {
    throw new Error("cave_invalid_lock:shape");
  }
  const integrity = lockIntegrityErrors(lock);

View on GitHub (pinned to 3ee70a1026)