Repository navigation
#3815 (part 2): stored paths are NFC; include / copybook resolution matches across NFC and NFD - #3917
Merged
Merged
Conversation
…atches across NFC and NFD macOS exports and some zip / git checkouts write file names decomposed (NFD). The same estate then recorded different paths on two machines, a delta scan of an NFD checkout read an edit as a new file beside a stale one, and a COPY / #include spelled in one form never resolved a file stored in the other. - gitgalaxy/core/unicode_paths.py: nfc() (ASCII returned as-is) and on_disk() (a stored path back to the file system's spelling). - galaxyscope: the census keys every file by its NFC path and keeps the on-disk name in Orchestrator.disk_paths for the files where it differs; the worker, manifest gathering and the model-weights scan open the on-disk name. Two Unicode-equivalent names side by side are excluded with a reason, never merged. The import suffix/stem resolver compares the source's token in NFC. - Delta scan: git diff runs with core.quotepath=off (non-ASCII names were octal-escaped) and its paths are compared in NFC; the rehydrator re-keys an older baseline's NFD paths. - network_risk_sensor._resolve_target, invocation_resolver's program index, galaxy_ir's copybook / %INCLUDE / SYSTSIN member lookups and lookup(), the refractor controller: names compared in NFC, files opened by on-disk name. - chronometer: git log with core.quotepath=off, churn / author / mtime keyed NFC. - Unicode Gauntlet: expected paths are NFC; new mainframe `nfd-paths` cells (national names, file names written NFD) pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part 2 of #3815 (epic #3811, "4. Downstream: Paths"). Part 1 (#3896) did the generated-Java half.
What / why
macOS (HFS+/APFS exports) and some zip / git checkouts write file names decomposed (NFD:
e+ U+0301). Before this PR the engine stored whatever bytes the checkout had, so:file_paths;"cafe\314\201.cbl"), so the file came back as a new one next to the stale old row;COPY KÖNIG(NFC in source) did not resolve an NFD-namedkönig.cpy, and#include "naïve.h"spelled NFD did not resolve an NFCnaïve.h.Normalized vs on-disk
New
gitgalaxy/core/unicode_paths.py:nfc()returns ASCII strings unchanged (the same object), so pure-ASCII estates are byte-identical.on_disk(root, stored)maps a stored NFC path back to how the file system spells it.stem_map,file_size_map, unparsable/anomaly paths), every path the worker reports (path,stem, logs, encoding-glob matching), theram_cachekeys, sofile_data.file_pathand every downstream table too; the rehydrator re-keys an older baseline's NFD paths; chronometer churn/author/mtime maps.Orchestrator.disk_paths(NFC → on-disk, only for names that differ). The worker gets the on-disk name, and so do manifest gathering and the model-weights (tensor) scan. Incremental added/modified files record theirs too. Downstream: the refractor controller opens programs viaon_disk().Unicode-equivalent duplicate of another path (NFC/NFD).Resolvers changed (NFC on both sides)
galaxyscope._resolve_dependency_graph(suffix/stem import map): import token NFC'd.NetworkRiskSensor._resolve_target(import/COPY/%INCLUDE edges): token NFC'd. Map keys come from stored NFC paths.invocation_resolver._program_indexplus the CALL / transaction lookups.galaxy_ir:_copybook_file, the web-service copybook index,_continuation_entries(copy_members),_pli_fragment, the PL/I missing-%INCLUDE note,_systsin_member_text(an rglob of the disk, so NFD names there too), andlookup().git diffand chronometergit logrun with-c core.quotepath=off. Before, non-ASCII paths came back octal-escaped and never matched.Unicode Gauntlet
The existing
nfdscript only renames unit names (and paths, where a file name contains one) for the rosetta Unicode languages. There was no mainframe NFD file-name dimension. This PR addsmainframe|nordic|nfd-pathsandmainframe|german|nfd-paths: the national-name estate with its file names written NFD and its content UTF-8 NFC, so%INCLUDE INCAÄÖÜhas to find an NFD-namedINCAÄÖÜ.inc. Both pass. Without the engine change they fail with every renamed file shown as "missing" / "unexpected".expected()now NFC-normalizes the paths it predicts, which is the engine's contract.test_unicode_gauntletpins the two new cells.Left alone (noted)
_dependency_captureclass ([A-Z NATIONAL a-z0-9_-]) and PL/I's\wdo not match combining marks. A COPY / %INCLUDE whose source text is itself written NFD (as opposed to the file name) is cut at the mark. That is an identifier-alphabet question, so the "NFD-spelled include" test uses C#include "...".cobol_to_java_port_tickets.py/port_runner.pyopensource_root / stored_path. They are fine on macOS (a normalization-insensitive FS) and would miss an NFD-named file on Linux. I didn't touch them because another agent is working in those files.on_disk()is the helper to use there.cobol_compiler_forge.flatten_copybooksuses an ASCII-only COPY regex plus rglob. It is pre-existing and out of scope.Tests / gates
tests/core_engine/test_nfc_paths.py(11 tests; all fail before the change except the pure helpers):#includeresolves an NFC header;on_disk;tests/tools/pr_gates.py(full, before merging main): lint, audits, secrets, xray, gauntlet (128s), golden (232s) and suite (952s) all PASS (7/7). Golden masters are byte-identical, with no re-bless.git merge origin/main: the targeted tests passed (124), andpr_gates --only lint goldenpassed 2/2.🤖 Generated with Claude Code