fix(install): stop corrupting line endings and fix the re-install guard in _register_always_on_block - #3741
fix(install): stop corrupting line endings and fix the re-install guard in _register_always_on_block#3741ayushcodes10 wants to merge 3 commits into
Conversation
_register_always_on_block had three problems, all only visible on the claude and codebuddy paths that call it. Path.write_text opens in text mode, so on Windows appending a few lines to an existing CLAUDE.md rewrote the WHOLE file to CRLF, turning a one line registration into an eighty five line diff for anyone who keeps that file in a dotfiles repo or syncs it across platforms. Separately, the re install guard was a bare check for the word graphify anywhere in the file, so a user whose file mentioned the project for any other reason got silently treated as already registered and never received the real block, and an edited or stale block could never be repaired by re running install since the word was still present either way. Switch the write to pass newline equals empty string so existing line endings are never translated, and switch the guard to _replace_or_append_section, the same marker anchored helper claude_install and gemini_install already use, so a stale block is correctly refreshed instead of silently skipped. That helper's boundary detection was hardcoded to the next H2 heading, which does not fit this block's own heading level, so it gains a boundary_prefix parameter mirroring the one _remove_marker_section already has, kept in sync with a new shared marker constant so the paired removal function matches on exactly the same heading. Deliberately kept at H1 rather than switched to the H2 markers the issue itself suggested, since the existing removal function anchors on H1 specifically to never collide with a genuine user authored H2 heading elsewhere in the same file, a design choice from a separate earlier issue that a plain heading level change would have quietly broken. gemini_install writes GEMINI.md through the exact same text mode write, so it gets the same newline fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
Cover an unrelated mention of the word graphify no longer suppressing the real registration block, a stale or hand edited block correctly getting refreshed on re install instead of being left alone, and both the CLAUDE.md and GEMINI.md writers now passing newline equals empty string so an existing file's own line endings are never translated on write. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 2 advisory finding(s) below merit a look before merge.
Graphify review — findings
Fixes graphify install on Windows so appending its registration to an existing CLAUDE.md/GEMINI.md no longer rewrites the whole file to CRLF, by writing every shared file with newline="". Replaces the bare "graphify" in content idempotency check in _register_always_on_block with a marker-anchored _replace_or_append_section keyed on the new H1 _SKILL_REGISTRATION_MARKER, so an unrelated mention of the word no longer suppresses the real block and a stale or hand-edited block gets refreshed on re-install instead of skipped. Extends _replace_or_append_section with a boundary_prefix argument so the H1 skill-registration section matches its removal counterpart on where the section ends.
Worth a look
- _skill_registration lost leading newline, no separation from prior content on append —
graphify/install.py:401· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
- CRLF files are normalized to LF before appending registration —
graphify/install.py:397· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 752 functions depend on the 520 functions this change touches.
Health — this change adds coupling hotspots:
- new:
dispatch_command()— 2 callers, 125 callees - new:
install()— 13 callers, 11 callees - new:
codebuddy_install()— 20 callers, 5 callees - new:
gemini_install()— 11 callers, 7 callees - new:
claude_install()— 19 callers, 4 callees - new:
_copy_skill_file()— 12 callers, 6 callees - new:
claude_uninstall()— 17 callers, 4 callees - new:
_project_uninstall()— 5 callers, 13 callees - …and 14 more — each is listed as a finding
Verification — 752 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: 671 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
290 of 290 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— impact, full-run-safetytests/test_affected_member_seed.py— full-run-safetytests/test_agents_platform.py— impact, 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— impact, 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— impact, 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— impact, 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_external_call_guards.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-safety- … and 240 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.
· 22 more finding(s) on lines outside this diff (see the check run).
|
Shipped in v0.9.66 (on PyPI). Cherry-picked with authorship preserved so it shows under your GitHub contributions. Thanks @ayushcodes10! |
Fixes #3668.
_register_always_on_block(used by theclaude/codebuddyinstall paths) had three related problems:Path.write_textopens in text mode, so on Windows appending a few lines to an existingCLAUDE.mdrewrote the whole file to CRLF — an 85-line diff for a 3-line registration, for anyone keeping that file in a dotfiles repo or syncing it across platforms."graphify" in contentsubstring check — a file that merely mentions the project for any other reason gets silently treated as already registered, and a stale/edited block can never be refreshed by re-running install since the word is still present either way._skill_registrationemitted# graphify(H1), inconsistent with the## graphify(H2) the*_MD_MARKERconstants elsewhere in the file use.I initially tried the issue's own suggested fix for #2/#3 — switch to
## graphifyand reuse_replace_or_append_section/_CLAUDE_MD_MARKERdirectly, matchingclaude_install/gemini_install. That broke two existing tests (test_claude_subcommand_project_install_and_uninstall_are_project_scoped,test_uninstall_project_without_platform_removes_project_installs):_remove_claude_skill_registrationdeliberately matches the H1# graphifyheading specifically so it can never collide with a genuine user-authored H2## graphifyheading elsewhere in the file (#2062). Switching to H2 would have quietly reverted that protection.Instead: kept the H1 heading, and generalized
_replace_or_append_sectionwith aboundary_prefixparameter (mirroring the one_remove_marker_sectionalready has), added a_SKILL_REGISTRATION_MARKER = "# graphify"constant as the single source of truth, and wired both_register_always_on_block(write) and_remove_claude_skill_registration(removal) to it so insert and removal can never drift apart again. CRLF fixed by passingnewline=""on every write on this path, includinggemini_install'sGEMINI.mdwrite, which the issue explicitly flagged as the same bug.Five regression tests: an unrelated mention of "graphify" no longer suppresses the real block; a stale/edited block gets refreshed on re-install; both the
CLAUDE.mdandGEMINI.mdwriters now passnewline=""(verified via a call-tracking monkeypatch, since the actual CRLF corruption is only observable on Windows). All four bug-specific tests checked to fail against pre-fix code first. Full install test suite (213 tests) and the full suite (5718 passed) are green.🤖 Generated with Claude Code
https://claude.ai/code/session_017qfdzgbA5KedGEjD1AayNh