Skip to content

test(prebuilt): prove served and from-source builds archive the same bytes (#2196) - #2203

Merged
zackees merged 1 commit into
mainfrom
agent/2196-archive-parity
Nov 28, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/2196-archive-parity

Conversation

@zackees

@zackees zackees commented Nov 28, 2026

Copy link
Copy Markdown
Member

What

The last named acceptance cell of #2196: a served-tree build and a from-source build of the same cell must produce a byte-identical framework archive.

prebuilt_core_tests.rs gains one end-to-end parity test that goes through the real publisher and the real hydration rule rather than comparing names:

  1. the from-source arm writes one object per unit at this host's own CompilerBase::object_path inside one core build dir and archives them with the shared fbuild_core::archive::create primitive (the same one the library stage uses, 60 s watchdog included);
  2. the publisher packs exactly those bytes with prebuilt::pack (so the tree carries objects.json), the client extracts it, hydrates into a different build dir, and archives what it received;
  3. the assertion is on the artifact: equal SHA-256 and assert_eq!(fresh, reused) on the bytes, plus assert_ne! on the two build dirs so the test cannot pass by archiving one directory twice.

This is the #2192 rule applied to the archive itself: a marker that only recorded size_bytes once made a reused tree report a compressed size while a fresh extraction reported content bytes. Entry names alone cannot catch that class of drift.

Why now

#2199 (cell 3) proved hydration lands the publisher's object at this host's path, and #2201 (cell 3b) proved a packed tree is hydratable through the real extractor — but nothing on main asserts that the archive a build actually links is the same artifact either way. ar is deterministic (GNU binutils defaults to D) and hydration copies bytes verbatim, so the property holds today; this test pins it so a future hydration change (a permission fix, a re-hash, a re-link) cannot silently make a served build link a different archive.

Verification (real output)

$ soldr cargo test -p fbuild-build-esp --lib prebuilt_core
test esp32::orchestrator::prebuilt_core::tests::a_served_tree_and_a_source_build_archive_to_identical_bytes ... ok
test result: ok. 12 passed; 0 failed; 0 ignored; 0 measured; 279 filtered out; finished in 0.18s
  • soldr cargo fmt --check → exit 0 (soldr reported the cached verdict for identical inputs).
  • ci/enforce_platform_boundary.py --print-totals → rows=0; dylint_rows=0.
  • RED proof: one hydrated object is overwritten with b"tampered object" before the second archive → exit 101, exactly one failure:
    assertion left == right failed: a served build and a from-source build of one cell must hash the same archive
    (11 passed, 1 failed). Tamper removed, file restored + touched, re-run green above.

Additive only: one test helper plus one test in an existing _tests.rs; no production code, no new crate, no workflow change.

#2196 stays open (its remaining cell is the #1882 decision-6 cold/warm hook).

…bytes

The last named acceptance cell of #2196: a served-tree build and a
from-source build of one cell must produce a byte-identical framework
archive, asserted on the artifact (SHA-256 + bytes) rather than on entry
names -- the #2192 rule.

The test drives both arms through the real primitives: objects written at
this host's own CompilerBase::object_path, archived with the shared
fbuild_core::archive::create (60 s library watchdog), packed by
prebuilt::pack, extracted and hydrated into a *different* build dir, then
archived again.

Additive only: one helper plus one test, no production code.
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