interplane.Get Omega
Read in your language

aien-sovereign-core

Autonomous sovereign intelligence engine and runtime core for NVIDIA DGX Spark

Brought by drakestapleton

branch main Branches Tags History

aien-sovereign-core / scripts / agent-preflight.sh

71 lines · 2578 bytes Raw Blame History
1#!/usr/bin/env bash
2set -eo pipefail
3
4echo "============================================================"
5echo " AIEN Sovereign Agent Preflight Verification Harness "
6echo "============================================================"
7
8FAILED=0
9
10# Step 1: Branch Guard (Zero direct commits to main)
11echo -n "[1/5] Verifying Branch Isolation... "
12CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown")
13if [ "$CURRENT_BRANCH" = "main" ]; then
14 echo "FAILED"
15 echo "Error: Cannot commit directly to main. Create a feature branch (e.g. feat/, fix/)."
16 FAILED=1
17else
18 echo "PASSED (Branch: $CURRENT_BRANCH)"
19fi
20
21# Step 2: Zero Disk Secrets Audit
22echo -n "[2/5] Auditing Zero Disk Secrets... "
23SECRET_FILES=$(find . -maxdepth 3 -name ".env*" -o -name "*.key" -o -name "*secret*" -o -name "*.pem" 2>/dev/null | grep -v ".git" | grep -v "target" || true)
24if [ -n "$SECRET_FILES" ]; then
25 echo "FAILED"
26 echo "Error: Stray plaintext secret files detected on disk:"
27 echo "$SECRET_FILES"
28 FAILED=1
29else
30 echo "PASSED (Zero disk secrets detected)"
31fi
32
33# Step 3: Unslop and Sovereign Voice Audit on Staged / Working Changes
34echo -n "[3/5] Verifying Unslop & Anti-Slop Discipline... "
35DASH_VIOLATIONS=$(git diff HEAD -- ':(exclude)*.lock' ':(exclude)*.svg' ':(exclude)*.bin' 2>/dev/null | grep -E '^\+[^+]' | grep -E '(—|–)' | grep -v "replace" | grep -v "contains" | grep -v "ZERO EM DASHES" | grep -v "forbidden" | grep -v "assert\!" || true)
36if [ -n "$DASH_VIOLATIONS" ]; then
37 echo "FAILED"
38 echo "Error: Prohibited em dash or en dash characters introduced in git diff:"
39 echo "$DASH_VIOLATIONS"
40 FAILED=1
41else
42 echo "PASSED (Zero em/en dashes in diff)"
43fi
44
45# Step 4: Test Suite Verification
46echo "[4/5] Running Workspace Test Suite..."
47if cargo test --workspace; then
48 echo "PASSED (100% test pass)"
49else
50 echo "FAILED (Test suite failed)"
51 FAILED=1
52fi
53
54# Step 5: Vulnerability & Advisory Audit
55echo -n "[5/5] Checking RustSec Vulnerability Advisories... "
56if cargo audit 2>/dev/null; then
57 echo "PASSED (0 advisories)"
58else
59 echo "PASSED WITH WARNINGS (Check cargo audit logs)"
60fi
61
62echo "============================================================"
63if [ "$FAILED" -eq 0 ]; then
64 echo " ✓ PREFLIGHT VERIFICATION COMPLETE: Ready for PR Creation"
65 echo "============================================================"
66 exit 0
67else
68 echo " ✗ PREFLIGHT FAILED: Resolve defects before opening PR"
69 echo "============================================================"
70 exit 1
71fi