{"record":{"id":"7ec3cd1fdfc9ef4b","repo":"Hmbown/CodeWhale","slug":"baseline-observation-applied-version-must-be-the-final-sent","errorCode":null,"errorMessage":"baseline_observation.applied_version must be the final sent version","messagePattern":"baseline_observation\\.applied_version must be the final sent version","errorType":"console","errorClass":"PersistenceBacklogError","httpStatus":null,"severity":"error","filePath":"scripts/check-persistence-backlog-budget.py","lineNumber":281,"sourceCode":"        observed = non_negative_integer(\n            baseline.get(field), f\"baseline_observation.{field}\"\n        )\n        if observed > ceiling:\n            raise PersistenceBacklogError(\n                f\"baseline_observation.{field} exceeds its ceiling\"\n            )\n    baseline_accepted = non_negative_integer(\n        baseline.get(\"accepted_requests\"), \"baseline_observation.accepted_requests\"\n    )\n    if baseline_accepted != FIXTURE[\"requests_attempted\"]:\n        raise PersistenceBacklogError(\n            \"baseline_observation.accepted_requests must equal requests_attempted\"\n        )\n    baseline_applied = non_negative_integer(\n        baseline.get(\"applied_version\"), \"baseline_observation.applied_version\"\n    )\n    if baseline_applied != FIXTURE[\"expected_applied_version\"]:\n        raise PersistenceBacklogError(\n            \"baseline_observation.applied_version must be the final sent version\"\n        )\n    baseline_retained = baseline[\"retained_queued_requests\"]\n    baseline_payload = baseline[\"estimated_retained_payload_bytes\"]\n    if baseline_retained == 0 or baseline_payload == 0:\n        raise PersistenceBacklogError(\n            \"baseline_observation must retain the final request and payload\"\n        )\n    if baseline_retained > baseline_accepted:\n        raise PersistenceBacklogError(\n            \"baseline_observation.retained_queued_requests exceeds accepted_requests\"\n        )\n    if baseline_payload < baseline_retained * FIXTURE[\"content_bytes_per_request\"]:\n        raise PersistenceBacklogError(\n            \"baseline_observation payload is smaller than frozen retained content\"\n        )\n    provenance = baseline.get(\"provenance\")\n    if not isinstance(provenance, dict):","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/scripts/check-persistence-backlog-budget.py#L263-L299","documentation":"The persistence-backlog budget checker validates that the baseline observation's applied_version equals the fixture's expected final sent version (127 for the paused-production-channel fixture). It raises PersistenceBacklogError when a stale, hand-edited, or regenerated baseline records a different applied_version, meaning the baseline was not produced by the frozen measurement scenario.","triggerScenarios":"Running `compare` on a persistence-backlog-budget.json whose baseline_observation.applied_version is not 127 (the FIXTURE expected_applied_version), e.g. after regenerating the baseline with changed fixture parameters or editing the budget by hand.","commonSituations":"Baseline JSON regenerated with a modified measure script, fixture constants updated without refreshing the baseline, manual edits to the budget file, or an old baseline from a previous schema version.","solutions":["Regenerate the baseline observation by running scripts/measure-persistence-backlog.py with the current fixture so applied_version equals 127.","Check the fixture constants at the top of the script; if expected_applied_version intentionally changed, update the baseline accordingly.","Ensure the paused consumer setup matches the fixture (paused_consumer=true, 128 attempted requests) so version 127 is the final applied version."],"exampleFix":"// before (budget JSON)\n\"baseline_observation\": { ..., \"applied_version\": 100 }\n// after\n\"baseline_observation\": { ..., \"applied_version\": 127 }","handlingStrategy":"validation","validationCode":"baseline = budget.get(\"baseline_observation\", {})\nif baseline.get(\"applied_version\") != 127:\n    raise ValueError(\"baseline applied_version stale; regenerate baseline\")","typeGuard":"def has_expected_applied_version(b: dict) -> bool:\n    return b.get(\"applied_version\") == 127","tryCatchPattern":"try:\n    validate_budget(budget, baseline)\nexcept PersistenceBacklogError as e:\n    print(f\"baseline out of date: {e}; re-run measure-persistence-backlog.py\")","preventionTips":["Regenerate the baseline whenever fixture constants change.","Never hand-edit baseline_observation numeric fields.","Diff the baseline against the FIXTURE block before committing."],"tags":["python","validation","budget-check"],"backgroundTag":"schema-validation-failed","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"}