{"record":{"id":"b55336006fbeabe4","repo":"Hmbown/CodeWhale","slug":"rss-after-delta-bytes-is-inconsistent","errorCode":null,"errorMessage":"rss_after_delta_bytes is inconsistent","messagePattern":"rss_after_delta_bytes is inconsistent","errorType":"exception","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":237,"sourceCode":"    if not isinstance(receipt[\"rss_supported\"], bool):\n        raise PersistenceBacklogError(\"rss_supported must be boolean\")\n    if receipt[\"rss_supported\"] != (platform == \"macos\"):\n        raise PersistenceBacklogError(\n            \"rss_supported must be true exactly on the macOS measurement lane\"\n        )\n    rss_fields = RSS_SAMPLE_FIELDS + RSS_DELTA_FIELDS\n    if receipt[\"rss_supported\"]:\n        for field in rss_fields:\n            non_negative_integer(receipt[field], field)\n        before = receipt[\"rss_before_bytes\"]\n        if receipt[\"rss_during_delta_bytes\"] != max(\n            0, receipt[\"rss_during_bytes\"] - before\n        ):\n            raise PersistenceBacklogError(\"rss_during_delta_bytes is inconsistent\")\n        if receipt[\"rss_after_delta_bytes\"] != max(\n            0, receipt[\"rss_after_bytes\"] - before\n        ):\n            raise PersistenceBacklogError(\"rss_after_delta_bytes is inconsistent\")\n    elif any(receipt[field] is not None for field in rss_fields):\n        raise PersistenceBacklogError(\"unsupported RSS fields must be null\")\n\n\ndef validate_budget(budget: dict[str, Any]) -> None:\n    if budget.get(\"document_kind\") != BUDGET_KIND:\n        raise PersistenceBacklogError(f\"budget document_kind must be {BUDGET_KIND}\")\n    if budget.get(\"schema_version\") != SCHEMA_VERSION:\n        raise PersistenceBacklogError(\"budget schema_version changed\")\n    fixture = budget.get(\"fixture\")\n    if not isinstance(fixture, dict) or set(fixture) != set(FIXTURE):\n        raise PersistenceBacklogError(\"budget fixture no longer matches the frozen workload\")\n    for field, expected in FIXTURE.items():\n        if type(fixture[field]) is not type(expected) or fixture[field] != expected:\n            raise PersistenceBacklogError(\n                f\"budget fixture.{field} must remain {expected!r}\"\n            )\n    if budget.get(\"baseline_receipt\") != BASELINE_RECEIPT_REFERENCE:","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/8880682c63083a91624de936797efa3ce9e498fd/scripts/check-persistence-backlog-budget.py#L219-L255","documentation":"Raised by validate_receipt() when a receipt with rss_supported=true records rss_after_delta_bytes that is not exactly max(0, rss_after_bytes - rss_before_bytes). As with the during-delta check, the three raw RSS samples are ground truth and the after-delta column must be the clamped difference between the after sample and the before sample. A mismatch means the receipt's delta column disagrees with its own samples.","triggerScenarios":"Calling compare()/validate_receipt() with rss_supported true and rss_after_delta_bytes != max(0, rss_after_bytes - rss_before_bytes) - e.g. delta left at the during value after a copy-paste, or recomputed against rss_during_bytes instead of rss_before_bytes.","commonSituations":"Copy-pasting the rss_during_delta_bytes value into rss_after_delta_bytes when hand-editing; sampler changes that compute the after delta against a different baseline sample; stale deltas not refreshed after re-sampling.","solutions":["Recompute and write rss_after_delta_bytes = max(0, rss_after_bytes - rss_before_bytes) in the receipt","Prefer regenerating the receipt entirely: python scripts/measure-persistence-backlog.py > receipt.json","Fix the sampler if it derives the after delta from anything other than rss_before_bytes","Re-run scripts/check-persistence-backlog-budget.py --receipt receipt.json to confirm"],"exampleFix":"// before (receipt.json)\n\"rss_before_bytes\": 18923520,\n\"rss_after_bytes\": 31784960,\n\"rss_after_delta_bytes\": 9453568\n\n// after: 31784960 - 18923520 = 12861440\n\"rss_before_bytes\": 18923520,\n\"rss_after_bytes\": 31784960,\n\"rss_after_delta_bytes\": 12861440","handlingStrategy":"validation","validationCode":"def rss_after_delta_consistent(receipt: dict) -> bool:\n    if not receipt.get(\"rss_supported\"):\n        return receipt.get(\"rss_after_delta_bytes\") is None\n    return receipt[\"rss_after_delta_bytes\"] == max(\n        0, receipt[\"rss_after_bytes\"] - receipt[\"rss_before_bytes\"]\n    )\n# call before compare(receipt, budget)","typeGuard":"from typing import TypeGuard\n\ndef has_consistent_rss_deltas(r: dict) -> TypeGuard[dict]:\n    before = r[\"rss_before_bytes\"]\n    return (r[\"rss_during_delta_bytes\"] == max(0, r[\"rss_during_bytes\"] - before)\n            and r[\"rss_after_delta_bytes\"] == max(0, r[\"rss_after_bytes\"] - before))","tryCatchPattern":null,"preventionTips":["Never hand-edit receipt JSON; regenerate it with scripts/measure-persistence-backlog.py","Keep the clamp formula max(0, sample - rss_before_bytes) in one shared helper used by both the sampler and the checker","Run scripts/test_check_persistence_backlog_budget.py after touching any RSS handling"],"tags":["rss","measurement-receipt","python","ci-gate","json"],"backgroundTag":null,"analyzedSha":"8880682c63083a91624de936797efa3ce9e498fd","analyzedAt":"2026-08-16T11:31:27.956Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}