Skip to content

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

test(triage): make the origin tripwire check provenance, not just presence\n\nThe tripwire recorded each dispatch site's expected provenance in\nKNOWN_SITES and then dropped it: the set comparison mapped the tuple down\nto paths, and the per-file assertion only asked whether the text contained\n`with_origin(` at all. A remote, attacker-influenceable site scoped with\n`local_trigger_origin` therefore passed — which is precisely the defect the\ntwo labels exist to prevent, and the one this module is named for.\n\nThree assertions now run per recorded site:\n\n- the expected helper is present;\n- the opposite helper is absent, so a remote payload cannot take the local\n trust root without failing here;\n- `apply_decision(` and `with_origin(` counts match, so an unscoped second\n dispatch added beside a scoped one trips the wire instead of hiding\n behind its neighbour.\n\nText cannot prove which scope wraps which call — that needs a structural\npass over the AST, which this deliberately is not. The ratio check is the\npart of that property a grep-level tripwire can carry.\n\nVerified by construction: scoping a remote site with `local_trigger_origin`\nfails the provenance assertion, and adding a second unscoped\n`apply_decision` fails the ratio assertion. Neither failed before this.\n

M3gA-Mind42d4d2241fee
diff --git a/src/openhuman/agent/triage/origin_tests.rs b/src/openhuman/agent/triage/origin_tests.rs
index 9e0dfc7316..2ab660b24c 100644
--- a/src/openhuman/agent/triage/origin_tests.rs
+++ b/src/openhuman/agent/triage/origin_tests.rs
@@ -128,6 +128,45 @@ fn every_dispatch_site_scopes_an_origin() {
approval gate as `Unknown` and is denied (openhuman#5634). Scope \
`remote_trigger_origin` or `local_trigger_origin` by provenance."
);
+
+ // Every dispatch in the file must be inside a scope. Text
+ // cannot prove *which* scope wraps *which* call, but an
+ // unscoped call added beside a scoped one changes this ratio,
+ // which is the shape the previous version of this test missed.
+ let dispatches = text.matches("apply_decision(").count();
+ let scopes = text.matches("with_origin(").count();
+ assert_eq!(
+ dispatches, scopes,
+ "{rel} has {dispatches} triage dispatch(es) but {scopes} origin scope(s); \
+ every `apply_decision` call needs its own `with_origin` (openhuman#5634)"
+ );
+
+ // The provenance assertion — the reason two labels exist. A
+ // remote payload scoped with the local trust root is the exact
+ // defect this module prevents, and it is indistinguishable from
+ // a correct file if the test only asks whether *some* origin
+ // was scoped.
+ if let Some((_, kind)) = KNOWN_SITES.iter().find(|(path, _)| *path == rel) {
+ let (want, reject) = match *kind {
+ "remote" => ("remote_trigger_origin", "local_trigger_origin"),
+ "local" => ("local_trigger_origin", "remote_trigger_origin"),
+ other => panic!("KNOWN_SITES has unknown provenance {other:?} for {rel}"),
+ };
+ assert!(
+ text.contains(want),
+ "{rel} is recorded as `{kind}` provenance but does not scope `{want}`"
+ );
+ assert!(
+ !text.contains(reject),
+ "{rel} is recorded as `{kind}` provenance but scopes `{reject}`. \
+ A remote, attacker-influenceable payload must never take the local \
+ trust root: that grants authority the caller never had, which is the \
+ defect openhuman#5634 exists to prevent. If the provenance genuinely \
+ changed, change the KNOWN_SITES entry deliberately — do not widen \
+ this assertion."
+ );
+ }
+
found.push(rel);
}
}