Skip to content

[pkgdef 5/6] feat(pkgdef): support the initial package set - #3035

Open
mikeland73 wants to merge 11 commits into
mikeland73/pkgdef-packagesfrom
mikeland73/pkgdef-package-support
Open

mikeland73 wants to merge 11 commits into
mikeland73/pkgdef-packagesfrom
mikeland73/pkgdef-package-support

Conversation

@mikeland73

@mikeland73 mikeland73 commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Stack (merge in order):

  1. [pkgdef 1/6] docs(specs): add package definition spec and Go example #3000 — spec + Go example
  2. [pkgdef 2/6] feat(pkgdef): add package definition library #3001 — internal/pkgdef library
  3. [pkgdef 3/6] feat(pkgdef): wire package definitions into add, lock, install and env #3002 — wiring into add/lock/install/env (behind DEVBOX_FEATURE_PKG_DEFS)
  4. [pkgdef 4/6] feat(pkgs): add the initial set of package definitions #3034 — initial package set (15 definitions)
  5. [pkgdef 5/6] feat(pkgdef): support the initial package set #3035 — format features for the initial package set 👈 this PR
  6. [pkgdef 6/6] test(pkgs): install and switch versions of every shipped package #3036 — per-package install/switch tests + CI

Summary

Fifth PR of the package definitions stack. Implements the format features from #3034 that the initial package set needs, and fixes a wiring bug the package tests found.

Platforms a version isn't published for. Any of these means ErrNoArtifact:

  • a 404 from a checksum file or index;
  • a checksum list without the file;
  • a jq expression that matches nothing (or only null);
  • a GitHub release without the asset.

Lock leaves that system out and fails only when no platform has an artifact. Installing on a system the lock entry leaves out is a user error that names the platforms the version is available for.

New format features:

  • install.lookup: read the URL and checksum from a JSON index with a jq expression. Used by python, java and zig.

  • install.version_overrides: partial installs for versions matching a constraint (<11, >=2, <4). They apply before system overrides, and a version override can carry its own system overrides.

  • versions as a list of sources, combined.

  • Lazy pagination: github_releases reads 100 per page, and http_json paginates when its URL contains {{.Page}}. Resolution stops at the first page with a match, so latest costs one request.

  • Versions with +build metadata compare correctly and prefix-match (21.0.12 matches 21.0.12+101). Build metadata containing letters is not a pre-release.

  • Checksums:

    • sha512, sha256:/sha512: prefixes and SRI digests;
    • a new sha512_url type;
    • github_release, which reads GitHub's asset digests through the authenticated API.

    devbox.lock gets an omitempty sha512 per system.

  • binaries must be plain file names; they are made executable after extraction and must exist after install (checked after post_install, so hooks may create them).

  • post_install runs through /bin/sh, with /usr/bin:/bin appended to PATH.

  • Template function splitList.

Other library changes:

  • The client memoizes metadata responses, so locking four systems fetches an index once. Remote definition loads are not memoized, so a changed definition is still detected.
  • The install fingerprint now takes the version, since overrides can make two versions install differently.

Wiring fix. After a version was changed in devbox.json, the first devbox run resolved and installed it but ran without the definition's env and init hook (JAVA_HOME, RUSTUP_TOOLCHAIN, the python venv). Plugin configs are built at config load, before the lock entry exists. ensureStateIsUpToDate now reloads includes after installing when the project has package definitions.

Audit fixes carried into the new features:

  • The remote file:// ban covers install.lookup URLs (and the URL a lookup index returns), version-override URLs, and every paginated version URL.
  • Version validation applies to every source in a list.
  • Validate checks each version override combined with the definition's system overrides (the order InstallFor applies them), so a version override's lookup with a system override's checksum is rejected instead of silently dropping the checksum. Version-override constraints must contain valid version strings.
  • An install whose URL comes from a lookup index looks it up before computing its keyed install dir.

Test plan

  • New unit tests:
    • digest parsing; sha512 verification, including against the marker
    • http_json checksums: a 404 for one platform skips it, and array-valued selects ([... | .sha256]) work
    • lock skipping systems without artifacts
    • lookup, including an install with no locked artifact and a 404 index
    • github_release digests (with token, null digest, missing asset)
    • binaries chmod, the missing-binary error, and rejecting names that are not plain file names; hooks with an empty PATH
    • combined version sources; pagination for http_json and GitHub releases (stops early, stops at a 404 or a short page)
    • version override precedence and validation (including the version override + system override combination and invalid constraint versions); build metadata; constraints
    • remote file:// rejection for lookup (including a file:// URL returned by the index) and version overrides; a lookup that yields null
  • testscripts/pkgdef: editing devbox.json to a version not yet in devbox.lock applies env and init hook in the same run. This fails without the fix.
  • go test ./internal/pkgdef/... ./internal/lock/... and gofmt clean after the review fixes (golangci-lint/gofumpt were clean before them; not re-run since)
  • The per-package tests in [pkgdef 6/6] test(pkgs): install and switch versions of every shipped package #3036 pass on macOS arm64 and Linux arm64

https://claude.ai/code/session_01Bqy92oAnwydcLrbSE7nkVH


Generated by Claude Code

Implement what the initial package definitions need:

- Platforms a version is not published for: a 404 from a checksum file
  or index, a checksum list without the file, a jq expression that
  matches nothing or a GitHub release without the asset is ErrNoArtifact.
  Lock leaves those systems out and fails only when none has an artifact;
  installing on a left-out system is an error naming where the version is
  available.
