Skip to content

feat(environment): built-in manifest registry shipped in the wheel - #961

Merged
xdotli merged 2 commits into
mainfrom
feat/builtin-env-registry
Aug 9, 2026
Merged

feat(environment): built-in manifest registry shipped in the wheel#961
xdotli merged 2 commits into
mainfrom
feat/builtin-env-registry

Conversation

@xdotli

@xdotli xdotli commented Aug 9, 2026

Copy link
Copy Markdown
Member

A pip-installed user could not use --environment-manifest name@version at all: BENCHFLOW_ENV_REGISTRY had to point at a local directory of manifest files, and the documented recipe assumed a repo checkout. A fresh-user dogfood had to hand-download env0@prod.toml from raw.githubusercontent.com and reconstruct the layout by guesswork.

What changed

  • The pinned manifests ship inside the wheel. Canonical home moves benchmarks/_environments/*.tomlsrc/benchflow/environment/_registry/ (git mv, byte-faithful apart from header wording; benchmarks/_environments/ keeps a pointer README — one source of truth, no divergent copies). Verified through the actual artifacts: sdist and sdist-built wheel both carry the TOMLs.
  • Resolution order: explicit registry= argument → $BENCHFLOW_ENV_REGISTRY (wins entirely when set — no silent fallback; a missing/non-directory path errors loudly and the message names its source, env var vs argument; empty value counts as unset, documented and tested) → built-in registry. sha256 content-addressed resolution logging unchanged.
  • Acceptance, actually run: fresh venv + pip install of the built wheel, from outside the repo, zero env vars — env0@prod resolves from site-packages (8 services, sha256 logged), env0@outage (6 services, perturbation intact), unknown names error listing available specs.
  • Docs: environment-plane.md registry section (resolution order + bare-pip example), cli.md row, pointer README, CHANGELOG.

Review

Structural review before opening (REQUEST-CHANGES → fixed): the initial zipped-install temp-dir materialization branch was deleted on four grounds — unreachable (the repo's universal package-data idiom is Path(__file__)-relative, so zip imports are already unsupported package-wide), untested, leaky/racy lifecycle, and a hand-rolled importlib.resources.as_file. The shipped lookup is three lines matching repo precedent; packaging is still pinned by an importlib.resources test. Remaining review minors (error provenance, empty-means-unset, argument-beats-env-var ordering) all landed with tests.

Note for external consumers: the pins' sha256 content addresses changed with the header edits (no in-repo hash records them; disclosed here for anyone comparing env_hash across versions).

Gates: ruff format/check, ty; registry/environment/docs-drift 104 passed; manifest/registry sweep 483 passed.

xdotli added 2 commits August 9, 2026 10:35
BENCHFLOW_ENV_REGISTRY required a local directory of name@version.toml
pins, and the documented recipe assumed a repo checkout — a bare pip
install had to hand-download env0@prod.toml from raw.githubusercontent
and reconstruct the layout by guesswork.

Move the canonical pins from benchmarks/_environments/ into the package
(src/benchflow/environment/_registry/) so hatchling ships them in the
wheel as package data, and resolve them as the built-in default registry
when BENCHFLOW_ENV_REGISTRY is unset. The env var, when set, wins
entirely (no fallback into the built-ins); an explicit registry=
argument still beats both. Lookup goes through importlib.resources with
a one-shot temp-dir materialization so zipped installs work too.

- benchmarks/_environments/ keeps only a README pointing at the new
  single source of truth (no divergent copies)
- content-addressed sha256 logging of resolved manifests unchanged
- unknown names now error listing the available specs
- docs: environment-plane Registry section, cli.md flag row, pin
  headers, and the _environments README updated; CLI help mentions the
  built-in default

Acceptance: fresh venv + pip install of the built wheel resolves
--environment-manifest env0@prod (and env0@outage) with no env vars set,
logging the sha256 provenance from site-packages.
- Drop the zipped-install mkdtemp materialization branch: unreachable
  (the repo's package-data idiom is Path(__file__)-relative everywhere
  — compose files, default rubric, demo task — so zip imports are
  unsupported package-wide), untested, and it carried latent lifecycle
  defects (uncleaned mkdtemp, unserialized concurrent first call).
  _builtin_registry_dir is now a Path(__file__)-relative lookup like
  its siblings; the importlib.resources packaging test still pins that
  the pins ship as package data.
- Not-a-directory errors now name the source of the bad path
  ($BENCHFLOW_ENV_REGISTRY vs the registry= argument), with tests for
  both — the path had no test before.
- Pin the empty-env-var semantic: BENCHFLOW_ENV_REGISTRY="" counts as
  unset (docstring line + test).
- Add the missing resolution-order test: an explicit registry=
  argument beats a SET env var.
- Fix an accidental capture group in the no-builtin-fallback test
  regex.
@xdotli
xdotli temporarily deployed to pypi-internal-preview August 9, 2026 17:45 — with GitHub Actions Inactive

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5150749246

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +97 to +98
"""The acceptance contract: a bare pip install resolves ``env0@prod`` with
no ``$BENCHFLOW_ENV_REGISTRY`` set — the pins ship inside the package."""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Name the guarded change in regression-test docstrings

This acceptance test specifically guards the commit's fix for bare-install registry resolution, but its docstring does not identify the PR or commit; several adjacent regression tests added for the same behavior also omit that traceability. Name the guarded PR/commit in these docstrings as required by the repository convention.

AGENTS.md reference: AGENTS.md:L16-L17

Useful? React with 👍 / 👎.

@xdotli
xdotli merged commit 7c3803d into main Aug 9, 2026
10 checks passed
@xdotli
xdotli deleted the feat/builtin-env-registry branch August 9, 2026 17:54
@xdotli xdotli mentioned this pull request Aug 9, 2026
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