Skip to content

feat(manager): update Pkl package URIs with a pkl manager and source - #350

Merged
sweepies merged 12 commits into
mainfrom
feat/pkl-manager
Nov 22, 2026
Merged

sweepies merged 12 commits into
mainfrom
feat/pkl-manager

Conversation

@sweepies

@sweepies sweepies commented Nov 22, 2026 •

Copy link
Copy Markdown
Owner

Adds a pkl manager, the Count's answer to renovatebot/renovate#47876 (still open upstream).

What it reads

package:// URIs in amends, extends, import and import* clauses and import(…) expressions of *.pkl files. It does not read the root patchula.pkl, whose imports config loading already limits to local modules. Config loading and the manager both read imports through patchula_config::pkl_imports, which walks pklr's own tokens.

Package URI Repository Release tags
package://github.com/<owner>/<repo>/releases/download/<tag>/<name>@<version> <owner>/<repo> spelled like <tag>
package://pkg.pkl-lang.org/github.com/<owner>/<repo>/<name>@<version> <owner>/<repo> <name>@<version>
package://pkg.pkl-lang.org/<project>/<name>@<version> apple/<project> <name>@<version>

I checked the pkg.pkl-lang.org redirects against the live service.

Design

  • A pkl source instead of github-releases. A package is named by its URI without scheme and version (pkg.pkl-lang.org/pkl-pantry/pkl.toml; a release URI writes its tag's version as %version%, which GitHub does not strip as HTML and globs read literally). Its catalog is the publishing repository's releases, narrowed to the package's own tags (patchula_config::PklPackage). This keeps the dozens of apple/pkl-pantry packages apart. Keyed by (github-releases, apple/pkl-pantry), they would share branch identities, Change joins, batch overlaps and line computation, and current as a raw tag would not parse as a version ([email protected] would land on 8.x).
  • Each repository is read once per run. Engine::catalogs adds a Pkl package's repository to the existing release batches and derives every package's catalog from that one fetch. The new recorded engine test asserts that apple/pkl-pantry is walked once for two of its packages.
  • Two copies, one update. A release URI's version appears twice (v2.9.0/[email protected]). Both are occurrences of one declaration, so the report merges them and one update writes both.
  • Skipped, with a reason: other hosts or paths, checksum-pinned URIs (::sha256:), tags that do not hold the version exactly once, non-semver versions, and escaped or interpolated strings. A skipped URI is shown without its fragment, and hidden entirely when its authority holds a user.
  • Release notes: the notes source lookup maps a Pkl package to its repository. The existing <name>@ tag matching covers the pantry tags.

Other changes

  • Docs: the managers guide gains a Pkl section, plus a row in the sources table and in the compatibility matrix.
  • Dogfood: patchula.pkl groups hk from mise and pkl, so hk.pkl (still at 2.9.0) moves with mise.toml.
  • Cached state versions are bumped for extract, files, config, config-files, catalog, catalog-controls, osv-advisory, changelog and the notes derives.
  • Corpus snapshots are unchanged; the corpus has no package URIs.

Testing

  • Unit tests in crates/manager/tests/pkl.rs, crates/config/src/pkl_package.rs and crates/datasource/src/pkl.rs.
  • Recorded engine test crates/engine/tests/pkl.rs (cassette fixtures/engine/pkl.json).
  • test:unit, clippy, the docs build and the fixtures scan all pass.
  • patchula lookup on this repository reports hk 2.9.0 → 2.13.0 at hk.pkl:1 (+1).

After review (Gemini 4 Neon, adversarial)

Fixed in ec069a3:

  • A batch whose file moved on since the PR now moves every copy of the first declaration's value, so a release URI never gets its tag moved without its @version.
  • Pkl writes exact versions (Written::Tag): versions = "widen" no longer proposes 2.9.0 || 2.13.0.
  • Placeholder <version> → %version% (GitHub stripped <version> from PR bodies as an HTML tag).
  • Package names and tags are limited to [A-Za-z0-9._+@-], dot segments excluded. Percent-encoded tags and overlapping version matches are skipped, and versions are checked with the semver parser lookup uses.
  • Skipped URIs drop their query and checksum, and are hidden whenever a password could be present.
  • Release notes match only a Pkl package's own tag spelling (a typed Namespace in patchula-notes).
  • The engine test checks each proposal against the recorded tags and counts unbatched first pages.
  • The catalog, changelog and notes-adapter state rows now list pkl_package.rs. Docs add pkl to the datasource and release-notes tables.

Second round, fixed in 783b865:

  • The batch fallback (all managers) now moves declarations only when every candidate holds one value. When declarations disagree and none holds the PR's value, they are left alone. Before, the batch could rewrite another line's declaration, and the first-round fix had widened that to every copy of it.
  • The shared Pkl lexer follows Pkl's escape rules. \""" no longer ends a text block. Custom-delimited strings escape with \# (they are not raw). Imports inside \( … ) interpolations count. This also affects config loading, which now reads those interpolated imports too.
  • Queries in package URIs are skipped as no release path. pkg.pkl-lang.org/github.com/<name> is not read as an Apple project. A host-only skipped URI has no trailing slash.
  • The release-notes guide says a repository-root changelog is read whole.

Third round, fixed in 0a94777: every finding was in the hand-written import lexer:

  • exponential backtracking on unterminated interpolations;
  • duplicate imports;
  • paren-depth drift;
  • missed or invented imports around quoted identifiers, $ and Unicode identifiers, shebang lines and single-line strings.

Round 2 found bugs of the same kind, so instead of patching again the lexer is removed. pkl_imports now walks pklr's own tokens, the lexer the evaluator uses, interpolations included, and returns an error instead of a partial list for a module pklr can't lex. pklr's interpolation depth limit bounds hostile input. An import has an editable range only when its string's contents are written exactly as they read, so an escaped or text-block URI is skipped, not edited. An unlexable .pkl file is skipped with a warning, and an unlexable config module fails config loading.

Fourth round, fixed in 414890e:

  • Semicolons between an import keyword, its ( and its string are skipped, matching pklr's parser, so import; "pkl:math" reaches config loading's local-only check.
  • An import(…) expression counts only when its string closes the parenthesis.
  • Lex errors name the line only, never the source text pklr quoted.
  • Skipped URIs holding anything but printable ASCII after decoding are hidden. The escaped-URI reason now says escapes or a text block, and the stale backslash check is gone.

Fifth round, fixed in 97ef86f:

  • .pkl is also Python's pickle extension, and a selected file that is not text refused the whole repository. A file only pkl selects (a new Ecosystem::shared_name hook) is now left out when it is not text and is not read over 1 MiB, using the tree's blob size, listed as skipped (round 7). Other managers' selected files still refuse when unreadable. Design per a Fable consult.
  • Stale state-versions hashes after e137533.
  • Pkl block comments do not nest: Apple's own lexer ends one at the first */, and only its language reference calls them nestable. pklr agrees, so that follow-up is withdrawn and the test that claimed nesting is corrected (e137533).

Sixth round, fixed in b10c412:

  • shared_name asked only which managers selected a path, so a files override for pkl covering .npmrc, pip.conf or a YAML manifest would skip or drop it. It now holds only for .pkl names and never for registry settings, credential-checked files or tooling manifests.
  • The TreeEntry size field changed the sources of more cached states: not-ours, source-head, tag-catalog and tag-object state versions and the github-release-head derive version are bumped.

Seventh round, fixed in bd45bc4:

  • The oversize-.pkl warning degraded the repository, which stops automerge and branch and PR cleanup for every manager. Oversize .pkl files are now skipped entries, like pip requirements files.

Eighth round, fixed in 5392561:

  • Text .pkl files that are not Pkl (Git LFS pointers for models, protocol 0 and 1 pickles) failed to lex and warned, degrading the repository. A Git LFS pointer, and an unlexable .pkl file ending with the . every pickle ends with, now import nothing and warn nothing. A file that lexes is always read; any other unlexable .pkl file still warns, so a broken real module keeps its PRs from being closed as obsolete.

Ninth round found nothing of high or medium severity. Its one low finding, Git LFS pointers with CRLF line endings, is fixed in 07addb5.

Final review (Opus 5.5) found nothing to fix before merge. Its simplifications are in b11b74f:

  • A .pkl file that never writes package: is not lexed and never warns. This replaces the Git LFS pointer and pickle-ending checks of rounds 8 and 9 and covers any other text format named .pkl. A file that writes package: but does not lex still warns.
  • .pkl files over 1 MiB are left out unreported, like binary ones, so a repository of model pickles gets no skipped rows. Scanner::oversize is gone.
  • Namespace in crates/notes no longer derefs to its name.
  • The Pkl guide says a suffixed tag (v2.12.0-final under v%version%) reads as a prerelease, and that rules match the pkl source, not github-releases.

Follow-ups (not in this PR)

  • PklProject dependencies, which also need PklProject.deps.json regenerated.
  • Checksum-pinned URIs, which could become a digest from the published <name>@<version>.sha256.
  • GitHub Enterprise Server release URIs.
  • A recheck and an ordinary lookup in one run each borrow a Pkl repository's release fetch, so apple/pkl-pantry can be read twice; quota only, never a wrong answer.
  • Ecosystem::shared_name is a general hook with one user (pkl); fold it into a .pkl check if no second ecosystem needs it.

View guided diff Turn on auto-fix

The pkl manager reads the package:// URIs in Pkl amends, extends and
import clauses: GitHub release URIs and both pkg.pkl-lang.org forms. Each
package is looked up in a new pkl source, named by its URI without scheme
and version, whose catalog is the publishing repository's releases
narrowed to the package's own tags. Packages of one monorepo, such as
apple/pkl-pantry, stay separate packages with branches of their own, and
the engine reads each repository's releases once per run for all of its
packages. A release URI's two copies of the version are occurrences of
one declaration, so an update writes both.

Checksum-pinned URIs, other hosts and PklProject dependencies are
skipped. The repository's own patchula.pkl is not read. Config loading
and the manager share one Pkl import lexer.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
count-patchula b11b74f Commit Preview URL

Branch Preview URL
Nov 22 2026, 10:00 AM

- A batch whose file moved on since the PR moves every copy of the first
  declaration's value, so a Pkl release URI never gets its tag moved
  without its @Version.
- Pkl packages write the release's exact version: widen no longer
  proposes a range no URI can hold.
- The version placeholder in release URI package names is %version%,
  which GitHub does not strip from PR bodies as an HTML tag.
- Package names and tags take only letters, digits and ._+@-, so dot
  segments, pipes, control characters and percent-encoded tags are
  skipped. Overlapping version matches in a tag are skipped too, and
  versions are checked with the semver scheme's own parser.
- Skipped URIs drop their query and checksum and are hidden whenever a
  password could be present.
- Release notes read a Pkl package's own tags only, with its exact
  spelling, so monorepo neighbours and plain v tags stay out.
- The engine test checks each proposal against the recorded tags and
  counts unbatched first pages; docs list the pkl source in the
  datasource and release-notes tables.
- The batch fallback moves declarations only when every candidate holds
  one value. Declarations that disagree, none at the PR's value, are left
  alone instead of rewriting another line's (or every copy of it), for
  every manager.
- The shared Pkl lexer follows Pkl's escapes: an escape reaches past the
  character it escapes (`\"""` no longer ends a text block), a custom
  delimiter changes the escape to `\#` (custom-delimited strings are not
  raw), and imports inside interpolations count.
- A query in a package URI is skipped as no release path, before the
  checksum check can misread it; pkg.pkl-lang.org/github.com/<name> is
  not an Apple project; a host-only skipped URI shows no trailing slash.
- The release-notes guide says a repository-root changelog is read whole.
The hand-written import lexer shared by config loading and the pkl
manager kept drifting from Pkl's grammar: review found exponential
backtracking on unterminated interpolations, duplicate imports,
paren-depth drift, and missed or invented imports around quoted
identifiers, `$` and Unicode identifiers, shebang lines and single-line
strings. Two review rounds found the same class, so the lexer is gone.

pkl_imports now walks pklr's tokens, the lexer the evaluator itself
uses, interpolations included, and returns an error for a module pklr
cannot lex instead of a partial list; its interpolation depth limit
bounds hostile input. Each import records the byte range of its string's
contents only when they are written exactly as they read, so the
manager skips an escaped or text-block URI rather than edit the decoded
string. An unlexable .pkl file is skipped with a warning; an unlexable
config module fails config loading.
- Semicolons between an import keyword, its parenthesis and its string
  are skipped, as pklr's parser skips them after every token, so
  `import; "pkl:math"` reaches config loading's local-only check.
- An `import(…)` expression counts only when its string closes the
  parenthesis.
- A lex error names the line only: pklr's message can quote the text it
  failed on.
- A skipped package URI that holds anything but printable ASCII after
  decoding is hidden, so no line break or terminal escape reaches a
  report. The escaped-URI reason says escapes or a text block, and the
  stale backslash check on decoded URIs is gone.
…ository

.pkl is also Python's pickle extension. A .pkl file only the pkl manager
selects is dropped when it is not text and not read over 1 MiB (from the
tree's size), with one warning counting those, where any other selected
file that cannot be read still refuses the repository.
…nifests

Scanner::shared_name now asks the ecosystem about the path, so a pkl
files override that selects settings, credential-checked files or YAML
manifests reads them as any selected file. Bumps the state and derive
versions whose sources the TreeEntry size field changed.
A warning degrades the repository, which stops automerge and branch and
PR cleanup for every manager. An oversize .pkl file is now a skipped
entry, like pip requirements files, so a large pickle leaves them on.
… modules

A Git LFS pointer, or a .pkl file pklr cannot lex that ends with the '.'
every pickle ends with, imports nothing and warns nothing, so it leaves
auto-merge and cleanup on. A file that lexes is always read, and any
other unlexable .pkl file still warns.
…rsize ones silently

A .pkl file that never writes package: imports no package, so it is not
lexed and never warns, which replaces the Git LFS and pickle-ending
guesses. Oversize .pkl files are left out unreported like binary ones,
so model pickles add no skipped rows. Namespace no longer derefs to its
name, and the Pkl guide covers suffix tags read as prereleases and which
names rules match.
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.

1 participant