{"record":{"id":"01adb0261e74b7a7","repo":"abhigyanpatwari/GitNexus","slug":"oracle-source-changed-while-being-captured-relat","errorCode":null,"errorMessage":"oracle source changed while being captured: {relative}","messagePattern":"oracle source changed while being captured: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"eval/workflow_bench/oracle_assets.py","lineNumber":174,"sourceCode":"            or before.st_ino != opened.st_ino\n            or opened.st_size > MAX_ORACLE_FILE_BYTES\n        ):\n            raise ValueError(f\"oracle source must be a bounded regular non-symlink file: {relative}\")\n        chunks: list[bytes] = []\n        remaining = MAX_ORACLE_FILE_BYTES + 1\n        while remaining > 0:\n            chunk = os.read(descriptor, min(64 * 1024, remaining))\n            if not chunk:\n                break\n            chunks.append(chunk)\n            remaining -= len(chunk)\n        payload = b\"\".join(chunks)\n        after = os.fstat(descriptor)\n        stable_fields = (\"st_dev\", \"st_ino\", \"st_mode\", \"st_size\", \"st_mtime_ns\", \"st_ctime_ns\")\n        if len(payload) > MAX_ORACLE_FILE_BYTES or any(\n            getattr(opened, field) != getattr(after, field) for field in stable_fields\n        ):\n            raise ValueError(f\"oracle source changed while being captured: {relative}\")\n        return payload\n    finally:\n        os.close(descriptor)\n\n\ndef capture_task_oracle(task: dict[str, Any], *, root: Path = ORACLE_ROOT) -> TaskOracleSnapshot:\n    \"\"\"Capture and digest one task's hidden oracle before a model session.\"\"\"\n\n    validate_oracle_declaration(task)\n    oracle_root = _real_oracle_root(root)\n    oracle = task[\"oracle\"]\n    command = str(oracle[\"command\"])\n    snapshots: list[OracleFileSnapshot] = []\n    total = 0\n    for declaration in oracle[\"files\"]:\n        source = _bounded_relative_path(declaration[\"source\"], label=\"oracle source\")\n        target = _bounded_relative_path(declaration[\"target\"], label=\"oracle target\").as_posix()\n        payload = _read_oracle_file(oracle_root, source)","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/oracle_assets.py#L156-L192","documentation":"Raised by _read_oracle_file after reading the full payload, when either the payload length exceeds MAX_ORACLE_FILE_BYTES (512 KiB) or any of the stable stat fields (st_dev, st_ino, st_mode, st_size, st_mtime_ns, st_ctime_ns) changed between the pre-read fstat and a post-read fstat. This detects files mutated, truncated, or replaced while the harness was reading them, ensuring the captured digest is of a fixed, immutable byte sequence.","triggerScenarios":"A file grows beyond 512 KiB while being read; the file is written, touched, or replaced during the read loop; mtime/ctime changes because another process writes to it mid-capture.","commonSituations":"Log files or generated outputs being actively written when the oracle is captured; concurrent benchmark tooling touching oracle assets; an editor auto-saving over the file; clock/mtime updates from a filesystem sync.","solutions":["Freeze oracle assets before capture: copy them to a read-only location and capture from there.","Stop any process that writes to the oracle tree during the benchmark run.","Ensure the file size is stable and below 512 KiB at capture time."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import os, stat\nfrom pathlib import Path\n\ndef assert_file_stable(root: Path, relative) -> None:\n    p = root.joinpath(*Path(relative).parts)\n    fd = os.open(p, os.O_RDONLY | getattr(os, \"O_NOFOLLOW\", 0))\n    try:\n        a = os.fstat(fd)\n        os.read(fd, a.st_size)  # touch\n        b = os.fstat(fd)\n        for f in (\"st_dev\", \"st_ino\", \"st_mode\", \"st_size\", \"st_mtime_ns\", \"st_ctime_ns\"):\n            if getattr(a, f) != getattr(b, f):\n                raise ValueError(f\"{relative} is being modified during read\")\n    finally:\n        os.close(fd)","typeGuard":"def file_is_quiescent(root, relative) -> bool:\n    import os\n    p = Path(root).joinpath(*Path(relative).parts)\n    try:\n        fd = os.open(p, os.O_RDONLY)\n    except OSError:\n        return False\n    try:\n        return os.fstat(fd).st_size == p.stat().st_size\n    finally:\n        os.close(fd)","tryCatchPattern":"try:\n    payload = _read_oracle_file(root, relative)\nexcept ValueError as exc:\n    if \"changed while being captured\" in str(exc):\n        # freeze and retry once from a read-only copy\n        raise SystemExit(f\"Oracle file {relative} mutated mid-capture; freeze the asset tree\") from exc\n    raise","preventionTips":["Copy oracle assets to an immutable location and capture from there.","Stop background writers/logs that touch the oracle tree during runs.","Run benchmarks against a read-only mount of the oracle store."],"tags":["python","benchmark","oracle","security","toctou","integrity"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}