{"record":{"id":"99f4d0a1b5fef109","repo":"Hmbown/CodeWhale","slug":"measurement-command-failed","errorCode":null,"errorMessage":"measurement command failed","messagePattern":"measurement command failed","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":386,"sourceCode":"            decreases.append((field, current, ceiling))\n    return increases, decreases\n\n\ndef measure() -> dict[str, Any]:\n    env = os.environ.copy()\n    env[\"CARGO_NET_OFFLINE\"] = \"true\"\n    result = subprocess.run(\n        [sys.executable, str(MEASURE_SCRIPT)],\n        cwd=ROOT,\n        env=env,\n        text=True,\n        capture_output=True,\n        check=False,\n    )\n    sys.stderr.write(result.stderr)\n    if result.returncode != 0:\n        sys.stdout.write(result.stdout)\n        raise PersistenceBacklogError(\"measurement command failed\")\n    try:\n        receipt = json.loads(result.stdout)\n    except json.JSONDecodeError as error:\n        raise PersistenceBacklogError(f\"measurement emitted invalid JSON: {error}\") from error\n    if not isinstance(receipt, dict):\n        raise PersistenceBacklogError(\"measurement receipt must be an object\")\n    return receipt\n\n\ndef main() -> int:\n    parser = argparse.ArgumentParser(description=__doc__)\n    parser.add_argument(\"--receipt\", type=Path, help=\"check an existing receipt\")\n    parser.add_argument(\"--budget\", type=Path, default=BUDGET_PATH)\n    args = parser.parse_args()\n    try:\n        expected_source = current_source_identity()\n        receipt = load_json(args.receipt, \"receipt\") if args.receipt else measure()\n        budget = load_json(args.budget, \"budget\")","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L368-L404","documentation":"measure() in scripts/check-persistence-backlog-budget.py runs scripts/measure-persistence-backlog.py as a subprocess with CARGO_NET_OFFLINE=true; this error means that child exited non-zero. The child's stderr is forwarded and its stdout printed before the raise, so the real failure (usually a cargo build/test problem or a dirty source tree) appears directly above this message. The wrapper deliberately converts any child failure into this single contract error.","triggerScenarios":"Invoking the checker without --receipt on a machine where the forced-offline cargo build fails because required crates are not in the local cache; a workspace compile error; the measure script's own validation failing (for example on a dirty git tree); rustc or cargo missing from PATH.","commonSituations":"First run on a fresh machine or CI container without `cargo fetch`; local uncommitted changes making the tree dirty; a broken commit in the workspace; toolchain not installed.","solutions":["Read the forwarded child output immediately above the error line — it contains the actual failure","Reproduce directly: `python3 scripts/measure-persistence-backlog.py`","Pre-populate the cargo cache with `cargo fetch` so the forced-offline build succeeds","Commit or stash local changes; the measurement requires a clean source tree","Fix any compile error the child reported, then re-run the checker"],"exampleFix":"# before\npython3 scripts/check-persistence-backlog-budget.py   # ERROR: measurement command failed\n# after\ncargo fetch\ngit stash --include-untracked\npython3 scripts/measure-persistence-backlog.py && python3 scripts/check-persistence-backlog-budget.py","handlingStrategy":"try-catch","validationCode":"import shutil\nassert shutil.which('cargo') and shutil.which('rustc'), 'toolchain missing'\nsubprocess.run(['cargo', 'fetch'], cwd=ROOT, check=True)  # warm the offline cache","typeGuard":null,"tryCatchPattern":"try:\n    receipt = measure()\nexcept PersistenceBacklogError:\n    # child stderr/stdout were already forwarded above; fix the root cause there\n    raise","preventionTips":["Run cargo fetch before offline-gated measurement","Keep the working tree clean when measuring","Run scripts/measure-persistence-backlog.py directly in CI setup so root causes surface with their own exit codes"],"tags":["python","subprocess","cargo","offline-build","ci"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}