{"record":{"id":"7dc200a40534b07b","repo":"affaan-m/ECC","slug":"stable-source-snapshot-write-made-no-progress","errorCode":null,"errorMessage":"stable source snapshot write made no progress","messagePattern":"stable source snapshot write made no progress","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"skills/taste-application/scripts/tasteforge/workflow.py","lineNumber":87,"sourceCode":"            snapshot = Path(temporary) / f\"source{path.suffix}\"\n            snapshot_fd = os.open(\n                snapshot, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600\n            )\n            try:\n                os.lseek(descriptor, 0, os.SEEK_SET)\n                digest = hashlib.sha256()\n                total = 0\n                while True:\n                    chunk = os.read(descriptor, 1024 * 1024)\n                    if not chunk:\n                        break\n                    total += len(chunk)\n                    digest.update(chunk)\n                    view = memoryview(chunk)\n                    while view:\n                        written = os.write(snapshot_fd, view)\n                        if written <= 0:\n                            raise ValueError(\"stable source snapshot write made no progress\")\n                        view = view[written:]\n                os.fsync(snapshot_fd)\n            finally:\n                os.close(snapshot_fd)\n            source_digest = digest.hexdigest()\n            copied = os.fstat(descriptor)\n            if (before.st_dev, before.st_ino, before.st_size, before.st_mtime_ns) != (\n                copied.st_dev, copied.st_ino, copied.st_size, copied.st_mtime_ns\n            ):\n                raise ValueError(\"reference source mutated while creating stable snapshot\")\n            verified_size, verified_digest = _hash_descriptor(descriptor)\n            if verified_size != total or verified_digest != source_digest:\n                raise ValueError(\"reference source mutated while creating stable snapshot\")\n\n            measured = probe(snapshot)\n\n            after = os.fstat(descriptor)\n            final_size, final_digest = _hash_descriptor(descriptor)","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/skills/taste-application/scripts/tasteforge/workflow.py#L69-L105","documentation":"While copying the source into a private snapshot, the loop writes each chunk with os.write and asserts the return value is positive. os.write returning <= 0 means the write made no progress (zero bytes written), which would otherwise cause an infinite loop slicing the memoryview. This is an internal-invariant check: a blocking write to a regular file should always make progress, so <= 0 indicates a broken descriptor or filesystem condition.","triggerScenarios":"os.write(snapshot_fd, view) returns 0 or a negative value during the snapshot copy — e.g. the snapshot fd became invalid mid-write, the filesystem rejects the write outright, or a non-blocking fd hits a transient condition without progress.","commonSituations":"Underlying tmp filesystem full or misbehaving (some FS return unusual errors surfaced as short/zero writes), a mocked/patched os.write in tests returning 0, or fd corruption from external code closing the descriptor.","solutions":["Check the temp filesystem has free space (the snapshot goes to tempfile's tmp dir, typically /tmp): `df -h $(mktemp -d)`.","Do not patch or mock os.write to return 0 in tests; return len(data) instead.","Ensure no other code closes snapshot_fd concurrently; this is an internal invariant, so if reproducible report it as a bug with the filesystem details."],"exampleFix":"// before (test mock that stalls the loop)\nmock_os.write = lambda fd, buf: 0\n\n// after\ndef fake_write(fd, buf):\n    return len(buf)  # always report progress","handlingStrategy":"try-catch","validationCode":"import shutil, tempfile\ntmp = tempfile.gettempdir()\nfree = shutil.disk_usage(tmp).free\nif free < 100 * 1024 * 1024:\n    raise RuntimeError(f\"temp filesystem low on space: {free} bytes free\")","typeGuard":null,"tryCatchPattern":"try:\n    result = run_workflow(path, probe)\nexcept ValueError as e:\n    if \"made no progress\" in str(e):\n        # check temp filesystem / report bug; not retryable by itself\n        logging.error(\"snapshot write stalled; check %s space and report bug\", tempfile.gettempdir())\n    raise","preventionTips":["Keep the temp filesystem (usually /tmp) from filling up.","Never mock os.write to return 0 in tests.","Treat this as an internal invariant — report reproducible cases upstream."],"tags":["filesystem","internal-error","io"],"backgroundTag":"internal-invariant-violation","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}