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
//! Structured errors for the SM goal store (DOC-14 §9).
//!
//! Why: SM-6 is library code in `trusty-mpm-core`; per the workspace convention
//! library failures surface as typed, matchable `thiserror` enums rather than
//! `unwrap()`/`panic!`. The two operator-facing failure modes — an unknown goal
//! id and a verification-gate rejection (§3.5) — must be DISTINCT variants so the
//! future endpoint/loop (SM-7/SM-8) can render a precise message; the I/O and
//! palace surfaces degrade gracefully so a missing cache or unavailable palace
//! never crashes the daemon.
//! What: [`SmGoalError`] wraps not-found, the verification-gate rejection, cache
//! I/O, JSON (de)serialisation, and palace-memory failures, preserving the source
//! chain where one exists.
//! Test: `goals/store_tests.rs` asserts the `NotFound` and `VerificationGate`
//! variants on their respective paths; happy paths assert `Ok`.
/// Structured errors for goal-store operations (library → `thiserror`).
///
/// Why: see the module docs — distinct, matchable variants for the gate and
/// not-found cases, plus graceful wrappers for the persistence surfaces.
/// What: the five failure modes of the goal store.
/// Test: `close_without_all_verified_is_rejected` (gate),
/// `link_unknown_goal_is_not_found` (not-found).
/// Result alias for goal-store operations.
///
/// Why: keeps the public signatures terse and consistent with the rest of the
/// `sm` module (mirrors `SmMemoryResult` / `ConversationStoreResult`).
/// What: `Result<T, SmGoalError>`.
/// Test: used throughout `goals/store_tests.rs`.
pub type SmGoalResult<T> = Result;