Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(modules): document source module builds and staging

Steven Enamakelee379314a973
diff --git a/crates/openhuman-core/src/modules/README.md b/crates/openhuman-core/src/modules/README.md
index 967b4cb172..7ad2129249 100644
--- a/crates/openhuman-core/src/modules/README.md
+++ b/crates/openhuman-core/src/modules/README.md
@@ -150,7 +150,16 @@ global mode and `OPENHUMAN_MODULE_SOURCE_<ID>` (id upper-cased) one module.
linked-modules`, then `OPENHUMAN_MODULE_SOURCE=linked`). tinybus never unloads
a module, so a process serves an id from one source only. See the crate docs
for which modules can be linked at the current vendor pins.
-- `source`: a locally built artifact.
+- `source`: a library built from the module's vendored gitlink by
+ `node scripts/modules/build.mjs <id|all>` (the recipe is the record's
+ `SourceSpec`: submodule, manifest, package, `lib_name`, features). The build
+ stages `<out>/<id>/<library>` plus a `modules.toml` holding the file's sha256
+ as operator trust, and prints `OPENHUMAN_MODULE_SOURCE_DIR=<out>` and one
+ `OPENHUMAN_MODULE_SOURCE_<ID>=source` line per module. `ops::resolve` loads
+ `<OPENHUMAN_MODULE_SOURCE_DIR>/<id>/<library>` through the same local-file
+ path as an explicit `path` override, so no new loader exists. The digest is
+ never written to `records_*.rs`: registry pins come from published releases
+ only. Builds are cached by (submodule tree, rustc, target, profile, features).
For local development and local tests only. When `linked` or `source` cannot be
honoured (no factory registered, no built artifact), the module is served from
diff --git a/scripts/modules/build.mjs b/scripts/modules/build.mjs
old mode 100644
new mode 100755
diff --git a/scripts/modules/stage-local-modules.sh b/scripts/modules/stage-local-modules.sh
new file mode 100644
index 0000000000..071323fca1
--- /dev/null
+++ b/scripts/modules/stage-local-modules.sh
@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+# Helpers the local Rust test runners (scripts/test-rust-with-mock.sh,
+# scripts/test-rust-e2e.sh) source to stage native modules.
+#
+# Released modules (the default, same as CI): `stage_release_module <id>` downloads
+# the registry-pinned archive, verifies its sha256 and puts it on
+# OPENHUMAN_MODULE_PATH. Source-built modules: with OPENHUMAN_MODULE_SOURCE=source,
+# `stage_source_modules <id>...` builds them from the vendored submodules with
+# scripts/modules/build.mjs and exports OPENHUMAN_MODULE_SOURCE_DIR plus the
+# search path. tinyconnectors has no test release, so it is always built.
+#
+# Needs REPO_ROOT, module_ext and wallet_platform (or module_platform) set by the caller.
+
+local_module_source_is_source() {
+ [ "${OPENHUMAN_MODULE_SOURCE:-}" = "source" ]
+}
+
+# stage_release_module <id> <host-platform> <ext>; prints the staged directory.
+stage_release_module() {
+ local id="$1" platform="$2" ext="$3"
+ local asset url filename sha dir archive
+ asset="$(node "$REPO_ROOT/scripts/ci/self-hosted/test-module-assets.mjs" "$platform" "$id")"
+ IFS=$'\t' read -r _id url filename sha <<< "$asset"
+ dir="$REPO_ROOT/target/test-modules/$id/$sha"
+ archive="$dir/$filename"
+ if ! compgen -G "$dir/*.$ext" >/dev/null; then
+ echo "Downloading the checksum-pinned ${id} test module ..." >&2
+ mkdir -p "$dir"
+ curl --fail --location --silent --show-error "$url" --output "$archive"
+ if command -v shasum >/dev/null 2>&1; then
+ echo "${sha} $archive" | shasum -a 256 -c >&2
+ else
+ echo "${sha} $archive" | sha256sum --check >&2
+ fi
+ tar --no-same-owner -xzf "$archive" -C "$dir"
+ fi
+ printf '%s\n' "$dir"
+}
+
+# stage_source_modules <id>... : build from the pinned submodules and eval the
+# exports. OPENHUMAN_MODULE_PATH then carries every built directory.
+stage_source_modules() {
+ local exports
+ exports="$(node "$REPO_ROOT/scripts/modules/build.mjs" "$@" --print-env)" || return 1
+ eval "$exports"
+}
diff --git a/scripts/test-rust-with-mock.sh b/scripts/test-rust-with-mock.sh
index 15ee324d77..4b0ff6dc61 100755
--- a/scripts/test-rust-with-mock.sh
+++ b/scripts/test-rust-with-mock.sh
@@ -78,28 +78,22 @@ PRODUCT_FEATURES="$(bash "$REPO_ROOT/scripts/ci/product-features.sh")"
native_module_target="$(bash "$SCRIPT_DIR/ci/native-test-module-platform.sh")"
IFS=$'\t' read -r module_ext wallet_platform <<< "$native_module_target"
-# Tokenjuice JSON-RPC coverage loads the production native module. Keep the
-# test run hermetic by building the pinned submodule instead of falling back
-# to GitHub release metadata.
-if [ -z "${TINYJUICE_TEST_MODULE:-}" ]; then
- juice_manifest="vendor/tinyjuice/crates/tinyjuice-module/Cargo.toml"
- juice_target_dir="$REPO_ROOT/target/native-test-modules/tinyjuice"
- juice_module="$juice_target_dir/release/libtinyjuice_module.$module_ext"
- echo "Building TinyJuice test module from the pinned submodule ..."
- cargo build --release --manifest-path "$juice_manifest" --target-dir "$juice_target_dir"
- export TINYJUICE_TEST_MODULE="$juice_module"
-fi
+# shellcheck source=modules/stage-local-modules.sh
+source "$SCRIPT_DIR/modules/stage-local-modules.sh"
-# Search JSON-RPC/agent coverage calls the TinySearch module against the mock
-# backend's managed Exa/Gemini routes. Build the pinned submodule so the suite
-# never depends on a published release.
-if [ -z "${TINYSEARCH_TEST_MODULE:-}" ]; then
- search_manifest="vendor/tinysearch/crates/tinysearch/Cargo.toml"
- search_target_dir="$REPO_ROOT/target/native-test-modules/tinysearch"
- search_module="$search_target_dir/release/libtinysearch.$module_ext"
- echo "Building TinySearch test module from the pinned submodule ..."
- cargo build --release --manifest-path "$search_manifest" --target-dir "$search_target_dir"
- export TINYSEARCH_TEST_MODULE="$search_module"
+# Tokenjuice, search, hosts and MCP: the registry-pinned release, as in CI. With
+# OPENHUMAN_MODULE_SOURCE=source they are built from the pinned submodules
+# instead (scripts/modules/build.mjs), which is how a module change is tried
+# against the core locally. TinyConnectors has no test release, so it is always
+# built from its submodule; its modules.toml carries the operator-trust digest.
+local_source_ids=(tinyconnectors)
+if local_module_source_is_source; then
+ local_source_ids+=(tinyjuice tinysearch tinyhosts tinymcp)
+else
+ for released_id in tinyjuice tinysearch; do
+ released_dir="$(stage_release_module "$released_id" "$wallet_platform" "$module_ext")"
+ export OPENHUMAN_MODULE_PATH="$released_dir${OPENHUMAN_MODULE_PATH:+:$OPENHUMAN_MODULE_PATH}"
+ done
fi
# Wallet JSON-RPC E2E sends a recovery phrase only to an attested module. Build
@@ -141,6 +135,7 @@ if [ ! -f "$docs_dir/libtinydocs_module.$module_ext" ]; then
fi
export OPENHUMAN_MODULE_PATH="$docs_dir${OPENHUMAN_MODULE_PATH:+:$OPENHUMAN_MODULE_PATH}"
+if ! local_module_source_is_source; then
# The released TinyHosts contract test runs in its own process, outside the
# generic unit suite. Keep the recipient pinned to the registry digest just
# like the other native module fixtures.
@@ -159,7 +154,8 @@ if [ ! -f "$hosts_dir/libtinyhosts.$module_ext" ]; then
fi
tar --no-same-owner -xzf "$hosts_archive" -C "$hosts_dir"
fi
-export OPENHUMAN_TINYHOSTS_TEST_MODULE="$hosts_dir/libtinyhosts.$module_ext"
+export OPENHUMAN_MODULE_PATH="$hosts_dir${OPENHUMAN_MODULE_PATH:+:$OPENHUMAN_MODULE_PATH}"
+fi
# TinyBox command analysis is required by shell-backed storage and capability
# tests. Load the published, checksum-pinned module rather than relying on the
@@ -181,6 +177,7 @@ if [ ! -f "$tinybox_dir/libtinybox.$module_ext" ]; then
fi
export OPENHUMAN_MODULE_PATH="$tinybox_dir${OPENHUMAN_MODULE_PATH:+:$OPENHUMAN_MODULE_PATH}"
+if ! local_module_source_is_source; then
# The MCP registry E2E targets exercise real TinyMCP lifecycle calls through
# the host's module adapter. Load the released, checksum-pinned module just as
# the self-hosted CI installer does.
@@ -200,17 +197,24 @@ if [ ! -f "$tinymcp_dir/libtinymcp_module.$module_ext" ]; then
tar --no-same-owner -xzf "$tinymcp_archive" -C "$tinymcp_dir"
fi
export OPENHUMAN_MODULE_PATH="$tinymcp_dir${OPENHUMAN_MODULE_PATH:+:$OPENHUMAN_MODULE_PATH}"
-export OPENHUMAN_TINYMCP_TEST_MODULE="$tinymcp_dir/libtinymcp_module.$module_ext"
+fi
-if [ -z "${TINYCONNECTORS_TEST_MODULE:-}" ]; then
- connectors_manifest="vendor/tinyconnectors/crates/tinyconnectors/Cargo.toml"
- connectors_target_dir="${TINYCONNECTORS_TARGET_DIR:-$REPO_ROOT/target/native-test-modules/tinyconnectors}"
- connectors_module="$connectors_target_dir/release/libtinyconnectors.$module_ext"
- echo "Building TinyConnectors test module from the pinned submodule ..."
- cargo build --release --manifest-path "$connectors_manifest" --target-dir "$connectors_target_dir"
- connectors_module="$(node scripts/ci/stage-connector-test-module.mjs \
- "$connectors_module" "$REPO_ROOT/target/test-modules/tinyconnectors")"
+# Build the source modules in one call. The connector directory goes only on
+# the processes that exercise it: most Composio raw-coverage groups explicitly
+# test the absent-module path.
+path_before_sources="${OPENHUMAN_MODULE_PATH:-}"
+stage_source_modules "${local_source_ids[@]}"
+connectors_dir="$REPO_ROOT/target/module-sources/tinyconnectors"
+if [ -n "$path_before_sources" ]; then
+ export OPENHUMAN_MODULE_PATH="$path_before_sources"
+else
+ unset OPENHUMAN_MODULE_PATH
fi
+for source_id in "${local_source_ids[@]}"; do
+ [ "$source_id" = tinyconnectors ] && continue
+ export OPENHUMAN_MODULE_PATH="$REPO_ROOT/target/module-sources/$source_id${OPENHUMAN_MODULE_PATH:+:$OPENHUMAN_MODULE_PATH}"
+done
+connectors_module_path="$connectors_dir${OPENHUMAN_MODULE_PATH:+:$OPENHUMAN_MODULE_PATH}"
cargo_test() {
cargo test --manifest-path Cargo.toml --workspace \
@@ -239,8 +243,8 @@ run_raw_coverage_modules() {
if { [ "$module" = "composio_credentials_state_raw_coverage_e2e" ] ||
[ "$module" = "composio_tools_direct_raw_coverage_e2e" ] ||
[ "$module" = "tools_composio_large_round25_raw_coverage_e2e" ]; } &&
- [ -z "${TINYCONNECTORS_TEST_MODULE:-}" ]; then
- TINYCONNECTORS_TEST_MODULE="$connectors_module" \
+ true; then
+ OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --test raw_coverage_all -- "${module}::" --test-threads=1 "$@"
else
cargo_test --test raw_coverage_all -- "${module}::" --test-threads=1 "$@"
@@ -261,7 +265,7 @@ run_in_process_modules() {
while IFS= read -r module; do
[ -n "$module" ] || continue
echo "[test-rust-with-mock] in-process module: ${module}"
- TINYCONNECTORS_TEST_MODULE="${TINYCONNECTORS_TEST_MODULE:-$connectors_module}" \
+ OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --test in_process_all -- "${module}::" "$@"
done < <(in_process_modules)
}
@@ -299,7 +303,7 @@ run_full_suite() {
# Several unit fixtures mutate process-wide state (provider overrides and
# temporary executable paths). Keep this aggregate invocation deterministic;
# integration targets below retain their own, narrower isolation strategies.
- TINYCONNECTORS_TEST_MODULE="${TINYCONNECTORS_TEST_MODULE:-$connectors_module}" \
+ OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --lib -- --test-threads=1 \
--skip a_build_only_runtime_is_swept_before_it_can_be_invoked "$@"
# The core binary and the developer bins live in `crates/openhuman-cli`;
@@ -322,17 +326,17 @@ run_full_suite() {
elif [ "$target" = "mcp_registry_e2e" ]; then
# The TinyMCP module owns process-level directory transitions; this
# binary exercises several workspaces against that shared module object.
- TINYCONNECTORS_TEST_MODULE="${TINYCONNECTORS_TEST_MODULE:-$connectors_module}" \
+ OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --test "$target" -- --ignored --test-threads=1 "$@"
else
- TINYCONNECTORS_TEST_MODULE="${TINYCONNECTORS_TEST_MODULE:-$connectors_module}" \
+ OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --test "$target" -- "$@"
fi
done < <(integration_test_targets)
# Loading a native module mutates process-global module state, so exercise
# the published contract in a fresh libtest process with its pinned artifact.
- TINYCONNECTORS_TEST_MODULE="${TINYCONNECTORS_TEST_MODULE:-$connectors_module}" \
+ OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --lib \
hosting::test::released_artifact_serves_providers_and_confidential_local_preparation \
-- --exact --ignored --test-threads=1
@@ -366,7 +370,7 @@ elif [ "$#" -ge 2 ] && [ "$1" = "--test" ] && [ "$2" = "mcp_registry_e2e" ]; the
if [ "${1:-}" = "--" ]; then
shift
fi
- TINYCONNECTORS_TEST_MODULE="${TINYCONNECTORS_TEST_MODULE:-$connectors_module}" \
+ OPENHUMAN_MODULE_PATH="$connectors_module_path" \
cargo_test --test mcp_registry_e2e -- --ignored --test-threads=1 "$@"
else
cargo_test "$@"