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 / cortex-path-m1 / src / main.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 chrono::{DateTime, Utc}; |
| 17 | use clap::Parser; |
| 18 | use cortex_path_m1::run::{self, RunOutcome}; |
| 19 | use std::fs; |
| 20 | use std::path::PathBuf; |
| 21 | use std::process::ExitCode; |
| 22 | |
| 23 | #[derive(Parser)] |
| 24 | #[command(name = "cortex-path-m1")] |
| 25 | struct Args { |
| 26 | #[arg(long)] |
| 27 | snapshot: PathBuf, |
| 28 | #[arg(long)] |
| 29 | fixture: PathBuf, |
| 30 | #[arg(long)] |
| 31 | out: PathBuf, |
| 32 | /// RFC3339 timestamp stored with the snapshot. Freshness is measured against this, not the wall clock. |
| 33 | #[arg(long)] |
| 34 | snapshot_time: String, |
| 35 | } |
| 36 | |
| 37 | fn main() -> ExitCode { |
| 38 | let args = Args::parse(); |
| 39 | match execute(&args) { |
| 40 | Ok(ExitCode::SUCCESS) => ExitCode::SUCCESS, |
| 41 | Ok(code) => code, |
| 42 | Err(err) => { |
| 43 | eprintln!("cortex-path-m1: {err}"); |
| 44 | ExitCode::from(1) |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | fn execute(args: &Args) -> Result<ExitCode, String> { |
| 50 | let snapshot_time = DateTime::parse_from_rfc3339(&args.snapshot_time) |
| 51 | .map_err(|err| format!("snapshot-time: {err}"))? |
| 52 | .with_timezone(&Utc); |
| 53 | let fixture_bytes = |
| 54 | fs::read(&args.fixture).map_err(|err| format!("read {}: {err}", args.fixture.display()))?; |
| 55 | let binary_bytes = fs::read(std::env::current_exe().map_err(|err| err.to_string())?) |
| 56 | .map_err(|err| format!("read experiment binary: {err}"))?; |
| 57 | match run::run_experiment(&args.snapshot, &fixture_bytes, snapshot_time, &binary_bytes)? { |
| 58 | RunOutcome::Rejected(rejection) => { |
| 59 | eprintln!("scientific verdict refused"); |
| 60 | for reason in rejection.reasons { |
| 61 | eprintln!("- {reason}"); |
| 62 | } |
| 63 | Ok(ExitCode::from(2)) |
| 64 | } |
| 65 | RunOutcome::Report(report) => { |
| 66 | let json = serde_json::to_string_pretty(&report).map_err(|err| err.to_string())?; |
| 67 | fs::write(&args.out, json) |
| 68 | .map_err(|err| format!("write {}: {err}", args.out.display()))?; |
| 69 | println!( |
| 70 | "wrote {} pass={} strong_pass={} fail={}", |
| 71 | args.out.display(), |
| 72 | report.pass, |
| 73 | report.strong_pass, |
| 74 | report.fail |
| 75 | ); |
| 76 | Ok(ExitCode::SUCCESS) |
| 77 | } |
| 78 | } |
| 79 | } |