feat: stabilize OpenSim interactions and landmarks
Some checks failed
CI / rust-skia (Rust only) (push) Has been cancelled
CI / required (push) Has been cancelled

This commit is contained in:
2026-08-21 22:46:10 +02:00
parent adf5165033
commit e4e84dcdcb
27 changed files with 536 additions and 101 deletions

View File

@@ -15,6 +15,7 @@ fn id(value: u128) -> UUID {
#[derive(Default)]
struct FakeGrid {
created: Mutex<Vec<String>>,
accepted: Mutex<Vec<String>>,
declined: Mutex<Vec<String>>,
teleports: Mutex<Vec<UUID>>,
@@ -23,6 +24,17 @@ struct FakeGrid {
}
impl LandmarkGrid for FakeGrid {
fn create_current_landmark(
&self,
name: String,
_: CancellationToken,
) -> LandmarkFuture<'_, OfferedInventoryNode> {
Box::pin(async move {
self.created.lock().expect("created").push(name.clone());
Ok(landmark(980, 981, 70, &name))
})
}
fn accept_offer(&self, offer_id: &str, _: CancellationToken) -> LandmarkFuture<'_, ()> {
let offer_id = offer_id.to_owned();
Box::pin(async move {
@@ -57,6 +69,33 @@ impl LandmarkGrid for FakeGrid {
}
}
#[tokio::test]
async fn authorized_agent_creates_current_landmark_in_inventory_and_catalog() {
let grid = Arc::new(FakeGrid::default());
let service = service(grid.clone(), &[70]);
let entry = service
.create_current(
id(70),
"Current Test Location",
CancellationToken::default(),
)
.await
.expect("create current landmark");
assert_eq!(entry.display_name, "Current Test Location");
assert_eq!(service.entries(), vec![entry]);
assert_eq!(
grid.created.lock().expect("created").as_slice(),
&["Current Test Location"]
);
assert_eq!(
service
.create_current(id(71), "Denied", CancellationToken::default())
.await,
Err(LandmarkError::Unauthorized)
);
assert_eq!(grid.created.lock().expect("created").len(), 1);
}
#[derive(Debug)]
struct FixedRandom;
impl RoamingRandom for FixedRandom {
@@ -513,6 +552,11 @@ fn public_and_unauthorized_im_cannot_select_teleport_or_change_roaming() {
)
.expect("gateway");
for (origin, name, arguments) in [
(
ActionOrigin::public_chat(id(60)),
LANDMARK_CREATE_TOOL,
serde_json::json!({"name":"Denied"}),
),
(
ActionOrigin::public_chat(id(60)),
LANDMARK_TELEPORT_TOOL,
@@ -555,3 +599,33 @@ fn public_and_unauthorized_im_cannot_select_teleport_or_change_roaming() {
.is_some()
);
}
#[test]
fn schedule_configuration_does_not_spend_teleport_distance_budget() {
let gateway = PolicyGateway::new(
BTreeSet::from([id(62)]),
landmark_policy_tools(LandmarkLimits::default()).expect("tools"),
PolicyLimits::default(),
Arc::new(MemoryPolicyAudit::new(16).expect("audit")),
)
.expect("gateway");
let arguments = serde_json::json!({
"schedule_id":"budget-safe",
"minimum_interval_seconds":300,
"maximum_interval_seconds":300,
"enabled":false
});
let context =
PolicyRequestContext::new(ActionOrigin::instant_message(id(62)), "session", "schedule")
.expect("context");
let call =
ProposedToolCall::new("call", LANDMARK_SCHEDULE_TOOL, arguments.to_string()).expect("call");
assert!(
gateway
.evaluate(&context, &call, &arguments, None, 1)
.expect("decision")
.into_authorization()
.is_some()
);
assert_eq!(gateway.global_budget_usage().movement_millimeters, 0);
}