Skip to content

build: fetch the bundled drivers, and prove a build needs nothing else - #708

Merged
frahlg merged 1 commit into
masterfrom
fetch-bundled-drivers-at-build-time
Jul 28, 2026
Merged

build: fetch the bundled drivers, and prove a build needs nothing else#708
frahlg merged 1 commit into
masterfrom
fetch-bundled-drivers-at-build-time

Conversation

@frahlg

@frahlg frahlg commented Jul 28, 2026

Copy link
Copy Markdown
Member

First step toward FTW holding no driver source at all. Nothing is deleted here. The committed files still ship, the drift check still guards them, and this is reversible with one git revert.

What changes

make drivers          fetch drivers/ from the commit pinned in BUNDLED_SOURCE.json
make drivers-present  fail with the remedy when the directory is empty

test depends on the presence check, not the fetch, so the inner development loop keeps costing no network.

The part that matters

The new drivers build from the pin alone job deletes the committed drivers and rebuilds without them:

  1. rm -f drivers/*.lua
  2. confirms make drivers-present fails — the guard has to actually fire
  3. make drivers
  4. checks all 37 pinned drivers came back
  5. runs go test ./internal/drivers/... ./internal/driverinventory/... against the fetched copies
  6. asserts the fetched files are byte-identical to the committed ones

While the files are still in git this is redundant with the drift check. The moment they leave git it is the only thing standing between a fresh clone and a build that cannot find a driver. Proving it now means the deletion is a small, boring change rather than a leap.

One thing turned out cheaper than expected

The earlier sketch assumed the fifteen Go test files that build drivers/<id>.lua paths by hand would each need editing. They do not. sync-bundled-drivers.sh writes to ${ROOT}/drivers, which is exactly where those tests already look, so a fetched directory is indistinguishable from a committed one. The Dockerfile and the release tarballs are untouched for the same reason.

That removes most of the estimated work from the remaining steps.

Verified locally

$ rm drivers/*.lua && make drivers-present
drivers/ has no .lua files. Run 'make drivers' to fetch the
snapshot pinned in drivers/BUNDLED_SOURCE.json.

$ make drivers
wrote 37 drivers from srcfl/device-drivers@1f67078a54c4

$ git diff --exit-code -- drivers/   # identical to what was committed
$ cd go && go test ./internal/drivers/... ./internal/driverinventory/...
ok  	github.com/srcfl/ftw/go/internal/drivers
ok  	github.com/srcfl/ftw/go/internal/driverinventory

What is left

Step State
Fetch is a build step, proven sufficient this PR
Rework the SemVer gate to diff pins rather than git refs next
Delete drivers/*.lua, gitignore them, keep the pin after that
Replace the drift check with "no .lua may be committed here" with the deletion

Independent of #704 (moves the pin) and #705 (watches for a stale pin) — no overlapping files, any merge order works.

🤖 Generated with Claude Code

Groundwork for FTW holding no driver source at all. Nothing is deleted
here and the committed files still ship; what changes is that fetching
them becomes a first-class build step and CI proves it sufficient.

  make drivers          fetch drivers/ from the pinned commit
  make drivers-present  fail with the remedy when the directory is empty

`test` depends on the presence check rather than on the fetch, so the
inner loop keeps costing no network.

The new drivers-from-pin job is the point. It deletes the committed
drivers, confirms the guard fires, fetches from the pin, checks all 37
came back, runs the driver suites against the fetched copies, and
asserts they are byte-identical to what was committed. While the files
are still in git that is redundant with the drift check. The moment
they leave git it is the only thing between a fresh clone and a build
that cannot find a driver.

The fetch writes to the same path the committed files occupy, so
nothing that reads drivers/ needs to know where they came from. The
fifteen Go test files that build that path by hand are untouched, and
so are the Dockerfile and the release tarballs.

Verified locally: rm drivers/*.lua, guard fires, make drivers restores
37 of 37, go test ./internal/drivers/... ./internal/driverinventory/...
passes, git diff on drivers/ is empty.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>

@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: 26adba3ce0

ℹ️ 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 Makefile
# ---- Testing ----

test: optimizer/.venv/.installed
test: optimizer/.venv/.installed drivers-present

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 Gate release archives on the driver snapshot

When the committed .lua files are removed—or a developer has discarded them as this workflow does—only test checks drivers-present; release still archives the metadata-only drivers/ directory successfully and produces artifacts with no recovery drivers. Make release depend on fetching or validating the complete snapshot before the planned deletion can land.

AGENTS.md reference: AGENTS.md:L12-L15

Useful? React with 👍 / 👎.

Comment thread Makefile
Comment on lines +57 to +58
drivers:
bash scripts/sync-bundled-drivers.sh

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 Remove drivers no longer listed by the pin

When a pin update removes a driver, make drivers invokes the existing sync script in write mode, which reports the old file as UNLISTED but exits successfully without deleting it; for example, dropping zap leaves drivers/zap.lua on disk while printing that 36 drivers were written. The new target therefore does not reliably recreate the pinned snapshot in an existing checkout, so it should remove unlisted files or fail instead.

AGENTS.md reference: AGENTS.md:L12-L15

Useful? React with 👍 / 👎.

@frahlg
frahlg merged commit 2ec7f2d into master Jul 28, 2026
13 checks passed
@frahlg
frahlg deleted the fetch-bundled-drivers-at-build-time branch July 28, 2026 18:55
frahlg added a commit that referenced this pull request Jul 29, 2026
drivers/*.lua leaves git and is gitignored. The files still ship --
offline recovery needs them in the image, the release tarballs carry
them, the tests read them -- but they are fetched from the commit
pinned in drivers/BUNDLED_SOURCE.json rather than committed here.

The point is not the bytes. It is that there is no file to open a pull
request against. Two contributors spent real effort, including thirty
minutes on an SE17K and register-by-register probing on a Pixii,
writing fixes against files that regenerate. A guard that fails the
pull request recovers the codebase but not the afternoon. Absence
teaches faster than a red check does.

Everything that needed the files in git already stopped needing them:
#708 made the fetch a build step and proved a build works from the pin
alone, #709 moved the SemVer gate onto the pins. This is the small
change those two were for.

--check changes its question. It used to compare committed bytes
against the pin; there are no committed bytes now, so it asks whether
any driver is committed at all. Cheaper than a content diff, a stricter
rule, and it needs no network.

Every workflow that reads drivers/ fetches first: core, drivers and
e2e in test.yml, the image build in beta.yml, and both the tarball and
image jobs in release-assets.yml. e2e, release and
driver-repository-validate depend on drivers-present locally, so a
missing fetch fails with the remedy rather than a confusing
file-not-found.

Verified: rm -rf the drivers, make drivers restores 37 of 37, go test
./... passes uncached, and the full-stack e2e is green. The guard is
proven to fire -- git add -f on one driver and --check reports it.

Signed-off-by: Fredrik Ahlgren <fredrik@sourceful-labs.com>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
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