{"record":{"id":"1e8a8b61d8306b26","repo":"abhigyanpatwari/GitNexus","slug":"transcript-artifact-changed-while-reading-path","errorCode":null,"errorMessage":"transcript artifact changed while reading: {path}","messagePattern":"transcript artifact changed while reading: (.+?)","errorType":"exception","errorClass":"SandboxError","httpStatus":null,"severity":"critical","filePath":"eval/workflow_bench/evolve.py","lineNumber":414,"sourceCode":"        raise SandboxError(f\"transcript artifact must be owner-only: {path}\")\n    if before.st_size != expected_size:\n        raise SandboxError(f\"transcript artifact size does not match its results row: {path}\")\n\n    descriptor = os.open(path, os.O_RDONLY | getattr(os, \"O_NOFOLLOW\", 0))\n    try:\n        opened = os.fstat(descriptor)\n        if not stat.S_ISREG(opened.st_mode) or opened.st_dev != before.st_dev or opened.st_ino != before.st_ino:\n            raise SandboxError(f\"transcript artifact changed while opening: {path}\")\n        digest = hashlib.sha256()\n        content = bytearray()\n        while chunk := os.read(descriptor, 64 * 1024):\n            digest.update(chunk)\n            content.extend(chunk)\n            if len(content) > MAX_EVIDENCE_FILE_BYTES:\n                del content[: len(content) - MAX_EVIDENCE_FILE_BYTES]\n        after = os.fstat(descriptor)\n        if (opened.st_size, opened.st_mtime_ns) != (after.st_size, after.st_mtime_ns):\n            raise SandboxError(f\"transcript artifact changed while reading: {path}\")\n    finally:\n        os.close(descriptor)\n    if digest.hexdigest() != expected_digest:\n        raise SandboxError(f\"transcript artifact digest does not match its results row: {path}\")\n    return bytes(content).decode(errors=\"replace\")\n\n\ndef proposer_evidence_entries(\n    *,\n    results_dir: Path | None,\n    evidence: list[dict[str, Any]],\n    learnings: list[dict[str, Any]],\n    gate_summary: list[str],\n) -> dict[str, Any]:\n    \"\"\"Only structured, bounded evidence crosses into the proposer.\"\"\"\n\n    artifacts_by_row = _preflight_transcript_artifacts(evidence)\n    entries: dict[str, Any] = {","sourceCodeStart":396,"sourceCodeEnd":432,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/eval/workflow_bench/evolve.py#L396-L432","documentation":"Raised by `_bound_transcript_artifact` when, after streaming the file to compute its digest, a final `os.fstat` reports different size or mtime_ns than the fstat taken just before reading. The file changed while being read.","triggerScenarios":"The transcript file is being written/appended/truncated concurrently with the read loop, so its size or mtime_ns drifts during `os.read`.","commonSituations":"A live runner still streaming into the same transcripts/ file, log rotation, or a results dir on a filesystem another job is mutating.","solutions":["Wait for the producing runner to fully finish writing transcripts before feeding its results dir to evolve.","Copy the results dir to a stable, read-only location and point --seed-results there.","Retry once the concurrent writer is gone; if it recurs, investigate filesystem-level tampering."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from workflow_bench.proposer_sandbox import SandboxError\ntry:\n    proposer_evidence_entries(results_dir=rd, evidence=ev, learnings=lr, gate_summary=gs)\nexcept SandboxError as exc:\n    if 'changed while reading' in str(exc):\n        raise RuntimeError('transcript mutated mid-read; wait for writer to finish') from exc\n    raise","preventionTips":["Snapshot results into a read-only copy before running evolve.","Do not run evolve against a results dir a runner is still populating."],"tags":["python","workflow-bench","sandbox","toctou","race","security"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}