Skip to main content

vta_sdk/protocols/
memory.rs

1//! Wire payloads for the agent-memory Trust Tasks
2//! (`spec/vta/memory/{put,list,delete}/0.1`).
3//!
4//! A per-context key/value store for AI-agent memory: `put` upserts a value
5//! under a `(contextId, key)` pair, `list` enumerates every entry in a context,
6//! and `delete` removes one by key. The three request bodies carry
7//! `deny_unknown_fields` as a forward-compat guard; all fields are camelCase on
8//! the wire.
9//!
10//! Access is gated on **context** (not operator step-up like the issued-
11//! credential slice): the caller must be permitted to act in `contextId` — the
12//! same context-ACL check the context-scoped key tasks use
13//! ([`AuthClaims::require_context`] server-side). This enforces per-domain
14//! memory isolation: a context-A agent cannot read, write, or delete context-B
15//! memory.
16
17use serde::{Deserialize, Serialize};
18
19/// `spec/vta/memory/put/0.1` request body. Upsert: re-putting the same
20/// `(contextId, key)` replaces the stored value.
21#[derive(Debug, Clone, Serialize, Deserialize)]
22#[serde(rename_all = "camelCase", deny_unknown_fields)]
23pub struct MemoryPutBody {
24    /// The context the entry belongs to. The caller must have ACL access to it.
25    pub context_id: String,
26    /// The entry key (unique within the context).
27    pub key: String,
28    /// The value to store.
29    pub value: String,
30}
31
32/// `spec/vta/memory/put/0.1` response body.
33#[derive(Debug, Clone, Serialize, Deserialize)]
34#[serde(rename_all = "camelCase")]
35pub struct MemoryPutResponse {
36    /// The key that was upserted.
37    pub key: String,
38}
39
40/// `spec/vta/memory/list/0.1` request body.
41#[derive(Debug, Clone, Serialize, Deserialize)]
42#[serde(rename_all = "camelCase", deny_unknown_fields)]
43pub struct MemoryListBody {
44    /// The context whose entries to list. The caller must have ACL access to it.
45    pub context_id: String,
46}
47
48/// A single stored memory entry returned by `spec/vta/memory/list/0.1`.
49#[derive(Debug, Clone, Serialize, Deserialize)]
50#[serde(rename_all = "camelCase")]
51pub struct MemoryItem {
52    /// The entry key.
53    pub key: String,
54    /// The stored value.
55    pub value: String,
56}
57
58/// `spec/vta/memory/list/0.1` response body.
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(rename_all = "camelCase")]
61pub struct MemoryListResponse {
62    /// Every entry in the context, in ascending key order.
63    pub items: Vec<MemoryItem>,
64}
65
66/// `spec/vta/memory/delete/0.1` request body.
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(rename_all = "camelCase", deny_unknown_fields)]
69pub struct MemoryDeleteBody {
70    /// The context the entry belongs to. The caller must have ACL access to it.
71    pub context_id: String,
72    /// The entry key to delete. `not_found` if absent.
73    pub key: String,
74}
75
76/// `spec/vta/memory/delete/0.1` response body.
77#[derive(Debug, Clone, Serialize, Deserialize)]
78#[serde(rename_all = "camelCase")]
79pub struct MemoryDeleteResponse {
80    /// The key that was deleted.
81    pub key: String,
82}