vta_sdk/contexts.rs
1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
6pub struct ContextRecord {
7 /// The context's materialized path identifier — slash-separated segments
8 /// (e.g. `acme/eng/team-a`). A top-level context is a single segment.
9 pub id: String,
10 pub name: String,
11 pub did: Option<String>,
12 pub description: Option<String>,
13 /// The parent context's id, or `None` for a top-level context. Together
14 /// with [`id`](Self::id) this records the tree; absent on legacy (flat)
15 /// records, which deserialize as top-level.
16 #[serde(default, skip_serializing_if = "Option::is_none")]
17 pub parent: Option<String>,
18 /// BIP-32 derivation base for this context's keys. For a sub-context this
19 /// nests under the parent's base (`{parent.base_path}/<child>'`).
20 pub base_path: String,
21 pub index: u32,
22 pub created_at: DateTime<Utc>,
23 pub updated_at: DateTime<Utc>,
24 /// Per-context policy constraining what context-scoped actors may do within
25 /// this context (see [`crate::context_policy::ContextPolicy`]). Absent on
26 /// legacy records and by default, which imposes no constraints — enforcement
27 /// resolves the policy across the whole ancestor chain, so a missing policy
28 /// at any level simply contributes nothing.
29 #[serde(default, skip_serializing_if = "Option::is_none")]
30 pub context_policy: Option<crate::context_policy::ContextPolicy>,
31}