Skip to content

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

feat(modules): warn when a local module build is ahead of its pin

Steven Enamakel13d7bee9bd66
diff --git a/crates/openhuman-core/src/modules/ops.rs b/crates/openhuman-core/src/modules/ops.rs
index b1156858a7..77c2898cd6 100644
--- a/crates/openhuman-core/src/modules/ops.rs
+++ b/crates/openhuman-core/src/modules/ops.rs
@@ -295,6 +295,15 @@ async fn resolve(config: &Config, record: &'static ModuleRecord) -> Result<(), S
plan.requested.as_str(),
plan.served
);
+ // `resolve` runs once per id per process, so this is one line per id.
+ if let Some(line) = source::pin_ahead_warning(
+ record.id,
+ plan.served,
+ std::env::var(source::PIN_AHEAD_ENV).ok().as_deref(),
+ cfg!(debug_assertions),
+ ) {
+ log::warn!("{line}");
+ }
match plan.served {
ModuleSource::LocalFile | ModuleSource::Source => {
if let Some(path) = plan.artifact {
diff --git a/crates/openhuman-core/src/modules/source.rs b/crates/openhuman-core/src/modules/source.rs
index 6bbc626ffd..20827dbbb0 100644
--- a/crates/openhuman-core/src/modules/source.rs
+++ b/crates/openhuman-core/src/modules/source.rs
@@ -89,6 +89,37 @@ pub fn local_artifact(id: &str) -> Option<PathBuf> {
.find(|path| path.is_file())
}
+/// Environment variable listing module ids whose gitlink is ahead of the
+/// registry pin, comma separated. `scripts/modules/pin-status.mjs --print-env`
+/// prints it; a developer exports it next to `OPENHUMAN_MODULE_SOURCE`.
+pub(crate) const PIN_AHEAD_ENV: &str = "OPENHUMAN_MODULE_PIN_AHEAD";
+
+/// The warning for serving `id` from a local build whose gitlink is ahead of
+/// its released pin, or `None` when there is nothing to say.
+///
+/// Pure: `ahead_ids` is the raw [`PIN_AHEAD_ENV`] value and `debug` is whether
+/// this is a debug build. Only `Linked` and `Source` serve a local build, and
+/// release builds stay silent.
+#[must_use]
+pub(super) fn pin_ahead_warning(
+ id: &str,
+ served: ModuleSource,
+ ahead_ids: Option<&str>,
+ debug: bool,
+) -> Option<String> {
+ if !debug || !matches!(served, ModuleSource::Linked | ModuleSource::Source) {
+ return None;
+ }
+ let ahead = ahead_ids?
+ .split(',')
+ .any(|candidate| candidate.trim() == id);
+ ahead.then(|| {
+ format!(
+ "[modules] id={id} served={served:?}: gitlink ahead of released pin; you are running a locally compiled module, publish a release and re-pin (scripts/modules/release-and-repin.mjs) before CI will pass"
+ )
+ })
+}
+
/// Choose the source for `id` under `config`.
pub(super) fn plan(config: &Config, id: &str) -> SourcePlan {
plan_with(