Skip to content

Refuse a Tree Source That Names the Repository Root However It Is Spelled - #1462

Merged
ptr727 merged 1 commit into
developfrom
feature/validate-tree-source-root-final
Sep 9, 2026
Merged

ptr727 merged 1 commit into
developfrom
feature/validate-tree-source-root-final

Conversation

@ptr727

@ptr727 ptr727 commented Sep 9, 2026

Copy link
Copy Markdown
Owner

Addresses #1445.

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. 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 scoped
to 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 ./docs
fails 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 check
hand-rolls a weaker subset of this file's own escapes_repo_root, and the fix is to call that
function rather than restate part of it, which is a wider change than this one.

…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]>
Copilot AI lite review requested due to automatic review settings September 9, 2026 00:20
@coderabbitai

coderabbitai Bot commented Sep 9, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 48981192-fadd-469d-921c-a8dbb768dfaa


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.

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.

🟢 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/target validation 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.

@ptr727
ptr727 merged commit bcc06e3 into develop Sep 9, 2026
9 checks passed
@ptr727
ptr727 deleted the feature/validate-tree-source-root-final branch September 9, 2026 00:24
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