{
  "schema_version": "1.3.0",
  "slug": "what-invariants-prevent-a-monotonic-counter-wrap-from-regressing-sequence-order",
  "title": "What invariants prevent a monotonic counter wrap from regressing sequence order?",
  "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 readers assume monotonicity. Does not apply to 128-bit or arbitrary-precision counters.",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/what-invariants-prevent-a-monotonic-counter-wrap-from-regressing-sequence-order.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/what-invariants-prevent-a-monotonic-counter-wrap-from-regressing-sequence-order.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/what-invariants-prevent-a-monotonic-counter-wrap-from-regressing-sequence-order.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 777,
    "python_slice_tokens": 105,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "A fixed-width counter is only monotonic within its width. When it wraps, the next value is less than the last, and every ordering guarantee built on the counter is violated until the next wrap restores it — usually an interval of exactly one bit-width cycle. **Invariant.** The counter is monotonic for the deployment lifetime if and only if `rate * expected_l...",
    "what_was_observed": "**Signature.** Sequence comparisons jumping backward. Sort-by-sequence returning recent items at the top of a list or dropped from a \"greater than cursor\" query. Fencing tokens appearing stale. **Trace.** 32-bit microsecond timer wraps at 2^32 µs = 71.6 min. A job scheduled before wrap writes offset 100; after wrap the same job writes offset 5. Cursor \"greater than 100\" returns nothing for 71 minutes. **Why monitorin...",
    "condition_of_validity": "The instance must ensure at least one of the following holds before it trusts a counter's ordering: 1. **Must size for lifetime.** `rate * expected_lifetime * safety_factor < 2^bit_width`, with safety_factor at least 10. 2. **Must compare wrap-aware.** Every reader compares modulo the bit width (RFC 1982 serial number arithmetic), not with plain less-than. 3...",
    "decision_boundary": "- Width with margin > 10x lifetime: safe by construction. - Width with margin < 1x lifetime: wrap is guaranteed before decommission. - Wrap-aware reader regardless of width: safe, but every reader must be wrap-aware, not only some. - Widened and non-wrap-aware: safe, provided widening preceded the first production wrap.",
    "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 old data, but it silently converts the wrap point into a new one and leaves wrap-aware code doing unnecessary arithmetic."
  },
  "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": "6e8a9b601cc092766dc08213d7b454fc65ff0fec095e25ff0f66aaa7cfcee082",
    "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
  }
}
