The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
fix(modules): report unknown IDs and reject bare implementation packages
Steven Enamakel090df9e589cb
diff --git a/crates/openhuman-core/src/modules/client.rs b/crates/openhuman-core/src/modules/client.rsindex 7ecedae27b..ba3402c1dc 100644--- a/crates/openhuman-core/src/modules/client.rs+++ b/crates/openhuman-core/src/modules/client.rs@@ -80,7 +80,10 @@ impl ModuleClient {args: impl Serialize,confidential: bool,) -> Result<R, ModuleCallError> {- let record = registry::find(module).ok_or(ModuleCallError::Unavailable)?;+ let Some(record) = registry::find(module) else {+ failure::report_unknown_module();+ return Err(ModuleCallError::Unavailable);+ };if !self.config.modules.enabled {failure::report(record, failure::Reason::Disabled);return Err(ModuleCallError::Unavailable);diff --git a/crates/openhuman-core/src/modules/client_tests.rs b/crates/openhuman-core/src/modules/client_tests.rsindex 2134fb0401..b5f4d08f52 100644--- a/crates/openhuman-core/src/modules/client_tests.rs+++ b/crates/openhuman-core/src/modules/client_tests.rs@@ -151,3 +151,38 @@ async fn bus_calls_preserve_tuple_arity_and_never_downgrade_confidentiality() {Err(ModuleCallError::IncompatibleContract));}++#[cfg(feature = "crash-reporting")]+#[test]+fn unknown_module_failures_emit_only_safe_registry_metadata() {+ let events = sentry::test::with_captured_events(|| {+ let runtime = tokio::runtime::Builder::new_current_thread()+ .build()+ .unwrap();+ runtime.block_on(async {+ let client = ModuleClient::new(Config::default());+ for _ in 0..2 {+ let error = client+ .call::<serde_json::Value>(+ "private-token /home/private-user",+ "secret-member",+ ("private-content",),+ )+ .await+ .unwrap_err();+ assert_eq!(error, ModuleCallError::Unavailable);+ assert!(!error.to_string().contains("private"));+ }+ });+ });+ assert_eq!(events.len(), 1, "{events:?}");+ assert_eq!(+ events[0].tags.get("module").map(String::as_str),+ Some("unregistered")+ );+ assert_eq!(+ events[0].tags.get("reason_code").map(String::as_str),+ Some("unknown_module")+ );+ assert!(!format!("{events:?}").contains("private"));+}diff --git a/crates/openhuman-core/src/modules/failure.rs b/crates/openhuman-core/src/modules/failure.rsindex 301a58640a..524e273351 100644--- a/crates/openhuman-core/src/modules/failure.rs+++ b/crates/openhuman-core/src/modules/failure.rs@@ -8,6 +8,7 @@ use super::types::ModuleRecord;/// Closed reason vocabulary: never accept a module error, path or payload here.#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]pub(super) enum Reason {+ UnknownModule,Disabled,LoaderDisabled,ResolutionFailed,@@ -19,6 +20,7 @@ pub(super) enum Reason {impl Reason {fn code(self) -> &'static str {match self {+ Self::UnknownModule => "unknown_module",Self::Disabled => "disabled",Self::LoaderDisabled => "loader_disabled",Self::ResolutionFailed => "resolution_failed",@@ -30,6 +32,7 @@ impl Reason {fn stage(self) -> &'static str {match self {+ Self::UnknownModule => "registry",Self::Disabled | Self::LoaderDisabled => "availability",Self::ResolutionFailed => "resolve",Self::IncompatibleContract => "contract",@@ -44,6 +47,15 @@ impl Reason {/// There are finitely many registry records and reasons, so the process cache/// is bounded. Concurrent callers cannot duplicate the same terminal report.pub(super) fn report(record: &'static ModuleRecord, reason: Reason) {+ report_metadata(record.id, record.version, reason);+}++/// Unknown identifiers never become event metadata or deduplication keys.+pub(super) fn report_unknown_module() {+ report_metadata("unregistered", "unknown", Reason::UnknownModule);+}++fn report_metadata(module: &'static str, version: &'static str, reason: Reason) {static REPORTED: OnceLock<Mutex<HashSet<(&'static str, Reason)>>> = OnceLock::new();let platform = format!("{}-{}", std::env::consts::OS, std::env::consts::ARCH);let capture = || {@@ -52,8 +64,8 @@ pub(super) fn report(record: &'static ModuleRecord, reason: Reason) {"modules",reason.stage(),&[- ("module", record.id),- ("version", record.version),+ ("module", module),+ ("version", version),("stage", reason.stage()),("platform", &platform),("reason_code", reason.code()),@@ -71,7 +83,7 @@ pub(super) fn report(record: &'static ModuleRecord, reason: Reason) {.get_or_init(|| Mutex::new(HashSet::new())).lock().unwrap_or_else(std::sync::PoisonError::into_inner)- .insert((record.id, reason));+ .insert((module, reason));if !first {return;}diff --git a/crates/openhuman-core/src/modules/failure_tests.rs b/crates/openhuman-core/src/modules/failure_tests.rsindex 2626f93b6d..4162216994 100644--- a/crates/openhuman-core/src/modules/failure_tests.rs+++ b/crates/openhuman-core/src/modules/failure_tests.rs@@ -51,6 +51,7 @@ fn terminal_reports_are_sanitized_and_deduplicated() {#[test]fn reason_codes_and_stages_are_closed_vocabulary() {for reason in [+ Reason::UnknownModule,Reason::Disabled,Reason::LoaderDisabled,Reason::ResolutionFailed,diff --git a/scripts/__tests__/check-module-boundaries.test.mjs b/scripts/__tests__/check-module-boundaries.test.mjsindex a0689dbc8a..323c03c015 100644--- a/scripts/__tests__/check-module-boundaries.test.mjs+++ b/scripts/__tests__/check-module-boundaries.test.mjs@@ -116,3 +116,13 @@ test('every approved vocabulary descendant must come from the approved registry'm.packages.find(pkg => pkg.name === 'syn').source = null;assert.deepEqual(auditGraph(m, ['tinyjuice-bus'], strict, 'tinyjuice-bus').violations[0].path, ['tinyjuice-bus', 'serde', 'syn']);});++test('bare owning packages and their implementation descendants are both forbidden', () => {+ for (const prefix of policy.implementationPrefixes) {+ const owner = prefix.replace(/-$/, '');+ assert.equal(isImplementation(owner, strict), true, owner);+ assert.equal(isImplementation(`${owner}-new-engine`, strict), true, owner);+ const contract = policy.contracts.find(item => item.name === `${owner}-bus`);+ if (contract) assert.equal(isImplementation(contract.name, strict), false, contract.name);+ }+});diff --git a/scripts/ci/check-module-boundaries.mjs b/scripts/ci/check-module-boundaries.mjsindex ee430fb8b7..533b0c09ce 100644--- a/scripts/ci/check-module-boundaries.mjs+++ b/scripts/ci/check-module-boundaries.mjs@@ -16,7 +16,7 @@ export const CONTRACT_CLOSURE = new Set([export function isImplementation(name, policy) {return policy.implementationPackages.includes(name) ||- policy.implementationPrefixes.some(prefix => name.startsWith(prefix) &&+ policy.implementationPrefixes.some(prefix => (name === prefix.replace(/-$/, '') || name.startsWith(prefix)) &&!policy.contracts.some(contract => contract.name === name));}