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-cli / src / fs_bind_stub.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 | use std::path::{Path, PathBuf}; |
| 17 | |
| 18 | #[derive(Debug)] |
| 19 | pub enum BindError { |
| 20 | Denied(String), |
| 21 | NotFound(String), |
| 22 | Exists(String), |
| 23 | Failed(String), |
| 24 | } |
| 25 | |
| 26 | impl BindError { |
| 27 | pub fn message(&self) -> &str { |
| 28 | match self { |
| 29 | Self::Denied(m) | Self::NotFound(m) | Self::Exists(m) | Self::Failed(m) => m, |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | fn closed(op: &str) -> BindError { |
| 35 | BindError::Denied(format!( |
| 36 | "refusing {op}: filesystem binding is unavailable on this platform" |
| 37 | )) |
| 38 | } |
| 39 | |
| 40 | /// Same allow-list the Linux binder uses. Opening still fails closed. |
| 41 | pub fn permitted_workspaces() -> Vec<PathBuf> { |
| 42 | let mut allowed = crate::platform::PlatformContext::detect().default_workspaces; |
| 43 | allowed.push(PathBuf::from("/tmp")); |
| 44 | allowed |
| 45 | } |
| 46 | |
| 47 | #[derive(Debug)] |
| 48 | pub struct ListedEntry { |
| 49 | pub name: String, |
| 50 | pub is_dir: bool, |
| 51 | pub size_bytes: u64, |
| 52 | } |
| 53 | |
| 54 | #[derive(Debug)] |
| 55 | pub struct HeldFile; |
| 56 | |
| 57 | impl HeldFile { |
| 58 | pub fn authorized(&self) -> &Path { |
| 59 | Path::new("") |
| 60 | } |
| 61 | |
| 62 | pub fn display(&self) -> &str { |
| 63 | "" |
| 64 | } |
| 65 | |
| 66 | pub fn read_checkpoint(&self) -> Result<Option<Vec<u8>>, String> { |
| 67 | Err(closed("read").message().to_string()) |
| 68 | } |
| 69 | |
| 70 | pub fn write_bytes(&self, _content: &[u8], _overwrite: bool) -> Result<bool, BindError> { |
| 71 | Err(closed("write")) |
| 72 | } |
| 73 | |
| 74 | pub fn overwrite_existing(&self, _content: &[u8]) -> Result<(), BindError> { |
| 75 | Err(closed("replace")) |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | pub fn hold_for_write(_path: &str) -> Result<HeldFile, BindError> { |
| 80 | Err(closed("write")) |
| 81 | } |
| 82 | |
| 83 | pub fn read_text(_path: &str) -> Result<(PathBuf, String), BindError> { |
| 84 | Err(closed("read")) |
| 85 | } |
| 86 | |
| 87 | pub fn list_dir(_path: &str) -> Result<(PathBuf, Vec<ListedEntry>), BindError> { |
| 88 | Err(closed("list")) |
| 89 | } |
| 90 | |
| 91 | pub fn make_dir(_path: &str) -> Result<PathBuf, BindError> { |
| 92 | Err(closed("mkdir")) |
| 93 | } |
| 94 | |
| 95 | pub fn grep_search(_path: &str, _query: &str, _limit: usize) -> Result<Vec<String>, BindError> { |
| 96 | Err(closed("grep")) |
| 97 | } |
| 98 | |
| 99 | pub fn find_names(_path: &str, _pattern: &str, _limit: usize) -> Result<Vec<String>, BindError> { |
| 100 | Err(closed("find")) |
| 101 | } |