bxcore, brokerd, loopd: an invalid-arguments denial says why

Co-Authored-By: ornith-1.5-35b-a3b <agent@wntrmute.dev>
This commit is contained in:
2026-09-27 19:08:42 -07:00
co-authored by ornith-1.5-35b-a3b
parent 89a50bc3c6
commit de60c9e13a
21 changed files with 520 additions and 33 deletions
+30 -2
View File
@@ -5,7 +5,8 @@ mod support;
use bxcore::{CallId, DenyReason, SessionId, ToolRequest, ToolResponse};
use loopd::tools::{
Dispatch, FakeTools, Pending, Registry, ToolPort, cap_result, denial_text, dispatch,
Dispatch, FakeTools, Pending, Registry, ToolPort, cap_result, denial_message, denial_text,
dispatch,
};
fn req(tool: &str, arguments: &str) -> ToolRequest {
@@ -252,9 +253,35 @@ fn every_deny_reason_has_its_sentence() {
];
for (reason, want) in table {
assert_eq!(denial_text(reason), want, "{reason:?}");
assert_eq!(
denial_message(reason, None),
want,
"{reason:?}: without a detail, the sentence alone"
);
}
}
/// The broker's detail goes after the sentence, before its full stop.
#[test]
fn a_denial_with_a_detail_appends_it_to_the_sentence() {
assert_eq!(
denial_message(
DenyReason::InvalidArguments,
Some("invalid argument shape: unknown field `file`, expected `text`")
),
"Denied: the arguments are not valid for this tool: invalid argument shape: unknown field `file`, expected `text`."
);
assert_eq!(
denial_message(DenyReason::InvalidArguments, Some("invalid path: n/a")),
"Denied: the arguments are not valid for this tool: invalid path: n/a."
);
assert_eq!(
denial_message(DenyReason::NoGrant, Some("x")),
"Denied: no grant allows this call: x.",
"any reason's detail is shown the same way"
);
}
#[test]
fn results_are_cut_on_a_character_boundary_and_marked() {
assert_eq!(cap_result("short", 100), ("short".to_string(), false));
@@ -296,7 +323,8 @@ fn fake_tools_answer_echo_deny_the_rest_and_record_calls() {
assert_eq!(
fake.call(&req(tool, "{}"), &mut on_pending),
ToolResponse::Denied {
reason: DenyReason::NoGrant
reason: DenyReason::NoGrant,
detail: None,
},
"{tool}: the clock is loopd's own now, not the port's"
);