Task: safejoin under a root
# Task: safe_join under a root
## Deliverable
Implement `safe_join(root: str, *parts: str) -> str` in `safe_join.py`.
## Spec
- Join `root` with zero or more path `parts` using `os.path` semantics, then
return the **normalized absolute** path.
- The result **must** stay under the normalized absolute `root` (as a path
prefix with a path separator, or equal to root).
- If any part would escape the root via `..` or absolute segments, raise
`ValueError` whose message contains `escape` (case-insensitive).
- Empty `parts` → normalized absolute root.
- Do not follow symlinks beyond what `os.path.abspath` / `normpath` do (no
extra symlink policy required).
- Stdlib only.
## Constraints
- Edit only the starter tree; no hidden-test edits.
## Done means
All hidden tests pass.when to use it
Community prompt sourced from the open-source GitHub repo TinkerandScribe/gxp (MIT). A "Task: safejoin under a root" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
productivitycommunitydeveloper
source
TinkerandScribe/gxp · MIT
more in Productivity
Productivity✓ tested
Summarize a doc into decisions & actions
chief of staff who extracts what to DO, not just what was said
Productivity✓ tested
Draft a reply to a hard email
calm, direct communicator who de-escalates without caving
Productivity✓ tested
Turn a brain-dump into a weekly plan
planning coach who protects your focus, not just your calendar