Skip to main content

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