Deterministic state-guardrails for agentic hardware & critical systems.
Project description
🛡️ SilverAi
Deterministic Pre-flight validation for AI agents controlling hardware.
A governance layer to catch AI agent mistakes before they reach your hardware.
🚨 The Problem
Large Language Models (LLMs) are probabilistic, but hardware is deterministic. SilverAi is a lightweight Python middleware that acts as a "bouncer at the door". It validates Agent requests against the current state snapshot of your system before execution, preventing obvious hallucinations from becoming physical actions.
Where SilverAi Helps
- Smart Home/Office Automation: Preventing agents from triggering devices during "do not disturb" modes;
- Warehouse Batch Operations: Validating battery and connectivity status before starting a non-critical routine;
- Prototyping & Development: Making the development of Agentic IoT safer by catching logic errors early.
⚡ The Solution
SilverAi is a lightweight, dependency-free Python middleware that enforces pre-flight validation on the tools of your AI agent. It sits between the LLM intent and the execution of your system.
✨ 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")
# rules.TransactionLimit(amount=50)
)
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 is part of a Defense-in-Depth strategy. It validates agent intent so your lower-level systems do not have to.
graph TD
A[AI Agent Intent] --> B{SilverAi Governance}
B -- Invalid --> C[Reject & Feedback]
B -- Valid --> D[Hardware Controller]
D --> E{Physical Safety System / PLC}
E --> F[Execution]
🧪 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[AI 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 silver_ai.core import DRY_RUN_FLAG
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. Enable Safety Override (Dry Run)
# We manually flag this instance for simulation
setattr(robot, DRY_RUN_FLAG, 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. Prerequisites
- 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 .
⚠️ Important Limitations (Read Before Use)
SilverAi is a Software Governance Layer, not a real-time safety system.
- Not for Real-Time: Adds ~50-200ms latency. Works best for batch operations and control loops >500ms;
- Pre-flight only: Validates the intent before execution. It does not provide continuous monitoring during the action;
- Defense-in-Depth: SilverAi should be one layer of many. It does not replace hardware-level E-stops or PLC safety logic.
❌ NEVER Use for: Automotive, Medical Devices, Collision Avoidance, or any system where failure results in injury.
🤝 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file silver_ai-0.1.8.tar.gz.
File metadata
- Download URL: silver_ai-0.1.8.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c2156429c5372aa7e7274df59a8ad7f36177b36ca84f54f048c98bfe85d7504
|
|
| MD5 |
662b0df9d01068f0accea4d38dac02ce
|
|
| BLAKE2b-256 |
179ada903cc874bb1cd4cacdf6b538092f0269f59f086882964d467ce7428061
|
Provenance
The following attestation bundles were made for silver_ai-0.1.8.tar.gz:
Publisher:
release.yml on gcl-team/SilverAi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
silver_ai-0.1.8.tar.gz -
Subject digest:
3c2156429c5372aa7e7274df59a8ad7f36177b36ca84f54f048c98bfe85d7504 - Sigstore transparency entry: 1489021152
- Sigstore integration time:
-
Permalink:
gcl-team/SilverAi@6d9fbb7fff683adc1a8bbd64df85ac0b7b3526ed -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/gcl-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6d9fbb7fff683adc1a8bbd64df85ac0b7b3526ed -
Trigger Event:
release
-
Statement type:
File details
Details for the file silver_ai-0.1.8-py3-none-any.whl.
File metadata
- Download URL: silver_ai-0.1.8-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
60bd3d77ed4fd3694bd76a2496d596299b8b243440e83870a576ad1263ef23a9
|
|
| MD5 |
256c042c614323408a73e1fcddb90edb
|
|
| BLAKE2b-256 |
1f31056d8e05549fc15be53ce616a52e29c2596ae35bb777199f499d601b3e26
|
Provenance
The following attestation bundles were made for silver_ai-0.1.8-py3-none-any.whl:
Publisher:
release.yml on gcl-team/SilverAi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
silver_ai-0.1.8-py3-none-any.whl -
Subject digest:
60bd3d77ed4fd3694bd76a2496d596299b8b243440e83870a576ad1263ef23a9 - Sigstore transparency entry: 1489022744
- Sigstore integration time:
-
Permalink:
gcl-team/SilverAi@6d9fbb7fff683adc1a8bbd64df85ac0b7b3526ed -
Branch / Tag:
refs/tags/v0.1.8 - Owner: https://github.com/gcl-team
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6d9fbb7fff683adc1a8bbd64df85ac0b7b3526ed -
Trigger Event:
release
-
Statement type: