Skip to content

Materialize file names valid on the host; skip and name ones it can't write - #293

Merged
agorischek merged 4 commits into
mainfrom
fix/colon-paths-276
Dec 3, 2026
Merged

agorischek merged 4 commits into
mainfrom
fix/colon-paths-276

Conversation

@agorischek

@agorischek agorischek commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: abc48f905404b41f20dfe26b867c72b8239e93bd

Dimension Assessment Rationale
Change confidence 8.5/10 ↑ The issue's repro (weird:name.txt, package.json) now passes show, compare and a fresh-workspace toolchain run on macOS, as a native CLI test.
↑ The full projections-cli and projections-extractor-sdk suites pass locally, and cargo check --target x86_64-pc-windows-msvc --all-targets is clean. CI was green on the pre-rebase head 51fe334, Windows included.
↑ All seven Copilot review threads are addressed: six fixed, one declined with an explanation.
↓ Rebased onto #291; CI on this head is pending.
↓ The SDK's \ handling on Unix changes behaviour for definitions that used \ as a separator (called out in the changelog).
Diagnosis confidence 10/10 ↑ safe_path rejected : and \ on every platform and was called for every tree entry during capture, so one such file failed the whole revision with an unnamed error.
Evidence fit 9.5/10 ↑ The issue's exact repro fails on main and passes on this branch. The backslash case the reporter mentioned is covered too.

Refs #276

What was wrong

safe_path refused any repository path containing :, \ or NUL, with an error that didn't name the path. Capture calls it for every entry Git lists (ls-tree, ls-files), not just when materializing, so one tracked weird:name.txt made every projection of the revision fail. That included extractors that never read the file. doctor and list don't capture revisions, so they still passed.

What I chose for paths that can't be materialized

Paths now fall into three groups:

  1. Unsafe on every platform: refused, and the error names the path. These are empty paths, NUL, absolute paths, empty, . or .. segments, and .git components. On Windows the group also covers paths that leave the directory under its own parsing: a drive (C:x), \..\, and NTFS's other names for .git (.git., .git , GIT~1), as Git's core.protectNTFS guards. Git itself refuses to check these out, so finding one means the tree was crafted. Skipping it would hide that, so the whole revision still fails, as before, but the error now names the path (Unsafe repository path "..": it has an empty, . or .. segment).
  2. Valid in Git, but this platform can't write the name: skipped and named. On macOS and Linux nothing falls in this group, because : and \ are ordinary file-name characters. They are listed, written and read like any other name. On Windows the group covers <>:"|?*\, control characters, a trailing dot or space, and reserved device names. Those names are left out of the revision's file list, both in the runner and in the extractor SDK's Git-objects reader, so every placement sees the same set. They are recorded in Revision.unwritable with a reason, alongside the existing skipped-submodule mechanism. The reasoning:
    • Extractor sandboxes and containers only ever see what was written, so a skipped name can't leak in through another route.
    • Explicit needs fail clearly. If a declared source or extractor program is a skipped name, require_materialized fails and names it. A runner-side read_files of a skipped name fails with the reason instead of "does not exist". Projections that might have read it get a provenance limitation listing each skipped path within their scope, and a comparison notice.
    • Trust is unchanged. Skipping removes inputs and never adds any.
    • Caches: skipping depends on the platform, but extraction caches are per machine, and the provenance limitation records the skip in the document itself.
  3. Collisions on a case-insensitive file system (the macOS and Windows defaults). Two tracked paths that differ only in case can't both be written, and the same goes for a file and a directory such as A and a/child.txt. This used to fail with an unnamed File exists. Now the first in byte order is written, the second is skipped, and a limitation names it with the reason. This group is only found at write time, so placement records the note. Placement also checks the definition's declared sources and the command's program and path arguments against the copy: a collided run.sh fails, naming itself, instead of running the RUN.sh that took its name.

projections doctor lists the paths HEAD and the index track. Unsafe paths get a fail. Paths it can't write and case collisions get a warn that names each one. Collisions are checked within each snapshot separately, so a staged case-only rename doesn't warn. It adds no item when every path is fine, and a warn when the check itself fails.

The extractor SDK (relative_path, project_path, scope paths) used to treat \ as a separator, and x: as a drive, on every platform. As a result, back\slash.txt and a:b.txt were silently dropped or failed repository-map. Now both are separators only on Windows, matching the runner. Because this could change how a definition written with \ separators behaves on Unix, there's a behaviour-changes fragment for it.

Every error from these checks now names its path. That covers write_entry's symlink checks, Working path traverses a symlink, Working file replaced, and I/O failures while writing.

Known limit, not verified: on Windows, the worktree, clone and sparse workspace strategies check out through Git, which refuses such names. --workspace fresh goes through the new skip path instead.

