fix(host): align descriptor and publication identity

This commit is contained in:
2026-09-28 23:44:43 +09:00
parent 32f3fb6fb1
commit f9f083d4c6
2 changed files with 19 additions and 3 deletions
+9 -2
View File
@@ -160,7 +160,9 @@ impl InterfaceRegistry {
/// ///
/// `validator` should be present when the host intends the reference to /// `validator` should be present when the host intends the reference to
/// represent a versioned descriptor. Its presence makes the same value a /// 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<D>( pub fn register<D>(
&mut self, &mut self,
_definition: D, _definition: D,
@@ -174,7 +176,7 @@ impl InterfaceRegistry {
return Err(RegistrationError::AlreadyRegistered); return Err(RegistrationError::AlreadyRegistered);
} }
let descriptor = D::descriptor(); let mut descriptor = D::descriptor();
descriptor descriptor
.validate() .validate()
.map_err(RegistrationError::InvalidDescriptor)?; .map_err(RegistrationError::InvalidDescriptor)?;
@@ -183,6 +185,11 @@ impl InterfaceRegistry {
"wip-interface:{}:{}", "wip-interface:{}:{}",
self.namespace, self.next_reference 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 self.next_reference = self
.next_reference .next_reference
.checked_add(1) .checked_add(1)
+10 -1
View File
@@ -165,7 +165,7 @@ fn registry_exposes_opaque_validated_descriptor_observations() {
assert_ne!(reader.reference().as_str(), "Reader"); assert_ne!(reader.reference().as_str(), "Reader");
let observation = registry.observe(reader.reference()).unwrap(); let observation = registry.observe(reader.reference()).unwrap();
assert_eq!(observation.reference, *reader.reference()); 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); assert_eq!(observation.validator, None);
observation.descriptor.validate().unwrap(); observation.descriptor.validate().unwrap();
@@ -197,6 +197,15 @@ fn publication_is_explicit_ordered_qualified_and_request_scoped() {
reader.reference().as_str().to_owned() 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")); assert!(!format!("{object:?}").contains("private/backend/path"));
let writer_result = publication let writer_result = publication