Skip to content

Match Guard Self-Test Fixtures Across Path Separators for Windows - #2461

Merged
ptr727 merged 2 commits into
developfrom
feature/windows-guard-path-resolution
Oct 7, 2026
Merged

ptr727 merged 2 commits into
developfrom
feature/windows-guard-path-resolution

Conversation

@ptr727

@ptr727 ptr727 commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Summary

On a native Windows host, gh-write-guard.py --selftest failed 17 primary-checkout cases, and the installer runs that self-test before replacing any hook, so every Windows install refused (#2458).

  • The fixtures key fake checkouts by POSIX strings such as /primary. The rule's relative join runs a resolved value through os.path.normpath, which is ntpath on Windows and rewrites / to \. From Python 3.13, ntpath.isabs("/primary") is false, so absolute values take the join too. The exact-string fixture lookup then missed, and the rule failed open.
  • The fixture lookups now read every \ as / in both the key and the queried directory. Only the separator is folded, so collapsing .. stays the rule's job. The rule itself is unchanged.
  • A new test_install.py case runs the self-test with the guard's own os.path swapped for ntpath, so a POSIX CI host catches this regression.

Verification

  • The new test fails without the fix (3 cases on 3.12, 14 on 3.13) and passes with it on both versions.
  • Mutation check: with normpath removed from _join_relative, the native self-test fails 2 cases and the ntpath test fails, so the fold does not hide the rule's own normalization.
  • On Linux, --selftest passes and test_install.py passes (137 tests, 1 skipped). ruff and the prose gate are clean, and pyright reports no error beyond the develop baseline.
  • Not yet run natively on Windows. Emulation reproduces 14 of the 17 native failures, and a native run of this branch decides the other three. This PR waits on that run before it merges.

The older Git Bash gap in the rule itself, where a drive-prefixed /c/... spelling resolves wrongly and the rule fails open, is filed separately as #2460.

Refs #2458

🤖 Generated with Claude Code

The primary-checkout fixtures key fake checkouts by POSIX strings, and the
rule's relative join runs them through os.path.normpath, which is ntpath on
Windows and rewrites / to \. From Python 3.13, ntpath.isabs also reads a
rooted path with no drive as relative, so absolute values take the join too.
The exact-string fixture lookup then missed, the rule failed open, and the
self-test failed, which made every native Windows install refuse.

The fixture lookups now read every \ as / in both the key and the queried
directory. Only the separator is folded, so a case still fails where the
rule stops collapsing "..". The rule itself is unchanged.

A new install-suite case runs the self-test with the guard's own os.path
swapped for ntpath, so a POSIX CI host catches the regression.

Refs #2458

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI lite review requested due to automatic review settings October 7, 2026 00:34
@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: ptr727/ProjectTemplate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8793aba8-2ea1-491e-9896-02301acd2e00
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.47%. Comparing base (c3cbe63) to head (83c2f77).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2461   +/-   ##
========================================
  Coverage    58.47%   58.47%           
========================================
  Files           16       16           
  Lines         8062     8062           
========================================
  Hits          4714     4714           
  Misses        3348     3348           
Flag Coverage Δ
python-3.13 58.47% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🔵 Needs a closer look

Native Windows verification remains pending, and the test coverage documentation needs adjustment.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Fixes Windows path-separator mismatches in guard self-test fixtures and adds ntpath regression coverage.

Changes:

  • Normalizes fixture lookups across / and \.
  • Adds Windows path-semantics coverage to test_install.py.
File Summary
host-setup/​agent-safety/​claude/​test_install.py Adds Windows emulation coverage; docstring wording should accurately describe the skipped native case.
host-setup/​agent-safety/​claude/​gh-write-guard.py Normalizes fixture directory separators.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

The emulation test stubs out the one self-test case that spawns git, and
its docstring now says so, and names --selftest run with the host's own
paths as the only coverage of that case.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ptr727

ptr727 commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 83c2f776404ba893c53b299e9b68f3a1eeee339a, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727

ptr727 commented Oct 7, 2026

Copy link
Copy Markdown
Owner Author

Native Windows verification of 83c2f77 on Python 3.13.15: gh-write-guard.py --selftest prints SELFTEST PASS, and test_install.py runs to completion (137 tests) with no failure at the hook self-test step. The 11 failures that remain share one cause that predates this change, and it is filed as #2462.

@ptr727
ptr727 merged commit e93b673 into develop Oct 7, 2026
12 checks passed
@ptr727
ptr727 deleted the feature/windows-guard-path-resolution branch October 7, 2026 00:57
ptr727 added a commit that referenced this pull request Oct 7, 2026
…eparators for Windows (#2463)

## Summary

Promotes #2461 to `main`. The guard's self-test failed natively on
Windows, which made every Windows install refuse. Its primary-checkout
fixtures are POSIX-spelled, and `ntpath` rewrote the separators. The
fixture lookups now fold separators only, and a new install-suite case
runs the self-test under `ntpath`, so a POSIX CI host catches a
regression. The rule itself is unchanged.

Verified natively on Windows with Python 3.13.15: the self-test passes,
and `test_install.py` runs to completion with no failure at the hook
self-test step. Its 11 remaining failures predate this change and are
filed as #2462. The Git Bash path gap in the rule is filed as #2460.

Closes #2458

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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