Skip to content

[Bug]: Incomplete protected backups are reported as successful #3769

Description

@oleksii-tumanov

What happened?

A failed graph.json backup copy can still print backed up semantic graph and return the backup directory. In a local reproduction, a read-only same-day backup kept the old graph while a sidecar copied successfully. There was no warning that the returned backup was stale.

I'd expect an incomplete backup to return None and warn which file failed. The existing best-effort overwrite behavior can stay unchanged.

Steps to reproduce

Run as a regular user on macOS or Linux; root may bypass the read-only permission:

python - <<'PY'
from contextlib import redirect_stderr, redirect_stdout
from io import StringIO
from pathlib import Path
from tempfile import TemporaryDirectory
from graphify.export import backup_if_protected

with TemporaryDirectory() as temporary:
    out = Path(temporary)
    graph = out / "graph.json"
    graph.write_text('{"nodes":[{"id":"old"}],"links":[]}')
    (out / ".graphify_semantic_marker").write_text("{}")
    with redirect_stdout(StringIO()):
        backup = backup_if_protected(out)
    protected = backup / "graph.json"
    protected.chmod(0o444)
    try:
        graph.write_text('{"nodes":[{"id":"new"}],"links":[]}')
        stdout, stderr = StringIO(), StringIO()
        with redirect_stdout(stdout), redirect_stderr(stderr):
            result = backup_if_protected(out)
        print("result_is_none:", result is None)
        print("backup_matches_current_graph:", protected.read_bytes() == graph.read_bytes())
        print("stdout:", stdout.getvalue().strip())
        print("stderr:", stderr.getvalue().strip().replace(temporary, "<temporary-output>"))
    finally:
        protected.chmod(0o644)
PY

Error output or graph output

Observed on the tested base:

result_is_none: False
backup_matches_current_graph: False
stdout: [graphify] backed up semantic graph (1 files) -> 2026-09-22/
stderr:

Graphify version

0.9.66, v8 at a5957aa6ef51c9be8d054de9783d25046c187f3f.

Environment

macOS 26.6.2, Python 3.12.11, editable install.

Additional context

This is about copy-failure reporting and retrying incomplete same-day backups, not changing backup eligibility or retention.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions