Skip to content

build: a fresh worktree bootstraps its own drivers and venv - #804

Merged
frahlg merged 1 commit into
masterfrom
agent/worktree-bootstrap
Aug 5, 2026
Merged

build: a fresh worktree bootstraps its own drivers and venv#804
frahlg merged 1 commit into
masterfrom
agent/worktree-bootstrap

Conversation

@frahlg

@frahlg frahlg commented Aug 4, 2026

Copy link
Copy Markdown
Member

make verify does not run in a checkout that has never been built. Five
people have now found this out one at a time, each losing about half an hour
to the same two gates, and the shared workaround — copy 37 .lua files from
another checkout by hand — is a thing we should stop asking people to know.

What stopped

The drivers gate. drivers/*.lua is a gitignored snapshot fetched from
the commit pinned in drivers/BUNDLED_SOURCE.json, so a fresh clone or
git worktree add has none, and drivers-present stopped the build to name
the command that fetches them. It now runs it. On every later run — which is
every run in a checkout that already has the snapshot — the guard is still
one ls and no network; measured at 44 ms. A fetch that fails still prints
what to do by hand, including the copy. go test already downloads its
modules on a fresh checkout; this is the same bargain, paid once.

The optimizer venv. optimizer-install built the environment with
whatever answers to python3. On macOS that is 3.9 with pip 21.2.4, which
cannot do a PEP 660 editable install of a pyproject-only package and reports
it as:

ERROR: File "setup.py" or "setup.cfg" not found. Directory cannot be
installed in editable mode: .../optimizer

which reads like a packaging fault in this repository rather than the wrong
interpreter. Choosing the interpreter is now the whole job of
scripts/optimizer-venv.sh:

  1. $PYTHON — what the old recipe used, so a machine where it already worked
    builds exactly the venv it built before;
  2. a python3.N on PATH at or above the floor declared in
    optimizer/pyproject.toml, starting with the 3.12 that
    Dockerfile.optimizer and CI run;
  3. uv, which fetches an interpreter when the machine has none.

uv stays optional and is never consulted while a suitable python exists.
Neither one present is an error naming both remedies. A venv left behind by
the old failure — 3.9, half-built — is replaced rather than reused, which is
the state the second attempt actually starts from.

Evidence

A worktree created from master, no drivers, no venv:

before after
make verify fails at the editable install passes in 53 s
drivers/*.lua 0, copied by hand 37, fetched from the pin
manual steps 2 0

Also exercised: the uv route, with a PATH holding no python 3.11+ — the
venv it produces (3.12, --seed, so it has pip like any other) passes
make optimizer-test and the core↔optimizer contract test unchanged; the
"no python, no uv" error; and a fetch failure with curl broken.

The golden corpus is untouched and no record moved — this change reaches no
control code, and TestGoldenCorpusReplay passes at the same 0.01 W
tolerance in every run above.

Notes for review

  • No changeset. Makefile and scripts/ are outside the allowlist in
    changeset-check.yml, so the gate asks for one; nothing here ships to a
    gateway (the release tarballs carry neither file) and the change is local
    developer tooling, which .changeset/README.md puts under the
    no-changeset label. Label applied.
  • The CI step that asserted the opposite. drivers-from-pin in
    test.yml checked that drivers-present fails on an empty drivers/.
    It now checks that the guard materialises all 37 — the same job, asking
    the fresh-clone question the guard now answers.
  • ci: notice when a new Debian stable leaves the pinned suite behind #733 owns a line I left alone. The new script is not added to the
    bash -n list in compose-migration-test, because ci: notice when a new Debian stable leaves the pinned suite behind #733 is appending to
    that exact line and has right of way. Worth adding once it lands.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com

Two gates stop `make verify` in a checkout that has never been built, and
both have now cost several people the same half hour.

drivers/*.lua is a gitignored snapshot fetched from the pin, so a fresh
clone or worktree has none. The presence guard stopped the build to name
the command that fetches them; it now runs it. That costs one `ls` and no
network on every run after the first, which is every run in a checkout
that already has them, and a failed fetch still says what to do by hand.
`go test` already downloads its modules on a fresh checkout -- this is the
same bargain, once.

The optimizer venv was built with whatever answers to python3. On macOS
that is 3.9 with pip 21.2, which cannot do a PEP 660 editable install and
reports it as "File setup.py or setup.cfg not found" -- a message that
reads like a packaging fault here rather than the wrong interpreter. The
choice moves into scripts/optimizer-venv.sh: $PYTHON first so a machine
where it already worked is unaffected, then a python3.N at or above the
floor declared in optimizer/pyproject.toml, then uv, which fetches an
interpreter when the machine has none. uv stays optional and is never
consulted while a suitable python exists. No interpreter and no uv is an
error naming both remedies. A venv left behind by the old failure is
replaced rather than reused.

Verified in a worktree created from master with an empty drivers/ and no
venv: `make verify` failed at the editable install before, and passes in
65s after, fetching 37 drivers and building the environment on the way.
The uv path was exercised with a PATH holding no python 3.11+, and the
venv it produces passes optimizer-test and the core-optimizer contract
test unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@frahlg frahlg added the no-changeset PR intentionally exempt from the changeset requirement (dev tooling / non-shipping) label Aug 4, 2026

@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: 76a0e43146

ℹ️ 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 thread scripts/optimizer-venv.sh
# that could not do the install. Keep the environment when its own interpreter
# qualifies -- reinstalling into it is what an unchanged machine wants -- and
# otherwise throw it away and choose again.
if [ -x "${VENV}/bin/python" ] && satisfies_floor "${VENV}/bin/python"; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Honor PYTHON when reusing the virtual environment

When optimizer/.venv already contains any qualifying interpreter, this branch runs before candidate selection, so make optimizer-install PYTHON=/path/to/python silently reuses the existing interpreter. With an existing Python 3.12 environment and a requested Python 3.11 binary, the requested binary is never invoked, breaking the advertised override when a developer needs to switch or repair the environment; reuse should account for an explicit PYTHON selection.

Useful? React with 👍 / 👎.

Comment thread scripts/optimizer-venv.sh

if [ -n "${CHOSEN}" ]; then
echo "optimizer: building .venv with ${CHOSEN} ($("${CHOSEN}" --version 2>&1))"
"${CHOSEN}" -m venv "${VENV}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fall back when a candidate cannot create a venv

On a host where the first version-qualified interpreter cannot create virtual environments, this command exits immediately under set -e, without trying another candidate or the advertised uv fallback. Reproducing a Python 3.12 candidate that passes the version check but fails -m venv, with uv available on PATH, leaves uv uninvoked and the fresh-worktree bootstrap still fails; unsuccessful creation should continue to another candidate or fall back to uv.

Useful? React with 👍 / 👎.

@frahlg
frahlg merged commit 1fb230f into master Aug 5, 2026
13 of 14 checks passed
@frahlg
frahlg deleted the agent/worktree-bootstrap branch August 5, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changeset PR intentionally exempt from the changeset requirement (dev tooling / non-shipping)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant