Repository navigation
Conversation
The 200-byte stem cap from Graphify-Labs#1094 assumes the conventional 255-byte NAME_MAX. eCryptfs (Ubuntu's "encrypt my home folder") reports 143 because of its filename-encryption overhead, so a 150-200 byte label still produced a name the filesystem rejects and `graphify export obsidian` / `export wiki` aborted with ENAMETOOLONG. stem_filename_budget() already sizes every Obsidian, canvas and wiki stem against the destination (Graphify-Labs#2655), but returned the limit unchanged on POSIX. It now also caps the budget at the destination filesystem's PC_NAME_MAX less the caller's reserve and the ".md" extension, asking the nearest existing ancestor when the export directory does not exist yet. At the conventional 255 the budget is still 200, so output on ordinary filesystems is byte-for-byte unchanged. Closes Graphify-Labs#2109 Co-Authored-By: Claude <[email protected]>
|
Thanks for the pull request, @Synvoya. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify code review 
Review completed · 2d33fc737d94
Warning
Merge confidence: 3/5 · Review before merging · 🟠 High impact
2 P2 bugs · 1 preexisting
The filename budget now consults POSIX PC_NAME_MAX in addition to the existing Windows path-length calculation.
Full summary
The filename budget now consults POSIX PC_NAME_MAX in addition to the existing Windows path-length calculation. Obsidian, Canvas, and wiki exports use that budget to cap generated filenames.
Bugs (2)
P2 · Cap the stem budget at the space left after the suffix and .md: stem_filename_budget can exceed a very small PC_NAME_MAX, so _safe_filename may generate an unwritable filename. Inspect source
Detailed review · checked against the code
Exports can exceed very small POSIX filename limits
On a filesystem reporting NAME_MAX below the budget floor, long labels can still produce filenames that are too long, aborting the export.
Expected: The generated filename component, including its extension and any reserved suffix, fits within the filesystem's component limit.
Actually: The minimum budget can exceed the available space, allowing an overlong filename that can make the export write fail.
On POSIX, when PC_NAME_MAX is available, stem_filename_budget returns at least 16 even if name_max - reserve - len(".md") is smaller. For a limit of 14 and reserve of 5, that produces a 16-byte stem budget, although only 6 bytes remain for the stem. The wiki exporter passes that budget to _safe_filename, appends .md, and writes the resulting filename. A long ASCII label can therefore yield a 19-byte component on a filesystem limited to 14 bytes, causing the write to fail. The previous POSIX implementation returned limit without deriving a budget from PC_NAME_MAX; the faulty floor is introduced by this change.
- Independent source review: The existing low-NAME_MAX test uses 143 bytes and verifies the budget fits there; it does not cover values below the 16-byte floor plus reserve and extension. The wiki caller uses the computed limit directly when slugging and writing article filenames; no smaller-component guard appears in the inspected route.
P2 · Truncate slugs by UTF-8 byte length in _safe_filename: stem_filename_budget is a byte allowance, but character slicing lets multibyte wiki article names exceed PC_NAME_MAX and fail on write. Inspect source
Detailed review · checked against the code
Non-ASCII wiki names can still exceed the filesystem limit
On filesystems with a low NAME_MAX, exporting a wiki with non-ASCII labels can still fail when article files are written.
Expected: Every article filename, including its extension and any collision suffix, fits within the filesystem's component-byte limit.
Actually: The POSIX byte budget is used as a character slice limit; multibyte characters can make the resulting filename exceed the limit and cause an article write to fail.
On POSIX, stem_filename_budget computes a byte allowance from PC_NAME_MAX and subtracts the reserved suffix and .md extension. to_wiki passes that number to _safe_filename, which slices by Python characters. With NAME_MAX=143, reserve 5, and a label whose slug has at least 135 three-byte UTF-8 characters, the resulting filename can exceed the byte limit and fail when written. The path reaches article writes for both community and god-node slugs. The behavior is a bounded wiki-export failure under low component limits and sufficiently long multibyte labels.
-
Independent source review: The multibyte wiki test uses CJK labels, but replaces the budget function with a fixed value and asserts character length and link resolution—not encoded filename byte length. It therefore does not prevent the reported overrun. Base source also returned a 200-character POSIX budget, so long multibyte labels on low-NAME_MAX filesystems could already exceed the byte limit before this change; the new calculation reduces but does not eliminate that case.
-
Also reported as: Wiki filenames can still exceed a low byte limit for Unicode labels
Code graph and static checks · 5068 functions depend on this change
Impact & health
Impact — 5068 functions depend on the 237 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
to_obsidian()— 44 callers, 14 callees - worse:
to_wiki()— 58 callers, 8 callees - worse:
to_canvas()— 21 callers, 5 callees
Formal checks — 5068 functions this change can affect weren't formally checked in this review. Formal checks are informational only.
Gate & verification
✅ PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 2983 function(s) in the blast radius were not formally verified this run
Test selection
219 of 593 test file(s) selected (37%) via static blast radius.
tests/test_4874_jvm_resolution.py— impacttests/test_affected_cli.py— impacttests/test_affected_overrides.py— impacttests/test_affected_path_file_node.py— impacttests/test_affected_seed_reference_forms.py— impacttests/test_agents_platform.py— impacttests/test_alias_folding.py— impacttests/test_analyze.py— impacttests/test_atomic_canvas_export.py— impacttests/test_atomic_version_stamp.py— impacttests/test_atomic_writes.py— impacttests/test_benchmark.py— impacttests/test_benchmark_raw_graph.py— impacttests/test_benchmark_real_query.py— impacttests/test_binary_media_words.py— impacttests/test_build.py— impacttests/test_build_located_semantic_identity.py— impacttests/test_build_merge_dedup_scope.py— impacttests/test_build_merge_ghost_fold_4955.py— impacttests/test_build_merge_hyperedges_and_prune.py— impacttests/test_build_merge_shrink_guard.py— impacttests/test_c_include_resolution.py— impacttests/test_cache.py— impacttests/test_cache_long_paths.py— impacttests/test_cache_stale_import_target.py— impacttests/test_cache_windows_case_4925.py— impacttests/test_callflow_html.py— impacttests/test_carried_hyperedge_remap.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_claude_md.py— impacttests/test_cli_export.py— impacttests/test_cluster.py— impacttests/test_codebuddy.py— impacttests/test_community_labels_skill.py— impacttests/test_compact_graph_json.py— impacttests/test_confidence.py— impacttests/test_confidence_score_output.py— impacttests/test_corrupt_graph_json.py— impacttests/test_cpp_forward_declarations.py— impacttests/test_cpp_member_declaration_identity.py— impacttests/test_cpp_objc_cross_file_calls.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_csharp_method_owner_labels.py— impacttests/test_csharp_object_creation.py— impacttests/test_csharp_partial_classes.py— impacttests/test_dedup.py— impacttests/test_dedup_prefix_derived_words.py— impacttests/test_dedup_remaps_hyperedges.py— impacttests/test_dedup_shrink_refuses_force_write.py— impact- … and 169 more
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.
Every flagged function
to_wiki()ingraphify/wiki.py:306· 58 callers, 8 callees: fans out to 8 callees (efferent coupling); 58 callers depend on it (afferent coupling)to_obsidian()ingraphify/export.py:847· 44 callers, 14 callees: fans out to 14 callees (efferent coupling); 44 callers depend on it (afferent coupling)to_canvas()ingraphify/export.py:1210· 21 callers, 5 callees: 21 callers depend on it (afferent coupling)
Maintainer tweaks on top of the #5299/#5394/#5315/#5374 batch: - Move `import anyio` in serve.py to module top (was re-imported per call inside _warm_graph), a trivial cleanup on #5374. - 0.9.117 changelog and version bump. No AST-cache schema change in this batch (query scoring, export filenames, serve reload, rcfile parsing). Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.118 via an authorship-preserving cherry-pick. Export filenames now honor the target filesystem's NAME_MAX (probed via pathconf), so export no longer aborts with ENAMETOOLONG on filesystems like eCryptfs that report 143; long names are truncated with a hash suffix and internal links use the shortened names. Thanks @Synvoya! |
Follow-up to Graphify-Labs#5315. stem_filename_budget() returns a byte budget on POSIX, but two paths still overran it: - Where NAME_MAX leaves less room than the 16-byte floor after the reserve and ".md", the floor won and produced a name the filesystem rejects. The budget now drops to what fits, and _cap_filename keeps what fits when there is no room for its "_" + 8-hex digest instead of slicing with a negative index. - wiki._safe_filename sliced characters, so a CJK label could exceed a byte-based NAME_MAX. It now caps UTF-8 bytes, as _cap_filename already does for Obsidian (Graphify-Labs#1094). Co-Authored-By: Claude <[email protected]>
Follow-up to #5315. stem_filename_budget() returns a byte budget on POSIX, but two paths still overran it: - Where NAME_MAX leaves less room than the 16-byte floor after the reserve and ".md", the floor won and produced a name the filesystem rejects. The budget now drops to what fits, and _cap_filename keeps what fits when there is no room for its "_" + 8-hex digest instead of slicing with a negative index. - wiki._safe_filename sliced characters, so a CJK label could exceed a byte-based NAME_MAX. It now caps UTF-8 bytes, as _cap_filename already does for Obsidian (#1094). Co-Authored-By: Claude <[email protected]> (cherry picked from commit ffc921c)
What does this PR do?
Fixes #2109. Re-submission of #2118, rebased onto current v8 (340268a), which supersedes it.
Export filename capping assumes the conventional 255-byte
NAME_MAX. eCryptfs (Ubuntu's "encrypt my home folder") reportsPC_NAME_MAX=143because of its filename-encryption overhead, so a 150-200 byte label still produces a name the filesystem rejects, andgraphify export obsidian/export wikiabort withENAMETOOLONG.stem_filename_budget()(#2655) already sizes every Obsidian note, community note, canvas reference and wiki article stem against the destination, but returnedlimitunchanged on POSIX. It now also caps the budget at the destination filesystem'sPC_NAME_MAX, less the caller'sreserveand.md. When the export directory does not exist yet, it asks the nearest existing ancestor. Ifpathconfis unavailable or fails, the budget is unchanged. The WindowsMAX_PATHbranch is untouched.Type of change
Verification & Invariants
Invariant: every file an exporter writes has a name the destination filesystem accepts, and links keep pointing at the files actually written. On ordinary filesystems (
NAME_MAX255) output is byte-for-byte unchanged: the largest caller reserve is 16 (_COMMUNITY_plus the dedup suffix), so 255 - 16 - 3 = 236 is still above the 200 limit. This touches path handling, so I checked that the only new input is thepathconfresult for the export directory or its ancestors; no new path is built from graph data.Limitations:
The wiki slug is still capped in characters (as export obsidian / export wiki abort on Windows: the filename cap is sized for NAME_MAX and ignores MAX_PATH, so one long label kills the whole export #2655's tests specify), so a long multibyte wiki label can exceed a byte-based
NAME_MAX. That is true at 255 as well and is left for a separate change.Tested with a controlled
pathconfresult. I don't have an eCryptfs mount; the reporter of _cap_filename's hardcoded limit=200 assumes NAME_MAX=255; breaks on eCryptfs (real limit can be ~143 bytes) #2109 offered to verify on one.Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
How was this tested?
Python 3.11.16 on macOS, environment from
uv sync --all-extras, branch based on v8 340268a.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (No skill sources touched.)AI disclosure: drafted with help from Claude Code and reviewed before posting; the commit carries a
Co-Authored-Bytrailer.