Repository navigation
Refuse a Tree Source That Names the Repository Root However It Is Spelled - #1462
Conversation
…lled `spec/validate.py` compared a tree source against `"."` as a raw string, so `"./"` and `".///."` passed the validator and were then refused by `scripts/carry.py`, which compares `PurePosixPath` objects. A manifest author got a green validator and a failing carrier, and the validator is the gate they run first. The comparison is now normalized, in a named helper beside `escapes_repo_root`, so the rule reads the way `carry.py` already resolves it. The helper is scoped to POSIX path rules and says so, since backslash and drive-letter spellings are the neighbouring function's subject rather than this one's. The diagnostic no longer enumerates the shapes it rejects, since the enumeration described the rule this change replaced. The test asserts the helper for five spellings of the root and seven ordinary sources, three of them carrying a redundant separator or a `./` prefix, so an over-eager normalizer that refused `./docs` would fail rather than pass. What it does not assert is the validator's own refusal of a manifest: the tree check sits inside `main()`, which this module has no fixture for, so reverting the call site while leaving the helper intact would leave every test green. That gap is real and is the reason this says what the test covers rather than claiming it covers the defect. Two defects of the same class remain in the same check and are filed rather than fixed here, since each is an escape rather than a root reduction and neither is what #1445 reports: a backslash spelling passes the validator and is refused by the carrier on Windows, and a symlinked source passes `is_dir()` here and is refused by the carrier everywhere. Both exist because this check hand-rolls a weaker subset of this file's own `escapes_repo_root`. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
The change corrects the validation/carry mismatch with a narrowly scoped helper and includes targeted unit tests for the new normalization behavior.
Pull request overview
This PR aligns spec/validate.py with scripts/carry.py by rejecting tree sources that reduce to the repository root under POSIX path normalization, preventing cases like "./" and ".///." from passing validation and then failing later during carry.
Changes:
- Add
reduces_to_repo_root()helper (POSIX-scoped) to normalize root spellings consistently. - Update the tree
source/targetvalidation to use the normalized root check and simplify the associated error message. - Add unit tests covering multiple root spellings and several non-root sources (including benign redundant separators /
./prefixes).
File summaries
| File | Description |
|---|---|
spec/validate.py |
Introduces root-reduction helper and uses it in tree path validation to reject root-equivalent spellings consistently. |
scripts/tests/test_spec_validate.py |
Adds tests for the new helper, covering root spellings and common non-root cases. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Addresses #1445.
spec/validate.pycompared a tree source against"."as a raw string, so"./"and".///."passed the validator and were then refused by
scripts/carry.py, which comparesPurePosixPathobjects. The validator is the gate a manifest author runs first, so the failure surfaced late and in
a different tool.
The comparison is now normalized in a named helper beside
escapes_repo_root. The helper is scopedto POSIX path rules and says so, since backslash and drive-letter spellings are the neighbouring
function's subject.
On the test
It asserts the helper for five spellings of the root and seven ordinary sources, three of them
carrying a redundant separator or a
./prefix, so an over-eager normalizer that refused./docsfails rather than passes.
It does not assert the validator's own refusal of a manifest. The tree check sits inside
main(),which this module has no fixture for, so reverting the call site while leaving the helper intact
would leave every test green. That gap is stated rather than papered over.
Left for #1452
Two defects of the same class remain in the same check, each an escape rather than a root reduction:
a backslash spelling passes here and is refused by the carrier on Windows, and a symlinked source
passes
is_dir()here and is refused by the carrier everywhere. Both exist because this checkhand-rolls a weaker subset of this file's own
escapes_repo_root, and the fix is to call thatfunction rather than restate part of it, which is a wider change than this one.