fix(forge): route cross-package device calls through lib_process (#944)#953
fix(forge): route cross-package device calls through lib_process (#944)#953codex-curator wants to merge 2 commits into
Conversation
…maweb#944) Fresh release builds hit `undef` on first /compute: the device packager's per-package rename map leaves cross-package dev_* calls bare, so the vm-package devices that call dev_process_cache/dev_scheduler_formats directly fail at runtime. Route the three vm->process calls through lib_process (declared by both packages via -device_libraries) and add a packager regression test that reproduces the undef and proves the lib-routed call resolves. Verified: rebar3 compile + `rebar3 eunit --module=hb_packager_test_vectors` (all 15 pass) through a full native build. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Hey Tad! Responded with a general question on the issue, but I think your fix looks broadly right here from a logical perspective. The In order to make it mergable we would need to:
Thanks for looking at it and proposing a fix! Best, |
|
Thanks for the quick review! On the four points: 2, 3, 4 — agreed, on it: lift the duplicated functions out of their old home so 1 (the added test) — one caveat before I drop it: I checked what would actually catch a regression here, and right now nothing would. The genesis-wasm tests are Revised commit coming shortly. ~Tad & Claude |
…ermaweb#944) Per review on permaweb#953: make lib_process the single canonical home for the shared process-cache and scheduler-format helpers, and delegate from the original modules instead of mirroring duplicate bodies. - lib_process: canonical cache_write / cache_latest / cache_path / cache_first_with_path + assignments_to_aos2 (restored the ?event telemetry + latest/3 arity so the relocation is byte-faithful). - dev_process_cache: write/latest/read now delegate to lib_process; internal path/first_with_path removed. - dev_scheduler_formats: assignments_to_aos2 delegates; now-dead cursor/assignment_to_aos2 helpers removed. - Comments rewritten to describe the lib_ mechanism as-is (no issue archaeology). Net -143 lines. Avoids globalizing the rename map or any cross-package runtime coupling: shared logic stays canonical under lib_*, declared by each consuming package and compiled into its own renamed namespace. Verified: compiles clean on edge; hb_packager_test_vectors 15/15 (cross-package resolution). Runtime behavior preserved by verbatim relocation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Pushed the revision addressing the review:
This deliberately avoids globalizing the rename map or any cross-package runtime coupling: shared logic stays canonical under Verified: compiles clean on One open design question for your call: I kept the shared surface in ~Tad & Claude |
Hey — know the team's heads-down on launch, so this one's meant to be ready-to-merge, not more work.
Problem (#944): a fresh
rebar3 ... releasebuildundefs on the first/compute. Root cause is in the device packager, not the device logic.hb_packager's per-package rename map covers only a package's owndev_*roots/helpers plus its declaredlib_*, andhb_device_rename:substitute/2emits every other atom bare. So a direct call from one package to adev_*module in another package is emitted bare andundefs at runtime (only the generated/hashed module names are ever loaded). Three such vm→process calls exist today:src/preloaded/vm/dev_delegated_compute.erl:86→dev_scheduler_formats:assignments_to_aos2/4src/preloaded/vm/dev_genesis_wasm.erl:462→dev_process_cache:write/4src/preloaded/vm/dev_genesis_wasm.erl:608→dev_process_cache:latest/2(test path)Introduced by
ad285cd5("split core forge and preloaded devices").Fix: both packages already declare
-device_libraries([lib_process]), so route these calls throughlib_process— it's compiled (and renamed) into each package, so the calls resolve. Addscache_write/4,cache_latest/2,assignments_to_aos2/4tolib_process(self-contained on the never-renamedhb_*/ar_*core) and repoints the three sites.Test: new
hb_packager_test_vectors:cross_package_call_resolution_test— two packages where A calls B both directly and via a shared declared lib; asserts the direct callundefs and the lib-routed call resolves (reproduces #944 and locks it).rebar3 compile+rebar3 eunit --module=hb_packager_test_vectors→ all 15 pass, verified end-to-end through a full native build (WAMR + NIFs). Took three build iterations to nail the toolchain.One call for you: the three functions are currently mirrored into
lib_process(~110 lines) to keep this minimal and obviously correct. Happy to instead move the originals + delegate, or split outlib_process_cache/lib_scheduler_formats— whatever shape you prefer.~Tad & Claude