Hmbown/CodeWhale · error · PersistenceBacklogError
receipt source_dirty must be boolean
Error message
receipt source_dirty must be boolean
What it means
Raised in validate_receipt (scripts/check-persistence-backlog-budget.py:157-158) when type(receipt["source_dirty"]) is not bool. The flag records whether the source tree was dirty at measurement time and is later compared with a live `git status`, so a JSON true/false boolean is mandatory — the check uses exact type() to reject Python/JSON look-alikes.
Source
Thrown at scripts/check-persistence-backlog-budget.py:158
require_clean_source: bool = False,
) -> None:
missing = [field for field in REQUIRED_RECEIPT_FIELDS if field not in receipt]
if missing:
raise PersistenceBacklogError(
"receipt missing required field(s): " + ", ".join(missing)
)
if receipt["document_kind"] != RECEIPT_KIND:
raise PersistenceBacklogError(f"receipt document_kind must be {RECEIPT_KIND}")
if receipt["schema_version"] != SCHEMA_VERSION:
raise PersistenceBacklogError("receipt schema_version changed")
for field, expected in FIXTURE.items():
validate_frozen_field(field, receipt[field], expected)
if not isinstance(receipt["source_sha"], str) or not SOURCE_SHA_PATTERN.fullmatch(
receipt["source_sha"]
):
raise PersistenceBacklogError("receipt source_sha must be an exact lowercase Git SHA")
if type(receipt["source_dirty"]) is not bool:
raise PersistenceBacklogError("receipt source_dirty must be boolean")
for field, prefix in (("rustc_version", "rustc "), ("cargo_version", "cargo ")):
if not isinstance(receipt[field], str) or not receipt[field].startswith(prefix):
raise PersistenceBacklogError(f"receipt {field} must be a version string")
validate_frozen_field("build_profile", receipt["build_profile"], "test")
validate_frozen_field("sample_count", receipt["sample_count"], 1)
if expected_source is not None:
for field in (
"source_sha",
"source_dirty",
"rustc_version",
"cargo_version",
"build_profile",
"sample_count",
):
if receipt[field] != expected_source[field]:
raise PersistenceBacklogError(
f"receipt {field} does not match the checked source"
)View on GitHub (pinned to 8880682c63)
Solutions
- Fix the Rust receipt writer to emit a real JSON boolean (parse the env string with =="true").
- Regenerate the receipt after the fix.
- Never hand-edit source_dirty to work around a dirty-tree failure — clean the tree instead.
Example fix
// receipt (before) "source_dirty": "false" // receipt (after) "source_dirty": false
Defensive patterns
Strategy: type-guard
Validate before calling
if type(receipt.get("source_dirty")) is not bool:
sys.exit("source_dirty must be a JSON boolean; fix the emitter's env parsing") Type guard
def is_strict_bool(value) -> bool:
return type(value) is bool Try / catch
try:
validate_receipt(receipt)
except PersistenceBacklogError as e:
if "source_dirty must be boolean" in str(e):
raise RuntimeError("emitter leaked a string boolean; parse env with == 'true'") from e
raise Prevention
- Parse CODEWHALE_TEST_PERSISTENCE_BACKLOG_SOURCE_DIRTY with == "true" into a bool in the Rust test.
- Serialize receipts with a real JSON serializer, never string templating.
- Include boolean-typed smoke checks in emitter unit tests.
When it happens
Trigger: The emitter storing the string "true"/"false" instead of a boolean (the measure script passes the env var CODEWHALE_TEST_PERSISTENCE_BACKLOG_SOURCE_DIRTY as lowercase text and the Rust test must parse it back to a bool); null; 0/1 integers.
Common situations: Env-var provenance plumbing where the string reaches the JSON unconverted; hand-edited receipts; serializers that coerce booleans to strings.
Related errors
- rss_supported must be boolean
- Codewhale terminal receipt exceeded its total bound
- Codewhale stream-json line {line_number} was not an object
- invalid {label} {path}: {error}
- {label} must be a JSON object
AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16).
Data as JSON: /api/errors/e8ac6c5a5fdebbd3.
Report an issue: GitHub.