feat: add principal-scoped typed publication views
Restrict interface order and operation descriptors without changing registry artifacts or dispatch codecs; prune hidden-only types/docs and support typed pre-dispatch provider rejection. Validated host contracts and the dependent workspace suite for T-19.
This commit is contained in:
@@ -14,6 +14,62 @@ use wip_interface::{
|
||||
};
|
||||
use wip_protocol::ProtocolErrorCode;
|
||||
|
||||
#[test]
|
||||
fn principal_projection_orders_subsets_and_rejects_unimplemented_or_duplicate_tokens() {
|
||||
let mut registry = InterfaceRegistry::new();
|
||||
let read = registry.register(ReaderDefinition, None).unwrap();
|
||||
let write = registry.register(WriterDefinition, None).unwrap();
|
||||
let hidden = registry.register(HiddenDefinition, None).unwrap();
|
||||
let publication = || {
|
||||
PublishedObject::new(Document::open("document", None, Rc::new(Cell::new(0))))
|
||||
.expose(&read)
|
||||
.unwrap()
|
||||
.expose(&write)
|
||||
.unwrap()
|
||||
};
|
||||
let projected = publication()
|
||||
.project(
|
||||
&[write.reference().clone(), read.reference().clone()],
|
||||
|_, operation| operation == "label",
|
||||
)
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
projected.protocol_object().interfaces,
|
||||
vec![write.reference().as_str(), read.reference().as_str()]
|
||||
);
|
||||
assert!(
|
||||
publication()
|
||||
.project(&[hidden.reference().clone()], |_, _| true)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
publication()
|
||||
.project(
|
||||
&[read.reference().clone(), read.reference().clone()],
|
||||
|_, _| true
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
publication()
|
||||
.project(&[], |_, _| true)
|
||||
.unwrap()
|
||||
.protocol_object()
|
||||
.interfaces
|
||||
.is_empty()
|
||||
);
|
||||
let full = registry.fetch_interface(read.reference().as_str()).unwrap();
|
||||
let filtered = full
|
||||
.clone()
|
||||
.project_operations(|operation| operation == "label");
|
||||
assert_eq!(filtered.descriptor.operations.len(), 1);
|
||||
assert_eq!(full.descriptor.operations.len(), 3);
|
||||
assert_eq!(
|
||||
registry.fetch_interface(read.reference().as_str()).unwrap(),
|
||||
full
|
||||
);
|
||||
}
|
||||
|
||||
#[interface]
|
||||
pub trait Reader {
|
||||
/// Returns the reader-qualified label.
|
||||
|
||||
Reference in New Issue
Block a user