Skip to main content

Deterministic State-Guardrails for Agentic Hardware

Project description

🛡️ SilverAi

Deterministic State-Guardrails for Agentic Hardware & Critical Systems.

SilverAi CI License: Apache 2.0 Python 3.10+

"You wouldn't let a drunk person drive a forklift. Why let a probabilistic LLM drive your physical hardware?"

🚨 The Problem

Large Language Models (LLMs) like GPT-4, DeepSeek, and Claude are Probabilistic Engines. They are optimized for creativity, not safety.

When connecting Agents to Physical Hardware (IoT/Robotics) or Financial Systems, "99% accuracy" is not enough. A single hallucination can cause:

  • Physical Damage: Ignoring battery/thermal limits on a device.
  • Operational Failure: Attempting to control a disconnected device over BLE/MQTT.
  • Financial Risk: Hallucinating discounts or executing unauthorized transactions.

Existing solutions (Bedrock Guardrails, NeMo) focus on Semantic Safety (profanity, PII). They are blind to State Safety.

⚡ The Solution

SilverAi is a lightweight, dependency-free Python middleware that enforces Deterministic Contracts on your Agent's tools. It sits between the LLM's intent and your system's execution.

✨ Key Features

  • 🐍 Pythonic Decorators: Clean, readable syntax using @guard.
  • 🔌 Connectivity Gates: Prevents Agents from calling APIs when the device is offline (BLE, WiFi).
  • 🔋 State-Aware: Validates against real-time telemetry (Battery, Heat) before execution.
  • 🧪 Dry-Run Mode: Test your safety logic in CI/CD without requiring physical hardware or live APIs.

🚀 Quick Start

Installation

pip install silver-ai

Usage: Protecting a Robot

Prevent an Agent from moving a robot if the battery is critical or the connection is unstable.

from silver_ai import guard, rules

class IndustrialRobot:
    def __init__(self):
        # In production, this state comes from live telemetry
        self.state = {
            "battery": 10, 
            "connection": "offline",
            "is_stuck": False
        }

    @guard(
        rules.BatteryMin(15),
        rules.RequireConnectivity(protocol="BLE")
    )
    def start_operation(self, zone: str):
        # 🛑 This code NEVER runs because battery (10) < 15
        # AND the device is offline.
        hardware_driver.move_to(zone)

The Agent receives this structured rejection (instead of crashing):

{
  "status": "error",
  "reason": "Battery critical: 10%. Required: 15%.",
  "suggestion": "Connect device to charger before proceeding.",
  "dry_run": false
}

🏛️ Architecture

SilverAi acts as the "Prefrontal Cortex" for your Agent. It is a logical check before impulsive actions.

graph LR
    A[User Request] --> B[LLM / Agent]
    B -->|Unsafe Intent| C{SilverAi Guard}
    C -- Fails Rules --> D[Block & Explain]
    D -->|Feedback Loop| B
    C -- Passes Rules --> E[Execute Hardware API]

🧪 Simulation & Testing (No Hardware Required)

One of the hardest parts of IoT development is testing failure states (e.g., "What happens if the battery dies halfway?"). SilverAi provides a DryRun harness to test safety logic instantly.

graph TD
    Start[Agent Request] --> Check{Safety Rules}
    Check -- Unsafe --> Fail[Return Error]
    Check -- Safe --> Mode{Dry Run Active?}
    Mode -- Yes --> Dry[Return 'Success: Simulated']
    Mode -- No --> Real[Execute Real Hardware]
from my_robot import IndustrialRobot

def test_safety_stops_low_battery():
    # 1. Instantiate the robot
    robot = IndustrialRobot()
    
    # 2. Inject dangerous state
    robot.state = {"battery": 5, "connection": "online"}
    
    # 3. Activate Dry Run 
    # This ensures hardware is skipped even if a rule accidentally passes.
    robot._silver_dry_run = True 
    
    # 4. Run the function
    result = robot.start_operation("Zone A")
    
    # 5. Assert that SilverAI caught it
    assert result['status'] == 'error'
    assert "Battery" in result['reason']

🛠️ Development on Local Machine

This project uses Poetry for dependency management and Ruff for strict code quality.

1. Prerequisities

  • Python 3.11+;
  • Poetry installed.
    pip install poetry
    

2. Setup

Clone the repo and install dependencies (including the virtual environment):

git clone https://github.com/gcl-team/SilverAi.git
cd SilverAi
poetry install

3. Running the Demo

We provide a demo.py to showcase the behavior (Success, Failure, Dry Run, Exception).

poetry run python demo.py

4. Running

We use pytest for unit testing.

poetry run pytest

5. Linting & Security

We use ruff to enforce PEP8, import sorting, and Bandit security rules.

poetry run ruff check .

🤝 Contributing

We welcome your contributions! Bug reports and feature suggestions are encouraged. Open issues or submit pull requests via Project Issues.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

silver_ai-0.1.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

silver_ai-0.1.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file silver_ai-0.1.2.tar.gz.

File metadata

  • Download URL: silver_ai-0.1.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for silver_ai-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1d83afac6ff4a8e5c76a9a4059fc8b8a276bd822bdc2fc1102b91c152a23790e
MD5 a07279eebb837793d0b49d414122c65b
BLAKE2b-256 f72f42fda99a79d82db520af411186d0807e4974e4adfba6a52fe44fa76e4399

See more details on using hashes here.

Provenance

The following attestation bundles were made for silver_ai-0.1.2.tar.gz:

Publisher: release.yml on gcl-team/SilverAi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file silver_ai-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: silver_ai-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for silver_ai-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3c3a4cda023b89e0b8a3e6d469efba7a81967dd30844452e4b9e364869dee790
MD5 57498525c5e4b4b1de6abbeef1a731d9
BLAKE2b-256 40bedc31b0dbc762fd268616e003283f210be3bd058d4992d19cd1c9d842bf46

See more details on using hashes here.

Provenance

The following attestation bundles were made for silver_ai-0.1.2-py3-none-any.whl:

Publisher: release.yml on gcl-team/SilverAi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page