Repository navigation
Description
Why
#1882 delivered the prebuilt serving ladder — identity/fingerprint, prebuilt::obtain/tree_root, prebuilt::serve (decision enum + one retry), prebuilt::lru pruning, staging GC, deterministic prebuilt::pack behind the hidden fbuild __prebuilt-pack. All of it is verified in-tree and none of it is reachable from a build: nothing calls obtain/serve, so no artifact can ever be served, and --no-prebuilt-libs has no effect on what gets fetched.
Verified on origin/main a7394a52 (2026-11-27):
git grep -n "fetches_prebuilt_libs()" -- '*.rs'→ onlycrates/fbuild-build-engine/src/prebuilt.rslines 126/134, i.e. that function's own unit tests. Nothing in the build path consumes the policy.git grep -n "prebuilt::" -- 'crates/'→ exactly one production hit,crates/fbuild-cli/src/cli/prebuilt_notice.rs:25(thePrebuiltPolicytype for the notice line).- The only production constructor of
variants::FetchRequestiscrates/fbuild-library/src/library/esp32_framework/libs.rs:253, and it carries{name, version, url, variant}only. Decision 1 requires "an explicitPrebuiltLibsPolicyfield onFetchRequest"; that field does not exist, so the opt-out cannot change selection — the per-chip slice in the@esp-libsshard is still what every ESP32 build downloads.
Consequence: the last plan cell of #1882 (the cold/warm benchmark hook, decision 6) is unmeasurable today — with no consumer, the "prebuilt" and "control" arms are the same code, and a published ratio would be unfalsifiable. That is why the hook is not being written before this issue.
Scope (additive; no workflow files, no new crate)
- Carry the decision explicitly. Add the prebuilt policy to the build request on both sides (
crates/fbuild-cli/src/daemon_client/types.rsandcrates/fbuild-daemon/src/models.rs,#[serde(default)]so old clients keep working) and forward it into the ESP32 packages stage. The daemon must never read its own environment for this — decision 1's rationale is that it does not inherit the caller's env. - Honour it in the fetch layer. Add the
PrebuiltLibsPolicyfield tovariants::FetchRequestand skip the slice branch inselect()when prebuilt libs are disabled, so the opt-out selects the mirrored whole bundle (or the request URL) instead of the chip slice. This is decision 1's named mechanism and makes the flag's help text true. - Consult the ladder before compiling framework libs. In the ESP32 packages stage, resolve the framework term/fingerprint (
esp32_framework::prebuilt_core) and askprebuilt::serve.Served::Prebuilt→ use that tree;Served::Source→ compile from source exactly as today. A ladder failure must never fail a build. - Record the decision in
build_info.jsonasprebuilt_libs: {used, source, key, sha256}per decision 1, so any firmware can be traced to the archive or tree it linked against. - One honest line. Reuse
Served::Source(reason)'s notice so a fallback is reported once, and make--no-prebuilt-libs's line describe what now actually happens.
Acceptance criteria
- RED → GREEN: with a local HTTP fixture serving a published slice and a published prebuilt tree, a build with the ladder consulted uses the served tree and issues no compile of the covered units; remove the call and the same test fails.
- With prebuilt libs disabled, the fetch layer selects the whole bundle and never the slice (assert the selected URL and that no
@esp-libsslice key is used). - Any ladder error (transport, integrity, foreign marker, unsafe entry) falls back to source with exactly one notice line and a successful build.
- A served-tree build and a from-source build of the same cell produce byte-identical framework archives (the
#2192rule: assertreused == fresh, not just entry names). build_info.jsoncarries the fourprebuilt_libsfields, and a source build recordsused: false.- Existing gates:
prebuilt::unit suite,fbuild-packages-fetchlib suite, boundaryrows=0; dylint_rows=0, fmt/dylint clean.
Unblocks
#1882's remaining plan cell (the cold/warm benchmark hook, decision 6). That hook needs this consumer: it measures cold_first_compile_wall_s with prebuilt libs against the source arm in the same job, and a ratio without a real control arm is unfalsifiable.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsNo status
Activity
zackees commentedon Nov 27, 2026
Cells 1, 2 and 5 are shipped as PR #2197 (
agent/2196-prebuilt-consumer, heada4500186, unmerged). Cells 3 and 4 are untouched — this is the plumbing the ladder needs before it can be consulted, not the consultation itself. #2196 stays open.What #2197 changes, per cell:
BuildParams::prebuilt_libs(fbuild_build::prebuilt::PrebuiltPolicy); CLIBuildRequest::prebuilt_libsand daemonmodels::BuildRequest::prebuilt_libsareOption<String>with#[serde(default)]and the policy's stable spelling (disabled/libs/core). The daemon parses the request, never its own environment.dispatchnow resolves the policy once and both reports it and forwards the same value (before, it was reported and dropped).variants::PrebuiltLibsPolicy { Slices, WholeBundle }is a field onFetchRequest;select()refuses the slice branch underWholeBundle, so the request resolves to the mirrored whole bundle (entry.urls[0]) or, with no entry, the vendor URL.fbuild-packages-fetchre-exports the type. The verdict reaches it viaensure_sdk_libs→Esp32Framework::ensure_libs→install_sdk_archive→FetchRequest.prebuilt::servestill has no caller (git grepon the branch tip: onlyprebuilt/serve.rsand its tests).build_info.jsonprebuilt_libs {used, source, key, sha256}— NOT in feat(prebuilt): make --no-prebuilt-libs change what is fetched (decision 1) #2197; lands with 3, becauseused/key/sha256are only meaningful once something can be served.--no-prebuilt-libsnotice now reads "compiling framework libraries from source; the SDK download takes the whole published bundle instead of a pre-built per-chip slice", which is what the code does after this PR.Served::Source(reason)'s notice path is unchanged and still unused (blocked on 3).Acceptance evidence in #2197:
disabled_prebuilt_libs_select_the_whole_bundle_never_a_sliceasserts the selected URL and that no slice/chip is selected, with the default-policy arm as its own control (https://bucket.example/slices/s3.tar.zstvshttps://mirror.example/whole.tar.xz). RED-proven: removing the gate fails the test (assertion left == right failed), restoring it passes.fbuild-daemonmodels tests cover an old-client body with noprebuilt_libs(→None→ defaultLibs) and the"disabled"spelling parsing toDisabled.esp32_framework::libs17 passed, workspacecargo check --all-targetsclean, boundaryrows=0; dylint_rows=0.Still open for a later tick (unchanged by this comment): the fixture-served end-to-end acceptance test the issue asks for —
select()is the decision pointfetch()delegates to and is unit-tested both ways, butdownloader_mirror_manifest::current()returnsNoneundercfg!(test), so a manifest-drivenfetch()test has to live intests/itwithFBUILD_MIRROR_MANIFEST_URLpointed at a local fixture. That belongs with cell 3, where a realServed::Prebuilttree exists to compare against a from-source build.fix(loc): keep the ESP32 orchestrator build.rs at 1000 LOC
style(cli): keep run_build under the 100-line clippy cap
zackees commentedon Nov 27, 2026
Cells 1, 2 and 5 landed.
#2197 merged 2026-11-27T16:32:13Z ->
main=62e46674(agent/2196-prebuilt-consumer):BuildRequest/BuildParamscarryprebuilt_libs(#[serde(default)]on the wire), the daemon parses the request rather than its own env;variants::PrebuiltLibsPolicy { Slices, WholeBundle }onFetchRequestand theselect()gate, so--no-prebuilt-libsselects the whole bundle and never the@esp-libschip slice;Remaining: cell 3 (consult
prebuilt::servein the ESP32 packages stage) and cell 4 (prebuilt_libsinbuild_info.json). Cell 3 is the one that makes the ladder reachable from a build and unblocks #1882's cold/warm hook; taking it next.zackees commentedon Nov 27, 2026
Cell 3 shipped as PR #2199 (
agent/2196-serve-consult, head889a7267) — unmerged, awaiting review.What is now wired, on the request's own terms:
Esp32Framework::prebuilt_core_plangets its first production caller.CoreBuildInputsis built from the stamped framework term, one canonical argv per core unit (cache root / toolchain path replaced by placeholders, object path deliberately excluded — it carries the source's absolute path), and a pinned config-digest set:cores/<core>/Arduino.h,variants/<variant>/pins_arduino.h,<sdks>/<sdk_variant>/include/sdkconfig.hwhen the install ships one.framework = arduino-esp32,version = <core version>,arch = <mcu>,abi = <sdk variant>,fp = <fingerprint>— documented in the module so the packer can publish something a build will actually ask for.Reader::from_environment(cache_root).resolvethenprebuilt::serve;Served::Prebuilthydrates, everything else is one notice line and a source build.objects.jsonmapping canonical unit ids (source path relative to the framework root) to the publisher's object file names, because this host's object names come fromCompilerBase::object_path— which hashes the source's ABSOLUTE path, so~/.fbuildunder a different home directory yields a different name. Hydration resolves each id to the local source, computes this host's object path, and copies only manifest-named regular files there. A tree with no manifest, a newer schema, or one covering none of this build's units is refused.PrebuiltPolicy::serves_core_objects()only (hidden--prebuilt-core);--no-prebuilt-libs/default never reach the network path.Evidence: 278 crate lib tests pass (6 new);
the_ladder_serves_a_published_tree_and_it_is_hydratedruns a real loopbackIndex→Catalog→tar.zstand asserts both units hydrate to the paths the compiler derives withneeds_rebuild == false. RED: neutering the copy step failsa_served_tree_hydrates_every_unit_it_covers.cargo fmt --checkclean, boundaryrows=0; dylint_rows=0.Remaining gap, stated plainly (cell 3b, publisher side):
fbuild __prebuilt-packpacks an arbitrary objects tree and takes--fingerprintas an input; it does not writeobjects.json, nor the config/argv contract this client pins. Until the packer emits them (reusing the same helpers), no published artifact can be consumed — the ladder is reachable and proven end to end, but there is nothing in the bucket to serve. Cell 4 (prebuilt_libs: {used, source, key, sha256}inbuild_info.json) is unchanged and stays open, as does #1882's cold/warm hook.zackees commentedon Nov 27, 2026
Receipt — cell 3 merged
PR #2199 (
agent/2196-serve-consult, 889a726) is onorigin/mainas 08e82b0 (merge-group 46053528374 SUCCESS,linux / Check12039-line log with 0soldr#3377, 0test result: FAILED, retry never fired).The #1882 serving ladder now has its first production caller: the ESP32 packages stage builds a stamped fingerprint from the installed framework (component term + canonical per-unit argv + pinned config digests), queries the catalog (
arduino-esp32/core version/mcu/sdk-variant/fp), callsprebuilt::serve, and onServed::Prebuilthydrates the tree's compiled objects into the core build dir via anobjects.jsonmanifest (canonical unit id -> publisher object name). Every non-serve outcome — no identity, miss, transfer error, foreign marker, non-covering tree — is one log line and a source build, never a build error. Gated by hidden--prebuilt-core.Cells left on this issue:
fbuild __prebuilt-packwrites neitherobjects.jsonnor the pinned fingerprint inputs, so no published artifact is consumable by cell 3 yet.prebuilt_libsrecorded inbuild_info.json(the Implement experimental exact-fingerprint prebuilt framework serving v1 #1882 cold/warm hook needs it to tell the arms apart).#2196 stays open; no close keyword.
zackees commentedon Nov 27, 2026
Cell 4 shipped as PR #2200 (
agent/2196-build-info, 846a4f5, unmerged)build_info_<env>.jsonnow carries the ladder decision per decision 1:used: falsefor a source build, with the ladder's ownreason(nullwhen the hidden opt-in was off, so "never asked" and "asked and declined" stay distinguishable).keyis the identity the publisher uploads under — the same{framework}/{version}/{arch}/fp-<sha16>relative pathprebuilt::tree_rootextracts into.Option<PrebuiltLibsRecord>withskip_serializing_if, following theshrinkprecedent: non-ESP32 platforms' JSON stays byte-identical; ESP32 always emits the block becauseshrink_link::emit_build_info's only caller always passes the record.Evidence:
fbuild-build-enginelib 607 passed / 0 failed / 6 ignored;fbuild-build-esplib 282 passed / 0 failed / 7 ignored (4 newprebuilt_corerecord tests); fmt clean; boundaryrows=0; dylint_rows=0; RED proven by neuteringwith_prebuilt_libs(assertion left == right failed). All 43 checks on #2200 pass,mergeStateStatus: CLEAN(Dylint Full, LOC gate, Build fbuild included) — left unmerged for the owner.Cells left on #2196
fbuild __prebuilt-packwrites neitherobjects.jsonnor the pinned fingerprint inputs — still the one producer-side gap; no published tree is consumable until it lands.#1882's cold/warm hook (decision 6) becomes measurable, since the arms are now distinguishable frombuild_info.jsonalone.#2196stays open; no close keyword.zackees commentedon Nov 27, 2026
Cell 3b shipped as PR #2201 (
agent/2196-pack-manifest, 73eddd2, unmerged).Cell 3 left the ladder with no servable output:
prebuilt_core::hydratereadsobjects.jsonout of the served tree, andfbuild __prebuilt-packwrote neither that manifest nor anything about the unit set — so any archive the builder could mint was unhydratable at the client, the exact gap named in the previous receipt.Now:
prebuilt::packrequires and writesobjects.json(schema: 1,units: {unit-id: object-file},OBJECTS_MANIFEST/MANIFEST_SCHEMAexported), and refuses, before writing a byte, a unit naming an object the tree does not hold, a unit id/object name that could address a path outside the tree (.., absolute,C:, empty segment, control char), a duplicate unit id, and a tree that already carries a manifest.--unitstakes<unit-id><TAB><source-path>lines and the object name is derived with the sameCompilerBase::object_paththe client hydrates to — the names are not portable (they fold the source's own path in), which is why the id → name relation has to travel in the archive.Evidence:
prebuilt::89/0 (manifest content, determinism, all refusal cases),prebuilt_core::11/0 including a new cross-crate test that packs with the realpack, extracts with the realextractand hydrates,fbuild-cli prebuilt9/0 (manifest proven from the archive on disk), fmt clean, boundaryrows=0; dylint_rows=0. RED-proven by neuteringappend_manifest→served tree has no objects.json.Remaining on this track: the fingerprint is still an input (
--fingerprint), so a published artifact is not self-verifying — no producer emits the pinned fingerprint inputs; and the cold/warm bench hook #1882 still wants its last cell. Neither is in #2201.