{"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":"validation","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/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L219-L255","documentation":"This error comes from validate_receipt in scripts/check-persistence-backlog-budget.py when the receipt's rss_after_delta_bytes does not equal max(0, rss_after_bytes - rss_before_bytes). The script requires RSS delta fields to be exactly the derived, non-negative difference between the recorded absolute RSS samples, so hand-edited or partially recomputed receipts fail this consistency invariant. It only fires on the macOS lane where rss_supported is true.","triggerScenarios":"validate_receipt (called via validate_baseline_receipt or compare) processes a receipt with rss_supported=true whose rss_after_delta_bytes was edited independently of the rss_after_bytes/rss_before_bytes sample pair, or the measurement script wrote stale delta values after re-sampling.","commonSituations":"Manually editing persistence-backlog-baseline-receipt.json or a fresh measurement receipt to tweak numbers; merging receipts from different runs so deltas no longer match samples; re-running measurement with different RSS samples but copying old deltas.","solutions":["Recompute rss_after_delta_bytes as max(0, receipt['rss_after_bytes'] - receipt['rss_before_bytes']) and set it in the receipt","Re-run the measurement (scripts/check-persistence-backlog-budget.py without --receipt) to regenerate a self-consistent receipt","If hand-editing a baseline receipt, update rss_after_bytes and the delta together, never one alone"],"exampleFix":"// before\n\"rss_before_bytes\": 1000, \"rss_after_bytes\": 1200, \"rss_after_delta_bytes\": 300\n// after\n\"rss_before_bytes\": 1000, \"rss_after_bytes\": 1200, \"rss_after_delta_bytes\": 200","handlingStrategy":"validation","validationCode":"def rss_after_delta_ok(receipt):\n    return receipt.get(\"rss_after_delta_bytes\") == max(0, receipt[\"rss_after_bytes\"] - receipt[\"rss_before_bytes\"])","typeGuard":"def has_consistent_rss_deltas(r):\n    return isinstance(r.get(\"rss_supported\"), bool) and (\n        not r[\"rss_supported\"] or\n        (r[\"rss_during_delta_bytes\"] == max(0, r[\"rss_during_bytes\"] - r[\"rss_before_bytes\"])\n         and r[\"rss_after_delta_bytes\"] == max(0, r[\"rss_after_bytes\"] - r[\"rss_before_bytes\"])))","tryCatchPattern":"try:\n    compare(receipt, budget)\nexcept PersistenceBacklogError as e:\n    if \"rss_after_delta_bytes is inconsistent\" in str(e):\n        receipt[\"rss_after_delta_bytes\"] = max(0, receipt[\"rss_after_bytes\"] - receipt[\"rss_before_bytes\"])\n    raise","preventionTips":["Never edit RSS delta fields independently of their sample fields","Recompute deltas from samples with max(0, after - before) after any receipt edit","Regenerate receipts with the measurement script instead of hand-editing"],"tags":["validation","receipt","rss","consistency"],"backgroundTag":"internal-invariant-violation","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}