interplane.Get Omega
Read in your language

aien-sovereign-core-mv

AienOS host runtime: inference scheduling, paged KV state, the aien CLI and Spark verification tooling. Its inference engine is in alpha testing (DGX Spark GB10); Omega is the implementation destination.

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core-mv / crates / aien-allen-memory / src / refusal.rs

92 lines · 4342 bytes Raw Blame History
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16//! Every way a memory operation can say no, in plain words.
17use std::fmt;
18
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub enum MemoryRefusal {
21 /// ALLEN is not engaged: there is no identity to attach memory to.
22 NotEngaged,
23 /// A stored record names another agent or root than the engaged identity.
24 ForeignMemory(String),
25 /// A stored file is damaged, has an unknown schema or field, is oversize, or breaks the chain.
26 Damaged(String),
27 /// A requested value is not allowed.
28 Invalid(String),
29 UnknownItem(String),
30 /// The item was forgotten (or a forget is pending); it cannot be changed.
31 ItemForgotten(String),
32 NotAGoal(String),
33 /// The caller's grant is for a different scope than the item's.
34 ScopeMismatch(String),
35 /// Nothing matched a forget request.
36 NothingToForget,
37 /// The item's key is missing or damaged, so its content cannot be read.
38 KeyUnavailable(String),
39 /// The ciphertext or the record data it is bound to was changed.
40 Tampered(String),
41 /// Another writer appended first.
42 Conflict,
43 Io(String),
44 /// Test seam only (feature `fault-injection`): the write was stopped on purpose.
45 Crashed(String),
46}
47
48impl MemoryRefusal {
49 pub fn code(&self) -> &'static str {
50 use MemoryRefusal::*;
51 match self {
52 NotEngaged => "not_engaged",
53 ForeignMemory(_) => "foreign_memory",
54 Damaged(_) => "damaged",
55 Invalid(_) => "invalid",
56 UnknownItem(_) => "unknown_item",
57 ItemForgotten(_) => "item_forgotten",
58 NotAGoal(_) => "not_a_goal",
59 ScopeMismatch(_) => "scope_mismatch",
60 NothingToForget => "nothing_to_forget",
61 KeyUnavailable(_) => "key_unavailable",
62 Tampered(_) => "tampered",
63 Conflict => "conflict",
64 Io(_) => "io",
65 Crashed(_) => "crashed",
66 }
67 }
68}
69
70impl fmt::Display for MemoryRefusal {
71 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
72 use MemoryRefusal::*;
73 match self {
74 NotEngaged => write!(f, "ALLEN is not engaged on this machine, so there is no identity to attach memory to. Nothing was changed."),
75 ForeignMemory(w) => write!(f, "The saved memory belongs to a different ALLEN identity ({w}). It was not used or changed."),
76 Damaged(w) => write!(f, "The saved memory is damaged or not understood ({w}). It was not replaced; ask the operator to inspect the memory folder."),
77 Invalid(w) => write!(f, "Not allowed: {w}. Nothing was changed."),
78 UnknownItem(i) => write!(f, "There is no memory item {i}. Nothing was changed."),
79 ItemForgotten(i) => write!(f, "Item {i} was forgotten (or is being forgotten) and cannot be changed."),
80 NotAGoal(i) => write!(f, "Item {i} is not a goal. Nothing was changed."),
81 ScopeMismatch(i) => write!(f, "Your access covers a different scope than {i}. Nothing was changed."),
82 NothingToForget => write!(f, "No live memory matched. Nothing was forgotten."),
83 KeyUnavailable(i) => write!(f, "The key for item {i} is missing or damaged, so its content cannot be read."),
84 Tampered(i) => write!(f, "Item {i} failed its integrity check (ciphertext or bound data changed). It was not used."),
85 Conflict => write!(f, "Another writer changed the memory first. Nothing was changed; try again."),
86 Io(w) => write!(f, "Could not read or write the memory store: {w}."),
87 Crashed(w) => write!(f, "write stopped on purpose (test): {w}"),
88 }
89 }
90}
91
92impl std::error::Error for MemoryRefusal {}