Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .machine_readable/6a2/STATE.a2ml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# STATE.a2ml — Project state checkpoint
# Copyright (c) 2026 Jonathan D.A. Jewell (hyperpolymath)
# Converted from STATE.scm on 2026-03-15
# Updated: 2026-03-20 (system log analysis session)
# Updated: 2026-04-16 (compile blockers cleared; V-lang migration to Rust confirmed)

[metadata]
project = "ambientops"
version = "0.2.0"
last-updated = "2026-04-04"
last-updated = "2026-04-16"
status = "active"
crg-contracts-rust = "C"
note = "contracts-rust achieved CRG C: 72 tests (15 unit + 12 property + 5 E2E + 12 contract + 13 aspect + 12 benchmarks)"
note = "contracts-rust achieved CRG C: 72 tests (15 unit + 12 property + 5 E2E + 12 contract + 13 aspect + 12 benchmarks). Workspace now green: 195 tests pass across 13 suites, 0 failures."

[project-context]
name = "ambientops"
Expand Down Expand Up @@ -335,8 +335,8 @@ update = "Needs service-autopsy integration"

[next-actions]
priority-1 = [
"Fix HCT main.rs to compile (in progress — other bot)",
"Wire cross-component Evidence Envelope flow end-to-end",
"Expand clinician main.rs: re-wire full subcommand surface (process/network/disk/service/security/mesh/satellite) via clap Subcommand wrappers over tools::*Action enums",
]
priority-2 = [
"WirePlumber BT sentinel — implement D-Bus monitoring (stub exists)",
Expand All @@ -346,3 +346,16 @@ priority-3 = [
"ServiceAutopsy → BundleIngestion integration",
"Add clinician auto-remediation rules to live supervision tree",
]

# ============================================================================
# SESSION: 2026-04-16 — Compile Blocker Clearance
# ============================================================================

[session-2026-04-16]
summary = "Cleared two compile blockers discovered by `check current standing`; workspace now green."
changes = [
"emergency-button/rust/src/main.rs: added .display() to two PathBuf format calls (lines 82, 104)",
"clinician/src/main.rs: rewritten as minimal working dispatcher — imports modules from crate, uses real enum names, stubs non-wired subcommands. Full CLI surface tracked as P1 follow-up.",
]
test-baseline = "cargo test --workspace: 195 passed, 0 failed (13 suites: contracts-rust 47, clinician 15+13+12+5, contracts-rust property 12, aspect 5, E2E 9, hardware-crash-team 77, others 0)"
build-status = "cargo check --workspace: clean (1 unused-import warning in clinician lib)"
81 changes: 51 additions & 30 deletions clinician/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,33 @@

//! Personal Sysadmin (PSA) — AI-Assisted System Administration Toolkit (CLI).
//!
//! This binary implements the "Clinician" logic for Linux environments.
//! It provides a comprehensive suite of administrative tools combined with
//! This binary implements the "Clinician" logic for Linux environments.
//! It provides a comprehensive suite of administrative tools combined with
//! neurosymbolic reasoning to automate problem detection and resolution.
//!
//! CORE CAPABILITIES:
//! 1. **Resource Auditing**: Real-time management of processes, networks,
//! 1. **Resource Auditing**: Real-time management of processes, networks,
//! disks, and services.
//! 2. **AI-Diagnostics**: Uses local SLMs (Small Language Models) with
//! 2. **AI-Diagnostics**: Uses local SLMs (Small Language Models) with
//! cloud LLM fallback to diagnose complex system incidents.
//! 3. **Knowledge Ingestion**: Learns from solutions using miniKanren
//! 3. **Knowledge Ingestion**: Learns from solutions using miniKanren
//! logical reasoning, building a verified administrative knowledge base.
//! 4. **Distributed Tracing**: Uses a global `correlation_id` to link
//! 4. **Distributed Tracing**: Uses a global `correlation_id` to link
//! events across the satellite tool fleet.
//! 5. **P2P Mesh**: Securely shares administrative insights and solutions
//! 5. **P2P Mesh**: Securely shares administrative insights and solutions
//! across a decentralized mesh of PSA nodes.
//!
//! NOTE: This binary is a minimal dispatcher. The rich CLI surface described
//! in the module-level docs is scaffolded in `lib.rs`; wiring each
//! sub-command through clap is tracked as follow-up work.

use ambientops_clinician::{ai, cache, correlation, storage};
use clap::{Parser, Subcommand};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
// ... [other imports]

/// CLI SCHEMA: Defines the subcommand space for the Personal Sysadmin.
#[derive(Parser)]
#[command(name = "psa")]
#[command(name = "psa", version)]
struct Cli {
#[command(subcommand)]
command: Commands,
Expand All @@ -36,44 +40,61 @@ struct Cli {

#[derive(Subcommand)]
enum Commands {
/// RESOURCE MANAGEMENT: Process, Network, Disk, and Service audits.
Process { #[command(subcommand)] action: ProcessActionCli },
Network { #[command(subcommand)] action: NetworkActionCli },
Disk { #[command(subcommand)] action: DiskActionCli },
Service { #[command(subcommand)] action: ServiceActionCli },

/// SECURITY: Scanning, permission auditing, and rootkit detection.
Security { #[command(subcommand)] action: SecurityActionCli },

/// REASONING: AI-assisted diagnosis and autonomous learning.
Diagnose { problem: String, local_only: bool },
Learn { category: String, solution: Option<String> },

/// ORCHESTRATION: P2P mesh control and incident analysis.
Mesh { #[command(subcommand)] action: MeshActionCli },
Crisis { incident: String, correlation_id: Option<String> },
Satellite { #[command(subcommand)] action: SatelliteActionCli },
/// REASONING: AI-assisted diagnosis.
Diagnose {
/// Natural-language description of the problem.
problem: String,
/// Restrict diagnosis to the local SLM (no cloud fallback).
#[arg(long)]
local_only: bool,
},
/// REASONING: Record a solution under a category.
Learn {
/// Category label for the solution (e.g. "disk", "network").
category: String,
/// Optional free-form solution text.
solution: Option<String>,
},
/// Show protocol and binary version.
Version,
}

/// MAIN ENTRY: Boots the async runtime, initializes global state,
/// MAIN ENTRY: Boots the async runtime, initializes global state,
/// and dispatches to tool handlers.
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::registry()
.with(tracing_subscriber::EnvFilter::try_from_default_env()
.unwrap_or_else(|_| "info".into()))
.with(tracing_subscriber::fmt::layer())
.init();

let cli = Cli::parse();

// PROVENANCE: Initialize the correlation context for distributed tracing.
let corr_id = correlation::init(cli.correlation_id.clone());
let _corr_id = correlation::init(cli.correlation_id.clone());

// STORAGE: Establish links to the local knowledge base and state cache.
let storage = storage::Storage::new().await?;
let cache = cache::Cache::new().await?;

// DISPATCH: Executes the requested administrative workflow.
match cli.command {
Commands::Diagnose { problem, local_only } => {
ai::diagnose(&problem, local_only, &storage, &cache).await?;
}
// ... [Remaining handlers]
Commands::Learn { category, solution } => {
println!(
"learn: category={category} solution={}",
solution.as_deref().unwrap_or("(none)")
);
}
Commands::Version => {
println!(
"ambientops-clinician {} (protocol {})",
env!("CARGO_PKG_VERSION"),
ambientops_clinician::PROTOCOL_VERSION
);
}
}
Ok(())
}
4 changes: 2 additions & 2 deletions emergency-button/rust/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn run_trigger(args: TriggerArgs) {
}
};

println!("\x1b[32m[OK]\x1b[0m Created incident bundle: {}", inc.path);
println!("\x1b[32m[OK]\x1b[0m Created incident bundle: {}", inc.path.display());
println!("\x1b[34m[INFO]\x1b[0m Correlation ID: {}", inc.correlation_id);
println!();

Expand All @@ -101,7 +101,7 @@ fn run_trigger(args: TriggerArgs) {

println!();
println!("\x1b[32m════════════════════════════════════════════\x1b[0m");
println!("\x1b[32m[DONE]\x1b[0m Incident bundle ready: {}", inc.path);
println!("\x1b[32m[DONE]\x1b[0m Incident bundle ready: {}", inc.path.display());
println!("\x1b[32m════════════════════════════════════════════\x1b[0m");
}

Expand Down
Loading