Skip to content

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

fix(core): inventory narrow ledger and telemetry SDK contracts

Steven Enamakeleef8ee36be1d
diff --git a/crates/openhuman-core/src/agent/tinyagents/turn_observer.rs b/crates/openhuman-core/src/agent/tinyagents/turn_observer.rs
index d8db6cf3eb..0ccb7c3154 100644
--- a/crates/openhuman-core/src/agent/tinyagents/turn_observer.rs
+++ b/crates/openhuman-core/src/agent/tinyagents/turn_observer.rs
@@ -285,11 +285,7 @@ impl ModelMiddleware<(), OpenHumanRunContext> for ObserverScope {
/// Existing TinyAgents exporter; this module adds no transport implementation.
#[cfg(feature = "langfuse")]
pub mod langfuse {
- pub use tinyagents_harness::events::AgentEvent;
- pub use tinyagents_harness::ids::{CallId, EventId, RunId};
- pub use tinyagents_harness::observability::AgentObservation;
pub use tinyagents_harness::observability::{
LangfuseAuth, LangfuseClient, LangfuseScore, LangfuseScoreValue, LangfuseTraceConfig,
};
- pub use tinyinference_llm::usage::Usage;
}
diff --git a/crates/openhuman-embed/OBSERVERS.md b/crates/openhuman-embed/OBSERVERS.md
index 8aaecfcb13..2892dd25a6 100644
--- a/crates/openhuman-embed/OBSERVERS.md
+++ b/crates/openhuman-embed/OBSERVERS.md
@@ -51,13 +51,21 @@ API and await its cleanup when completion telemetry is required.
## Existing Langfuse exporter
-The optional `langfuse` feature forwards TinyAgents' existing exporter through
-`observe::langfuse`, including `LangfuseClient`, `LangfuseAuth`,
-`LangfuseTraceConfig`, and its durable `AgentObservation` contract. It adds no
-second HTTP transport. The host supplies export credentials and batches durable
-observations with `LangfuseClient::build_ingestion_batch` /
-`send_observations`; do that work outside synchronous callbacks. This is a
-separate durable-journal contract, not an implicit export of captured turn data.
+The optional `langfuse` feature forwards the existing transport through
+`observe::langfuse`: `LangfuseClient`, `LangfuseAuth`, score types and trace
+configuration. Hosts build their own batches from curated `TurnObservation`
+events and queue `send_batch` outside synchronous callbacks. The adapter adds
+no second HTTP transport. Harness events, journal records, runtime identifiers
+and native inference usage types are not part of this public facade.
+
+The architecture gate inventories two exact SDK forwarding statements in
+`scripts/lib/agent-sdk-contracts.mjs`: this telemetry transport contract and the
+native atomic budget ledger primitives. Reusing the ledger preserves one
+admission owner below physical retries; wrapping it with a second host ledger
+would split reservations. These inventories are permanent public contracts,
+not temporary violation baseline entries. Each matches its full statement and
+owning file; adding a runtime symbol, alias, wildcard or moving the forwarding
+requires explicit review and fails the anti-leak regressions.
See [CONSUMERS.md](CONSUMERS.md) for the current dependency footprint: gating the
public exporter does not make enabled Embed an HTTP-free build.
diff --git a/crates/openhuman-embed/src/observe.rs b/crates/openhuman-embed/src/observe.rs
index b9e57b16e2..d7e41a3af3 100644
--- a/crates/openhuman-embed/src/observe.rs
+++ b/crates/openhuman-embed/src/observe.rs
@@ -109,7 +109,7 @@ where
});
result
}
-/// Existing TinyAgents Langfuse client and durable observation contract.
+/// Existing Langfuse transport, authentication, score and configuration types.
/// Enable the `langfuse` feature. Export requires explicit host credentials.
#[cfg(feature = "langfuse")]
pub mod langfuse {
diff --git a/crates/openhuman-embed/tests/turn_observers.rs b/crates/openhuman-embed/tests/turn_observers.rs
index 09fbcd4562..2e30fd291b 100644
--- a/crates/openhuman-embed/tests/turn_observers.rs
+++ b/crates/openhuman-embed/tests/turn_observers.rs
@@ -62,28 +62,10 @@ fn terminal_errors_and_inputs_are_private_unless_content_is_requested() {
#[cfg(feature = "langfuse")]
#[test]
fn existing_langfuse_exporter_builds_a_host_owned_batch_without_network() {
- use openhuman_embed::observe::langfuse::{
- AgentEvent, AgentObservation, EventId, LangfuseClient, LangfuseTraceConfig, RunId,
- };
+ use openhuman_embed::observe::langfuse::{LangfuseClient, LangfuseScore};
let client = LangfuseClient::proxy("http://127.0.0.1:1", "fixture-token").unwrap();
- let batch = client
- .build_ingestion_batch(
- LangfuseTraceConfig::default(),
- &[AgentObservation {
- event_id: EventId::new("event"),
- run_id: RunId::new("run"),
- root_run_id: RunId::new("run"),
- parent_run_id: None,
- offset: 0,
- ts_ms: 1_704_067_200_000,
- event: AgentEvent::RunStarted {
- run_id: RunId::new("run"),
- thread_id: None,
- },
- }],
- )
- .unwrap();
- assert_eq!(batch["batch"][0]["type"], "trace-create");
- assert_eq!(batch["batch"][0]["body"]["id"], "run");
+ let batch = client.build_score_batch(LangfuseScore::numeric("run", "review", 1.0));
+ assert_eq!(batch["batch"][0]["type"], "score-create");
+ assert_eq!(batch["batch"][0]["body"]["traceId"], "run");
assert!(!batch.to_string().contains("fixture-token"));
}
diff --git a/scripts/__tests__/agent-sdk-contracts.test.mjs b/scripts/__tests__/agent-sdk-contracts.test.mjs
new file mode 100644
index 0000000000..7361895987
--- /dev/null
+++ b/scripts/__tests__/agent-sdk-contracts.test.mjs
@@ -0,0 +1,27 @@
+import assert from "node:assert/strict";
+import test from "node:test";
+import { sanctionedSdkReexportLines } from "../lib/agent-sdk-contracts.mjs";
+
+const budgetPath = "crates/openhuman-core/src/agent/tinyagents/budget.rs";
+const observerPath = "crates/openhuman-core/src/agent/tinyagents/turn_observer.rs";
+const budget = "pub use tinyinference_llm::model::budget::{\n Budget, BudgetExceeded, BudgetSnapshot, CallBudget, Spend, SpendLimits,\n};";
+const transport = "pub use tinyagents_harness::observability::{LangfuseAuth, LangfuseClient, LangfuseScore, LangfuseScoreValue, LangfuseTraceConfig};";
+
+test("native ledger and existing telemetry transport have exact host contracts", () => {
+ assert.deepEqual([...sanctionedSdkReexportLines(budgetPath, `\n${budget}`)], [2]);
+ assert.deepEqual([...sanctionedSdkReexportLines(observerPath, transport)], [1]);
+});
+
+test("inventory refuses runtime types, wildcard, aliases and physically moved contracts", () => {
+ for (const statement of [
+ budget.replace("SpendLimits,", "SpendLimits, BudgetedModel,"),
+ budget.replace("Budget,", "Budget as HostBudget,"),
+ "pub use tinyinference_llm::model::budget::*;",
+ transport.replace("LangfuseAuth,", "AgentHarness, LangfuseAuth,"),
+ "pub use tinyagents_harness::events::AgentEvent;",
+ ]) {
+ assert.equal(sanctionedSdkReexportLines(budgetPath, statement).size, 0);
+ assert.equal(sanctionedSdkReexportLines(observerPath, statement).size, 0);
+ }
+ assert.equal(sanctionedSdkReexportLines("crates/openhuman-embed/src/budget.rs", budget).size, 0);
+});
diff --git a/scripts/ci/check-agent-runtime-boundary.mjs b/scripts/ci/check-agent-runtime-boundary.mjs
index b9d71f171c..63c99687b0 100644
--- a/scripts/ci/check-agent-runtime-boundary.mjs
+++ b/scripts/ci/check-agent-runtime-boundary.mjs
@@ -4,6 +4,7 @@ import { readFile, readdir, writeFile } from "node:fs/promises";
import { dirname, relative, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import { isClaudeCodeBridgeMessage } from "../lib/runtime-boundary-types.mjs";
+import { sanctionedSdkReexportLines } from "../lib/agent-sdk-contracts.mjs";
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
const baselinePath = resolve(
@@ -361,6 +362,14 @@ function isBehaviorFreeForwarder(source) {
}
function assertSelfTests() {
+ const sdkPath = "crates/openhuman-core/src/agent/tinyagents/budget.rs";
+ const sdkStatement = "pub use tinyinference_llm::model::budget::{Budget, BudgetExceeded, BudgetSnapshot, CallBudget, Spend, SpendLimits};";
+ if (
+ sanctionedSdkReexportLines(sdkPath, sdkStatement).size !== 1 ||
+ sanctionedSdkReexportLines(sdkPath, sdkStatement.replace("SpendLimits", "SpendLimits, BudgetedModel")).size !== 0 ||
+ sanctionedSdkReexportLines(sdkPath, "pub use tinyagents_harness::runtime::AgentHarness;").size !== 0
+ )
+ throw new Error("agent-runtime boundary self-test: host SDK inventory leaked runtime contracts");
const fixture = [
"[dependencies.openhuman]",
'version = "1"',
@@ -468,7 +477,9 @@ for (const path of await filesUnder(
(path) => path.endsWith(".rs") && /\/src\//.test(path),
)) {
const rel = relative(repoRoot, path);
- for (const { line, text, raw } of codeLines(await readFile(path, "utf8"))) {
+ const source = await readFile(path, "utf8");
+ const sdkContractLines = sanctionedSdkReexportLines(rel, rustCode(source));
+ for (const { line, text, raw } of codeLines(source)) {
if (!text.trim()) continue;
const compact = compactRustPath(text);
if (/\btinyagents_harness::tool_calling\b/.test(compact))
@@ -517,7 +528,7 @@ for (const path of await filesUnder(
if (
/\bpub(?:\s*\([^)]*\))?\s+use\s+(?:tinyagents(?:_[a-z_]+)?|tinytools(?:_[a-z_]+)?|tinyinference(?:_[a-z_]+)?)\s*::/i.test(
text,
- )
+ ) && !sdkContractLines.has(line)
)
add("openhuman-upstream-reexport", path, line, raw);
}
diff --git a/scripts/lib/agent-sdk-contracts.mjs b/scripts/lib/agent-sdk-contracts.mjs
new file mode 100644
index 0000000000..0a3a346277
--- /dev/null
+++ b/scripts/lib/agent-sdk-contracts.mjs
@@ -0,0 +1,24 @@
+// Exact host SDK contracts; never general runtime/harness forwarding.
+const compact = (value) => value.replace(/\s+/g, "").replace(/,}/g, "}");
+const contracts = new Map([
+ ["crates/openhuman-core/src/agent/tinyagents/budget.rs", compact(
+ "pub use tinyinference_llm::model::budget::{Budget, BudgetExceeded, BudgetSnapshot, CallBudget, Spend, SpendLimits};",
+ )],
+ ["crates/openhuman-core/src/agent/tinyagents/turn_observer.rs", compact(
+ "pub use tinyagents_harness::observability::{LangfuseAuth, LangfuseClient, LangfuseScore, LangfuseScoreValue, LangfuseTraceConfig};",
+ )],
+]);
+
+// Callers pass Rust with comments/literals masked. Full-statement matching
+// prevents adding a runtime type to a multiline approved forwarding statement.
+export function sanctionedSdkReexportLines(path, code) {
+ const approved = contracts.get(path);
+ const lines = new Set();
+ if (!approved) return lines;
+ for (const match of code.matchAll(/\bpub\s+use\s+[^;]+;/g)) {
+ if (compact(match[0]) === approved) {
+ lines.add(code.slice(0, match.index).split(/\r?\n/).length);
+ }
+ }
+ return lines;
+}