Skip to content

RFC 38: measure relative paths in a fragment from that fragment - #40

Merged
zkochan merged 1 commit into
mainfrom
rfc/config-fragments-file-relative-paths
Oct 16, 2026
Merged

zkochan merged 1 commit into
mainfrom
rfc/config-fragments-file-relative-paths

Conversation

@zkochan

@zkochan zkochan commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Summary

Changes how relative paths inside a local fragment of RFC 38 resolve. They are now measured from the directory of the fragment's include path, not from the workspace root.

  • Includes: a relative path in a fragment is relative to that fragment, just as one in the root manifest is relative to the workspace root. The rule covers path-valued settings (packages, patchedDependencies, patchesDir, pnpmfile, storeDir, ...), a scriptShell that contains a separator, and file:, link: and bare-path specifiers in catalogs and overrides. Absolute, ~ and $VAR paths are unchanged. pnpm re-expresses them from the root when merging, so the merged configuration means what the same values would mean in the root manifest.
  • Writes: a path pnpm writes to a fragment, such as a patch-commit entry, is written relative to that fragment.
  • Rationale and Alternatives: root-relative paths move here as the rejected alternative.
  • Prior Art: adds tsconfig.json extends and Docker Compose include, which resolve paths from the included file.
  • Unresolved Questions: notes that the file-relative rule gives package-provided paths a natural base, the package itself, if they are ever allowed.

Why

Root-relative paths keep a setting's meaning when it moves between files, but they stop a fragment from being kept with the files it names. A patch list in patches/patches.yaml would have to spell patches/ in every entry. Config dependency entries could only resolve paths from the package, which would give the two kinds of source two rules. Moving a setting between files by hand is rare, and pnpm's own writes already go to the owning file.

The implementation is in pnpm/pnpm#16967.


Written by an agent (Claude Code, claude-opus-5-5).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Clarified that local-fragment paths are relative to the fragment’s location, including how paths are represented when fragments are merged.
    • Updated examples and guidance for writing paths to local fragments.
    • Clarified how package-defined paths would resolve, while noting that they remain disallowed.

A relative path in a local fragment is now relative to the directory of
the fragment's include path, the way a relative path in the root
manifest is relative to the workspace root. This lets a fragment sit
next to the files it names, such as a patch list in `patches/`, and
gives config dependency entries a consistent base if path-valued
settings are ever allowed there. Root-relative resolution moves to the
alternatives considered.

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

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d04edd20-92da-4ced-a020-af1354204d6f
📥 Commits

Reviewing files that changed from the base of the PR and between d574a3c and 6186195.

📒 Files selected for processing: 1
  • text/0000-config-fragments.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
🔇 Additional comments: 1
text/0000-config-fragments.md: 1

95-107: LGTM!

Also applies to: 296-296, 357-360, 396-396, 405-405

📝 Walkthrough

The RFC now describes local fragment paths as relative to the included fragment. It updates the examples, write guidance, rationale, prior-art reference, and an unresolved question.

Changes: Local Fragment Paths

Layer / File(s) Summary
Path resolution rule and supporting guidance
text/0000-config-fragments.md
The RFC describes fragment-relative path resolution and workspace-root re-expression during merging. It updates the example, write guidance, rationale, prior-art reference, and package-path question.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 61861

The RFC consistently describes the proposed path behavior, and this change presents no actionable mergeability risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: resolving relative paths from the fragment that contains them.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · 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

A rabbit reads the fragment rule,
And hops beside the patch file’s door.
“Resolve from where the fragment lives,”
It scribbles in the RFC.
Then bounds away through clover fields,
With tidy paths and nothing more.

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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

RFC 38: Resolve fragment paths relative to the fragment

📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Define fragment-relative resolution for local paths while preserving absolute and expanded paths.
• Specify fragment-relative paths for pnpm writes, keeping generated entries beside their targets.
• Document the rejected root-relative rule, prior art, and implications for package sources.
Diagram

graph TD
  R["Root manifest"] --> F["Local fragment"] --> D{"Relative path?"} -->|yes| B["Fragment directory"] --> M["Merged config"]
  D -->|no| M
  W["Project writes"] --> F
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Resolve all fragment paths from the workspace root
  • ➕ Moving a setting between files would not change its meaning.
  • ➖ Fragments could not move with the files they reference without rewriting paths.
  • ➖ Local and potential package-provided fragments would have different path bases.

Recommendation: Keep fragment-relative paths. They let fragments live alongside referenced files and give pnpm reads and writes a consistent base; the root-relative alternative favors the less common case of manually moving settings between files.

Files changed (1) +20 / -2

Documentation (1) +20 / -2
0000-config-fragments.mdSpecify fragment-relative path resolution in RFC 38 +20/-2

Specify fragment-relative path resolution in RFC 38

• Defines which paths in local fragments resolve from the fragment directory and how pnpm re-expresses them when merging. Clarifies that writes use the same base, explains the rejected root-relative alternative, cites prior art, and narrows the remaining question about package-provided paths.

text/0000-config-fragments.md

zkochan added a commit to pnpm/pnpm that referenced this pull request Oct 16, 2026
Implement the config fragments RFC in pnpm v12.

The root pnpm-workspace.yaml can list local YAML files and config
dependencies under `include`, each mapped to the settings it owns (or
'*' for local files). Every setting and catalog slot (catalog,
catalogs.<name>, catalogs) has exactly one owner; a listed setting is
reserved even when the file omits it, and legacy aliases share their
canonical setting's owner.

pnpm-workspace loads the include index and merges the fragments into one
document that every reader consumes: config loading, workspace package
discovery, catalogs, changed-catalog detection in the projects filter,
and the napi config cache. Without `include` the root text is read as
before. Fragments are normalized (merge keys applied, tags dropped,
scalar keys stringified) before ownership is checked, so a fragment
cannot define a catalog it was not delegated through a tag or a `<<`
merge.

A relative path in a local fragment is relative to the directory of
the fragment's include path, the way a path in the root manifest is
relative to the workspace root. The loader re-expresses each fragment's
relative paths from the workspace root before merging: path settings,
`packages` globs, `pnpmfile`, `patchedDependencies`, a path-like
`scriptShell`, and local specifiers in catalogs and `overrides`
(re-anchored with the same LocalSpec logic catalogs use). Absolute,
`~` and `$VAR` paths are kept. This departs from the RFC, which
resolved fragment paths from the root, so a fragment can sit next to
the files it names. The RFC change is pnpm/rfcs#40.

workspace-manifest-writer routes every write to the owning file. Writes
to settings owned by a config dependency fail, `include` itself is never
written, included files are never deleted, and symlinked includes are
written through. Paths it writes to a fragment, such as patch-commit
entries, link: overrides and local catalog entries, are written
relative to that fragment. Every file's edit is computed before any
file is written, so a rejected edit leaves the workspace unchanged, and
a failed write restores the files written before it.

A config dependency names its settings file in package.json
`pnpm.config`. The entry must stay inside the installed package and may
only define delegated settings. Its values are applied at the project
layer after config dependencies are installed and before hooks run, so
they take effect on the first install too. Installs fail closed when an
included package's entry cannot be loaded.

`bootConfig` holds the policy (minimumReleaseAge*, trustPolicy*) used to
resolve config dependencies and the packageManager pnpm version.
Package-owned keys fall back to the values from below the project layer,
env and CLI overrides still win, and self-update ignores it.
@zkochan
zkochan merged commit aff5f5c into main Oct 16, 2026
1 check passed
@gluxon

gluxon commented Oct 16, 2026

Copy link
Copy Markdown
Member

Good idea!

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