phasespace-labs / phasespace-labs/palinode

rel_path is backslash-separated on Windows: to_rel_path uses os.path.relpath and nothing normalises to POSIX form

Open
#214 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Python
Stars
39
Forks
42
Avg merge
1d 1h
Merged PRs (30d)
37

Description

`rel_path` is part of the API contract — `test_rel_path_api_parity.py` exists to hold it — and on Windows it is built from `os.path.relpath`, which returns backslash-separated paths.

**The chain.** `_enrich_with_rel_path()` (`palinode/api/search_helpers.py`) is what attaches `rel_path` to search, associative, dedup-suggest, orphan-repair and topic-coverage results. It calls `to_rel_path()` (`palinode/core/path_guard.py`), whose body is `os.path.relpath(file_path, base)`. That is correct POSIX behaviour and correct Windows behaviour — it is just not the same string, and **`as_posix()` appears nowhere in the package.**

**Seven `test_rel_path_api_parity` tests fail on native Windows** in @Kaap10's 3.12 inventory and @kevin-lozada-santos's 3.11 inventory, both posted on #169. Whether all seven trace to this expression is for the fix to establish — **that has not been verified, and it should not be assumed.**

**A separate, smaller instance in the same family.** `palinode/core/store.py` derives a path for associative results with `fp.replace(config.memory_dir + "/", "").lstrip("/")` — a hardcoded separator. On Windows that replace never matches, so the value stays absolute. It feeds the result's `category` field, **not** `rel_path`, so the consequence is a wrong category rather than a broken contract. Worth fixing in the same pass; worth not conflating with the above.

**The precedent is already in the tree.** `palinode/core/skip_dirs.py` does `rel_path.replace(os.sep, "/")`. Someone solved this once, in one place, and it was never generalised.

**What is wanted:** `rel_path` renders in POSIX form on every platform, and a test that pins it so the next refactor cannot quietly undo it. Where the normalisation belongs — inside `to_rel_path`, or at the enrichment boundary — is a design call worth stating in the PR.

**Not in scope:** the rest of the Windows suite failures. Those are being carved separately.

**Context:** found by @Kaap10 and @kevin-lozada-santos during the native Windows runs on #169.

**Reserved for @Kaap10**, who claimed this slice on #169. GitHub currently rejects the direct assignment on this new issue; it is not open for another claim.

Contributor guide

Open the contributing guide

Research direction

Start with palinode/core/path_guard.py and palinode/api/search_helpers.py, then run test_rel_path_api_parity.py on Windows to confirm which cases fail. Review the separator precedent in palinode/core/skip_dirs.py and the associative path logic in palinode/core/store.py. Done means rel_path is POSIX-formatted across platforms, the contract is pinned by tests, and the separate category issue is handled or explicitly excluded.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.