cpex_core/extensions/meta.rs
1// Location: ./crates/cpex-core/src/extensions/meta.rs
2// Copyright 2025
3// SPDX-License-Identifier: Apache-2.0
4// Authors: Teryl Taylor
5//
6// MetaExtension — host-provided operational metadata.
7// Mirrors cpex/framework/extensions/meta.py.
8
9use std::collections::{HashMap, HashSet};
10
11use serde::{Deserialize, Serialize};
12
13/// Host-provided operational metadata.
14///
15/// Carries entity identification (type + name) for route resolution,
16/// operational tags for policy group inheritance, scope for
17/// host-defined grouping, and arbitrary properties.
18///
19/// Immutable — set by the host before invoking the hook. Plugins
20/// can read but not modify.
21#[derive(Debug, Clone, Default, Serialize, Deserialize)]
22pub struct MetaExtension {
23 /// Entity type: "tool", "resource", "prompt", "llm".
24 /// Used by the manager for route resolution.
25 #[serde(default)]
26 pub entity_type: Option<String>,
27
28 /// Entity name: "get_compensation", "hr://employees/*", etc.
29 /// Used by the manager for route resolution.
30 #[serde(default)]
31 pub entity_name: Option<String>,
32
33 /// Operational tags — drive policy group inheritance.
34 /// Merged with static tags from the matching route's `meta.tags`.
35 #[serde(default)]
36 pub tags: HashSet<String>,
37
38 /// Host-defined grouping (virtual server ID, namespace, etc.).
39 #[serde(default)]
40 pub scope: Option<String>,
41
42 /// Arbitrary key-value metadata.
43 #[serde(default)]
44 pub properties: HashMap<String, String>,
45}