Repository navigation
fix(watch): route graph.json replace through the atomic fallback on both incremental write sites - #3555
fix(watch): route graph.json replace through the atomic fallback on both incremental write sites#3555ayushcodes10 wants to merge 6 commits into
Conversation
watch.py writes graph.json via a plain Path.replace() at two call sites instead of the shared os_replace_with_fallback helper that export.py, cache.py, and install.py already route through. This adds the import with no behavior change yet; both call sites are switched over in the next two commits. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
Fixes issue 2689 for the reconcile existing graph write site. This site reads existing_graph a few lines earlier in the same process, then replaced graph_tmp onto it with a plain Path.replace. On a VMware HGFS shared folder, os.replace over a destination that was read earlier in the same process raises PermissionError even though src and dst are on the same drive; deleting then renaming succeeds in that exact situation. os_replace_with_fallback already implements that fallback for PermissionError generally, so this switches the call over to it instead of duplicating the recovery here. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
Fixes issue 2689 for the main rebuild write site, the second of the two watch.py call sites reported. Same reasoning as the reconcile path: existing_graph was read a few lines earlier in this same process for the same_graph comparison, so a plain Path.replace can hit the VMware HGFS PermissionError this issue reports. Both call sites in watch.py now route through the shared os_replace_with_fallback helper that export.py, cache.py, and install.py already use. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
Simulates the VMware HGFS PermissionError this issue reports by monkeypatching os.replace to always raise it, then confirms an incremental no_cluster rebuild still succeeds and lands the new content instead of aborting the whole run. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
Same Graphify-Labs#2689 fallback requirement as the no_cluster test, exercised against the default clustered rebuild path, the second of the two watch.py call sites the issue reports. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Formal verification. No changes could be formally verified in this run.
Graphify review — findings
Routes both incremental-rebuild graph.json write sites in _rebuild_code (no-cluster and clustered) through os_replace_with_fallback instead of a plain Path.replace, so graphify update/cluster-only no longer abort with [WinError 5] when the destination was read earlier in the same process on a VMware HGFS share. Adds tests that monkeypatch os.replace to raise PermissionError and assert both paths fall back and still land the new content.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 797 functions depend on the 611 functions this change touches.
Health — this change adds coupling hotspots:
- new:
_rebuild_code()— 118 callers, 52 callees - new:
dispatch_command()— 2 callers, 124 callees - new:
watch()— 5 callers, 7 callees - new:
_reconcile_graph_html()— 6 callers, 5 callees - new:
_reconcile_existing_graph()— 1 callers, 8 callees - new:
_reconcile_markdown_links()— 1 callers, 6 callees - new:
test_poisoned_manifest_is_healed()— 0 callers, 6 callees
Verification — 797 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 623 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
275 of 275 test file(s) selected (100%) via static blast radius.
Escalated to a full run for safety — the selection is not trustworthy on its own (see below). CI should run the whole suite.
tests/test_affected_cli.py— full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_agents_platform.py— full-run-safetytests/test_analyze.py— full-run-safetytests/test_anthropic_custom_endpoint.py— full-run-safetytests/test_antigravity_install.py— full-run-safetytests/test_apm_fallback_version.py— full-run-safetytests/test_architecture_doc.py— full-run-safetytests/test_astro_extraction.py— full-run-safetytests/test_astro_import_ids.py— full-run-safetytests/test_atomic_canvas_export.py— full-run-safetytests/test_atomic_version_stamp.py— full-run-safetytests/test_atomic_writes.py— full-run-safetytests/test_backend_env_isolation.py— full-run-safetytests/test_backend_extras.py— full-run-safetytests/test_benchmark.py— full-run-safetytests/test_benchmark_raw_graph.py— full-run-safetytests/test_build.py— full-run-safetytests/test_build_merge_dedup_scope.py— full-run-safetytests/test_build_merge_hyperedges_and_prune.py— full-run-safetytests/test_build_merge_shrink_guard.py— full-run-safetytests/test_builtin_global_type_refs.py— full-run-safetytests/test_cache.py— full-run-safetytests/test_callflow_html.py— full-run-safetytests/test_cargo_introspect.py— full-run-safetytests/test_carried_hyperedge_remap.py— full-run-safetytests/test_case_sensitive_resolution.py— full-run-safetytests/test_charmap_encoding.py— full-run-safetytests/test_chunking.py— full-run-safetytests/test_cjs_module_extension.py— full-run-safetytests/test_claude_cli_backend.py— full-run-safetytests/test_claude_md.py— full-run-safetytests/test_cli_broken_pipe.py— full-run-safetytests/test_cli_export.py— full-run-safetytests/test_cli_help.py— full-run-safetytests/test_cluster.py— full-run-safetytests/test_codebuddy.py— full-run-safetytests/test_community_hub_labels.py— full-run-safetytests/test_community_labels_skill.py— full-run-safetytests/test_confidence.py— full-run-safetytests/test_corrupt_graph_json.py— full-run-safetytests/test_cpp_nested_and_cli.py— full-run-safetytests/test_cpp_objc_cross_file_calls.py— full-run-safetytests/test_cpp_preprocess.py— full-run-safetytests/test_cross_extension_reexport_self_cycle.py— full-run-safetytests/test_cross_language_call_resolution.py— full-run-safetytests/test_cross_repo_member_calls.py— full-run-safetytests/test_cross_repo_shared_types.py— full-run-safetytests/test_csharp_call_site_generic_args.py— full-run-safetytests/test_csharp_enum_members.py— full-run-safety- … and 225 more
non-code file(s) changed (
CHANGELOG.md) → running the full suite for safety (a code graph can't see config/fixture/data deps)
changed code file(s) with no mapped test (
CHANGELOG.md) — a coverage gap or a missing link — running the full suite rather than only the selected tests
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify \_rebuild\_code.
The verifier did not have enough to check \_rebuild\_code, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: parameter `watch_path` is annotated `Path` — outside the synthesizable primitive/collection set
· 7 more finding(s) on lines outside this diff (see the check run).
|
Shipped in v0.9.62 (now on PyPI: |
Fixes #2689.
Summary
On a VMware HGFS shared folder,
os.replace(src, dst)raisesPermissionError([WinError 5] Access is denied) whendstwas read earlier in the same process before being replaced — reproduced directly in the issue with a minimal snippet.graphify updateandcluster-onlydo exactly that: read the existinggraph.jsonfor the merge/shrink-guard comparison, then replace the temp file onto it. On this filesystem the rebuild aborts at that point,GRAPH_REPORT.md/graph.html/manifest.jsonnever get written, and the un-advanced manifest means every later run re-detects the same delta and fails at the same spot — incremental updates are permanently blocked.graphify/paths.pyalready hasos_replace_with_fallback(added in #3508, my own earlier PR) — it falls back to a copy-through-temp-and-rename-aside sequence on exactly thisPermissionError/WinError-5 case, andexport.py's clustered-path write already routes through it.watch.py's two incremental-rebuild write sites (theno_clusterfast path and the default clustered path) were both still using a plainPath.replace(), bypassing the fallback entirely — that's the actual gap this issue is hitting.Changes
graphify/watch.py: bothgraph_tmp.replace(existing_graph)call sites now callos_replace_with_fallback(graph_tmp, existing_graph)instead.tests/test_watch.py: two new regression tests (one per call site), each monkeypatchingos.replaceto always raise the simulated HGFSPermissionErrorand confirming the incremental rebuild still succeeds and lands the new content.CHANGELOG.md: entry under 0.9.61 (unreleased).Testing
python -m pytest tests/test_watch.py -k permission_error -q— 2 passedpython -m pytest -q— 5487 passed, 68 skipped (pre-existing unrelated failures excluded:tests/test_ollama_retry_cap.pymissing the optionalopenaimodule, andtest_ts_normalizer_scales_linearly_on_large_files/test_hyperedge_convex_hull_js_is_geometrically_sound, both known environment-specific flakes unrelated to this change)python -m tools.skillgen --check— OK🤖 Generated with Claude Code
https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh