pub struct SkillRegistry { /* private fields */ }Expand description
The broker’s registry of admitted skills.
Registration is the trust boundary: the broker takes an Admission
(already verified by ) and the skill’s code bytes, pins the
code hash, and only then lists the skill. Every lookup can re-verify
the code against the pinned hash to detect drift.
Implementations§
Source§impl SkillRegistry
impl SkillRegistry
Sourcepub fn register(
&mut self,
admission: Admission,
code: &[u8],
) -> Result<SkillId, Error>
pub fn register( &mut self, admission: Admission, code: &[u8], ) -> Result<SkillId, Error>
Register an admitted skill with its code bytes.
The code hash is computed from the actual bytes and pinned.
If a skill with the same id is already registered, registration
is refused — even if the code hash matches. Silent re-registration
would let a caller swap a skill’s code without any signal; the
explicit unregister + register sequence is the only update
path (both are auditable broker operations).
§Errors
Returns Error::AlreadyRegistered if the id is already
registered.
Sourcepub fn unregister(&mut self, id: &SkillId) -> bool
pub fn unregister(&mut self, id: &SkillId) -> bool
Remove a skill from the registry by id.
This is the explicit half of the update path: unregister then
register replaces a skill’s code with a clear audit trail.
Returns true if a skill was removed, false if the id was
not registered.
Sourcepub fn get(&self, id: &SkillId) -> Option<&RegisteredSkill>
pub fn get(&self, id: &SkillId) -> Option<&RegisteredSkill>
Look up a registered skill by id.
Sourcepub fn verify_code(&self, id: &SkillId, code: &[u8]) -> Result<(), Error>
pub fn verify_code(&self, id: &SkillId, code: &[u8]) -> Result<(), Error>
Verify code bytes against the pinned hash for a registered skill.
Call this at load time and at call time: if the code on disk (or presented by the cell) doesn’t match the pinned hash, the skill has drifted and must be refused.
§Errors
Returns Error::UnknownSkill if the id is not registered.
Returns Error::IdentityDrift if the hash doesn’t match.