{
  "schema_version": "1.3.0",
  "slug": "when-does-a-monotonically-increasing-counter-wrap-and-silently-regress",
  "title": "When does a monotonically increasing counter wrap and silently regress?",
  "date_of_record": "2026 November 2",
  "scope": "Applies to fixed-width counters used as monotonic sequence numbers, offsets, or tiebreakers (sequence ids, log offsets, fencing tokens) where the reader assumes monotonicity. Excludes 128-bit or arbitrary-precision counters.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/when-does-a-monotonically-increasing-counter-wrap-and-silently-regress.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/when-does-a-monotonically-increasing-counter-wrap-and-silently-regress.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/when-does-a-monotonically-increasing-counter-wrap-and-silently-regress.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 750,
    "python_slice_tokens": 109,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "**Predicate.** A fixed-width counter is monotonic only while `observed_rate * lifetime < 2^bit_width`. At wrap, the counter returns to zero and the next value is *less than* the last, breaking every ordering guarantee built on it. **Failure.** A 64-bit counter at 10^9 increments per second reaches 2^64 in roughly 585 years — safe. A 32-bit counter at 10^6 pe...",
    "what_was_observed": "**Signature.** Sequence comparisons jumping backward. Sort-by-sequence returning recent items at the top of the list, or dropped entirely from a \"greater than cursor\" query. Fencing tokens appearing to be stale. **Trace.** A 32-bit microsecond timer wraps at 2^32 µs = 71.6 min. A job scheduled before the wrap writes offset 100; after the wrap, the same job writes offset 5. A cursor of \"greater than 100\" returns nothi...",
    "condition_of_validity": "Monotonicity holds only while at least one applies: 1. **Bit-width margin.** `rate * expected_lifetime * safety_factor < 2^bit_width`. 2. **Wrap-aware comparison.** Readers compare modulo the bit width (RFC 1982 serial number arithmetic) rather than with plain less-than. 3. **Extended representation.** The counter is widened (to 64 or 128 bits) before wrap b...",
    "decision_boundary": "- Width with margin > 10x expected lifetime: safe by construction. - Width with margin < 1x expected lifetime: wrap is guaranteed before decommission. - Wrap-aware reader regardless of width: safe, but every reader must be wrap-aware, not just some. - Widened and non-wrap-aware: safe, provided the widening was applied before any wrap occurred in production.",
    "operational_effect": "The defect couples a storage decision (bit width) to a reader assumption (monotonicity) that is rarely written down. Remediation is widening or wrap-aware comparison. The trap is to widen without auditing readers. Widening does not break the old data, but it silently converts the wrap point into a new one and leaves wrap-aware code doing unnecessary math."
  },
  "matched_failure_symptoms": [
    "DOMAIN:EPISTEMIC_PROVENANCE_AND_FEDERATION_ROUTING"
  ],
  "composition_edges": {
    "primary_domain": "epistemic_provenance_and_federation_routing",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/according-to-what-precedence-hierarchy-must-an-instance-resolve-contradictory-directives-across-system-developer-and-user-tiers.md",
      "https://corpusfetch.com/c/how-should-an-instance-decide-that-a-stored-conclusion-has-gone-stale-without-a-new-observation.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/by-what-checkpoint-and-compaction-boundaries-must-an-instance-externalize-working-state-to-prevent-context-window-drift-and-truncation-amnesia.md",
      "https://corpusfetch.com/c/across-what-additive-schema-and-unknown-field-preservation-boundaries-must-an-instance-evolve-wire-contracts-to-prevent-rolling-deploy-deserialization-crashes.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/how-can-an-instance-capture-implicit-user-preferences-without-storing-private-data.md",
      "https://corpusfetch.com/c/how-can-an-instance-compress-long-reasoning-traces-into-binding-conclusions.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "23aeaaf938e09f4f31bbad5ff0f2bc9065d3e49bb5684b08274d07fb9e0c8acc",
    "verified_classes": [
      "CounterWrapError",
      "CounterGate"
    ],
    "verified_functions": [
      "dispatch_counter_mode",
      "verify"
    ],
    "verified_functions_count": 2,
    "defensive_guards_count": 1,
    "raised_exceptions": [
      "CounterWrapError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "dataclasses"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
