{
  "schema_version": "1.3.0",
  "slug": "within-what-ephemeral-workspace-and-disk-headroom-bounds-must-an-instance-confine-temporary-file-lifecycles-to-prevent-inode-exhaustion-and-enospc-crashes",
  "title": "Within what ephemeral-workspace and disk-headroom bounds must an instance confine temporary file lifecycles to prevent inode exhaustion and ENOSPC crashes?",
  "date_of_record": "2026 October 20",
  "scope": "* **Applies when:** An AI instance, autonomous coding agent, or backend worker creates temporary files, downloads staging artifacts, extracts archives, runs compilers/CLI tools that emit intermediate files, or buffers streams to disk. * **D",
  "projections": {
    "unified_markdown_uri": "https://corpusfetch.com/c/within-what-ephemeral-workspace-and-disk-headroom-bounds-must-an-instance-confine-temporary-file-lifecycles-to-prevent-inode-exhaustion-and-enospc-crashes.md",
    "method_python_slice_uri": "https://corpusfetch.com/c/within-what-ephemeral-workspace-and-disk-headroom-bounds-must-an-instance-confine-temporary-file-lifecycles-to-prevent-inode-exhaustion-and-enospc-crashes.py",
    "remnant_warrant_slice_uri": "https://corpusfetch.com/c/within-what-ephemeral-workspace-and-disk-headroom-bounds-must-an-instance-confine-temporary-file-lifecycles-to-prevent-inode-exhaustion-and-enospc-crashes.warrant.json"
  },
  "token_profile": {
    "full_markdown_tokens": 2998,
    "python_slice_tokens": 557,
    "warrant_slice_tokens": 220
  },
  "remnant_summary": {
    "core_distinction": "Autonomous systems constantly materialize intermediate state on disk—downloading media or dataset blobs for transformation, writing scratch files for external CLI compilers, staging atomic file replacements, and buffering multi-megabyte command outputs. A foundational systems-availability failure occurs when an instance treats `/tmp` or the local working dir...",
    "what_was_observed": "In batch media/document pipelines, CI build agents, and autonomous coding loops, instances operating without explicit temporary-file lifecycle and disk-headroom bounds exhibit four primary failure modes: 1. **Exception-Path Orphan Accumulation (`ENOSPC` Death Spiral):** An instance writes `tmp = \"/tmp/chunk_\" + uuid4().hex; write_data(tmp); process(tmp); os.remove(tmp)` without wrapping the lifecycle in a `try...fina...",
    "condition_of_validity": "* **Applies when:** An AI instance, autonomous coding agent, or backend worker creates temporary files, downloads staging artifacts, extracts archives, runs compilers/CLI tools that emit intermediate files, or buffers streams to disk. * **Does not apply when:** Transforming small payloads ($\\le 16\\text{ MiB}$) that fit comfortably in RAM using `io.BytesIO`, ...",
    "decision_boundary": "1. **Did you write a literal path starting with `\"/tmp/...\"` in your code?** Replace it with `with tempfile.TemporaryDirectory() as tmpdir:` and write to `Path(tmpdir) / \"filename\"` instead. Hardcoded `/tmp` filenames collide under concurrency and leak whenever an exception occurs. 2. **Are you writing large files, downloading archives, or generating thousan...",
    "operational_effect": "1. **Zero Hardcoded `/tmp` Paths:** Across all generated scripts, tests, and services, the instance never writes to fixed paths in `/tmp`, confining all scratch files inside context-managed `TemporaryDirectory` scopes (`0700`). 2. **Pre-Flight Byte & Inode Headroom Verification:** Before staging large downloads, extractions, or batch outputs, generated code ..."
  },
  "matched_failure_symptoms": [
    "OOM_KILL_OR_MEMORY_EXHAUSTION",
    "ENOSPC_DISK_OR_INODE_EXHAUSTION"
  ],
  "composition_edges": {
    "primary_domain": "concurrency_locking_and_shared_resources",
    "upstream_precondition_residuals": [
      "https://corpusfetch.com/c/beneath-what-concurrency-and-backpressure-ceilings-must-an-instance-throttle-fan-out-tasks-to-prevent-file-descriptor-and-connection-pool-starvation.md",
      "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"
    ],
    "downstream_consequence_residuals": [
      "https://corpusfetch.com/c/across-what-readiness-unregistration-and-in-flight-drain-gates-must-an-instance-sequence-sigterm-shutdown-to-prevent-dropped-requests-and-truncated-writes.md",
      "https://corpusfetch.com/c/before-what-pre-flight-and-dry-run-gates-must-an-instance-stage-bulk-or-irreversible-mutations-to-prevent-unrecoverable-blast-radius-cascade.md"
    ],
    "co_occurring_sibling_residuals": [
      "https://corpusfetch.com/c/across-what-bounded-queue-admission-control-and-load-shedding-gates-must-an-instance-manage-concurrency-to-prevent-unbounded-memory-growth-and-tail-latency-collapse.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"
    ]
  },
  "empirical_verification_warrant": {
    "status": "AST_AND_INVARIANT_VERIFIED",
    "syntax_valid": true,
    "code_sha256": "e20e3b45d95bf42907a21857e14883ef9930704c1be3ea13604ddfe84efbe2f8",
    "verified_classes": [
      "DiskHeadroomError"
    ],
    "verified_functions": [
      "verify_filesystem_headroom",
      "sweep_stale_scratch_dirs",
      "ephemeral_task_workspace"
    ],
    "verified_functions_count": 3,
    "defensive_guards_count": 2,
    "raised_exceptions": [
      "DiskHeadroomError"
    ],
    "sample_fail_closed_invariants": [],
    "stdlib_dependencies": [
      "contextlib",
      "os",
      "pathlib",
      "shutil",
      "tempfile",
      "time",
      "typing"
    ],
    "observation_mode": "EMPIRICAL_BOUNDARY_CAPTURE",
    "zero_external_deps": true
  }
}
