affaan-m/ECC · error · ValueError

stable source snapshot write made no progress

Error message

stable source snapshot write made no progress

What it means

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.

Solutions

  1. Check the temp filesystem has free space (the snapshot goes to tempfile's tmp dir, typically /tmp): `df -h $(mktemp -d)`.
  2. Do not patch or mock os.write to return 0 in tests; return len(data) instead.
  3. 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.

Example fix

// before (test mock that stalls the loop)
mock_os.write = lambda fd, buf: 0

// after
def fake_write(fd, buf):
    return len(buf)  # always report progress
Defensive patterns

Strategy: try-catch

Validate before calling

import shutil, tempfile
tmp = tempfile.gettempdir()
free = shutil.disk_usage(tmp).free
if free < 100 * 1024 * 1024:
    raise RuntimeError(f"temp filesystem low on space: {free} bytes free")

Try / catch

try:
    result = run_workflow(path, probe)
except ValueError as e:
    if "made no progress" in str(e):
        # check temp filesystem / report bug; not retryable by itself
        logging.error("snapshot write stalled; check %s space and report bug", tempfile.gettempdir())
    raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/7dc200a40534b07b. Report an issue: GitHub.

Appendix: source

Thrown at skills/taste-application/scripts/tasteforge/workflow.py:87

            snapshot = Path(temporary) / f"source{path.suffix}"
            snapshot_fd = os.open(
                snapshot, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW, 0o600
            )
            try:
                os.lseek(descriptor, 0, os.SEEK_SET)
                digest = hashlib.sha256()
                total = 0
                while True:
                    chunk = os.read(descriptor, 1024 * 1024)
                    if not chunk:
                        break
                    total += len(chunk)
                    digest.update(chunk)
                    view = memoryview(chunk)
                    while view:
                        written = os.write(snapshot_fd, view)
                        if written <= 0:
                            raise ValueError("stable source snapshot write made no progress")
                        view = view[written:]
                os.fsync(snapshot_fd)
            finally:
                os.close(snapshot_fd)
            source_digest = digest.hexdigest()
            copied = os.fstat(descriptor)
            if (before.st_dev, before.st_ino, before.st_size, before.st_mtime_ns) != (
                copied.st_dev, copied.st_ino, copied.st_size, copied.st_mtime_ns
            ):
                raise ValueError("reference source mutated while creating stable snapshot")
            verified_size, verified_digest = _hash_descriptor(descriptor)
            if verified_size != total or verified_digest != source_digest:
                raise ValueError("reference source mutated while creating stable snapshot")

            measured = probe(snapshot)

            after = os.fstat(descriptor)
            final_size, final_digest = _hash_descriptor(descriptor)

View on GitHub (pinned to 8321021c54)