Skip to content

feat(prebuilt): the identity -> tree call site (#1882) - #2192

Merged
zackees merged 1 commit into
mainfrom
agent/1882-extract-marker
Nov 26, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/1882-extract-marker

Conversation

@zackees

@zackees zackees commented Nov 26, 2026

Copy link
Copy Markdown
Member

What

Unit 11 of #1882: the call site that turns an exact identity into one reusable
tree. Until now the pieces were disconnected — Reader resolved, Fetcher
verified, extract unpacked — but nothing decided where a tree lives or what to
do when that place was already occupied, so extract had no caller at all.

piece behaviour
tree_root(cache, query) {cache}/prebuilt/<framework>/<version>/<arch>/fp-<sha16> — the same key the bucket uses, asserted equal to the path operator_urls builds
key validation each component must be one ordinary path component (no /, \, :, NUL, ., .., empty) and the fingerprint 64 lowercase hex — a catalog value can never steer the write
obtain(cache, query, asset, fetcher) marked tree for this archive → reused with zero requests; different archive's marker → refused untouched, no download; nothing there → fetch, then extract at that path
marker report extract::existing_tree + Existing::{None,Same,Different}; completed() is now a thin caller of it and keeps its exact behaviour (the existing occupied/reuse tests still pass)
staging depth extraction stages beside the destination, a depth sweep_staging_tree visits — a test proves the sweep reaps that sibling under the real layout

Bug fixed on the way: the marker recorded only the archive size, so a reused
tree reported the compressed size (92 B) where a fresh extraction reported
decompressed bytes (7 B). TreeMarker.extracted_bytes makes the two agree; the
reuse test asserts tree == fresh and tree.bytes == content length.

Opt-in: no build path calls obtain, and nothing is wired to a request or flag —
the per-request opt-in/kill-switch, the source-fallback retry, the LRU and the
benchmark hook remain open cells. #1882 stays open.

Verification (real output)

  • soldr cargo test -p fbuild-packages-fetch --lib prebuilt:: → 54 passed; 0 failed
    (6 new obtain tests: bucket-key agreement, path-component refusal, reuse with
    no request, identity conflict refused untouched with 0 requests, unparseable
    marker, sweep covers the layout).
  • soldr cargo test -p fbuild-packages-fetch --lib → 376 passed; 0 failed; 2 ignored.
  • soldr cargo clippy -p fbuild-packages-fetch --all-targets -- -D warnings → clean.
  • soldr cargo fmt --check -p fbuild-packages-fetch → clean.
  • uv run --no-project python ci/enforce_platform_boundary.py --print-totals → rows=0; dylint_rows=0.
  • New files: obtain.rs 132 LOC, obtain_tests.rs 254 LOC (limit 1000).

Not done

No workflow file, no new crate, no daemon request path, no tuning of the pool's
daemon route. Nothing in Zach's live tree was touched.

`extract` had no caller: nothing decided where a prebuilt tree lives, or what
to do when that place is already occupied. Add `prebuilt::obtain` as the one
opt-in call site, and give the marker check the shape that decision needs.

- `tree_root` derives the destination from the exact identity alone:
  `{cache}/prebuilt/<framework>/<version>/<arch>/fp-<sha16>` -- the same key the
  bucket uses (asserted against `operator_urls`). Each component must be one
  ordinary path component, so a catalog value cannot steer the write.
- `obtain` reuses a marked tree with zero network traffic, refuses a marker
  from a different archive untouched (eviction is the LRU's), and otherwise
  fetches then extracts at that path.
- Extraction now reports the marker through `existing_tree`/`Existing`, so the
  policy lives at the call site and `completed()` keeps its exact behaviour.
- Fix: the marker recorded only the archive's size, so a reused tree reported
  the compressed size where a fresh extraction reported decompressed bytes.
  `TreeMarker.extracted_bytes` makes both agree; `extract_tests` asserts it.

No build path calls `obtain` yet, and nothing is wired to a request.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant