Skip to content

#3815 (part 2): stored paths are NFC; include / copybook resolution matches across NFC and NFD - #3917

Merged
squid-protocol merged 2 commits into
mainfrom
feat/3815-nfc-paths
Sep 27, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
feat/3815-nfc-paths

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

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:

  • the same estate scanned from an NFD and an NFC checkout recorded different file_paths;
  • a delta scan of an NFD checkout could not match git's name for an edited file to the baseline's (git also octal-escaped it: "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-named könig.cpy, and #include "naïve.h" spelled NFD did not resolve an NFC naï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.

  • Stored / reported in NFC: the census keys (stem_map, file_size_map, unparsable/anomaly paths), every path the worker reports (path, stem, logs, encoding-glob matching), the ram_cache keys, so file_data.file_path and every downstream table too; the rehydrator re-keys an older baseline's NFD paths; chronometer churn/author/mtime maps.
  • Opened by the real on-disk name: 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 via on_disk().
  • Collision: two names with the same NFC form side by side (Linux allows this) are not silently merged. The second is excluded with the reason 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_index plus 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), and lookup().
  • Delta scan: git diff and chronometer git log run with -c core.quotepath=off. Before, non-ASCII paths came back octal-escaped and never matched.

Unicode Gauntlet

The existing nfd script 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 adds mainframe|nordic|nfd-paths and mainframe|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-named INCAÄÖÜ.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_gauntlet pins the two new cells.

Left alone (noted)

  • COBOL's _dependency_capture class ([A-Z NATIONAL a-z0-9_-]) and PL/I's \w do 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.py open source_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_copybooks uses 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):
    • an NFD git checkout stores NFC paths;
    • an NFC COPY resolves an NFD copybook;
    • an NFD #include resolves an NFC header;
    • NFC and NFD checkouts give identical paths and edges;
    • a delta rescan after editing the NFD file keeps one row per file and re-scans the edit;
    • chronometer history is found by the stored path;
    • census bookkeeping and the collision case;
    • an NFD CALL resolves an NFC PROGRAM-ID;
    • on_disk;
    • ASCII identity.
  • 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.
  • After git merge origin/main: the targeted tests passed (124), and pr_gates --only lint golden passed 2/2.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits September 27, 2026 15:16
…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]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 95bbd05 into main Sep 27, 2026
38 checks passed
@squid-protocol
squid-protocol deleted the feat/3815-nfc-paths branch September 27, 2026 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant