diff --git a/crates/wip-host/src/lib.rs b/crates/wip-host/src/lib.rs index c049dcb..935e8ce 100644 --- a/crates/wip-host/src/lib.rs +++ b/crates/wip-host/src/lib.rs @@ -160,7 +160,9 @@ impl InterfaceRegistry { /// /// `validator` should be present when the host intends the reference to /// represent a versioned descriptor. Its presence makes the same value a - /// mandatory precondition for dispatch. + /// mandatory precondition for dispatch. Registration finalizes the + /// descriptor's protocol `name` to the assigned opaque reference so it + /// corresponds directly to [`Object::interfaces`]. pub fn register( &mut self, _definition: D, @@ -174,7 +176,7 @@ impl InterfaceRegistry { return Err(RegistrationError::AlreadyRegistered); } - let descriptor = D::descriptor(); + let mut descriptor = D::descriptor(); descriptor .validate() .map_err(RegistrationError::InvalidDescriptor)?; @@ -183,6 +185,11 @@ impl InterfaceRegistry { "wip-interface:{}:{}", self.namespace, self.next_reference )); + // The protocol model currently carries the interface identifier in the + // descriptor's `name` field. Finalize that identity to the same opaque + // reference placed on published objects; the generated Rust trait name + // is registration-local metadata, not wire identity. + descriptor.name = reference.0.clone(); self.next_reference = self .next_reference .checked_add(1) diff --git a/crates/wip-host/tests/host.rs b/crates/wip-host/tests/host.rs index 2106b46..49439c7 100644 --- a/crates/wip-host/tests/host.rs +++ b/crates/wip-host/tests/host.rs @@ -165,7 +165,7 @@ fn registry_exposes_opaque_validated_descriptor_observations() { assert_ne!(reader.reference().as_str(), "Reader"); let observation = registry.observe(reader.reference()).unwrap(); assert_eq!(observation.reference, *reader.reference()); - assert_eq!(observation.descriptor.name, "Reader"); + assert_eq!(observation.descriptor.name, reader.reference().as_str()); assert_eq!(observation.validator, None); observation.descriptor.validate().unwrap(); @@ -197,6 +197,15 @@ fn publication_is_explicit_ordered_qualified_and_request_scoped() { reader.reference().as_str().to_owned() ] ); + wip_protocol::InterfaceObservation { + object: object.clone(), + descriptors: vec![ + registry.observe(writer.reference()).unwrap().descriptor, + registry.observe(reader.reference()).unwrap().descriptor, + ], + } + .validate() + .unwrap(); assert!(!format!("{object:?}").contains("private/backend/path")); let writer_result = publication