1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! Centralized path construction for the Git registry tree.
//!
//! All schema-versioned path strings and entity file paths are built here.
//! `adapter.rs` must not perform inline string concatenation for entity paths —
//! call these functions instead.
use STORAGE_SCHEMA_VERSION;
// ── Schema versioning ────────────────────────────────────────────────────────
/// Prefix `path` with the current storage schema version.
///
/// Args:
/// * `path`: Relative path within the versioned tree (e.g. `"metadata.json"`).
///
/// Usage:
/// ```ignore
/// let p = versioned("metadata.json"); // "v1/metadata.json"
/// ```
// ── Simple concatenation ─────────────────────────────────────────────────────
/// Append `name` to `parent` with a `/` separator.
///
/// Args:
/// * `parent`: Parent path segment.
/// * `name`: Child path segment to append.
///
/// Usage:
/// ```ignore
/// let p = child("v1/identities/EX/q5", "EXq5..."); // "v1/identities/EX/q5/EXq5..."
/// ```
// ── Identity paths ───────────────────────────────────────────────────────────
/// Path to the events directory for an identity.
///
/// Args:
/// * `identity_base`: Base path returned by `identity_path(prefix)`.
///
/// Usage:
/// ```ignore
/// let dir = events_dir(&base); // "v1/identities/.../events"
/// ```
/// Path to a specific event file.
///
/// Args:
/// * `identity_base`: Base path for the identity.
/// * `seq`: Zero-based sequence number.
///
/// Usage:
/// ```ignore
/// let path = event_file(&base, 3); // "v1/identities/.../events/00000003.json"
/// ```
/// Path to the tip metadata file.
///
/// Args:
/// * `identity_base`: Base path for the identity.
///
/// Usage:
/// ```ignore
/// let path = tip_file(&base); // "v1/identities/.../tip.json"
/// ```
/// Path to the cached key-state file.
///
/// Args:
/// * `identity_base`: Base path for the identity.
///
/// Usage:
/// ```ignore
/// let path = state_file(&base); // "v1/identities/.../state.json"
/// ```
// ── Device / attestation paths ───────────────────────────────────────────────
/// Path to the current (latest) attestation file for a device.
///
/// Args:
/// * `device_base`: Base path returned by `device_path(sanitized_did)`.
///
/// Usage:
/// ```ignore
/// let path = attestation_file(&base); // "v1/devices/.../attestation.json"
/// ```
/// Path to the history directory for a device.
///
/// Args:
/// * `device_base`: Base path for the device.
///
/// Usage:
/// ```ignore
/// let dir = history_dir(&base); // "v1/devices/.../history"
/// ```
/// Path to a single history entry file.
///
/// Args:
/// * `device_base`: Base path for the device.
/// * `entry_id`: Sortable entry identifier (e.g. `"20240101T000000.000_<rid-suffix>"`).
///
/// Usage:
/// ```ignore
/// let path = history_entry_file(&base, &entry_id); // "v1/devices/.../history/<id>.json"
/// ```
// ── Org member paths ─────────────────────────────────────────────────────────
/// Path to the members directory for an org.
///
/// Args:
/// * `org_base`: Base path returned by `org_path(prefix)`.
///
/// Usage:
/// ```ignore
/// let dir = members_dir(&base); // "v1/orgs/.../members"
/// ```
/// Path to a specific org member file.
///
/// Args:
/// * `org_base`: Base path for the org.
/// * `sanitized_member_did`: Sanitized DID string (`:` replaced with `_`).
///
/// Usage:
/// ```ignore
/// let path = member_file(&base, &sanitized_did); // "v1/orgs/.../members/<did>.json"
/// ```