feat: stabilize OpenSim interactions and landmarks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user