- install.lookup reads the artifact URL and checksum from a JSON index
  (python-build-standalone via uv's index, Temurin, zig).
- install.version_overrides apply partial installs to versions matching a
  constraint such as "<11" (pnpm, yarn, deno).
- versions may be a list of sources (yarn 1 and 2+ are different npm
  packages). github_releases and http_json URLs with {{.Page}} paginate
  lazily, stopping at the first page with a match.
- Versions with +build metadata (21.0.5+11) compare and prefix-match.
- sha512 digests and SRI strings, a sha512_url checksum type, and a
  github_release type that reads GitHub's asset digests. devbox.lock gets
  an omitempty sha512 per system.
- binaries are made executable after extraction and must exist after
  install. post_install hooks run with /bin/sh and /usr/bin:/bin on PATH.
- Metadata requests are memoized per client, so locking four systems
  fetches an index once. Install fingerprints include the version, since
  overrides can make versions install differently.
- ensureStateIsUpToDate reloads plugin configs after installing, so a
  version changed in devbox.json gets its definition's env and init hook
  in the same run instead of the next one.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@mikeland73 mikeland73 closed this Nov 17, 2026
@mikeland73 mikeland73 reopened this Nov 17, 2026
@claude

claude Bot commented Nov 17, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@greptile-apps

greptile-apps Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding actionable findings.

Summary

Adds the format features needed by the initial package definitions:

  • Package definitions combine version sources and choose recipes for each version.
  • Package definitions find vendor artifacts and checksums for each system.
  • Package installs check named binaries and give hooks a standard shell path.
  • Newly resolved package versions activate their environment in the same run.
  • Package metadata responses are reused during a client's work.

No new actionable issues were found. All three earlier findings are fixed: binary names cannot contain paths, checksum 404s skip the missing platform, and array-valued checksum expressions work again. Those threads were unnumbered, so they have no numbered entries above.

Checked PR #3036 for changed API callers and follow-on fixes. This assessment does not depend on a fix there. Tests were not run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Resolve requested version] --> B[Apply version and system overrides]
  B --> C[Find artifact URL and digest]
  C --> D{Artifact available?}
  D -->|No| E[Leave platform out of lock]
  D -->|Yes| F[Record platform in lock]
  F --> G[Download and check digest]
  G --> H[Extract and prepare binaries]
  H --> I[Run post-install hooks]
  I --> J[Check required binaries]
  J --> K[Reload activation config]
Loading

Reviews (4) · Last reviewed commit: "Merge branch 'mikeland73/pkgdef-packages..." · Reviewed by Greptile

Comment thread internal/pkgdef/install.go Resolved
Comment thread internal/pkgdef/checksum.go Resolved
Comment thread internal/pkgdef/checksum.go Resolved
…age-support

# Conflicts:
#	internal/devbox/pkgdef.go
#	internal/pkgdef/client_test.go
#	internal/pkgdef/definition.go
#	internal/pkgdef/install.go
#	internal/pkgdef/version.go
#	internal/pkgdef/versions.go

Copy link
Copy Markdown
Collaborator Author

@greptileai review


Generated by Claude Code

1 similar comment

Copy link
Copy Markdown
Collaborator Author

@greptileai review


Generated by Claude Code

@mikeland73
mikeland73 added this pull request to stack #3003 November 23, 2026 21:41
- Validate rejects `binaries` entries that are not plain file names, so
  makeBinariesExecutable cannot chmod files outside the install root.
- An http_json checksum endpoint that 404s now reports ErrNoArtifact, so
  Lock skips that platform instead of failing every platform.
- http_json checksum selects that produce an array of digests are
  flattened one level again, matching runJQ.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bqy92nAJeXk9DPbkjEddqY
…age-support

Resolve conflicts with the Greptile fixes from lower in the stack:
runJQValues now takes a context and enforces jqResultLimit (runJQ and
queryJSON pass ctx through); install strips an archive-supplied marker
before making binaries executable; keep both new definition validation
cases.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bqy92mV11RTGiKeSuiHtuV
The missing-binaries check runs after post_install, so hooks may create
listed binaries (bun's bunx). Entries must be plain file names.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bqy92nAJeXk9DPbkjEddqY
- A lookup select that yields null now means "no artifact" for that
  system, as the spec says for an expression that produces nothing,
  instead of failing the whole lock.
- The URL a lookup index returns is checked against the remote file://
  ban at lock time, so a remote definition cannot write one into
  devbox.lock.
- Spec: http_json checksums flatten array results one level; lookup
  null results and file:// URLs are documented.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bqy92nAJeXk9DPbkjEddqY
…versions

- Validate checks each version override combined with the definition's
  system overrides, in InstallFor's order, so a version override's lookup
  with a system override's checksum is rejected instead of the checksum
  being silently dropped.
- Version-override constraints must contain valid version strings.
- Spec: document pagination detection and the page-0 404 error, the
  lookup/checksum rules, constraint validation, that install fails on a
  missing binary after post_install, github_releases skipping tags without
  strip_prefix, and sha256_url's "*" prefix and dir/filename matching.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bqy92nAJeXk9DPbkjEddqY

Copy link
Copy Markdown
Collaborator Author

@greptileai review


Generated by Claude Code

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants