Hmbown/CodeWhale · error · PersistenceBacklogError

measurement command failed

Error message

measurement command failed

What it means

measure() runs the measurement command via subprocess and this error is raised when that command exits with a non-zero return code. The receipt generation underlying the budget check failed before producing output; the command's stdout is flushed and its stderr was already forwarded so the real failure cause is visible in the log. This is a wrapper error — diagnose the underlying command, not this line.

Solutions

  1. Read the stderr echoed by the script immediately above this error to find the real failure
  2. Build/verify the measurement target manually (cargo build) before re-running the script
  3. Re-run the script from the repository root with a clean workspace
Defensive patterns

Strategy: try-catch

Try / catch

result = subprocess.run(cmd, capture_output=True)
if result.returncode != 0:
    sys.stderr.write(result.stderr)
    raise PersistenceBacklogError(f"measurement command failed: rc={result.returncode}")

Prevention

When it happens

Trigger: Running scripts/check-persistence-backlog-budget.py (without --receipt) when the subprocess that produces the measurement receipt exits non-zero — e.g. the measurement binary fails to build, the workspace has compile errors, or the measurement tool itself errors.

Common situations: Broken workspace state when the guard runs in CI; missing build artifacts; the measurement command path/config changed; running from a directory where the measurement command cannot execute.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@433685b202 (2026-09-15). Data as JSON: /api/errors/99f4d0a1b5fef109. Report an issue: GitHub.

Appendix: source

Thrown at scripts/check-persistence-backlog-budget.py:386

            decreases.append((field, current, ceiling))
    return increases, decreases


def measure() -> dict[str, Any]:
    env = os.environ.copy()
    env["CARGO_NET_OFFLINE"] = "true"
    result = subprocess.run(
        [sys.executable, str(MEASURE_SCRIPT)],
        cwd=ROOT,
        env=env,
        text=True,
        capture_output=True,
        check=False,
    )
    sys.stderr.write(result.stderr)
    if result.returncode != 0:
        sys.stdout.write(result.stdout)
        raise PersistenceBacklogError("measurement command failed")
    try:
        receipt = json.loads(result.stdout)
    except json.JSONDecodeError as error:
        raise PersistenceBacklogError(f"measurement emitted invalid JSON: {error}") from error
    if not isinstance(receipt, dict):
        raise PersistenceBacklogError("measurement receipt must be an object")
    return receipt


def main() -> int:
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument("--receipt", type=Path, help="check an existing receipt")
    parser.add_argument("--budget", type=Path, default=BUDGET_PATH)
    args = parser.parse_args()
    try:
        expected_source = current_source_identity()
        receipt = load_json(args.receipt, "receipt") if args.receipt else measure()
        budget = load_json(args.budget, "budget")

View on GitHub (pinned to 433685b202)