Tests

  • packages/cli/src/runtime/entries/tests.rs: unsafe paths are refused and named. windows_reason is checked on every platform. : and \ names are written on Unix. A cfg(windows) case checks that names are skipped and that drive, traversal and NTFS .git paths are refused. A case collision is skipped, and the errors name their paths.
  • tests/native.rs (Unix):
    • The issue's repro plus back\slash.txt, through show (commit and working tree), compare, a --workspace fresh toolchain extractor that checks both files are on disk, and doctor. A crafted .. tree entry is refused and named.
    • Case collisions (asserted against the actual file system): doctor's warning, the provenance limitation, a collided extractor program that fails by name, and a staged case-only rename that doesn't warn.
  • runtime/capture/tests.rs: file-file and file-directory case collisions. SDK paths::separator_tests: \ and x: are separators only on Windows, scope paths included.
  • tests/windows.rs (cfg(windows)): a crafted weird:name.txt commit shows with a limitation naming it, and doctor warns.

Changelog: changelog.d/293.md (credits @IgnacioN99) and changelog.d/293-behaviour-changes.md. Docs: docs/runner/execution.md, docs/runner/commands.md.

agorischek added a commit that referenced this pull request Dec 3, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek requested a balanced review from Copilot December 3, 2026 15:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Materialization collisions are not revalidated before execution, allowing a skipped extractor path to resolve to and run the wrong executable on case-insensitive filesystems.

4 open issues
What changed in this PR

Addresses #276 by allowing host-valid filenames and reporting paths that cannot be materialized, rather than failing unrelated projections.

Changes:

  • Adds platform-aware path handling to the runner and extractor SDK.
  • Records skipped paths in provenance, comparison notices, and doctor diagnostics.
  • Adds regression tests and documents compatibility changes.
File Description
packages/​extractors/​sdk/​src/​source.rs Filters Windows-unwritable Git entries.
packages/​extractors/​sdk/​src/​paths.rs Adds platform-aware path rules.
packages/​extractors/​sdk/​src/​lib.rs Exports Windows filename validation.
packages/​cli/​tests/​windows.rs Tests skipped Windows filenames.
packages/​cli/​tests/​native.rs Tests valid names, traversal, and collisions.
packages/​cli/​src/​runtime/​revision.rs Tracks unwritable paths and limitations.
packages/​cli/​src/​runtime/​placement.rs Reports materialization collisions.
packages/​cli/​src/​runtime/​mod.rs Exports path diagnostics.
packages/​cli/​src/​runtime/​entries/​tests.rs Tests path validation and writing.
packages/​cli/​src/​runtime/​entries.rs Separates unsafe names from unwritable names.
packages/​cli/​src/​runtime/​document.rs Includes skipped-path limitations.
packages/​cli/​src/​runtime/​compare.rs Adds unwritable-path notices.
packages/​cli/​src/​runtime/​capture/​read.rs Rejects reads of skipped paths explicitly.
packages/​cli/​src/​runtime/​capture/​mod.rs Classifies paths and gathers doctor diagnostics.
packages/​cli/​src/​runtime/​capture/​materialize.rs Records skipped writes and improves errors.
packages/​cli/​src/​runtime/​capture/​locate.rs Filters unwritable revision entries.
packages/​cli/​src/​doctor/​paths.rs Adds repository-path diagnostic items.
packages/​cli/​src/​doctor.rs Integrates path checks.
docs/​runner/​execution.md Documents platform-specific materialization.
docs/​runner/​commands.md Documents doctor’s path checks.
changelog.d/​293.md Summarizes filename-handling fixes.
changelog.d/​293-behaviour-changes.md Notes Unix backslash compatibility changes.

Review effort: Balanced

Comment thread packages/cli/src/runtime/placement.rs Resolved
Comment thread packages/cli/src/runtime/capture/mod.rs Resolved
Comment thread packages/cli/src/runtime/capture/mod.rs Resolved
Comment thread packages/extractors/sdk/src/paths.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

3 open issues
4 resolved since last review

Review effort: Lite

Comment thread packages/cli/src/doctor/paths.rs Resolved
Comment thread packages/cli/src/runtime/capture/mod.rs Resolved
Comment thread packages/cli/src/runtime/placement.rs Resolved
Copilot stopped reviewing on behalf of agorischek due to an error December 3, 2026 16:26
agorischek and others added 4 commits December 3, 2026 08:34
A tracked file with `:` or `\` in its name made every projection of the
revision fail with an unnamed "Unsafe repository path". On macOS and Linux
those are ordinary file names, so they are now listed and written like any
other. On Windows, names it can't create are skipped and named in provenance
limitations, as are paths that collide on a case-insensitive file system; a
definition that requires one fails naming it. Unsafe paths (traversal,
absolute, `.git`) still fail the revision, and every error names the path.
`projections doctor` warns about tracked paths this platform can't write.

Refs #276

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…ollisions

- A declared source or extractor program that collided while materializing
  (case-insensitive file system) now fails, naming it, instead of running the
  file that took its name.
- doctor detects collisions within HEAD and the index separately (a staged
  case-only rename isn't one) and also file-versus-directory collisions.
- The SDK's scope paths keep `\` as a file-name character off Windows, as
  `project_path` and `relative_path` do.
- Regenerate docs/reference/extractor-sdk.md for `windows_reason`.

Refs #276

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… path

Refs #276

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@agorischek
agorischek merged commit 3478c0b into main Dec 3, 2026
36 checks passed
@agorischek
agorischek deleted the fix/colon-paths-276 branch December 3, 2026 17:03
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.

2 participants