Hmbown/CodeWhale · error · PersistenceBacklogError

baseline_observation must retain the final request and paylo

Error message

baseline_observation must retain the final request and payload

What it means

Raised by validate_budget() when baseline_observation.retained_queued_requests or estimated_retained_payload_bytes is 0. The fixture pauses the consumer after the sends, so the queue must still hold the newest request and its payload bytes at measurement time; a zero means the baseline was captured from a drained or unpaused channel and says nothing about backlog retention.

Source

Thrown at scripts/check-persistence-backlog-budget.py:287

            )
    baseline_accepted = non_negative_integer(
        baseline.get("accepted_requests"), "baseline_observation.accepted_requests"
    )
    if baseline_accepted != FIXTURE["requests_attempted"]:
        raise PersistenceBacklogError(
            "baseline_observation.accepted_requests must equal requests_attempted"
        )
    baseline_applied = non_negative_integer(
        baseline.get("applied_version"), "baseline_observation.applied_version"
    )
    if baseline_applied != FIXTURE["expected_applied_version"]:
        raise PersistenceBacklogError(
            "baseline_observation.applied_version must be the final sent version"
        )
    baseline_retained = baseline["retained_queued_requests"]
    baseline_payload = baseline["estimated_retained_payload_bytes"]
    if baseline_retained == 0 or baseline_payload == 0:
        raise PersistenceBacklogError(
            "baseline_observation must retain the final request and payload"
        )
    if baseline_retained > baseline_accepted:
        raise PersistenceBacklogError(
            "baseline_observation.retained_queued_requests exceeds accepted_requests"
        )
    if baseline_payload < baseline_retained * FIXTURE["content_bytes_per_request"]:
        raise PersistenceBacklogError(
            "baseline_observation payload is smaller than frozen retained content"
        )
    provenance = baseline.get("provenance")
    if not isinstance(provenance, dict):
        raise PersistenceBacklogError("baseline_observation needs provenance")
    if provenance.get("platform") != "macos":
        raise PersistenceBacklogError("baseline provenance platform must be macos")
    if not isinstance(provenance.get("source_sha"), str) or not SOURCE_SHA_PATTERN.fullmatch(
        provenance["source_sha"]
    ):

View on GitHub (pinned to 8880682c63)

Solutions

  1. Capture the baseline while the consumer is paused, before any flush
  2. Set retained_queued_requests and estimated_retained_payload_bytes to the observed non-zero values
  3. Keep fixture.paused_consumer=true in the measurement configuration

Example fix

// before (budget.json)
"baseline_observation": {
  "retained_queued_requests": 0,
  "estimated_retained_payload_bytes": 0, ... }

// after: paused-consumer run retains the queue
"baseline_observation": {
  "retained_queued_requests": 128,
  "estimated_retained_payload_bytes": 8527994, ... }
Defensive patterns

Strategy: validation

Validate before calling

def baseline_retention_ok(budget: dict) -> bool:
    b = budget.get("baseline_observation", {})
    return (b.get("retained_queued_requests", 0) > 0
            and b.get("estimated_retained_payload_bytes", 0) > 0)

Prevention

When it happens

Trigger: Either field 0 in the baseline block - typically a baseline measured after the consumer resumed and emptied the queue, or zero-filled template values left in a hand-written budget.

Common situations: Baseline captured too late (after a flush); running with paused_consumer=false; copy-pasting a template whose placeholder zeros were never replaced.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@8880682c63 (2026-08-16). Data as JSON: /api/errors/9cfda0939923c57c. Report an issue: GitHub.