JuliusBrussee/caveman · error
invalid Decision Ledger response
Error message
invalid Decision Ledger response
What it means
`caveman why` parses the Decision Ledger response from the proxy (`native-why --decision <id>`) and validates the schema: it must be schema 'caveman.native.why.v1', match the requested decision_id, and include an object input_basis. Any mismatch raises this error before displaying an explanation.
Solutions
- Upgrade the CLI and proxy together so both use caveman.native.why.v1
- Confirm the --decision id exists in the current ledger (re-run the decision)
- Run the proxy command manually (`native-why --decision <id>`) and inspect the raw output for corruption
- Check proxy logs for an underlying failure producing the bad response
Defensive patterns
Strategy: try-catch
Validate before calling
function isNativeWhy(v: unknown): v is NativeWhy {
const p = v as NativeWhy;
return !!p && p.schema === 'caveman.native.why.v1' && typeof p.decision_id === 'string' && typeof p.input_basis === 'object';
} Type guard
const isNativeWhy = (v: unknown): v is NativeWhy => typeof v === 'object' && v !== null && (v as any).schema === 'caveman.native.why.v1' && typeof (v as any).input_basis === 'object';
Try / catch
try {
const parsed = JSON.parse(raw);
if (!isNativeWhy(parsed)) throw new Error('invalid Decision Ledger response');
} catch (e) {
// check proxy/CLI version skew and re-fetch the decision
} Prevention
- Keep CLI and proxy on the same version
- Validate decision ids exist before querying
- Log raw proxy output on parse failures
When it happens
Trigger: The proxy returned JSON that fails validation — wrong/missing schema field, decision_id mismatch, or non-object input_basis; also thrown by JSON.parse failures inside the same try (proxy returned non-JSON).
Common situations: Proxy and CLI version skew (different schema versions); passing a decision id from a different ledger; proxy returning an HTML/empty error page.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- canonical span
- cave_agent_definition_invalid
- cave_context_ir_invalid
- cave_output_schema_mismatch
- cave_output_schema_mismatch
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/43987809028dcc98.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:14138
line("unresolved assumptions", String(receipt.policy.unresolved_assumptions ?? 0));
console.log("\nClaim status");
line("compression reduction", receipt.claim_status.compression_reduction ?? "not_attested");
line("task savings", receipt.claim_status.task_savings ?? "not_verified");
}
function nativeWhy(argv: string[]) {
const json = argv.includes("--json");
const decisionID = argv.find((arg) => !arg.startsWith("--"));
if (!decisionID || !/^dec_[0-9a-f]{24}$/.test(decisionID)) {
console.error(`usage: ${invokedAs()} why <decision-id> [--json]`);
process.exitCode = 2;
return;
}
let explanation: NativeWhy;
try {
const parsed = JSON.parse(proxyExec(["native-why", "--decision", decisionID], process.env, false)) as NativeWhy;
if (parsed?.schema !== "caveman.native.why.v1" || parsed.decision_id !== decisionID || typeof parsed.input_basis !== "object") {
throw new Error("invalid Decision Ledger response");
}
explanation = parsed;
} catch (error) {
if (process.exitCode) return;
console.error(`caveman why: ${(error as Error).message}`);
process.exitCode = 1;
return;
}
if (json) {
print(explanation);
return;
}
const line = (label: string, value: string) => console.log(` ${label.padEnd(22)} ${value}`);
console.log(`Decision ${explanation.decision_id}`);
line("session", explanation.session_id);
line("action", explanation.action);
line("reason", explanation.reason);
line("input basis", JSON.stringify(explanation.input_basis));View on GitHub (pinned to 3ee70a1026)