{
  "schema_version": "1.3.0",
  "slug": "across-what-monotonic-fencing-token-and-lease-heartbeat-gates-must-an-instance-execute-background-jobs-to-prevent-zombie-worker-split-brain-writes",
  "title": "Across what monotonic-fencing-token and lease-heartbeat gates must an instance execute background jobs to prevent zombie-worker split-brain writes?",
  "date_of_record": "2026 October 20",
  "scope": "* **Applies when:** An AI instance, autonomous coding agent, or backend service implements distributed background workers, database-backed job queues, lease-based cron schedulers, or long-running asynchronous state machines. * **Does not ap",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/across-what-monotonic-fencing-token-and-lease-heartbeat-gates-must-an-instance-execute-background-jobs-to-prevent-zombie-worker-split-brain-writes.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/across-what-monotonic-fencing-token-and-lease-heartbeat-gates-must-an-instance-execute-background-jobs-to-prevent-zombie-worker-split-brain-writes.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/across-what-monotonic-fencing-token-and-lease-heartbeat-gates-must-an-instance-execute-background-jobs-to-prevent-zombie-worker-split-brain-writes.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 3322,
    "python_slice_tokens": 780,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Autonomous systems routinely execute long-running asynchronous workflows—such as document indexing, video transcoding, batch invoice settlement, and multi-step agent tool executions—by claiming jobs from a persistent work queue or database table (`status = 'RUNNING'`). A foundational distributed-systems consistency failure occurs when an instance assumes tha...",
    "what_was_observed": "In Celery/SQS worker pools, PostgreSQL/SQLite `SKIP LOCKED` job queues, and distributed cron runners, instances operating without monotonic fencing tokens and heartbeat abort triggers exhibit four primary failure modes: 1. **Zombie Worker Post-Expiry Clobber (`WHERE job_id = ?` Without `fencing_token`):** Worker A claims Job 42 with a 30-second lease. A slow upstream call stalls Worker A for 35 seconds. At second 31,...",
    "condition_of_validity": "* **Applies when:** An AI instance, autonomous coding agent, or backend service implements distributed background workers, database-backed job queues, lease-based cron schedulers, or long-running asynchronous state machines. * **Does not apply when:** Executing purely synchronous, in-process function calls within a single thread that involve no shared work q...",
    "decision_boundary": "1. **When a worker finishes a job and updates the database row to `COMPLETED`, what is in your `WHERE` clause?** Never write `WHERE job_id = ?` by itself. Always increment a `fencing_token` integer every time a job is claimed and require `WHERE job_id = ? AND fencing_token = ?` on completion so a slow worker waking up after its lease expired cannot overwrite...",
    "operational_effect": "1. **Atomic Single-Statement Claim with Epoch Increment:** Across all generated queue consumers and schedulers, the instance claims work and increments `fencing_token = fencing_token + 1` atomically in a single statement. 2. **Fenced Heartbeats & Immediate Zombie Cancellation:** Lease renewal loops verify `AND fencing_token = :token` at intervals of `lease_s..."
  },
  "matched_failure_symptoms": [
    "SPLIT_BRAIN_OR_ZOMBIE_WORKER"
  ],
  "composition_edges": {
    "primary_domain": "authentication_and_credential_rotation",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/across-what-w3c-baggage-allowlist-and-pii-sanitization-gates-must-an-instance-propagate-cross-service-context-to-prevent-header-amplification-and-external-data-exfiltration.md",
      "https://corpusfetch.com/c/across-what-encoding-and-canonicalization-boundaries-must-an-instance-normalize-identifiers-and-paths-to-prevent-equivalence-collision-and-bypass.md"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/across-what-mandatory-tenant-predicate-scoping-and-row-level-security-gates-must-an-instance-isolate-multi-tenant-data-to-prevent-cross-tenant-data-leaks.md",
      "https://corpusfetch.com/c/across-what-concurrent-pipe-drain-and-ring-buffer-boundaries-must-an-instance-consume-subprocess-stdout-and-stderr-to-prevent-os-pipe-deadlocks-and-unbounded-output-oom.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/across-what-cryptographic-csprng-and-state-prediction-isolation-gates-must-an-instance-generate-tokens-and-session-identifiers-to-prevent-pseudo-random-predictability-and-token-forgery.md",
      "https://corpusfetch.com/c/across-what-dependency-pinning-and-hash-verification-gates-must-an-instance-resolve-external-packages-to-prevent-hallucinated-typosquat-and-supply-chain-injection.md"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "cdc62d515e38f61195cbae527cf47a0377595eede8141de334daa704cc1421a0",
    "verified_classes": [
      "ZombieWorkerFencedError",
      "ClaimedJobLease",
      "FencedJobStateMachine"
    ],
    "verified_functions": [
      "__init__",
      "_init_schema",
      "enqueue_job",
      "claim_next_job",
      "heartbeat_lease",
      "complete_job_fenced"
    ],
    "verified_functions_count": 6,
    "defensive_guards_count": 3,
    "raised_exceptions": [
      "ValueError",
      "ZombieWorkerFencedError"
    ],
    "sample_fail_closed_invariants": [
      "lease_duration_sec must be at least 3.0 seconds"
    ],
    "stdlib_dependencies": [
      "dataclasses",
      "sqlite3",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
