Hmbown/CodeWhale · error · PersistenceBacklogError
measurement command failed
Error message
measurement command failed
What it means
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.
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 8880682c63)
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
Example fix
# before python3 scripts/check-persistence-backlog-budget.py # ERROR: measurement command failed # after cargo fetch git stash --include-untracked python3 scripts/measure-persistence-backlog.py && python3 scripts/check-persistence-backlog-budget.py
Defensive patterns
Strategy: try-catch
Validate before calling
import shutil
assert shutil.which('cargo') and shutil.which('rustc'), 'toolchain missing'
subprocess.run(['cargo', 'fetch'], cwd=ROOT, check=True) # warm the offline cache Try / catch
try:
receipt = measure()
except PersistenceBacklogError:
# child stderr/stdout were already forwarded above; fix the root cause there
raise Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- runtime-contract measurement failed with exit code {proc.ret
- measurement emitted invalid JSON: {error}
- exact library metric test {metric_test_name(test_name)} ran
- missing {marker.rstrip()} marker from exact library metric t
- failed to read git range {commit_range!r}: {exc}
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/99f4d0a1b5fef109.
Report an issue: GitHub.