{"record":{"id":"9fb568fa2d2df175","repo":"Hmbown/CodeWhale","slug":"rss-during-delta-bytes-is-inconsistent","errorCode":null,"errorMessage":"rss_during_delta_bytes is inconsistent","messagePattern":"rss_during_delta_bytes is inconsistent","errorType":"validation","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":233,"sourceCode":"        isinstance(item, str) and item for item in limitations\n    ):\n        raise PersistenceBacklogError(\"limitations must be a non-empty string array\")\n\n    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:","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L215-L251","documentation":"On the RSS-supported (macOS) lane, rss_during_delta_bytes must equal max(0, rss_during_bytes - rss_before_bytes): the delta is a derived field clamped at zero, and it must be arithmetically consistent with the raw samples. A mismatch means the receipt's deltas were computed or edited independently of the samples, breaking the measurement's internal consistency.","triggerScenarios":"Raised by validate_receipt (macOS lane only, after rss_supported passes) when receipt['rss_during_delta_bytes'] != max(0, receipt['rss_during_bytes'] - receipt['rss_before_bytes']), from validate_baseline_receipt or compare.","commonSituations":"Recomputing raw RSS samples after a re-run while leaving stale deltas; a generator that clamps deltas differently (e.g. without max(0, ...)); hand-editing a delta to fit under a ceiling in the budget file.","solutions":["Re-run the measurement so deltas are recomputed from the same samples as the raw byte counts.","Fix the generator to derive deltas exactly as max(0, during - before) at receipt-write time.","Never edit deltas independently; if a ceiling fails, tighten or justify the budget instead of altering the receipt."],"exampleFix":"// before\n{\"rss_before_bytes\": 100, \"rss_during_bytes\": 90, \"rss_during_delta_bytes\": -10}\n// after\n# delta = max(0, during - before)\n{\"rss_before_bytes\": 100, \"rss_during_bytes\": 90, \"rss_during_delta_bytes\": 0}","handlingStrategy":"validation","validationCode":"def rss_deltas_consistent(receipt):\n    before = receipt.get(\"rss_before_bytes\", 0)\n    return (\n        receipt.get(\"rss_during_delta_bytes\") == max(0, receipt.get(\"rss_during_bytes\", 0) - before)\n        and receipt.get(\"rss_after_delta_bytes\") == max(0, receipt.get(\"rss_after_bytes\", 0) - before)\n    )","typeGuard":"def is_non_negative_int(v):\n    return isinstance(v, int) and not isinstance(v, bool) and v >= 0","tryCatchPattern":"try:\n    validate_receipt(receipt)\nexcept PersistenceBacklogError as e:\n    print(f\"rss delta mismatch: {e}\", file=sys.stderr)\n    sys.exit(2)","preventionTips":["Compute deltas in the same write path as the raw samples, never by hand.","Use max(0, after - before) as the single canonical delta formula.","If a ceiling fails, adjust the budget file — never massage receipt deltas to fit."],"tags":["measurement","validation","memory","python"],"backgroundTag":"checksum-mismatch","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"}