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
aien-sovereign-core-mv / crates / aien-abi-core / tests / kv_seam_defaults.rs
| 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 | //! C6a (sc#484, ADR 0003 sections 6.1 to 6.3): the backend trait gains two |
| 17 | //! hooks for persistent KV, `computed_prefix` and `restore_sequence`. A backend |
| 18 | //! that implements neither must behave as it does today: it reports no |
| 19 | //! computed prefix (so nothing is ever parked from it) and refuses a restore |
| 20 | //! (so a restored prefix can never be admitted on a backend that cannot honour |
| 21 | //! it). |
| 22 | |
| 23 | use aien_abi_core::{AienInferenceBackend, DecodeOutput, ModelConfig, ScheduledBatch, StepMetrics}; |
| 24 | use async_trait::async_trait; |
| 25 | |
| 26 | struct Bare; |
| 27 | |
| 28 | #[async_trait] |
| 29 | impl AienInferenceBackend for Bare { |
| 30 | async fn load_model(&mut self, _config: &ModelConfig) -> Result<(), String> { |
| 31 | Ok(()) |
| 32 | } |
| 33 | |
| 34 | async fn execute_step( |
| 35 | &mut self, |
| 36 | _batch: &ScheduledBatch, |
| 37 | ) -> Result<(Vec<DecodeOutput>, StepMetrics), String> { |
| 38 | Ok((Vec::new(), StepMetrics::default())) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | #[test] |
| 43 | fn restore_sequence_defaults_to_err() { |
| 44 | let mut backend = Bare; |
| 45 | let refusal = backend |
| 46 | .restore_sequence(0x1_0000_0001, &[1, 2, 3]) |
| 47 | .expect_err("a backend that does not override restore_sequence must refuse"); |
| 48 | assert!( |
| 49 | refusal.contains("restore_sequence"), |
| 50 | "the refusal names the hook so a log says what is missing: {refusal}" |
| 51 | ); |
| 52 | } |
| 53 | |
| 54 | #[test] |
| 55 | fn computed_prefix_defaults_to_none() { |
| 56 | let backend = Bare; |
| 57 | assert_eq!( |
| 58 | backend.computed_prefix(0x1_0000_0001), |
| 59 | None, |
| 60 | "no override means no claim about which positions hold K/V" |
| 61 | ); |
| 62 | } |